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

List:       kde-pim
Subject:    [Kde-pim] korganizer patch
From:       Bo Thorsen <bo () sonofthor ! dk>
Date:       2002-11-28 15:45:11
[Download RAW message or body]

Hi all,

I'll be integrating the kroupware stuff quite slowly over the next days.

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.

Can I commit this?

Bo.

Index: Makefile.am
===================================================================
RCS file: /home/kde/kdepim/korganizer/Makefile.am,v
retrieving revision 1.199
diff -u -p -r1.199 Makefile.am
--- Makefile.am	2002/10/15 01:16:21	1.199
+++ Makefile.am	2002/11/28 13:43:52
@@ -45,7 +45,7 @@ libkorganizer_la_SOURCES =  outgoingdial
 	komailclient.cpp kotodoview.cpp kotodoviewitem.cpp \
         kolistview.cpp \
         exportwebdialog.cpp htmlexport.cpp \
-        koapp.cpp korganizer_part.cpp korganizer.cpp \
+        koapp.cpp koappshared.cpp korganizer_part.cpp korganizer.cpp \
         koprefsdialog.cpp \
         koincidenceeditor.cpp koeventeditor.cpp kotodoeditor.cpp \
         koprefs.cpp koeventviewer.cpp kowindowlist.cpp \
@@ -79,7 +79,7 @@ noinst_HEADERS = komonthview.h \
 	archivedialog.h \
 	komailclient.h kotodoview.h \
         kolistview.h \
-	koapp.h exportwebdialog.h korganizer_part.h korganizer.h \
+	koapp.h koappshared.h exportwebdialog.h korganizer_part.h korganizer.h \
         koprefsdialog.h koeventeditor.h \
         kotodoeditor.h koprefs.h koeventviewer.h \
         kowindowlist.h kocounterdialog.h \
Index: koapp.cpp
===================================================================
RCS file: /home/kde/kdepim/korganizer/koapp.cpp,v
retrieving revision 1.57
diff -u -p -r1.57 koapp.cpp
--- koapp.cpp	2002/10/10 10:01:36	1.57
+++ koapp.cpp	2002/11/28 13:43:52
@@ -25,28 +25,22 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-#include <qfile.h>
-
-#include <kstandarddirs.h>
 #include <kglobal.h>
 #include <kcmdlineargs.h>
 #include <kconfig.h>
 #include <kdebug.h>
-#include <dcopclient.h>
 #include <kwin.h>
 #include <kurl.h>
-#include <kprocess.h>
 
 #include <libkcal/calendarlocal.h>
 #include <libkcal/filestorage.h>
 #include <libkcal/calformat.h>
 
-#include "kalarmd/alarmdaemoniface_stub.h"
-
 #include "korganizer.h"
 #include "koprefs.h"
 #include "version.h"
 
+#include "koappshared.h"
 #include "koapp.h"
 #include "koapp.moc"
 
@@ -118,37 +112,6 @@ void KOrganizerApp::displayImminent( con
 }
 
 
