summaryrefslogtreecommitdiffstats
path: root/examples/client/main.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-12-22 16:35:09 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-12-22 16:35:09 +0100
commite8ab53258c044969146be385629a80afe801dee5 (patch)
tree170ded5835b8a60ef813964530aff7c79e52f4a0 /examples/client/main.cpp
parent50069f3c28b4130a9a81c25746d2c9d97c0356f5 (diff)
downloadsink-e8ab53258c044969146be385629a80afe801dee5.tar.gz
sink-e8ab53258c044969146be385629a80afe801dee5.zip
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.
Diffstat (limited to 'examples/client/main.cpp')
-rw-r--r--examples/client/main.cpp35
1 files changed, 27 insertions, 8 deletions
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[])
335 } else if (command == "create") { 335 } else if (command == "create") {
336 auto type = !args.isEmpty() ? args.takeFirst().toLatin1() : QByteArray(); 336 auto type = !args.isEmpty() ? args.takeFirst().toLatin1() : QByteArray();
337 auto &store = getStore(type); 337 auto &store = getStore(type);
338 auto resource = !args.isEmpty() ? args.takeFirst().toLatin1() : QByteArray(); 338 Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr object;
339 auto object = store.getObject(resource); 339 if (type == "resource") {
340 auto resourceType = !args.isEmpty() ? args.takeFirst().toLatin1() : QByteArray();
341 object = store.getObject("");
342 object->setProperty("type", resourceType);
343 } else {
344 auto resource = !args.isEmpty() ? args.takeFirst().toLatin1() : QByteArray();
345 object = store.getObject(resource);
346 }
340 auto map = consumeMap(args); 347 auto map = consumeMap(args);
341 for (auto i = map.begin(); i != map.end(); ++i) { 348 for (auto i = map.begin(); i != map.end(); ++i) {
342 object->setProperty(i.key().toLatin1(), i.value()); 349 object->setProperty(i.key().toLatin1(), i.value());
@@ -349,9 +356,15 @@ int main(int argc, char *argv[])
349 } else if (command == "modify") { 356 } else if (command == "modify") {
350 auto type = !args.isEmpty() ? args.takeFirst().toLatin1() : QByteArray(); 357 auto type = !args.isEmpty() ? args.takeFirst().toLatin1() : QByteArray();
351 auto &store = getStore(type); 358 auto &store = getStore(type);
352 auto resource = !args.isEmpty() ? args.takeFirst().toLatin1() : QByteArray(); 359 Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr object;
353 auto identifier = !args.isEmpty() ? args.takeFirst().toLatin1() : QByteArray(); 360 if (type == "resource") {
354 auto object = store.getObject(resource, identifier); 361 auto identifier = !args.isEmpty() ? args.takeFirst().toLatin1() : QByteArray();
362 object = store.getObject("", identifier);
363 } else {
364 auto resource = !args.isEmpty() ? args.takeFirst().toLatin1() : QByteArray();
365 auto identifier = !args.isEmpty() ? args.takeFirst().toLatin1() : QByteArray();
366 object = store.getObject(resource, identifier);
367 }
355 auto map = consumeMap(args); 368 auto map = consumeMap(args);
356 for (auto i = map.begin(); i != map.end(); ++i) { 369 for (auto i = map.begin(); i != map.end(); ++i) {
357 object->setProperty(i.key().toLatin1(), i.value()); 370 object->setProperty(i.key().toLatin1(), i.value());
@@ -364,9 +377,15 @@ int main(int argc, char *argv[])
364 } else if (command == "remove") { 377 } else if (command == "remove") {
365 auto type = !args.isEmpty() ? args.takeFirst().toLatin1() : QByteArray(); 378 auto type = !args.isEmpty() ? args.takeFirst().toLatin1() : QByteArray();
366 auto &store = getStore(type); 379 auto &store = getStore(type);
367 auto resource = !args.isEmpty() ? args.takeFirst().toLatin1() : QByteArray(); 380 Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr object;
368 auto identifier = !args.isEmpty() ? args.takeFirst().toLatin1() : QByteArray(); 381 if (type == "resource") {
369 auto object = store.getObject(resource, identifier); 382 auto identifier = !args.isEmpty() ? args.takeFirst().toLatin1() : QByteArray();
383 object = store.getObject("", identifier);
384 } else {
385 auto resource = !args.isEmpty() ? args.takeFirst().toLatin1() : QByteArray();
386 auto identifier = !args.isEmpty() ? args.takeFirst().toLatin1() : QByteArray();
387 object = store.getObject(resource, identifier);
388 }
370 auto result = store.remove(*object).exec(); 389 auto result = store.remove(*object).exec();
371 result.waitForFinished(); 390 result.waitForFinished();
372 if (result.errorCode()) { 391 if (result.errorCode()) {