kpilot/lib

kpilotdevicelink.h

00001 #ifndef _KPILOT_KPILOTDEVICELINK_H
00002 #define _KPILOT_KPILOTDEVICELINK_H
00003 /* kpilotdevicelink.h           KPilot
00004 **
00005 ** Copyright (C) 1998-2001 by Dan Pilone
00006 ** Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
00007 ** Copyright (C) 2006 Adriaan de Groot <groot@kde.org>
00008 **
00009 */
00010 
00011 /*
00012 ** This program is free software; you can redistribute it and/or modify
00013 ** it under the terms of the GNU Lesser General Public License as published by
00014 ** the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
00021 **
00022 ** You should have received a copy of the GNU Lesser 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 #include "kpilotlink.h"
00033 
00040 class KDE_EXPORT KPilotDeviceLink : public KPilotLink
00041 {
00042 friend class PilotSerialDatabase;
00043 Q_OBJECT
00044 
00045 /*
00046 ** Constructors and destructors.
00047 */
00048 public:
00054     KPilotDeviceLink( QObject *parent = 0, 
00055         const char *name = 0, 
00056         const QString &tempDevice = QString::null );
00058     virtual ~KPilotDeviceLink();
00059 
00060 
00066     typedef enum {
00067         Init,
00068         WaitingForDevice,
00069         FoundDevice,
00070         CreatedSocket,
00071         DeviceOpen,
00072         AcceptedDevice,
00073         SyncDone,
00074         PilotLinkError,
00075         WorkaroundUSB
00076         } LinkStatus;
00077 
00081     LinkStatus status() const { return fLinkStatus; } ;
00083     static QString statusString(LinkStatus l);
00084 
00085     // The followin API is the actual implementation of
00086     // the KPilotLink API, for documentation see that file.
00087     //
00088     virtual QString statusString() const;
00089     virtual bool isConnected() const;
00090     virtual void reset( const QString & );
00091     virtual void close();
00092     virtual void reset();
00093     virtual bool tickle();
00094     virtual const KPilotCard *getCardInfo(int card);
00095     virtual void endOfSync();
00096     virtual void finishSync();
00097     virtual int openConduit();
00098     virtual int getNextDatabase(int index,struct DBInfo *);
00099     virtual int findDatabase(const char *name, struct DBInfo*,
00100         int index=0, unsigned long type=0, unsigned long creator=0);
00101     virtual bool retrieveDatabase(const QString &path, struct DBInfo *db);
00102     virtual DBInfoList getDBList(int cardno=0, int flags=dlpDBListRAM);
00103     virtual PilotDatabase *database( const QString &name );
00104 
00105 protected:
00106     virtual bool installFile(const QString &, const bool deleteFile);
00107     virtual void addSyncLogEntryImpl( const QString &s );
00108     virtual int pilotSocket() const { return fCurrentPilotSocket; } ;
00109 
00110 
00111 private:
00112     LinkStatus fLinkStatus;
00113 
00114 
00115 
00116 
00117 
00118 public:
00119 
00126     void setWorkarounds(bool usb)
00127     {
00128         fWorkaroundUSB = usb;
00129     } ;
00130 
00136     void setTempDevice( const QString &device );
00137 
00138 private:
00140     bool fWorkaroundUSB;
00142     QTimer *fWorkaroundUSBTimer;
00143 
00144 private slots:
00149     void workaroundUSB();
00150 
00151 protected slots:
00156     void openDevice();
00157 
00162     void acceptDevice();
00163 
00164 protected:
00169     bool open( const QString &device = QString::null );
00170 
00176     void checkDevice();
00177 
00183     enum { OpenMessage=1, OpenFailMessage=2 } ;
00184     int messages;
00185     int messagesMask;
00186     static const int messagesType;
00187 
00193     void shouldPrint(int msgid,const QString &s);
00194 
00195 
00196 
00197 private:
00202     QString fRealPilotPath;
00203 
00207     int fRetries;
00208 
00212     QTimer *fOpenTimer;
00213     QSocketNotifier *fSocketNotifier;
00214     bool fSocketNotifierActive;
00215 
00219     int fPilotMasterSocket;
00220     int fCurrentPilotSocket;
00221     QString fTempDevice;
00222 
00227     int fAcceptedCount;
00228 
00229 private:
00230     class KPilotDeviceLinkPrivate;
00231 } ;
00232 
00233 #endif
00234 
KDE Home | KDE Accessibility Home | Description of Access Keys