#include <SQLiteContactSource.h>
Public Member Functions | |
SQLiteContactSource (const EvolutionSyncSourceParams ¶ms) | |
Protected Member Functions | |
virtual void | open () |
virtual void | close () |
virtual Databases | getDatabases () |
virtual SyncItem * | createItem (const string &uid) |
virtual string | fileSuffix () const |
virtual const char * | getMimeType () const |
virtual const char * | getMimeVersion () const |
virtual const char * | getSupportedTypes () const |
virtual void | logItem (const string &uid, const string &info, bool debug=false) |
virtual void | logItem (const SyncItem &item, const string &info, bool debug=false) |
virtual void | listAllItems (RevisionMap_t &revisions) |
virtual InsertItemResult | insertItem (const string &uid, const SyncItem &item) |
virtual void | deleteItem (const string &uid) |
The handling of the "N" and "ORG" property shows how mapping between one property and multiple different columns works.
Properties which can occur more than once per contact like address, email and phone numbers are not supported. They would have to be stored in additional tables.
Change tracking is done by implementing a modification date as part of each contact and using that as the revision string required by TrackingSyncSource, which then takes care of change tracking.
The database file is created automatically if the database ID is file:///<path>.
Definition at line 48 of file SQLiteContactSource.h.
SQLiteContactSource::SQLiteContactSource | ( | const EvolutionSyncSourceParams & | params | ) | [inline] |
Definition at line 51 of file SQLiteContactSource.h.
void SQLiteContactSource::close | ( | ) | [protected, virtual] |
closes the data source so that it can be reopened
Just as open() it should not affect the state of the database unless some previous action requires it.
Implements TrackingSyncSource.
Definition at line 162 of file SQLiteContactSource.cpp.
References SQLiteUtil::close(), and EvolutionSyncSource::sleepSinceModification().
SyncItem * SQLiteContactSource::createItem | ( | const string & | uid | ) | [protected, virtual] |
Extract information for the item identified by UID and store it in a new SyncItem. The caller must free that item. May throw exceptions.
uid | identifies the item |
Implements TrackingSyncSource.
Definition at line 193 of file SQLiteContactSource.cpp.
References SQLiteUtil::checkSQL(), SQLiteUtil::getMapping(), getMimeType(), EvolutionSyncSource::getName(), SQLiteUtil::getTextColumn(), logItem(), PERSON_DEPARTMENT, PERSON_FIRST, PERSON_LAST, PERSON_MIDDLE, PERSON_ORGANIZATION, PERSON_PREFIX, PERSON_SUFFIX, PERSON_UNIT, SQLiteUtil::prepareSQL(), eptr< T, T, CxxUnref< T > >::release(), and SQLiteUtil::rowToVObject().
void SQLiteContactSource::deleteItem | ( | const string & | uid | ) | [protected, virtual] |
removes and item
Implements TrackingSyncSource.
Definition at line 383 of file SQLiteContactSource.cpp.
References SQLiteUtil::checkSQL(), SQLiteUtil::prepareSQL(), and eptr< T, base, R >::set().
virtual string SQLiteContactSource::fileSuffix | ( | ) | const [inline, protected, virtual] |
file suffix for database files
Implements TrackingSyncSource.
Definition at line 61 of file SQLiteContactSource.h.
SQLiteContactSource::Databases SQLiteContactSource::getDatabases | ( | ) | [protected, virtual] |
returns a list of all know sources for the kind of items supported by this sync source
Implements TrackingSyncSource.
Definition at line 174 of file SQLiteContactSource.cpp.
virtual const char* SQLiteContactSource::getMimeType | ( | ) | const [inline, protected, virtual] |
Returns the preferred mime type of the items handled by the sync source. Example: "text/x-vcard"
Implements TrackingSyncSource.
Definition at line 62 of file SQLiteContactSource.h.
Referenced by createItem().
virtual const char* SQLiteContactSource::getMimeVersion | ( | ) | const [inline, protected, virtual] |
Returns the version of the mime type used by client. Example: "2.1"
Implements TrackingSyncSource.
Definition at line 63 of file SQLiteContactSource.h.
virtual const char* SQLiteContactSource::getSupportedTypes | ( | ) | const [inline, protected, virtual] |
A string representing the source types (with versions) supported by the SyncSource. The string must be formatted as a sequence of "type:version" separated by commas ','. For example: "text/x-vcard:2.1,text/vcard:3.0". The version can be left empty, for example: "text/x-s4j-sifc:". Supported types will be sent as part of the DevInf.
Implements TrackingSyncSource.
Definition at line 64 of file SQLiteContactSource.h.
TrackingSyncSource::InsertItemResult SQLiteContactSource::insertItem | ( | const string & | uid, | |
const SyncItem & | item | |||
) | [protected, virtual] |
Create or modify an item.
The sync source should be flexible: if the UID is non-empty, it shall modify the item referenced by the UID. If the UID is empty, the normal operation is to add it. But if the item already exists (e.g., a calendar event which was imported by the user manually), then the existing item should be updated also in the second case.
Passing a UID of an item which does not exist is an error. This error should be reported instead of covering it up by (re)creating the item.
Errors are signalled by throwing an exception. Returning empty strings in the result is an error which triggers an "item could not be stored" error.
uid | identifies the item to be modified, empty for creating | |
item | contains the new content of the item and its MIME type |
Implements TrackingSyncSource.
Definition at line 246 of file SQLiteContactSource.cpp.
References SQLiteUtil::checkSQL(), SQLiteUtil::findColumn(), SQLiteUtil::getMapping(), PERSON_DEPARTMENT, PERSON_FIRST, PERSON_FIRSTSORT, PERSON_LAST, PERSON_LASTSORT, PERSON_MIDDLE, PERSON_ORGANIZATION, PERSON_PREFIX, PERSON_SUFFIX, PERSON_UNIT, SQLiteUtil::prepareSQL(), EvolutionSyncSource::throwError(), SQLiteUtil::time2str(), and SQLiteUtil::vObjectToRow().
void SQLiteContactSource::listAllItems | ( | RevisionMap_t & | revisions | ) | [protected, virtual] |
Definition at line 183 of file SQLiteContactSource.cpp.
References SQLiteUtil::checkSQL(), SQLiteUtil::getTimeColumn(), SQLiteUtil::prepareSQL(), SQLITE3_COLUMN_KEY, SQLiteUtil::time2str(), and SQLiteUtil::toString().
void SQLiteContactSource::logItem | ( | const SyncItem & | item, | |
const string & | info, | |||
bool | debug = false | |||
) | [protected, virtual] |
Implements TrackingSyncSource.
Definition at line 407 of file SQLiteContactSource.cpp.
References EvolutionSyncSource::getName(), and logItem().
void SQLiteContactSource::logItem | ( | const string & | uid, | |
const string & | info, | |||
bool | debug = false | |||
) | [protected, virtual] |
log a one-line info about an item
Implements TrackingSyncSource.
Definition at line 393 of file SQLiteContactSource.cpp.
References SQLiteUtil::findColumn(), and EvolutionSyncSource::getName().
Referenced by createItem(), and logItem().
void SQLiteContactSource::open | ( | ) | [protected, virtual] |
Actually opens the data source specified in the constructor, will throw the normal exceptions if that fails. Should not modify the state of the sync source: that can be deferred until the server is also ready and beginSync() is called.
Implements TrackingSyncSource.
Definition at line 75 of file SQLiteContactSource.cpp.
References EvolutionSyncSourceConfig::getDatabaseID(), EvolutionSyncSource::getName(), LAST_COL, and SQLiteUtil::open().