[haiku-commits] r41062 - in haiku/trunk: headers/os/mail src/add-ons/mail_daemon/inbound_protocols/pop3 src/apps/mail src/kits/mail src/servers/mail
- From: clemens.zeidler@xxxxxxxxxxxxxx
- To: haiku-commits@xxxxxxxxxxxxx
- Date: Mon, 21 Mar 2011 10:13:13 +0100 (CET)
Author: czeidler
Date: 2011-03-21 10:13:12 +0100 (Mon, 21 Mar 2011)
New Revision: 41062
Changeset: https://dev.haiku-os.org/changeset/41062
Ticket: https://dev.haiku-os.org/ticket/7375
Modified:
haiku/trunk/headers/os/mail/E-mail.h
haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/pop3/pop3.cpp
haiku/trunk/src/apps/mail/MailWindow.cpp
haiku/trunk/src/kits/mail/HaikuMailFormatFilter.cpp
haiku/trunk/src/kits/mail/HaikuMailFormatFilter.h
haiku/trunk/src/kits/mail/MailMessage.cpp
haiku/trunk/src/servers/mail/MailDaemon.cpp
Log:
Write MAIL:name, MAIL:thread and MAIL:account attribute. The account id is now
stored in MAIL:account_id. This requires to re-download all mails to write the
correct attribute (sorry).
Fixes #7375.
Modified: haiku/trunk/headers/os/mail/E-mail.h
===================================================================
--- haiku/trunk/headers/os/mail/E-mail.h 2011-03-21 05:24:48 UTC (rev
41061)
+++ haiku/trunk/headers/os/mail/E-mail.h 2011-03-21 09:13:12 UTC (rev
41062)
@@ -29,6 +29,9 @@
#define B_MAIL_ATTR_HEADER "MAIL:header_length" // int32
#define B_MAIL_ATTR_CONTENT "MAIL:content_length" // int32
#define B_MAIL_ATTR_READ "MAIL:read"
// int32
+#define B_MAIL_ATTR_THREAD "MAIL:thread" //
string
+#define B_MAIL_ATTR_ACCOUNT "MAIL:account" //
string
+#define B_MAIL_ATTR_ACCOUNT_ID "MAIL:account_id" // int32
// read flags
Modified: haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/pop3/pop3.cpp
===================================================================
--- haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/pop3/pop3.cpp
2011-03-21 05:24:48 UTC (rev 41061)
+++ haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/pop3/pop3.cpp
2011-03-21 09:13:12 UTC (rev 41062)
@@ -603,7 +603,7 @@
entry_ref entry;
fido.SetVolume(&volume);
- fido.PushAttr("MAIL:account");
+ fido.PushAttr(B_MAIL_ATTR_ACCOUNT_ID);
fido.PushInt32(fAccountSettings.AccountID());
fido.PushOp(B_EQ);
Modified: haiku/trunk/src/apps/mail/MailWindow.cpp
===================================================================
--- haiku/trunk/src/apps/mail/MailWindow.cpp 2011-03-21 05:24:48 UTC (rev
41061)
+++ haiku/trunk/src/apps/mail/MailWindow.cpp 2011-03-21 09:13:12 UTC (rev
41062)
@@ -804,7 +804,7 @@
return;
int32 account;
- if (node.ReadAttr("MAIL:account", B_INT32_TYPE, 0, &account,
+ if (node.ReadAttr(B_MAIL_ATTR_ACCOUNT_ID, B_INT32_TYPE, 0, &account,
sizeof(account)) < 0)
account = -1;
Modified: haiku/trunk/src/kits/mail/HaikuMailFormatFilter.cpp
===================================================================
--- haiku/trunk/src/kits/mail/HaikuMailFormatFilter.cpp 2011-03-21 05:24:48 UTC
(rev 41061)
+++ haiku/trunk/src/kits/mail/HaikuMailFormatFilter.cpp 2011-03-21 09:13:12 UTC
(rev 41062)
@@ -35,12 +35,15 @@
{ "Delivery-Date", B_MAIL_ATTR_WHEN, B_TIME_TYPE },
{ "Reply-To", B_MAIL_ATTR_REPLY, B_STRING_TYPE },
{ "Subject", B_MAIL_ATTR_SUBJECT, B_STRING_TYPE },
- { "X-Priority", B_MAIL_ATTR_PRIORITY, B_STRING_TYPE },
// Priorities with prefered
- { "Priority", B_MAIL_ATTR_PRIORITY, B_STRING_TYPE },
// one first - the numeric
- { "X-Msmail-Priority", B_MAIL_ATTR_PRIORITY, B_STRING_TYPE }, // one
(has more levels).
+ { "X-Priority", B_MAIL_ATTR_PRIORITY, B_STRING_TYPE },
+ // Priorities with prefered
+ { "Priority", B_MAIL_ATTR_PRIORITY, B_STRING_TYPE },
+ // one first - the numeric
+ { "X-Msmail-Priority", B_MAIL_ATTR_PRIORITY, B_STRING_TYPE },
+ // one (has more levels).
{ "Mime-Version", B_MAIL_ATTR_MIME, B_STRING_TYPE },
{ "STATUS", B_MAIL_ATTR_STATUS, B_STRING_TYPE },
- { "THREAD", "MAIL:thread", B_STRING_TYPE
}, //---Not supposed to be used for this (we add it in Parser), but why not?
+ { "THREAD", B_MAIL_ATTR_THREAD, B_STRING_TYPE },
{ "NAME", B_MAIL_ATTR_NAME, B_STRING_TYPE },
{ NULL, NULL,
0 }
};
@@ -51,7 +54,8 @@
:
MailFilter(protocol, NULL),
- fAccountId(settings->AccountID())
+ fAccountId(settings->AccountID()),
+ fAccountName(settings->Name())
{
const BMessage* outboundSettings =
&settings->OutboundSettings().Settings();
if (outboundSettings->FindString("destination", &fOutboundDirectory)
@@ -68,7 +72,8 @@
BMessage attributes;
// TODO attributes.AddInt32(B_MAIL_ATTR_CONTENT, length);
- attributes.AddInt32("MAIL:account", fAccountId);
+ attributes.AddInt32(B_MAIL_ATTR_ACCOUNT_ID, fAccountId);
+ attributes.AddString(B_MAIL_ATTR_ACCOUNT, fAccountName);
BString header;
off_t size;
@@ -102,16 +107,16 @@
}
}
- (*file) << attributes;
+ BString senderName =
_ExtractName(attributes.FindString(B_MAIL_ATTR_FROM));
+ attributes.AddString(B_MAIL_ATTR_NAME, senderName);
-
// Generate a file name for the incoming message. See also
// Message::RenderTo which does a similar thing for outgoing messages.
-
- BString name = attributes.FindString("MAIL:subject");
+ BString name = attributes.FindString(B_MAIL_ATTR_SUBJECT);
SubjectToThread(name); // Extract the core subject words.
if (name.Length() <= 0)
name = "No Subject";
+ attributes.AddString(B_MAIL_ATTR_THREAD, name);
if (name[0] == '.')
name.Prepend ("_"); // Avoid hidden files, starting with a dot.
@@ -171,6 +176,8 @@
fMailProtocol.FileRenamed(ref, to);
}
+ (*file) << attributes;
+
BNodeInfo info(file);
info.SetType(B_PARTIAL_MAIL_TYPE);
}
@@ -205,3 +212,25 @@
BEntry entry(&ref);
return entry.Rename(name);
}
+
+
+BString
+HaikuMailFormatFilter::_ExtractName(const BString& from)
+{
+ BString name;
+
+ int32 emailStart = from.FindFirst("<");
+ if (emailStart < 0)
+ name = from;
+
+ from.CopyInto(name, 0, emailStart);
+ name.Trim();
+ if (name.Length() < 2)
+ return from;
+
+ if (name[name.Length() - 1] == '\"')
+ name.Truncate(name.Length() - 1, true);
+ if (name[0] == '\"')
+ name.Remove(0, 1);
+ return name;
+}
Modified: haiku/trunk/src/kits/mail/HaikuMailFormatFilter.h
===================================================================
--- haiku/trunk/src/kits/mail/HaikuMailFormatFilter.h 2011-03-21 05:24:48 UTC
(rev 41061)
+++ haiku/trunk/src/kits/mail/HaikuMailFormatFilter.h 2011-03-21 09:13:12 UTC
(rev 41062)
@@ -26,8 +26,10 @@
private:
status_t _SetFileName(const
entry_ref& ref,
const
BString& name);
+ BString _ExtractName(const
BString& from);
int32 fAccountId;
+ BString fAccountName;
BString fOutboundDirectory;
};
Modified: haiku/trunk/src/kits/mail/MailMessage.cpp
===================================================================
--- haiku/trunk/src/kits/mail/MailMessage.cpp 2011-03-21 05:24:48 UTC (rev
41061)
+++ haiku/trunk/src/kits/mail/MailMessage.cpp 2011-03-21 09:13:12 UTC (rev
41062)
@@ -636,10 +636,13 @@
status_t
-BEmailMessage::SetToRFC822(BPositionIO *mail_file, size_t length, bool
parse_now)
+BEmailMessage::SetToRFC822(BPositionIO *mail_file, size_t length,
+ bool parse_now)
{
- if (BFile *file = dynamic_cast<BFile *>(mail_file))
-
file->ReadAttr("MAIL:account",B_INT32_TYPE,0,&_account_id,sizeof(_account_id));
+ if (BFile *file = dynamic_cast<BFile *>(mail_file)) {
+ file->ReadAttr(B_MAIL_ATTR_ACCOUNT_ID, B_INT32_TYPE, 0,
&_account_id,
+ sizeof(_account_id));
+ }
mail_file->Seek(0,SEEK_END);
length = mail_file->Position();
@@ -806,8 +809,8 @@
attributed->WriteAttr(B_MAIL_ATTR_FLAGS, B_INT32_TYPE, 0,
&flags,
sizeof(int32));
- attributed->WriteAttr("MAIL:account", B_INT32_TYPE, 0,
&_account_id,
- sizeof(int32));
+ attributed->WriteAttr(B_MAIL_ATTR_ACCOUNT_ID, B_INT32_TYPE, 0,
+ &_account_id, sizeof(int32));
}
return B_OK;
Modified: haiku/trunk/src/servers/mail/MailDaemon.cpp
===================================================================
--- haiku/trunk/src/servers/mail/MailDaemon.cpp 2011-03-21 05:24:48 UTC (rev
41061)
+++ haiku/trunk/src/servers/mail/MailDaemon.cpp 2011-03-21 09:13:12 UTC (rev
41062)
@@ -193,7 +193,7 @@
continue;
int32 account;
- if (node.ReadAttr("MAIL:account", B_INT32_TYPE, 0, &account,
+ if (node.ReadAttr(B_MAIL_ATTR_ACCOUNT_ID, B_INT32_TYPE, 0,
&account,
sizeof(account)) < 0)
continue;
@@ -724,7 +724,7 @@
query.PushOp(B_EQ);
if (account >= 0) {
- query.PushAttr("MAIL:account");
+ query.PushAttr(B_MAIL_ATTR_ACCOUNT_ID);
query.PushInt32(account);
query.PushOp(B_EQ);
query.PushOp(B_AND);
@@ -744,7 +744,7 @@
continue;
int32 messageAccount;
- if (node.ReadAttr("MAIL:account", B_INT32_TYPE,
0,
+ if (node.ReadAttr(B_MAIL_ATTR_ACCOUNT_ID,
B_INT32_TYPE, 0,
&messageAccount, sizeof(int32)) < 0)
messageAccount = -1;
Other related posts: