From 18f04f0ea8da9c635742571eb0de01d12d856e9f Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 31 Oct 2016 23:32:22 +0100 Subject: Got the sender to work --- common/domain/applicationdomaintype.h | 8 ++++---- common/mailpreprocessor.cpp | 10 ++++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'common') diff --git a/common/domain/applicationdomaintype.h b/common/domain/applicationdomaintype.h index b377db9..d2b4d83 100644 --- a/common/domain/applicationdomaintype.h +++ b/common/domain/applicationdomaintype.h @@ -278,10 +278,10 @@ struct SINK_EXPORT Mail : public Entity { SINK_ENTITY(Mail); SINK_PROPERTY(QString, Uid, uid); - SINK_PROPERTY(Contact, Sender, sender); - SINK_PROPERTY(QList, To, to); - SINK_PROPERTY(QList, Cc, cc); - SINK_PROPERTY(QList, Bcc, bcc); + SINK_EXTRACTED_PROPERTY(Contact, Sender, sender); + SINK_EXTRACTED_PROPERTY(QList, To, to); + SINK_EXTRACTED_PROPERTY(QList, Cc, cc); + SINK_EXTRACTED_PROPERTY(QList, Bcc, bcc); SINK_EXTRACTED_PROPERTY(QString, Subject, subject); SINK_EXTRACTED_PROPERTY(QDateTime, Date, date); SINK_PROPERTY(bool, Unread, unread); diff --git a/common/mailpreprocessor.cpp b/common/mailpreprocessor.cpp index 17a2f4f..45f5def 100644 --- a/common/mailpreprocessor.cpp +++ b/common/mailpreprocessor.cpp @@ -81,11 +81,17 @@ struct MimeMessageReader { qint64 mappedSize; }; +static Sink::ApplicationDomain::Mail::Contact getContact(const KMime::Headers::From *header) +{ + const auto name = header->displayNames().isEmpty() ? QString() : header->displayNames().first(); + const auto address = header->addresses().isEmpty() ? QString() : header->addresses().first(); + return Sink::ApplicationDomain::Mail::Contact{name, address}; +} + static void updatedIndexedProperties(Sink::ApplicationDomain::Mail &mail, KMime::Message::Ptr msg) { mail.setExtractedSubject(msg->subject(true)->asUnicodeString()); - /* mail.setExtractedSender(msg->from(true)->asUnicodeString()); */ - /* mail.setExtractedSenderName(msg->from(true)->asUnicodeString()); */ + mail.setExtractedSender(getContact(msg->from(true))); mail.setExtractedDate(msg->date(true)->dateTime()); //The rest should never change, unless we didn't have the headers available initially. -- cgit v1.2.3