kpilot/lib

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 ** 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 #include "pilotDatabase.h"
00033 
00034 class KDE_EXPORT PilotLocalDatabase : public PilotDatabase
00035 {
00036 public:
00048     PilotLocalDatabase( const QString& path,
00049         const QString& name, bool useDefaultPath=true);
00050 
00055     PilotLocalDatabase(const QString &name);
00056 
00057     virtual ~PilotLocalDatabase();
00058 
00063     virtual bool createDatabase(long creator=0,
00064         long type=0, int cardno=0, int flags=0, int version=0);
00065 
00066 
00067 
00071     virtual int deleteDatabase();
00072 
00073     // Reads the application block info
00074     virtual int readAppBlock(unsigned char* buffer, int maxLen);
00075     // Writes the application block info.
00076     virtual int writeAppBlock(unsigned char* buffer, int len);
00077     // returns the number of records in the database, 0 if not open
00078     virtual unsigned int recordCount() const;
00079     // Returns a QValueList of all record ids in the database.
00080     virtual QValueList<recordid_t> idList();
00081     // Reads a record from database by id, returns record
00082     virtual PilotRecord* readRecordById(recordid_t id);
00083     // Reads a record from database, returns the record
00084     virtual PilotRecord* readRecordByIndex(int index);
00085     // Reads the next record from database in category 'category'
00086     virtual PilotRecord* readNextRecInCategory(int category);
00096     const PilotRecord *findNextNewRecord();
00097 
00103     virtual PilotRecord* readNextModifiedRec(int *ind=0L);
00104     // Writes a new record to database (if 'id' == 0, none is assigned, either)
00105     virtual recordid_t writeRecord(PilotRecord* newRecord);
00111     virtual int deleteRecord(recordid_t id, bool all=false);
00112     // Resets all records in the database to not dirty.
00113     virtual int resetSyncFlags();
00114     // Resets next record index to beginning
00115     virtual int resetDBIndex();
00116     // Purges all Archived/Deleted records from Palm Pilot database
00117     virtual int cleanup();
00118 
00119 
00124     virtual recordid_t  updateID(recordid_t id);
00125 
00126 
00128     QString getDBName() const { return fDBName; }
00129 
00135     virtual QString dbPathName() const;
00136 
00140     int appInfoSize() const
00141         { if (isOpen()) return fAppLen; else return -1; } ;
00142     char *appInfo() { return fAppInfo; } ;
00143 
00144     const struct DBInfo &getDBInfo() const { return fDBInfo; }
00145     void setDBInfo(const struct DBInfo &dbi) {fDBInfo=dbi; }
00146 
00147     virtual DBType dbType() const;
00148 
00160     static bool infoFromFile( const QString &path, DBInfo *d );
00161 
00162 protected:
00163     // Changes any forward slashes to underscores
00164     void fixupDBName();
00165     virtual void openDatabase();
00166     virtual void closeDatabase();
00167 
00168 private:
00169     struct DBInfo fDBInfo;
00170     QString fPathName,fDBName;
00171     char*       fAppInfo;
00172     size_t      fAppLen;
00173 
00174     class Private;
00175     Private *d;
00176 
00182 public:
00183     static void setDBPath(const QString &);
00184     static const QString &getDBPath() { return *fPathBase; } ;
00185 private:
00186     static QString *fPathBase;
00187 };
00188 
00189 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys