kpilot

vcal-conduitbase.h

Go to the documentation of this file.
00001 #ifndef _KPILOT_VCAL_CONDUITBASE_H
00002 #define _KPILOT_VCAL_CONDUITBASE_H
00003 /* vcal-conduit.h                       KPilot
00004 **
00005 ** Copyright (C) 2002-2003 Reinhold Kainhofer
00006 ** Copyright (C) 2001 by Dan Pilone
00007 **
00008 ** This file defines the vcal-conduit plugin.
00009 */
00010 
00011 /*
00012 ** This program is free software; you can redistribute it and/or modify
00013 ** it under the terms of the GNU General Public License as published by
00014 ** the Free Software Foundation; either version 2 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 General Public License for more details.
00021 **
00022 ** You should have received a copy of the GNU 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 
00033 #include <qstring.h>
00034 
00035 #include <libkcal/calendarlocal.h>
00036 
00037 #include <plugin.h>
00038 #include <pilotRecord.h>
00039 
00040 namespace KCal
00041 {
00042 class Calendar;
00043 class Incidence;
00044 }
00045 
00046 class PilotSerialDatabase;
00047 class PilotLocalDatabase;
00048 class VCalConduitSettings;
00049 
00050 class ConduitState;
00051 
00052 class VCalConduitPrivateBase
00053 {
00054 protected:
00055     bool reading;
00056     KCal::Calendar *fCalendar;
00057 public:
00058     VCalConduitPrivateBase(KCal::Calendar *buddy) : fCalendar(buddy)
00059     {
00060         reading = false;
00061     };
00062 
00063     virtual ~VCalConduitPrivateBase() { } ;
00064 
00065     virtual int updateIncidences() = 0;
00066     virtual void addIncidence(KCal::Incidence*) = 0;
00067     virtual void removeIncidence(KCal::Incidence*) = 0;
00068     virtual KCal::Incidence *findIncidence(recordid_t) = 0;
00069     virtual KCal::Incidence *findIncidence(PilotRecordBase *tosearch) = 0;
00070     virtual KCal::Incidence *getNextIncidence() = 0;
00071     virtual KCal::Incidence *getNextModifiedIncidence() = 0;
00072     virtual int count()=0;
00073 } ;
00074 
00075 class VCalConduitBase : public ConduitAction
00076 {
00077         Q_OBJECT
00078 public:
00079     VCalConduitBase(KPilotLink *,
00080         const char *name = 0L,
00081         const QStringList &args = QStringList());
00082     virtual ~VCalConduitBase();
00083 
00084 /*********************************************************************
00085                 D A T A   M E M B E R S ,   S E T T I N G S
00086  *********************************************************************/
00087 protected:
00088     KCal::Calendar *fCalendar;
00089     QString fCalendarFile;
00090     VCalConduitPrivateBase *fP;
00091     ConduitState *fState;
00092     bool hasNextRecord;
00093 
00094     virtual const QString dbname() = 0;
00095     virtual const QString getTitle(PilotRecordBase *de) = 0;
00096     virtual void readConfig();
00097 
00098     virtual bool exec();
00099 
00100 protected slots:
00107     void slotProcess();
00108 
00109 public:
00114     void setHasNextRecord( bool b ) 
00115     {
00116         hasNextRecord = b;
00117     }
00118 
00124     void setState( ConduitState *s );
00125 
00129     VCalConduitPrivateBase *privateBase() const
00130     {
00131         return fP;
00132     }
00133 
00138     PilotRecord *readRecordByIndex( int index );
00139 
00144     KCal::Incidence *incidenceFromRecord( PilotRecord *r );
00145 
00146     virtual void preIncidence( KCal::Incidence* ) {};
00147 
00148     // Getters
00149     KCal::Calendar *calendar() const { return fCalendar; };
00150     QString calendarFile() const { return fCalendarFile; };
00151 
00152     virtual VCalConduitSettings *config() = 0;
00153     virtual PilotDatabase *database() const { return fDatabase; };
00154     virtual PilotDatabase *localDatabase() const { return fLocalDatabase; };
00155 
00156     // add, change or delete records from the palm
00157     virtual void addPalmRecord( KCal::Incidence *e );
00158     virtual void changePalmRecord( KCal::Incidence *e, PilotRecord *s );
00159     virtual void deletePalmRecord( KCal::Incidence *e, PilotRecord *s );
00160 
00161     // add, change or delete events from the calendar
00162     virtual KCal::Incidence* changeRecord( PilotRecord*, PilotRecord* );
00163     virtual KCal::Incidence* deleteRecord( PilotRecord*, PilotRecord* );
00164     virtual KCal::Incidence* addRecord( PilotRecord * );
00165 
00166 /*********************************************************************
00167           P R E -   A N D   P O S T S Y N C   F U N C T I O N S
00168  *********************************************************************/
00169     virtual void preSync();
00170     virtual void postSync();
00171     virtual void preRecord(PilotRecord*) {};
00172 
00173 protected:
00174     virtual void updateIncidenceOnPalm(KCal::Incidence *e, PilotRecordBase *de);
00175 
00176 /*********************************************************************
00177                     S Y N C   F U N C T I O N S
00178                for creating events from Palm records or vice versa
00179  *********************************************************************/
00180     virtual PilotRecord *recordFromIncidence(PilotRecordBase *de,
00181         const KCal::Incidence *e) = 0;
00182     virtual PilotRecordBase *newPilotEntry(PilotRecord *r) = 0;
00183 
00184     virtual KCal::Incidence *newIncidence() = 0;
00185     virtual KCal::Incidence *incidenceFromRecord(KCal::Incidence *e,
00186         const PilotRecordBase *de) = 0;
00187 
00188 /*********************************************************************
00189                 M I S C   F U N C T I O N S
00190  *********************************************************************/
00197     virtual int resolveConflict(KCal::Incidence *e, PilotRecordBase *de);
00198     virtual bool openCalendar();
00199     virtual VCalConduitPrivateBase *createPrivateCalendarData(KCal::Calendar *fCalendar) = 0;
00200 } ;
00201 
00202 #endif