-void KOrganizerApp::startAlarmDaemon()
-{
-  kdDebug() << "Starting alarm daemon" << endl;
-
-  // 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));
-
-  kdDebug() << "Starting alarm daemon done" << endl;
-}
-
-void KOrganizerApp::startAlarmClient()
-{
-  kdDebug() << "Starting alarm client" << endl;
-
-  KProcess *proc = new KProcess;
-  *proc << "korgac";
-  *proc << "--miniicon" <<  "korganizer";
-  connect( proc, SIGNAL( processExited( KProcess * ) ),
-           SLOT( startCompleted( KProcess * ) ) );
-  if (!proc->start())
-      delete proc;
-}
-
-void KOrganizerApp::startCompleted( KProcess *process )
-{
-  delete process;
-}
-
 int KOrganizerApp::newInstance()
 {
   kdDebug() << "KOApp::newInstance()" << endl;
@@ -162,20 +125,8 @@ int KOrganizerApp::newInstance()
   } else if (args->isSet("show")) {
     numDays = args->getOption("show").toInt();
   } else {
-    if (!dcopClient()->isApplicationRegistered("kalarmd")) {
-      startAlarmDaemon();
-    }
-    if (!dcopClient()->isApplicationRegistered("korgac")) {
-      startAlarmClient();
-    }
-
-    kdDebug() << "KOApp::newInstance() registerApp" << endl;
-    // Register this application with the alarm daemon
-    AlarmDaemonIface_stub stub( "kalarmd", "ad" );
-    stub.registerApp( "korgac", "KOrganizer", "ac", 3, true );
-    if( !stub.ok() ) {
-      kdDebug() << "KOrganizerApp::newInstance(): dcop send failed" << 
endl;
-    }
+    KOAppShared::startAlarmDaemon();
+    KOAppShared::startAlarmClient();
   }
 
   // If filenames was given as argument load this as calendars, one per 
window.
Index: koapp.h
===================================================================
RCS file: /home/kde/kdepim/korganizer/koapp.h,v
retrieving revision 1.13
diff -u -p -r1.13 koapp.h
--- koapp.h	2002/10/10 10:01:36	1.13
+++ koapp.h	2002/11/28 13:43:52
@@ -26,8 +26,6 @@
 
 #include <kuniqueapp.h>
 
-class KProcess;
-
 class KOrganizerApp : public KUniqueApplication
 {
     Q_OBJECT
@@ -41,16 +39,10 @@ class KOrganizerApp : public KUniqueAppl
     */
     int newInstance();
 
-  private slots:
-    void startCompleted( KProcess * );
-
   private:
     /** Print events for numDays days from calendar loaded from file to 
screen.*/
     void displayImminent( const KURL &url, int numdays );
-    /** Start alarm daemon from KDE binary directory */
-    void startAlarmDaemon();
-    /** Start alarm client from KDE binary directory */
-    void startAlarmClient();
+
     /**
       Process calendar from file. If numDays is 0, open a new KOrganizer 
window,
       if is is greater print events from corresponding number of dates to 
the
Index: koappshared.cpp
===================================================================
RCS file: koappshared.cpp
diff -N koappshared.cpp
--- /dev/null	Fri Feb  1 11:53:05 2002
+++ koappshared.cpp	Thu Nov 28 14:43:52 2002
@@ -0,0 +1,62 @@
+#include "koappshared.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 KOAppShared::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 KOAppShared::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() << "KOAppShared::startAlarmClient(): dcop send failed" << 
endl;
+}
+
+void KOAppShared::startCompleted( KProcess* process )
+{
+  delete process;
+}
+
+KOAppShared* KOAppShared::instance()
+{
+  static KOAppShared *singleton = 0;
+
+  if( singleton == 0 )
+    singleton = new KOAppShared();
+
+  return singleton;
+}
Index: koappshared.h
===================================================================
RCS file: koappshared.h
diff -N koappshared.h
--- /dev/null	Fri Feb  1 11:53:05 2002
+++ koappshared.h	Thu Nov 28 14:43:52 2002
@@ -0,0 +1,43 @@
+#ifndef KOAPPSHARED_H
+#define KOAPPSHARED_H
+
+#include <qobject.h>
+
+class KProcess;
+
+/**
+ * This class is used by KOrganizerApp and KOrganizerPart to initialize
+ * KOrganizer.
+ *
+ * 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 KOAppShared : 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 KOAppShared* instance();
+
+  KOAppShared() : QObject() {}
+  KOAppShared( const KOAppShared& );
+  KOAppShared& operator=( const KOAppShared& );
+
+  class gccShouldNotWarnAboutPrivateConstructors;
+  friend class gccShouldNotWarnAboutPrivateConstructors;
+};
+
+#endif // KOAPPSHARED_H


-- 

     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