diff options
Diffstat (limited to 'common/clientapi.h')
-rw-r--r-- | common/clientapi.h | 140 |
1 files changed, 0 insertions, 140 deletions
diff --git a/common/clientapi.h b/common/clientapi.h deleted file mode 100644 index 64c4f64..0000000 --- a/common/clientapi.h +++ /dev/null | |||
@@ -1,140 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014 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 | |||
21 | #pragma once | ||
22 | |||
23 | #include <QString> | ||
24 | #include <QSharedPointer> | ||
25 | |||
26 | #include <Async/Async> | ||
27 | |||
28 | #include "query.h" | ||
29 | #include "inspection.h" | ||
30 | #include "applicationdomaintype.h" | ||
31 | |||
32 | class QAbstractItemModel; | ||
33 | |||
34 | namespace Sink { | ||
35 | class ResourceAccess; | ||
36 | class Notification; | ||
37 | |||
38 | /** | ||
39 | * Store interface used in the client API. | ||
40 | */ | ||
41 | class Store { | ||
42 | public: | ||
43 | static QString storageLocation(); | ||
44 | static QByteArray resourceName(const QByteArray &instanceIdentifier); | ||
45 | |||
46 | enum Roles { | ||
47 | DomainObjectRole = Qt::UserRole + 1, //Must be the same as in ModelResult | ||
48 | ChildrenFetchedRole, | ||
49 | DomainObjectBaseRole | ||
50 | }; | ||
51 | |||
52 | /** | ||
53 | * Asynchronusly load a dataset with tree structure information | ||
54 | */ | ||
55 | template <class DomainType> | ||
56 | static QSharedPointer<QAbstractItemModel> loadModel(Query query); | ||
57 | |||
58 | /** | ||
59 | * Create a new entity. | ||
60 | */ | ||
61 | template <class DomainType> | ||
62 | static KAsync::Job<void> create(const DomainType &domainObject); | ||
63 | |||
64 | /** | ||
65 | * Modify an entity. | ||
66 | * | ||
67 | * This includes moving etc. since these are also simple settings on a property. | ||
68 | */ | ||
69 | template <class DomainType> | ||
70 | static KAsync::Job<void> modify(const DomainType &domainObject); | ||
71 | |||
72 | /** | ||
73 | * Remove an entity. | ||
74 | */ | ||
75 | template <class DomainType> | ||
76 | static KAsync::Job<void> remove(const DomainType &domainObject); | ||
77 | |||
78 | /** | ||
79 | * Synchronize data to local cache. | ||
80 | */ | ||
81 | static KAsync::Job<void> synchronize(const Sink::Query &query); | ||
82 | |||
83 | /** | ||
84 | * Shutdown resource. | ||
85 | */ | ||
86 | static KAsync::Job<void> shutdown(const QByteArray &resourceIdentifier); | ||
87 | |||
88 | /** | ||
89 | * Start resource. | ||
90 | * | ||
91 | * The resource is ready for operation once this command completes. | ||
92 | * This command is only necessary if a resource was shutdown previously, | ||
93 | * otherwise the resource process will automatically start as necessary. | ||
94 | */ | ||
95 | static KAsync::Job<void> start(const QByteArray &resourceIdentifier); | ||
96 | |||
97 | /** | ||
98 | * Flushes any pending messages to disk | ||
99 | */ | ||
100 | static KAsync::Job<void> flushMessageQueue(const QByteArrayList &resourceIdentifier); | ||
101 | |||
102 | /** | ||
103 | * Flushes any pending messages that haven't been replayed to the source. | ||
104 | */ | ||
105 | static KAsync::Job<void> flushReplayQueue(const QByteArrayList &resourceIdentifier); | ||
106 | |||
107 | /** | ||
108 | * Removes a resource from disk. | ||
109 | */ | ||
110 | static void removeFromDisk(const QByteArray &resourceIdentifier); | ||
111 | |||
112 | template <class DomainType> | ||
113 | static KAsync::Job<DomainType> fetchOne(const Sink::Query &query); | ||
114 | |||
115 | template <class DomainType> | ||
116 | static KAsync::Job<QList<typename DomainType::Ptr> > fetchAll(const Sink::Query &query); | ||
117 | |||
118 | template <class DomainType> | ||
119 | static KAsync::Job<QList<typename DomainType::Ptr> > fetch(const Sink::Query &query, int minimumAmount = 0); | ||
120 | }; | ||
121 | |||
122 | namespace Resources { | ||
123 | template <class DomainType> | ||
124 | KAsync::Job<void> inspect(const Inspection &inspectionCommand); | ||
125 | } | ||
126 | |||
127 | class Notifier { | ||
128 | public: | ||
129 | Notifier(const QSharedPointer<ResourceAccess> &resourceAccess); | ||
130 | // Notifier(const QByteArray &resource); | ||
131 | // Notifier(const QByteArrayList &resource); | ||
132 | void registerHandler(std::function<void(const Notification &)>); | ||
133 | |||
134 | private: | ||
135 | class Private; | ||
136 | QScopedPointer<Private> d; | ||
137 | }; | ||
138 | |||
139 | } | ||
140 | |||