[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [sink/develop] /: Reuse mailpreprocessor
From: Christian Mollekopf <chrigi_1 () fastmail ! fm>
Date: 2016-06-30 19:49:33
Message-ID: E1bIhxt-0005c3-0D () code ! kde ! org
[Download RAW message or body]
Git commit cf487248df311bd055844ce44786e28ea5aa7c2c by Christian Mollekopf.
Committed on 26/06/2016 at 11:21.
Pushed by cmollekopf into branch 'develop'.
Reuse mailpreprocessor
M +6 -1 common/mailpreprocessor.cpp
M +3 -0 common/mailpreprocessor.h
M +5 -30 examples/maildirresource/maildirresource.cpp
http://commits.kde.org/akonadi-next/cf487248df311bd055844ce44786e28ea5aa7c2c
diff --git a/common/mailpreprocessor.cpp b/common/mailpreprocessor.cpp
index 64cb3d9..005a93e 100644
--- a/common/mailpreprocessor.cpp
+++ b/common/mailpreprocessor.cpp
@@ -29,9 +29,14 @@
using namespace Sink;
+QString MailPropertyExtractor::getFilePathFromMimeMessagePath(const QString &s) \
const +{
+ return s;
+}
+
void MailPropertyExtractor::updatedIndexedProperties(Sink::ApplicationDomain::Mail \
&mail) {
- const auto mimeMessagePath = mail.getMimeMessagePath();
+ const auto mimeMessagePath = \
getFilePathFromMimeMessagePath(mail.getMimeMessagePath()); Trace() << "Updating \
indexed properties " << mimeMessagePath; QFile f(mimeMessagePath);
if (!f.open(QIODevice::ReadOnly)) {
diff --git a/common/mailpreprocessor.h b/common/mailpreprocessor.h
index 715e336..473931c 100644
--- a/common/mailpreprocessor.h
+++ b/common/mailpreprocessor.h
@@ -26,6 +26,9 @@ public:
virtual ~MailPropertyExtractor(){}
virtual void newEntity(Sink::ApplicationDomain::Mail &mail, \
Sink::Storage::Transaction &transaction) Q_DECL_OVERRIDE; virtual void \
modifiedEntity(const Sink::ApplicationDomain::Mail &oldMail, \
Sink::ApplicationDomain::Mail &newMail,Sink::Storage::Transaction &transaction) \
Q_DECL_OVERRIDE; +protected:
+ virtual QString getFilePathFromMimeMessagePath(const QString &) const;
+
private:
void updatedIndexedProperties(Sink::ApplicationDomain::Mail &mail);
};
diff --git a/examples/maildirresource/maildirresource.cpp \
b/examples/maildirresource/maildirresource.cpp index 92cfceb..b14a1bd 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 "mailpreprocessor.h"
#include "specialpurposepreprocessor.h"
#include <QDate>
#include <QUuid>
@@ -71,38 +72,12 @@ static QString getFilePathFromMimeMessagePath(const QString \
&mimeMessagePath) return list.first().filePath();
}
-class MaildirMailPropertyExtractor : public Sink::Preprocessor
+class MaildirMailPropertyExtractor : public MailPropertyExtractor
{
-public:
- MaildirMailPropertyExtractor() {}
-
- void updatedIndexedProperties(Sink::ApplicationDomain::BufferAdaptor &newEntity)
- {
- const auto filePath = \
getFilePathFromMimeMessagePath(newEntity.getProperty("mimeMessage").toString());
-
- KMime::Message *msg = new KMime::Message;
- msg->setHead(KMime::CRLFtoLF(KPIM::Maildir::readEntryHeadersFromFile(filePath)));
- msg->parse();
-
- newEntity.setProperty("subject", msg->subject(true)->asUnicodeString());
- newEntity.setProperty("sender", msg->from(true)->asUnicodeString());
- newEntity.setProperty("senderName", msg->from(true)->asUnicodeString());
- newEntity.setProperty("date", msg->date(true)->dateTime());
- }
-
- void newEntity(const QByteArray &uid, qint64 revision, \
Sink::ApplicationDomain::BufferAdaptor &newEntity, Sink::Storage::Transaction \
&transaction) Q_DECL_OVERRIDE
- {
- updatedIndexedProperties(newEntity);
- }
-
- void modifiedEntity(const QByteArray &uid, qint64 revision, const \
Sink::ApplicationDomain::BufferAdaptor &oldEntity, \
Sink::ApplicationDomain::BufferAdaptor &newEntity,
- Sink::Storage::Transaction &transaction) Q_DECL_OVERRIDE
- {
- updatedIndexedProperties(newEntity);
- }
-
- void deletedEntity(const QByteArray &uid, qint64 revision, const \
Sink::ApplicationDomain::BufferAdaptor &oldEntity, Sink::Storage::Transaction \
&transaction) Q_DECL_OVERRIDE +protected:
+ virtual QString getFilePathFromMimeMessagePath(const QString &mimeMessagePath) \
const Q_DECL_OVERRIDE {
+ return ::getFilePathFromMimeMessagePath(mimeMessagePath);
}
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic