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 struct DBInfo;
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071 struct db
00072 {
00073 char name[256];
00074 int flags;
00075 unsigned long creator;
00076 unsigned long type;
00077 int maxblock;
00078 };
00079
00080 #define pi_mktag(c1,c2,c3,c4) (((c1)<<24)|((c2)<<16)|((c3)<<8)|(c4))
00081
00085 QDateTime readTm(const struct tm &t);
00089 struct tm writeTm(const QDateTime &dt);
00090
00091
00092 class KPilotDeviceLink : public QObject
00093 {
00094 friend class SyncAction;
00095 Q_OBJECT
00096
00097
00098
00099
00100 protected:
00106 KPilotDeviceLink(QObject *parent, const char *name);
00107 private:
00108 static KPilotDeviceLink *fDeviceLink;
00109
00110 public:
00111 virtual ~KPilotDeviceLink();
00112 static KPilotDeviceLink *link() { return fDeviceLink; } ;
00113 static KPilotDeviceLink *init(QObject *parent=0L,const char *n=0L);
00114
00115
00116
00117
00118
00119 public:
00125 typedef enum {
00126 Init,
00127 WaitingForDevice,
00128 FoundDevice,
00129 CreatedSocket,
00130 DeviceOpen,
00131 AcceptedDevice,
00132 SyncDone,
00133 PilotLinkError
00134 } LinkStatus;
00135
00136 LinkStatus status() const { return fStatus; } ;
00137 virtual QString statusString() const;
00138
00143 bool getConnected() const { return fStatus == AcceptedDevice; }
00144
00145 public slots:
00149 void tickle() const;
00150
00151 private:
00152 LinkStatus fStatus;
00153
00154
00155
00156
00157
00158
00159
00160 public:
00164 typedef enum { None,
00165 Serial,
00166 OldStyleUSB,
00167 DevFSUSB
00168 } DeviceType;
00169
00170 DeviceType deviceType() const { return fDeviceType; } ;
00171 QString deviceTypeString(int i) const;
00172 bool isTransient() const
00173 {
00174 return (fDeviceType==OldStyleUSB) ||
00175 (fDeviceType==DevFSUSB);
00176 }
00177
00178 QString pilotPath() const { return fPilotPath; } ;
00179
00184 void reset(DeviceType t,const QString &pilotPath = QString::null);
00185
00186
00187 public slots:
00192 void close();
00193
00199 void reset();
00200
00201 protected slots:
00206 void openDevice();
00207
00212 void acceptDevice();
00213
00214 protected:
00219 bool open();
00220
00226 void checkDevice();
00227
00233 enum { OpenMessage=1, OpenFailMessage=2 } ;
00234 int messages;
00235 int messagesMask;
00236 static const int messagesType;
00237
00238 void shouldPrint(int,const QString &);
00239
00240 signals:
00245 void deviceReady();
00246
00247 protected:
00248 int pilotSocket() const { return fCurrentPilotSocket; } ;
00249
00250
00251 private:
00256 QString fPilotPath;
00257
00261 DeviceType fDeviceType;
00262
00266 int fRetries;
00267
00271 QTimer *fOpenTimer;
00272 QSocketNotifier *fSocketNotifier;
00273 bool fSocketNotifierActive;
00274
00278 int fPilotMasterSocket;
00279 int fCurrentPilotSocket;
00280
00281 signals:
00287 void logEntry(const char *);
00288
00289
00290
00291
00292 public:
00293 int installFiles(const QStringList &, const bool deleteFiles=true);
00294 protected:
00295 bool installFile(const QString &, const bool deleteFile=true);
00296
00303 void addSyncLogEntry(const QString &entry,bool log=true);
00304
00305 signals:
00311 void logMessage(const QString &);
00312 void logError(const QString &);
00313 void logProgress(const QString &, int);
00314
00315
00316
00317
00318
00319 public:
00327 KPilotUser *getPilotUser() { return fPilotUser; }
00328 void finishSync();
00329
00330 protected:
00331 KPilotUser *fPilotUser;
00332
00333
00334
00335
00336 protected:
00340 int openConduit();
00341 public:
00342 int getNextDatabase(int index,struct DBInfo *);
00343 int findDatabase(const char *name, struct DBInfo*,
00344 int index=0, long type=0, long creator=0);
00345
00350 bool retrieveDatabase(const QString &path, struct DBInfo *db);
00351
00352 public:
00356 QDateTime getTime();
00360 bool setTime(const time_t &pctime);
00361
00365 unsigned long ROMversion() const;
00369 unsigned long majorVersion() const;
00373 unsigned long minorVersion() const;
00374
00375
00376 } ;
00377
00378 bool operator < ( const struct db &, const struct db &) ;
00379
00380 #endif
This file is part of the documentation for kdelibs Version 3.1.5.