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;
77 * MIME types(s) of items, from submime constructor parameter.
78 * Only one format is supported, but it may have different aliases (for example,
79 * application/x-vnd.kde.notes == application/x-vnd.akonadi.note).
81 QStringList m_mimeTypes;
84 * The actual type to be used inside the collection. Set after opening
87 QString m_contentMimeType;
90 class AkonadiContactSource : public AkonadiSyncSource
93 AkonadiContactSource(const SyncSourceParams ¶ms)
94 : AkonadiSyncSource("text/directory", params)
98 virtual std::string getMimeType() const {
101 virtual std::string getMimeVersion() const {
105 void getSynthesisInfo(SynthesisInfo &info,
106 XMLConfigFragments &fragments)
108 TrackingSyncSource::getSynthesisInfo(info, fragments);
110 /** enable the KDE X- extensions in the Synthesis<->backend conversion */
111 info.m_backendRule = "KDE";
114 * Disable the default VCARD_BEFOREWRITE_SCRIPT_EVOLUTION.
115 * If any KDE-specific transformations via such a script
116 * are needed, it can be named here and then defined by appending
119 info.m_beforeWriteScript = ""; // "$VCARD_BEFOREWRITE_SCRIPT_KDE;";
120 // fragments.m_datatypes["VCARD_BEFOREWRITE_SCRIPT_KDE"] = "<macro name=\"VCARD_BEFOREWRITE_SCRIPT_KDE\"><![DATA[ ... ]]></macro>";
124 class AkonadiCalendarSource : public AkonadiSyncSource
127 AkonadiCalendarSource(const SyncSourceParams ¶ms)
128 : AkonadiSyncSource("application/x-vnd.akonadi.calendar.event", params)
132 // TODO: the items are expected to be complete VCALENDAR with
133 // all necessary VTIMEZONEs and one VEVENT (here) resp. VTODO
134 // (AkonadiTodoSource). Not sure what we get from Akonadi.
135 virtual std::string getMimeType() const { return "text/calendar"; }
136 virtual std::string getMimeVersion() const { return "2.0"; }
139 class AkonadiTaskSource : public AkonadiSyncSource
142 AkonadiTaskSource(const SyncSourceParams ¶ms)
143 : AkonadiSyncSource("application/x-vnd.akonadi.calendar.todo", params)
147 virtual std::string getMimeType() const { return "text/calendar"; }
148 virtual std::string getMimeVersion() const { return "2.0"; }
151 class AkonadiMemoSource : public AkonadiSyncSource
154 QString toKJots(QString data);
155 QString toSynthesis(QString data);
158 AkonadiMemoSource(const SyncSourceParams ¶ms) :
159 AkonadiSyncSource("text/x-vnd.akonadi.note,application/x-vnd.kde.notes", params)
163 // TODO: the AkonadiMemoSource is expected to import/export
164 // plain text with the summary in the first line; currently
165 // the AkonadiSyncSource will use VJOURNAL
166 // Also Currently there is no application which uses akonadi backend
167 // to display notes: probably work for knote??
168 virtual std::string getMimeType() const { return "text/plain"; }
169 virtual std::string getMimeVersion() const { return "1.0"; }
170 virtual InsertItemResult insertItem(const std::string &luid, const std::string &item, bool raw);
171 virtual void readItem(const std::string &luid, std::string &item, bool raw);
176 #endif // ENABLE_AKONADI
177 #endif // AKONADISYNCSOURCE_H