kpilot/kpilot

pilotDaemon.h

00001 #ifndef _KPILOT_PILOTDAEMON_H
00002 #define _KPILOT_PILOTDAEMON_H
00003 /* pilotDaemon.h            KPilot
00004 **
00005 ** Copyright (C) 1998-2001 by Dan Pilone
00006 ** Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
00007 **
00008 ** See the .cc file for an explanation of what this file is for.
00009 */
00010 
00011 /*
00012 ** This program is free software; you can redistribute it and/or modify
00013 ** it under the terms of the GNU General Public License as published by
00014 ** the Free Software Foundation; either version 2 of the License, or
00015 ** (at your option) any later version.
00016 **
00017 ** This program is distributed in the hope that it will be useful,
00018 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00020 ** GNU General Public License for more details.
00021 **
00022 ** You should have received a copy of the GNU General Public License
00023 ** along with this program in a file called COPYING; if not, write to
00024 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00025 ** MA 02110-1301, USA.
00026 */
00027 
00028 /*
00029 ** Bug reports and questions can be sent to kde-pim@kde.org
00030 */
00031 
00032 
00033 #include <ksystemtray.h>
00034 
00035 #include "kpilotlink.h"
00036 #include "syncAction.h"
00037 #include "pilotDaemonDCOP.h"
00038 
00039 class QPixmap;
00040 class QTimer;
00041 class KAboutApplication;
00042 class QPopupMenu;
00043 
00044 class PilotDaemon;
00045 class ActionQueue;
00046 class FileInstaller;
00047 class LoggerDCOP_stub;
00048 class KPilotDCOP_stub;
00049 class LogFile;
00050 
00051 class PilotDaemonTray : public KSystemTray
00052 {
00053     Q_OBJECT
00054 
00055 friend class PilotDaemon;
00056 
00057 public:
00058     PilotDaemonTray(PilotDaemon *p);
00059 
00060     typedef enum { Normal, Busy, NotListening } IconShape ;
00061     void changeIcon(IconShape);
00062 
00063     void enableRunKPilot(bool);
00064 
00065     virtual void dragEnterEvent(QDragEnterEvent *);
00066     virtual void dropEvent(QDropEvent *);
00067 
00068 
00069 protected:
00070     void setupWidget();
00074     QPopupMenu *fSyncTypeMenu;
00075 
00076 protected slots:
00077     void slotShowAbout();
00078     void slotShowBusy();
00079     void slotShowNormal();
00080     void slotShowNotListening();
00081     void slotBusyTimer();
00082 
00083     // "Regular" QT actions
00084     //
00085     //
00086     virtual void mousePressEvent(QMouseEvent* e);
00087     virtual void closeEvent(QCloseEvent *e);
00088 
00089 protected:
00090     void startHotSync();
00091     void endHotSync();
00092 
00093 private:
00094     QPixmap icons[((int) NotListening) + 1];
00095     IconShape fCurrentIcon;
00096     PilotDaemon *daemon;
00097 
00103     int menuKPilotItem;
00104 
00110     int menuConfigureConduitsItem;
00111 
00115     KAboutApplication *kap;
00116 
00120     QTimer *fBlinkTimer;
00121 
00122 } ;
00123 
00124 class PilotDaemon : public QObject, virtual public PilotDaemonDCOP
00125 {
00126 Q_OBJECT
00127 
00128 // The tray must be our friend so that we can let it stop the daemon.
00129 friend class PilotDaemonTray;
00130 
00131 
00132 public:
00133     PilotDaemon();
00134     ~PilotDaemon();
00135 
00136     enum DaemonStatus
00137     {
00138         HOTSYNC_START,    // Hotsync is running
00139         HOTSYNC_END,      // Hotsync is cleaning up
00140         FILE_INSTALL_REQ, // A file is being saved for installation
00141         ERROR,
00142         READY,            // Connected to device and ready for Sync
00143         INIT,
00144         NOT_LISTENING
00145     };
00146 
00147     DaemonStatus status() const { return fDaemonStatus; } ;
00148     /* DCOP */ virtual QString statusString();
00149     /* DCOP */ virtual QString shortStatusString();
00150 
00156     void showTray();
00157     virtual void addInstallFiles(const QStringList &);
00158 
00159     // The next few functions are the DCOP interface.
00160     // Some are also slots.
00161     //
00162 public slots:
00163     virtual ASYNC requestSync(int);
00164 public:
00165     virtual ASYNC requestSyncType(QString);
00166     virtual ASYNC requestFastSyncNext();
00167     virtual ASYNC requestRegularSyncNext();
00168     virtual int nextSyncType() const;
00169     virtual ASYNC requestSyncOptions(bool,bool);
00170 
00171     virtual ASYNC quitNow();
00172     virtual ASYNC reloadSettings();
00173     virtual ASYNC setTempDevice(QString d);
00174 
00175     virtual void stopListening();
00176     virtual void startListening();
00177     virtual bool isListening() { return fIsListening; }
00181     virtual QDateTime lastSyncDate();
00182     virtual QStringList configuredConduitList();
00183     virtual QString logFileName();
00184     virtual QString userName();
00185     virtual QString pilotDevice();
00186     virtual bool killDaemonOnExit();
00187 
00188 protected:
00189     DaemonStatus fDaemonStatus;
00190 
00191     enum postSyncActions {
00192         None=0,
00193         ReloadSettings = 1,
00194         Quit = 2
00195         } ;
00196     int fPostSyncAction;
00197 
00198 protected slots:
00199     void startHotSync( KPilotDeviceLink* lnk );
00200     void endHotSync();
00201 
00202     void logMessage(const QString &);
00203     void logError(const QString &);
00204     void logProgress(const QString &,int);
00205 
00206 private:
00207     int getPilotSpeed();
00208 
00209     bool setupPilotLink();
00210 
00211     KPilotDeviceLink &getPilotLink() { return *fPilotLink; }
00212     KPilotDeviceLink *fPilotLink;
00213 
00214     SyncAction::SyncMode fNextSyncType;
00215 
00216     ActionQueue *fSyncStack;
00217 
00222     PilotDaemonTray *fTray;
00223 
00227     void updateTrayStatus(const QString &s=QString::null);
00228 
00229     FileInstaller *fInstaller;
00230 
00231 protected slots:
00238     void slotFilesChanged();
00239 
00243     void slotRunKPilot();
00244 
00248     void slotRunConfig();
00249 
00253 protected:
00254     LoggerDCOP_stub &getLogger() { return *fLogStub; } ;
00255     LoggerDCOP_stub &getFileLogger() { return *fLogFileStub; } ;
00256     KPilotDCOP_stub &getKPilot() { return *fKPilotStub; } ;
00257 
00258     LogFile *fLogFile;
00259     bool fIsListening;
00260 
00261 private:
00262     LoggerDCOP_stub *fLogStub;
00263     LoggerDCOP_stub *fLogFileStub;
00264     KPilotDCOP_stub *fKPilotStub;
00265     QString fTempDevice;
00266 };
00267 
00268 
00269 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys