kpilotlink.h
00001 #ifndef _KPILOT_KPILOTLINK_H
00002 #define _KPILOT_KPILOTLINK_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include <time.h>
00034 #include <pi-dlp.h>
00035
00036 #ifndef QOBJECT_H
00037 #include <qobject.h>
00038 #endif
00039
00040
00041 class QTimer;
00042 class QDateTime;
00043 class QSocketNotifier;
00044 class KPilotUser;
00045 class KPilotSysInfo;
00046 class KPilotCard;
00047 struct DBInfo;
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073 struct db
00074 {
00075 char name[256];
00076 int flags;
00077 unsigned long creator;
00078 unsigned long type;
00079 int maxblock;
00080 };
00081
00082 #define pi_mktag(c1,c2,c3,c4) (((c1)<<24)|((c2)<<16)|((c3)<<8)|(c4))
00083
00084
00085
00086 class KPilotDeviceLink : public QObject
00087 {
00088 friend class SyncAction;
00089 Q_OBJECT
00090
00091
00092
00093
00094 protected:
00100 KPilotDeviceLink(QObject *parent, const char *name);
00101 private:
00102 static KPilotDeviceLink *fDeviceLink;
00103
00104 public:
00105 virtual ~KPilotDeviceLink();
00106 static KPilotDeviceLink *link() { return fDeviceLink; } ;
00107 static KPilotDeviceLink *init(QObject *parent=0L,const char *n=0L);
00108
00109
00110
00111
00112
00113 public:
00119 typedef enum {
00120 Init,
00121 WaitingForDevice,
00122 FoundDevice,
00123 CreatedSocket,
00124 DeviceOpen,
00125 AcceptedDevice,
00126 SyncDone,
00127 PilotLinkError
00128 } LinkStatus;
00129
00130 LinkStatus status() const { return fStatus; } ;
00131 virtual QString statusString() const;
00132
00137 bool getConnected() const { return fStatus == AcceptedDevice; }
00138
00139 public slots:
00143 void tickle() const;
00144
00145 private:
00146 LinkStatus fStatus;
00147
00148
00149
00150
00151
00152
00153
00154 public:
00158 typedef enum { None,
00159 Serial,
00160 OldStyleUSB,
00161 DevFSUSB
00162 } DeviceType;
00163
00164 DeviceType deviceType() const { return fDeviceType; } ;
00165 QString deviceTypeString(int i) const;
00166 bool isTransient() const
00167 {
00168 return (fDeviceType==OldStyleUSB) ||
00169 (fDeviceType==DevFSUSB);
00170 }
00171
00172 QString pilotPath() const { return fPilotPath; } ;
00173
00178 void reset(DeviceType t,const QString &pilotPath = QString::null);
00179
00180
00181 public slots:
00186 void close();
00187
00193 void reset();
00194
00195 protected slots:
00200 void openDevice();
00201
00206 void acceptDevice();
00207
00208 protected:
00213 bool open();
00214
00220 void checkDevice();
00221
00227 enum { OpenMessage=1, OpenFailMessage=2 } ;
00228 int messages;
00229 int messagesMask;
00230 static const int messagesType;
00231
00232 void shouldPrint(int,const QString &);
00233
00234 signals:
00239 void deviceReady();
00240
00241 protected:
00242 int pilotSocket() const { return fCurrentPilotSocket; } ;
00243
00244
00245 private:
00250 QString fPilotPath;
00251
00255 DeviceType fDeviceType;
00256
00260 int fRetries;
00261
00265 QTimer *fOpenTimer;
00266 QSocketNotifier *fSocketNotifier;
00267 bool fSocketNotifierActive;
00268
00272 int fPilotMasterSocket;
00273 int fCurrentPilotSocket;
00274
00279 int fAcceptedCount;
00280 signals:
00286 void logEntry(const char *);
00287
00288
00289
00290
00291 public:
00292 int installFiles(const QStringList &, const bool deleteFiles=true);
00293 protected:
00294 bool installFile(const QString &, const bool deleteFile=true);
00295
00302 void addSyncLogEntry(const QString &entry,bool log=true);
00303
00304 signals:
00310 void logMessage(const QString &);
00311 void logError(const QString &);
00312 void logProgress(const QString &, int);
00313
00314
00315
00316
00317
00318 protected:
00319 KPilotUser *fPilotUser;
00320 KPilotSysInfo *fPilotSysInfo;
00321 public:
00329 KPilotUser *getPilotUser() { return fPilotUser; }
00330 KPilotSysInfo *getSysInfo() { return fPilotSysInfo; }
00331 KPilotCard *getCardInfo(int card=0);
00332 void finishSync();
00333
00334
00335
00336
00337 protected:
00341 int openConduit();
00342 public:
00343 int getNextDatabase(int index,struct DBInfo *);
00344 int findDatabase(const char *name, struct DBInfo*,
00345 int index=0, long type=0, long creator=0);
00346
00351 bool retrieveDatabase(const QString &path, struct DBInfo *db);
00352 QPtrList<DBInfo> getDBList(int cardno=0, int flags=dlpDBListRAM);
00353
00354 public:
00358 QDateTime getTime();
00362 bool setTime(const time_t &pctime);
00363
00367 unsigned long ROMversion() const;
00371 unsigned long majorVersion() const;
00375 unsigned long minorVersion() const;
00376 } ;
00377
00378 bool operator < ( const struct db &, const struct db &) ;
00379
00380 #endif
This file is part of the documentation for kpilot Library Version 3.2.2.