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);
00059         PilotLocalDatabase(const QString &name,
00060                 QObject *p=0L,const char *n=0L);
00061 
00062 
00063         virtual ~PilotLocalDatabase();
00064 
00066         virtual bool createDatabase(long creator=0, long type=0, int cardno=0, int flags=0, int version=0);
00068         virtual int deleteDatabase();
00069         // Reads the application block info
00070         virtual int readAppBlock(unsigned char* buffer, int maxLen);
00071         // Writes the application block info.
00072         virtual int writeAppBlock(unsigned char* buffer, int len);
00073         // returns the number of records in the database
00074         virtual int recordCount();
00075         // Returns a QValueList of all record ids in the database.
00076         virtual QValueList<recordid_t> idList();
00077         // Reads a record from database by id, returns record length
00078         virtual PilotRecord* readRecordById(recordid_t id);
00079         // Reads a record from database, returns the record length
00080         virtual PilotRecord* readRecordByIndex(int index);
00081         // Reads the next record from database in category 'category'
00082         virtual PilotRecord* readNextRecInCategory(int category);
00088         virtual PilotRecord* readNextModifiedRec(int *ind=NULL);
00089         // Writes a new record to database (if 'id' == 0, one will be assigned to newRecord)
00090         virtual recordid_t writeRecord(PilotRecord* newRecord);
00096         virtual int deleteRecord(recordid_t id, bool all=false);
00097         // Resets all records in the database to not dirty.
00098         virtual int resetSyncFlags();
00099         // Resets next record index to beginning
00100         virtual int resetDBIndex();
00101         // Purges all Archived/Deleted records from Palm Pilot database
00102         virtual int cleanup();
00103 
00104 
00105         // Writes a new ID to the record specified the index.  Not supported on Serial connections
00106         virtual recordid_t writeID(PilotRecord* rec);
00107         QString getDBName() const { return fDBName; }
00108 
00114         virtual QString dbPathName() const;
00115 
00119         int appInfoSize() const
00120                 { if (isDBOpen()) return fAppLen; else return -1; } ;
00121         char *appInfo() { return fAppInfo; } ;
00122 
00123 protected:
00124         // Changes any forward slahses to underscores
00125         void fixupDBName();
00126         virtual void openDatabase();
00127         virtual void closeDatabase();
00128 
00129 private:
00130         struct DBInfo fDBInfo;
00131         QString fPathName,fDBName;
00132         char*       fAppInfo;
00133         int         fAppLen;
00134         int         fNumRecords;
00135         int         fCurrentRecord;
00136         PilotRecord* fRecords[10000]; // Current max records in DB.. hope it's enough
00137         int         fPendingRec; // Temp index for the record about to get an ID.
00138 
00139 
00145 public:
00146         static void setDBPath(const QString &);
00147         static const QString *getDBPath() { return fPathBase; } ;
00148 private:
00149         static QString *fPathBase;
00150 };
00151 
00152 #endif
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sat Oct 18 02:47:14 2003 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001