diff options
-rw-r--r-- | sinksh/sinksh_utils.cpp | 19 | ||||
-rw-r--r-- | sinksh/sinksh_utils.h | 1 | ||||
-rw-r--r-- | sinksh/syntax_modules/sink_list.cpp | 3 | ||||
-rw-r--r-- | sinksh/syntax_modules/sink_sync.cpp | 2 |
4 files changed, 19 insertions, 6 deletions
diff --git a/sinksh/sinksh_utils.cpp b/sinksh/sinksh_utils.cpp index c542670..e2cd977 100644 --- a/sinksh/sinksh_utils.cpp +++ b/sinksh/sinksh_utils.cpp | |||
@@ -164,7 +164,7 @@ bool applyFilter(Sink::Query &query, const QStringList &args_) | |||
164 | if (resource.contains('/')) { | 164 | if (resource.contains('/')) { |
165 | //The resource isn't an id but a path | 165 | //The resource isn't an id but a path |
166 | auto list = resource.split('/'); | 166 | auto list = resource.split('/'); |
167 | const auto resourceId = list.takeFirst(); | 167 | const auto resourceId = parseUid(list.takeFirst()); |
168 | query.resourceFilter(resourceId); | 168 | query.resourceFilter(resourceId); |
169 | if (type == Sink::ApplicationDomain::getTypeName<Sink::ApplicationDomain::Mail>() && !list.isEmpty()) { | 169 | if (type == Sink::ApplicationDomain::getTypeName<Sink::ApplicationDomain::Mail>() && !list.isEmpty()) { |
170 | auto value = list.takeFirst(); | 170 | auto value = list.takeFirst(); |
@@ -188,7 +188,7 @@ bool applyFilter(Sink::Query &query, const QStringList &args_) | |||
188 | } | 188 | } |
189 | } | 189 | } |
190 | } else { | 190 | } else { |
191 | query.resourceFilter(resource); | 191 | query.resourceFilter(parseUid(resource)); |
192 | } | 192 | } |
193 | } | 193 | } |
194 | return true; | 194 | return true; |
@@ -199,22 +199,31 @@ bool applyFilter(Sink::Query &query, const SyntaxTree::Options &options) | |||
199 | bool ret = applyFilter(query, options.positionalArguments); | 199 | bool ret = applyFilter(query, options.positionalArguments); |
200 | if (options.options.contains("resource")) { | 200 | if (options.options.contains("resource")) { |
201 | for (const auto &f : options.options.value("resource")) { | 201 | for (const auto &f : options.options.value("resource")) { |
202 | query.resourceFilter(f.toLatin1()); | 202 | query.resourceFilter(parseUid(f.toLatin1())); |
203 | } | 203 | } |
204 | } | 204 | } |
205 | if (options.options.contains("filter")) { | 205 | if (options.options.contains("filter")) { |
206 | for (const auto &f : options.options.value("filter")) { | 206 | for (const auto &f : options.options.value("filter")) { |
207 | auto filter = f.split("="); | 207 | auto filter = f.split("="); |
208 | const auto property = filter.value(0).toLatin1(); | 208 | const auto property = filter.value(0).toLatin1(); |
209 | query.filter(property, Sink::PropertyParser::parse(query.type(), property, filter.value(1))); | 209 | const auto value = filter.value(1); |
210 | query.filter(property, Sink::PropertyParser::parse(query.type(), property, QString::fromUtf8(parseUid(value.toUtf8())))); | ||
210 | } | 211 | } |
211 | } | 212 | } |
212 | if (options.options.contains("id")) { | 213 | if (options.options.contains("id")) { |
213 | for (const auto &f : options.options.value("id")) { | 214 | for (const auto &f : options.options.value("id")) { |
214 | query.filter(f.toUtf8()); | 215 | query.filter(parseUid(f.toUtf8())); |
215 | } | 216 | } |
216 | } | 217 | } |
217 | return ret; | 218 | return ret; |
218 | } | 219 | } |
219 | 220 | ||
221 | QByteArray parseUid(const QByteArray &uid) | ||
222 | { | ||
223 | if (uid.size() == 36 && uid.contains('-') && !uid.startsWith('{')) { | ||
224 | return '{' + uid + '}'; | ||
225 | } | ||
226 | return uid; | ||
227 | } | ||
228 | |||
220 | } | 229 | } |
diff --git a/sinksh/sinksh_utils.h b/sinksh/sinksh_utils.h index e251803..e11a428 100644 --- a/sinksh/sinksh_utils.h +++ b/sinksh/sinksh_utils.h | |||
@@ -45,6 +45,7 @@ QStringList debugareaCompleter(const QStringList &, const QString &fragment, Sta | |||
45 | QMap<QString, QString> keyValueMapFromArgs(const QStringList &args); | 45 | QMap<QString, QString> keyValueMapFromArgs(const QStringList &args); |
46 | bool applyFilter(Sink::Query &query, const QStringList &args); | 46 | bool applyFilter(Sink::Query &query, const QStringList &args); |
47 | bool applyFilter(Sink::Query &query, const SyntaxTree::Options &args); | 47 | bool applyFilter(Sink::Query &query, const SyntaxTree::Options &args); |
48 | QByteArray parseUid(const QByteArray &); | ||
48 | 49 | ||
49 | /** | 50 | /** |
50 | * A small abstraction layer to use the sink store with the type available as string. | 51 | * A small abstraction layer to use the sink store with the type available as string. |
diff --git a/sinksh/syntax_modules/sink_list.cpp b/sinksh/syntax_modules/sink_list.cpp index b002438..a56740d 100644 --- a/sinksh/syntax_modules/sink_list.cpp +++ b/sinksh/syntax_modules/sink_list.cpp | |||
@@ -42,6 +42,9 @@ namespace SinkList | |||
42 | static QByteArray compressId(bool compress, const QByteArray &id) | 42 | static QByteArray compressId(bool compress, const QByteArray &id) |
43 | { | 43 | { |
44 | if (!compress) { | 44 | if (!compress) { |
45 | if (id.startsWith('{')) { | ||
46 | return id.mid(1, id.length() - 2); | ||
47 | } | ||
45 | return id; | 48 | return id; |
46 | } | 49 | } |
47 | auto compactId = id.mid(1, id.length() - 2).split('-'); | 50 | auto compactId = id.mid(1, id.length() - 2).split('-'); |
diff --git a/sinksh/syntax_modules/sink_sync.cpp b/sinksh/syntax_modules/sink_sync.cpp index 8b48785..f165f58 100644 --- a/sinksh/syntax_modules/sink_sync.cpp +++ b/sinksh/syntax_modules/sink_sync.cpp | |||
@@ -49,7 +49,7 @@ bool sync(const QStringList &args, State &state) | |||
49 | Sink::Query query; | 49 | Sink::Query query; |
50 | if (!options.positionalArguments.isEmpty() && !SinkshUtils::isValidStoreType(options.positionalArguments.first())) { | 50 | if (!options.positionalArguments.isEmpty() && !SinkshUtils::isValidStoreType(options.positionalArguments.first())) { |
51 | //We have only specified a resource | 51 | //We have only specified a resource |
52 | query.resourceFilter(options.positionalArguments.first().toLatin1()); | 52 | query.resourceFilter(SinkshUtils::parseUid(options.positionalArguments.first().toLatin1())); |
53 | } else { | 53 | } else { |
54 | //We have specified a full filter | 54 | //We have specified a full filter |
55 | if (!SinkshUtils::applyFilter(query, options.positionalArguments)) { | 55 | if (!SinkshUtils::applyFilter(query, options.positionalArguments)) { |