diff options
-rw-r--r-- | common/clientapi.cpp | 13 | ||||
-rw-r--r-- | common/clientapi.h | 5 | ||||
-rw-r--r-- | examples/client/main.cpp | 5 |
3 files changed, 20 insertions, 3 deletions
diff --git a/common/clientapi.cpp b/common/clientapi.cpp index 255ea21..061d920 100644 --- a/common/clientapi.cpp +++ b/common/clientapi.cpp | |||
@@ -24,17 +24,18 @@ | |||
24 | #include <QTimer> | 24 | #include <QTimer> |
25 | #include <QEventLoop> | 25 | #include <QEventLoop> |
26 | #include <QAbstractItemModel> | 26 | #include <QAbstractItemModel> |
27 | #include <QDir> | ||
27 | #include <functional> | 28 | #include <functional> |
28 | #include <memory> | 29 | #include <memory> |
29 | 30 | ||
30 | #include "resourceaccess.h" | 31 | #include "resourceaccess.h" |
31 | #include "commands.h" | 32 | #include "commands.h" |
32 | #include "resourcefacade.h" | 33 | #include "resourcefacade.h" |
33 | #include "log.h" | ||
34 | #include "definitions.h" | 34 | #include "definitions.h" |
35 | #include "resourceconfig.h" | 35 | #include "resourceconfig.h" |
36 | #include "facadefactory.h" | 36 | #include "facadefactory.h" |
37 | #include "modelresult.h" | 37 | #include "modelresult.h" |
38 | #include "storage.h" | ||
38 | #include "log.h" | 39 | #include "log.h" |
39 | 40 | ||
40 | namespace Akonadi2 | 41 | namespace Akonadi2 |
@@ -178,6 +179,16 @@ KAsync::Job<void> Store::start(const QByteArray &identifier) | |||
178 | }); | 179 | }); |
179 | } | 180 | } |
180 | 181 | ||
182 | void Store::removeFromDisk(const QByteArray &identifier) | ||
183 | { | ||
184 | //TODO By calling the resource executable with a --remove option instead | ||
185 | //we can ensure that no other resource process is running at the same time | ||
186 | QDir dir(Akonadi2::storageLocation()); | ||
187 | for (const auto &folder : dir.entryList(QStringList() << identifier + "*")) { | ||
188 | Akonadi2::Storage(Akonadi2::storageLocation(), folder, Akonadi2::Storage::ReadWrite).removeFromDisk(); | ||
189 | } | ||
190 | } | ||
191 | |||
181 | KAsync::Job<void> Store::synchronize(const Akonadi2::Query &query) | 192 | KAsync::Job<void> Store::synchronize(const Akonadi2::Query &query) |
182 | { | 193 | { |
183 | Trace() << "synchronize"; | 194 | Trace() << "synchronize"; |
diff --git a/common/clientapi.h b/common/clientapi.h index 074aabc..3d9095d 100644 --- a/common/clientapi.h +++ b/common/clientapi.h | |||
@@ -93,6 +93,11 @@ public: | |||
93 | * Synchronize data to local cache. | 93 | * Synchronize data to local cache. |
94 | */ | 94 | */ |
95 | static KAsync::Job<void> synchronize(const Akonadi2::Query &query); | 95 | static KAsync::Job<void> synchronize(const Akonadi2::Query &query); |
96 | |||
97 | /** | ||
98 | * Removes a resource from disk. | ||
99 | */ | ||
100 | static void removeFromDisk(const QByteArray &resourceIdentifier); | ||
96 | }; | 101 | }; |
97 | 102 | ||
98 | 103 | ||
diff --git a/examples/client/main.cpp b/examples/client/main.cpp index e0d9078..59ff9d9 100644 --- a/examples/client/main.cpp +++ b/examples/client/main.cpp | |||
@@ -29,6 +29,8 @@ | |||
29 | #include "common/domain/folder.h" | 29 | #include "common/domain/folder.h" |
30 | #include "common/resourceconfig.h" | 30 | #include "common/resourceconfig.h" |
31 | #include "common/log.h" | 31 | #include "common/log.h" |
32 | #include "common/storage.h" | ||
33 | #include "common/definitions.h" | ||
32 | #include "console.h" | 34 | #include "console.h" |
33 | 35 | ||
34 | #include <QWidget> | 36 | #include <QWidget> |
@@ -153,8 +155,7 @@ int main(int argc, char *argv[]) | |||
153 | if (cliOptions.isSet("clear")) { | 155 | if (cliOptions.isSet("clear")) { |
154 | qDebug() << "Clearing"; | 156 | qDebug() << "Clearing"; |
155 | for (const auto &resource : resources) { | 157 | for (const auto &resource : resources) { |
156 | Akonadi2::Storage store(Akonadi2::Store::storageLocation(), resource, Akonadi2::Storage::ReadWrite); | 158 | Akonadi2::Store::removeFromDisk(resource.toLatin1()); |
157 | store.removeFromDisk(); | ||
158 | } | 159 | } |
159 | return 0; | 160 | return 0; |
160 | } | 161 | } |