kpilot Library API Documentation

knotes-conduit.h

00001 /* knotes-conduit.h                     KPilot
00002 **
00003 ** Copyright (C) 2000-2001 by Adriaan de Groot
00004 **
00005 ** This file is part of the KNotes conduit, a conduit for KPilot that
00006 ** synchronises the Pilot's memo pad application with KNotes.
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., 59 Temple Place, Suite 330, Boston, 
00023 ** MA 02111-1307, USA.
00024 */
00025 
00026 /*
00027 ** Bug reports and questions can be sent to kde-pim@kde.org
00028 */
00029 
00030 #ifndef _KPILOT_KNOTES_CONDUIT_H
00031 #define _KPILOT_KNOTES_CONDUIT_H
00032 
00033 #ifndef _KPILOT_BASECONDUIT_H
00034 #include "baseConduit.h"
00035 #endif
00036 
00037 
00038 class PilotRecord;
00039 class PilotMemo;
00040 
00041 #ifndef QSTRING_H
00042 #include <qstring.h>
00043 #endif
00044 
00045 #ifndef QMAP_H
00046 #include <qmap.h>
00047 #endif
00048 
00049 
00050 
00051 // This class stores information about notes.
00052 // We construct a map that associates note names
00053 // with NotesSettings so that we can quickly 
00054 // find out which notes are new / changed / old
00055 // or deleted without having to re-read all those
00056 // KNotes config files every time.
00057 //
00058 //
00059 class NotesSettings
00060 {
00061 public:
00062         // Both of these constructores are deprecated.
00063         //
00064         //
00065         NotesSettings() {} ;
00066         NotesSettings(const QString& name,
00067                 const QString& configPath,
00068                 const QString& dataPath,
00069                 unsigned long pilotID) :
00070                 nN(name),
00071                 cP(configPath),dP(dataPath),id(pilotID),
00072                 checksum(0L),csValid(false) {} ;
00073 
00074         NotesSettings(const QString &configPath,
00075                 const QString &notesdir,
00076                 KConfig& c);
00077 
00078         const QString& name() const { return nN; } ;
00079         const QString& configPath() const { return cP; } ;
00080         const QString& dataPath() const { return dP; } ;
00081         unsigned long pilotID() const { return id; } ;
00082 
00083         bool isNew() const { return id == 0L ; } ;
00084         void setId(unsigned long i) { id=i; } ;
00085 
00086         QString checkSum() const { return checksum; } ;
00087         bool isCheckSumValid() const { return csValid; } ;
00094         bool isChanged() const 
00095         { 
00096                 QString newCS = computeCheckSum();
00097                 return !csValid || (newCS != checksum) ; 
00098         }
00099 
00100         QString updateCheckSum() 
00101         { 
00102                 checksum=computeCheckSum(); 
00103                 csValid = !checksum.isNull();
00104                 return checksum; 
00105         } ;
00106         QString computeCheckSum() const;
00107 
00114         int readNotesData(char *text);
00115 
00116 private:
00117         QString nN,cP,dP;
00118         unsigned long id;
00127         QString checksum;
00128         bool csValid;           // Checksum valid?
00129 } ;
00130 
00131 typedef QMap<QString,NotesSettings> NotesMap;
00132 
00133 class KNotesConduit : public BaseConduit
00134 {
00135 public:
00136   KNotesConduit(eConduitMode mode);
00137   virtual ~KNotesConduit();
00138   
00139   virtual void doSync();
00140   virtual QWidget* aboutAndSetup();
00141 
00142   virtual const char* dbInfo() ; // { return NULL; }
00143   virtual void doTest();
00144 
00145 protected:
00146         int notesToPilot(NotesMap&);
00147         int pilotToNotes(NotesMap&);
00148 
00153         bool addNewNote(NotesSettings&);
00154         bool changeNote(NotesSettings&);
00155 
00156         bool changeMemo(NotesMap&,NotesMap::Iterator,PilotMemo *);
00157         bool newMemo(NotesMap&,unsigned long id,PilotMemo *);
00164         bool deleteNote(NotesMap&,NotesMap::Iterator *,unsigned long);
00165 
00166 private:
00172         void readConfig();
00173 
00180         bool fDeleteNoteForMemo;
00181 };
00182 
00183 #endif
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sun Feb 15 11:40:43 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2001