[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [akonadi-google/wip-v0.3] /: Support Google's exceptions in recurrent events
From: Dan_Vrátil <dan () progdan ! cz>
Date: 2012-03-04 19:16:24
Message-ID: 20120304191624.BC2E2A60A9 () git ! kde ! org
[Download RAW message or body]
Git commit 4478d3f73229d366284017f15e40b0cb99cc1ac4 by Dan Vrátil.
Committed on 04/03/2012 at 20:16.
Pushed by dvratil into branch 'wip-v0.3'.
Support Google's exceptions in recurrent events
M +2 -0 calendar/calendarresource.cpp
M +32 -0 calendar/resource_events.cpp
M +6 -1 libkgoogle/services/calendar.cpp
http://commits.kde.org/akonadi-google/4478d3f73229d366284017f15e40b0cb99cc1ac4
diff --git a/calendar/calendarresource.cpp b/calendar/calendarresource.cpp
index 890f46a..421779c 100644
--- a/calendar/calendarresource.cpp
+++ b/calendar/calendarresource.cpp
@@ -193,6 +193,8 @@ void CalendarResource::cachedItemsRetrieved(KJob* job)
url.addQueryItem("updated-min", lastSync);
}
+ url.addQueryItem("showDeleted", "true");
+
FetchListJob *fetchJob = new FetchListJob(url, service, Settings::self()->account());
fetchJob->setProperty("collection", qVariantFromValue(collection));
connect(fetchJob, SIGNAL(finished(KJob*)),
diff --git a/calendar/resource_events.cpp b/calendar/resource_events.cpp
index acd40ec..b4f90e3 100644
--- a/calendar/resource_events.cpp
+++ b/calendar/resource_events.cpp
@@ -139,12 +139,31 @@ void CalendarResource::eventsReceived(KJob *job)
Item::List removed;
Item::List changed;
+ QMap< QString, Objects::Event* > recurrentEvents;
QList< Object *> allData = fetchJob->items();
foreach (Object* replyData, allData) {
Objects::Event *event = static_cast< Objects::Event* >(replyData);
+ /* If this is a recurrent event then put it to map and continue with
+ * next event. We will return to this later... */
+ if (event->recurs() && !event->deleted()) {
+ recurrentEvents.insert(event->uid(), event);
+ continue;
+ }
+
+ /* If the event is deleted, but it has same ID as some of the recurrent
+ * events stored in the map, then take the original recurrent event from the map
+ * and set date of this particular instance as an exception date and continue.
+ * We will process content of the map later */
+ if (event->deleted() && recurrentEvents.contains(event->uid())) {
+ Objects::Event *rEvent = recurrentEvents.value(event->uid());
+
+ rEvent->recurrence()->addExDate(event->dtStart().date());
+ continue;
+ }
+
Item item;
item.setRemoteId(event->uid());
item.setRemoteRevision(event->etag());
@@ -159,6 +178,19 @@ void CalendarResource::eventsReceived(KJob *job)
}
+ /* Now process the recurrent events */
+ foreach (Objects::Event *event, recurrentEvents.values()) {
+
+ Item item;
+ item.setRemoteId(event->uid());
+ item.setRemoteRevision(event->etag());
+ item.setPayload< EventPtr >(EventPtr(event));
+ item.setMimeType(Event::eventMimeType());
+ item.setParentCollection(collection);
+
+ changed << item;
+ }
+
itemsRetrievedIncremental(changed, removed);
collection.setRemoteRevision(QString::number(KDateTime::currentUtcDateTime().toTime_t()));
diff --git a/libkgoogle/services/calendar.cpp b/libkgoogle/services/calendar.cpp
index 3fc7d21..286bc4c 100644
--- a/libkgoogle/services/calendar.cpp
+++ b/libkgoogle/services/calendar.cpp
@@ -324,7 +324,7 @@ KGoogle::Object* Services::Calendar::JSONToEvent(const QVariantMap& event)
/* Status */
if (event["status"].toString() == "confirmed") {
object->setStatus(Incidence::StatusConfirmed);
- } else if (event["status"].toString() == "canceled") {
+ } else if (event["status"].toString() == "cancelled") {
object->setStatus(Incidence::StatusCanceled);
object->setDeleted(true);
} else if (event["status"].toString() == "tentative") {
@@ -333,6 +333,11 @@ KGoogle::Object* Services::Calendar::JSONToEvent(const QVariantMap& event)
object->setStatus(Incidence::StatusNone);
}
+ /* Canceled instance of recurring event. Set ID of the instance to match ID of the event */
+ if (event.contains("recurringEventId") && object->deleted()) {
+ object->setUid(QUrl::fromPercentEncoding(event["recurringEventId"].toByteArray()));
+ }
+
/* Created */
object->setCreated(AccessManager::RFC3339StringToDate(event["created"].toString()));
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic