kpilot

recordConduit.h

Go to the documentation of this file.
00001 #ifndef _KPILOT_RECORDCONDUIT_H
00002 #define _KPILOT_RECORDCONDUIT_H
00003 /* record-conduit.h                           KPilot
00004 **
00005 ** Copyright (C) 2005 by Adriaan de Groot
00006 **
00007 */
00008 
00009 /*
00010 ** This program is free software; you can redistribute it and/or modify
00011 ** it under the terms of the GNU General Public License as published by
00012 ** the Free Software Foundation; either version 2 of the License, or
00013 ** (at your option) any later version.
00014 **
00015 ** This program is distributed in the hope that it will be useful,
00016 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00018 ** GNU General Public License for more details.
00019 **
00020 ** You should have received a copy of the GNU General Public License
00021 ** along with this program in a file called COPYING; if not, write to
00022 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00023 ** MA 02110-1301, USA.
00024 */
00025 
00026 /*
00027 ** Bug reports and questions can be sent to kde-pim@kde.org
00028 */
00029 
00030 #include <qtimer.h>
00031 #include <klocale.h>
00032 
00033 #include "plugin.h"
00034 #include "pilot.h"
00035 #include "pilotDatabase.h"
00036 #include "kpilotdevicelink.h"
00037 
00038 class KPilotDeviceLink;
00039 
00056 class RecordConduitBase : public ConduitAction
00057 {
00058 Q_OBJECT
00059 public:
00062     RecordConduitBase(KPilotDeviceLink *o,
00063         const char *n,
00064         const QStringList a = QStringList()) :
00065         ConduitAction(o,n,a),
00066         fTimer(0L)
00067     {
00068     } ;
00070     virtual ~RecordConduitBase()
00071     {
00072         // delete fTimer; // Timer is a child object
00073     } ;
00074 
00080     enum SyncProgress { NotDone=0, Done=1, Error=2 } ;
00081 
00083     static QString name(SyncProgress s);
00084 
00086     enum States { Initialize, PalmToPC, PCToPalm, Cleanup } ;
00087 
00088     static QString name(States s);
00089 
00090 protected:
00095     virtual SyncProgress loadPC() = 0;
00096 
00103     virtual SyncProgress palmRecToPC() = 0;
00104 
00111     virtual SyncProgress pcRecToPalm() = 0;
00112 
00119     virtual SyncProgress cleanup() = 0;
00120 
00121 protected slots:
00125     void process();
00126 
00127 protected:
00128     virtual bool exec();
00129 
00130 private:
00132     QTimer *fTimer;
00133 
00134     States fState;
00135 
00136     Pilot::RecordIDList fIDList;
00137     Pilot::RecordIDList::Iterator fIDListIterator;
00138 
00139     QString fDBName;
00140 } ;
00141 
00142 template <class PCEntry, class PCContainer, class HHEntry, class HHAppInfo, class Syncer>
00143 class RecordConduit : public RecordConduitBase
00144 {
00145 public:
00147     RecordConduit(
00148         KPilotDeviceLink *o ,
00149         const char *n ,
00150         const QStringList a = QStringList() ) :
00151         RecordConduitBase(o,n,a)
00152     {
00153     } ;
00154     virtual ~RecordConduit()
00155     {
00156     } ;
00157 
00158     virtual SyncProgress loadPC()
00159     {
00160         return Done;
00161     } ;
00162 
00163     virtual SyncProgress palmRecToPC()
00164     {
00165         return Done;
00166     }
00167 
00168     virtual SyncProgress pcRecToPalm()
00169     {
00170         return Done;
00171     }
00172 
00173     virtual SyncProgress cleanup()
00174     {
00175         return Done;
00176     }
00177 } ;
00178 
00179 
00180 #endif
00181