mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 06:43:32 +00:00
fixed bug 13574 -- use stream converter instead of temp file for reply quoting
This commit is contained in:
parent
664a5ace95
commit
a46c88cc36
@ -17,18 +17,22 @@
|
||||
*/
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIStreamListener.idl"
|
||||
#include "nsIChannel.idl"
|
||||
|
||||
%{ C++
|
||||
%}
|
||||
|
||||
interface nsIMimeStreamConverterListener;
|
||||
|
||||
[scriptable, uuid(1C7ABF0C-21E5-11d3-8EF1-00A024A7D144)]
|
||||
|
||||
|
||||
interface nsIMsgQuote : nsISupports {
|
||||
/*
|
||||
* This is the primary interface for quoting a particular message specified
|
||||
* by a URI
|
||||
*/
|
||||
void QuoteMessage(in wstring msgURI, in boolean quoteHeaders, in nsIStreamListener aStreamListener);
|
||||
void QuoteMessage(in wstring msgURI, in boolean quoteHeaders, in
|
||||
nsIStreamListener aStreamListener);
|
||||
readonly attribute nsIMimeStreamConverterListener quoteListener;
|
||||
readonly attribute nsIChannel quoteChannel;
|
||||
};
|
||||
|
||||
|
@ -24,9 +24,8 @@
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIStreamConverter.h"
|
||||
#include "nsIStreamConverterService.h"
|
||||
#include "nsIMimeStreamConverter.h"
|
||||
#include "nsFileStream.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsMimeTypes.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
@ -37,12 +36,23 @@
|
||||
#include "nsMsgUtils.h"
|
||||
#include "nsMsgDeliveryListener.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsMsgMimeCID.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsMsgCompose.h"
|
||||
#include "nsMsgMailNewsUrl.h"
|
||||
#include "nsIImapUrl.h"
|
||||
#include "nsIMailboxUrl.h"
|
||||
#include "nsINntpUrl.h"
|
||||
#include "nsMsgNewsCID.h"
|
||||
#include "nsMsgLocalCID.h"
|
||||
#include "nsMsgBaseCID.h"
|
||||
#include "nsMsgImapCID.h"
|
||||
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
static NS_DEFINE_CID(kIStreamConverterServiceCID, NS_STREAMCONVERTERSERVICE_CID);
|
||||
static NS_DEFINE_CID(kImapUrlCID, NS_IMAPURL_CID);
|
||||
static NS_DEFINE_CID(kCMailboxUrl, NS_MAILBOXURL_CID);
|
||||
static NS_DEFINE_CID(kCNntpUrlCID, NS_NNTPURL_CID);
|
||||
static NS_DEFINE_CID(kStreamConverterCID, NS_MAILNEWS_MIME_STREAM_CONVERTER_CID);
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsMsgQuoteListener, nsCOMTypeInfo<nsIMimeStreamConverterListener>::GetIID())
|
||||
@ -95,8 +105,6 @@ nsMsgQuote::nsMsgQuote()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
mTmpFileSpec = nsnull;
|
||||
mTmpIFileSpec = nsnull;
|
||||
mURI = nsnull;
|
||||
mMessageService = nsnull;
|
||||
mQuoteHeaders = PR_FALSE;
|
||||
@ -137,204 +145,45 @@ NS_NewMsgQuote(const nsIID &aIID, void ** aInstancePtrResult)
|
||||
}
|
||||
|
||||
|
||||
// stream converter
|
||||
static NS_DEFINE_CID(kStreamConverterCID, NS_MAILNEWS_MIME_STREAM_CONVERTER_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// THIS IS A TEMPORARY CLASS THAT MAKES A DISK FILE LOOK LIKE A nsIInputStream
|
||||
// INTERFACE...this may already exist, but I didn't find it. Eventually, you would
|
||||
// just plugin a Necko stream when they are all rewritten to be new style streams
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
class FileInputStreamImpl : public nsIInputStream
|
||||
nsresult
|
||||
nsMsgQuote::CreateStartupUrl(char *uri, nsIURI** aUrl)
|
||||
{
|
||||
public:
|
||||
FileInputStreamImpl(void)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mBufLen = 0;
|
||||
mInFile = nsnull;
|
||||
}
|
||||
virtual ~FileInputStreamImpl(void)
|
||||
{
|
||||
if (mInFile) delete mInFile;
|
||||
}
|
||||
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIBaseStream interface
|
||||
NS_IMETHOD Close(void)
|
||||
{
|
||||
if (mInFile)
|
||||
mInFile->close();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIInputStream interface
|
||||
NS_IMETHOD Available(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = mBufLen;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* unsigned long Read (in charStar buf, in unsigned long count); */
|
||||
NS_IMETHOD Read(char * buf, PRUint32 count, PRUint32 *_retval)
|
||||
{
|
||||
nsCRT::memcpy(buf, mBuf, mBufLen);
|
||||
*_retval = mBufLen;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD OpenDiskFile(nsFileSpec fs);
|
||||
NS_IMETHOD PumpFileStream();
|
||||
|
||||
private:
|
||||
PRUint32 mBufLen;
|
||||
char mBuf[8192];
|
||||
nsIOFileStream *mInFile;
|
||||
};
|
||||
|
||||
nsresult
|
||||
FileInputStreamImpl::OpenDiskFile(nsFileSpec fs)
|
||||
{
|
||||
mInFile = new nsIOFileStream(fs);
|
||||
if (!mInFile)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
mInFile->seek(0);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
FileInputStreamImpl::PumpFileStream()
|
||||
{
|
||||
if (mInFile->eof())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mBufLen = mInFile->read(mBuf, sizeof(mBuf));
|
||||
if (mBufLen > 0)
|
||||
return NS_OK;
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(FileInputStreamImpl, nsCOMTypeInfo<nsIInputStream>::GetIID());
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// End of FileInputStreamImpl()
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult
|
||||
SaveQuoteMessageCompleteCallback(nsIURI *aURL, nsresult aExitCode, void *tagData)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (!tagData)
|
||||
{
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
nsMsgQuote *ptr = (nsMsgQuote *) tagData;
|
||||
if (ptr->mMessageService)
|
||||
{
|
||||
ReleaseMessageServiceFromURI(ptr->mURI, ptr->mMessageService);
|
||||
ptr->mMessageService = nsnull;
|
||||
}
|
||||
|
||||
/* mscott - the NS_BINDING_ABORTED is a hack to get around a problem I have
|
||||
with the necko code...it returns this and treats it as an error when
|
||||
it really isn't an error! I'm trying to get them to change this.
|
||||
*/
|
||||
if (NS_FAILED(aExitCode) && aExitCode != NS_BINDING_ABORTED)
|
||||
{
|
||||
NS_RELEASE(ptr);
|
||||
return aExitCode;
|
||||
}
|
||||
|
||||
// Create a mime parser (nsIStreamConverter)!
|
||||
nsCOMPtr<nsIStreamConverter> mimeParser;
|
||||
rv = nsComponentManager::CreateInstance(kStreamConverterCID,
|
||||
NULL, nsCOMTypeInfo<nsIStreamConverter>::GetIID(),
|
||||
(void **) getter_AddRefs(mimeParser));
|
||||
if (NS_FAILED(rv) || !mimeParser)
|
||||
{
|
||||
NS_RELEASE(ptr);
|
||||
printf("Failed to create MIME stream converter...\n");
|
||||
nsresult rv = NS_ERROR_NULL_POINTER;
|
||||
if (!uri || !*uri || !aUrl) return rv;
|
||||
*aUrl = nsnull;
|
||||
if (PL_strncasecmp(uri, "imap", 4) == 0)
|
||||
{
|
||||
nsCOMPtr<nsIImapUrl> imapUrl;
|
||||
rv = nsComponentManager::CreateInstance(kImapUrlCID, nsnull,
|
||||
nsIImapUrl::GetIID(),
|
||||
getter_AddRefs(imapUrl));
|
||||
if (NS_SUCCEEDED(rv) && imapUrl)
|
||||
rv = imapUrl->QueryInterface(nsCOMTypeInfo<nsIURI>::GetIID(),
|
||||
(void**) aUrl);
|
||||
}
|
||||
else if (PL_strncasecmp(uri, "mailbox", 7) == 0)
|
||||
{
|
||||
nsCOMPtr<nsIMailboxUrl> mailboxUrl;
|
||||
rv = nsComponentManager::CreateInstance(kCMailboxUrl, nsnull,
|
||||
nsIMailboxUrl::GetIID(),
|
||||
getter_AddRefs(mailboxUrl));
|
||||
if (NS_SUCCEEDED(rv) && mailboxUrl)
|
||||
rv = mailboxUrl->QueryInterface(nsCOMTypeInfo<nsIURI>::GetIID(),
|
||||
(void**) aUrl);
|
||||
}
|
||||
else if (PL_strncasecmp(uri, "news", 4) == 0)
|
||||
{
|
||||
nsCOMPtr<nsINntpUrl> nntpUrl;
|
||||
rv = nsComponentManager::CreateInstance(kCNntpUrlCID, nsnull,
|
||||
nsINntpUrl::GetIID(),
|
||||
getter_AddRefs(nntpUrl));
|
||||
if (NS_SUCCEEDED(rv) && nntpUrl)
|
||||
rv = nntpUrl->QueryInterface(nsCOMTypeInfo<nsIURI>::GetIID(),
|
||||
(void**) aUrl);
|
||||
}
|
||||
if (*aUrl)
|
||||
(*aUrl)->SetSpec(uri);
|
||||
return rv;
|
||||
}
|
||||
|
||||
// This is the producer stream that will deliver data from the disk file...
|
||||
// ...someday, we'll just get streams from Necko.
|
||||
// mscott --> the type for a nsCOMPtr needs to be an interface.
|
||||
// but this class (which is only temporary anyway) is mixing and matching
|
||||
// interface calls and implementation calls....so you really can't use a
|
||||
// com ptr. to get around it, I'm using fileStream to make calls on the
|
||||
// methods that aren't supported by the nsIInputStream and "in" for
|
||||
// methods that are supported as part of the interface...
|
||||
FileInputStreamImpl * fileStream = new FileInputStreamImpl();
|
||||
nsCOMPtr<nsIInputStream> in = do_QueryInterface(fileStream);
|
||||
if (!in || !fileStream)
|
||||
{
|
||||
NS_RELEASE(ptr);
|
||||
printf("Failed to create nsIInputStream\n");
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
if (NS_FAILED(fileStream->OpenDiskFile(*(ptr->mTmpFileSpec))))
|
||||
{
|
||||
NS_RELEASE(ptr);
|
||||
printf("Unable to open input file\n");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Set us as the output stream for HTML data from libmime...
|
||||
nsCOMPtr<nsIMimeStreamConverter> mimeConverter = do_QueryInterface(mimeParser);
|
||||
if (mimeConverter)
|
||||
{
|
||||
if (ptr->mQuoteHeaders)
|
||||
mimeConverter->SetMimeOutputType(nsMimeOutput::nsMimeMessageQuoting);
|
||||
else
|
||||
{
|
||||
mimeConverter->SetMimeOutputType(nsMimeOutput::nsMimeMessageBodyQuoting);
|
||||
|
||||
ptr->mQuoteListener = new nsMsgQuoteListener();
|
||||
if (ptr->mQuoteListener)
|
||||
{
|
||||
NS_ADDREF(ptr->mQuoteListener);
|
||||
ptr->mQuoteListener->SetMsgQuote(ptr);
|
||||
mimeConverter->SetMimeHeadersListener(ptr->mQuoteListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIChannel> dummyChannel;
|
||||
NS_WITH_SERVICE(nsIIOService, netService, kIOServiceCID, &rv);
|
||||
rv = netService->NewInputStreamChannel(aURL, nsnull, nsnull, getter_AddRefs(dummyChannel));
|
||||
if (NS_FAILED(mimeParser->AsyncConvertData(nsnull, nsnull, ptr->mStreamListener, dummyChannel)))
|
||||
{
|
||||
NS_RELEASE(ptr);
|
||||
printf("Unable to set the output stream for the mime parser...\ncould be failure to create internal libmime data\n");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
// Assuming this is an RFC822 message...
|
||||
mimeParser->OnStartRequest(nsnull, aURL);
|
||||
|
||||
// Just pump all of the data from the file into libmime...
|
||||
while (NS_SUCCEEDED(fileStream->PumpFileStream()))
|
||||
{
|
||||
PRUint32 len;
|
||||
in->Available(&len);
|
||||
mimeParser->OnDataAvailable(nsnull, aURL, in, 0, len);
|
||||
}
|
||||
|
||||
mimeParser->OnStopRequest(nsnull, aURL, NS_OK, nsnull);
|
||||
in->Close();
|
||||
ptr->mTmpFileSpec->Delete(PR_FALSE);
|
||||
NS_RELEASE(ptr);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -348,15 +197,13 @@ nsresult rv;
|
||||
mQuoteHeaders = quoteHeaders;
|
||||
mStreamListener = aQuoteMsgStreamListener;
|
||||
|
||||
mTmpFileSpec = nsMsgCreateTempFileSpec("nsquot.tmp");
|
||||
if (!mTmpFileSpec)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
NS_NewFileSpecWithSpec(*mTmpFileSpec, &mTmpIFileSpec);
|
||||
if (!mTmpIFileSpec)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsString convertString(msgURI);
|
||||
|
||||
if (quoteHeaders)
|
||||
convertString += "?header=quote";
|
||||
else
|
||||
convertString += "?header=quotebody";
|
||||
|
||||
mURI = convertString.ToNewCString();
|
||||
|
||||
if (!mURI)
|
||||
@ -368,20 +215,74 @@ nsresult rv;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_ADDREF(this);
|
||||
nsMsgDeliveryListener *sendListener = new nsMsgDeliveryListener(SaveQuoteMessageCompleteCallback,
|
||||
nsFileSaveDelivery, this);
|
||||
if (!sendListener)
|
||||
{
|
||||
ReleaseMessageServiceFromURI(mURI, mMessageService);
|
||||
mMessageService = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
// NS_ADDREF(this);
|
||||
AddRef();
|
||||
|
||||
rv = mMessageService->SaveMessageToDisk(mURI, mTmpIFileSpec, PR_FALSE, sendListener, nsnull);
|
||||
NS_WITH_SERVICE(nsIStreamConverterService, streamConverterService,
|
||||
kIStreamConverterServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsAutoString from, to;
|
||||
from = "message/rfc822";
|
||||
to = "text/xul";
|
||||
|
||||
nsCOMPtr<nsIURI> aURL;
|
||||
rv = CreateStartupUrl(mURI, getter_AddRefs(aURL));
|
||||
|
||||
mQuoteChannel = null_nsCOMPtr();
|
||||
NS_WITH_SERVICE(nsIIOService, netService, kIOServiceCID, &rv);
|
||||
rv = netService->NewInputStreamChannel(aURL, nsnull, nsnull,
|
||||
getter_AddRefs(mQuoteChannel));
|
||||
|
||||
NS_ASSERTION(!mQuoteListener, "Oops quote listener exists\n");
|
||||
|
||||
if (mQuoteListener)
|
||||
delete mQuoteListener;
|
||||
|
||||
mQuoteListener = new nsMsgQuoteListener();
|
||||
if (mQuoteListener)
|
||||
{
|
||||
NS_ADDREF(mQuoteListener);
|
||||
mQuoteListener->SetMsgQuote(this);
|
||||
}
|
||||
nsCOMPtr<nsISupports> quoteSupport;
|
||||
rv = QueryInterface(nsCOMTypeInfo<nsISupports>::GetIID(),
|
||||
getter_AddRefs(quoteSupport));
|
||||
|
||||
nsCOMPtr<nsIStreamListener> convertedListener;
|
||||
rv = streamConverterService->AsyncConvertData(from.GetUnicode(),
|
||||
to.GetUnicode(),
|
||||
mStreamListener,
|
||||
quoteSupport,
|
||||
getter_AddRefs(convertedListener));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = mMessageService->DisplayMessage(mURI, convertedListener, nsnull,
|
||||
nsnull);
|
||||
ReleaseMessageServiceFromURI(mURI, mMessageService);
|
||||
mMessageService = nsnull;
|
||||
Release();
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
else
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgQuote::GetQuoteListener(nsIMimeStreamConverterListener** aQuoteListener)
|
||||
{
|
||||
if (!aQuoteListener || !mQuoteListener)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
*aQuoteListener = mQuoteListener;
|
||||
NS_ADDREF(*aQuoteListener);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgQuote::GetQuoteChannel(nsIChannel** aQuoteChannel)
|
||||
{
|
||||
if (!aQuoteChannel || !mQuoteChannel)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
*aQuoteChannel = mQuoteChannel;
|
||||
NS_ADDREF(*aQuoteChannel);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -24,6 +24,8 @@
|
||||
#include "nsIMsgMessageService.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIMimeStreamConverter.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#define NS_MSGQUOTE_CID \
|
||||
{0x1C7ABF0C, 0x21E5, 0x11d3, \
|
||||
@ -55,17 +57,16 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIMSGQUOTE
|
||||
|
||||
nsresult CreateStartupUrl(char *uri, nsIURI** aUrl);
|
||||
//
|
||||
// Implementation data...
|
||||
//
|
||||
nsFileSpec *mTmpFileSpec;
|
||||
nsIFileSpec *mTmpIFileSpec;
|
||||
// nsCOMPtr<nsIStreamListener> mStreamListener;
|
||||
nsIStreamListener* mStreamListener;
|
||||
char *mURI;
|
||||
nsIMsgMessageService *mMessageService;
|
||||
PRBool mQuoteHeaders;
|
||||
nsMsgQuoteListener *mQuoteListener;
|
||||
nsCOMPtr<nsIChannel> mQuoteChannel;
|
||||
};
|
||||
|
||||
// Will be used by factory to generate a nsMsgQuote class...
|
||||
|
@ -514,7 +514,10 @@ nsresult nsImapProtocol::SetupWithUrl(nsIURI * aURL, nsISupports* aConsumer)
|
||||
if (m_mockChannel)
|
||||
{
|
||||
// if we have a listener from a mock channel, over-ride the consumer that was passed in
|
||||
m_mockChannel->GetChannelListener(getter_AddRefs(aRealStreamListener));
|
||||
nsCOMPtr<nsIStreamListener> channelListener;
|
||||
m_mockChannel->GetChannelListener(getter_AddRefs(channelListener));
|
||||
if (channelListener) // only over-ride if we have a non null channel listener
|
||||
aRealStreamListener = channelListener;
|
||||
m_mockChannel->GetChannelContext(getter_AddRefs(m_channelContext));
|
||||
}
|
||||
|
||||
@ -1938,7 +1941,7 @@ void nsImapProtocol::BeginMessageDownLoad(
|
||||
// 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
|
||||
// and they will read it out of the other end.
|
||||
else if (m_mockChannel)
|
||||
else if (m_channelListener)
|
||||
{
|
||||
// create a pipe to pump the message into...the output will go to whoever
|
||||
// is consuming the message display
|
||||
|
@ -48,7 +48,6 @@ static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
static NS_DEFINE_CID(kImapUrlCID, NS_IMAPURL_CID);
|
||||
static NS_DEFINE_CID(kCImapMockChannel, NS_IMAPMOCKCHANNEL_CID);
|
||||
|
||||
static const char *sequenceString = "SEQUENCE";
|
||||
static const char *uidString = "UID";
|
||||
@ -2082,20 +2081,16 @@ NS_IMETHODIMP nsImapService::NewChannel(const char *verb, nsIURI *aURI, nsILoadG
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIImapMockChannel> mockChannel;
|
||||
nsCOMPtr<nsIImapUrl> imapUrl = do_QueryInterface(aURI);
|
||||
nsCOMPtr<nsIImapUrl> imapUrl = do_QueryInterface(aURI, &rv);
|
||||
|
||||
rv = nsComponentManager::CreateInstance(kCImapMockChannel, nsnull, NS_GET_IID(nsIImapMockChannel), getter_AddRefs(mockChannel));
|
||||
if (mockChannel)
|
||||
{
|
||||
mockChannel->SetLoadGroup(aGroup);
|
||||
mockChannel->SetURI(aURI);
|
||||
if (imapUrl)
|
||||
imapUrl->SetMockChannel(mockChannel);
|
||||
*_retval = mockChannel;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
}
|
||||
else
|
||||
rv = NS_ERROR_FAILURE;
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = imapUrl->GetMockChannel(getter_AddRefs(mockChannel));
|
||||
if (NS_FAILED(rv) || !mockChannel) return rv;
|
||||
|
||||
mockChannel->SetLoadGroup(aGroup);
|
||||
*_retval = mockChannel;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "nsImapUtils.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
static NS_DEFINE_CID(kCImapMockChannel, NS_IMAPMOCKCHANNEL_CID);
|
||||
static NS_DEFINE_CID(kMsgMailSessionCID, NS_MSGMAILSESSION_CID);
|
||||
static NS_DEFINE_CID(kCImapHostSessionListCID, NS_IIMAPHOSTSESSIONLIST_CID);
|
||||
|
||||
@ -74,6 +75,11 @@ nsresult nsImapUrl::Initialize(const char * aUserName)
|
||||
m_userName = PL_strdup(aUserName);
|
||||
else
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
|
||||
rv = nsComponentManager::CreateInstance(kCImapMockChannel, nsnull, NS_GET_IID(nsIImapMockChannel), getter_AddRefs(m_mockChannel));
|
||||
if (NS_SUCCEEDED(rv) && m_mockChannel)
|
||||
m_mockChannel->SetURI(this);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -241,11 +241,17 @@ nsresult nsParseImapMessageURI(const char* uri, nsCString& folderURI, PRUint32 *
|
||||
PRInt32 keySeparator = uriStr.FindChar('#');
|
||||
if(keySeparator != -1)
|
||||
{
|
||||
PRInt32 keyEndSeparator = uriStr.FindCharInSet("?&",
|
||||
keySeparator);
|
||||
nsAutoString folderPath;
|
||||
uriStr.Left(folderURI, keySeparator);
|
||||
folderURI.Cut(4, 8); // cut out the _message part of imap_message:
|
||||
nsCAutoString keyStr;
|
||||
uriStr.Right(keyStr, uriStr.Length() - (keySeparator + 1));
|
||||
if (keyEndSeparator != -1)
|
||||
uriStr.Mid(keyStr, keySeparator+1,
|
||||
keyEndSeparator-(keySeparator+1));
|
||||
else
|
||||
uriStr.Right(keyStr, uriStr.Length() - (keySeparator + 1));
|
||||
PRInt32 errorCode;
|
||||
*key = keyStr.ToInteger(&errorCode);
|
||||
|
||||
|
@ -218,7 +218,8 @@ nsLocalURI2Path(const char* rootURI, const char* uriStr,
|
||||
}
|
||||
|
||||
/* parses LocalMessageURI
|
||||
* mailbox://folder1/folder2#123
|
||||
* mailbox://folder1/folder2#123?header=none or
|
||||
* mailbox://folder1/folder2#1234&part=1.2
|
||||
*
|
||||
* puts folder path in folderURI
|
||||
* message key number in key
|
||||
@ -234,11 +235,17 @@ nsresult nsParseLocalMessageURI(const char* uri,
|
||||
PRInt32 keySeparator = uriStr.FindChar('#');
|
||||
if(keySeparator != -1)
|
||||
{
|
||||
PRInt32 keyEndSeparator = uriStr.FindCharInSet("?&",
|
||||
keySeparator);
|
||||
nsAutoString folderPath;
|
||||
uriStr.Left(folderURI, keySeparator);
|
||||
|
||||
nsCAutoString keyStr;
|
||||
uriStr.Right(keyStr, uriStr.Length() - (keySeparator + 1));
|
||||
if (keyEndSeparator != -1)
|
||||
uriStr.Mid(keyStr, keySeparator+1,
|
||||
keyEndSeparator-(keySeparator+1));
|
||||
else
|
||||
uriStr.Right(keyStr, uriStr.Length() - (keySeparator + 1));
|
||||
PRInt32 errorCode;
|
||||
*key = keyStr.ToInteger(&errorCode);
|
||||
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "nsMimeStringResources.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIMsgQuote.h"
|
||||
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
@ -238,8 +239,9 @@ nsStreamConverter::DetermineOutputFormat(const char *url, nsMimeOutputType *aNe
|
||||
|
||||
char *ptr2 = PL_strcasestr ("only", (header+lenOfHeader));
|
||||
char *ptr3 = PL_strcasestr ("quote", (header+lenOfHeader));
|
||||
char *ptr4 = PL_strcasestr ("none", (header+lenOfHeader));
|
||||
if (ptr4)
|
||||
char *ptr4 = PL_strcasestr ("quotebody", (header+lenOfHeader));
|
||||
char *ptr5 = PL_strcasestr ("none", (header+lenOfHeader));
|
||||
if (ptr5)
|
||||
{
|
||||
PR_FREEIF(mOutputFormat);
|
||||
mOutputFormat = PL_strdup("text/html");
|
||||
@ -257,6 +259,12 @@ nsStreamConverter::DetermineOutputFormat(const char *url, nsMimeOutputType *aNe
|
||||
mOutputFormat = PL_strdup("text/html");
|
||||
*aNewType = nsMimeOutput::nsMimeMessageQuoting;
|
||||
}
|
||||
else if (ptr4)
|
||||
{
|
||||
PR_FREEIF(mOutputFormat);
|
||||
mOutputFormat = PL_strdup("text/html");
|
||||
*aNewType = nsMimeOutput::nsMimeMessageBodyQuoting;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -722,7 +730,22 @@ NS_IMETHODIMP nsStreamConverter::AsyncConvertData(const PRUnichar *aFromType, co
|
||||
nsIStreamListener *aListener, nsISupports *aCtxt)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIChannel> aChannel = do_QueryInterface(aCtxt, &rv);
|
||||
nsCOMPtr<nsIMsgQuote> aMsgQuote = do_QueryInterface(aCtxt, &rv);
|
||||
nsCOMPtr<nsIChannel> aChannel;
|
||||
|
||||
if (aMsgQuote)
|
||||
{
|
||||
nsCOMPtr<nsIMimeStreamConverterListener> quoteListener;
|
||||
rv = aMsgQuote->GetQuoteListener(getter_AddRefs(quoteListener));
|
||||
if (quoteListener)
|
||||
SetMimeHeadersListener(quoteListener);
|
||||
rv = aMsgQuote->GetQuoteChannel(getter_AddRefs(aChannel));
|
||||
}
|
||||
else
|
||||
{
|
||||
aChannel = do_QueryInterface(aCtxt, &rv);
|
||||
}
|
||||
|
||||
NS_ASSERTION(aChannel && NS_SUCCEEDED(rv), "mailnews mime converter has to have the channel passed in...");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
@ -235,10 +235,17 @@ nsParseNewsMessageURI(const char* uri, nsCString& messageUriWithoutKey, PRUint32
|
||||
PRInt32 keySeparator = uriStr.FindChar('#');
|
||||
if(keySeparator != -1)
|
||||
{
|
||||
PRInt32 keyEndSeparator = uriStr.FindCharInSet("?&",
|
||||
keySeparator);
|
||||
|
||||
uriStr.Left(messageUriWithoutKey, keySeparator);
|
||||
|
||||
nsCAutoString keyStr;
|
||||
uriStr.Right(keyStr, uriStr.Length() - (keySeparator + 1));
|
||||
if (keyEndSeparator != -1)
|
||||
uriStr.Mid(keyStr, keySeparator+1,
|
||||
keyEndSeparator-(keySeparator+1));
|
||||
else
|
||||
uriStr.Right(keyStr, uriStr.Length() - (keySeparator + 1));
|
||||
PRInt32 errorCode;
|
||||
*key = keyStr.ToInteger(&errorCode);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user