2 Copyright (c) 2009 Sascha Peilicke <sasch.pe@gmx.de>
4 This application is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
9 This application is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this application; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 #ifndef AKONADISYNCSOURCE_H
21 #define AKONADISYNCSOURCE_H
27 #include <Akonadi/Collection>
28 #include <Akonadi/Item>
30 #include <QtCore/QDateTime>
31 #include <QtCore/QStringList>
33 #include <syncevo/TrackingSyncSource.h>
37 class TimeTrackingObserver;
40 * General purpose Akonadi Sync Source. Choosing the type of data is
41 * done when instantiating it, using the Akonadi MIME subtypes.
42 * Payload is always using the native Akonadi format (no special "raw"
43 * and "engine" formats).
45 * Change tracking is done via the item uid/revision attributes.
47 * Databases (collections in Akonadi terminology) are selected via
48 * their int64 ID number.
50 class AkonadiSyncSource : public TrackingSyncSource
54 * @param submime the MIME type string used by Akonadi
55 * to identify contacts, tasks, events, etc.
56 * @param params the SyncEvolution source parameters
58 AkonadiSyncSource(const char *submime,
59 const SyncSourceParams ¶ms);
60 virtual ~AkonadiSyncSource();
62 /* methods that have to be implemented to complete TrackingSyncSource */
63 virtual Databases getDatabases();
65 virtual void listAllItems(SyncSourceRevisions::RevisionMap_t &revisions);
66 virtual InsertItemResult insertItem(const std::string &luid, const std::string &item, bool raw);
67 virtual void readItem(const std::string &luid, std::string &item, bool raw);
68 virtual void removeItem(const string &luid);
70 virtual bool isEmpty();
74 Akonadi::Collection m_collection;
75 const std::string m_subMime;
78 class AkonadiContactSource : public AkonadiSyncSource
81 AkonadiContactSource(const SyncSourceParams ¶ms)
82 : AkonadiSyncSource("text/directory", params)
86 virtual std::string getMimeType() const {
89 virtual std::string getMimeVersion() const {
93 void getSynthesisInfo(SynthesisInfo &info,
94 XMLConfigFragments &fragments)
96 TrackingSyncSource::getSynthesisInfo(info, fragments);
98 /** enable the KDE X- extensions in the Synthesis<->backend conversion */
99 info.m_backendRule = "KDE";
102 * Disable the default VCARD_BEFOREWRITE_SCRIPT_EVOLUTION.
103 * If any KDE-specific transformations via such a script
104 * are needed, it can be named here and then defined by appending
107 info.m_beforeWriteScript = ""; // "$VCARD_BEFOREWRITE_SCRIPT_KDE;";
108 // fragments.m_datatypes["VCARD_BEFOREWRITE_SCRIPT_KDE"] = "<macro name=\"VCARD_BEFOREWRITE_SCRIPT_KDE\"><![DATA[ ... ]]></macro>";
112 class AkonadiCalendarSource : public AkonadiSyncSource
115 AkonadiCalendarSource(const SyncSourceParams ¶ms)
116 : AkonadiSyncSource("application/x-vnd.akonadi.calendar.event", params)
120 // TODO: the items are expected to be complete VCALENDAR with
121 // all necessary VTIMEZONEs and one VEVENT (here) resp. VTODO
122 // (AkonadiTodoSource). Not sure what we get from Akonadi.
123 virtual std::string getMimeType() const { return "text/calendar"; }
124 virtual std::string getMimeVersion() const { return "2.0"; }
127 class AkonadiTaskSource : public AkonadiSyncSource
130 AkonadiTaskSource(const SyncSourceParams ¶ms)
131 : AkonadiSyncSource("application/x-vnd.akonadi.calendar.todo", params)
135 virtual std::string getMimeType() const { return "text/calendar"; }
136 virtual std::string getMimeVersion() const { return "2.0"; }
139 class AkonadiMemoSource : public AkonadiSyncSource
142 QString toKJots(QString data);
143 QString toSynthesis(QString data);
146 AkonadiMemoSource(const SyncSourceParams ¶ms)
147 : AkonadiSyncSource("text/x-vnd.akonadi.note", params)
151 // TODO: the AkonadiMemoSource is expected to import/export
152 // plain text with the summary in the first line; currently
153 // the AkonadiSyncSource will use VJOURNAL
154 // Also Currently there is no application which uses akonadi backend
155 // to display notes: probably work for knote??
156 virtual std::string getMimeType() const { return "text/plain"; }
157 virtual std::string getMimeVersion() const { return "1.0"; }
158 virtual InsertItemResult insertItem(const std::string &luid, const std::string &item, bool raw);
159 virtual void readItem(const std::string &luid, std::string &item, bool raw);
164 #endif // ENABLE_AKONADI
165 #endif // AKONADISYNCSOURCE_H