зеркало из https://github.com/mozilla/gecko-dev.git
Landing imap integration with the memory cache!! *Yeah*
Bug #23491 --> add memory cache support for imap urls. Bug #23325 --> fix a crasher...only try to find a folder if we have a folder name r=bienvenu
This commit is contained in:
Родитель
69cc1d4e10
Коммит
df476382d9
|
@ -49,6 +49,12 @@
|
||||||
#include "nsIPipe.h"
|
#include "nsIPipe.h"
|
||||||
#include "nsIMsgFolder.h"
|
#include "nsIMsgFolder.h"
|
||||||
#include "nsImapStringBundle.h"
|
#include "nsImapStringBundle.h"
|
||||||
|
|
||||||
|
// for the memory cache...
|
||||||
|
#include "nsINetDataCacheManager.h"
|
||||||
|
#include "nsINetDataCache.h"
|
||||||
|
#include "nsICachedNetData.h"
|
||||||
|
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
PRLogModuleInfo *IMAP;
|
PRLogModuleInfo *IMAP;
|
||||||
|
|
||||||
|
@ -1128,8 +1134,6 @@ PRBool nsImapProtocol::ProcessCurrentURL()
|
||||||
if (m_runningUrl && m_imapServerSink)
|
if (m_runningUrl && m_imapServerSink)
|
||||||
m_imapServerSink->RemoveChannelFromUrl(mailnewsurl, NS_OK);
|
m_imapServerSink->RemoveChannelFromUrl(mailnewsurl, NS_OK);
|
||||||
|
|
||||||
m_runningUrl->RemoveChannel(NS_OK);
|
|
||||||
|
|
||||||
// release this by hand so that we can load the next queued url without thinking
|
// release this by hand so that we can load the next queued url without thinking
|
||||||
// this connection is busy running a url.
|
// this connection is busy running a url.
|
||||||
m_runningUrl = null_nsCOMPtr();
|
m_runningUrl = null_nsCOMPtr();
|
||||||
|
@ -2062,34 +2066,35 @@ void nsImapProtocol::BeginMessageDownLoad(
|
||||||
m_imapMailFolderSink->SetupHeaderParseStream(this, total_message_size, content_type, nsnull);
|
m_imapMailFolderSink->SetupHeaderParseStream(this, total_message_size, content_type, nsnull);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if we have a mock channel, that means we have a channel listener who wants the
|
|
||||||
// message. So set up a pipe. We'll write the messsage into one end of the pipe
|
// if we have a mock channel, that means we have a channel listener who wants the
|
||||||
// and they will read it out of the other end.
|
// message. So set up a pipe. We'll write the messsage into one end of the pipe
|
||||||
else if (m_channelListener)
|
// and they will read it out of the other end.
|
||||||
{
|
else if (m_channelListener)
|
||||||
// create a pipe to pump the message into...the output will go to whoever
|
{
|
||||||
// is consuming the message display
|
// create a pipe to pump the message into...the output will go to whoever
|
||||||
nsresult rv;
|
// is consuming the message display
|
||||||
rv = NS_NewPipe(getter_AddRefs(m_channelInputStream), getter_AddRefs(m_channelOutputStream));
|
nsresult rv;
|
||||||
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_NewPipe failed!");
|
rv = NS_NewPipe(getter_AddRefs(m_channelInputStream), getter_AddRefs(m_channelOutputStream));
|
||||||
}
|
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_NewPipe failed!");
|
||||||
// else, if we are saving the message to disk!
|
}
|
||||||
else if (m_imapMessageSink /* && m_imapAction == nsIImapUrl::nsImapSaveMessageToDisk */)
|
// else, if we are saving the message to disk!
|
||||||
{
|
else if (m_imapMessageSink /* && m_imapAction == nsIImapUrl::nsImapSaveMessageToDisk */)
|
||||||
nsCOMPtr<nsIFileSpec> fileSpec;
|
{
|
||||||
PRBool addDummyEnvelope = PR_TRUE;
|
nsCOMPtr<nsIFileSpec> fileSpec;
|
||||||
nsCOMPtr<nsIMsgMessageUrl> msgurl = do_QueryInterface(m_runningUrl);
|
PRBool addDummyEnvelope = PR_TRUE;
|
||||||
msgurl->GetMessageFile(getter_AddRefs(fileSpec));
|
nsCOMPtr<nsIMsgMessageUrl> msgurl = do_QueryInterface(m_runningUrl);
|
||||||
msgurl->GetAddDummyEnvelope(&addDummyEnvelope);
|
msgurl->GetMessageFile(getter_AddRefs(fileSpec));
|
||||||
|
msgurl->GetAddDummyEnvelope(&addDummyEnvelope);
|
||||||
// m_imapMessageSink->SetupMsgWriteStream(fileSpec, addDummyEnvelope);
|
// m_imapMessageSink->SetupMsgWriteStream(fileSpec, addDummyEnvelope);
|
||||||
nsXPIDLCString nativePath;
|
nsXPIDLCString nativePath;
|
||||||
NS_ASSERTION(fileSpec, "no fileSpec!");
|
NS_ASSERTION(fileSpec, "no fileSpec!");
|
||||||
if (fileSpec)
|
if (fileSpec)
|
||||||
{
|
{
|
||||||
fileSpec->GetNativePath(getter_Copies(nativePath));
|
fileSpec->GetNativePath(getter_Copies(nativePath));
|
||||||
m_imapMessageSink->SetupMsgWriteStream(nativePath, addDummyEnvelope);
|
m_imapMessageSink->SetupMsgWriteStream(nativePath, addDummyEnvelope);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
HandleMemoryFailure();
|
HandleMemoryFailure();
|
||||||
|
@ -6254,13 +6259,18 @@ NS_IMPL_ISUPPORTS2(nsImapMockChannel, nsIImapMockChannel, nsIChannel)
|
||||||
|
|
||||||
nsImapMockChannel::nsImapMockChannel()
|
nsImapMockChannel::nsImapMockChannel()
|
||||||
{
|
{
|
||||||
NS_INIT_REFCNT();
|
NS_INIT_REFCNT();
|
||||||
m_channelContext = nsnull;
|
m_channelContext = nsnull;
|
||||||
m_cancelled = PR_FALSE;
|
m_cancelled = PR_FALSE;
|
||||||
|
mOwningRefToUrl = PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsImapMockChannel::~nsImapMockChannel()
|
nsImapMockChannel::~nsImapMockChannel()
|
||||||
{
|
{
|
||||||
|
// only release the url if we have a owning ref on it...
|
||||||
|
// this only occurrs when we are loading the url from the cache...
|
||||||
|
if (mOwningRefToUrl && m_url)
|
||||||
|
NS_RELEASE(m_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -6341,12 +6351,60 @@ NS_IMETHODIMP nsImapMockChannel::AsyncOpen(nsIStreamObserver *observer, nsISuppo
|
||||||
|
|
||||||
NS_IMETHODIMP nsImapMockChannel::AsyncRead(PRUint32 startPosition, PRInt32 readCount, nsISupports *ctxt, nsIStreamListener *listener)
|
NS_IMETHODIMP nsImapMockChannel::AsyncRead(PRUint32 startPosition, PRInt32 readCount, nsISupports *ctxt, nsIStreamListener *listener)
|
||||||
{
|
{
|
||||||
|
nsCOMPtr<nsICachedNetData> cacheEntry;
|
||||||
|
PRUint32 contentLength = 0;
|
||||||
|
PRBool partialFlag = PR_FALSE;
|
||||||
|
|
||||||
// set the stream listener and then load the url
|
// set the stream listener and then load the url
|
||||||
m_channelContext = ctxt;
|
m_channelContext = ctxt;
|
||||||
m_channelListener = listener;
|
m_channelListener = listener;
|
||||||
|
|
||||||
// the following load group code is completely bogus....
|
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
|
|
||||||
|
nsCOMPtr<nsIImapUrl> imapUrl = do_QueryInterface(m_url);
|
||||||
|
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(m_url, &rv);
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
// look to see if this url should be added to the memory cache..
|
||||||
|
PRBool useMemoryCache = PR_FALSE;
|
||||||
|
mailnewsUrl->GetAddToMemoryCache(&useMemoryCache);
|
||||||
|
nsCOMPtr<nsINetDataCacheManager> cacheManager = do_GetService(NS_NETWORK_CACHE_MANAGER_PROGID, &rv);
|
||||||
|
if (NS_SUCCEEDED(rv) && cacheManager)
|
||||||
|
{
|
||||||
|
// Retrieve an existing cache entry or create a new one if none exists for the
|
||||||
|
// given URL.
|
||||||
|
nsXPIDLCString urlCString;
|
||||||
|
// eventually we are going to want to use the url spec - the query/ref part 'cause that doesn't
|
||||||
|
// distinguish urls.......
|
||||||
|
m_url->GetSpec(getter_Copies(urlCString));
|
||||||
|
// for now, truncate of the query part so we don't duplicate urls in the cache...
|
||||||
|
char * anchor = PL_strrchr(urlCString, '?');
|
||||||
|
if (anchor)
|
||||||
|
*anchor = '\0';
|
||||||
|
rv = cacheManager->GetCachedNetData(urlCString, 0, 0, nsINetDataCacheManager::BYPASS_PERSISTENT_CACHE,
|
||||||
|
getter_AddRefs(cacheEntry));
|
||||||
|
if (NS_SUCCEEDED(rv) && cacheEntry)
|
||||||
|
{
|
||||||
|
PRBool updateInProgress;
|
||||||
|
cacheEntry->GetPartialFlag(&partialFlag);
|
||||||
|
cacheEntry->GetUpdateInProgress(&updateInProgress);
|
||||||
|
cacheEntry->GetStoredContentLength(&contentLength);
|
||||||
|
// only try to update the cache entry if it isn't being used.
|
||||||
|
// and we want to write to the memory cache.
|
||||||
|
if (!updateInProgress && useMemoryCache)
|
||||||
|
{
|
||||||
|
// now we need to figure out if the entry is new / or partially unfinished...
|
||||||
|
// this determines if we are going to USE the cache entry for reading the data
|
||||||
|
// vs. if we need to write data into the cache entry...
|
||||||
|
if (!contentLength || partialFlag)
|
||||||
|
// we're going to fill up this cache entry,
|
||||||
|
rv = cacheEntry->InterceptAsyncRead(listener, 0, getter_AddRefs(m_channelListener));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// regardless as to whether we are inserting into the cache or not, proceed with
|
||||||
|
// setting up the load group!
|
||||||
if (m_loadGroup)
|
if (m_loadGroup)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsILoadGroupListenerFactory> factory;
|
nsCOMPtr<nsILoadGroupListenerFactory> factory;
|
||||||
|
@ -6363,10 +6421,28 @@ NS_IMETHODIMP nsImapMockChannel::AsyncRead(PRUint32 startPosition, PRInt32 readC
|
||||||
}
|
}
|
||||||
} // if aLoadGroup
|
} // if aLoadGroup
|
||||||
|
|
||||||
|
// now, determine if we should be loading from the cache or if we have
|
||||||
|
// to really load the msg with a protocol connection...
|
||||||
|
if (cacheEntry && contentLength > 0 && !partialFlag)
|
||||||
|
{
|
||||||
|
nsCOMPtr<nsIChannel> cacheChannel;
|
||||||
|
rv = cacheEntry->NewChannel(m_loadGroup, this, getter_AddRefs(cacheChannel));
|
||||||
|
if (NS_SUCCEEDED(rv))
|
||||||
|
{
|
||||||
|
// turn around and make our ref on m_url an owning ref...and force the url to remove
|
||||||
|
// its reference on the mock channel...this is a complicated texas two step to solve
|
||||||
|
// a nasty reference counting problem...
|
||||||
|
NS_IF_ADDREF(m_url);
|
||||||
|
mOwningRefToUrl = PR_TRUE;
|
||||||
|
imapUrl->SetMockChannel(nsnull);
|
||||||
|
|
||||||
|
rv = cacheChannel->AsyncRead(startPosition, readCount, m_channelContext, m_channelListener);
|
||||||
|
if (NS_SUCCEEDED(rv)) // ONLY if we succeeded in actually starting the read should we return
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// loading the url consists of asking the server to add the url to it's imap event queue....
|
// loading the url consists of asking the server to add the url to it's imap event queue....
|
||||||
nsCOMPtr<nsIImapUrl> imapUrl = do_QueryInterface(m_url);
|
|
||||||
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(m_url, &rv);
|
|
||||||
if (NS_FAILED(rv)) return rv;
|
|
||||||
nsCOMPtr<nsIMsgIncomingServer> server;
|
nsCOMPtr<nsIMsgIncomingServer> server;
|
||||||
rv = mailnewsUrl->GetServer(getter_AddRefs(server));
|
rv = mailnewsUrl->GetServer(getter_AddRefs(server));
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
|
@ -552,21 +552,25 @@ class nsImapMockChannel : public nsIImapMockChannel
|
||||||
public:
|
public:
|
||||||
|
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
NS_DECL_NSIIMAPMOCKCHANNEL
|
NS_DECL_NSIIMAPMOCKCHANNEL
|
||||||
NS_DECL_NSICHANNEL
|
NS_DECL_NSICHANNEL
|
||||||
NS_DECL_NSIREQUEST
|
NS_DECL_NSIREQUEST
|
||||||
|
|
||||||
nsImapMockChannel();
|
nsImapMockChannel();
|
||||||
virtual ~nsImapMockChannel();
|
virtual ~nsImapMockChannel();
|
||||||
|
static nsresult Create (const nsIID& iid, void **result);
|
||||||
static nsresult Create (const nsIID& iid, void **result);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// we CANNOT own the uri else we will have a circular ref count
|
// we CANNOT own the uri else we will have a circular ref count
|
||||||
// because the imap uri ref counts us....so don't think about
|
// because the imap uri ref counts us....so don't think about
|
||||||
// turning this into a com ptr!
|
// turning this into a com ptr! HOWEVER, because life is complicated,
|
||||||
nsCOMPtr<nsIURI> m_originalUrl;
|
// there is one scenario where we need to own the url....and that
|
||||||
|
// is when we are loading the url from the cache....so in that case,
|
||||||
|
// we'll turn around and make our m_url ptr an owning reference... *sigh*
|
||||||
nsIURI * m_url;
|
nsIURI * m_url;
|
||||||
|
PRBool mOwningRefToUrl;
|
||||||
|
|
||||||
|
nsCOMPtr<nsIURI> m_originalUrl;
|
||||||
nsCOMPtr<nsILoadGroup> m_loadGroup;
|
nsCOMPtr<nsILoadGroup> m_loadGroup;
|
||||||
nsCOMPtr<nsIStreamListener> m_channelListener;
|
nsCOMPtr<nsIStreamListener> m_channelListener;
|
||||||
// non owning ref of the context in order to fix a circular ref count
|
// non owning ref of the context in order to fix a circular ref count
|
||||||
|
|
|
@ -215,10 +215,10 @@ NS_IMETHODIMP nsImapService::GetUrlForUri(const char *aMessageURI, nsIURI **aURL
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIImapUrl> imapUrl;
|
nsCOMPtr<nsIImapUrl> imapUrl;
|
||||||
nsCAutoString urlSpec;
|
nsCAutoString urlSpec;
|
||||||
PRUnichar hierarchySeparator = '/';
|
PRUnichar hierarchySeparator = '/';
|
||||||
rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), folder, nsnull, urlSpec, hierarchySeparator);
|
rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), folder, nsnull, urlSpec, hierarchySeparator);
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
imapUrl->SetImapMessageSink(imapMessageSink);
|
imapUrl->SetImapMessageSink(imapMessageSink);
|
||||||
|
|
||||||
nsCOMPtr<nsIURI> url = do_QueryInterface(imapUrl);
|
nsCOMPtr<nsIURI> url = do_QueryInterface(imapUrl);
|
||||||
nsXPIDLCString currentSpec;
|
nsXPIDLCString currentSpec;
|
||||||
|
@ -264,8 +264,10 @@ NS_IMETHODIMP nsImapService::DisplayMessage(const char* aMessageURI,
|
||||||
PRUnichar hierarchySeparator = '/';
|
PRUnichar hierarchySeparator = '/';
|
||||||
rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), folder, aUrlListener, urlSpec, hierarchySeparator);
|
rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), folder, aUrlListener, urlSpec, hierarchySeparator);
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
nsCOMPtr<nsIMsgMailNewsUrl> msgurl (do_QueryInterface(imapUrl));
|
nsCOMPtr<nsIMsgMailNewsUrl> msgurl (do_QueryInterface(imapUrl));
|
||||||
msgurl->SetMsgWindow(aMsgWindow);
|
msgurl->SetMsgWindow(aMsgWindow);
|
||||||
|
// whenever we are displaying a message, we want to add it to the memory cache..
|
||||||
|
msgurl->SetAddToMemoryCache(PR_TRUE);
|
||||||
imapUrl->AddChannelToLoadGroup();
|
imapUrl->AddChannelToLoadGroup();
|
||||||
rv = FetchMessage(imapUrl, nsIImapUrl::nsImapMsgFetch, folder, imapMessageSink,
|
rv = FetchMessage(imapUrl, nsIImapUrl::nsImapMsgFetch, folder, imapMessageSink,
|
||||||
aURL, aDisplayConsumer, msgKey, PR_TRUE);
|
aURL, aDisplayConsumer, msgKey, PR_TRUE);
|
||||||
|
@ -295,7 +297,7 @@ nsImapService::CopyMessage(const char * aSrcMailboxURI, nsIStreamListener *
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIImapUrl> imapUrl;
|
nsCOMPtr<nsIImapUrl> imapUrl;
|
||||||
nsCAutoString urlSpec;
|
nsCAutoString urlSpec;
|
||||||
PRUnichar hierarchySeparator = '/';
|
PRUnichar hierarchySeparator = '/';
|
||||||
rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), folder, aUrlListener, urlSpec, hierarchySeparator);
|
rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), folder, aUrlListener, urlSpec, hierarchySeparator);
|
||||||
|
|
||||||
// now try to download the message
|
// now try to download the message
|
||||||
|
@ -428,7 +430,7 @@ NS_IMETHODIMP nsImapService::SaveMessageToDisk(const char *aMessageURI,
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
nsCAutoString urlSpec;
|
nsCAutoString urlSpec;
|
||||||
PRUnichar hierarchySeparator = '/';
|
PRUnichar hierarchySeparator = '/';
|
||||||
rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), folder, aUrlListener, urlSpec, hierarchySeparator);
|
rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), folder, aUrlListener, urlSpec, hierarchySeparator);
|
||||||
if (NS_SUCCEEDED(rv))
|
if (NS_SUCCEEDED(rv))
|
||||||
{
|
{
|
||||||
|
@ -527,10 +529,10 @@ nsImapService::FetchMessage(nsIImapUrl * aImapUrl,
|
||||||
if (NS_SUCCEEDED(rv) && aStreamListener)
|
if (NS_SUCCEEDED(rv) && aStreamListener)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIChannel> aChannel;
|
nsCOMPtr<nsIChannel> aChannel;
|
||||||
nsCOMPtr<nsILoadGroup> aLoadGroup;
|
nsCOMPtr<nsILoadGroup> aLoadGroup;
|
||||||
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(aImapUrl, &rv);
|
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(aImapUrl, &rv);
|
||||||
if (NS_SUCCEEDED(rv) && mailnewsUrl)
|
if (NS_SUCCEEDED(rv) && mailnewsUrl)
|
||||||
mailnewsUrl->GetLoadGroup(getter_AddRefs(aLoadGroup));
|
mailnewsUrl->GetLoadGroup(getter_AddRefs(aLoadGroup));
|
||||||
|
|
||||||
rv = NewChannel(nsnull, url, aLoadGroup, nsnull, nsIChannel::LOAD_NORMAL,
|
rv = NewChannel(nsnull, url, aLoadGroup, nsnull, nsIChannel::LOAD_NORMAL,
|
||||||
nsnull, 0, 0, getter_AddRefs(aChannel));
|
nsnull, 0, 0, getter_AddRefs(aChannel));
|
||||||
|
@ -589,28 +591,28 @@ nsImapService::CreateStartOfImapUrl(nsIImapUrl ** imapUrl,
|
||||||
imapUrl);
|
imapUrl);
|
||||||
if (NS_SUCCEEDED(rv) && imapUrl)
|
if (NS_SUCCEEDED(rv) && imapUrl)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(*imapUrl, &rv);
|
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(*imapUrl, &rv);
|
||||||
if (NS_SUCCEEDED(rv) && mailnewsUrl && aUrlListener)
|
if (NS_SUCCEEDED(rv) && mailnewsUrl && aUrlListener)
|
||||||
mailnewsUrl->RegisterListener(aUrlListener);
|
mailnewsUrl->RegisterListener(aUrlListener);
|
||||||
|
|
||||||
urlSpec = "imap://";
|
urlSpec = "imap://";
|
||||||
urlSpec.Append(username);
|
urlSpec.Append(username);
|
||||||
urlSpec.Append('@');
|
urlSpec.Append('@');
|
||||||
urlSpec.Append(hostname);
|
urlSpec.Append(hostname);
|
||||||
urlSpec.Append(':');
|
urlSpec.Append(':');
|
||||||
urlSpec.Append("143"); // mscott -- i know this is bogus...i'm i a hurry =)
|
urlSpec.Append("143"); // mscott -- i know this is bogus...i'm i a hurry =)
|
||||||
|
|
||||||
// *** jefft - force to parse the urlSpec in order to search for
|
// *** jefft - force to parse the urlSpec in order to search for
|
||||||
// the correct incoming server
|
// the correct incoming server
|
||||||
// mscott - this cast to a char * is okay...there's a bug in the XPIDL
|
// mscott - this cast to a char * is okay...there's a bug in the XPIDL
|
||||||
// compiler that is preventing in string parameters from showing up as
|
// compiler that is preventing in string parameters from showing up as
|
||||||
// const char *. hopefully they will fix it soon.
|
// const char *. hopefully they will fix it soon.
|
||||||
rv = mailnewsUrl->SetSpec((char *) urlSpec.GetBuffer());
|
rv = mailnewsUrl->SetSpec((char *) urlSpec.GetBuffer());
|
||||||
|
|
||||||
hierarchyDelimiter = kOnlineHierarchySeparatorUnknown;
|
hierarchyDelimiter = kOnlineHierarchySeparatorUnknown;
|
||||||
nsCOMPtr <nsIMsgImapMailFolder> imapFolder = do_QueryInterface(aImapMailFolder);
|
nsCOMPtr <nsIMsgImapMailFolder> imapFolder = do_QueryInterface(aImapMailFolder);
|
||||||
if (imapFolder)
|
if (imapFolder)
|
||||||
imapFolder->GetHierarchyDelimiter(&hierarchyDelimiter);
|
imapFolder->GetHierarchyDelimiter(&hierarchyDelimiter);
|
||||||
}
|
}
|
||||||
|
|
||||||
PR_FREEIF(hostname);
|
PR_FREEIF(hostname);
|
||||||
|
@ -2297,58 +2299,57 @@ NS_IMETHODIMP nsImapService::GetDefaultPort(PRInt32 *aDefaultPort)
|
||||||
|
|
||||||
NS_IMETHODIMP nsImapService::NewURI(const char *aSpec, nsIURI *aBaseURI, nsIURI **_retval)
|
NS_IMETHODIMP nsImapService::NewURI(const char *aSpec, nsIURI *aBaseURI, nsIURI **_retval)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIImapUrl> aImapUrl;
|
nsCOMPtr<nsIImapUrl> aImapUrl;
|
||||||
nsresult rv = nsComponentManager::CreateInstance(kImapUrlCID, nsnull, NS_GET_IID(nsIImapUrl), getter_AddRefs(aImapUrl));
|
nsresult rv = nsComponentManager::CreateInstance(kImapUrlCID, nsnull, NS_GET_IID(nsIImapUrl), getter_AddRefs(aImapUrl));
|
||||||
if (NS_SUCCEEDED(rv))
|
if (NS_SUCCEEDED(rv))
|
||||||
|
{
|
||||||
|
// now extract lots of fun information...
|
||||||
|
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(aImapUrl);
|
||||||
|
nsCAutoString unescapedSpec = aSpec;
|
||||||
|
nsUnescape(unescapedSpec);
|
||||||
|
mailnewsUrl->SetSpec((char *) unescapedSpec); // set the url spec...
|
||||||
|
|
||||||
|
nsXPIDLCString userName;
|
||||||
|
nsXPIDLCString hostName;
|
||||||
|
nsXPIDLCString folderName;
|
||||||
|
|
||||||
|
// extract the user name and host name information...
|
||||||
|
rv = mailnewsUrl->GetHost(getter_Copies(hostName));
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
rv = mailnewsUrl->GetPreHost(getter_Copies(userName));
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
// if we can't get a folder name out of the url then I think this is an error
|
||||||
|
aImapUrl->CreateCanonicalSourceFolderPathString(getter_Copies(folderName));
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
nsCOMPtr<nsIMsgIncomingServer> aServer;
|
||||||
|
rv = nsGetImapServer(userName, hostName, getter_AddRefs(aServer));
|
||||||
|
// if we can't extract the imap server from this url then give up!!!
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
// now try to get the folder in question...
|
||||||
|
nsCOMPtr<nsIFolder> aRootFolder;
|
||||||
|
aServer->GetRootFolder(getter_AddRefs(aRootFolder));
|
||||||
|
|
||||||
|
if (aRootFolder && folderName && (* ((const char *) folderName)) )
|
||||||
{
|
{
|
||||||
// now extract lots of fun information...
|
nsCOMPtr<nsIFolder> aFolder;
|
||||||
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(aImapUrl);
|
rv = aRootFolder->FindSubFolder(folderName, getter_AddRefs(aFolder));
|
||||||
nsCAutoString unescapedSpec = aSpec;
|
if (NS_SUCCEEDED(rv))
|
||||||
nsUnescape(unescapedSpec);
|
{
|
||||||
mailnewsUrl->SetSpec((char *) unescapedSpec); // set the url spec...
|
nsCOMPtr<nsIImapMessageSink> msgSink = do_QueryInterface(aFolder);
|
||||||
|
rv = aImapUrl->SetImapMessageSink(msgSink);
|
||||||
|
|
||||||
nsXPIDLCString userName;
|
nsCOMPtr<nsIMsgFolder> msgFolder = do_QueryInterface(aFolder);
|
||||||
nsXPIDLCString hostName;
|
rv = SetImapUrlSink(msgFolder, aImapUrl);
|
||||||
nsXPIDLCString folderName;
|
}
|
||||||
|
|
||||||
// extract the user name and host name information...
|
|
||||||
rv = mailnewsUrl->GetHost(getter_Copies(hostName));
|
|
||||||
if (NS_FAILED(rv)) return rv;
|
|
||||||
rv = mailnewsUrl->GetPreHost(getter_Copies(userName));
|
|
||||||
if (NS_FAILED(rv)) return rv;
|
|
||||||
// if we can't get a folder name out of the url then I think this is an error
|
|
||||||
aImapUrl->CreateCanonicalSourceFolderPathString(getter_Copies(folderName));
|
|
||||||
if (NS_FAILED(rv)) return rv;
|
|
||||||
|
|
||||||
nsCOMPtr<nsIMsgIncomingServer> aServer;
|
|
||||||
rv = nsGetImapServer(userName, hostName, getter_AddRefs(aServer));
|
|
||||||
// if we can't extract the imap server from this url then give up!!!
|
|
||||||
if (NS_FAILED(rv)) return rv;
|
|
||||||
|
|
||||||
// now try to get the folder in question...
|
|
||||||
nsCOMPtr<nsIFolder> aRootFolder;
|
|
||||||
aServer->GetRootFolder(getter_AddRefs(aRootFolder));
|
|
||||||
|
|
||||||
if (aRootFolder)
|
|
||||||
{
|
|
||||||
nsCOMPtr<nsIFolder> aFolder;
|
|
||||||
rv = aRootFolder->FindSubFolder(folderName, getter_AddRefs(aFolder));
|
|
||||||
if (NS_SUCCEEDED(rv))
|
|
||||||
{
|
|
||||||
nsCOMPtr<nsIImapMessageSink> msgSink = do_QueryInterface(aFolder);
|
|
||||||
rv = aImapUrl->SetImapMessageSink(msgSink);
|
|
||||||
|
|
||||||
nsCOMPtr<nsIMsgFolder> msgFolder = do_QueryInterface(aFolder);
|
|
||||||
rv = SetImapUrlSink(msgFolder, aImapUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// we got an imap url, so be sure to return it...
|
|
||||||
aImapUrl->QueryInterface(NS_GET_IID(nsIURI), (void **) _retval);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return rv;
|
// we got an imap url, so be sure to return it...
|
||||||
|
aImapUrl->QueryInterface(NS_GET_IID(nsIURI), (void **) _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsImapService::NewChannel(const char *verb,
|
NS_IMETHODIMP nsImapService::NewChannel(const char *verb,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче