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. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41062 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -29,6 +29,9 @@ struct entry_ref;
|
|||||||
#define B_MAIL_ATTR_HEADER "MAIL:header_length" // int32
|
#define B_MAIL_ATTR_HEADER "MAIL:header_length" // int32
|
||||||
#define B_MAIL_ATTR_CONTENT "MAIL:content_length" // int32
|
#define B_MAIL_ATTR_CONTENT "MAIL:content_length" // int32
|
||||||
#define B_MAIL_ATTR_READ "MAIL:read" // 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
|
// read flags
|
||||||
|
|||||||
@@ -603,7 +603,7 @@ POP3Protocol::CheckForDeletedMessages()
|
|||||||
entry_ref entry;
|
entry_ref entry;
|
||||||
|
|
||||||
fido.SetVolume(&volume);
|
fido.SetVolume(&volume);
|
||||||
fido.PushAttr("MAIL:account");
|
fido.PushAttr(B_MAIL_ATTR_ACCOUNT_ID);
|
||||||
fido.PushInt32(fAccountSettings.AccountID());
|
fido.PushInt32(fAccountSettings.AccountID());
|
||||||
fido.PushOp(B_EQ);
|
fido.PushOp(B_EQ);
|
||||||
|
|
||||||
|
|||||||
@@ -804,7 +804,7 @@ TMailWindow::MarkMessageRead(entry_ref* message, read_flags flag)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
int32 account;
|
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)
|
sizeof(account)) < 0)
|
||||||
account = -1;
|
account = -1;
|
||||||
|
|
||||||
|
|||||||
@@ -35,12 +35,15 @@ static const mail_header_field gDefaultFields[] =
|
|||||||
{ "Delivery-Date", B_MAIL_ATTR_WHEN, B_TIME_TYPE },
|
{ "Delivery-Date", B_MAIL_ATTR_WHEN, B_TIME_TYPE },
|
||||||
{ "Reply-To", B_MAIL_ATTR_REPLY, B_STRING_TYPE },
|
{ "Reply-To", B_MAIL_ATTR_REPLY, B_STRING_TYPE },
|
||||||
{ "Subject", B_MAIL_ATTR_SUBJECT, B_STRING_TYPE },
|
{ "Subject", B_MAIL_ATTR_SUBJECT, B_STRING_TYPE },
|
||||||
{ "X-Priority", B_MAIL_ATTR_PRIORITY, B_STRING_TYPE }, // Priorities with prefered
|
{ "X-Priority", B_MAIL_ATTR_PRIORITY, B_STRING_TYPE },
|
||||||
{ "Priority", B_MAIL_ATTR_PRIORITY, B_STRING_TYPE }, // one first - the numeric
|
// Priorities with prefered
|
||||||
{ "X-Msmail-Priority", B_MAIL_ATTR_PRIORITY, B_STRING_TYPE }, // one (has more levels).
|
{ "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 },
|
{ "Mime-Version", B_MAIL_ATTR_MIME, B_STRING_TYPE },
|
||||||
{ "STATUS", B_MAIL_ATTR_STATUS, 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 },
|
{ "NAME", B_MAIL_ATTR_NAME, B_STRING_TYPE },
|
||||||
{ NULL, NULL, 0 }
|
{ NULL, NULL, 0 }
|
||||||
};
|
};
|
||||||
@@ -51,7 +54,8 @@ HaikuMailFormatFilter::HaikuMailFormatFilter(MailProtocol& protocol,
|
|||||||
:
|
:
|
||||||
MailFilter(protocol, NULL),
|
MailFilter(protocol, NULL),
|
||||||
|
|
||||||
fAccountId(settings->AccountID())
|
fAccountId(settings->AccountID()),
|
||||||
|
fAccountName(settings->Name())
|
||||||
{
|
{
|
||||||
const BMessage* outboundSettings = &settings->OutboundSettings().Settings();
|
const BMessage* outboundSettings = &settings->OutboundSettings().Settings();
|
||||||
if (outboundSettings->FindString("destination", &fOutboundDirectory)
|
if (outboundSettings->FindString("destination", &fOutboundDirectory)
|
||||||
@@ -68,7 +72,8 @@ HaikuMailFormatFilter::HeaderFetched(const entry_ref& ref, BFile* file)
|
|||||||
|
|
||||||
BMessage attributes;
|
BMessage attributes;
|
||||||
// TODO attributes.AddInt32(B_MAIL_ATTR_CONTENT, length);
|
// 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;
|
BString header;
|
||||||
off_t size;
|
off_t size;
|
||||||
@@ -102,16 +107,16 @@ HaikuMailFormatFilter::HeaderFetched(const entry_ref& ref, BFile* file)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(*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
|
// Generate a file name for the incoming message. See also
|
||||||
// Message::RenderTo which does a similar thing for outgoing messages.
|
// Message::RenderTo which does a similar thing for outgoing messages.
|
||||||
|
BString name = attributes.FindString(B_MAIL_ATTR_SUBJECT);
|
||||||
BString name = attributes.FindString("MAIL:subject");
|
|
||||||
SubjectToThread(name); // Extract the core subject words.
|
SubjectToThread(name); // Extract the core subject words.
|
||||||
if (name.Length() <= 0)
|
if (name.Length() <= 0)
|
||||||
name = "No Subject";
|
name = "No Subject";
|
||||||
|
attributes.AddString(B_MAIL_ATTR_THREAD, name);
|
||||||
if (name[0] == '.')
|
if (name[0] == '.')
|
||||||
name.Prepend ("_"); // Avoid hidden files, starting with a dot.
|
name.Prepend ("_"); // Avoid hidden files, starting with a dot.
|
||||||
|
|
||||||
@@ -171,6 +176,8 @@ HaikuMailFormatFilter::HeaderFetched(const entry_ref& ref, BFile* file)
|
|||||||
fMailProtocol.FileRenamed(ref, to);
|
fMailProtocol.FileRenamed(ref, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(*file) << attributes;
|
||||||
|
|
||||||
BNodeInfo info(file);
|
BNodeInfo info(file);
|
||||||
info.SetType(B_PARTIAL_MAIL_TYPE);
|
info.SetType(B_PARTIAL_MAIL_TYPE);
|
||||||
}
|
}
|
||||||
@@ -205,3 +212,25 @@ HaikuMailFormatFilter::_SetFileName(const entry_ref& ref, const BString& name)
|
|||||||
BEntry entry(&ref);
|
BEntry entry(&ref);
|
||||||
return entry.Rename(name);
|
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;
|
||||||
|
}
|
||||||
|
|||||||
@@ -26,8 +26,10 @@ public:
|
|||||||
private:
|
private:
|
||||||
status_t _SetFileName(const entry_ref& ref,
|
status_t _SetFileName(const entry_ref& ref,
|
||||||
const BString& name);
|
const BString& name);
|
||||||
|
BString _ExtractName(const BString& from);
|
||||||
|
|
||||||
int32 fAccountId;
|
int32 fAccountId;
|
||||||
|
BString fAccountName;
|
||||||
BString fOutboundDirectory;
|
BString fOutboundDirectory;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -636,10 +636,13 @@ BEmailMessage::RetrieveTextBody(BMailComponent *component)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
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))
|
if (BFile *file = dynamic_cast<BFile *>(mail_file)) {
|
||||||
file->ReadAttr("MAIL:account",B_INT32_TYPE,0,&_account_id,sizeof(_account_id));
|
file->ReadAttr(B_MAIL_ATTR_ACCOUNT_ID, B_INT32_TYPE, 0, &_account_id,
|
||||||
|
sizeof(_account_id));
|
||||||
|
}
|
||||||
|
|
||||||
mail_file->Seek(0,SEEK_END);
|
mail_file->Seek(0,SEEK_END);
|
||||||
length = mail_file->Position();
|
length = mail_file->Position();
|
||||||
@@ -806,8 +809,8 @@ BEmailMessage::RenderToRFC822(BPositionIO *file)
|
|||||||
attributed->WriteAttr(B_MAIL_ATTR_FLAGS, B_INT32_TYPE, 0, &flags,
|
attributed->WriteAttr(B_MAIL_ATTR_FLAGS, B_INT32_TYPE, 0, &flags,
|
||||||
sizeof(int32));
|
sizeof(int32));
|
||||||
|
|
||||||
attributed->WriteAttr("MAIL:account", B_INT32_TYPE, 0, &_account_id,
|
attributed->WriteAttr(B_MAIL_ATTR_ACCOUNT_ID, B_INT32_TYPE, 0,
|
||||||
sizeof(int32));
|
&_account_id, sizeof(int32));
|
||||||
}
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ MailDaemonApp::RefsReceived(BMessage* message)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
int32 account;
|
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)
|
sizeof(account)) < 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -724,7 +724,7 @@ MailDaemonApp::SendPendingMessages(BMessage* msg)
|
|||||||
query.PushOp(B_EQ);
|
query.PushOp(B_EQ);
|
||||||
|
|
||||||
if (account >= 0) {
|
if (account >= 0) {
|
||||||
query.PushAttr("MAIL:account");
|
query.PushAttr(B_MAIL_ATTR_ACCOUNT_ID);
|
||||||
query.PushInt32(account);
|
query.PushInt32(account);
|
||||||
query.PushOp(B_EQ);
|
query.PushOp(B_EQ);
|
||||||
query.PushOp(B_AND);
|
query.PushOp(B_AND);
|
||||||
@@ -744,7 +744,7 @@ MailDaemonApp::SendPendingMessages(BMessage* msg)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
int32 messageAccount;
|
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, sizeof(int32)) < 0)
|
||||||
messageAccount = -1;
|
messageAccount = -1;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user