kpilot

kpilotlink.h

Go to the documentation of this file.
00001 #ifndef _KPILOT_KPILOTLINK_H
00002 #define _KPILOT_KPILOTLINK_H
00003 /* 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 <pi-dlp.h>
00033 
00034 #include <qobject.h>
00035 #include <qvaluelist.h>
00036 
00043 class QThread;
00044 class KPilotUser;
00045 class KPilotSysInfo;
00046 class KPilotCard;
00047 class PilotDatabase;
00048 
00049 
00050 
00171 class KDE_EXPORT KPilotLink : public QObject
00172 {
00173 Q_OBJECT
00174 friend class SyncAction;
00175 public:
00177     typedef QValueList<struct DBInfo> DBInfoList;
00178 
00180     KPilotLink( QObject *parent = 0, const char *name = 0 );
00181 
00186     virtual ~KPilotLink();
00187 
00188 
00190     virtual QString statusString() const = 0;
00191 
00196     virtual bool isConnected() const = 0;
00197 
00198 
00207     QString pilotPath() const
00208     {
00209         return fPilotPath;
00210     }
00211 
00220     virtual void reset(const QString &pilotPath) = 0;
00221 
00226     virtual bool event(QEvent *e);
00227 
00235     unsigned int installFiles(const QStringList &l, const bool deleteFiles);
00236 
00244     void addSyncLogEntry(const QString &entry,bool log=true);
00245 
00256     virtual int findDatabase(const char *name,
00257         struct DBInfo *info,
00258         int index=0,
00259         unsigned long type=0,
00260         unsigned long creator=0) = 0;
00261 
00269     virtual bool retrieveDatabase(const QString &path, struct DBInfo *db) = 0;
00270 
00278     virtual int getNextDatabase(int index,struct DBInfo *db) = 0;
00279 
00292     virtual DBInfoList getDBList(int cardno=0, int flags=dlpDBListRAM) = 0;
00293 
00303     virtual PilotDatabase *database( const QString &name ) = 0;
00304 
00313     virtual PilotDatabase *database( const DBInfo *info );
00314 
00323     KPilotUser &getPilotUser()
00324     {
00325         return *fPilotUser;
00326     }
00327 
00335     const KPilotSysInfo &getSysInfo()
00336     {
00337         return *fPilotSysInfo;
00338     }
00339 
00351     virtual const KPilotCard *getCardInfo(int card=0) = 0;
00352 
00359     enum EndOfSyncFlags {
00360         NoUpdate, 
00361         UpdateUserInfo 
00362     } ;
00363 
00367     enum CustomEvents { 
00368         EventTickleTimeout = 1066
00369     };
00370     
00376     virtual void endSync( EndOfSyncFlags f ) = 0;
00377 
00378 signals:
00387     void timeout();
00388 
00390     void logMessage(const QString &);
00391 
00393     void logError(const QString &);
00394 
00400     void logProgress(const QString &s, int p);
00401 
00406     void deviceReady( KPilotLink * );
00407 
00408 
00409 public slots:
00414     virtual void close() = 0;
00415 
00421     virtual void reset() = 0;
00422 
00424     virtual bool tickle() = 0;
00425 
00426 protected:
00432     QString fPilotPath;
00433 
00442     void startTickle(unsigned int timeout=0);
00443 
00449     void stopTickle();
00450 
00456     virtual bool installFile( const QString &f, const bool deleteFile ) = 0;
00457 
00466     virtual int openConduit();
00467 
00474     virtual int pilotSocket() const;
00475 
00480     virtual void addSyncLogEntryImpl( const QString &s ) = 0;
00481 
00486     KPilotUser  *fPilotUser;
00487 
00492     KPilotSysInfo *fPilotSysInfo;
00493 
00494 
00495 private:
00496     bool fTickleDone;
00497     QThread *fTickleThread;
00498 
00499 } ;
00500 
00501 #endif