2005-11-05 23:04:33 +01:00
|
|
|
/*
|
2006-12-10 18:35:20 +01:00
|
|
|
* Copyright (C) 2005-2006 Patrick Ohly
|
|
|
|
* Copyright (C) 2007 Funambol
|
2005-11-05 23:04:33 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
2006-07-23 12:27:21 +02:00
|
|
|
#ifndef INCL_EVOLUTIONCONTACTSOURCE
|
|
|
|
#define INCL_EVOLUTIONCONTACTSOURCE
|
|
|
|
|
2006-07-25 23:25:51 +02:00
|
|
|
#include <config.h>
|
2005-11-05 23:04:33 +01:00
|
|
|
#include "EvolutionSyncSource.h"
|
|
|
|
#include "EvolutionSmartPtr.h"
|
|
|
|
|
2006-07-23 12:27:21 +02:00
|
|
|
#ifdef ENABLE_EBOOK
|
|
|
|
|
2005-11-05 23:04:33 +01:00
|
|
|
#include <libebook/e-book.h>
|
|
|
|
#include <libebook/e-vcard.h>
|
|
|
|
|
2006-03-12 23:30:35 +01:00
|
|
|
#include <set>
|
|
|
|
|
2005-11-05 23:04:33 +01:00
|
|
|
/**
|
|
|
|
* Implements access to Evolution address books.
|
|
|
|
*/
|
|
|
|
class EvolutionContactSource : public EvolutionSyncSource
|
|
|
|
{
|
|
|
|
public:
|
2008-03-06 23:23:13 +01:00
|
|
|
EvolutionContactSource(const EvolutionSyncSourceParams ¶ms,
|
|
|
|
EVCardFormat vcardFormat = EVC_FORMAT_VCARD_30);
|
|
|
|
EvolutionContactSource(const EvolutionContactSource &other);
|
2006-04-09 13:48:11 +02:00
|
|
|
virtual ~EvolutionContactSource() { close(); }
|
2005-11-05 23:04:33 +01:00
|
|
|
|
2006-01-08 22:49:03 +01:00
|
|
|
// utility function: extract vcard from item in format suitable for Evolution
|
|
|
|
string preparseVCard(SyncItem& item);
|
|
|
|
|
2005-11-05 23:04:33 +01:00
|
|
|
//
|
|
|
|
// implementation of EvolutionSyncSource
|
|
|
|
//
|
2008-07-10 21:17:42 +02:00
|
|
|
virtual Databases getDatabases();
|
2005-11-05 23:04:33 +01:00
|
|
|
virtual void open();
|
2006-03-18 14:35:23 +01:00
|
|
|
virtual void close();
|
|
|
|
virtual void exportData(ostream &out);
|
2006-03-19 22:37:30 +01:00
|
|
|
virtual string fileSuffix() { return "vcf"; }
|
2008-03-06 23:23:13 +01:00
|
|
|
virtual const char *getMimeType() const;
|
|
|
|
virtual const char *getMimeVersion() const;
|
|
|
|
virtual const char *getSupportedTypes() const { return "text/vcard:3.0,text/x-vcard:2.1"; }
|
2006-03-18 14:35:23 +01:00
|
|
|
|
2008-01-13 02:41:21 +01:00
|
|
|
virtual SyncItem *createItem(const string &uid);
|
2006-04-09 13:48:11 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
//
|
|
|
|
// implementation of EvolutionSyncSource callbacks
|
|
|
|
//
|
|
|
|
virtual void beginSyncThrow(bool needAll,
|
|
|
|
bool needPartial,
|
|
|
|
bool deleteLocal);
|
|
|
|
virtual void endSyncThrow();
|
|
|
|
virtual void setItemStatusThrow(const char *key, int status);
|
2006-04-17 11:41:37 +02:00
|
|
|
virtual int addItemThrow(SyncItem& item);
|
|
|
|
virtual int updateItemThrow(SyncItem& item);
|
|
|
|
virtual int deleteItemThrow(SyncItem& item);
|
2006-11-11 17:00:37 +01: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);
|
2006-09-07 21:47:29 +02:00
|
|
|
|
2005-11-05 23:04:33 +01:00
|
|
|
private:
|
|
|
|
/** valid after open(): the address book that this source references */
|
2006-08-14 22:52:34 +02:00
|
|
|
eptr<EBook, GObject> m_addressbook;
|
2005-11-05 23:04:33 +01:00
|
|
|
|
|
|
|
/** the format of vcards that new items are expected to have */
|
|
|
|
const EVCardFormat m_vcardFormat;
|
|
|
|
|
2006-03-12 23:30:35 +01:00
|
|
|
/**
|
|
|
|
* a list of Evolution vcard properties which have to be encoded
|
|
|
|
* as X-SYNCEVOLUTION-* when sending to server in 2.1 and decoded
|
|
|
|
* back when receiving.
|
|
|
|
*/
|
|
|
|
static const class extensions : public set<string> {
|
|
|
|
public:
|
|
|
|
extensions() : prefix("X-SYNCEVOLUTION-") {
|
|
|
|
this->insert("FBURL");
|
|
|
|
this->insert("CALURI");
|
|
|
|
}
|
|
|
|
|
|
|
|
const string prefix;
|
|
|
|
} m_vcardExtensions;
|
|
|
|
|
2006-03-18 15:18:14 +01:00
|
|
|
/**
|
|
|
|
* a list of properties which SyncEvolution (in contrast to
|
|
|
|
* the server) will only store once in each contact
|
|
|
|
*/
|
|
|
|
static const class unique : public set<string> {
|
|
|
|
public:
|
|
|
|
unique () {
|
|
|
|
insert("X-AIM");
|
|
|
|
insert("X-GROUPWISE");
|
|
|
|
insert("X-ICQ");
|
|
|
|
insert("X-YAHOO");
|
|
|
|
insert("X-EVOLUTION-ANNIVERSARY");
|
|
|
|
insert("X-EVOLUTION-ASSISTANT");
|
|
|
|
insert("X-EVOLUTION-BLOG-URL");
|
|
|
|
insert("X-EVOLUTION-FILE-AS");
|
|
|
|
insert("X-EVOLUTION-MANAGER");
|
|
|
|
insert("X-EVOLUTION-SPOUSE");
|
|
|
|
insert("X-EVOLUTION-VIDEO-URL");
|
|
|
|
insert("X-MOZILLA-HTML");
|
|
|
|
insert("FBURL");
|
|
|
|
insert("CALURI");
|
|
|
|
}
|
|
|
|
} m_uniqueProperties;
|
2005-11-05 23:04:33 +01:00
|
|
|
};
|
2006-07-23 12:27:21 +02:00
|
|
|
|
|
|
|
#endif // ENABLE_EBOOK
|
|
|
|
|
|
|
|
#endif // INCL_EVOLUTIONCONTACTSOURCE
|