mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 08:12:05 +00:00
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).
This commit is contained in:
parent
0250d12095
commit
6835a27780
@ -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 <nsIURL> 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 <nsIURL> 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 <nsIMsgMailNewsUrl> url = do_QueryInterface(m_runningUrl);
|
||||
url->SetUrlState(PR_FALSE, NS_OK);
|
||||
m_nextState = MAILBOX_FREE;
|
||||
}
|
||||
break;
|
||||
|
||||
case MAILBOX_FREE:
|
||||
|
@ -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<nsIMailboxUrl> url;
|
||||
nsCOMPtr<nsIMailboxUrl> 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<nsIMsgMailNewsUrl> 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<nsIMailboxUrl> url;
|
||||
nsCOMPtr<nsIMailboxUrl> 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<nsIURL> 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<nsIMailboxUrl> url;
|
||||
nsCOMPtr<nsIMailboxUrl> 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<nsIURL> 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<nsIMailboxUrl> url;
|
||||
nsCOMPtr<nsIMailboxUrl> 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<nsIURL> 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 <nsIMsgMailNewsUrl> 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)
|
||||
|
@ -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___ */
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user