kpilot/lib

pilotSerialDatabase.h

00001 #ifndef _KPILOT_PILOTSERIALDATABASE_H
00002 #define _KPILOT_PILOTSERIALDATABASE_H
00003 /* pilotSerialDatabase.h            KPilot
00004 **
00005 ** Copyright (C) 1998-2001 by Dan Pilone
00006 ** Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
00007 **
00008 ** See the .cc file for an explanation of what this file is for.
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 // Database class for a database on the pilot connected
00033 // via the serial port (ie: hot-sync cradle)
00034 
00035 #include "pilotDatabase.h"
00036 #include "pilotRecord.h"
00037 
00038 class KPilotDeviceLink;
00039 
00040 class KDE_EXPORT PilotSerialDatabase : public PilotDatabase
00041 {
00042 friend class KPilotDeviceLink;
00043 protected:
00044     PilotSerialDatabase( KPilotDeviceLink *l, const QString &dbName);
00045 
00046 public:
00047     virtual ~PilotSerialDatabase();
00048 
00050     virtual int readAppBlock(unsigned char* buffer, int maxLen);
00052     virtual int writeAppBlock(unsigned char* buffer, int len);
00054     virtual unsigned int recordCount() const;
00056      virtual QValueList<recordid_t> idList();
00058     virtual PilotRecord* readRecordById(recordid_t id);
00060     virtual PilotRecord* readRecordByIndex(int index);
00062     virtual PilotRecord* readNextRecInCategory(int category);
00068     virtual PilotRecord* readNextModifiedRec(int *ind=NULL);
00069 
00074     virtual recordid_t writeRecord(PilotRecord* newRecordb);
00075 
00081     virtual int deleteRecord(recordid_t id, bool all=false);
00083     virtual int resetSyncFlags();
00085     virtual int resetDBIndex();
00087     virtual int cleanup();
00088 
00089     virtual QString dbPathName() const;
00090 
00095     virtual int deleteDatabase();
00096 
00102     virtual bool createDatabase(long creator=0,
00103         long type=0, int cardno=0, int flags=0, int version=0);
00104     QString getDBName() { return fDBName; }
00105 
00106 
00107     virtual DBType dbType() const;
00108 
00109 protected:
00110     virtual void openDatabase();
00111     virtual void closeDatabase();
00115     int getDBHandle() const
00116     {
00117         return fDBHandle;
00118     }
00119 
00120 
00121 private:
00122     void setDBHandle(int handle) { fDBHandle = handle; }
00123 
00124     QString     fDBName;
00125     int         fDBHandle;
00126     int         fDBSocket;
00127     // Pilot-link 0.12 allocates buffers as needed and resizes them.
00128     // Start with a buffer that is _probably_ big enough for most 
00129     // PIM records, but much smaller than the 64k that we use otherwise.
00130     // Might want to add algorithm for trying to optimize the initial 
00131     // allocation for a given database.
00132     static const int InitialBufferSize = 2048;
00133 };
00134 
00135 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys