kpilot/lib

PilotLocalDatabase Class Reference

Inheritance diagram for PilotLocalDatabase:

PilotDatabase List of all members.

Detailed Description

Definition at line 34 of file pilotLocalDatabase.h.


Public Member Functions

 PilotLocalDatabase (const QString &path, const QString &name, bool useDefaultPath=true)
 PilotLocalDatabase (const QString &name)
virtual ~PilotLocalDatabase ()
virtual bool createDatabase (long creator=0, long type=0, int cardno=0, int flags=0, int version=0)
virtual int deleteDatabase ()
virtual int readAppBlock (unsigned char *buffer, int maxLen)
virtual int writeAppBlock (unsigned char *buffer, int len)
virtual unsigned int recordCount () const
virtual QValueList< recordid_t > idList ()
virtual PilotRecordreadRecordById (recordid_t id)
virtual PilotRecordreadRecordByIndex (int index)
virtual PilotRecordreadNextRecInCategory (int category)
const PilotRecordfindNextNewRecord ()
virtual PilotRecordreadNextModifiedRec (int *ind=0L)
virtual recordid_t writeRecord (PilotRecord *newRecord)
virtual int deleteRecord (recordid_t id, bool all=false)
virtual int resetSyncFlags ()
virtual int resetDBIndex ()
virtual int cleanup ()
virtual recordid_t updateID (recordid_t id)
QString getDBName () const
virtual QString dbPathName () const
int appInfoSize () const
char * appInfo ()
DBInfo & getDBInfo () const
void setDBInfo (const struct DBInfo &dbi)
virtual DBType dbType () const

Static Public Member Functions

static bool infoFromFile (const QString &path, DBInfo *d)
static void setDBPath (const QString &)
static const QString & getDBPath ()

Protected Member Functions

void fixupDBName ()
virtual void openDatabase ()
virtual void closeDatabase ()

Constructor & Destructor Documentation

PilotLocalDatabase::PilotLocalDatabase ( const QString &  path,
const QString &  name,
bool  useDefaultPath = true 
)

Opens the local database.

If the database cannot be found at the given position, a default path is used ($KDEHOME/share/apps/kpilot/DBBackup) and if the file is found there, it is opened. In some cases this should not be done, so the parameter useDefaultPath controls this behavior. If it is set to true, the default path is used if the file cannot be found in the explicitly given location. If it is set to false and the database cannot be found, no database is opened. It can then be created explicitly at the specified location.

Definition at line 82 of file pilotLocalDatabase.cc.

PilotLocalDatabase::PilotLocalDatabase ( const QString &  name  ) 

Opens the local database.

This is primarily for testing purposes; only tries the given path.

Definition at line 116 of file pilotLocalDatabase.cc.


Member Function Documentation

bool PilotLocalDatabase::createDatabase ( long  creator = 0,
long  type = 0,
int  cardno = 0,
int  flags = 0,
int  version = 0 
) [virtual]

Creates the database with the given creator, type and flags on the given card (default is RAM).

If the database already exists, this function does nothing.

Implements PilotDatabase.

Definition at line 157 of file pilotLocalDatabase.cc.

int PilotLocalDatabase::deleteDatabase (  )  [virtual]

Deletes the database (by name, as given in the constructor and stored in the fDBName field.

)

Implements PilotDatabase.

Definition at line 198 of file pilotLocalDatabase.cc.

int PilotLocalDatabase::readAppBlock ( unsigned char *  buffer,
int  maxLen 
) [virtual]

Reads the application block info, returns size.

Implements PilotDatabase.

Definition at line 221 of file pilotLocalDatabase.cc.

int PilotLocalDatabase::writeAppBlock ( unsigned char *  buffer,
int  len 
) [virtual]

Writes the application block info.

Implements PilotDatabase.

Definition at line 238 of file pilotLocalDatabase.cc.

unsigned int PilotLocalDatabase::recordCount (  )  const [virtual]

Returns the number of records in the database.

If the database is not open, return -1.

Implements PilotDatabase.

Definition at line 257 of file pilotLocalDatabase.cc.

QValueList< recordid_t > PilotLocalDatabase::idList (  )  [virtual]

Returns a QValueList of all record ids in the database.

This implementation is really bad.

Reimplemented from PilotDatabase.

Definition at line 271 of file pilotLocalDatabase.cc.

PilotRecord * PilotLocalDatabase::readRecordById ( recordid_t  id  )  [virtual]

