summaryrefslogtreecommitdiff
path: root/src/backends/evolution/EvolutionCalendarSource.cpp
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@gmx.de>2009-08-13 17:50:32 +0200
committerPatrick Ohly <patrick.ohly@gmx.de>2009-08-26 15:41:51 +0200
commitf762431cea85af01a5a8fed80092094c72f3d1a3 (patch)
tree95d80ebb47f6cf521a6ed7c10f4105c0a6068639 /src/backends/evolution/EvolutionCalendarSource.cpp
parent28561fe96b9c651381295c42afeed94351d3a136 (diff)
EvolutionCalendarSource: added logging via SyncSourceLogging
In 0.9, logging of calendar, task, memo changes was very rudimentary. Only the LUID was logged. Now the summary (tasks), summary and location separated by comma (event) and the summary or first line (memo) are printed. This works for inserted/updated items as well as deleted ones.
Diffstat (limited to 'src/backends/evolution/EvolutionCalendarSource.cpp')
-rw-r--r--src/backends/evolution/EvolutionCalendarSource.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/backends/evolution/EvolutionCalendarSource.cpp b/src/backends/evolution/EvolutionCalendarSource.cpp
index 69054653..d44ae84e 100644
--- a/src/backends/evolution/EvolutionCalendarSource.cpp
+++ b/src/backends/evolution/EvolutionCalendarSource.cpp
@@ -78,14 +78,23 @@ EvolutionCalendarSource::EvolutionCalendarSource(ECalSourceType type,
{
switch (m_type) {
case E_CAL_SOURCE_TYPE_EVENT:
+ SyncSourceLogging::init(InitList<std::string>("SUMMARY") + "LOCATION",
+ ", ",
+ m_operations);
m_typeName = "calendar";
m_newSystem = e_cal_new_system_calendar;
break;
case E_CAL_SOURCE_TYPE_TODO:
+ SyncSourceLogging::init(InitList<std::string>("SUMMARY"),
+ ", ",
+ m_operations);
m_typeName = "task list";
m_newSystem = e_cal_new_system_tasks;
break;
case E_CAL_SOURCE_TYPE_JOURNAL:
+ SyncSourceLogging::init(InitList<std::string>("SUBJECT"),
+ ", ",
+ m_operations);
m_typeName = "memo list";
// This is not available in older Evolution versions.
// A configure check could detect that, but as this isn't
@@ -607,6 +616,55 @@ string EvolutionCalendarSource::retrieveItemAsString(const ItemID &id)
return data;
}
+std::string EvolutionCalendarSource::getDescription(const string &luid)
+{
+ try {
+ eptr<icalcomponent> comp(retrieveItem(ItemID(luid)));
+ std::string descr;
+
+ const char *summary = icalcomponent_get_summary(comp);
+ if (summary && summary[0]) {
+ descr += summary;
+ }
+
+ if (m_type == E_CAL_SOURCE_TYPE_EVENT) {
+ const char *location = icalcomponent_get_location(comp);
+ if (location && location[0]) {
+ if (!descr.empty()) {
+ descr += ", ";
+ }
+ descr += location;
+ }
+ }
+
+ if (m_type == E_CAL_SOURCE_TYPE_JOURNAL &&
+ descr.empty()) {
+ // fallback to first line of body text
+ icalproperty *desc = icalcomponent_get_first_property(comp, ICAL_DESCRIPTION_PROPERTY);
+ if (desc) {
+ const char *text = icalproperty_get_description(desc);
+ if (text) {
+ const char *eol = strchr(text, '\n');
+ if (eol) {
+ descr.assign(text, eol - text);
+ } else {
+ descr = text;
+ }
+ }
+ }
+ }
+
+ return descr;
+ } catch (...) {
+ // Instead of failing we log the error and ask
+ // the caller to log the UID. That way transient
+ // errors or errors in the logging code don't
+ // prevent syncs.
+ handleException();
+ return "";
+ }
+}
+
string EvolutionCalendarSource::ItemID::getLUID() const
{
return getLUID(m_uid, m_rid);