[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [sink/develop] /: Use specialpurpose preprocessor which gives us trash folder support.
From: Christian Mollekopf <chrigi_1 () fastmail ! fm>
Date: 2016-06-30 19:49:32
Message-ID: E1bIhxs-0005c3-RB () code ! kde ! org
[Download RAW message or body]
Git commit c354798305f79805ca208951ba1ea8f43f7fe717 by Christian Mollekopf.
Committed on 26/06/2016 at 08:44.
Pushed by cmollekopf into branch 'develop'.
Use specialpurpose preprocessor which gives us trash folder support.
M +1 -1 common/domain/applicationdomaintype.cpp
M +8 -21 examples/maildirresource/maildirresource.cpp
http://commits.kde.org/akonadi-next/c354798305f79805ca208951ba1ea8f43f7fe717
diff --git a/common/domain/applicationdomaintype.cpp \
b/common/domain/applicationdomaintype.cpp index df63c35..d1faf25 100644
--- a/common/domain/applicationdomaintype.cpp
+++ b/common/domain/applicationdomaintype.cpp
@@ -253,7 +253,7 @@ namespace MaildirResource {
auto &&resource = ApplicationDomainType::createEntity<SinkResource>();
resource.setProperty("type", "org.kde.maildir");
resource.setProperty("account", account);
- resource.setProperty("capabilities", QVariant::fromValue(QByteArrayList() << \
ResourceCapabilities::Mail::storage << ResourceCapabilities::Mail::drafts << \
"-folder.rename")); + resource.setProperty("capabilities", \
QVariant::fromValue(QByteArrayList() << ResourceCapabilities::Mail::storage << \
ResourceCapabilities::Mail::drafts << "-folder.rename" << \
ResourceCapabilities::Mail::trash)); return resource;
}
}
diff --git a/examples/maildirresource/maildirresource.cpp \
b/examples/maildirresource/maildirresource.cpp index ea780cc..92cfceb 100644
--- a/examples/maildirresource/maildirresource.cpp
+++ b/examples/maildirresource/maildirresource.cpp
@@ -39,6 +39,7 @@
#include "synchronizer.h"
#include "sourcewriteback.h"
#include "adaptorfactoryregistry.h"
+#include "specialpurposepreprocessor.h"
#include <QDate>
#include <QUuid>
#include <QDir>
@@ -105,10 +106,10 @@ public:
}
};
-class FolderUpdater : public Sink::Preprocessor
+class MaildirMimeMessageMover : public Sink::Preprocessor
{
public:
- FolderUpdater(const QByteArray &drafts) : mDraftsFolder(drafts) {}
+ MaildirMimeMessageMover(const QByteArray &resourceInstanceIdentifier, const \
QString &maildirPath) : mResourceInstanceIdentifier(resourceInstanceIdentifier), \
mMaildirPath(maildirPath) {}
QString getPath(const QByteArray &folderIdentifier, Sink::Storage::Transaction \
&transaction) {
@@ -168,9 +169,6 @@ public:
void newEntity(const QByteArray &uid, qint64 revision, \
Sink::ApplicationDomain::BufferAdaptor &newEntity, Sink::Storage::Transaction \
&transaction) Q_DECL_OVERRIDE {
- if (newEntity.getProperty("draft").toBool()) {
- newEntity.setProperty("folder", mDraftsFolder);
- }
const auto mimeMessage = newEntity.getProperty("mimeMessage");
if (mimeMessage.isValid()) {
newEntity.setProperty("mimeMessage", moveMessage(mimeMessage.toString(), \
newEntity.getProperty("folder").toByteArray(), transaction)); @@ -180,9 +178,6 @@ \
public: void modifiedEntity(const QByteArray &uid, qint64 revision, const \
Sink::ApplicationDomain::BufferAdaptor &oldEntity, \
Sink::ApplicationDomain::BufferAdaptor &newEntity, Sink::Storage::Transaction \
&transaction) Q_DECL_OVERRIDE {
- if (newEntity.getProperty("draft").toBool()) {
- newEntity.setProperty("folder", mDraftsFolder);
- }
const auto mimeMessage = newEntity.getProperty("mimeMessage");
const auto newFolder = newEntity.getProperty("folder");
const bool mimeMessageChanged = mimeMessage.isValid() && \
mimeMessage.toString() != oldEntity.getProperty("mimeMessage").toString(); @@ -221,7 \
+216,6 @@ public:
const auto filePath = \
getFilePathFromMimeMessagePath(oldEntity.getProperty("mimeMessage").toString()); \
QFile::remove(filePath); }
- QByteArray mDraftsFolder;
QByteArray mResourceInstanceIdentifier;
QString mMaildirPath;
};
@@ -229,7 +223,7 @@ public:
class FolderPreprocessor : public Sink::Preprocessor
{
public:
- FolderPreprocessor() {}
+ FolderPreprocessor(const QString maildirPath) : mMaildirPath(maildirPath) {}
void newEntity(const QByteArray &uid, qint64 revision, \
Sink::ApplicationDomain::BufferAdaptor &newEntity, Sink::Storage::Transaction \
&transaction) Q_DECL_OVERRIDE {
@@ -499,23 +493,16 @@ MaildirResource::MaildirResource(const QByteArray \
&instanceIdentifier, const QSh changereplay->mMaildirPath = mMaildirPath;
setupChangereplay(changereplay);
- auto folderUpdater = new FolderUpdater(QByteArray());
- setupPreprocessors(ENTITY_TYPE_MAIL, QVector<Sink::Preprocessor*>() << \
folderUpdater << new MaildirMailPropertyExtractor << new \
DefaultIndexUpdater<Sink::ApplicationDomain::Mail>);
- auto folderPreprocessor = new FolderPreprocessor;
- setupPreprocessors(ENTITY_TYPE_FOLDER, QVector<Sink::Preprocessor*>() << \
folderPreprocessor << new DefaultIndexUpdater<Sink::ApplicationDomain::Folder>); + \
setupPreprocessors(ENTITY_TYPE_MAIL, QVector<Sink::Preprocessor*>() << new \
SpecialPurposeProcessor(mResourceType, mResourceInstanceIdentifier) << new \
MaildirMimeMessageMover(mResourceInstanceIdentifier, mMaildirPath) << new \
MaildirMailPropertyExtractor << new \
DefaultIndexUpdater<Sink::ApplicationDomain::Mail>); + \
setupPreprocessors(ENTITY_TYPE_FOLDER, QVector<Sink::Preprocessor*>() << new \
FolderPreprocessor(mMaildirPath) << new \
DefaultIndexUpdater<Sink::ApplicationDomain::Folder>);
KPIM::Maildir dir(mMaildirPath, true);
Trace() << "Started maildir resource for maildir: " << mMaildirPath;
- mDraftsFolder = dir.addSubFolder("Drafts");
+ auto draftsFolder = dir.addSubFolder("Drafts");
- auto remoteId = synchronizer->createFolder(mDraftsFolder, "folder", \
QByteArrayList() << "drafts"); + auto remoteId = \
synchronizer->createFolder(draftsFolder, "folder", QByteArrayList() \
<< "drafts");
auto draftsFolderLocalId = \
synchronizer->syncStore().resolveRemoteId(ENTITY_TYPE_FOLDER, remoteId); \
synchronizer->commit();
-
- folderUpdater->mDraftsFolder = draftsFolderLocalId;
- folderUpdater->mResourceInstanceIdentifier = mResourceInstanceIdentifier;
- folderUpdater->mMaildirPath = mMaildirPath;
- folderPreprocessor->mMaildirPath = mMaildirPath;
}
void MaildirResource::removeFromDisk(const QByteArray &instanceIdentifier)
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic