summaryrefslogtreecommitdiffstats
path: root/common/mailpreprocessor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'common/mailpreprocessor.cpp')
-rw-r--r--common/mailpreprocessor.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/common/mailpreprocessor.cpp b/common/mailpreprocessor.cpp
index 45f5def..575ff4b 100644
--- a/common/mailpreprocessor.cpp
+++ b/common/mailpreprocessor.cpp
@@ -81,17 +81,29 @@ struct MimeMessageReader {
81 qint64 mappedSize; 81 qint64 mappedSize;
82}; 82};
83 83
84static Sink::ApplicationDomain::Mail::Contact getContact(const KMime::Headers::From *header) 84static Sink::ApplicationDomain::Mail::Contact getContact(const KMime::Headers::Generics::MailboxList *header)
85{ 85{
86 const auto name = header->displayNames().isEmpty() ? QString() : header->displayNames().first(); 86 const auto name = header->displayNames().isEmpty() ? QString() : header->displayNames().first();
87 const auto address = header->addresses().isEmpty() ? QString() : header->addresses().first(); 87 const auto address = header->addresses().isEmpty() ? QString() : header->addresses().first();
88 return Sink::ApplicationDomain::Mail::Contact{name, address}; 88 return Sink::ApplicationDomain::Mail::Contact{name, address};
89} 89}
90 90
91static QList<Sink::ApplicationDomain::Mail::Contact> getContactList(const KMime::Headers::Generics::AddressList *header)
92{
93 QList<Sink::ApplicationDomain::Mail::Contact> list;
94 for (const auto mb : header->mailboxes()) {
95 list << Sink::ApplicationDomain::Mail::Contact{mb.name(), mb.address()};
96 }
97 return list;
98}
99
91static void updatedIndexedProperties(Sink::ApplicationDomain::Mail &mail, KMime::Message::Ptr msg) 100static void updatedIndexedProperties(Sink::ApplicationDomain::Mail &mail, KMime::Message::Ptr msg)
92{ 101{
93 mail.setExtractedSubject(msg->subject(true)->asUnicodeString()); 102 mail.setExtractedSubject(msg->subject(true)->asUnicodeString());
94 mail.setExtractedSender(getContact(msg->from(true))); 103 mail.setExtractedSender(getContact(msg->from(true)));
104 mail.setExtractedTo(getContactList(msg->to(true)));
105 mail.setExtractedCc(getContactList(msg->cc(true)));
106 mail.setExtractedBcc(getContactList(msg->bcc(true)));
95 mail.setExtractedDate(msg->date(true)->dateTime()); 107 mail.setExtractedDate(msg->date(true)->dateTime());
96 108
97 //The rest should never change, unless we didn't have the headers available initially. 109 //The rest should never change, unless we didn't have the headers available initially.