diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-01-02 00:19:01 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-01-02 00:31:49 +0100 |
commit | 1ef70a4c8c2bb9fd70d5bc73614b09177b6b970c (patch) | |
tree | 57503402891c5d02720a06b2bdebb26ba551d9d7 /framework/domain/foldercontroller.cpp | |
parent | 8cf790d6bc91e5e9c06651ffe4a193b625207f0d (diff) | |
download | kube-1ef70a4c8c2bb9fd70d5bc73614b09177b6b970c.tar.gz kube-1ef70a4c8c2bb9fd70d5bc73614b09177b6b970c.zip |
Foldercontroller
Diffstat (limited to 'framework/domain/foldercontroller.cpp')
-rw-r--r-- | framework/domain/foldercontroller.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/framework/domain/foldercontroller.cpp b/framework/domain/foldercontroller.cpp new file mode 100644 index 00000000..45fb86a6 --- /dev/null +++ b/framework/domain/foldercontroller.cpp | |||
@@ -0,0 +1,50 @@ | |||
1 | /* | ||
2 | Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com> | ||
3 | |||
4 | This library is free software; you can redistribute it and/or modify it | ||
5 | under the terms of the GNU Library General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or (at your | ||
7 | option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, but WITHOUT | ||
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public | ||
12 | License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
17 | 02110-1301, USA. | ||
18 | */ | ||
19 | #include "foldercontroller.h" | ||
20 | |||
21 | #include <sink/store.h> | ||
22 | #include <sink/log.h> | ||
23 | |||
24 | SINK_DEBUG_AREA("foldercontroller"); | ||
25 | |||
26 | FolderController::FolderController() | ||
27 | : Kube::Controller(), | ||
28 | action_synchronize{new Kube::ControllerAction} | ||
29 | { | ||
30 | QObject::connect(synchronizeAction(), &Kube::ControllerAction::triggered, this, &FolderController::synchronize); | ||
31 | } | ||
32 | |||
33 | void FolderController::synchronize() | ||
34 | { | ||
35 | using namespace Sink; | ||
36 | using namespace Sink::ApplicationDomain; | ||
37 | auto job = [&] { | ||
38 | if (auto folder = getFolder()) { | ||
39 | SinkLog() << "Synchronizing folder " << folder->resourceInstanceIdentifier() << folder->identifier(); | ||
40 | auto scope = SyncScope().resourceFilter(folder->resourceInstanceIdentifier()).filter<Mail::Folder>(QVariant::fromValue(folder->identifier())); | ||
41 | scope.setType<ApplicationDomain::Mail>(); | ||
42 | return Store::synchronize(scope); | ||
43 | } else { | ||
44 | SinkLog() << "Synchronizing all"; | ||
45 | return Store::synchronize(SyncScope()); | ||
46 | } | ||
47 | }(); | ||
48 | run(job); | ||
49 | } | ||
50 | |||