diff --git a/src/akonadi/akonadiserializer.h b/src/akonadi/akonadiserializer.h --- a/src/akonadi/akonadiserializer.h +++ b/src/akonadi/akonadiserializer.h @@ -75,6 +75,13 @@ void addContextToTask(Domain::Context::Ptr context, Akonadi::Item item) override; void removeContextFromTask(Domain::Context::Ptr context, Akonadi::Item item) override; QString contextUid(Akonadi::Item item) override; + + static QByteArray customPropertyAppName(); + static QByteArray customPropertyIsProject(); + static QByteArray customPropertyIsContext(); + static QByteArray customPropertyIsRunning(); + static QByteArray customPropertyContextList(); + }; } diff --git a/src/akonadi/akonadiserializer.cpp b/src/akonadi/akonadiserializer.cpp --- a/src/akonadi/akonadiserializer.cpp +++ b/src/akonadi/akonadiserializer.cpp @@ -40,9 +40,6 @@ using namespace Akonadi; -static const char s_contextListProperty[] = "ContextList"; -static const char s_appName[] = "Zanshin"; - Serializer::Serializer() { } @@ -183,7 +180,7 @@ task->setProperty("parentCollectionId", item.parentCollection().id()); task->setProperty("todoUid", todo->uid()); task->setProperty("relatedUid", todo->relatedTo()); - task->setRunning(todo->customProperty("Zanshin", "Running") == QLatin1String("1")); + task->setRunning(todo->customProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsRunning()) == QLatin1String("1")); switch (todo->recurrence()->recurrenceType()) { case KCalCore::Recurrence::rDaily: @@ -281,9 +278,9 @@ } if (task->isRunning()) { - todo->setCustomProperty("Zanshin", "Running", "1"); + todo->setCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsRunning(), "1"); } else { - todo->removeCustomProperty("Zanshin", "Running"); + todo->removeCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsRunning()); } // Needs to be done after all other dates are positioned @@ -349,7 +346,7 @@ auto todo = item.payload(); todo->setRelatedTo(QString()); - todo->setCustomProperty("Zanshin", "Project", QStringLiteral("1")); + todo->setCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsProject(), QStringLiteral("1")); } void Serializer::clearItem(Akonadi::Item *item) @@ -359,7 +356,7 @@ return; auto todo = item->payload(); - todo->removeCustomProperty(s_appName, s_contextListProperty); + todo->removeCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyContextList()); } Akonadi::Item::List Serializer::filterDescendantItems(const Akonadi::Item::List &potentialChildren, const Akonadi::Item &ancestorItem) @@ -398,7 +395,7 @@ return false; auto todo = item.payload(); - return !todo->customProperty(s_appName, "Project").isEmpty(); + return !todo->customProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsProject()).isEmpty(); } Domain::Project::Ptr Serializer::createProjectFromItem(Item item) @@ -429,7 +426,7 @@ auto todo = KCalCore::Todo::Ptr::create(); todo->setSummary(project->name()); - todo->setCustomProperty("Zanshin", "Project", QStringLiteral("1")); + todo->setCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsProject(), QStringLiteral("1")); if (project->property("todoUid").isValid()) { todo->setUid(project->property("todoUid").toString()); @@ -460,7 +457,7 @@ static QStringList extractContexts(KCalCore::Todo::Ptr todo) { - const auto contexts = todo->customProperty(s_appName, s_contextListProperty); + const QString contexts = todo->customProperty(Serializer::customPropertyAppName(), Serializer::customPropertyContextList()); return contexts.split(',', QString::SkipEmptyParts); } @@ -484,7 +481,7 @@ return false; auto todo = item.payload(); - return !todo->customProperty(s_appName, "Context").isEmpty(); + return !todo->customProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsContext()).isEmpty(); } Domain::Context::Ptr Serializer::createContextFromItem(Item item) @@ -502,7 +499,7 @@ auto todo = KCalCore::Todo::Ptr::create(); todo->setSummary(context->name()); - todo->setCustomProperty(s_appName, "Context", QStringLiteral("1")); + todo->setCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsContext(), QStringLiteral("1")); if (context->property("todoUid").isValid()) { todo->setUid(context->property("todoUid").toString()); @@ -550,7 +547,7 @@ auto contextList = extractContexts(todo); if (!contextList.contains(contextUid)) contextList.append(contextUid); - todo->setCustomProperty(s_appName, s_contextListProperty, contextList.join(',')); + todo->setCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyContextList(), contextList.join(',')); item.setPayload(todo); } @@ -571,9 +568,9 @@ QStringList contextList = extractContexts(todo); contextList.removeAll(contextUid); if (contextList.isEmpty()) - todo->removeCustomProperty(s_appName, s_contextListProperty); + todo->removeCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyContextList()); else - todo->setCustomProperty(s_appName, s_contextListProperty, contextList.join(',')); + todo->setCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyContextList(), contextList.join(',')); item.setPayload(todo); } @@ -586,3 +583,32 @@ auto todo = item.payload(); return todo->uid(); } + +// KCalCore's CustomProperties doesn't implement case insensitivity +// and some CALDAV servers make everything uppercase. So do like most of kdepim +// and use uppercase property names. + +QByteArray Serializer::customPropertyAppName() +{ + return QByteArrayLiteral("ZANSHIN"); +} + +QByteArray Serializer::customPropertyIsProject() +{ + return QByteArrayLiteral("ISPROJECT"); +} + +QByteArray Serializer::customPropertyIsContext() +{ + return QByteArrayLiteral("ISCONTEXT"); +} + +QByteArray Serializer::customPropertyIsRunning() +{ + return QByteArrayLiteral("ISRUNNING"); +} + +QByteArray Serializer::customPropertyContextList() +{ + return QByteArrayLiteral("CONTEXTLIST"); +} diff --git a/src/zanshin/migrator/zanshin021migrator.cpp b/src/zanshin/migrator/zanshin021migrator.cpp --- a/src/zanshin/migrator/zanshin021migrator.cpp +++ b/src/zanshin/migrator/zanshin021migrator.cpp @@ -24,22 +24,25 @@ #include "zanshin021migrator.h" #include #include +#include #include #include #include #include +using Akonadi::Serializer; + Zanshin021Migrator::Zanshin021Migrator() { } bool Zanshin021Migrator::isProject(const Akonadi::Item& item) { // same as Serializer::isProject, but we don't need the serializer here... - return item.hasPayload() && !item.payload()->customProperty("Zanshin", "Project").isEmpty(); + return item.hasPayload() && !item.payload()->customProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsProject()).isEmpty(); } @@ -71,7 +74,7 @@ Akonadi::Item &item = seenItem.item(); if (!isProject(item)) { auto todo = item.payload(); - todo->setCustomProperty("Zanshin", "Project", QStringLiteral("1")); + todo->setCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsProject(), QStringLiteral("1")); item.setPayload(todo); seenItem.setDirty(); qDebug() << "Marking as project:" << item.id() << item.remoteId() << todo->summary(); diff --git a/src/zanshin/migrator/zanshincontextitemsmigrator.cpp b/src/zanshin/migrator/zanshincontextitemsmigrator.cpp --- a/src/zanshin/migrator/zanshincontextitemsmigrator.cpp +++ b/src/zanshin/migrator/zanshincontextitemsmigrator.cpp @@ -32,6 +32,8 @@ #include #include +using Akonadi::Serializer; + static const char s_contextTagType[] = "Zanshin-Context"; ZanshinContextItemsMigrator::ZanshinContextItemsMigrator() @@ -55,13 +57,13 @@ foreach (const Akonadi::Item &item, items) { if (item.hasPayload()) { auto todo = item.payload(); - if (which == WhichItems::TasksToConvert && !todo->customProperty("Zanshin", "ContextList").isEmpty()) { + if (which == WhichItems::TasksToConvert && !todo->customProperty(Serializer::customPropertyAppName(), Serializer::customPropertyContextList()).isEmpty()) { // This folder was already migrated, skip it hasTaskToConvert = false; qDebug() << "Detected an already converted task" << todo->uid(); break; } - const bool isContext = !todo->customProperty("Zanshin", "Context").isEmpty(); + const bool isContext = !todo->customProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsContext()).isEmpty(); if ((isContext && which == WhichItems::OnlyContexts) || (!isContext && which == WhichItems::TasksToConvert) || (!isContext && which == WhichItems::AllTasks)) { @@ -135,6 +137,13 @@ } } } + // While we're here, port from "Project" to "ISPROJECT" + auto todo = item.payload(); + if (!todo->customProperty("Zanshin", "Project").isEmpty()) { + todo->setCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsProject(), QStringLiteral("1")); + auto job = new Akonadi::ItemModifyJob(item); + job->exec(); + } } qDebug() << "Associated contexts to" << count << "items"; } diff --git a/tests/features/testenv/data/testdata.xml b/tests/features/testenv/data/testdata.xml --- a/tests/features/testenv/data/testdata.xml +++ b/tests/features/testenv/data/testdata.xml @@ -17,7 +17,7 @@ SUMMARY:Buy kiwis DUE;VALUE=DATE:20150310 PERCENT-COMPLETE:0 -X-KDE-Zanshin-ContextList:errands-context +X-KDE-ZANSHIN-CONTEXTLIST:errands-context END:VTODO END:VCALENDAR @@ -76,7 +76,7 @@ ACTION:DISPLAY TRIGGER;VALUE=DURATION:-PT15M X-KDE-KCALCORE-ENABLED:TRUE -X-KDE-Zanshin-ContextList:online-context +X-KDE-ZANSHIN-CONTEXTLIST:online-context END:VALARM END:VEVENT @@ -92,7 +92,7 @@ CREATED:20120322T164413Z UID:06ff6f36-f0a0-47b9-8c77-7a18207eb5ea LAST-MODIFIED:20120322T164413Z -X-KDE-Zanshin-Project:1 +X-KDE-ZANSHIN-ISPROJECT:1 SUMMARY:Read List PERCENT-COMPLETE:0 END:VTODO @@ -161,7 +161,7 @@ UID:f1a30fc7-d941-4c81-a083-7c1e9657ae24 LAST-MODIFIED:20120322T164413Z SUMMARY: Prepare talk about TDD -X-KDE-Zanshin-Project:1 +X-KDE-ZANSHIN-ISPROJECT:1 PERCENT-COMPLETE:0 END:VTODO @@ -302,7 +302,7 @@ CREATED:20120322T164413Z UID:04944d0e-43a5-4cc1-9ca0-bc3200981879 LAST-MODIFIED:20120322T164413Z -X-KDE-Zanshin-Project:1 +X-KDE-ZANSHIN-ISPROJECT:1 SUMMARY:Backlog PERCENT-COMPLETE:0 END:VTODO @@ -334,7 +334,7 @@ BEGIN:VTODO CREATED:20190317T162551Z UID:errands-context -X-KDE-Zanshin-Context:1 +X-KDE-ZANSHIN-ISCONTEXT:1 LAST-MODIFIED:20140317T162551Z SUMMARY:Errands END:VTODO @@ -349,7 +349,7 @@ BEGIN:VTODO CREATED:20190317T162551Z UID:online-context -X-KDE-Zanshin-Context:1 +X-KDE-ZANSHIN-ISCONTEXT:1 LAST-MODIFIED:20140317T162551Z SUMMARY:Online END:VTODO diff --git a/tests/testlib/akonadifakedata.cpp b/tests/testlib/akonadifakedata.cpp --- a/tests/testlib/akonadifakedata.cpp +++ b/tests/testlib/akonadifakedata.cpp @@ -27,11 +27,13 @@ #include +#include "akonadi/akonadiserializer.h" #include "akonadi/akonadiapplicationselectedattribute.h" #include using namespace Testlib; +using Akonadi::Serializer; template static Akonadi::Collection::Id findParentId(const Entity &entity) @@ -41,16 +43,13 @@ : Akonadi::Collection::root().id(); } -static const char s_contextListProperty[] = "ContextList"; -static const char s_appName[] = "Zanshin"; - // Should be in the serializer ideally ... but we don't link to that from here anyway. static QStringList extractContextUids(const Akonadi::Item &taskItem) { if (!taskItem.hasPayload()) return {}; auto todo = taskItem.payload(); - const QString contexts = todo->customProperty(s_appName, s_contextListProperty); + const QString contexts = todo->customProperty(Serializer::customPropertyAppName(), Serializer::customPropertyContextList()); return contexts.split(',', QString::SkipEmptyParts); } @@ -65,13 +64,13 @@ static void removeContextFromTask(const QString &contextUid, Akonadi::Item &item) { auto todo = item.payload(); - const QString contexts = todo->customProperty(s_appName, s_contextListProperty); + const QString contexts = todo->customProperty(Serializer::customPropertyAppName(), Serializer::customPropertyContextList()); QStringList contextList = contexts.split(',', QString::SkipEmptyParts); contextList.removeAll(contextUid); if (contextList.isEmpty()) - todo->removeCustomProperty(s_appName, s_contextListProperty); + todo->removeCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyContextList()); else - todo->setCustomProperty(s_appName, s_contextListProperty, contextList.join(',')); + todo->setCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyContextList(), contextList.join(',')); item.setPayload(todo); Q_ASSERT(contextList == extractContextUids(item)); } @@ -83,7 +82,7 @@ return false; auto todo = item.payload(); - return !todo->customProperty(s_appName, "Context").isEmpty(); + return !todo->customProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsContext()).isEmpty(); } AkonadiFakeData::AkonadiFakeData() diff --git a/tests/testlib/gentodo.cpp b/tests/testlib/gentodo.cpp --- a/tests/testlib/gentodo.cpp +++ b/tests/testlib/gentodo.cpp @@ -25,11 +25,10 @@ #include #include +#include using namespace Testlib; - -static const char s_contextListProperty[] = "ContextList"; -static const char s_appName[] = "Zanshin"; +using Akonadi::Serializer; GenTodo::GenTodo(const Akonadi::Item &item) : m_item(item) @@ -60,30 +59,30 @@ { auto todo = m_item.payload(); if (contextUids.isEmpty()) - todo->removeCustomProperty(s_appName, s_contextListProperty); + todo->removeCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyContextList()); else - todo->setCustomProperty(s_appName, s_contextListProperty, contextUids.join(',')); + todo->setCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyContextList(), contextUids.join(',')); m_item.setPayload(todo); return *this; } GenTodo &GenTodo::asProject(bool value) { auto todo = m_item.payload(); if (value) - todo->setCustomProperty("Zanshin", "Project", QStringLiteral("1")); + todo->setCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsProject(), QStringLiteral("1")); else - todo->removeCustomProperty("Zanshin", "Project"); + todo->removeCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsProject()); return *this; } GenTodo &GenTodo::asContext(bool value) { auto todo = m_item.payload(); if (value) - todo->setCustomProperty("Zanshin", "Context", QStringLiteral("1")); + todo->setCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsContext(), QStringLiteral("1")); else - todo->removeCustomProperty("Zanshin", "Context"); + todo->removeCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsContext()); return *this; } diff --git a/tests/units/akonadi/akonadiserializertest.cpp b/tests/units/akonadi/akonadiserializertest.cpp --- a/tests/units/akonadi/akonadiserializertest.cpp +++ b/tests/units/akonadi/akonadiserializertest.cpp @@ -35,14 +35,13 @@ Q_DECLARE_METATYPE(Akonadi::Item*) +using Akonadi::Serializer; + static void setTodoDates(KCalCore::Todo::Ptr todo, const QDate &start, const QDate &due) { todo->setDtStart(QDateTime(start)); todo->setDtDue(QDateTime(due)); } -static const char s_contextListProperty[] = "ContextList"; -static const char s_appName[] = "Zanshin"; - class AkonadiSerializerTest : public QObject { Q_OBJECT @@ -533,7 +532,7 @@ // A todo with the project flag KCalCore::Todo::Ptr todo(new KCalCore::Todo); todo->setSummary(QStringLiteral("foo")); - todo->setCustomProperty("Zanshin", "Project", QStringLiteral("1")); + todo->setCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsProject(), QStringLiteral("1")); // ... as payload of an item Akonadi::Item item; @@ -647,9 +646,9 @@ } if (updatedRunning) { - updatedTodo->setCustomProperty("Zanshin", "Running", "1"); + updatedTodo->setCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsRunning(), "1"); } else { - updatedTodo->removeCustomProperty("Zanshin", "Running"); + updatedTodo->removeCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsRunning()); } // ... as payload of a new item @@ -875,7 +874,7 @@ // A todo with the project flag KCalCore::Todo::Ptr projectTodo(new KCalCore::Todo); projectTodo->setSummary(QStringLiteral("foo")); - projectTodo->setCustomProperty("Zanshin", "Project", QStringLiteral("1")); + projectTodo->setCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsProject(), QStringLiteral("1")); // ... as payload of an item Akonadi::Item projectItem; @@ -1088,7 +1087,7 @@ } QCOMPARE(todo->relatedTo(), QStringLiteral("parent-uid")); - QCOMPARE(todo->customProperty("Zanshin", "Running"), running ? QStringLiteral("1") : QString()); + QCOMPARE(todo->customProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsRunning()), running ? QStringLiteral("1") : QString()); } void shouldVerifyIfAnItemIsATaskChild_data() @@ -1236,7 +1235,7 @@ // ... stored in a todo... KCalCore::Todo::Ptr todo(new KCalCore::Todo); todo->setSummary(summary); - todo->setCustomProperty("Zanshin", "Project", QStringLiteral("1")); + todo->setCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsProject(), QStringLiteral("1")); QVERIFY(!todo->uid().isEmpty()); // ... as payload of an item @@ -1308,7 +1307,7 @@ // A todo... KCalCore::Todo::Ptr originalTodo(new KCalCore::Todo); originalTodo->setSummary(QStringLiteral("summary")); - originalTodo->setCustomProperty("Zanshin", "Project", QStringLiteral("1")); + originalTodo->setCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsProject(), QStringLiteral("1")); // ... as payload of an item... Akonadi::Item originalItem(42); @@ -1331,7 +1330,7 @@ // ... in a new todo... KCalCore::Todo::Ptr updatedTodo(new KCalCore::Todo); updatedTodo->setSummary(updatedSummary); - updatedTodo->setCustomProperty("Zanshin", "Project", QStringLiteral("1")); + updatedTodo->setCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsProject(), QStringLiteral("1")); QVERIFY(!updatedTodo->uid().isEmpty()); // ... as payload of a new item @@ -1362,7 +1361,7 @@ // ... stored in a todo... KCalCore::Todo::Ptr originalTodo(new KCalCore::Todo); originalTodo->setSummary(summary); - originalTodo->setCustomProperty("Zanshin", "Project", QStringLiteral("1")); + originalTodo->setCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsProject(), QStringLiteral("1")); // ... as payload of an item... Akonadi::Item originalItem; @@ -1391,7 +1390,7 @@ // ... stored in a todo... KCalCore::Todo::Ptr originalTodo(new KCalCore::Todo); originalTodo->setSummary(summary); - originalTodo->setCustomProperty("Zanshin", "Project", QStringLiteral("1")); + originalTodo->setCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsProject(), QStringLiteral("1")); // ... as payload of an item... Akonadi::Item originalItem; @@ -1471,7 +1470,7 @@ auto todo = item.payload(); QCOMPARE(todo->summary(), summary); QCOMPARE(todo->uid(), todoUid); - QVERIFY(!todo->customProperty("Zanshin", "Project").isEmpty()); + QVERIFY(!todo->customProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsProject()).isEmpty()); } void shouldVerifyIfAnItemIsAProjectChild_data() @@ -1725,7 +1724,7 @@ if (item.hasPayload()) { auto todo = item.payload(); QCOMPARE(todo->relatedTo(), QString()); - QVERIFY(!todo->customProperty("Zanshin", "Project").isEmpty()); + QVERIFY(!todo->customProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsProject()).isEmpty()); } } @@ -1736,7 +1735,7 @@ Akonadi::Item *itemWithContexts = new Akonadi::Item(15); KCalCore::Todo::Ptr todo(new KCalCore::Todo); // we can cheat and not really create contexts... - todo->setCustomProperty(s_appName, s_contextListProperty, "one,two"); + todo->setCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyContextList(), "one,two"); itemWithContexts->setPayload(todo); QTest::newRow("with_contexts") << itemWithContexts; @@ -1756,7 +1755,7 @@ // THEN auto todo = item->payload(); - QVERIFY(todo->customProperty(s_appName, s_contextListProperty).isEmpty()); + QVERIFY(todo->customProperty(Serializer::customPropertyAppName(), Serializer::customPropertyContextList()).isEmpty()); delete item; } @@ -1778,7 +1777,7 @@ // ... stored in a todo... KCalCore::Todo::Ptr todo(new KCalCore::Todo); todo->setSummary(name); - todo->setCustomProperty(s_appName, "Context", QStringLiteral("1")); + todo->setCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsContext(), QStringLiteral("1")); QVERIFY(!todo->uid().isEmpty()); // ... as payload of an item @@ -1818,7 +1817,7 @@ KCalCore::Todo::Ptr originalTodo(new KCalCore::Todo); originalTodo->setSummary("summary"); if (isProject) - originalTodo->setCustomProperty(s_appName, "Project", QStringLiteral("1")); + originalTodo->setCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsProject(), QStringLiteral("1")); // ... as payload of an item... Akonadi::Item originalItem; @@ -1848,7 +1847,7 @@ // ... stored in a todo... KCalCore::Todo::Ptr todo(new KCalCore::Todo); todo->setSummary(name); - todo->setCustomProperty(s_appName, "Context", QStringLiteral("1")); + todo->setCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsContext(), QStringLiteral("1")); QVERIFY(!todo->uid().isEmpty()); // ... as payload of an item @@ -1889,7 +1888,7 @@ KCalCore::Todo::Ptr wrongTodo(new KCalCore::Todo); wrongTodo->setSummary("wrongSummary"); if (isProject) - wrongTodo->setCustomProperty(s_appName, "Project", QStringLiteral("1")); + wrongTodo->setCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsProject(), QStringLiteral("1")); Akonadi::Item wrongItem; wrongItem.setMimeType(QStringLiteral("application/x-vnd.akonadi.calendar.todo")); @@ -1921,7 +1920,7 @@ Akonadi::Item relatedItem; auto todo = KCalCore::Todo::Ptr::create(); todo->setSummary("summary"); - todo->setCustomProperty(s_appName, s_contextListProperty, contextUid); + todo->setCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyContextList(), contextUid); relatedItem.setPayload(todo); QTest::newRow("Related item") << context << relatedItem << true; @@ -2019,14 +2018,14 @@ Akonadi::Item item2; auto todo2 = KCalCore::Todo::Ptr::create(); - todo2->setCustomProperty(s_appName, s_contextListProperty, "another"); + todo2->setCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyContextList(), "another"); item2.setPayload(todo2); const QString bothContexts = QStringLiteral("another,") + contextUid; QTest::newRow("item_with_another_context") << context << item2 << bothContexts; Akonadi::Item item3; auto todo3 = KCalCore::Todo::Ptr::create(); - todo3->setCustomProperty(s_appName, s_contextListProperty, bothContexts); + todo3->setCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyContextList(), bothContexts); item3.setPayload(todo3); QTest::newRow("item_with_this_context_already") << context << item3 << bothContexts; } @@ -2044,7 +2043,7 @@ // THEN KCalCore::Todo::Ptr todo = item.payload(); - QCOMPARE(todo->customProperty(s_appName, s_contextListProperty), expectedContextList); + QCOMPARE(todo->customProperty(Serializer::customPropertyAppName(), Serializer::customPropertyContextList()), expectedContextList); } void shouldRemoveContextFromTask_data() @@ -2065,20 +2064,20 @@ Akonadi::Item item2; auto todo2 = KCalCore::Todo::Ptr::create(); - todo2->setCustomProperty(s_appName, s_contextListProperty, "another"); + todo2->setCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyContextList(), "another"); item2.setPayload(todo2); QTest::newRow("item_with_another_context") << context << item2 << QString("another"); Akonadi::Item item3; auto todo3 = KCalCore::Todo::Ptr::create(); - todo3->setCustomProperty(s_appName, s_contextListProperty, contextUid); + todo3->setCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyContextList(), contextUid); item3.setPayload(todo3); QTest::newRow("item_with_this_context_already") << context << item3 << QString(); Akonadi::Item item4; auto todo4 = KCalCore::Todo::Ptr::create(); const QString bothContexts = QStringLiteral("another,") + contextUid; - todo4->setCustomProperty(s_appName, s_contextListProperty, bothContexts); + todo4->setCustomProperty(Serializer::customPropertyAppName(), Serializer::customPropertyContextList(), bothContexts); item4.setPayload(todo4); QTest::newRow("item_with_two_contexts") << context << item4 << QString("another"); } @@ -2096,7 +2095,7 @@ // THEN KCalCore::Todo::Ptr todo = item.payload(); - QCOMPARE(todo->customProperty(s_appName, s_contextListProperty), expectedContextList); + QCOMPARE(todo->customProperty(Serializer::customPropertyAppName(), Serializer::customPropertyContextList()), expectedContextList); } // Investigation into how to differentiate all-day events from events with time, diff --git a/tests/units/akonadi/testenv/data/testdata.xml b/tests/units/akonadi/testenv/data/testdata.xml --- a/tests/units/akonadi/testenv/data/testdata.xml +++ b/tests/units/akonadi/testenv/data/testdata.xml @@ -70,7 +70,7 @@ UID:f1a30fc7-d941-4c81-a083-7c1e9657ae24 LAST-MODIFIED:20120322T164413Z SUMMARY: Prepare the talk on TDD -X-KDE-Zanshin-Project:1 +X-KDE-ZANSHIN-ISPROJECT:1 PERCENT-COMPLETE:0 END:VTODO @@ -158,7 +158,7 @@ LAST-MODIFIED:20111214T031148Z SUMMARY:Buy apples PERCENT-COMPLETE:0 -X-KDE-Zanshin-ContextList:errands-context +X-KDE-ZANSHIN-CONTEXTLIST:errands-context END:VTODO END:VCALENDAR @@ -176,7 +176,7 @@ UID:144e86e5-a169-4c89-8ad0-fdd0b2a948e1 LAST-MODIFIED:20111214T031148Z SUMMARY:Buy apples -X-KDE-Zanshin-ContextList:errands-context +X-KDE-ZANSHIN-CONTEXTLIST:errands-context PERCENT-COMPLETE:0 END:VTODO @@ -270,7 +270,7 @@ BEGIN:VTODO CREATED:20190317T162551Z UID:errands-context -X-KDE-Zanshin-Context:1 +X-KDE-ZANSHIN-ISCONTEXT:1 LAST-MODIFIED:20140317T162551Z SUMMARY:Errands END:VTODO @@ -285,7 +285,7 @@ BEGIN:VTODO CREATED:20190317T162551Z UID:online-context -X-KDE-Zanshin-Context:1 +X-KDE-ZANSHIN-ISCONTEXT:1 LAST-MODIFIED:20140317T162551Z SUMMARY:Online END:VTODO diff --git a/tests/units/migrator/testenv/data/testdata.xml b/tests/units/migrator/testenv/data/testdata.xml --- a/tests/units/migrator/testenv/data/testdata.xml +++ b/tests/units/migrator/testenv/data/testdata.xml @@ -49,7 +49,7 @@ CREATED:20111214T031148Z UID:project-with-comment-and-property COMMENT:X-Zanshin-Project -X-KDE-Zanshin-Project:1 +X-KDE-ZANSHIN-ISPROJECT:1 LAST-MODIFIED:20111214T031148Z SUMMARY:Buy apples PERCENT-COMPLETE:0 @@ -69,7 +69,7 @@ DTSTAMP:20140317T162551Z CREATED:20140317T162551Z UID:new-project-with-property -X-KDE-Zanshin-Project:1 +X-KDE-ZANSHIN-ISPROJECT:1 LAST-MODIFIED:20140317T162551Z SUMMARY:Buy pears DUE;VALUE=DATE:20140324 diff --git a/tests/units/migrator/zanshincontextitemsmigrationtest.cpp b/tests/units/migrator/zanshincontextitemsmigrationtest.cpp --- a/tests/units/migrator/zanshincontextitemsmigrationtest.cpp +++ b/tests/units/migrator/zanshincontextitemsmigrationtest.cpp @@ -45,6 +45,8 @@ #include +using Akonadi::Serializer; + class ZanshinContextItemsMigrationTest : public QObject { Q_OBJECT @@ -194,7 +196,7 @@ //qDebug() << item.id() << it.key(); auto todo = item.payload(); QVERIFY(todo); - const auto contextUids = todo->customProperty("Zanshin", "ContextList").split(',', QString::SkipEmptyParts); + const auto contextUids = todo->customProperty(Serializer::customPropertyAppName(), Serializer::customPropertyContextList()).split(',', QString::SkipEmptyParts); QStringList contextNames; std::transform(contextUids.cbegin(), contextUids.cend(), std::back_inserter(contextNames), [this](const QString &uid) { return m_contextTodos.value(uid); }); contextNames.sort(); diff --git a/tests/units/testlib/akonadifakedataxmlloadertest.cpp b/tests/units/testlib/akonadifakedataxmlloadertest.cpp --- a/tests/units/testlib/akonadifakedataxmlloadertest.cpp +++ b/tests/units/testlib/akonadifakedataxmlloadertest.cpp @@ -23,11 +23,14 @@ #include "testlib/akonadifakedata.h" #include "testlib/akonadifakedataxmlloader.h" +#include #include #include +using Akonadi::Serializer; + class AkonadiFakeDataXmlLoaderTest : public QObject { Q_OBJECT @@ -84,7 +87,7 @@ const auto contextAsTodo = firstContext.payload(); QCOMPARE(contextAsTodo->uid(), "online-context"); QCOMPARE(contextAsTodo->summary(), "Online"); - QCOMPARE(contextAsTodo->customProperty("Zanshin", "Context"), "1"); + QCOMPARE(contextAsTodo->customProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsContext()), "1"); } }; diff --git a/tests/units/testlib/gentodotest.cpp b/tests/units/testlib/gentodotest.cpp --- a/tests/units/testlib/gentodotest.cpp +++ b/tests/units/testlib/gentodotest.cpp @@ -26,8 +26,10 @@ #include #include +#include using namespace Testlib; +using Akonadi::Serializer; class GenTodoTest : public QObject { @@ -73,7 +75,7 @@ // THEN auto todo = item.payload(); - QStringList contextUids = todo->customProperty("Zanshin", "ContextList").split(','); + QStringList contextUids = todo->customProperty(Serializer::customPropertyAppName(), Serializer::customPropertyContextList()).split(','); QCOMPARE(contextUids.size(), 3); QCOMPARE(contextUids.at(0), "42"); QCOMPARE(contextUids.at(1), "43"); @@ -86,28 +88,28 @@ Akonadi::Item item = GenTodo().asProject(); // THEN - QVERIFY(!item.payload()->customProperty("Zanshin", "Project").isEmpty()); + QVERIFY(!item.payload()->customProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsProject()).isEmpty()); // WHEN item = GenTodo(item).asProject(false); // THEN - QVERIFY(item.payload()->customProperty("Zanshin", "Project").isEmpty()); + QVERIFY(item.payload()->customProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsProject()).isEmpty()); } void shouldAllowToSetContextType() { // GIVEN Akonadi::Item item = GenTodo().asContext(); // THEN - QVERIFY(!item.payload()->customProperty("Zanshin", "Context").isEmpty()); + QVERIFY(!item.payload()->customProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsContext()).isEmpty()); // WHEN item = GenTodo(item).asContext(false); // THEN - QVERIFY(item.payload()->customProperty("Zanshin", "Context").isEmpty()); + QVERIFY(item.payload()->customProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsContext()).isEmpty()); } void shouldAllowToSetUid()