From 6835a27780549d27c21819fc8e1c2e27b4a8f1ce Mon Sep 17 00:00:00 2001 From: "mscott%netscape.com" Date: Tue, 22 Jun 1999 00:09:48 +0000 Subject: [PATCH] Because of my over-haul for mailnews urls, we now need to be more explicit about the url interfac we are calling the method on (nsIURL, nsIMailboxUrl, nsIMsgMailNewsUrl, etc). --- mailnews/local/src/nsMailboxProtocol.cpp | 17 +++++-- mailnews/local/src/nsMailboxService.cpp | 59 +++++++++++------------- mailnews/local/src/nsMailboxService.h | 2 +- mailnews/local/src/nsParseMailbox.cpp | 2 +- 4 files changed, 43 insertions(+), 37 deletions(-) diff --git a/mailnews/local/src/nsMailboxProtocol.cpp b/mailnews/local/src/nsMailboxProtocol.cpp index 89501c448a4c..b8bd23b17372 100644 --- a/mailnews/local/src/nsMailboxProtocol.cpp +++ b/mailnews/local/src/nsMailboxProtocol.cpp @@ -277,7 +277,10 @@ PRInt32 nsMailboxProtocol::ReadFolderResponse(nsIInputStream * inputStream, PRUi nsresult rv = NS_OK; if (m_mailboxParser) - rv = m_mailboxParser->OnDataAvailable(m_runningUrl, inputStream, length); // let the parser deal with it... + { + nsCOMPtr url = do_QueryInterface(m_runningUrl); + rv = m_mailboxParser->OnDataAvailable(url, inputStream, length); // let the parser deal with it... + } if (NS_FAILED(rv)) { @@ -308,7 +311,10 @@ PRInt32 nsMailboxProtocol::ReadMessageResponse(nsIInputStream * inputStream, PRU if (m_mailboxAction == nsMailboxActionCopyMessage || m_mailboxAction == nsMailboxActionMoveMessage) { if (m_mailboxCopyHandler) - rv = m_mailboxCopyHandler->OnDataAvailable(m_runningUrl, inputStream, length); + { + nsCOMPtr url = do_QueryInterface(m_runningUrl); + rv = m_mailboxCopyHandler->OnDataAvailable(url, inputStream, length); + } } else { @@ -387,8 +393,11 @@ nsresult nsMailboxProtocol::ProcessProtocolState(nsIURL * url, nsIInputStream * break; case MAILBOX_DONE: case MAILBOX_ERROR_DONE: - m_runningUrl->SetUrlState(PR_FALSE, NS_OK); - m_nextState = MAILBOX_FREE; + { + nsCOMPtr url = do_QueryInterface(m_runningUrl); + url->SetUrlState(PR_FALSE, NS_OK); + m_nextState = MAILBOX_FREE; + } break; case MAILBOX_FREE: diff --git a/mailnews/local/src/nsMailboxService.cpp b/mailnews/local/src/nsMailboxService.cpp index d738706b1387..fb8e9e8688f9 100644 --- a/mailnews/local/src/nsMailboxService.cpp +++ b/mailnews/local/src/nsMailboxService.cpp @@ -27,6 +27,7 @@ #include "nsMailboxService.h" #include "nsMailboxUrl.h" +#include "nsIMsgMailNewsUrl.h" #include "nsMailboxProtocol.h" #include "nsIMsgDatabase.h" #include "nsMsgDBCID.h" @@ -85,22 +86,23 @@ nsresult nsMailboxService::QueryInterface(const nsIID &aIID, void** aInstancePtr nsresult nsMailboxService::ParseMailbox(nsFileSpec& aMailboxPath, nsIStreamListener *aMailboxParser, nsIUrlListener * aUrlListener, nsIURL ** aURL) { - nsCOMPtr url; + nsCOMPtr mailboxurl; nsresult rv = NS_OK; NS_LOCK_INSTANCE(); rv = nsComponentManager::CreateInstance(kCMailboxUrl, nsnull, nsIMailboxUrl::GetIID(), - (void **) getter_AddRefs(url)); - if (NS_SUCCEEDED(rv) && url) + (void **) getter_AddRefs(mailboxurl)); + if (NS_SUCCEEDED(rv) && mailboxurl) { + nsCOMPtr url = do_QueryInterface(mailboxurl); // okay now generate the url string nsFilePath filePath(aMailboxPath); // convert to file url representation... char * urlSpec = PR_smprintf("mailbox://%s", (const char *) filePath); url->SetSpec(urlSpec); PR_FREEIF(urlSpec); - url->SetMailboxParser(aMailboxParser); + mailboxurl->SetMailboxParser(aMailboxParser); if (aUrlListener) url->RegisterListener(aUrlListener); @@ -124,27 +126,26 @@ nsresult nsMailboxService::CopyMessage(const char * aSrcMailboxURI, nsIUrlListener * aUrlListener, nsIURL **aURL) { - nsCOMPtr url; + nsCOMPtr mailboxurl; nsresult rv = NS_OK; NS_LOCK_INSTANCE(); nsMailboxAction mailboxAction = nsMailboxActionMoveMessage; - rv = PrepareMessageUrl(aSrcMailboxURI, aUrlListener, mailboxAction, getter_AddRefs(url)); + rv = PrepareMessageUrl(aSrcMailboxURI, aUrlListener, mailboxAction, getter_AddRefs(mailboxurl)); - if (NS_SUCCEEDED(rv)) + if (NS_SUCCEEDED(rv) && mailboxurl) { + if (!moveMessage) - url->SetMailboxAction(nsMailboxActionCopyMessage); - url->SetMailboxCopyHandler(aMailboxCopyHandler); + mailboxurl->SetMailboxAction(nsMailboxActionCopyMessage); + mailboxurl->SetMailboxCopyHandler(aMailboxCopyHandler); + nsCOMPtr url = do_QueryInterface(mailboxurl); rv = RunMailboxUrl(url); } if (aURL) - { - *aURL = url; - NS_IF_ADDREF(*aURL); - } + mailboxurl->QueryInterface(nsIURL::GetIID(), (void **) aURL); NS_UNLOCK_INSTANCE(); @@ -157,20 +158,19 @@ nsresult nsMailboxService::DisplayMessage(const char* aMessageURI, nsIURL ** aURL) { nsresult rv = NS_OK; - nsCOMPtr url; + nsCOMPtr mailboxurl; NS_LOCK_INSTANCE(); - rv = PrepareMessageUrl(aMessageURI, aUrlListener, nsMailboxActionDisplayMessage, getter_AddRefs(url)); + rv = PrepareMessageUrl(aMessageURI, aUrlListener, nsMailboxActionDisplayMessage, getter_AddRefs(mailboxurl)); if (NS_SUCCEEDED(rv)) + { + nsCOMPtr url = do_QueryInterface(mailboxurl); rv = RunMailboxUrl(url, aDisplayConsumer); + } if (aURL) - { - *aURL = url; - NS_IF_ADDREF(*aURL); - } - + mailboxurl->QueryInterface(nsIURL::GetIID(), (void **) aURL); NS_UNLOCK_INSTANCE(); return rv; @@ -180,22 +180,20 @@ NS_IMETHODIMP nsMailboxService::SaveMessageToDisk(const char *aMessageURI, nsIFi PRBool aAppendToFile, nsIUrlListener *aUrlListener, nsIURL **aURL) { nsresult rv = NS_OK; - nsCOMPtr url; + nsCOMPtr mailboxurl; NS_LOCK_INSTANCE(); - rv = PrepareMessageUrl(aMessageURI, aUrlListener, nsMailboxActionSaveMessageToDisk, getter_AddRefs(url)); + rv = PrepareMessageUrl(aMessageURI, aUrlListener, nsMailboxActionSaveMessageToDisk, getter_AddRefs(mailboxurl)); if (NS_SUCCEEDED(rv)) { - url->SetMessageFile(aFile); + mailboxurl->SetMessageFile(aFile); + nsCOMPtr url = do_QueryInterface(mailboxurl); rv = RunMailboxUrl(url); } if (aURL) - { - *aURL = url; - NS_IF_ADDREF(*aURL); - } + mailboxurl->QueryInterface(nsIURL::GetIID(), (void **) aURL); NS_UNLOCK_INSTANCE(); return rv; @@ -214,7 +212,7 @@ nsresult nsMailboxService::DisplayMessageNumber(const char *url, // Takes a mailbox url, this method creates a protocol instance and loads the url // into the protocol instance. -nsresult nsMailboxService::RunMailboxUrl(nsIMailboxUrl * aMailboxUrl, nsISupports * aDisplayConsumer) +nsresult nsMailboxService::RunMailboxUrl(nsIURL * aMailboxUrl, nsISupports * aDisplayConsumer) { // create a protocol instance to run the url.. nsresult rv = NS_OK; @@ -245,8 +243,6 @@ nsresult nsMailboxService::PrepareMessageUrl(const char * aSrcMsgMailboxURI, nsI if (NS_SUCCEEDED(rv) && aMailboxUrl && *aMailboxUrl) { - nsIMailboxUrl * url = *aMailboxUrl; // no need to ref cnt.. - // okay now generate the url string char * urlSpec; nsAutoString folderURI (eOneByte); @@ -261,11 +257,12 @@ nsresult nsMailboxService::PrepareMessageUrl(const char * aSrcMsgMailboxURI, nsI // set up the url spec and initialize the url with it. nsFilePath filePath(folderPath); // convert to file url representation... urlSpec = PR_smprintf("mailboxMessage://%s?number=%d", (const char *) filePath, msgKey); + nsCOMPtr url = do_QueryInterface(*aMailboxUrl); url->SetSpec(urlSpec); PR_FREEIF(urlSpec); // set up the mailbox action - url->SetMailboxAction(aMailboxAction); + (*aMailboxUrl)->SetMailboxAction(aMailboxAction); // set up the url listener if (aUrlListener) diff --git a/mailnews/local/src/nsMailboxService.h b/mailnews/local/src/nsMailboxService.h index bb7c7a24c8ce..187b6635ac44 100644 --- a/mailnews/local/src/nsMailboxService.h +++ b/mailnews/local/src/nsMailboxService.h @@ -83,7 +83,7 @@ protected: nsresult PrepareMessageUrl(const char * aSrcMsgMailboxURI, nsIUrlListener * aUrlListener, nsMailboxAction aMailboxAction, nsIMailboxUrl ** aMailboxUrl); - nsresult RunMailboxUrl(nsIMailboxUrl * aMailboxUrl, nsISupports * aDisplayConsumer = nsnull); + nsresult RunMailboxUrl(nsIURL * aMailboxUrl, nsISupports * aDisplayConsumer = nsnull); }; #endif /* nsMailboxService_h___ */ diff --git a/mailnews/local/src/nsParseMailbox.cpp b/mailnews/local/src/nsParseMailbox.cpp index 6b8c066b8a57..62c09fd418bd 100644 --- a/mailnews/local/src/nsParseMailbox.cpp +++ b/mailnews/local/src/nsParseMailbox.cpp @@ -73,7 +73,7 @@ NS_IMETHODIMP nsMsgMailboxParser::OnStartBinding(nsIURL* aURL, const char *aCont // okay, now fill in our event sinks...Note that each getter ref counts before // it returns the interface to us...we'll release when we are done const char *fileName; - runningUrl->GetFile(&fileName); + aURL->GetFile(&fileName); if (fileName) { nsFilePath dbPath(fileName);