From e8ab53258c044969146be385629a80afe801dee5 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 22 Dec 2015 16:35:09 +0100 Subject: Turn operations of resources into a special case. Resources don't live inside a resource context, and as such inherently are a special case. By also removing the option to manually specify the identifier, the commandline is a lot easier to use. --- examples/client/main.cpp | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) (limited to 'examples/client') diff --git a/examples/client/main.cpp b/examples/client/main.cpp index 81bcc11..946557f 100644 --- a/examples/client/main.cpp +++ b/examples/client/main.cpp @@ -335,8 +335,15 @@ int main(int argc, char *argv[]) } else if (command == "create") { auto type = !args.isEmpty() ? args.takeFirst().toLatin1() : QByteArray(); auto &store = getStore(type); - auto resource = !args.isEmpty() ? args.takeFirst().toLatin1() : QByteArray(); - auto object = store.getObject(resource); + Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr object; + if (type == "resource") { + auto resourceType = !args.isEmpty() ? args.takeFirst().toLatin1() : QByteArray(); + object = store.getObject(""); + object->setProperty("type", resourceType); + } else { + auto resource = !args.isEmpty() ? args.takeFirst().toLatin1() : QByteArray(); + object = store.getObject(resource); + } auto map = consumeMap(args); for (auto i = map.begin(); i != map.end(); ++i) { object->setProperty(i.key().toLatin1(), i.value()); @@ -349,9 +356,15 @@ int main(int argc, char *argv[]) } else if (command == "modify") { auto type = !args.isEmpty() ? args.takeFirst().toLatin1() : QByteArray(); auto &store = getStore(type); - auto resource = !args.isEmpty() ? args.takeFirst().toLatin1() : QByteArray(); - auto identifier = !args.isEmpty() ? args.takeFirst().toLatin1() : QByteArray(); - auto object = store.getObject(resource, identifier); + Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr object; + if (type == "resource") { + auto identifier = !args.isEmpty() ? args.takeFirst().toLatin1() : QByteArray(); + object = store.getObject("", identifier); + } else { + auto resource = !args.isEmpty() ? args.takeFirst().toLatin1() : QByteArray(); + auto identifier = !args.isEmpty() ? args.takeFirst().toLatin1() : QByteArray(); + object = store.getObject(resource, identifier); + } auto map = consumeMap(args); for (auto i = map.begin(); i != map.end(); ++i) { object->setProperty(i.key().toLatin1(), i.value()); @@ -364,9 +377,15 @@ int main(int argc, char *argv[]) } else if (command == "remove") { auto type = !args.isEmpty() ? args.takeFirst().toLatin1() : QByteArray(); auto &store = getStore(type); - auto resource = !args.isEmpty() ? args.takeFirst().toLatin1() : QByteArray(); - auto identifier = !args.isEmpty() ? args.takeFirst().toLatin1() : QByteArray(); - auto object = store.getObject(resource, identifier); + Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr object; + if (type == "resource") { + auto identifier = !args.isEmpty() ? args.takeFirst().toLatin1() : QByteArray(); + object = store.getObject("", identifier); + } else { + auto resource = !args.isEmpty() ? args.takeFirst().toLatin1() : QByteArray(); + auto identifier = !args.isEmpty() ? args.takeFirst().toLatin1() : QByteArray(); + object = store.getObject(resource, identifier); + } auto result = store.remove(*object).exec(); result.waitForFinished(); if (result.errorCode()) { -- cgit v1.2.3