From a0e514f34d772fcf55941007e1ba820769b6ce87 Mon Sep 17 00:00:00 2001 From: Sergey Kashin Date: Wed, 20 Jun 2018 23:30:01 +0300 Subject: [PATCH] [sociald] Upsync event attendees from local storage to Google calendar. Contibutes to JB#1106 This patch implements a proper event creation on the Google server side. Rest will be done by a default invitation plugin (can be integrated completely separate from this change). --- rpm/sociald.spec | 2 +- .../googlecalendarsyncadaptor.cpp | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/rpm/sociald.spec b/rpm/sociald.spec index 078b0f1..0f36f3f 100644 --- a/rpm/sociald.spec +++ b/rpm/sociald.spec @@ -1,6 +1,6 @@ Name: sociald Summary: Syncs device data from social services -Version: 0.1.65 +Version: 0.1.67 Release: 1 Group: System/Libraries License: LGPLv2.1 diff --git a/src/google/google-calendars/googlecalendarsyncadaptor.cpp b/src/google/google-calendars/googlecalendarsyncadaptor.cpp index 26804a8..c90f867 100644 --- a/src/google/google-calendars/googlecalendarsyncadaptor.cpp +++ b/src/google/google-calendars/googlecalendarsyncadaptor.cpp @@ -402,6 +402,25 @@ QJsonObject kCalToJson(KCalCore::Event::Ptr event, KCalCore::ICalFormat &icalFor QString eventId = gCalEventId(event); QJsonObject start, end, reminders; + QJsonArray attendees; + const KCalCore::Attendee::List attendeesList = event->attendees(); + if (!attendeesList.isEmpty()) { + Q_FOREACH (auto att, attendeesList) { + if (att->email().isEmpty()) { + continue; + } + QJsonObject attendee; + attendee.insert("email", att->email()); + if (att->role() == KCalCore::Attendee::OptParticipant) { + attendee.insert("optional", true); + } + const QString &name = att->name(); + if (!name.isEmpty()) { + attendee.insert("displayName", name); + } + attendees.append(attendee); + } + } // insert the date/time and timeZone information into the Json object. // note that timeZone is required for recurring events, for some reason. if (event->dtStart().isDateOnly() || (event->allDay() && event->dtStart().time() == QTime(0,0,0))) { @@ -432,6 +451,9 @@ QJsonObject kCalToJson(KCalCore::Event::Ptr event, KCalCore::ICalFormat &icalFor retn.insert(QLatin1String("start"), start); retn.insert(QLatin1String("end"), end); retn.insert(QLatin1String("sequence"), QString::number(event->revision()+1)); + if (!attendees.isEmpty()) { + retn.insert(QLatin1String("attendees"), attendees); + } //retn.insert(QLatin1String("locked"), event->readOnly()); // only allow locking server-side. // we may wish to support locking/readonly from local side also, in the future.