diff --git a/mailnews/local/public/nsIMailboxUrl.h b/mailnews/local/public/nsIMailboxUrl.h index 7406761428bf..af4a46ef5b01 100644 --- a/mailnews/local/public/nsIMailboxUrl.h +++ b/mailnews/local/public/nsIMailboxUrl.h @@ -48,6 +48,8 @@ typedef enum { nsMailboxActionMoveMessage } nsMailboxAction; +class nsIMsgDBHdr; + class nsIMailboxUrl : public nsIMsgMailNewsUrl { public: @@ -84,7 +86,10 @@ public: // Getters and Setters for the mailbox url state /////////////////////////////////////////////////////////////////////////////// NS_IMETHOD GetFilePath(const nsFileSpec ** aFilePath) = 0; - // NS_IMETHOD SetFilePath(const nsFileSpec& aFilePath) = 0; + + // if the mailbox url represents a single message, than this interface will + // return a message db header for that message. + NS_IMETHOD GetMessageHeader(nsIMsgDBHdr ** aMsgHdr) = 0; // Some mailbox urls include a message key for the message in question. NS_IMETHOD GetMessageKey(nsMsgKey& aMessageID) = 0; diff --git a/mailnews/local/src/nsMailboxUrl.cpp b/mailnews/local/src/nsMailboxUrl.cpp index bfa66b1f63c6..d99cff3920d0 100644 --- a/mailnews/local/src/nsMailboxUrl.cpp +++ b/mailnews/local/src/nsMailboxUrl.cpp @@ -32,12 +32,16 @@ #include "nsEscape.h" #include "nsCRT.h" #include "nsLocalUtils.h" +#include "nsIMsgDatabase.h" +#include "nsMsgDBCID.h" +#include "nsIMsgHdr.h" // we need this because of an egcs 1.0 (and possibly gcc) compiler bug // that doesn't allow you to call ::nsISupports::GetIID() inside of a class // that multiply inherits from nsISupports static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_CID(kUrlListenerManagerCID, NS_URLLISTENERMANAGER_CID); +static NS_DEFINE_CID(kCMailDB, NS_MAILDB_CID); // this is totally lame and MUST be removed by M6 // the real fix is to attach the URI to the URL as it runs through netlib @@ -358,8 +362,7 @@ nsresult nsMailboxUrl::SetUrlState(PRBool aRunningUrl, nsresult aExitCode) } // from nsIMsgUriUrl -NS_IMETHODIMP -nsMailboxUrl::GetURI(char ** aURI) +NS_IMETHODIMP nsMailboxUrl::GetURI(char ** aURI) { // function not implemented yet.... // when I get scott's function to take a path and a message id and turn it into @@ -386,6 +389,27 @@ nsMailboxUrl::GetURI(char ** aURI) return NS_OK; } +NS_IMETHODIMP nsMailboxUrl::GetMessageHeader(nsIMsgDBHdr ** aMsgHdr) +{ + nsresult rv = NS_OK; + if (aMsgHdr) + { + nsCOMPtr mailDBFactory; + nsCOMPtr mailDB; + + rv = nsComponentManager::CreateInstance(kCMailDB, nsnull, nsIMsgDatabase::GetIID(), + (void **) getter_AddRefs(mailDBFactory)); + if (NS_SUCCEEDED(rv) && mailDBFactory) + rv = mailDBFactory->Open((nsFileSpec&) *m_filePath, PR_FALSE, (nsIMsgDatabase **) getter_AddRefs(mailDB), PR_FALSE); + if (NS_SUCCEEDED(rv) && mailDB) // did we get a db back? + rv = mailDB->GetMsgHdrForKey(m_messageKey, aMsgHdr); + } + else + rv = NS_ERROR_NULL_POINTER; + + return rv; +} + //////////////////////////////////////////////////////////////////////////////////// // End nsIMailboxUrl specific support //////////////////////////////////////////////////////////////////////////////////// diff --git a/mailnews/local/src/nsMailboxUrl.h b/mailnews/local/src/nsMailboxUrl.h index 1190aa9d1d15..2f098b899a83 100644 --- a/mailnews/local/src/nsMailboxUrl.h +++ b/mailnews/local/src/nsMailboxUrl.h @@ -65,6 +65,7 @@ public: NS_IMETHOD SetURLInfo(URL_Struct_ *URL_s); // from nsIMailboxUrl: + NS_IMETHOD GetMessageHeader(nsIMsgDBHdr ** aMsgHdr); NS_IMETHOD SetMailboxParser(nsIStreamListener * aConsumer); NS_IMETHOD GetMailboxParser(nsIStreamListener ** aConsumer); NS_IMETHOD SetMailboxCopyHandler(nsIStreamListener * aConsumer);