00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef INCL_EVOLUTIONCALENDARSOURCE
00020 #define INCL_EVOLUTIONCALENDARSOURCE
00021
00022 #include <config.h>
00023 #include "TrackingSyncSource.h"
00024 #include "EvolutionSmartPtr.h"
00025
00026 #ifdef ENABLE_ECAL
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 class EvolutionCalendarSource : public TrackingSyncSource
00037 {
00038 public:
00039
00040
00041
00042
00043
00044
00045 EvolutionCalendarSource(ECalSourceType type,
00046 const EvolutionSyncSourceParams ¶ms);
00047 EvolutionCalendarSource(const EvolutionCalendarSource &other);
00048 virtual ~EvolutionCalendarSource() { close(); }
00049
00050
00051
00052
00053 virtual Databases getDatabases();
00054 virtual void open();
00055 virtual void close();
00056 virtual void exportData(ostream &out);
00057 virtual string fileSuffix() const { return "ics"; }
00058 virtual const char *getMimeType() const { return "text/calendar"; }
00059 virtual const char *getMimeVersion() const { return "2.0"; }
00060 virtual const char *getSupportedTypes() const { return "text/calendar:2.0"; }
00061
00062 virtual SyncItem *createItem(const string &luid);
00063
00064 protected:
00065
00066
00067
00068 virtual void listAllItems(RevisionMap_t &revisions);
00069 virtual InsertItemResult insertItem(const string &luid, const SyncItem &item);
00070 virtual void setItemStatusThrow(const char *key, int status);
00071 virtual void deleteItem(const string &luid);
00072 virtual void logItem(const string &luid, const string &info, bool debug = false);
00073 virtual void logItem(const SyncItem &item, const string &info, bool debug = false);
00074
00075 protected:
00076
00077 eptr<ECal, GObject> m_calendar;
00078
00079 ECalSourceType m_type;
00080 string m_typeName;
00081 ECal *(*m_newSystem)(void);
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092 class ItemID {
00093 public:
00094 ItemID(const string &uid, const string &rid) :
00095 m_uid(uid),
00096 m_rid(rid)
00097 {}
00098 ItemID(const char *uid, const char *rid):
00099 m_uid(uid ? uid : ""),
00100 m_rid(rid ? rid : "")
00101 {}
00102 ItemID(const string &luid);
00103
00104 const string m_uid, m_rid;
00105
00106 string getLUID() const;
00107 static string getLUID(const string &uid, const string &rid);
00108 };
00109
00110
00111
00112
00113
00114
00115 icalcomponent *retrieveItem(const ItemID &id);
00116
00117
00118 string retrieveItemAsString(const ItemID &id);
00119
00120
00121
00122 icalcomponent_kind getCompType() {
00123 return m_type == E_CAL_SOURCE_TYPE_EVENT ? ICAL_VEVENT_COMPONENT :
00124 m_type == E_CAL_SOURCE_TYPE_JOURNAL ? ICAL_VJOURNAL_COMPONENT :
00125 ICAL_VTODO_COMPONENT;
00126 }
00127
00128
00129 static char *eCalAuthFunc(ECal *ecal,
00130 const char *prompt,
00131 const char *key,
00132 gpointer user_data) {
00133 return ((EvolutionCalendarSource *)user_data)->authenticate(prompt, key);
00134 }
00135
00136
00137 char *authenticate(const char *prompt,
00138 const char *key);
00139
00140
00141
00142
00143 string getLUID(ECalComponent *ecomp);
00144
00145
00146
00147
00148
00149 ItemID getItemID(ECalComponent *ecomp);
00150 ItemID getItemID(icalcomponent *icomp);
00151
00152
00153
00154
00155
00156 string getItemModTime(ECalComponent *ecomp);
00157
00158
00159
00160
00161
00162
00163 string getItemModTime(const ItemID &id);
00164
00165
00166
00167
00168 string icalTime2Str(const struct icaltimetype &tt);
00169
00170
00171
00172
00173
00174
00175
00176
00177 set<string> m_allLUIDs;
00178
00179
00180
00181
00182
00183
00184
00185 typedef list< boost::shared_ptr< eptr<icalcomponent> > > ICalComps_t;
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199 ICalComps_t removeEvents(const string &uid, bool returnOnlyChildren);
00200 };
00201
00202 #else
00203
00204 typedef int ECalSourceType;
00205
00206 #endif // ENABLE_ECAL
00207
00208 #endif // INCL_EVOLUTIONSYNCSOURCE