From 0e657c0b6c38084d9aa684515ec505a212b96bc9 Mon Sep 17 00:00:00 2001 From: Clemens Zeidler Date: Sun, 20 Feb 2011 07:55:47 +0000 Subject: [PATCH] Remember tracker message when downloading a partial message and open it with Mail. This is needed to get the next/previous message after downloading the body. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40575 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/add-ons/mail_daemon/MailProtocol.h | 2 +- headers/os/mail/MailDaemon.h | 3 ++- src/apps/mail/MailWindow.cpp | 7 ++++--- src/apps/mail/MailWindow.h | 3 ++- src/kits/mail/MailDaemon.cpp | 3 ++- src/kits/mail/MailProtocol.cpp | 16 +++++++++++----- src/servers/mail/MailDaemon.cpp | 8 ++++++-- 7 files changed, 28 insertions(+), 14 deletions(-) diff --git a/headers/os/add-ons/mail_daemon/MailProtocol.h b/headers/os/add-ons/mail_daemon/MailProtocol.h index 547738cf3e..31a8baa5bb 100644 --- a/headers/os/add-ons/mail_daemon/MailProtocol.h +++ b/headers/os/add-ons/mail_daemon/MailProtocol.h @@ -194,7 +194,7 @@ public: void SyncMessages(); void FetchBody(const entry_ref& ref, - bool launch = false); + BMessage* launch = NULL); void MarkMessageAsRead(const entry_ref& ref, bool read = true); void DeleteMessage(const entry_ref& ref); diff --git a/headers/os/mail/MailDaemon.h b/headers/os/mail/MailDaemon.h index 46eca98816..43b26431a1 100644 --- a/headers/os/mail/MailDaemon.h +++ b/headers/os/mail/MailDaemon.h @@ -28,7 +28,8 @@ public: bool waitForFetchCompletion = false); static status_t MarkAsRead(int32 account, const entry_ref& ref, bool read = true); - static status_t FetchBody(const entry_ref& ref); + static status_t FetchBody(const entry_ref& ref, + BMessage* launchMessage = NULL); static status_t Quit(); }; diff --git a/src/apps/mail/MailWindow.cpp b/src/apps/mail/MailWindow.cpp index fc31aaffb5..62052bfc17 100644 --- a/src/apps/mail/MailWindow.cpp +++ b/src/apps/mail/MailWindow.cpp @@ -1511,7 +1511,7 @@ TMailWindow::MessageReceived(BMessage *msg) if (fAutoMarkRead) SetCurrentMessageRead(); OpenMessage(&nextRef, - fHeaderView->fCharacterSetUserSees); + fHeaderView->fCharacterSetUserSees, msg); } else { window->Activate(); @@ -2794,7 +2794,8 @@ TMailWindow::SetTitleForMessage() // status_t -TMailWindow::OpenMessage(entry_ref *ref, uint32 characterSetForDecoding) +TMailWindow::OpenMessage(entry_ref *ref, uint32 characterSetForDecoding, + BMessage* trackerMsg) { // // Set some references to the email file @@ -2822,7 +2823,7 @@ TMailWindow::OpenMessage(entry_ref *ref, uint32 characterSetForDecoding) fileInfo.GetType(mimeType); if (strcmp(mimeType, B_PARTIAL_MAIL_TYPE) == 0) { - BMailDaemon::FetchBody(*ref); + BMailDaemon::FetchBody(*ref, trackerMsg); fileInfo.GetType(mimeType); } diff --git a/src/apps/mail/MailWindow.h b/src/apps/mail/MailWindow.h index fc509978d0..c17b2da111 100644 --- a/src/apps/mail/MailWindow.h +++ b/src/apps/mail/MailWindow.h @@ -97,7 +97,8 @@ class TMailWindow : public BWindow { status_t SaveAsDraft(); status_t OpenMessage(entry_ref* ref, uint32 characterSetForDecoding - = B_MAIL_NULL_CONVERSION); + = B_MAIL_NULL_CONVERSION, + BMessage* trackerMsg = NULL); status_t GetMailNodeRef(node_ref &nodeRef) const; BEmailMessage* Mail() const { return fMail; } diff --git a/src/kits/mail/MailDaemon.cpp b/src/kits/mail/MailDaemon.cpp index 3a3fd1dc34..7ee3de1d40 100644 --- a/src/kits/mail/MailDaemon.cpp +++ b/src/kits/mail/MailDaemon.cpp @@ -87,7 +87,7 @@ BMailDaemon::MarkAsRead(int32 account, const entry_ref& ref, bool read) status_t -BMailDaemon::FetchBody(const entry_ref& ref) +BMailDaemon::FetchBody(const entry_ref& ref, BMessage* launchMessage) { BMessenger daemon("application/x-vnd.Be-POST"); if (!daemon.IsValid()) @@ -95,6 +95,7 @@ BMailDaemon::FetchBody(const entry_ref& ref) BMessage message(kMsgFetchBody); message.AddRef("refs", &ref); + message.AddMessage("launch", launchMessage); BMessage reply; return daemon.SendMessage(&message, &reply); diff --git a/src/kits/mail/MailProtocol.cpp b/src/kits/mail/MailProtocol.cpp index 23882d6f25..16d79f4d07 100644 --- a/src/kits/mail/MailProtocol.cpp +++ b/src/kits/mail/MailProtocol.cpp @@ -582,11 +582,17 @@ InboundProtocolThread::MessageReceived(BMessage* message) entry_ref ref; message->FindRef("ref", &ref); status_t status = fProtocol->FetchBody(ref); - if (status != B_OK || !message->FindBool("launch")) + if (status != B_OK) break; - BMessage argv(B_ARGV_RECEIVED); - BPath path(&ref); + + BMessage argv; + if (message->FindMessage("launch", &argv) != B_OK) + break; + argv.RemoveName("argv"); + argv.RemoveName("argc"); + argv.AddString("argv", "E-mail"); + BPath path(&ref); argv.AddString("argv", path.Path()); argv.AddInt32("argc", 2); be_roster->Launch("text/x-email", &argv); @@ -632,11 +638,11 @@ InboundProtocolThread::SyncMessages() void -InboundProtocolThread::FetchBody(const entry_ref& ref, bool launch) +InboundProtocolThread::FetchBody(const entry_ref& ref, BMessage* launch) { BMessage message(kMsgFetchBody); message.AddRef("ref", &ref); - message.AddBool("launch", launch); + message.AddMessage("launch", launch); PostMessage(&message); } diff --git a/src/servers/mail/MailDaemon.cpp b/src/servers/mail/MailDaemon.cpp index 6d8d69d8e4..aa1277adb3 100644 --- a/src/servers/mail/MailDaemon.cpp +++ b/src/servers/mail/MailDaemon.cpp @@ -199,8 +199,12 @@ MailDaemonApp::RefsReceived(BMessage* message) InboundProtocolThread* protocol = _FindInboundProtocol(account); if (!protocol) continue; - bool launch = true; - protocol->FetchBody(ref, launch); + + BMessage* launchMessage = message; + BMessage temp; + if (message->FindMessage("launch", &temp) == B_OK) + launchMessage = &temp; + protocol->FetchBody(ref, launchMessage); } }