Reads a record from database by id, returns record length.

Implements PilotDatabase.

Definition at line 290 of file pilotLocalDatabase.cc.

PilotRecord * PilotLocalDatabase::readRecordByIndex ( int  index  )  [virtual]

Reads a record from database, returns the record length.

Implements PilotDatabase.

Definition at line 315 of file pilotLocalDatabase.cc.

PilotRecord * PilotLocalDatabase::readNextRecInCategory ( int  category  )  [virtual]

Reads the next record from database in category 'category'.

Implements PilotDatabase.

Definition at line 345 of file pilotLocalDatabase.cc.

const PilotRecord * PilotLocalDatabase::findNextNewRecord (  ) 

Returns the next "new" record, ie.

the next record that has not been synced yet. These records all have ID=0, so are not easy to find with the other methods. The record is the one contained in the database, not a copy like the read*() functions give you -- so be careful with it. Don't delete it, in any case. Casting it to non-const and marking it deleted is OK, though, which is mostly its intended use.

Definition at line 369 of file pilotLocalDatabase.cc.

PilotRecord * PilotLocalDatabase::readNextModifiedRec ( int *  ind = 0L  )  [virtual]

Reads the next record from database that has the dirty flag set.

ind (if a valid pointer is given) will receive the index of the returned record.

Implements PilotDatabase.

Definition at line 394 of file pilotLocalDatabase.cc.

recordid_t PilotLocalDatabase::writeRecord ( PilotRecord newRecord  )  [virtual]

Writes a new record to database (if 'id' == 0, one will be assigned to newRecord).

Implements PilotDatabase.

Definition at line 449 of file pilotLocalDatabase.cc.

int PilotLocalDatabase::deleteRecord ( recordid_t  id,
bool  all = false 
) [virtual]

Deletes a record with the given recordid_t from the database, or all records, if all is set to true.

The recordid_t will be ignored in this case. Return value is negative on error, 0 otherwise.

Implements PilotDatabase.

Definition at line 490 of file pilotLocalDatabase.cc.

int PilotLocalDatabase::resetSyncFlags (  )  [virtual]

Resets all records in the database to not dirty.

Implements PilotDatabase.

Definition at line 527 of file pilotLocalDatabase.cc.

int PilotLocalDatabase::resetDBIndex (  )  [virtual]

Resets next record index to beginning.

Implements PilotDatabase.

Definition at line 545 of file pilotLocalDatabase.cc.

int PilotLocalDatabase::cleanup (  )  [virtual]

Purges all Archived/Deleted records from Palm Pilot database.

Implements PilotDatabase.

Definition at line 558 of file pilotLocalDatabase.cc.

recordid_t PilotLocalDatabase::updateID ( recordid_t  id  )  [virtual]

Update the ID of the current record in the database with the specified.

Parameters:
id . This is allowed only after reading or writing a modified or new record.

Definition at line 428 of file pilotLocalDatabase.cc.

QString PilotLocalDatabase::getDBName (  )  const [inline]

Return the name of the database (as it would be on the handheld).

Definition at line 128 of file pilotLocalDatabase.h.

QString PilotLocalDatabase::dbPathName (  )  const [virtual]

Returns the full path of the current database, based on the path and dbname passed to the constructor, and including the .pdb extension.

Implements PilotDatabase.

Definition at line 590 of file pilotLocalDatabase.cc.

int PilotLocalDatabase::appInfoSize (  )  const [inline]

Accessor functions for the application info block.

Definition at line 140 of file pilotLocalDatabase.h.

bool PilotLocalDatabase::infoFromFile ( const QString &  path,
DBInfo *  d 
) [static]

Reads local file path and fills in the DBInfo structure d with the DBInfo from the file.

Returns:
false if d is NULL

false if the file path does not exist

true if reading the DBInfo succeeds

Note:
Relatively expensive operation, since the pilot-link library doesn't provide a cheap way of getting this information.

Definition at line 733 of file pilotLocalDatabase.cc.

void PilotLocalDatabase::setDBPath ( const QString &   )  [static]

For databases opened by name only (constructor 2 -- which is the preferred one, too) try this path first before the default path.

Set statically so it's shared for all local databases.

Definition at line 708 of file pilotLocalDatabase.cc.


The documentation for this class was generated from the following files:
KDE Home | KDE Accessibility Home | Description of Access Keys