summaryrefslogtreecommitdiffstats
path: root/framework
diff options
context:
space:
mode:
Diffstat (limited to 'framework')
-rw-r--r--framework/domain/CMakeLists.txt1
-rw-r--r--framework/domain/controller.h8
-rw-r--r--framework/domain/foldercontroller.cpp50
-rw-r--r--framework/domain/foldercontroller.h33
-rw-r--r--framework/domain/mailcontroller.h7
-rw-r--r--framework/domain/mailplugin.cpp2
6 files changed, 94 insertions, 7 deletions
diff --git a/framework/domain/CMakeLists.txt b/framework/domain/CMakeLists.txt
index 8f343928..70a86d01 100644
--- a/framework/domain/CMakeLists.txt
+++ b/framework/domain/CMakeLists.txt
@@ -25,6 +25,7 @@ set(mailplugin_SRCS
25 controller.cpp 25 controller.cpp
26 outboxcontroller.cpp 26 outboxcontroller.cpp
27 mailcontroller.cpp 27 mailcontroller.cpp
28 foldercontroller.cpp
28) 29)
29find_package(KF5 REQUIRED COMPONENTS Package) 30find_package(KF5 REQUIRED COMPONENTS Package)
30 31
diff --git a/framework/domain/controller.h b/framework/domain/controller.h
index c152a588..77baa606 100644
--- a/framework/domain/controller.h
+++ b/framework/domain/controller.h
@@ -35,6 +35,14 @@
35 void clear##NAME() { setProperty(NAME::name, QVariant{}); } \ 35 void clear##NAME() { setProperty(NAME::name, QVariant{}); } \
36 TYPE get##NAME() const { return m##NAME; } \ 36 TYPE get##NAME() const { return m##NAME; } \
37 37
38
39#define KUBE_CONTROLLER_ACTION(NAME) \
40 Q_PROPERTY (Kube::ControllerAction* NAME##Action READ NAME##Action CONSTANT) \
41 private: QScopedPointer<Kube::ControllerAction> action_##NAME; \
42 public: Kube::ControllerAction* NAME##Action() const { Q_ASSERT(action_##NAME); return action_##NAME.data(); } \
43 private slots: void NAME(); \
44
45
38namespace Kube { 46namespace Kube {
39 47
40class ControllerAction : public QObject { 48class ControllerAction : public QObject {
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
24SINK_DEBUG_AREA("foldercontroller");
25
26FolderController::FolderController()
27 : Kube::Controller(),
28 action_synchronize{new Kube::ControllerAction}
29{
30 QObject::connect(synchronizeAction(), &Kube::ControllerAction::triggered, this, &FolderController::synchronize);
31}
32
33void 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
diff --git a/framework/domain/foldercontroller.h b/framework/domain/foldercontroller.h
new file mode 100644
index 00000000..24d6929c
--- /dev/null
+++ b/framework/domain/foldercontroller.h
@@ -0,0 +1,33 @@
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#pragma once
20
21#include <QObject>
22#include "controller.h"
23#include "sink/applicationdomaintype.h"
24
25class FolderController : public Kube::Controller
26{
27 Q_OBJECT
28 KUBE_CONTROLLER_PROPERTY(Sink::ApplicationDomain::Folder::Ptr, Folder, folder)
29 KUBE_CONTROLLER_ACTION(synchronize)
30
31public:
32 explicit FolderController();
33};
diff --git a/framework/domain/mailcontroller.h b/framework/domain/mailcontroller.h
index 66cb7b4b..6c41f433 100644
--- a/framework/domain/mailcontroller.h
+++ b/framework/domain/mailcontroller.h
@@ -22,13 +22,6 @@
22#include "controller.h" 22#include "controller.h"
23#include "sink/applicationdomaintype.h" 23#include "sink/applicationdomaintype.h"
24 24
25#define KUBE_CONTROLLER_ACTION(NAME) \
26 Q_PROPERTY (Kube::ControllerAction* NAME##Action READ NAME##Action CONSTANT) \
27 private: QScopedPointer<Kube::ControllerAction> action_##NAME; \
28 public: Kube::ControllerAction* NAME##Action() const { Q_ASSERT(action_##NAME); return action_##NAME.data(); } \
29 private slots: void NAME(); \
30
31
32class MailController : public Kube::Controller 25class MailController : public Kube::Controller
33{ 26{
34 Q_OBJECT 27 Q_OBJECT
diff --git a/framework/domain/mailplugin.cpp b/framework/domain/mailplugin.cpp
index eeb1aeb1..e63f3ad1 100644
--- a/framework/domain/mailplugin.cpp
+++ b/framework/domain/mailplugin.cpp
@@ -31,6 +31,7 @@
31#include "outboxmodel.h" 31#include "outboxmodel.h"
32#include "outboxcontroller.h" 32#include "outboxcontroller.h"
33#include "mailcontroller.h" 33#include "mailcontroller.h"
34#include "foldercontroller.h"
34 35
35#include <QtQml> 36#include <QtQml>
36 37
@@ -49,4 +50,5 @@ void MailPlugin::registerTypes (const char *uri)
49 qmlRegisterType<OutboxController>(uri, 1, 0, "OutboxController"); 50 qmlRegisterType<OutboxController>(uri, 1, 0, "OutboxController");
50 qmlRegisterType<OutboxModel>(uri, 1, 0, "OutboxModel"); 51 qmlRegisterType<OutboxModel>(uri, 1, 0, "OutboxModel");
51 qmlRegisterType<MailController>(uri, 1, 0, "MailController"); 52 qmlRegisterType<MailController>(uri, 1, 0, "MailController");
53 qmlRegisterType<FolderController>(uri, 1, 0, "FolderController");
52} 54}