2 * Copyright (C) 2005-2006 Patrick Ohly
3 * Copyright (C) 2007 Funambol
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #ifndef INCL_EVOLUTIONCONTACTSOURCE
21 #define INCL_EVOLUTIONCONTACTSOURCE
24 #include "EvolutionSyncSource.h"
25 #include "EvolutionSmartPtr.h"
29 #include <libebook/e-book.h>
30 #include <libebook/e-vcard.h>
35 * Implements access to Evolution address books.
37 class EvolutionContactSource : public EvolutionSyncSource
40 EvolutionContactSource(const EvolutionSyncSourceParams ¶ms,
41 EVCardFormat vcardFormat = EVC_FORMAT_VCARD_30);
42 EvolutionContactSource(const EvolutionContactSource &other);
43 virtual ~EvolutionContactSource() { close(); }
45 // utility function: extract vcard from item in format suitable for Evolution
46 string preparseVCard(SyncItem& item);
49 // implementation of EvolutionSyncSource
51 virtual sources getSyncBackends();
54 virtual void exportData(ostream &out);
55 virtual string fileSuffix() { return "vcf"; }
56 virtual const char *getMimeType() const;
57 virtual const char *getMimeVersion() const;
58 virtual const char *getSupportedTypes() const { return "text/vcard:3.0,text/x-vcard:2.1"; }
60 virtual SyncItem *createItem(const string &uid);
64 // implementation of EvolutionSyncSource callbacks
66 virtual void beginSyncThrow(bool needAll,
69 virtual void endSyncThrow();
70 virtual void setItemStatusThrow(const char *key, int status);
71 virtual int addItemThrow(SyncItem& item);
72 virtual int updateItemThrow(SyncItem& item);
73 virtual int deleteItemThrow(SyncItem& item);
74 virtual void logItem(const string &uid, const string &info, bool debug = false);
75 virtual void logItem(const SyncItem &item, const string &info, bool debug = false);
78 /** valid after open(): the address book that this source references */
79 eptr<EBook, GObject> m_addressbook;
81 /** the format of vcards that new items are expected to have */
82 const EVCardFormat m_vcardFormat;
85 * a list of Evolution vcard properties which have to be encoded
86 * as X-SYNCEVOLUTION-* when sending to server in 2.1 and decoded
87 * back when receiving.
89 static const class extensions : public set<string> {
91 extensions() : prefix("X-SYNCEVOLUTION-") {
92 this->insert("FBURL");
93 this->insert("CALURI");
100 * a list of properties which SyncEvolution (in contrast to
101 * the server) will only store once in each contact
103 static const class unique : public set<string> {
107 insert("X-GROUPWISE");
110 insert("X-EVOLUTION-ANNIVERSARY");
111 insert("X-EVOLUTION-ASSISTANT");
112 insert("X-EVOLUTION-BLOG-URL");
113 insert("X-EVOLUTION-FILE-AS");
114 insert("X-EVOLUTION-MANAGER");
115 insert("X-EVOLUTION-SPOUSE");
116 insert("X-EVOLUTION-VIDEO-URL");
117 insert("X-MOZILLA-HTML");
121 } m_uniqueProperties;
124 #endif // ENABLE_EBOOK
126 #endif // INCL_EVOLUTIONCONTACTSOURCE