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);
00062     PilotLocalDatabase(const QString &name, bool useConduitDBs /* =false */);
00063 
00064 
00069     PilotLocalDatabase(const QString &name);
00070 
00071     virtual ~PilotLocalDatabase();
00072 
00077     virtual bool createDatabase(long creator=0,
00078         long type=0, int cardno=0, int flags=0, int version=0);
00079 
00080 
00081 
00085     virtual int deleteDatabase();
00086 
00087     // Reads the application block info
00088     virtual int readAppBlock(unsigned char* buffer, int maxLen);
00089     // Writes the application block info.
00090     virtual int writeAppBlock(unsigned char* buffer, int len);
00091     // returns the number of records in the database
00092     virtual int recordCount();
00093     // Returns a QValueList of all record ids in the database.
00094     virtual QValueList<recordid_t> idList();
00095     // Reads a record from database by id, returns record
00096     virtual PilotRecord* readRecordById(recordid_t id);
00097     // Reads a record from database, returns the record
00098     virtual PilotRecord* readRecordByIndex(int index);
00099     // Reads the next record from database in category 'category'
00100     virtual PilotRecord* readNextRecInCategory(int category);
00110     const PilotRecord *findNextNewRecord();
00111 
00117     virtual PilotRecord* readNextModifiedRec(int *ind=0L);
00118     // Writes a new record to database (if 'id' == 0, none is assigned, either)
00119     virtual recordid_t writeRecord(PilotRecord* newRecord);
00125     virtual int deleteRecord(recordid_t id, bool all=false);
00126     // Resets all records in the database to not dirty.
00127     virtual int resetSyncFlags();
00128     // Resets next record index to beginning
00129     virtual int resetDBIndex();
00130     // Purges all Archived/Deleted records from Palm Pilot database
00131     virtual int cleanup();
00132 
00133 
00138     virtual recordid_t  updateID(recordid_t id);
00139 
00140 
00142     QString getDBName() const { return fDBName; }
00143 
00149     virtual QString dbPathName() const;
00150 
00154     int appInfoSize() const
00155         { if (isDBOpen()) return fAppLen; else return -1; } ;
00156     char *appInfo() { return fAppInfo; } ;
00157 
00158     const struct DBInfo &getDBInfo() const { return fDBInfo; }
00159     void setDBInfo(const struct DBInfo &dbi) {fDBInfo=dbi; }
00160 
00161     virtual DBType dbType() const;
00162 
00163 
00164 protected:
00165     // Changes any forward slashes to underscores
00166     void fixupDBName();
00167     virtual void openDatabase();
00168     virtual void closeDatabase();
00169 
00170 private:
00171     struct DBInfo fDBInfo;
00172     QString fPathName,fDBName;
00173     char*       fAppInfo;
00174     size_t      fAppLen;
00175 
00176     class Private;
00177     Private *d;
00178 
00184 public:
00185     static void setDBPath(const QString &);
00186     static const QString *getDBPath() { return fPathBase; } ;
00187 private:
00188     static QString *fPathBase;
00189 };
00190 
00191 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys