[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-pim
Subject:    Re: [Kde-pim] korganizer patch
From:       Bo Thorsen <bo () sonofthor ! dk>
Date:       2002-12-10 11:38:09
[Download RAW message or body]

On Thursday 28 November 2002 17:37, Cornelius Schumacher wrote:
> On Thursday 28 November 2002 16:45, Bo Thorsen wrote:
> > This is the first patch I have come up with. It solves a problem that
> > is introduced in kroupware branch because there is stuff we need to
> > set up that is also set up in koapp. The solution was to move this to
> > a file in it's own. I have already checked this solution into
> > kroupware_branch and made the necessary change to kokroupware.cpp.
>
> This looks good, but I would like to slightly change the semantic of
> the new class. I was planning to put all the code for communication
> with the alarm daemon in an own class anyway, so I would like to rename
> it from KOAppShared to AlarmClient. Would that be ok?

Finally getting back to this.

Can I commit the alarmclient.* files and change koapp.cpp to use this in
HEAD? The diff is in kroupware_branch but I guess you won't have a problem
with seeing what the idea is.

Index: Makefile.am
===================================================================
RCS file: /home/kde/kdepim/korganizer/Makefile.am,v
retrieving revision 1.195.2.16
diff -u -p -r1.195.2.16 Makefile.am
--- Makefile.am	28 Nov 2002 14:59:30 -0000	1.195.2.16
+++ Makefile.am	10 Dec 2002 11:33:16 -0000
@@ -46,7 +46,7 @@ libkorganizer_la_SOURCES =  outgoingdial
 	komailclient.cpp kotodoview.cpp kotodoviewitem.cpp \
         kolistview.cpp \
         exportwebdialog.cpp htmlexport.cpp \
-        koapp.cpp koappshared.cpp korganizer_part.cpp korganizer.cpp \
+        koapp.cpp alarmclient.cpp korganizer_part.cpp korganizer.cpp \
         koprefsdialog.cpp \
         koincidenceeditor.cpp koeventeditor.cpp kotodoeditor.cpp \
         koprefs.cpp koeventviewer.cpp kowindowlist.cpp \
@@ -85,8 +85,8 @@ noinst_HEADERS = komonthview.h \
 	searchdialog.h calprinter.h \
 	archivedialog.h \
 	komailclient.h kotodoview.h \
-        kolistview.h \
-	koapp.h koappshared.h exportwebdialog.h korganizer_part.h korganizer.h \
+        kolistview.h koapp.h alarmclient.h \
+	exportwebdialog.h korganizer_part.h korganizer.h \
         koprefsdialog.h koeventeditor.h \
         kotodoeditor.h koprefs.h koeventviewer.h \
         kowindowlist.h kocounterdialog.h \
Index: alarmclient.cpp
===================================================================
RCS file: alarmclient.cpp
diff -N alarmclient.cpp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ alarmclient.cpp	10 Dec 2002 11:33:16 -0000
@@ -0,0 +1,62 @@
+#include "alarmclient.h"
+
+#include "kalarmd/alarmdaemoniface_stub.h"
+
+#include <kstandarddirs.h>
+#include <kprocess.h>
+#include <dcopclient.h>
+#include <kapplication.h>
+#include <kdebug.h>
+
+#include <qstring.h>
+#include <qfile.h>
+
+
+void AlarmClient::startAlarmDaemon()
+{
+  if( kapp->dcopClient()->isApplicationRegistered( "kalarmd" ) )
+    // Alarm daemon already registered
+    return;
+
+  // Start alarmdaemon. It is a KUniqueApplication, that means it is
+  // automatically made sure that there is only one instance of the alarm daemon
+  // running.
+  QString execStr = locate( "exe", "kalarmd" );
+  system( QFile::encodeName( execStr ) );
+}
+
+void AlarmClient::startAlarmClient()
+{
+  if( kapp->dcopClient()->isApplicationRegistered( "korgac" ) )
+    // Alarm daemon already registered
+    return;
+
+  KProcess *proc = new KProcess;
+  *proc << "korgac";
+  *proc << "--miniicon" <<  "korganizer";
+  connect( proc, SIGNAL( processExited( KProcess* ) ),
+           instance(), SLOT( startCompleted( KProcess* ) ) );
+  if( !proc->start() )
+    delete proc;
+
+  // Register this application with the alarm daemon
+  AlarmDaemonIface_stub stub( "kalarmd", "ad" );
+  stub.registerApp( "korgac", "KOrganizer", "ac", 3, true );
+  if( !stub.ok() )
+    kdDebug() << "AlarmClient::startAlarmClient(): dcop send failed" << endl;
+}
+
+void AlarmClient::startCompleted( KProcess* process )
+{
+  delete process;
+}
+
+AlarmClient* AlarmClient::instance()
+{
+  static AlarmClient *singleton = 0;
+
+  if( singleton == 0 )
+    singleton = new AlarmClient();
+
+  return singleton;
+}
Index: alarmclient.h
===================================================================
RCS file: alarmclient.h
diff -N alarmclient.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ alarmclient.h	10 Dec 2002 11:33:16 -0000
@@ -0,0 +1,44 @@
+#ifndef ALARMCLIENT_H
+#define ALARMCLIENT_H
+
+#include <qobject.h>
+
+class KProcess;
+
+/**
+ * This class is used by KOrganizerApp and KOrganizerPart to initialize
+ * KOrganizer alarmd usage. It's possible that more code could be moved
+ * to this class later.
+ *
+ * Since this is code that should only run during initialization, it's a 
+ * singleton class. Actually only static methods are public now, so the
+ * instance() method is private too. Change this if necessary.
+ *
+ * When code is shared between init of the two, it should go into this class.
+ *
+ */
+class AlarmClient : public QObject {
+  Q_OBJECT
+
+public:
+  /** Start alarm daemon from KDE binary directory */
+  static void startAlarmDaemon();
+
+  /** Start alarm client from KDE binary directory */
+  static void startAlarmClient();
+
+private slots:
+  void startCompleted( KProcess * );
+
+private:
+  static AlarmClient* instance();
+
+  AlarmClient() : QObject() {}
+  AlarmClient( const AlarmClient& );
+  AlarmClient& operator=( const AlarmClient& );
+
+  class gccShouldNotWarnAboutPrivateConstructors;
+  friend class gccShouldNotWarnAboutPrivateConstructors;
+};
+
+#endif // ALARMCLIENT_H
Index: koapp.cpp
===================================================================
RCS file: /home/kde/kdepim/korganizer/koapp.cpp,v
retrieving revision 1.56.2.3
diff -u -p -r1.56.2.3 koapp.cpp
--- koapp.cpp	28 Nov 2002 13:55:42 -0000	1.56.2.3
+++ koapp.cpp	10 Dec 2002 11:33:16 -0000
@@ -40,7 +40,7 @@
 #include "koprefs.h"
 #include "version.h"
 
-#include "koappshared.h"
+#include "alarmclient.h"
 #include "koapp.h"
 #include "koapp.moc"
 
@@ -125,8 +125,8 @@ int KOrganizerApp::newInstance()
   } else if (args->isSet("show")) {
     numDays = args->getOption("show").toInt();
   } else {
-    KOAppShared::startAlarmDaemon();
-    KOAppShared::startAlarmClient();
+    AlarmClient::startAlarmDaemon();
+    AlarmClient::startAlarmClient();
   }
 
   // If filenames was given as argument load this as calendars, one per window.
