kpilot/lib
kpilotlink.hGo to the documentation of this file.00001 #ifndef _KPILOT_KPILOTLINK_H
00002 #define _KPILOT_KPILOTLINK_H
00003
00004
00005
00006
00007
00008
00009
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #include <time.h>
00038 #include <pi-dlp.h>
00039
00040 #include <qobject.h>
00041 #include <qptrlist.h>
00042
00043 class QTimer;
00044 class QDateTime;
00045 class QSocketNotifier;
00046 class QThread;
00047 class KPilotUser;
00048 class KPilotSysInfo;
00049 class KPilotCard;
00050 struct DBInfo;
00051
00062 struct db
00063 {
00064 char name[256];
00065 int flags;
00066 unsigned long creator;
00067 unsigned long type;
00068 int maxblock;
00069 };
00070
00071 #define pi_mktag(c1,c2,c3,c4) (((c1)<<24)|((c2)<<16)|((c3)<<8)|(c4))
00072
00073
00074
00094 class KDE_EXPORT KPilotDeviceLink : public QObject
00095 {
00096 friend class SyncAction;
00097 Q_OBJECT
00098
00099
00100
00101
00102 public:
00108 KPilotDeviceLink( QObject *parent = 0, const char *name = 0, const QString &tempDevice = QString::null );
00110 virtual ~KPilotDeviceLink();
00111
00112
00113
00114
00115
00116
00117 public:
00123 typedef enum {
00124 Init,
00125 WaitingForDevice,
00126 FoundDevice,
00127 CreatedSocket,
00128 DeviceOpen,
00129 AcceptedDevice,
00130 SyncDone,
00131 PilotLinkError,
00132 WorkaroundUSB
00133 } LinkStatus;
00134
00138 LinkStatus status() const { return fLinkStatus; } ;
00140 static QString statusString(LinkStatus l);
00142 virtual QString statusString() const;
00143
00148 bool getConnected() const { return fLinkStatus == AcceptedDevice; }
00149
00150 private:
00151 LinkStatus fLinkStatus;
00152
00216 public slots:
00217 bool tickle() const;
00218 protected:
00219 void startTickle(unsigned int timeout=0);
00220 void stopTickle();
00221 public:
00222 virtual bool event(QEvent *e);
00223 static const unsigned int TickleTimeoutEvent = 1066;
00224
00225 signals:
00226 void timeout();
00227
00228 private:
00229 bool fTickleDone;
00230 QThread *fTickleThread;
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241 public:
00245 QString pilotPath() const { return fPilotPath; } ;
00246
00251 void reset(const QString &pilotPath);
00252
00253
00260 void setWorkarounds(bool usb)
00261 {
00262 fWorkaroundUSB = usb;
00263 } ;
00264
00269 void setTempDevice( const QString &device );
00270
00271 private:
00272 bool fWorkaroundUSB;
00273 QTimer *fWorkaroundUSBTimer;
00274
00275 private slots:
00276 void workaroundUSB();
00277
00278 public slots:
00283 void close();
00284
00290 void reset();
00291
00292 protected slots:
00297 void openDevice();
00298
00303 void acceptDevice();
00304
00305 protected:
00310 bool open( QString device = QString::null );
00311
00317 void checkDevice();
00318
00324 enum { OpenMessage=1, OpenFailMessage=2 } ;
00325 int messages;
00326 int messagesMask;
00327 static const int messagesType;
00328
00329 void shouldPrint(int,const QString &);
00330
00331 signals:
00336 void deviceReady( KPilotDeviceLink* );
00337
00338 protected:
00339 int pilotSocket() const { return fCurrentPilotSocket; } ;
00340
00341
00342 private:
00347 QString fPilotPath;
00352 QString fRealPilotPath;
00353
00357 int fRetries;
00358
00362 QTimer *fOpenTimer;
00363 QSocketNotifier *fSocketNotifier;
00364 bool fSocketNotifierActive;
00365
00369 int fPilotMasterSocket;
00370 int fCurrentPilotSocket;
00371 QString fTempDevice;
00372
00377 int fAcceptedCount;
00378 signals:
00384 void logEntry(const char *);
00385
00386
00387
00388
00389 public:
00390 int installFiles(const QStringList &, const bool deleteFiles=true);
00391 protected:
00392 bool installFile(const QString &, const bool deleteFile=true);
00393
00400 void addSyncLogEntry(const QString &entry,bool log=true);
00401
00402 signals:
00408 void logMessage(const QString &);
00409 void logError(const QString &);
00410 void logProgress(const QString &, int);
00411
00412
00413
00414
00415
00416 protected:
00417 KPilotUser *fPilotUser;
00418 KPilotSysInfo *fPilotSysInfo;
00419 public:
00427 KPilotUser *getPilotUser() { return fPilotUser; }
00428 KPilotSysInfo *getSysInfo() { return fPilotSysInfo; }
00429 KPilotCard *getCardInfo(int card=0);
00430 void endOfSync();
00431 void finishSync();
00432
00433
00434
00435
00436 protected:
00440 int openConduit();
00441 public:
00442 int getNextDatabase(int index,struct DBInfo *);
00443 int findDatabase(const char *name, struct DBInfo*,
00444 int index=0, long type=0, long creator=0);
00445
00450 bool retrieveDatabase(const QString &path, struct DBInfo *db);
00451 QPtrList<DBInfo> getDBList(int cardno=0, int flags=dlpDBListRAM);
00452
00453 public:
00457 QDateTime getTime();
00461 bool setTime(const time_t &pctime);
00462
00466 unsigned long ROMversion() const;
00470 unsigned long majorVersion() const;
00474 unsigned long minorVersion() const;
00475
00476 private:
00477 class KPilotDeviceLinkPrivate;
00478 } ;
00479
00480 bool operator < ( const struct db &, const struct db &) ;
00481
00482 #endif
|