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/mailpreprocessor.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'common/mailpreprocessor.cpp') 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