summaryrefslogtreecommitdiffstats
path: root/examples/maildirresource
diff options
context:
space:
mode:
Diffstat (limited to 'examples/maildirresource')
-rw-r--r--examples/maildirresource/CMakeLists.txt5
-rw-r--r--examples/maildirresource/domainadaptor.cpp35
-rw-r--r--examples/maildirresource/domainadaptor.h38
-rw-r--r--examples/maildirresource/libmaildir/CMakeLists.txt8
-rw-r--r--examples/maildirresource/libmaildir/maildir.cpp2
-rw-r--r--examples/maildirresource/libmaildir/maildir.h6
-rw-r--r--examples/maildirresource/libmaildir/maildir_export.h43
-rw-r--r--examples/maildirresource/maildirresource.cpp14
8 files changed, 12 insertions, 139 deletions
diff --git a/examples/maildirresource/CMakeLists.txt b/examples/maildirresource/CMakeLists.txt
index e4d113c..a8f0359 100644
--- a/examples/maildirresource/CMakeLists.txt
+++ b/examples/maildirresource/CMakeLists.txt
@@ -5,13 +5,12 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
5 5
6find_package(KF5 COMPONENTS REQUIRED Mime) 6find_package(KF5 COMPONENTS REQUIRED Mime)
7 7
8add_library(${PROJECT_NAME} SHARED facade.cpp maildirresource.cpp domainadaptor.cpp) 8add_library(${PROJECT_NAME} SHARED facade.cpp maildirresource.cpp libmaildir/maildir.cpp libmaildir/keycache.cpp)
9qt5_use_modules(${PROJECT_NAME} Core Network) 9qt5_use_modules(${PROJECT_NAME} Core Network)
10target_link_libraries(${PROJECT_NAME} sink maildir KF5::Mime) 10target_link_libraries(${PROJECT_NAME} sink KF5::Mime)
11 11
12install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${SINK_RESOURCE_PLUGINS_PATH}) 12install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${SINK_RESOURCE_PLUGINS_PATH})
13 13
14add_definitions(-DTESTDATAPATH="${CMAKE_CURRENT_SOURCE_DIR}/tests/data") 14add_definitions(-DTESTDATAPATH="${CMAKE_CURRENT_SOURCE_DIR}/tests/data")
15 15
16add_subdirectory(libmaildir)
17add_subdirectory(tests) 16add_subdirectory(tests)
diff --git a/examples/maildirresource/domainadaptor.cpp b/examples/maildirresource/domainadaptor.cpp
deleted file mode 100644
index 71b2354..0000000
--- a/examples/maildirresource/domainadaptor.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
1/*
2 * Copyright (C) 2015 Christian Mollekopf <chrigi_1@fastmail.fm>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20#include "domainadaptor.h"
21
22using namespace flatbuffers;
23
24MaildirMailAdaptorFactory::MaildirMailAdaptorFactory()
25 : DomainTypeAdaptorFactory()
26{
27
28}
29
30MaildirFolderAdaptorFactory::MaildirFolderAdaptorFactory()
31 : DomainTypeAdaptorFactory()
32{
33
34}
35
diff --git a/examples/maildirresource/domainadaptor.h b/examples/maildirresource/domainadaptor.h
deleted file mode 100644
index 700d2e5..0000000
--- a/examples/maildirresource/domainadaptor.h
+++ /dev/null
@@ -1,38 +0,0 @@
1/*
2 * Copyright (C) 2015 Christian Mollekopf <chrigi_1@fastmail.fm>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19#pragma once
20
21#include <common/domainadaptor.h>
22#include "mail_generated.h"
23#include "folder_generated.h"
24#include "dummy_generated.h"
25
26class MaildirMailAdaptorFactory : public DomainTypeAdaptorFactory<Sink::ApplicationDomain::Mail, Sink::ApplicationDomain::Buffer::Dummy, Sink::ApplicationDomain::Buffer::DummyBuilder>
27{
28public:
29 MaildirMailAdaptorFactory();
30 virtual ~MaildirMailAdaptorFactory() {};
31};
32
33class MaildirFolderAdaptorFactory : public DomainTypeAdaptorFactory<Sink::ApplicationDomain::Folder, Sink::ApplicationDomain::Buffer::Dummy, Sink::ApplicationDomain::Buffer::DummyBuilder>
34{
35public:
36 MaildirFolderAdaptorFactory();
37 virtual ~MaildirFolderAdaptorFactory() {};
38};
diff --git a/examples/maildirresource/libmaildir/CMakeLists.txt b/examples/maildirresource/libmaildir/CMakeLists.txt
deleted file mode 100644
index e7803f5..0000000
--- a/examples/maildirresource/libmaildir/CMakeLists.txt
+++ /dev/null
@@ -1,8 +0,0 @@
1# add_subdirectory( tests )
2
3set(maildir_LIB_SRCS keycache.cpp maildir.cpp)
4
5add_library(maildir ${LIBRARY_TYPE} ${maildir_LIB_SRCS})
6qt5_use_modules(maildir Core Network)
7# set_target_properties(maildir PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} )
8install(TARGETS maildir ${INSTALL_TARGETS_DEFAULT_ARGS})
diff --git a/examples/maildirresource/libmaildir/maildir.cpp b/examples/maildirresource/libmaildir/maildir.cpp
index a889ea2..203f6a6 100644
--- a/examples/maildirresource/libmaildir/maildir.cpp
+++ b/examples/maildirresource/libmaildir/maildir.cpp
@@ -1,5 +1,6 @@
1/* 1/*
2 Copyright (c) 2007 Till Adam <adam@kde.org> 2 Copyright (c) 2007 Till Adam <adam@kde.org>
3 Copyright (c) 2017 Christian Mollekopf <mollekopf@kolabsys.com>
3 4
4 This library is free software; you can redistribute it and/or modify it 5 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 under the terms of the GNU Library General Public License as published by
@@ -24,7 +25,6 @@
24#include <QDirIterator> 25#include <QDirIterator>
25#include <QFileInfo> 26#include <QFileInfo>
26#include <QHostInfo> 27#include <QHostInfo>
27#include <QUuid>
28#include <QLoggingCategory> 28#include <QLoggingCategory>
29 29
30Q_LOGGING_CATEGORY(log, "maildir"); 30Q_LOGGING_CATEGORY(log, "maildir");
diff --git a/examples/maildirresource/libmaildir/maildir.h b/examples/maildirresource/libmaildir/maildir.h
index c10b046..a72f2bc 100644
--- a/examples/maildirresource/libmaildir/maildir.h
+++ b/examples/maildirresource/libmaildir/maildir.h
@@ -1,5 +1,6 @@
1/* 1/*
2 Copyright (c) 2007 Till Adam <adam@kde.org> 2 Copyright (c) 2007 Till Adam <adam@kde.org>
3 Copyright (c) 2017 Christian Mollekopf <mollekopf@kolabsys.com>
3 4
4 This library is free software; you can redistribute it and/or modify it 5 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 under the terms of the GNU Library General Public License as published by
@@ -20,9 +21,6 @@
20#ifndef MAILDIR_H 21#ifndef MAILDIR_H
21#define MAILDIR_H 22#define MAILDIR_H
22 23
23
24#include "maildir_export.h"
25
26#include <QString> 24#include <QString>
27#include <QStringList> 25#include <QStringList>
28 26
@@ -30,7 +28,7 @@ class QDateTime;
30 28
31namespace KPIM { 29namespace KPIM {
32 30
33class MAILDIR_EXPORT Maildir 31class Maildir
34{ 32{
35public: 33public:
36 /** 34 /**
diff --git a/examples/maildirresource/libmaildir/maildir_export.h b/examples/maildirresource/libmaildir/maildir_export.h
deleted file mode 100644
index b330fd0..0000000
--- a/examples/maildirresource/libmaildir/maildir_export.h
+++ /dev/null
@@ -1,43 +0,0 @@
1/* This file is part of the KDE project
2 Copyright (C) 2007 David Faure <faure@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public 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
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20#ifndef MAILDIR_EXPORT_H
21#define MAILDIR_EXPORT_H
22
23/* needed for KDE_EXPORT and KDE_IMPORT macros */
24// #include <kdemacros.h>
25
26#ifndef MAILDIR_EXPORT
27// # if defined(KDEPIM_STATIC_LIBS)
28// #<{(| No export/import for static libraries |)}>#
29# define MAILDIR_EXPORT
30// # elif defined(MAKE_MAILDIR_LIB)
31// #<{(| We are building this library |)}>#
32// # define MAILDIR_EXPORT KDE_EXPORT
33// # else
34// #<{(| We are using this library |)}>#
35// # define MAILDIR_EXPORT KDE_IMPORT
36// # endif
37#endif
38//
39// # ifndef MAILDIR_EXPORT_DEPRECATED
40// # define MAILDIR_EXPORT_DEPRECATED KDE_DEPRECATED MAILDIR_EXPORT
41// # endif
42
43#endif
diff --git a/examples/maildirresource/maildirresource.cpp b/examples/maildirresource/maildirresource.cpp
index 813d84f..40bab37 100644
--- a/examples/maildirresource/maildirresource.cpp
+++ b/examples/maildirresource/maildirresource.cpp
@@ -37,7 +37,7 @@
37 37
38#include <QDir> 38#include <QDir>
39#include <QDirIterator> 39#include <QDirIterator>
40#include <KMime/KMime/KMimeMessage> 40#include <KMime/KMimeMessage>
41 41
42//This is the resources entity type, and not the domain type 42//This is the resources entity type, and not the domain type
43#define ENTITY_TYPE_MAIL "mail" 43#define ENTITY_TYPE_MAIL "mail"
@@ -360,12 +360,12 @@ public:
360 360
361 KAsync::Job<void> synchronizeWithSource(const Sink::QueryBase &query) Q_DECL_OVERRIDE 361 KAsync::Job<void> synchronizeWithSource(const Sink::QueryBase &query) Q_DECL_OVERRIDE
362 { 362 {
363 auto job = KAsync::start<void>([this] { 363 auto job = KAsync::start([this] {
364 KPIM::Maildir maildir(mMaildirPath, true); 364 KPIM::Maildir maildir(mMaildirPath, true);
365 if (!maildir.isValid(false)) { 365 if (!maildir.isValid(false)) {
366 return KAsync::error<void>(1, "Maildir path doesn't point to a valid maildir: " + mMaildirPath); 366 return KAsync::error(ApplicationDomain::ConfigurationError, "Maildir path doesn't point to a valid maildir: " + mMaildirPath);
367 } 367 }
368 return KAsync::null<void>(); 368 return KAsync::null();
369 }); 369 });
370 370
371 if (query.type() == ApplicationDomain::getTypeName<ApplicationDomain::Folder>()) { 371 if (query.type() == ApplicationDomain::getTypeName<ApplicationDomain::Folder>()) {
@@ -551,7 +551,7 @@ MaildirResource::MaildirResource(const Sink::ResourceContext &resourceContext)
551 setupSynchronizer(synchronizer); 551 setupSynchronizer(synchronizer);
552 setupInspector(QSharedPointer<MaildirInspector>::create(resourceContext)); 552 setupInspector(QSharedPointer<MaildirInspector>::create(resourceContext));
553 553
554 setupPreprocessors(ENTITY_TYPE_MAIL, QVector<Sink::Preprocessor*>() << new SpecialPurposeProcessor(resourceContext.resourceType, resourceContext.instanceId()) << new MaildirMimeMessageMover(resourceContext.instanceId(), mMaildirPath) << new MaildirMailPropertyExtractor); 554 setupPreprocessors(ENTITY_TYPE_MAIL, QVector<Sink::Preprocessor*>() << new SpecialPurposeProcessor << new MaildirMimeMessageMover(resourceContext.instanceId(), mMaildirPath) << new MaildirMailPropertyExtractor);
555 setupPreprocessors(ENTITY_TYPE_FOLDER, QVector<Sink::Preprocessor*>() << new FolderPreprocessor(mMaildirPath)); 555 setupPreprocessors(ENTITY_TYPE_FOLDER, QVector<Sink::Preprocessor*>() << new FolderPreprocessor(mMaildirPath));
556 556
557 KPIM::Maildir dir(mMaildirPath, true); 557 KPIM::Maildir dir(mMaildirPath, true);
@@ -596,8 +596,8 @@ void MaildirResourceFactory::registerFacades(const QByteArray &name, Sink::Facad
596 596
597void MaildirResourceFactory::registerAdaptorFactories(const QByteArray &name, Sink::AdaptorFactoryRegistry &registry) 597void MaildirResourceFactory::registerAdaptorFactories(const QByteArray &name, Sink::AdaptorFactoryRegistry &registry)
598{ 598{
599 registry.registerFactory<Sink::ApplicationDomain::Mail, MaildirMailAdaptorFactory>(name); 599 registry.registerFactory<ApplicationDomain::Mail, DefaultAdaptorFactory<ApplicationDomain::Mail>>(name);
600 registry.registerFactory<Sink::ApplicationDomain::Folder, MaildirFolderAdaptorFactory>(name); 600 registry.registerFactory<ApplicationDomain::Folder, DefaultAdaptorFactory<ApplicationDomain::Folder>>(name);
601} 601}
602 602
603void MaildirResourceFactory::removeDataFromDisk(const QByteArray &instanceIdentifier) 603void MaildirResourceFactory::removeDataFromDisk(const QByteArray &instanceIdentifier)