summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/CMakeLists.txt2
-rw-r--r--common/domain/applicationdomaintype.cpp1
-rw-r--r--common/propertyparser.cpp29
-rw-r--r--common/propertyparser.h33
-rw-r--r--sinksh/syntax_modules/sink_create.cpp6
-rw-r--r--sinksh/syntax_modules/sink_list.cpp6
-rw-r--r--sinksh/syntax_modules/sink_modify.cpp9
7 files changed, 76 insertions, 10 deletions
diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt
index 92da470..ec437ed 100644
--- a/common/CMakeLists.txt
+++ b/common/CMakeLists.txt
@@ -60,6 +60,7 @@ set(command_SRCS
60 resourceconfig.cpp 60 resourceconfig.cpp
61 configstore.cpp 61 configstore.cpp
62 resultset.cpp 62 resultset.cpp
63 domain/propertyregistry.cpp
63 domain/applicationdomaintype.cpp 64 domain/applicationdomaintype.cpp
64 domain/contact.cpp 65 domain/contact.cpp
65 domain/event.cpp 66 domain/event.cpp
@@ -81,6 +82,7 @@ set(command_SRCS
81 notification.cpp 82 notification.cpp
82 commandprocessor.cpp 83 commandprocessor.cpp
83 inspector.cpp 84 inspector.cpp
85 propertyparser.cpp
84 ${storage_SRCS}) 86 ${storage_SRCS})
85 87
86add_library(${PROJECT_NAME} SHARED ${command_SRCS}) 88add_library(${PROJECT_NAME} SHARED ${command_SRCS})
diff --git a/common/domain/applicationdomaintype.cpp b/common/domain/applicationdomaintype.cpp
index 4bd17fe..49bfb5f 100644
--- a/common/domain/applicationdomaintype.cpp
+++ b/common/domain/applicationdomaintype.cpp
@@ -62,6 +62,7 @@ SINK_REGISTER_PROPERTY(Folder, Name);
62SINK_REGISTER_PROPERTY(Folder, Icon); 62SINK_REGISTER_PROPERTY(Folder, Icon);
63SINK_REGISTER_PROPERTY(Folder, SpecialPurpose); 63SINK_REGISTER_PROPERTY(Folder, SpecialPurpose);
64SINK_REGISTER_PROPERTY(Folder, Enabled); 64SINK_REGISTER_PROPERTY(Folder, Enabled);
65SINK_REGISTER_PROPERTY(Folder, Parent);
65 66
66static const int foo = [] { 67static const int foo = [] {
67 QMetaType::registerEqualsComparator<Reference>(); 68 QMetaType::registerEqualsComparator<Reference>();
diff --git a/common/propertyparser.cpp b/common/propertyparser.cpp
new file mode 100644
index 0000000..c638594
--- /dev/null
+++ b/common/propertyparser.cpp
@@ -0,0 +1,29 @@
1/*
2 * Copyright (C) 2017 Christian Mollekopf <chrigi_1@fastmail.fm>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) version 3, or any
8 * later version accepted by the membership of KDE e.V. (or its
9 * successor approved by the membership of KDE e.V.), which shall
10 * act as a proxy defined in Section 6 of version 3 of the license.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
19 */
20#include "propertyparser.h"
21
22#include "domain/propertyregistry.h"
23
24using namespace Sink;
25
26QVariant PropertyParser::parse(const QByteArray &type, const QByteArray &property, const QString &value)
27{
28 return Private::PropertyRegistry::instance().parse(type, property, value);
29}
diff --git a/common/propertyparser.h b/common/propertyparser.h
new file mode 100644
index 0000000..f5bda85
--- /dev/null
+++ b/common/propertyparser.h
@@ -0,0 +1,33 @@
1/*
2 * Copyright (C) 2017 Christian Mollekopf <chrigi_1@fastmail.fm>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) version 3, or any
8 * later version accepted by the membership of KDE e.V. (or its
9 * successor approved by the membership of KDE e.V.), which shall
10 * act as a proxy defined in Section 6 of version 3 of the license.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
19 */
20#pragma once
21
22#include "sink_export.h"
23#include <QVariant>
24
25namespace Sink {
26
27class SINK_EXPORT PropertyParser {
28public:
29 static QVariant parse(const QByteArray &type, const QByteArray &property, const QString &value);
30};
31
32}
33
diff --git a/sinksh/syntax_modules/sink_create.cpp b/sinksh/syntax_modules/sink_create.cpp
index 9f5d010..f18a990 100644
--- a/sinksh/syntax_modules/sink_create.cpp
+++ b/sinksh/syntax_modules/sink_create.cpp
@@ -25,12 +25,11 @@
25 25
26#include "common/resource.h" 26#include "common/resource.h"
27#include "common/storage.h" 27#include "common/storage.h"
28#include "common/domain/event.h"
29#include "common/domain/folder.h"
30#include "common/resourceconfig.h" 28#include "common/resourceconfig.h"
31#include "common/log.h" 29#include "common/log.h"
32#include "common/storage.h" 30#include "common/storage.h"
33#include "common/definitions.h" 31#include "common/definitions.h"
32#include "common/propertyparser.h"
34 33
35#include "sinksh_utils.h" 34#include "sinksh_utils.h"
36#include "state.h" 35#include "state.h"
@@ -62,7 +61,8 @@ bool create(const QStringList &allArgs, State &state)
62 61
63 auto map = SinkshUtils::keyValueMapFromArgs(args); 62 auto map = SinkshUtils::keyValueMapFromArgs(args);
64 for (auto i = map.begin(); i != map.end(); ++i) { 63 for (auto i = map.begin(); i != map.end(); ++i) {
65 object->setProperty(i.key().toLatin1(), i.value()); 64 const auto property = i.key().toLatin1();
65 object->setProperty(property, Sink::PropertyParser::parse(type.toLatin1(), property, i.value()));
66 } 66 }
67 67
68 auto result = store.create(*object).exec(); 68 auto result = store.create(*object).exec();
diff --git a/sinksh/syntax_modules/sink_list.cpp b/sinksh/syntax_modules/sink_list.cpp
index 837f60d..d63749b 100644
--- a/sinksh/syntax_modules/sink_list.cpp
+++ b/sinksh/syntax_modules/sink_list.cpp
@@ -25,13 +25,12 @@
25 25
26#include "common/resource.h" 26#include "common/resource.h"
27#include "common/storage.h" 27#include "common/storage.h"
28#include "common/domain/event.h"
29#include "common/domain/folder.h"
30#include "common/resourceconfig.h" 28#include "common/resourceconfig.h"
31#include "common/log.h" 29#include "common/log.h"
32#include "common/storage.h" 30#include "common/storage.h"
33#include "common/definitions.h" 31#include "common/definitions.h"
34#include "common/store.h" 32#include "common/store.h"
33#include "common/propertyparser.h"
35 34
36#include "sinksh_utils.h" 35#include "sinksh_utils.h"
37#include "state.h" 36#include "state.h"
@@ -109,7 +108,8 @@ bool list(const QStringList &args_, State &state)
109 if (options.options.contains("filter")) { 108 if (options.options.contains("filter")) {
110 for (const auto &f : options.options.value("filter")) { 109 for (const auto &f : options.options.value("filter")) {
111 auto filter = f.split("="); 110 auto filter = f.split("=");
112 query.filter(filter.at(0).toLatin1(), QVariant::fromValue(Sink::ApplicationDomain::Reference{filter.at(1).toLatin1()})); 111 const auto property = filter.value(0).toLatin1();
112 query.filter(property, Sink::PropertyParser::parse(type.toLatin1(), property, filter.value(1)));
113 } 113 }
114 } 114 }
115 if (options.options.contains("id")) { 115 if (options.options.contains("id")) {
diff --git a/sinksh/syntax_modules/sink_modify.cpp b/sinksh/syntax_modules/sink_modify.cpp
index 4d637d8..2579550 100644
--- a/sinksh/syntax_modules/sink_modify.cpp
+++ b/sinksh/syntax_modules/sink_modify.cpp
@@ -25,12 +25,11 @@
25 25
26#include "common/resource.h" 26#include "common/resource.h"
27#include "common/storage.h" 27#include "common/storage.h"
28#include "common/domain/event.h"
29#include "common/domain/folder.h"
30#include "common/resourceconfig.h" 28#include "common/resourceconfig.h"
31#include "common/log.h" 29#include "common/log.h"
32#include "common/storage.h" 30#include "common/storage.h"
33#include "common/definitions.h" 31#include "common/definitions.h"
32#include "common/propertyparser.h"
34 33
35#include "sinksh_utils.h" 34#include "sinksh_utils.h"
36#include "state.h" 35#include "state.h"
@@ -65,7 +64,8 @@ bool modify(const QStringList &args, State &state)
65 64
66 auto map = SinkshUtils::keyValueMapFromArgs(args); 65 auto map = SinkshUtils::keyValueMapFromArgs(args);
67 for (auto i = map.begin(); i != map.end(); ++i) { 66 for (auto i = map.begin(); i != map.end(); ++i) {
68 object->setProperty(i.key().toLatin1(), i.value()); 67 const auto property = i.key().toLatin1();
68 object->setProperty(property, Sink::PropertyParser::parse(type.toLatin1(), property, i.value()));
69 } 69 }
70 70
71 auto result = store.modify(*object).exec(); 71 auto result = store.modify(*object).exec();
@@ -91,7 +91,8 @@ bool resource(const QStringList &args, State &state)
91 91
92 auto map = SinkshUtils::keyValueMapFromArgs(args); 92 auto map = SinkshUtils::keyValueMapFromArgs(args);
93 for (auto i = map.begin(); i != map.end(); ++i) { 93 for (auto i = map.begin(); i != map.end(); ++i) {
94 object->setProperty(i.key().toLatin1(), i.value()); 94 const auto property = i.key().toLatin1();
95 object->setProperty(property, Sink::PropertyParser::parse("resource", property, i.value()));
95 } 96 }
96 97
97 auto result = store.modify(*object).exec(); 98 auto result = store.modify(*object).exec();