2007-08-13 22:46:49 +02:00
|
|
|
/*
|
2008-08-26 19:45:28 +02:00
|
|
|
* Copyright (C) 2007-2008 Patrick Ohly
|
2007-08-13 22:46:49 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef INCL_SQLITECONTACTSOURCE
|
|
|
|
#define INCL_SQLITECONTACTSOURCE
|
|
|
|
|
2008-01-14 22:25:03 +01:00
|
|
|
#include "TrackingSyncSource.h"
|
2008-01-13 00:22:43 +01:00
|
|
|
#include "SQLiteUtil.h"
|
2007-08-13 22:46:49 +02:00
|
|
|
|
|
|
|
#ifdef ENABLE_SQLITE
|
|
|
|
|
|
|
|
/**
|
2008-02-02 22:40:42 +01:00
|
|
|
* Uses SQLiteUtil for contacts with a schema inspired by the one used
|
|
|
|
* by Mac OS X. That schema has hierarchical tables which is not
|
|
|
|
* supported by SQLiteUtil, therefore SQLiteContactSource uses a
|
|
|
|
* simplified schema where each contact consists of one row in the
|
|
|
|
* database table.
|
|
|
|
*
|
|
|
|
* 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>.
|
2007-08-13 22:46:49 +02:00
|
|
|
*/
|
2008-01-14 22:25:03 +01:00
|
|
|
class SQLiteContactSource : public TrackingSyncSource
|
2007-08-13 22:46:49 +02:00
|
|
|
{
|
|
|
|
public:
|
2008-03-06 23:23:13 +01:00
|
|
|
SQLiteContactSource(const EvolutionSyncSourceParams ¶ms) :
|
|
|
|
TrackingSyncSource(params)
|
2007-08-13 22:46:49 +02:00
|
|
|
{}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
/* implementation of EvolutionSyncSource interface */
|
|
|
|
virtual void open();
|
2008-01-13 00:22:43 +01:00
|
|
|
virtual void close();
|
2008-07-10 21:17:42 +02:00
|
|
|
virtual Databases getDatabases();
|
2008-01-13 02:41:21 +01:00
|
|
|
virtual SyncItem *createItem(const string &uid);
|
2008-07-12 20:36:56 +02:00
|
|
|
virtual string fileSuffix() const { return "vcf"; }
|
2008-03-06 23:23:13 +01:00
|
|
|
virtual const char *getMimeType() const { return "text/x-vcard"; }
|
|
|
|
virtual const char *getMimeVersion() const { return "2.1"; }
|
|
|
|
virtual const char *getSupportedTypes()const { return "text/vcard:3.0,text/x-vcard:2.1"; }
|
2007-08-13 22:46:49 +02:00
|
|
|
virtual void logItem(const string &uid, const string &info, bool debug = false);
|
2008-04-07 19:59:17 +02:00
|
|
|
virtual void logItem(const SyncItem &item, const string &info, bool debug = false);
|
2007-08-13 22:46:49 +02:00
|
|
|
|
2008-01-14 22:25:03 +01:00
|
|
|
/* implementation of TrackingSyncSource interface */
|
|
|
|
virtual void listAllItems(RevisionMap_t &revisions);
|
2008-04-07 20:38:25 +02:00
|
|
|
virtual InsertItemResult insertItem(const string &uid, const SyncItem &item);
|
2008-01-14 22:25:03 +01:00
|
|
|
virtual void deleteItem(const string &uid);
|
|
|
|
|
2007-08-13 22:46:49 +02:00
|
|
|
private:
|
2008-01-13 00:22:43 +01:00
|
|
|
/** encapsulates access to database */
|
|
|
|
SQLiteUtil m_sqlite;
|
2007-08-13 22:46:49 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ENABLE_SQLITE
|
|
|
|
#endif // INCL_SQLITECONTACTSOURCE
|