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 SyncAction;
00043 friend class PilotSerialDatabase;
00044 Q_OBJECT
00045 
00046 /*
00047 ** Constructors and destructors.
00048 */
00049 public:
00055     KPilotDeviceLink( QObject *parent = 0, const char *name = 0, const QString &tempDevice = QString::null );
00057     virtual ~KPilotDeviceLink();
00058 
00059 
00065     typedef enum {
00066         Init,
00067         WaitingForDevice,
00068         FoundDevice,
00069         CreatedSocket,
00070         DeviceOpen,
00071         AcceptedDevice,
00072         SyncDone,
00073         PilotLinkError,
00074         WorkaroundUSB
00075         } LinkStatus;
00076 
00080     LinkStatus status() const { return fLinkStatus; } ;
00082     static QString statusString(LinkStatus l);
00083 
00084 
00085     virtual QString statusString() const;
00086     virtual bool isConnected() const;
00087     virtual void reset( const QString & );
00088     virtual void close();
00089     virtual void reset();
00090     virtual bool tickle();
00091     virtual const KPilotCard *getCardInfo(int card);
00092     virtual void endOfSync();
00093     virtual void finishSync();
00094     virtual int openConduit();
00095     virtual int getNextDatabase(int index,struct DBInfo *);
00096     virtual int findDatabase(const char *name, struct DBInfo*,
00097         int index=0, unsigned long type=0, unsigned long creator=0);
00098     virtual bool retrieveDatabase(const QString &path, struct DBInfo *db);
00099     virtual DBInfoList getDBList(int cardno=0, int flags=dlpDBListRAM);
00100     virtual PilotDatabase *database( const QString &name );
00101 
00102 protected:
00103     virtual bool installFile(const QString &, const bool deleteFile);
00104     virtual void addSyncLogEntryImpl( const QString &s );
00105     virtual int pilotSocket() const { return fCurrentPilotSocket; } ;
00106 
00107 
00108 private:
00109     LinkStatus fLinkStatus;
00110 
00111 
00112 
00113 
00114 
00115 public:
00116 
00123     void setWorkarounds(bool usb)
00124     {
00125         fWorkaroundUSB = usb;
00126     } ;
00127 
00132     void setTempDevice( const QString &device );
00133 
00134 private:
00135     bool fWorkaroundUSB;
00136     QTimer *fWorkaroundUSBTimer;
00137 
00138 private slots:
00139     void workaroundUSB();
00140 
00141 protected slots:
00146     void openDevice();
00147 
00152     void acceptDevice();
00153 
00154 protected:
00159     bool open( QString device = QString::null );
00160 
00166     void checkDevice();
00167 
00173     enum { OpenMessage=1, OpenFailMessage=2 } ;
00174     int messages;
00175     int messagesMask;
00176     static const int messagesType;
00177 
00178     void shouldPrint(int,const QString &);
00179 
00180 
00181 
00182 private:
00187     QString fRealPilotPath;
00188 
00192     int fRetries;
00193 
00197     QTimer *fOpenTimer;
00198     QSocketNotifier *fSocketNotifier;
00199     bool fSocketNotifierActive;
00200 
00204     int fPilotMasterSocket;
00205     int fCurrentPilotSocket;
00206     QString fTempDevice;
00207 
00212     int fAcceptedCount;
00213 
00214 private:
00215     class KPilotDeviceLinkPrivate;
00216 } ;
00217 
00218 #endif
00219 
KDE Home | KDE Accessibility Home | Description of Access Keys