diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-01-05 14:21:19 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-01-05 14:21:19 +0100 |
commit | 3ab66dd16323d8e25e7322dce0fc0cbe9eae7685 (patch) | |
tree | 7abebc3b11ee37b279987b2d7511e68244c4f94f /sinksh/syntax_modules | |
parent | 2cdea00408a48c268c2c74b8c058f984732f75a2 (diff) | |
download | sink-3ab66dd16323d8e25e7322dce0fc0cbe9eae7685.tar.gz sink-3ab66dd16323d8e25e7322dce0fc0cbe9eae7685.zip |
sinksh account removal
Diffstat (limited to 'sinksh/syntax_modules')
-rw-r--r-- | sinksh/syntax_modules/sink_remove.cpp | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/sinksh/syntax_modules/sink_remove.cpp b/sinksh/syntax_modules/sink_remove.cpp index d474518..7e66ece 100644 --- a/sinksh/syntax_modules/sink_remove.cpp +++ b/sinksh/syntax_modules/sink_remove.cpp | |||
@@ -94,13 +94,57 @@ bool resource(const QStringList &args, State &state) | |||
94 | return true; | 94 | return true; |
95 | } | 95 | } |
96 | 96 | ||
97 | bool account(const QStringList &args, State &state) | ||
98 | { | ||
99 | if (args.isEmpty()) { | ||
100 | state.printError(QObject::tr("An account can not be removed without an id"), "sink_remove/01"); | ||
101 | } | ||
102 | |||
103 | auto &store = SinkshUtils::getStore("account"); | ||
104 | |||
105 | auto id = args.at(0); | ||
106 | Sink::ApplicationDomain::ApplicationDomainType::Ptr object = store.getObject("", id.toLatin1()); | ||
107 | |||
108 | auto result = store.remove(*object).exec(); | ||
109 | result.waitForFinished(); | ||
110 | if (result.errorCode()) { | ||
111 | state.printError(QObject::tr("An error occurred while removing the account %1: %2").arg(id).arg(result.errorMessage()), | ||
112 | "akonaid_remove_e" + QString::number(result.errorCode())); | ||
113 | } | ||
114 | |||
115 | return true; | ||
116 | } | ||
117 | |||
118 | bool identity(const QStringList &args, State &state) | ||
119 | { | ||
120 | if (args.isEmpty()) { | ||
121 | state.printError(QObject::tr("An identity can not be removed without an id"), "sink_remove/01"); | ||
122 | } | ||
123 | |||
124 | auto &store = SinkshUtils::getStore("identity"); | ||
125 | |||
126 | auto id = args.at(0); | ||
127 | Sink::ApplicationDomain::ApplicationDomainType::Ptr object = store.getObject("", id.toLatin1()); | ||
128 | |||
129 | auto result = store.remove(*object).exec(); | ||
130 | result.waitForFinished(); | ||
131 | if (result.errorCode()) { | ||
132 | state.printError(QObject::tr("An error occurred while removing the identity %1: %2").arg(id).arg(result.errorMessage()), | ||
133 | "akonaid_remove_e" + QString::number(result.errorCode())); | ||
134 | } | ||
135 | |||
136 | return true; | ||
137 | } | ||
138 | |||
97 | 139 | ||
98 | Syntax::List syntax() | 140 | Syntax::List syntax() |
99 | { | 141 | { |
100 | Syntax remove("remove", QObject::tr("Remove items in a resource"), &SinkRemove::remove); | 142 | Syntax remove("remove", QObject::tr("Remove items in a resource"), &SinkRemove::remove); |
101 | Syntax resource("resource", QObject::tr("Removes a resource"), &SinkRemove::resource, Syntax::NotInteractive); | 143 | Syntax resource("resource", QObject::tr("Removes a resource"), &SinkRemove::resource, Syntax::NotInteractive); |
144 | Syntax account("account", QObject::tr("Removes a account"), &SinkRemove::account, Syntax::NotInteractive); | ||
145 | Syntax identity("identity", QObject::tr("Removes an identity"), &SinkRemove::identity, Syntax::NotInteractive); | ||
102 | resource.completer = &SinkshUtils::resourceCompleter; | 146 | resource.completer = &SinkshUtils::resourceCompleter; |
103 | remove.children << resource; | 147 | remove.children << resource << account << identity; |
104 | 148 | ||
105 | return Syntax::List() << remove; | 149 | return Syntax::List() << remove; |
106 | } | 150 | } |