kpilot Library API Documentation

pilotLocalDatabase.h

00001 #ifndef _KPILOT_PILOTLOCALDATABASE_H 00002 #define _KPILOT_PILOTLOCALDATABASE_H 00003 /* pilotLocalDatabase.h KPilot 00004 ** 00005 ** Copyright (C) 1998-2001 by Dan Pilone 00006 ** 00007 ** See the .cc file for an explanation of what this file is for. 00008 */ 00009 00010 /* 00011 ** This program is free software; you can redistribute it and/or modify 00012 ** it under the terms of the GNU Lesser General Public License as published by 00013 ** the Free Software Foundation; either version 2.1 of the License, or 00014 ** (at your option) any later version. 00015 ** 00016 ** This program is distributed in the hope that it will be useful, 00017 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 ** GNU Lesser General Public License for more details. 00020 ** 00021 ** You should have received a copy of the GNU Lesser General Public License 00022 ** along with this program in a file called COPYING; if not, write to 00023 ** the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 00024 ** MA 02111-1307, USA. 00025 */ 00026 00027 /* 00028 ** Bug reports and questions can be sent to kde-pim@kde.org 00029 */ 00030 00031 // Database class for a local (file based) pilot datbase. 00032 00033 #include <time.h> /* for broken pilot-link libraries */ 00034 00035 #ifndef _PILOT_MACROS_H_ 00036 #include <pi-macros.h> /* for recordid_t */ 00037 #endif 00038 00039 #ifndef _KPILOT_PILOTDATABASE_H 00040 #include "pilotDatabase.h" 00041 #endif 00042 00043 class PilotLocalDatabase : public PilotDatabase 00044 { 00045 public: 00056 PilotLocalDatabase( const QString& path, 00057 const QString& name, bool useDefaultPath=true, 00058 QObject *p=0L,const char *n=0L); 00069 PilotLocalDatabase(const QString &name, bool useConduitDBs=false, 00070 QObject *p=0L,const char *n=0L); 00071 00072 00073 virtual ~PilotLocalDatabase(); 00074 00076 virtual bool createDatabase(long creator=0, long type=0, int cardno=0, int flags=0, int version=0); 00078 virtual int deleteDatabase(); 00079 // Reads the application block info 00080 virtual int readAppBlock(unsigned char* buffer, int maxLen); 00081 // Writes the application block info. 00082 virtual int writeAppBlock(unsigned char* buffer, int len); 00083 // returns the number of records in the database 00084 virtual int recordCount(); 00085 // Returns a QValueList of all record ids in the database. 00086 virtual QValueList<recordid_t> idList(); 00087 // Reads a record from database by id, returns record length 00088 virtual PilotRecord* readRecordById(recordid_t id); 00089 // Reads a record from database, returns the record length 00090 virtual PilotRecord* readRecordByIndex(int index); 00091 // Reads the next record from database in category 'category' 00092 virtual PilotRecord* readNextRecInCategory(int category); 00098 virtual PilotRecord* readNextModifiedRec(int *ind=NULL); 00099 // Writes a new record to database (if 'id' == 0, one will be assigned to newRecord) 00100 virtual recordid_t writeRecord(PilotRecord* newRecord); 00106 virtual int deleteRecord(recordid_t id, bool all=false); 00107 // Resets all records in the database to not dirty. 00108 virtual int resetSyncFlags(); 00109 // Resets next record index to beginning 00110 virtual int resetDBIndex(); 00111 // Purges all Archived/Deleted records from Palm Pilot database 00112 virtual int cleanup(); 00113 00114 00115 // Writes a new ID to the record specified the index. Not supported on Serial connections 00116 virtual recordid_t writeID(PilotRecord* rec); 00117 QString getDBName() const { return fDBName; } 00118 00124 virtual QString dbPathName() const; 00125 00129 int appInfoSize() const 00130 { if (isDBOpen()) return fAppLen; else return -1; } ; 00131 char *appInfo() { return fAppInfo; } ; 00132 00133 struct DBInfo getDBInfo() const { return fDBInfo; } 00134 void setDBInfo(struct DBInfo dbi) {fDBInfo=dbi; } 00135 00136 protected: 00137 // Changes any forward slashes to underscores 00138 void fixupDBName(); 00139 virtual void openDatabase(); 00140 virtual void closeDatabase(); 00141 00142 private: 00143 struct DBInfo fDBInfo; 00144 QString fPathName,fDBName; 00145 char* fAppInfo; 00146 int fAppLen; 00147 int fNumRecords; 00148 int fCurrentRecord; 00149 PilotRecord* fRecords[10000]; // Current max records in DB.. hope it's enough 00150 int fPendingRec; // Temp index for the record about to get an ID. 00151 00152 00158 public: 00159 static void setDBPath(const QString &); 00160 static const QString *getDBPath() { return fPathBase; } ; 00161 private: 00162 static QString *fPathBase; 00163 }; 00164 00165 #endif
KDE Logo
This file is part of the documentation for kpilot Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jul 28 23:57:49 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003