Index: kokroupware.cpp
===================================================================
RCS file: /home/kde/kdepim/korganizer/Attic/kokroupware.cpp,v
retrieving revision 1.1.2.55
diff -u -p -r1.1.2.55 kokroupware.cpp
--- kokroupware.cpp	28 Nov 2002 15:42:16 -0000	1.1.2.55
+++ kokroupware.cpp	10 Dec 2002 11:33:16 -0000
@@ -29,7 +29,7 @@
 #include "mailscheduler.h"
 #include "kokroupwareincomingdialogimpl.h"
 #include "koviewmanager.h"
-#include "koappshared.h"
+#include "alarmclient.h"
 
 #include <libkcal/incidencebase.h>
 #include <libkcal/attendee.h>
@@ -78,8 +78,8 @@ KOKroupware::KOKroupware( QObject* kmail
 	   kmailTarget, SLOT( slotDeleteNote( const QString& ) ) );
 
   // Setup alarms
-  KOAppShared::startAlarmDaemon();
-  KOAppShared::startAlarmClient();
+  AlarmClient::startAlarmDaemon();
+  AlarmClient::startAlarmClient();
 
 }
 


Bo.

-- 

     Bo Thorsen                 |   Praestevejen 4
     Senior Software Engineer   |   5290 Marslev
     Klarälvdalens Datakonsult  |   Denmark

_______________________________________________
kde-pim mailing list
kde-pim@mail.kde.org
http://mail.kde.org/mailman/listinfo/kde-pim
kde-pim home page at http://pim.kde.org/
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic