kpilot Library API Documentation

kpilotlink.h

00001 #ifndef _KPILOT_KPILOTLINK_H 00002 #define _KPILOT_KPILOTLINK_H 00003 /* kpilotlink.h KPilot 00004 ** 00005 ** Copyright (C) 1998-2001 by Dan Pilone 00006 ** 00007 ** Encapsulates all the communication with the pilot. Also 00008 ** does daemon-like polling of the Pilot. Interesting status 00009 ** changes are signalled. 00010 */ 00011 00012 /* 00013 ** This program is free software; you can redistribute it and/or modify 00014 ** it under the terms of the GNU Lesser General Public License as published by 00015 ** the Free Software Foundation; either version 2.1 of the License, or 00016 ** (at your option) any later version. 00017 ** 00018 ** This program is distributed in the hope that it will be useful, 00019 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00021 ** GNU Lesser General Public License for more details. 00022 ** 00023 ** You should have received a copy of the GNU Lesser General Public License 00024 ** along with this program in a file called COPYING; if not, write to 00025 ** the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 00026 ** MA 02111-1307, USA. 00027 */ 00028 00029 /* 00030 ** Bug reports and questions can be sent to kde-pim@kde.org 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 ** The KPilotLink class was originally a kind of C++ wrapper 00051 ** for the pilot-link library. It grew and grew and mutated 00052 ** until it was finally cleaned up again in 2001. In the meantime 00053 ** it had become something that wrapped a lot more than just 00054 ** pilot-link. This class currently does: 00055 ** 00056 ** * Client (ie. conduit) handling of kpilotlink protocol connections 00057 ** * Pilot-link handling 00058 ** 00059 ** Which is exactly what is needed: something that conduits can 00060 ** plug onto to talk to the pilot. 00061 */ 00062 00063 /* 00064 ** The struct db is a description class for Pilot databases 00065 ** by Kenneth Albanowski. It's not really clear why it's *here*. 00066 ** The macro pi_mktag is meant to be given four char (8-bit) 00067 ** quantities, which are arranged into an unsigned long; for example 00068 ** pi_mktag('l','n','c','h'). This is called the creator tag 00069 ** of a database, and db.creator can be compared with such a 00070 ** tag. The tag lnch is used by the Pilot's launcher app. Some 00071 ** parts of KPilot require such a tag. 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 ** Constructors and destructors. 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 ** Status information 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 ** Used for initially attaching to the device. 00151 ** deviceReady() is emitted when the device has been opened 00152 ** and a Sync can start. 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 ** File installation. 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 ** Pilot User Identity functions. 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 ** Actions intended just to abstract away the pilot-link library interface. 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
KDE Logo
This file is part of the documentation for kpilot Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jul 28 23:57:49 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003