Skip to content

Commit

Permalink
[buteo-sync-plugins-social] Store GCal ID in custom property. Contrib…
Browse files Browse the repository at this point in the history
…utes to JB#38165

This commit ensures that the Google Calendar ID for a synced event is
stored into a custom X-SAILFISHOS-REMOTE-UID property of the event, so
that the email application can find the appropriate event for a given
invitation attachment.

Contributes to JB#38165
  • Loading branch information
Chris Adams committed Jun 28, 2017
1 parent 0c42522 commit 20bad33
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/google/google-calendars/googlecalendarsyncadaptor.cpp
Expand Up @@ -146,6 +146,23 @@ void setGCalEventId(KCalCore::Incidence::Ptr event, const QString &id)
event->addComment(QStringLiteral("jolla-sociald:gcal-id:%1").arg(id));
}

void setRemoteUidCustomField(KCalCore::Incidence::Ptr event, const QString &uid, const QString &id)
{
// store it also in a custom property purely for invitation lookup purposes.
if (!uid.isEmpty()) {
event->setNonKDECustomProperty("X-SAILFISHOS-REMOTE-UID", uid.toUtf8());
} else {
// Google Calendar invites are sent as invitations with uid suffixed with @google.com.
if (id.endsWith(QLatin1String("@google.com"), Qt::CaseInsensitive)) {
event->setNonKDECustomProperty("X-SAILFISHOS-REMOTE-UID", id.toUtf8());
} else {
QString suffixedId = id;
suffixedId.append(QLatin1String("@google.com"));
event->setNonKDECustomProperty("X-SAILFISHOS-REMOTE-UID", suffixedId.toUtf8());
}
}
}

QString gCalETag(KCalCore::Incidence::Ptr event)
{
return event->customProperty("jolla-sociald", "gcal-etag");
Expand Down Expand Up @@ -731,6 +748,7 @@ void jsonToKCal(const QJsonObject &json, KCalCore::Event::Ptr event, int default
START_EVENT_UPDATES_IF_REQUIRED(event, changed);
setGCalETag(event, json.value(QLatin1String("etag")).toVariant().toString());
}
setRemoteUidCustomField(event, json.value(QLatin1String("iCalUID")).toVariant().toString(), json.value(QLatin1String("id")).toVariant().toString());
extractRecurrence(json.value(QLatin1String("recurrence")).toArray(), event, icalFormat);
UPDATE_EVENT_PROPERTY_IF_REQUIRED(event, isReadOnly, setReadOnly, json.value(QLatin1String("locked")).toVariant().toBool(), changed)
UPDATE_EVENT_PROPERTY_IF_REQUIRED(event, summary, setSummary, json.value(QLatin1String("summary")).toVariant().toString(), changed)
Expand Down

0 comments on commit 20bad33

Please sign in to comment.