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 
00039 class KDE_EXPORT PilotSerialDatabase : public PilotDatabase
00040 {
00041 public:
00042     PilotSerialDatabase(int linksocket, const QString &dbName);
00043     virtual ~PilotSerialDatabase();
00044 
00046     virtual int readAppBlock(unsigned char* buffer, int maxLen);
00048     virtual int writeAppBlock(unsigned char* buffer, int len);
00050     virtual int recordCount();
00052      virtual QValueList<recordid_t> idList();
00054     virtual PilotRecord* readRecordById(recordid_t id);
00056     virtual PilotRecord* readRecordByIndex(int index);
00058     virtual PilotRecord* readNextRecInCategory(int category);
00064     virtual PilotRecord* readNextModifiedRec(int *ind=NULL);
00065 
00070     virtual recordid_t writeRecord(PilotRecord* newRecordb);
00071 
00077     virtual int deleteRecord(recordid_t id, bool all=false);
00079     virtual int resetSyncFlags();
00081     virtual int resetDBIndex();
00083     virtual int cleanup();
00084 
00085     virtual QString dbPathName() const;
00086 
00091     virtual int deleteDatabase();
00092 
00098     virtual bool createDatabase(long creator=0,
00099         long type=0, int cardno=0, int flags=0, int version=0);
00100     QString getDBName() { return fDBName; }
00101 
00102 
00103     virtual DBType dbType() const;
00104 
00105 protected:
00106     virtual void openDatabase();
00107     virtual void closeDatabase();
00108     int getDBHandle() { return fDBHandle; }
00109 
00110 
00111 private:
00112     void setDBHandle(int handle) { fDBHandle = handle; }
00113 
00114     QString     fDBName;
00115     int         fDBHandle;
00116     int         fDBSocket;
00117 #if PILOT_LINK_NUMBER >= PILOT_LINK_0_12_0
00118     // Pilot-link 0.12 allocates buffers as needed and resizes them.
00119     // Start with a buffer that is _probably_ big enough for most 
00120     // PIM records, but much smaller than the 64k that we use otherwise.
00121     // Might want to add algorithm for trying to optimize the initial 
00122     // allocation for a given database.
00123     static const int InitialBufferSize = 2048;
00124 #endif
00125 };
00126 
00127 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys