diff options
author | Aaron Seigo <aseigo@kde.org> | 2015-12-25 20:11:02 +0100 |
---|---|---|
committer | Aaron Seigo <aseigo@kde.org> | 2015-12-25 20:11:02 +0100 |
commit | 47f175743ada27a031c9496a2bd1890c74464b27 (patch) | |
tree | 5772fa581e4e3ab208315e86fcc43f15819aa82e /akonadish/syntax_modules/akonadi_remove.cpp | |
parent | 23f0de019b76cc3552fa7b03a7ff343b6f1c1b2d (diff) | |
download | sink-47f175743ada27a031c9496a2bd1890c74464b27.tar.gz sink-47f175743ada27a031c9496a2bd1890c74464b27.zip |
remove non-resources
Diffstat (limited to 'akonadish/syntax_modules/akonadi_remove.cpp')
-rw-r--r-- | akonadish/syntax_modules/akonadi_remove.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/akonadish/syntax_modules/akonadi_remove.cpp b/akonadish/syntax_modules/akonadi_remove.cpp index 01e4ead..5e11af3 100644 --- a/akonadish/syntax_modules/akonadi_remove.cpp +++ b/akonadish/syntax_modules/akonadi_remove.cpp | |||
@@ -39,6 +39,40 @@ | |||
39 | namespace AkonadiRemove | 39 | namespace AkonadiRemove |
40 | { | 40 | { |
41 | 41 | ||
42 | bool remove(const QStringList &args, State &state) | ||
43 | { | ||
44 | if (args.isEmpty()) { | ||
45 | state.printError(QObject::tr("A type is required"), "akonadicreate/02"); | ||
46 | return false; | ||
47 | } | ||
48 | |||
49 | if (args.count() < 2) { | ||
50 | state.printError(QObject::tr("A resource ID is required to remove items"), "akonadicreate/03"); | ||
51 | return false; | ||
52 | } | ||
53 | |||
54 | if (args.count() < 3) { | ||
55 | state.printError(QObject::tr("An object ID is required to remove items"), "akonadicreate/03"); | ||
56 | return false; | ||
57 | } | ||
58 | |||
59 | auto type = args[0]; | ||
60 | auto resourceId = args[1]; | ||
61 | auto identifier = args[2]; | ||
62 | |||
63 | auto &store = AkonadishUtils::getStore(type); | ||
64 | Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr object = store.getObject(resourceId.toUtf8(), identifier.toUtf8()); | ||
65 | |||
66 | auto result = store.remove(*object).exec(); | ||
67 | result.waitForFinished(); | ||
68 | if (result.errorCode()) { | ||
69 | state.printError(QObject::tr("An error occurred while removing %1 from %1: %2").arg(identifier).arg(resourceId).arg(result.errorMessage()), | ||
70 | "akonaid_create_" + QString::number(result.errorCode())); | ||
71 | } | ||
72 | |||
73 | return true; | ||
74 | } | ||
75 | |||
42 | bool resource(const QStringList &args, State &state) | 76 | bool resource(const QStringList &args, State &state) |
43 | { | 77 | { |
44 | if (args.isEmpty()) { | 78 | if (args.isEmpty()) { |