summaryrefslogtreecommitdiffstats
path: root/framework/src/domain
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-04-24 21:56:13 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-04-24 21:56:13 +0200
commit100f409967cd5c17567e401826a0773c7e848ff3 (patch)
tree64114fa1a8db36febe5448d5d199b3e9c8fc294f /framework/src/domain
parentb3223155b178427354b44f05167d0afba0926cbd (diff)
downloadkube-100f409967cd5c17567e401826a0773c7e848ff3.tar.gz
kube-100f409967cd5c17567e401826a0773c7e848ff3.zip
Dropped the now unused action framework
Diffstat (limited to 'framework/src/domain')
-rw-r--r--framework/src/domain/actions/sinkactions.cpp56
-rw-r--r--framework/src/domain/actions/tests/CMakeLists.txt6
-rw-r--r--framework/src/domain/actions/tests/sinkactiontest.cpp58
3 files changed, 0 insertions, 120 deletions
diff --git a/framework/src/domain/actions/sinkactions.cpp b/framework/src/domain/actions/sinkactions.cpp
deleted file mode 100644
index 460cb6a1..00000000
--- a/framework/src/domain/actions/sinkactions.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
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
20#include <actions/actionhandler.h>
21
22#include <KMime/Message>
23#include <QFile>
24
25#include <sink/store.h>
26#include <sink/log.h>
27
28SINK_DEBUG_AREA("sinkactions")
29
30using namespace Kube;
31using namespace Sink;
32using namespace Sink::ApplicationDomain;
33
34class FolderContext : public Kube::ContextWrapper {
35 using Kube::ContextWrapper::ContextWrapper;
36 KUBE_CONTEXTWRAPPER_PROPERTY(Sink::ApplicationDomain::Folder::Ptr, Folder, folder)
37};
38
39static ActionHandlerHelper synchronizeHandler("org.kde.kube.actions.synchronize",
40 [](Context *context) -> bool {
41 return true;
42 },
43 [](Context *context_) {
44 auto context = FolderContext{*context_};
45 if (auto folder = context.getFolder()) {
46 SinkLog() << "Synchronizing folder " << folder->resourceInstanceIdentifier() << folder->identifier();
47 auto scope = SyncScope().resourceFilter(folder->resourceInstanceIdentifier()).filter<Mail::Folder>(QVariant::fromValue(folder->identifier()));
48 scope.setType<ApplicationDomain::Mail>();
49 Store::synchronize(scope).exec();
50 } else {
51 SinkLog() << "Synchronizing all";
52 Store::synchronize(SyncScope()).exec();
53 }
54 }
55);
56
diff --git a/framework/src/domain/actions/tests/CMakeLists.txt b/framework/src/domain/actions/tests/CMakeLists.txt
deleted file mode 100644
index 2c34d628..00000000
--- a/framework/src/domain/actions/tests/CMakeLists.txt
+++ /dev/null
@@ -1,6 +0,0 @@
1include_directories(${CMAKE_CURRENT_BINARY_DIR})
2cmake_policy(SET CMP0063 NEW)
3add_executable(sinkactiontest sinkactiontest.cpp)
4add_test(sinkactiontest sinkactiontest)
5qt5_use_modules(sinkactiontest Core Test Concurrent)
6target_link_libraries(sinkactiontest sink frameworkplugin KF5::Mime)
diff --git a/framework/src/domain/actions/tests/sinkactiontest.cpp b/framework/src/domain/actions/tests/sinkactiontest.cpp
deleted file mode 100644
index 79375503..00000000
--- a/framework/src/domain/actions/tests/sinkactiontest.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
1#include <QTest>
2#include <QDebug>
3#include <QSignalSpy>
4#include <sink/test.h>
5#include <sink/store.h>
6#include <sink/log.h>
7#include <KMime/Message>
8
9#include <actions/action.h>
10#include <actions/context.h>
11
12using namespace Sink;
13
14class SinkActionTest : public QObject
15{
16 Q_OBJECT
17private slots:
18
19 void initTestCase()
20 {
21 Sink::Test::initTest();
22 Sink::Log::setDebugOutputLevel(Sink::Log::Trace);
23 }
24
25 void testSaveAsDraftFail()
26 {
27 Kube::Context context;
28 auto future = Kube::Action("org.kde.kube.actions.save-as-draft", context).executeWithResult();
29
30 QTRY_VERIFY(future.isDone());
31 //because of empty context
32 QVERIFY(future.error());
33 }
34
35 void testSaveAsDraftNew()
36 {
37 auto message = KMime::Message::Ptr::create();
38 message->subject(true)->fromUnicodeString(QString::fromLatin1("Foobar"), "utf8");
39 message->assemble();
40
41 auto &&account = Test::TestAccount::registerAccount();
42
43 Kube::Context context;
44 context.setProperty("message", QVariant::fromValue(message));
45 context.setProperty("accountId", QVariant::fromValue(account.identifier));
46 auto future = Kube::Action("org.kde.kube.actions.save-as-draft", context).executeWithResult();
47
48 QTRY_VERIFY(future.isDone());
49 QVERIFY(!future.error());
50 auto mails = account.entities<Sink::ApplicationDomain::Mail>();
51 QCOMPARE(mails.size(), 1);
52 auto mail = mails.first();
53 QVERIFY(mail->getProperty("draft").toBool());
54 }
55};
56
57QTEST_GUILESS_MAIN(SinkActionTest)
58#include "sinkactiontest.moc"