backing my ass out. These changes were meant for my branch, not the trunk. sr-leaf

This commit is contained in:
dougt%netscape.com 2001-01-25 22:07:38 +00:00
Родитель 997a6cb19a
Коммит 461938270b
42 изменённых файлов: 464 добавлений и 695 удалений

Просмотреть файл

@ -37,7 +37,6 @@
#include "nsAbSyncPostEngine.h"
#include "nsIIOService.h"
#include "nsIChannel.h"
#include "nsIStreamContentInfo.h"
#include "nsNetUtil.h"
#include "nsMimeTypes.h"
#include "nsIHTTPChannel.h"
@ -343,7 +342,7 @@ NS_IMETHODIMP
nsAbSyncPostEngine::DoContent(const char * aContentType,
nsURILoadCommand aCommand,
const char * aWindowTarget,
nsIRequest *request,
nsIChannel * aOpenedChannel,
nsIStreamListener ** aContentHandler,
PRBool * aAbortProcess)
{
@ -392,7 +391,7 @@ nsAbSyncPostEngine::StillRunning(PRBool *running)
// Methods for nsIStreamListener...
nsresult
nsAbSyncPostEngine::OnDataAvailable(nsIRequest *request, nsISupports * ctxt, nsIInputStream *aIStream,
nsAbSyncPostEngine::OnDataAvailable(nsIChannel * aChannel, nsISupports * ctxt, nsIInputStream *aIStream,
PRUint32 sourceOffset, PRUint32 aLength)
{
PRUint32 readLen = aLength;
@ -418,7 +417,7 @@ nsAbSyncPostEngine::OnDataAvailable(nsIRequest *request, nsISupports * ctxt, nsI
// Methods for nsIStreamObserver
nsresult
nsAbSyncPostEngine::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
nsAbSyncPostEngine::OnStartRequest(nsIChannel *aChannel, nsISupports *ctxt)
{
if (mAuthenticationRunning)
NotifyListenersOnStartAuthOperation();
@ -428,7 +427,7 @@ nsAbSyncPostEngine::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
}
nsresult
nsAbSyncPostEngine::OnStopRequest(nsIRequest *request, nsISupports * /* ctxt */, nsresult aStatus, const PRUnichar* aMsg)
nsAbSyncPostEngine::OnStopRequest(nsIChannel *aChannel, nsISupports * /* ctxt */, nsresult aStatus, const PRUnichar* aMsg)
{
#ifdef NS_DEBUG_rhp
printf("nsAbSyncPostEngine::OnStopRequest()\n");
@ -442,22 +441,18 @@ nsAbSyncPostEngine::OnStopRequest(nsIRequest *request, nsISupports * /* ctxt */,
mStillRunning = PR_FALSE;
// Check the content type!
nsCOMPtr<nsIStreamContentInfo> contentInfo = do_QueryInterface(request);
if (contentInfo)
if (aChannel)
{
char *contentType = nsnull;
char *charset = nsnull;
if (NS_SUCCEEDED(contentInfo->GetContentType(&contentType)) && contentType)
if (NS_SUCCEEDED(aChannel->GetContentType(&contentType)) && contentType)
{
if (PL_strcasecmp(contentType, UNKNOWN_CONTENT_TYPE))
{
mContentType = contentType;
}
}
nsCOMPtr<nsIChannel> aChannel;
request->GetParent(getter_AddRefs(aChannel));
if (!aChannel) return NS_ERROR_FAILURE;
nsCOMPtr<nsIHTTPChannel> httpChannel = do_QueryInterface(aChannel);
if (httpChannel)
@ -711,8 +706,8 @@ nsAbSyncPostEngine::FireURLRequest(nsIURI *aURL, const char *postData)
httpChannel->SetRequestMethod(method);
if (NS_SUCCEEDED(rv = NS_NewPostDataStream(getter_AddRefs(postStream), PR_FALSE, postData, 0)))
httpChannel->SetUploadStream(postStream);
httpChannel->AsyncRead(this, nsnull, 0, -1, getter_AddRefs(mRequest));
httpChannel->AsyncRead(this, nsnull);
return NS_OK;
}
@ -851,8 +846,9 @@ nsAbSyncPostEngine::CancelAbSync()
}
else
{
if (mRequest)
rv = mRequest->Cancel(NS_BINDING_ABORTED);
nsCOMPtr<nsIHTTPChannel> httpChannel = do_QueryInterface(mChannel);
if (httpChannel)
rv = httpChannel->Cancel(NS_BINDING_ABORTED);
}
return rv;

Просмотреть файл

@ -109,7 +109,7 @@ private:
PRBool mAuthenticationRunning;
nsCOMPtr<nsIAbSyncMojo> mSyncMojo;
nsCOMPtr<nsIChannel> mChannel;
nsCOMPtr<nsIRequest> mRequest;
char *mSyncProtocolRequest;
char *mSyncProtocolRequestPrefix;

Просмотреть файл

@ -341,7 +341,7 @@ const nsMsgBiffState nsMsgBiffState_Unknown = 2; // We dunno whether there is ne
nsIMsgDBHdr GetMessageHeader(in nsMsgKey msgKey);
boolean shouldStoreMsgOffline(in nsMsgKey msgKey);
boolean hasMsgOffline(in nsMsgKey msgKey);
nsIFileChannel getOfflineFileChannel(in nsMsgKey msgKey, out PRUint32 offset, out PRUint32 size);
nsIFileChannel getOfflineFileChannel(in nsMsgKey msgKey);
void DownloadMessagesForOffline(in nsISupportsArray messages);
nsIMsgFolder getChildWithURI(in string uri, in boolean deep);

Просмотреть файл

@ -131,14 +131,14 @@ NS_IMETHODIMP nsCopyMessageStreamListener::EndMessage(nsMsgKey key)
}
NS_IMETHODIMP nsCopyMessageStreamListener::OnDataAvailable(nsIRequest * /* request */, nsISupports *ctxt, nsIInputStream *aIStream, PRUint32 sourceOffset, PRUint32 aLength)
NS_IMETHODIMP nsCopyMessageStreamListener::OnDataAvailable(nsIChannel * /* aChannel */, nsISupports *ctxt, nsIInputStream *aIStream, PRUint32 sourceOffset, PRUint32 aLength)
{
nsresult rv;
rv = mDestination->CopyData(aIStream, aLength);
return rv;
}
NS_IMETHODIMP nsCopyMessageStreamListener::OnStartRequest(nsIRequest * request, nsISupports *ctxt)
NS_IMETHODIMP nsCopyMessageStreamListener::OnStartRequest(nsIChannel * aChannel, nsISupports *ctxt)
{
nsCOMPtr<nsIMessage> message;
nsresult rv = NS_OK;
@ -154,7 +154,7 @@ NS_IMETHODIMP nsCopyMessageStreamListener::OnStartRequest(nsIRequest * request,
return rv;
}
NS_IMETHODIMP nsCopyMessageStreamListener::OnStopRequest(nsIRequest* request, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg)
NS_IMETHODIMP nsCopyMessageStreamListener::OnStopRequest(nsIChannel * aChannel, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg)
{
nsresult rv = NS_OK;
nsCOMPtr<nsIURI> uri = do_QueryInterface(ctxt, &rv);

Просмотреть файл

@ -1573,7 +1573,7 @@ nsSaveAsListener::OnStopCopy(nsresult aStatus)
}
NS_IMETHODIMP
nsSaveAsListener::OnStartRequest(nsIRequest* request, nsISupports* aSupport)
nsSaveAsListener::OnStartRequest(nsIChannel* aChannel, nsISupports* aSupport)
{
nsresult rv = NS_OK;
if (m_fileSpec)
@ -1590,7 +1590,7 @@ nsSaveAsListener::OnStartRequest(nsIRequest* request, nsISupports* aSupport)
}
NS_IMETHODIMP
nsSaveAsListener::OnStopRequest(nsIRequest* request, nsISupports* aSupport,
nsSaveAsListener::OnStopRequest(nsIChannel* aChannel, nsISupports* aSupport,
nsresult status, const PRUnichar* aMsg)
{
nsresult rv = NS_OK;
@ -1688,7 +1688,7 @@ nsSaveAsListener::OnStopRequest(nsIRequest* request, nsISupports* aSupport,
}
NS_IMETHODIMP
nsSaveAsListener::OnDataAvailable(nsIRequest* request,
nsSaveAsListener::OnDataAvailable(nsIChannel* aChannel,
nsISupports* aSupport,
nsIInputStream* inStream,
PRUint32 srcOffset,

Просмотреть файл

@ -281,7 +281,7 @@ nsFolderCompactState::GetMessage(nsIMessage **message)
NS_IMETHODIMP
nsFolderCompactState::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
nsFolderCompactState::OnStartRequest(nsIChannel *channel, nsISupports *ctxt)
{
nsresult rv = NS_ERROR_FAILURE;
NS_ASSERTION(m_fileStream, "Fatal, null m_fileStream...\n");
@ -296,7 +296,7 @@ nsFolderCompactState::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
}
NS_IMETHODIMP
nsFolderCompactState::OnStopRequest(nsIRequest *request, nsISupports *ctxt,
nsFolderCompactState::OnStopRequest(nsIChannel *channel, nsISupports *ctxt,
nsresult status,
const PRUnichar *errorMsg)
{
@ -355,7 +355,7 @@ done:
}
NS_IMETHODIMP
nsFolderCompactState::OnDataAvailable(nsIRequest *request, nsISupports *ctxt,
nsFolderCompactState::OnDataAvailable(nsIChannel *channel, nsISupports *ctxt,
nsIInputStream *inStr,
PRUint32 sourceOffset, PRUint32 count)
{
@ -397,7 +397,7 @@ nsOfflineStoreCompactState::InitDB(nsIMsgDatabase *db)
}
NS_IMETHODIMP
nsOfflineStoreCompactState::OnStopRequest(nsIRequest *request, nsISupports *ctxt,
nsOfflineStoreCompactState::OnStopRequest(nsIChannel *channel, nsISupports *ctxt,
nsresult status,
const PRUnichar *errorMsg)
{

Просмотреть файл

@ -72,7 +72,7 @@ public:
virtual ~nsOfflineStoreCompactState(void);
virtual nsresult InitDB(nsIMsgDatabase *db);
NS_IMETHOD OnStopRequest(nsIRequest *request, nsISupports *ctxt,
NS_IMETHOD OnStopRequest(nsIChannel *channel, nsISupports *ctxt,
nsresult status, const PRUnichar *errorMsg);
NS_IMETHODIMP FinishCompact();

Просмотреть файл

@ -95,7 +95,7 @@ nsMsgPrintEngine::OnStartDocumentLoad(nsIDocumentLoader *aLoader, nsIURI *aURL,
}
NS_IMETHODIMP
nsMsgPrintEngine::OnEndDocumentLoad(nsIDocumentLoader *loader, nsIRequest *request, PRUint32 aStatus)
nsMsgPrintEngine::OnEndDocumentLoad(nsIDocumentLoader *loader, nsIChannel *aChannel, PRUint32 aStatus)
{
// Now, fire off the print operation!
nsresult rv = NS_ERROR_FAILURE;
@ -106,13 +106,10 @@ nsMsgPrintEngine::OnEndDocumentLoad(nsIDocumentLoader *loader, nsIRequest *reque
PR_FREEIF(msg);
NS_ASSERTION(mDocShell,"can't print, there is no docshell");
if ( (!mDocShell) || (!request) )
if ( (!mDocShell) || (!aChannel) )
{
return StartNextPrintOperation();
}
nsCOMPtr<nsIChannel> aChannel;
request->GetParent(getter_AddRefs(aChannel));
if (!aChannel) return NS_ERROR_FAILURE;
// Make sure this isn't just "about:blank" finishing....
nsCOMPtr<nsIURI> originalURI = nsnull;
@ -160,25 +157,25 @@ nsMsgPrintEngine::OnEndDocumentLoad(nsIDocumentLoader *loader, nsIRequest *reque
}
NS_IMETHODIMP
nsMsgPrintEngine::OnStartURLLoad(nsIDocumentLoader *aLoader, nsIRequest *request)
nsMsgPrintEngine::OnStartURLLoad(nsIDocumentLoader *aLoader, nsIChannel *channel)
{
return NS_OK;
}
NS_IMETHODIMP
nsMsgPrintEngine::OnProgressURLLoad(nsIDocumentLoader *aLoader, nsIRequest *request, PRUint32 aProgress, PRUint32 aProgressMax)
nsMsgPrintEngine::OnProgressURLLoad(nsIDocumentLoader *aLoader, nsIChannel *aChannel, PRUint32 aProgress, PRUint32 aProgressMax)
{
return NS_OK;
}
NS_IMETHODIMP
nsMsgPrintEngine::OnStatusURLLoad(nsIDocumentLoader *loader, nsIRequest *request, nsString & aMsg)
nsMsgPrintEngine::OnStatusURLLoad(nsIDocumentLoader *loader, nsIChannel *channel, nsString & aMsg)
{
return NS_OK;
}
NS_IMETHODIMP
nsMsgPrintEngine::OnEndURLLoad(nsIDocumentLoader *aLoader, nsIRequest *request, PRUint32 aStatus)
nsMsgPrintEngine::OnEndURLLoad(nsIDocumentLoader *aLoader, nsIChannel *aChannel, PRUint32 aStatus)
{
return NS_OK;
}

Просмотреть файл

@ -353,15 +353,15 @@ nsMsgStatusFeedback::NotifyStopMeteors(nsITimer* aTimer)
m_meteorsSpinning = PR_FALSE;
}
NS_IMETHODIMP nsMsgStatusFeedback::OnProgress(nsIRequest *request, nsISupports* ctxt,
NS_IMETHODIMP nsMsgStatusFeedback::OnProgress(nsIChannel* channel, nsISupports* ctxt,
PRUint32 aProgress, PRUint32 aProgressMax)
{
// XXX: What should the nsIWebProgress be?
return OnProgressChange(nsnull, request, aProgress, aProgressMax,
return OnProgressChange(nsnull, channel, aProgress, aProgressMax,
aProgress /* current total progress */, aProgressMax /* max total progress */);
}
NS_IMETHODIMP nsMsgStatusFeedback::OnStatus(nsIRequest *request, nsISupports* ctxt,
NS_IMETHODIMP nsMsgStatusFeedback::OnStatus(nsIChannel* channel, nsISupports* ctxt,
nsresult aStatus, const PRUnichar* aStatusArg)
{
nsresult rv;

Просмотреть файл

@ -398,7 +398,7 @@ NS_IMETHODIMP nsMsgWindow::GetProtocolHandler(nsIURI * /* aURI */, nsIProtocolHa
}
NS_IMETHODIMP nsMsgWindow::DoContent(const char *aContentType, nsURILoadCommand aCommand, const char *aWindowTarget,
nsIRequest *request, nsIStreamListener **aContentHandler, PRBool *aAbortProcess)
nsIChannel *aChannel, nsIStreamListener **aContentHandler, PRBool *aAbortProcess)
{
if (aContentType)
{
@ -408,10 +408,6 @@ NS_IMETHODIMP nsMsgWindow::DoContent(const char *aContentType, nsURILoadCommand
nsCOMPtr<nsIURIContentListener> ctnListener = do_QueryInterface(messageWindowDocShell);
if (ctnListener)
{
nsCOMPtr<nsIChannel> aChannel;
request->GetParent(getter_AddRefs(aChannel));
if (!aChannel) return NS_ERROR_FAILURE;
// get the url for the channel...let's hope it is a mailnews url so we can set our msg hdr sink on it..
// right now, this is the only way I can think of to force the msg hdr sink into the mime converter so it can
// get too it later...
@ -423,7 +419,7 @@ NS_IMETHODIMP nsMsgWindow::DoContent(const char *aContentType, nsURILoadCommand
if (mailnewsUrl)
mailnewsUrl->SetMsgWindow(this);
}
return ctnListener->DoContent(aContentType, aCommand, aWindowTarget, request, aContentHandler, aAbortProcess);
return ctnListener->DoContent(aContentType, aCommand, aWindowTarget, aChannel, aContentHandler, aAbortProcess);
}
}
return NS_OK;

Просмотреть файл

@ -581,12 +581,10 @@ nsresult nsMsgDBFolder::GetOfflineStoreInputStream(nsIInputStream **stream)
return rv;
}
NS_IMETHODIMP nsMsgDBFolder::GetOfflineFileChannel(nsMsgKey msgKey, PRUint32 *offset, PRUint32 *size, nsIFileChannel **aFileChannel)
NS_IMETHODIMP nsMsgDBFolder::GetOfflineFileChannel(nsMsgKey msgKey, nsIFileChannel **aFileChannel)
{
NS_ENSURE_ARG(aFileChannel);
*offset = *size = 0;
nsresult rv;
rv = nsComponentManager::CreateInstance(NS_LOCALFILECHANNEL_CONTRACTID, nsnull,
@ -608,8 +606,12 @@ NS_IMETHODIMP nsMsgDBFolder::GetOfflineFileChannel(nsMsgKey msgKey, PRUint32 *of
rv = mDatabase->GetMsgHdrForKey(msgKey, getter_AddRefs(hdr));
if (hdr && NS_SUCCEEDED(rv))
{
hdr->GetMessageOffset(offset);
hdr->GetOfflineMessageSize(size);
PRUint32 messageOffset;
PRUint32 messageSize;
hdr->GetMessageOffset(&messageOffset);
hdr->GetOfflineMessageSize(&messageSize);
(*aFileChannel)->SetTransferOffset(messageOffset);
(*aFileChannel)->SetTransferCount(messageSize);
}
}
}
@ -641,8 +643,8 @@ nsresult nsMsgDBFolder::GetOfflineStoreOutputStream(nsIOutputStream **outputStre
rv = fileChannel->Init(localStore, PR_CREATE_FILE | PR_RDWR, 0);
if (NS_FAILED(rv))
return rv;
//bad see dougt fileChannel->SetTransferOffset(fileSize);
//bad see dougt rv = fileChannel->OpenOutputStream(outputStream);
fileChannel->SetTransferOffset(fileSize);
rv = fileChannel->OpenOutputStream(outputStream);
if (NS_FAILED(rv))
return rv;
}
@ -688,6 +690,7 @@ nsresult nsMsgDBFolder::CreatePlatformLeafNameForDisk(const char *userLeafName,
// (c) does not already exist on the disk
// then we simply return nsCRT::strdup(userLeafName)
// Otherwise we mangle it
// mangledPath is the entire path to the newly mangled leaf name
nsCAutoString mangledLeaf(userLeafName);

Просмотреть файл

@ -93,7 +93,7 @@ public:
NS_IMETHOD SetGettingNewMessages(PRBool gettingNewMessages);
NS_IMETHOD ShouldStoreMsgOffline(nsMsgKey msgKey, PRBool *result);
NS_IMETHOD GetOfflineFileChannel(nsMsgKey msgKey, PRUint32 *offset, PRUint32 *size, nsIFileChannel **_retval);
NS_IMETHOD GetOfflineFileChannel(nsMsgKey msgKey, nsIFileChannel **aFileChannel);
NS_IMETHOD HasMsgOffline(nsMsgKey msgKey, PRBool *result);
NS_IMETHOD DownloadMessagesForOffline(nsISupportsArray *messages);
NS_IMETHOD GetRetentionSettings(nsIMsgRetentionSettings **settings);

Просмотреть файл

@ -37,12 +37,7 @@
static NS_DEFINE_CID(kNetSupportDialogCID, NS_NETSUPPORTDIALOG_CID);
static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
NS_IMPL_ISUPPORTS5(nsMsgProtocol,
nsIStreamListener,
nsIStreamObserver,
nsIChannel,
nsIRequest,
nsIStreamContentInfo)
NS_IMPL_ISUPPORTS3(nsMsgProtocol, nsIStreamListener, nsIStreamObserver, nsIChannel)
nsMsgProtocol::nsMsgProtocol(nsIURI * aURL)
{
@ -141,7 +136,7 @@ nsresult nsMsgProtocol::SetupTransportState()
if (!m_socketIsOpen && m_channel)
{
rv = m_channel->OpenOutputStream(0, -1, getter_AddRefs(m_outputStream));
rv = m_channel->OpenOutputStream(getter_AddRefs(m_outputStream));
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create an output stream");
// we want to open the stream
@ -159,11 +154,10 @@ nsresult nsMsgProtocol::CloseSocket()
m_outputStream = null_nsCOMPtr();
// we need to call Cancel so that we remove the socket transport from the mActiveTransportList. see bug #30648
if (m_request) {
rv = m_request->Cancel(NS_BINDING_ABORTED);
if (m_channel) {
rv = m_channel->Cancel(NS_BINDING_ABORTED);
}
m_request = 0;
m_channel = 0;
m_channel = null_nsCOMPtr();
return rv;
}
@ -193,14 +187,14 @@ PRInt32 nsMsgProtocol::SendData(nsIURI * aURL, const char * dataBuffer, PRBool a
// Whenever data arrives from the connection, core netlib notifices the protocol by calling
// OnDataAvailable. We then read and process the incoming data from the input stream.
NS_IMETHODIMP nsMsgProtocol::OnDataAvailable(nsIRequest *request, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count)
NS_IMETHODIMP nsMsgProtocol::OnDataAvailable(nsIChannel * /* aChannel */, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count)
{
// right now, this really just means turn around and churn through the state machine
nsCOMPtr<nsIURI> uri = do_QueryInterface(ctxt);
return ProcessProtocolState(uri, inStr, sourceOffset, count);
}
NS_IMETHODIMP nsMsgProtocol::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
NS_IMETHODIMP nsMsgProtocol::OnStartRequest(nsIChannel * aChannel, nsISupports *ctxt)
{
nsresult rv = NS_OK;
nsCOMPtr <nsIMsgMailNewsUrl> aMsgUrl = do_QueryInterface(ctxt, &rv);
@ -208,7 +202,7 @@ NS_IMETHODIMP nsMsgProtocol::OnStartRequest(nsIRequest *request, nsISupports *ct
{
rv = aMsgUrl->SetUrlState(PR_TRUE, NS_OK);
if (m_loadGroup)
m_loadGroup->AddRequest(NS_STATIC_CAST(nsIRequest *, this), nsnull /* context isupports */);
m_loadGroup->AddChannel(NS_STATIC_CAST(nsIChannel *, this), nsnull /* context isupports */);
}
// if we are set up as a channel, we should notify our channel listener that we are starting...
@ -225,7 +219,7 @@ NS_IMETHODIMP nsMsgProtocol::OnStartRequest(nsIRequest *request, nsISupports *ct
}
// stop binding is a "notification" informing us that the stream associated with aURL is going away.
NS_IMETHODIMP nsMsgProtocol::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aMsg)
NS_IMETHODIMP nsMsgProtocol::OnStopRequest(nsIChannel * aChannel, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aMsg)
{
nsresult rv = NS_OK;
@ -240,7 +234,7 @@ NS_IMETHODIMP nsMsgProtocol::OnStopRequest(nsIRequest *request, nsISupports *ctx
{
rv = msgUrl->SetUrlState(PR_FALSE, aStatus);
if (m_loadGroup)
m_loadGroup->RemoveRequest(NS_STATIC_CAST(nsIRequest *, this), nsnull, aStatus, nsnull);
m_loadGroup->RemoveChannel(NS_STATIC_CAST(nsIChannel *, this), nsnull, aStatus, nsnull);
// !NS_BINDING_ABORTED because we don't want to see an alert if the user
// cancelled the operation. also, we'll get here because we call Cancel()
@ -320,8 +314,17 @@ nsresult nsMsgProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer)
nsCOMPtr<nsISupports> urlSupports = do_QueryInterface(aURL);
if (m_channel)
{
// XXX should these errors be returned?:
if (m_startPosition > 0)
{
rv = m_channel->SetTransferOffset(m_startPosition);
NS_ASSERTION(NS_SUCCEEDED(rv), "SetTransferOffset failed");
}
rv = m_channel->SetTransferCount(m_readCount);
NS_ASSERTION(NS_SUCCEEDED(rv), "SetTransferCount failed");
// put us in a state where we are always notified of incoming data
rv = m_channel->AsyncRead(this, urlSupports, m_startPosition, m_readCount, getter_AddRefs(m_request));
rv = m_channel->AsyncRead(this /* stream observer */, urlSupports);
NS_ASSERTION(NS_SUCCEEDED(rv), "AsyncRead failed");
m_socketIsOpen = PR_TRUE; // mark the channel as open
}
@ -375,20 +378,19 @@ NS_IMETHODIMP nsMsgProtocol::SetURI(nsIURI* aURI)
return NS_OK;
}
NS_IMETHODIMP nsMsgProtocol::OpenInputStream(PRUint32 transferOffset, PRUint32 transferCount, nsIInputStream **_retval)
NS_IMETHODIMP nsMsgProtocol::OpenInputStream(nsIInputStream **_retval)
{
NS_NOTREACHED("OpenInputStream");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgProtocol::OpenOutputStream(PRUint32 transferOffset, PRUint32 transferCount, nsIOutputStream **_retval)
NS_IMETHODIMP nsMsgProtocol::OpenOutputStream(nsIOutputStream **_retval)
{
NS_NOTREACHED("OpenOutputStream");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgProtocol::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt,
PRUint32 transferOffset, PRUint32 transferCount, nsIRequest **_retval)
NS_IMETHODIMP nsMsgProtocol::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt)
{
// set the stream listener and then load the url
m_channelContext = ctxt;
@ -415,8 +417,7 @@ NS_IMETHODIMP nsMsgProtocol::AsyncRead(nsIStreamListener *listener, nsISupports
return LoadUrl(m_url, nsnull);
}
NS_IMETHODIMP nsMsgProtocol::AsyncWrite(nsIInputStream *a, nsIStreamObserver*b, nsISupports *ctxt,
PRUint32 transferOffset, PRUint32 transferCount, nsIRequest **_retval)
NS_IMETHODIMP nsMsgProtocol::AsyncWrite(nsIStreamProvider *provider, nsISupports *ctxt)
{
NS_NOTREACHED("AsyncWrite");
return NS_ERROR_NOT_IMPLEMENTED;
@ -467,6 +468,83 @@ nsMsgProtocol::SetContentLength(PRInt32 aContentLength)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsMsgProtocol::GetTransferOffset(PRUint32 *aTransferOffset)
{
NS_NOTREACHED("GetTransferOffset");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsMsgProtocol::SetTransferOffset(PRUint32 aTransferOffset)
{
NS_NOTREACHED("SetTransferOffset");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsMsgProtocol::GetTransferCount(PRInt32 *aTransferCount)
{
NS_NOTREACHED("GetTransferCount");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsMsgProtocol::SetTransferCount(PRInt32 aTransferCount)
{
NS_NOTREACHED("SetTransferCount");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsMsgProtocol::GetBufferSegmentSize(PRUint32 *aBufferSegmentSize)
{
NS_NOTREACHED("GetBufferSegmentSize");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsMsgProtocol::SetBufferSegmentSize(PRUint32 aBufferSegmentSize)
{
NS_NOTREACHED("SetBufferSegmentSize");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsMsgProtocol::GetBufferMaxSize(PRUint32 *aBufferMaxSize)
{
NS_NOTREACHED("GetBufferMaxSize");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsMsgProtocol::SetBufferMaxSize(PRUint32 aBufferMaxSize)
{
NS_NOTREACHED("SetBufferMaxSize");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsMsgProtocol::GetLocalFile(nsIFile* *file)
{
NS_NOTREACHED("GetLocalFile");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsMsgProtocol::GetPipeliningAllowed(PRBool *aPipeliningAllowed)
{
*aPipeliningAllowed = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
nsMsgProtocol::SetPipeliningAllowed(PRBool aPipeliningAllowed)
{
NS_NOTREACHED("SetPipeliningAllowed");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgProtocol::GetOwner(nsISupports * *aPrincipal)
{
*aPrincipal = mOwner;
@ -527,8 +605,8 @@ nsMsgProtocol::GetSecurityInfo(nsISupports * *aSecurityInfo)
NS_IMETHODIMP nsMsgProtocol::GetName(PRUnichar* *result)
{
if (m_request)
return m_request->GetName(result);
if (m_channel)
return m_channel->GetName(result);
NS_NOTREACHED("nsMsgProtocol::GetName");
return NS_ERROR_NOT_IMPLEMENTED;
}
@ -541,8 +619,8 @@ NS_IMETHODIMP nsMsgProtocol::IsPending(PRBool *result)
NS_IMETHODIMP nsMsgProtocol::GetStatus(nsresult *status)
{
if (m_request)
return m_request->GetStatus(status);
if (m_channel)
return m_channel->GetStatus(status);
*status = NS_ERROR_FAILURE;
return *status;
@ -550,12 +628,12 @@ NS_IMETHODIMP nsMsgProtocol::GetStatus(nsresult *status)
NS_IMETHODIMP nsMsgProtocol::Cancel(nsresult status)
{
NS_ASSERTION(m_request,"no channel");
if (!m_request) {
NS_ASSERTION(m_channel,"no channel");
if (!m_channel) {
return NS_ERROR_FAILURE;
}
return m_request->Cancel(status);
return m_channel->Cancel(status);
}
NS_IMETHODIMP nsMsgProtocol::Suspend()
@ -570,18 +648,6 @@ NS_IMETHODIMP nsMsgProtocol::Resume()
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgProtocol::GetParent(nsISupports * *aParent)
{
NS_ADDREF(*aParent=(nsISupports*)(nsIChannel*)this);
return NS_OK;
}
NS_IMETHODIMP nsMsgProtocol::SetParent(nsISupports * aParent)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult nsMsgProtocol::PostMessage(nsIURI* url, nsIFileSpec *fileSpec)
{
if (!url || !fileSpec) return NS_ERROR_NULL_POINTER;

Просмотреть файл

@ -33,7 +33,6 @@
#include "nsIFileSpec.h"
#include "nsIInterfaceRequestor.h"
#include "nsIProgressEventSink.h"
#include "nsIStreamContentInfo.h"
class nsIPrompt;
class nsIMsgMailNewsUrl;
@ -43,11 +42,7 @@ class nsIMsgMailNewsUrl;
// it unifies the core networking code for the protocols. My hope is that
// this will make unification with Necko easier as we'll only have to change
// this class and not all of the mailnews protocols.
class NS_MSG_BASE nsMsgProtocol
: public nsIStreamListener,
public nsIChannel,
public nsIRequest,
public nsIStreamContentInfo
class NS_MSG_BASE nsMsgProtocol : public nsIStreamListener, public nsIChannel
{
public:
nsMsgProtocol(nsIURI * aURL);
@ -57,7 +52,6 @@ public:
// nsIChannel support
NS_DECL_NSICHANNEL
NS_DECL_NSIREQUEST
NS_DECL_NSISTREAMCONTENTINFO
NS_DECL_NSISTREAMLISTENER
NS_DECL_NSISTREAMOBSERVER
@ -108,9 +102,7 @@ protected:
// Ouput stream for writing commands to the socket
nsCOMPtr<nsIChannel> m_channel;
nsCOMPtr<nsIRequest> m_request;
nsCOMPtr<nsIOutputStream> m_outputStream; // this will be obtained from the transport interface
nsCOMPtr<nsIOutputStream> m_outputStream; // this will be obtained from the transport interface
PRBool m_socketIsOpen; // mscott: we should look into keeping this state in the nsSocketTransport...
// I'm using it to make sure I open the socket the first time a URL is loaded into the connection

Просмотреть файл

@ -1173,12 +1173,12 @@ QuotingOutputStreamListener::ConvertToPlainText(PRBool formatflowed /* = PR_FALS
return rv;
}
NS_IMETHODIMP QuotingOutputStreamListener::OnStartRequest(nsIRequest *request, nsISupports * /* ctxt */)
NS_IMETHODIMP QuotingOutputStreamListener::OnStartRequest(nsIChannel * /* aChannel */, nsISupports * /* ctxt */)
{
return NS_OK;
}
NS_IMETHODIMP QuotingOutputStreamListener::OnStopRequest(nsIRequest *request, nsISupports * /* ctxt */, nsresult status, const PRUnichar * /* errorMsg */)
NS_IMETHODIMP QuotingOutputStreamListener::OnStopRequest(nsIChannel *aChannel, nsISupports * /* ctxt */, nsresult status, const PRUnichar * /* errorMsg */)
{
nsresult rv = NS_OK;
nsAutoString aCharset;
@ -1373,7 +1373,7 @@ NS_IMETHODIMP QuotingOutputStreamListener::OnStopRequest(nsIRequest *request, ns
return rv;
}
NS_IMETHODIMP QuotingOutputStreamListener::OnDataAvailable(nsIRequest *request,
NS_IMETHODIMP QuotingOutputStreamListener::OnDataAvailable(nsIChannel * /* aChannel */,
nsISupports *ctxt, nsIInputStream *inStr,
PRUint32 sourceOffset, PRUint32 count)
{

Просмотреть файл

@ -42,19 +42,15 @@ nsMsgComposeContentHandler::~nsMsgComposeContentHandler()
}
NS_IMETHODIMP nsMsgComposeContentHandler::HandleContent(const char * aContentType, const char * aCommand,
const char * aWindowTarget, nsISupports * aWindowContext, nsIRequest *request)
const char * aWindowTarget, nsISupports * aWindowContext, nsIChannel * aChannel)
{
nsresult rv = NS_OK;
if (!request)
if (!aChannel)
return NS_ERROR_NULL_POINTER;
// First of all, get the content type and make sure it is a content type we know how to handle!
if (nsCRT::strcasecmp(aContentType, "x-application-mailto") == 0) {
nsCOMPtr<nsIURI> aUri;
nsCOMPtr<nsIChannel> aChannel;
request->GetParent(getter_AddRefs(aChannel));
if(!aChannel) return NS_ERROR_FAILURE;
rv = aChannel->GetURI(getter_AddRefs(aUri));
if (aUri)
{

Просмотреть файл

@ -220,8 +220,7 @@ nsMsgQuote::QuoteMessage(const PRUnichar *msgURI, PRBool quoteHeaders, nsIStream
if (NS_FAILED(rv)) return rv;
// now try to open the channel passing in our display consumer as the listener
nsCOMPtr<nsIRequest> request;
rv = mQuoteChannel->AsyncRead(convertedListener, ctxt, 0, -1, getter_AddRefs(request));
rv = mQuoteChannel->AsyncRead(convertedListener, ctxt);
ReleaseMessageServiceFromURI(aMsgUri, msgService);
return rv;

Просмотреть файл

@ -141,7 +141,7 @@ nsMsgSendLater::~nsMsgSendLater()
// Stream is done...drive on!
nsresult
nsMsgSendLater::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg)
nsMsgSendLater::OnStopRequest(nsIChannel *channel, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg)
{
nsresult rv;
@ -179,10 +179,6 @@ nsMsgSendLater::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult s
}
else
{
nsCOMPtr<nsIChannel> channel;
request->GetParent(getter_AddRefs(channel));
if(!channel) return NS_ERROR_FAILURE;
// extract the prompt object to use for the alert from the url....
nsCOMPtr<nsIURI> uri;
nsCOMPtr<nsIPrompt> promptObject;
@ -264,7 +260,7 @@ nsMsgSendLater::BuildNewBuffer(const char* aBuf, PRUint32 aCount, PRUint32 *tota
// Got data?
nsresult
nsMsgSendLater::OnDataAvailable(nsIRequest *request, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count)
nsMsgSendLater::OnDataAvailable(nsIChannel *channel, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count)
{
// This is a little bit tricky since we have to chop random
// buffers into lines and deliver the lines...plus keeping the
@ -320,7 +316,7 @@ nsMsgSendLater::OnDataAvailable(nsIRequest *request, nsISupports *ctxt, nsIInput
}
nsresult
nsMsgSendLater::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
nsMsgSendLater::OnStartRequest(nsIChannel *channel, nsISupports *ctxt)
{
return NS_OK;
}

Просмотреть файл

@ -386,7 +386,7 @@ const char * nsSmtpProtocol::GetUserDomainName()
////////////////////////////////////////////////////////////////////////////////////////////
// stop binding is a "notification" informing us that the stream associated with aURL is going away.
NS_IMETHODIMP nsSmtpProtocol::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg)
NS_IMETHODIMP nsSmtpProtocol::OnStopRequest(nsIChannel * /* aChannel */, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg)
{
nsMsgProtocol::OnStopRequest(nsnull, ctxt, aStatus, aMsg);

Просмотреть файл

@ -119,7 +119,7 @@ public:
////////////////////////////////////////////////////////////////////////////////////////
// stop binding is a "notification" informing us that the stream associated with aURL is going away.
NS_IMETHOD OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg);
NS_IMETHOD OnStopRequest(nsIChannel * aChannel, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg);
private:
// logon redirection related variables and methods

Просмотреть файл

@ -244,15 +244,14 @@ NS_IMETHODIMP nsSmtpService::GetDefaultPort(PRInt32 *aDefaultPort)
// But we need to have a channel to return for nsSmtpService::NewChannel
// that can simulate a real channel such that the uri loader can then get the
// content type for the channel.
class nsMailtoChannel : public nsIChannel, public nsIRequest, public nsIStreamContentInfo
class nsMailtoChannel : public nsIChannel
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSICHANNEL
NS_DECL_NSIREQUEST
NS_DECL_NSISTREAMCONTENTINFO
nsMailtoChannel(nsIURI * aURI);
virtual ~nsMailtoChannel();
@ -325,26 +324,24 @@ NS_IMETHODIMP nsMailtoChannel::SetURI(nsIURI* aURI)
return NS_OK;
}
NS_IMETHODIMP nsMailtoChannel::OpenInputStream(PRUint32 transferOffset, PRUint32 transferCount, nsIInputStream **_retval)
NS_IMETHODIMP nsMailtoChannel::OpenInputStream(nsIInputStream **_retval)
{
NS_NOTREACHED("OpenInputStream");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMailtoChannel::OpenOutputStream(PRUint32 transferOffset, PRUint32 transferCount, nsIOutputStream **_retval)
NS_IMETHODIMP nsMailtoChannel::OpenOutputStream(nsIOutputStream **_retval)
{
NS_NOTREACHED("OpenOutputStream");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMailtoChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt,
PRUint32 transferOffset, PRUint32 transferCount, nsIRequest **_retval)
NS_IMETHODIMP nsMailtoChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt)
{
return listener->OnStartRequest(this, ctxt);
}
NS_IMETHODIMP nsMailtoChannel::AsyncWrite(nsIInputStream *fromStream, nsIStreamObserver *observer, nsISupports *ctxt,
PRUint32 transferOffset, PRUint32 transferCount, nsIRequest **_retval)
NS_IMETHODIMP nsMailtoChannel::AsyncWrite(nsIStreamProvider *provider, nsISupports *ctxt)
{
NS_NOTREACHED("AsyncWrite");
return NS_ERROR_NOT_IMPLEMENTED;
@ -385,6 +382,83 @@ nsMailtoChannel::SetContentLength(PRInt32 aContentLength)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsMailtoChannel::GetTransferOffset(PRUint32 *aTransferOffset)
{
NS_NOTREACHED("GetTransferOffset");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsMailtoChannel::SetTransferOffset(PRUint32 aTransferOffset)
{
NS_NOTREACHED("SetTransferOffset");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsMailtoChannel::GetTransferCount(PRInt32 *aTransferCount)
{
NS_NOTREACHED("GetTransferCount");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsMailtoChannel::SetTransferCount(PRInt32 aTransferCount)
{
NS_NOTREACHED("SetTransferCount");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsMailtoChannel::GetBufferSegmentSize(PRUint32 *aBufferSegmentSize)
{
NS_NOTREACHED("GetBufferSegmentSize");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsMailtoChannel::SetBufferSegmentSize(PRUint32 aBufferSegmentSize)
{
NS_NOTREACHED("SetBufferSegmentSize");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsMailtoChannel::GetBufferMaxSize(PRUint32 *aBufferMaxSize)
{
NS_NOTREACHED("GetBufferMaxSize");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsMailtoChannel::SetBufferMaxSize(PRUint32 aBufferMaxSize)
{
NS_NOTREACHED("SetBufferMaxSize");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsMailtoChannel::GetLocalFile(nsIFile* *file)
{
NS_NOTREACHED("GetLocalFile");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsMailtoChannel::GetPipeliningAllowed(PRBool *aPipeliningAllowed)
{
*aPipeliningAllowed = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
nsMailtoChannel::SetPipeliningAllowed(PRBool aPipeliningAllowed)
{
NS_NOTREACHED("SetPipeliningAllowed");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMailtoChannel::GetOwner(nsISupports * *aPrincipal)
{
NS_NOTREACHED("GetOwner");
@ -437,17 +511,6 @@ NS_IMETHODIMP nsMailtoChannel::Resume()
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute nsISupports parent; */
NS_IMETHODIMP nsMailtoChannel::GetParent(nsISupports * *aParent)
{
NS_ADDREF(*aParent=(nsISupports*)(nsIChannel*)this);
return NS_OK;
}
NS_IMETHODIMP nsMailtoChannel::SetParent(nsISupports * aParent)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
// the smtp service is also the protocol handler for mailto urls....

Просмотреть файл

@ -40,7 +40,6 @@
#include "nsMimeTypes.h"
#include "nsIHTTPChannel.h"
#include "nsIWebProgress.h"
#include "nsIStreamContentInfo.h"
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
@ -162,7 +161,7 @@ NS_IMETHODIMP
nsURLFetcher::DoContent(const char * aContentType,
nsURILoadCommand aCommand,
const char * aWindowTarget,
nsIRequest *request,
nsIChannel * aOpenedChannel,
nsIStreamListener ** aContentHandler,
PRBool * aAbortProcess)
{
@ -230,7 +229,7 @@ nsURLFetcher::StillRunning(PRBool *running)
// Methods for nsIStreamListener...
nsresult
nsURLFetcher::OnDataAvailable(nsIRequest *request, nsISupports * ctxt, nsIInputStream *aIStream,
nsURLFetcher::OnDataAvailable(nsIChannel * aChannel, nsISupports * ctxt, nsIInputStream *aIStream,
PRUint32 sourceOffset, PRUint32 aLength)
{
PRUint32 readLen = aLength;
@ -263,13 +262,13 @@ nsURLFetcher::OnDataAvailable(nsIRequest *request, nsISupports * ctxt, nsIInputS
// Methods for nsIStreamObserver
nsresult
nsURLFetcher::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
nsURLFetcher::OnStartRequest(nsIChannel *aChannel, nsISupports *ctxt)
{
return NS_OK;
}
nsresult
nsURLFetcher::OnStopRequest(nsIRequest *request, nsISupports * /* ctxt */, nsresult aStatus, const PRUnichar* aMsg)
nsURLFetcher::OnStopRequest(nsIChannel *aChannel, nsISupports * /* ctxt */, nsresult aStatus, const PRUnichar* aMsg)
{
#ifdef NS_DEBUG_rhp
printf("nsURLFetcher::OnStopRequest()\n");
@ -294,31 +293,29 @@ nsURLFetcher::OnStopRequest(nsIRequest *request, nsISupports * /* ctxt */, nsres
mOutStream = nsnull;
}
// Check the content type!
char *contentType = nsnull;
char *charset = nsnull;
nsCOMPtr<nsIStreamContentInfo> contentInfo = do_QueryInterface(request);
if (contentInfo && NS_SUCCEEDED(contentInfo->GetContentType(&contentType)) && contentType)
if (aChannel)
{
if (PL_strcasecmp(contentType, UNKNOWN_CONTENT_TYPE))
{
mContentType = contentType;
}
}
char *contentType = nsnull;
char *charset = nsnull;
nsCOMPtr<nsIChannel> aChannel;
request->GetParent(getter_AddRefs(aChannel));
if(!aChannel) return NS_ERROR_FAILURE;
nsCOMPtr<nsIHTTPChannel> httpChannel = do_QueryInterface(aChannel);
if (httpChannel)
{
if (NS_SUCCEEDED(httpChannel->GetCharset(&charset)) && charset)
if (NS_SUCCEEDED(aChannel->GetContentType(&contentType)) && contentType)
{
mCharset = charset;
if (PL_strcasecmp(contentType, UNKNOWN_CONTENT_TYPE))
{
mContentType = contentType;
}
}
}
nsCOMPtr<nsIHTTPChannel> httpChannel = do_QueryInterface(aChannel);
if (httpChannel)
{
if (NS_SUCCEEDED(httpChannel->GetCharset(&charset)) && charset)
{
mCharset = charset;
}
}
}
// Now if there is a callback, we need to call it...
if (mCallback)
@ -404,7 +401,10 @@ nsURLFetcher::OnStateChange(nsIWebProgress *aProgress, nsIRequest *aRequest,
// the url....
if (NS_FAILED(aStatus))
OnStopRequest(aRequest, nsnull, aStatus, nsnull);
{
nsCOMPtr<nsIChannel> channel (do_QueryInterface(aRequest));
OnStopRequest(channel, nsnull, aStatus, nsnull);
}
return NS_OK;
}

Просмотреть файл

@ -1,210 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Pierre Phaneuf <pp@ludusdesign.com>
*/
#include "nsCOMPtr.h"
#include "stdio.h"
#include "nscore.h"
#include "nsIFactory.h"
#include "nsISupports.h"
#include "comi18n.h"
#include "prmem.h"
#include "plstr.h"
#include "nsRepository.h"
#include "nsIURL.h"
#include "nsString.h"
#include "nsIServiceManager.h"
#include "nsURLFetcher.h"
#include "nsIIOService.h"
#include "nsIChannel.h"
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
/*
* This function will be used by the factory to generate an
* mime object class object....
*/
nsresult NS_NewURLFetcher(nsURLFetcher ** aInstancePtrResult)
{
//nsresult result = NS_OK;
NS_PRECONDITION(nsnull != aInstancePtrResult, "nsnull ptr");
if (nsnull != aInstancePtrResult)
{
nsURLFetcher *obj = new nsURLFetcher();
if (obj)
return obj->QueryInterface(NS_GET_IID(nsIStreamListener), (void**) aInstancePtrResult);
else
return NS_ERROR_OUT_OF_MEMORY; // we couldn't allocate the object
}
else
return NS_ERROR_NULL_POINTER; // aInstancePtrResult was NULL....
}
// The following macros actually implement addref, release and
// query interface for our component.
NS_IMPL_ISUPPORTS1(nsURLFetcher, nsIStreamListener)
/*
* Inherited methods for nsMimeConverter
*/
nsURLFetcher::nsURLFetcher()
{
/* the following macro is used to initialize the ref counting data */
NS_INIT_REFCNT();
// Init member variables...
mOutStream = nsnull;
mTotalWritten = 0;
mStillRunning = PR_TRUE;
mCallback = nsnull;
}
nsURLFetcher::~nsURLFetcher()
{
mStillRunning = PR_FALSE;
}
nsresult
nsURLFetcher::StillRunning(PRBool *running)
{
*running = mStillRunning;
return NS_OK;
}
/**
* Notify the client that data is available in the input stream. This
* method is called whenver data is written into the input stream by the
* networking library...<BR><BR>
*
* @param pIStream The input stream containing the data. This stream can
* be either a blocking or non-blocking stream.
* @param length The amount of data that was just pushed into the stream.
* @return The return value is currently ignored.
*/
nsresult
nsURLFetcher::OnDataAvailable(nsIRequest *request, nsISupports * ctxt, nsIInputStream *aIStream,
PRUint32 sourceOffset, PRUint32 aLength)
{
nsresult rc = NS_OK;
PRUint32 readLen = aLength;
if (!mOutStream)
return NS_ERROR_FAILURE;
char *buf = (char *)PR_Malloc(aLength);
if (!buf)
return NS_ERROR_OUT_OF_MEMORY; /* we couldn't allocate the object */
// read the data from the input stram...
nsresult rv = aIStream->Read(buf, aLength, &readLen);
if (NS_FAILED(rv)) return rv;
// write to the output file...
mTotalWritten += mOutStream->write(buf, readLen);
PR_FREEIF(buf);
return rc;
}
// Methods for nsIStreamObserver
/**
* Notify the observer that the URL has started to load. This method is
* called only once, at the beginning of a URL load.<BR><BR>
*
* @return The return value is currently ignored. In the future it may be
* used to cancel the URL load..
*/
nsresult
nsURLFetcher::OnStartRequest(nsIRequest *request, nsISupports * ctxt)
{
return NS_OK;
}
/**
* Notify the observer that the URL has finished loading. This method is
* called once when the networking library has finished processing the
* URL transaction initiatied via the nsINetService::Open(...) call.<BR><BR>
*
* This method is called regardless of whether the URL loaded successfully.<BR><BR>
*
* @param status Status code for the URL load.
* @param msg A text string describing the error.
* @return The return value is currently ignored.
*/
nsresult
nsURLFetcher::OnStopRequest(nsIRequest *request, nsISupports * /* ctxt */, nsresult aStatus, const PRUnichar* aMsg)
{
#ifdef NS_DEBUG_rhp
printf("nsURLFetcher::OnStopRequest()\n");
#endif
//
// Now complete the stream!
//
mStillRunning = PR_FALSE;
// First close the output stream...
if (mOutStream)
mOutStream->close();
// Now if there is a callback, we need to call it...
if (mCallback)
mCallback (mURL, aStatus, mTotalWritten, aMsg, mTagData);
// Time to return...
return NS_OK;
}
nsresult
nsURLFetcher::FireURLRequest(nsIURI *aURL, nsOutputFileStream *fOut,
nsAttachSaveCompletionCallback cb, void *tagData)
{
nsresult rv;
if ( (!aURL) || (!fOut) )
{
return NS_ERROR_INVALID_ARG;
}
if (!fOut->is_open())
{
return NS_ERROR_FAILURE;
}
NS_WITH_SERVICE(nsIIOService, service, kIOServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIChannel> channel;
rv = service->NewChannelFromURI(aURL, getter_AddRefs(channel));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIRequest> request;
rv = channel->AsyncRead(this, nsnull, 0, -1, getter_AddRefs(request));
if (NS_FAILED(rv)) return rv;
mURL = dont_QueryInterface(aURL);
mOutStream = fOut;
mCallback = cb;
mTagData = tagData;
NS_ADDREF(this);
return NS_OK;
}

Просмотреть файл

@ -1,107 +0,0 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsURLFetcher_h_
#define nsURLFetcher_h_
#include "nsCOMPtr.h"
#include "nsFileStream.h"
#include "nsIStreamListener.h"
#include "nsIURI.h"
//
// Callback declarations for URL completion
//
// For completion of send/message creation operations...
typedef nsresult (*nsAttachSaveCompletionCallback) (nsIURI* aURL, nsresult aStatus,
PRInt32 totalSize, const PRUnichar* aMsg,
void *tagData);
class nsURLFetcher : public nsIStreamListener {
public:
nsURLFetcher();
virtual ~nsURLFetcher();
/* this macro defines QueryInterface, AddRef and Release for this class */
NS_DECL_ISUPPORTS
//
// This is the output stream where the stream converter will write processed data after
// conversion.
//
NS_IMETHOD StillRunning(PRBool *running);
NS_IMETHOD FireURLRequest(nsIURI *aURL, nsOutputFileStream *fOut,
nsAttachSaveCompletionCallback cb, void *tagData);
/**
* Notify the client that data is available in the input stream. This
* method is called whenver data is written into the input stream by the
* networking library...<BR><BR>
*
* @param pIStream The input stream containing the data. This stream can
* be either a blocking or non-blocking stream.
* @param length The amount of data that was just pushed into the stream.
* @return The return value is currently ignored.
*/
NS_IMETHOD OnDataAvailable(nsIRequest *request, nsISupports * ctxt, nsIInputStream *aIStream,
PRUint32 sourceOffset, PRUint32 aLength);
// Methods for nsIStreamObserver
/**
* Notify the observer that the URL has started to load. This method is
* called only once, at the beginning of a URL load.<BR><BR>
*
* @return The return value is currently ignored. In the future it may be
* used to cancel the URL load..
*/
NS_IMETHOD OnStartRequest(nsIRequest *request, nsISupports * aCtxt);
/**
* Notify the observer that the URL has finished loading. This method is
* called once when the networking library has finished processing the
* URL transaction initiatied via the nsINetService::Open(...) call.<BR><BR>
*
* This method is called regardless of whether the URL loaded successfully.<BR><BR>
*
* @param status Status code for the URL load.
* @param msg A text string describing the error.
* @return The return value is currently ignored.
*/
NS_IMETHOD OnStopRequest(nsIRequest *request, nsISupports * /* ctxt */, nsresult aStatus, const PRUnichar* aMsg);
private:
nsOutputFileStream *mOutStream; // the output file stream
PRBool mStillRunning; // Are we still running?
PRInt32 mTotalWritten; // Size counter variable
nsCOMPtr<nsIURI> mURL; // URL being processed
void *mTagData; // Tag data for callback...
nsAttachSaveCompletionCallback mCallback; // Callback to call once the file is saved...
};
/* this function will be used by the factory to generate an class access object....*/
extern nsresult NS_NewURLFetcher(nsURLFetcher **aInstancePtrResult);
#endif /* nsURLFetcher_h_ */

Просмотреть файл

@ -476,10 +476,7 @@ nsImapIncomingServer::LoadNextQueuedUrl(PRBool *aResult)
if (NS_SUCCEEDED(aImapUrl->GetMockChannel(getter_AddRefs(mockChannel))) && mockChannel)
{
nsCOMPtr<nsIRequest> request = do_QueryInterface(mockChannel);
if (!request)
return NS_ERROR_FAILURE;
request->GetStatus(&rv);
mockChannel->GetStatus(&rv);
if (!NS_SUCCEEDED(rv))
{
nsresult res;

Просмотреть файл

@ -913,7 +913,7 @@ NS_IMETHODIMP nsImapMailFolder::EmptyTrash(nsIMsgWindow *msgWindow,
if (empytingOnExit)
{
nsCOMPtr<nsIImapIncomingServer> imapServer;
rv = GetImapIncomingServer(getter_AddRefs(imapServer));
nsresult rv = GetImapIncomingServer(getter_AddRefs(imapServer));
if (NS_SUCCEEDED(rv) && imapServer)
{
@ -3389,18 +3389,18 @@ nsImapMailFolder::SetContentModified(nsIImapUrl *aImapUrl, nsImapContentModified
// to hook up the mock channel and other stuff when downloading messages for offline use.
// But we don't really need to do anything with these notifications because we use
// the nsIImapMesageSink interfaces ParseAdoptedMessageLine and NormalEndMsgWriteStream
NS_IMETHODIMP nsImapMailFolder::OnDataAvailable(nsIRequest * /* request */, nsISupports *ctxt, nsIInputStream *aIStream, PRUint32 sourceOffset, PRUint32 aLength)
NS_IMETHODIMP nsImapMailFolder::OnDataAvailable(nsIChannel * /* aChannel */, nsISupports *ctxt, nsIInputStream *aIStream, PRUint32 sourceOffset, PRUint32 aLength)
{
nsresult rv = NS_OK;
return rv;
}
NS_IMETHODIMP nsImapMailFolder::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
NS_IMETHODIMP nsImapMailFolder::OnStartRequest(nsIChannel * aChannel, nsISupports *ctxt)
{
return NS_OK;
}
NS_IMETHODIMP nsImapMailFolder::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg)
NS_IMETHODIMP nsImapMailFolder::OnStopRequest(nsIChannel * aChannel, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg)
{
return NS_OK;
}
@ -3951,9 +3951,7 @@ nsresult nsImapMailFolder::DisplayStatusMsg(nsIImapUrl *aImapUrl, const PRUnicha
mockChannel->GetProgressEventSink(getter_AddRefs(progressSink));
if (progressSink)
{
nsCOMPtr<nsIRequest> request = do_QueryInterface(mockChannel);
if (!request) return NS_ERROR_FAILURE;
progressSink->OnStatus(request, nsnull, NS_OK, msg); // XXX i18n message
progressSink->OnStatus(mockChannel, nsnull, NS_OK, msg); // XXX i18n message
}
}
return NS_OK;
@ -4016,12 +4014,9 @@ nsImapMailFolder::PercentProgress(nsIImapProtocol* aProtocol,
mockChannel->GetProgressEventSink(getter_AddRefs(progressSink));
if (progressSink)
{
nsCOMPtr<nsIRequest> request = do_QueryInterface(mockChannel);
if (!request) return NS_ERROR_FAILURE;
progressSink->OnProgress(request, nsnull, aInfo->currentProgress, aInfo->maxProgress);
progressSink->OnProgress(mockChannel, nsnull, aInfo->currentProgress, aInfo->maxProgress);
if (aInfo->message)
progressSink->OnStatus(request, nsnull, NS_OK, aInfo->message); // XXX i18n message
progressSink->OnStatus(mockChannel, nsnull, NS_OK, aInfo->message); // XXX i18n message
}

Просмотреть файл

@ -600,7 +600,7 @@ nsresult nsImapProtocol::SetupWithUrl(nsIURI * aURL, nsISupports* aConsumer)
rv = socketService->CreateTransportOfType(connectionType, hostName, port, nsnull, -1, 0, 0, getter_AddRefs(m_channel));
if (NS_SUCCEEDED(rv))
rv = m_channel->OpenOutputStream(0, -1, getter_AddRefs(m_outputStream));
rv = m_channel->OpenOutputStream(getter_AddRefs(m_outputStream));
}
} // if m_runningUrl
@ -997,8 +997,7 @@ PRBool nsImapProtocol::ProcessCurrentURL()
if (!TestFlag(IMAP_CONNECTION_IS_OPEN) && m_channel)
{
nsCOMPtr<nsIRequest> request;
m_channel->AsyncRead(this /* stream observer */, nsnull, 0, -1, getter_AddRefs(request));
m_channel->AsyncRead(this /* stream observer */, nsnull);
SetFlag(IMAP_CONNECTION_IS_OPEN);
}
#ifdef DEBUG_bienvenu
@ -1030,10 +1029,9 @@ PRBool nsImapProtocol::ProcessCurrentURL()
// if we are set up as a channel, we should notify our channel listener that we are starting...
// so pass in ourself as the channel and not the underlying socket or file channel the protocol
// happens to be using
if (m_channelListener) {
nsCOMPtr<nsIRequest> request = do_QueryInterface(m_mockChannel);
m_channelListener->OnStartRequest(request, m_channelContext);
}
if (m_channelListener)
m_channelListener->OnStartRequest(m_mockChannel, m_channelContext);
// mscott - I believe whenever we get here that we will also have
// a connection. Why? Because when we load the url we open the
// connection if it isn't open already....However, if we haven't received
@ -1118,13 +1116,9 @@ PRBool nsImapProtocol::ProcessCurrentURL()
// if we are set up as a channel, we should notify our channel listener that we are starting...
// so pass in ourself as the channel and not the underlying socket or file channel the protocol
// happens to be using
if (m_channelListener)
{
nsCOMPtr<nsIRequest> request = do_QueryInterface(m_mockChannel);
if (!request) return NS_ERROR_FAILURE;
if (m_channelListener)
rv = m_channelListener->OnStopRequest(m_mockChannel, m_channelContext, NS_OK, nsnull);
rv = m_channelListener->OnStopRequest(request, m_channelContext, NS_OK, nsnull);
}
m_lastActiveTime = PR_Now(); // ** jt -- is this the best place for time stamp
SetFlag(IMAP_CLEAN_UP_URL_STATE);
if (NS_SUCCEEDED(rv) && GetConnectionStatus() >= 0 && GetServerStateParser().LastCommandSuccessful()
@ -1188,7 +1182,7 @@ void nsImapProtocol::ParseIMAPandCheckForNewMail(const char* commandString, PRBo
/////////////////////////////////////////////////////////////////////////////////////////////
// we suppport the nsIStreamListener interface
////////////////////////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP nsImapProtocol::OnDataAvailable(nsIRequest *request, nsISupports *ctxt, nsIInputStream *aIStream, PRUint32 aSourceOffset, PRUint32 aLength)
NS_IMETHODIMP nsImapProtocol::OnDataAvailable(nsIChannel * /* aChannel */, nsISupports *ctxt, nsIInputStream *aIStream, PRUint32 aSourceOffset, PRUint32 aLength)
{
nsresult res = NS_OK;
@ -1212,7 +1206,7 @@ NS_IMETHODIMP nsImapProtocol::OnDataAvailable(nsIRequest *request, nsISupports *
return res;
}
NS_IMETHODIMP nsImapProtocol::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
NS_IMETHODIMP nsImapProtocol::OnStartRequest(nsIChannel * /* aChannel */, nsISupports *ctxt)
{
// we used to change the url state here......but OnStartRequest only gets called
// once....when the connnection is first build from necko...So we'll set the url
@ -1229,7 +1223,7 @@ NS_IMETHODIMP nsImapProtocol::OnStartRequest(nsIRequest *request, nsISupports *c
}
// stop binding is a "notification" informing us that the stream associated with aURL is going away.
NS_IMETHODIMP nsImapProtocol::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aMsg)
NS_IMETHODIMP nsImapProtocol::OnStopRequest(nsIChannel * /* aChannel */, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aMsg)
{
PRBool killThread = PR_FALSE;
@ -2805,11 +2799,8 @@ nsImapProtocol::PostLineDownLoadEvent(msg_line_info *downloadLineDontDelete)
{
nsresult rv = m_channelOutputStream->Write(line, PL_strlen(line), &count);
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIRequest> request = do_QueryInterface(m_mockChannel);
m_channelListener->OnDataAvailable(request, m_channelContext, m_channelInputStream, 0, count);
}
// here is where we should echo the line to the local folder copy of an online message
m_channelListener->OnDataAvailable(m_mockChannel, m_channelContext, m_channelInputStream, 0, count);
// here is where we should echo the line to the local folder copy of an online message
}
if (m_imapMessageSink)
m_imapMessageSink->GetNotifyDownloadedLines(&echoLineToMessageSink);
@ -3497,11 +3488,8 @@ PRBool nsImapProtocol::DeathSignalReceived()
// ignore mock channel status if we've been pseudo interrupted
// ### need to make sure we clear pseudo interrupted status appropriately.
if (!GetPseudoInterrupted() && m_mockChannel)
{
nsCOMPtr<nsIRequest> request = do_QueryInterface(m_mockChannel);
if (request)
request->GetStatus(&returnValue);
}
m_mockChannel->GetStatus(&returnValue);
if (NS_SUCCEEDED(returnValue)) // check the other way of cancelling.
{
PR_EnterMonitor(m_threadDeathMonitor);
@ -6699,23 +6687,23 @@ nsresult nsImapCacheStreamListener::Init(nsIStreamListener * aStreamListener, ns
}
NS_IMETHODIMP
nsImapCacheStreamListener::OnStartRequest(nsIRequest *request, nsISupports * aCtxt)
nsImapCacheStreamListener::OnStartRequest(nsIChannel * aChannel, nsISupports * aCtxt)
{
nsCOMPtr <nsILoadGroup> loadGroup;
mChannelToUse->GetLoadGroup(getter_AddRefs(loadGroup));
if (loadGroup)
loadGroup->AddRequest(request, nsnull /* context isupports */);
return mListener->OnStartRequest(request, aCtxt);
loadGroup->AddChannel(mChannelToUse, nsnull /* context isupports */);
return mListener->OnStartRequest(mChannelToUse, aCtxt);
}
NS_IMETHODIMP
nsImapCacheStreamListener::OnStopRequest(nsIRequest *request, nsISupports * aCtxt, nsresult aStatus, const PRUnichar* aMsg)
nsImapCacheStreamListener::OnStopRequest(nsIChannel * aChannel, nsISupports * aCtxt, nsresult aStatus, const PRUnichar* aMsg)
{
nsresult rv = mListener->OnStopRequest(request, aCtxt, aStatus, aMsg);
nsresult rv = mListener->OnStopRequest(mChannelToUse, aCtxt, aStatus, aMsg);
nsCOMPtr <nsILoadGroup> loadGroup;
mChannelToUse->GetLoadGroup(getter_AddRefs(loadGroup));
if (loadGroup)
loadGroup->RemoveRequest(request, nsnull, aStatus, nsnull);
loadGroup->RemoveChannel(mChannelToUse, nsnull, aStatus, nsnull);
mListener = nsnull;
mChannelToUse = nsnull;
@ -6723,9 +6711,9 @@ nsImapCacheStreamListener::OnStopRequest(nsIRequest *request, nsISupports * aCtx
}
NS_IMETHODIMP
nsImapCacheStreamListener::OnDataAvailable(nsIRequest *request, nsISupports * aCtxt, nsIInputStream * aInStream, PRUint32 aSourceOffset, PRUint32 aCount)
nsImapCacheStreamListener::OnDataAvailable(nsIChannel * aChannel, nsISupports * aCtxt, nsIInputStream * aInStream, PRUint32 aSourceOffset, PRUint32 aCount)
{
return mListener->OnDataAvailable(request, aCtxt, aInStream, aSourceOffset, aCount);
return mListener->OnDataAvailable(mChannelToUse, aCtxt, aInStream, aSourceOffset, aCount);
}
NS_IMPL_THREADSAFE_ADDREF(nsImapMockChannel)
@ -6845,20 +6833,19 @@ NS_IMETHODIMP nsImapMockChannel::SetURI(nsIURI* aURI)
return NS_OK;
}
NS_IMETHODIMP nsImapMockChannel::OpenInputStream(PRUint32 transferOffset, PRUint32 transferCount, nsIInputStream **_retval)
NS_IMETHODIMP nsImapMockChannel::OpenInputStream(nsIInputStream **_retval)
{
NS_NOTREACHED("nsImapMockChannel::OpenInputStream");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsImapMockChannel::OpenOutputStream(PRUint32 transferOffset, PRUint32 transferCount, nsIOutputStream **_retval)
NS_IMETHODIMP nsImapMockChannel::OpenOutputStream(nsIOutputStream **_retval)
{
NS_NOTREACHED("nsImapMockChannel::OpenOutputStream");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsImapMockChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt,
PRUint32 transferOffset, PRUint32 transferCount, nsIRequest **_retval)
NS_IMETHODIMP nsImapMockChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt)
{
nsCOMPtr<nsICachedNetData> cacheEntry;
PRUint32 contentLength = 0;
@ -6938,8 +6925,7 @@ NS_IMETHODIMP nsImapMockChannel::AsyncRead(nsIStreamListener *listener, nsISuppo
nsImapCacheStreamListener * cacheListener = new nsImapCacheStreamListener();
NS_ADDREF(cacheListener);
cacheListener->Init(m_channelListener, NS_STATIC_CAST(nsIChannel *, this));
nsCOMPtr<nsIRequest> request;
rv = cacheChannel->AsyncRead(cacheListener, m_channelContext, 0, -1, getter_AddRefs(request));
rv = cacheChannel->AsyncRead(cacheListener, m_channelContext);
NS_RELEASE(cacheListener);
if (NS_SUCCEEDED(rv)) // ONLY if we succeeded in actually starting the read should we return
@ -6951,7 +6937,7 @@ NS_IMETHODIMP nsImapMockChannel::AsyncRead(nsIStreamListener *listener, nsISuppo
nsCOMPtr<nsISupports> securityInfo;
cacheEntry->GetSecurityInfo(getter_AddRefs(securityInfo));
SetSecurityInfo(securityInfo);
NS_ADDREF(*_retval = (nsIRequest*)this);
return rv;
}
}
@ -6972,8 +6958,7 @@ NS_IMETHODIMP nsImapMockChannel::AsyncRead(nsIStreamListener *listener, nsISuppo
// we want to create a file channel and read the msg from there.
nsCOMPtr<nsIFileChannel> fileChannel;
nsMsgKey msgKey = atoi(messageIdString);
PRUint32 size, offset;
rv = folder->GetOfflineFileChannel(msgKey, &offset, &size, getter_AddRefs(fileChannel));
rv = folder->GetOfflineFileChannel(msgKey, getter_AddRefs(fileChannel));
// get the file channel from the folder, somehow (through the message or
// folder sink?) We also need to set the transfer offset to the message offset
if (fileChannel && NS_SUCCEEDED(rv))
@ -6987,8 +6972,7 @@ NS_IMETHODIMP nsImapMockChannel::AsyncRead(nsIStreamListener *listener, nsISuppo
nsImapCacheStreamListener * cacheListener = new nsImapCacheStreamListener();
NS_ADDREF(cacheListener);
cacheListener->Init(m_channelListener, NS_STATIC_CAST(nsIChannel *, this));
nsCOMPtr<nsIRequest> request;
rv = fileChannel->AsyncRead(cacheListener, m_channelContext, offset, size, getter_AddRefs(request));
rv = fileChannel->AsyncRead(cacheListener, m_channelContext);
NS_RELEASE(cacheListener);
if (NS_SUCCEEDED(rv)) // ONLY if we succeeded in actually starting the read should we return
@ -6996,7 +6980,6 @@ NS_IMETHODIMP nsImapMockChannel::AsyncRead(nsIStreamListener *listener, nsISuppo
// if the msg is unread, we should mark it read on the server. This lets
// the code running this url we're loading from the cache, if it cares.
imapUrl->SetMsgLoadingFromCache(PR_TRUE);
NS_ADDREF(*_retval = (nsIRequest*)this);
return rv;
}
}
@ -7022,13 +7005,10 @@ NS_IMETHODIMP nsImapMockChannel::AsyncRead(nsIStreamListener *listener, nsISuppo
rv = pEventQService->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(queue));
if (NS_FAILED(rv)) return rv;
rv = imapServer->GetImapConnectionAndLoadUrl(queue, imapUrl, nsnull);
if(NS_SUCCEEDED(rv))
NS_ADDREF(*_retval = (nsIRequest*)this);
return rv;
}
NS_IMETHODIMP nsImapMockChannel::AsyncWrite(nsIInputStream *fromStream, nsIStreamObserver *observer, nsISupports *ctxt,
PRUint32 transferOffset, PRUint32 transferCount, nsIRequest **_retval)
NS_IMETHODIMP nsImapMockChannel::AsyncWrite(nsIStreamProvider *provider, nsISupports *ctxt)
{
NS_NOTREACHED("nsImapMockChannel::AsyncWrite");
return NS_ERROR_NOT_IMPLEMENTED;
@ -7075,6 +7055,83 @@ nsImapMockChannel::SetContentLength(PRInt32 aContentLength)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsImapMockChannel::GetTransferOffset(PRUint32 *aTransferOffset)
{
NS_NOTREACHED("nsImapMockChannel::GetTransferOffset");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsImapMockChannel::SetTransferOffset(PRUint32 aTransferOffset)
{
NS_NOTREACHED("nsImapMockChannel::SetTransferOffset");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsImapMockChannel::GetTransferCount(PRInt32 *aTransferCount)
{
NS_NOTREACHED("nsImapMockChannel::GetTransferCount");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsImapMockChannel::SetTransferCount(PRInt32 aTransferCount)
{
NS_NOTREACHED("nsImapMockChannel::SetTransferCount");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsImapMockChannel::GetBufferSegmentSize(PRUint32 *aBufferSegmentSize)
{
NS_NOTREACHED("nsImapMockChannel::GetBufferSegmentSize");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsImapMockChannel::SetBufferSegmentSize(PRUint32 aBufferSegmentSize)
{
NS_NOTREACHED("nsImapMockChannel::SetBufferSegmentSize");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsImapMockChannel::GetBufferMaxSize(PRUint32 *aBufferMaxSize)
{
NS_NOTREACHED("nsImapMockChannel::GetBufferMaxSize");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsImapMockChannel::SetBufferMaxSize(PRUint32 aBufferMaxSize)
{
NS_NOTREACHED("nsImapMockChannel::SetBufferMaxSize");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsImapMockChannel::GetLocalFile(nsIFile* *file)
{
NS_NOTREACHED("GetLocalFile");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsImapMockChannel::GetPipeliningAllowed(PRBool *aPipeliningAllowed)
{
*aPipeliningAllowed = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
nsImapMockChannel::SetPipeliningAllowed(PRBool aPipeliningAllowed)
{
NS_NOTREACHED("SetPipeliningAllowed");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsImapMockChannel::GetOwner(nsISupports * *aPrincipal)
{
*aPrincipal = mOwner;
@ -7128,18 +7185,6 @@ NS_IMETHODIMP nsImapMockChannel::Resume()
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute nsISupports parent; */
NS_IMETHODIMP nsImapMockChannel::GetParent(nsISupports * *aParent)
{
NS_ADDREF(*aParent=(nsISupports*)(nsIChannel*)this);
return NS_OK;
}
NS_IMETHODIMP nsImapMockChannel::SetParent(nsISupports * aParent)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsImapMockChannel::GetNotificationCallbacks(nsIInterfaceRequestor* *aNotificationCallbacks)
{

Просмотреть файл

@ -62,7 +62,6 @@
#include "nsXPIDLString.h"
#include "nsIMsgWindow.h"
#include "nsIMsgLogonRedirector.h"
#include "nsIStreamContentInfo.h"
class nsIMAPMessagePartIDArray;
class nsIMsgIncomingServer;
@ -577,7 +576,7 @@ private:
//
// Threading concern: This class lives entirely in the UI thread.
class nsImapMockChannel : public nsIImapMockChannel, public nsIRequest, public nsIStreamContentInfo
class nsImapMockChannel : public nsIImapMockChannel
{
public:
@ -585,7 +584,6 @@ public:
NS_DECL_NSIIMAPMOCKCHANNEL
NS_DECL_NSICHANNEL
NS_DECL_NSIREQUEST
NS_DECL_NSISTREAMCONTENTINFO
nsImapMockChannel();
virtual ~nsImapMockChannel();

Просмотреть файл

@ -671,9 +671,8 @@ nsresult nsImapService::FetchMimePart(nsIImapUrl * aImapUrl,
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsISupports> aCtxt = do_QueryInterface(url);
// now try to open the channel passing in our display consumer as the listener
nsCOMPtr<nsIRequest> request;
rv = aChannel->AsyncRead(aStreamListener, aCtxt, 0, -1, getter_AddRefs(request));
// now try to open the channel passing in our display consumer as the listener
rv = aChannel->AsyncRead(aStreamListener, aCtxt);
}
else // do what we used to do before
{
@ -1036,8 +1035,7 @@ nsImapService::FetchMessage(nsIImapUrl * aImapUrl,
nsCOMPtr<nsISupports> aCtxt = do_QueryInterface(url);
// now try to open the channel passing in our display consumer as the listener
nsCOMPtr<nsIRequest> request;
rv = aChannel->AsyncRead(aStreamListener, aCtxt, 0, -1, getter_AddRefs(request));
rv = aChannel->AsyncRead(aStreamListener, aCtxt);
}
else // do what we used to do before
{

Просмотреть файл

@ -1123,8 +1123,7 @@ NS_IMETHODIMP nsImapUrl::AddChannelToLoadGroup()
if (loadGroup)
{
nsCOMPtr<nsIRequest> request = do_QueryInterface(m_mockChannel);
loadGroup->AddRequest(request, nsnull /* context isupports */);
loadGroup->AddChannel(m_mockChannel, nsnull /* context isupports */);
}
}
return NS_OK;
@ -1142,8 +1141,7 @@ NS_IMETHODIMP nsImapUrl::RemoveChannel(nsresult status)
GetLoadGroup(getter_AddRefs(loadGroup));
if (loadGroup)
{
nsCOMPtr<nsIRequest> request = do_QueryInterface(m_mockChannel);
loadGroup->RemoveRequest(request, nsnull, status, nsnull);
loadGroup->RemoveChannel(m_mockChannel, nsnull, status, nsnull);
}
// break deadly embrace between mock channel and url
SetMockChannel(nsnull);

Просмотреть файл

@ -35,7 +35,6 @@
#include "nsIMessage.h"
#include "nsMsgDBCID.h"
#include "nsIMsgMailNewsUrl.h"
#include "nsIStreamContentInfo.h"
//#include "allxpstr.h"
#include "prtime.h"
@ -83,14 +82,11 @@ NS_IMETHODIMP nsMailboxProtocol::GetContentLength(PRInt32 * aContentLength)
{
// our file transport knows the entire length of the berkley mail folder
// so get it from there.
if (!m_request)
if (m_channel)
return m_channel->GetContentLength(aContentLength);
else
return NS_OK;
nsCOMPtr<nsIStreamContentInfo> info = do_QueryInterface(m_request);
if (info)
info->GetContentLength(aContentLength);
return NS_OK;
}
else if (m_runningUrl)
{
@ -148,7 +144,7 @@ void nsMailboxProtocol::Initialize(nsIURI * aURL)
// we suppport the nsIStreamListener interface
////////////////////////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP nsMailboxProtocol::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
NS_IMETHODIMP nsMailboxProtocol::OnStartRequest(nsIChannel * aChannel, nsISupports *ctxt)
{
// extract the appropriate event sinks from the url and initialize them in our protocol data
// the URL should be queried for a nsINewsURL. If it doesn't support a news URL interface then
@ -156,19 +152,19 @@ NS_IMETHODIMP nsMailboxProtocol::OnStartRequest(nsIRequest *request, nsISupports
if (m_nextState == MAILBOX_READ_FOLDER && m_mailboxParser)
{
// we need to inform our mailbox parser that it's time to start...
m_mailboxParser->OnStartRequest(request, ctxt);
m_mailboxParser->OnStartRequest(aChannel, ctxt);
}
return nsMsgProtocol::OnStartRequest(request, ctxt);
return nsMsgProtocol::OnStartRequest(aChannel, ctxt);
}
// stop binding is a "notification" informing us that the stream associated with aURL is going away.
NS_IMETHODIMP nsMailboxProtocol::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg)
NS_IMETHODIMP nsMailboxProtocol::OnStopRequest(nsIChannel * aChannel, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg)
{
if (m_nextState == MAILBOX_READ_FOLDER && m_mailboxParser)
{
// we need to inform our mailbox parser that there is no more incoming data...
m_mailboxParser->OnStopRequest(request, ctxt, aStatus, nsnull);
m_mailboxParser->OnStopRequest(aChannel, ctxt, aStatus, nsnull);
}
else if (m_nextState == MAILBOX_READ_MESSAGE)
{
@ -200,7 +196,7 @@ NS_IMETHODIMP nsMailboxProtocol::OnStopRequest(nsIRequest *request, nsISupports
*/
if (aStatus == NS_BINDING_ABORTED)
aStatus = NS_OK;
nsMsgProtocol::OnStopRequest(request, ctxt, aStatus, aMsg);
nsMsgProtocol::OnStopRequest(aChannel, ctxt, aStatus, aMsg);
return CloseSocket();
}
@ -483,8 +479,8 @@ nsresult nsMailboxProtocol::ProcessProtocolState(nsIURI * url, nsIInputStream *
case MAILBOX_DONE:
case MAILBOX_ERROR_DONE:
{
nsCOMPtr <nsIMsgMailNewsUrl> anotherUrl = do_QueryInterface(m_runningUrl);
anotherUrl->SetUrlState(PR_FALSE, m_nextState == MAILBOX_DONE ?
nsCOMPtr <nsIMsgMailNewsUrl> url = do_QueryInterface(m_runningUrl);
url->SetUrlState(PR_FALSE, m_nextState == MAILBOX_DONE ?
NS_OK : NS_ERROR_FAILURE);
m_nextState = MAILBOX_FREE;
}

Просмотреть файл

@ -76,8 +76,8 @@ public:
// we suppport the nsIStreamListener interface
////////////////////////////////////////////////////////////////////////////////////////
NS_IMETHOD OnStartRequest(nsIRequest *request, nsISupports *ctxt);
NS_IMETHOD OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg);
NS_IMETHOD OnStartRequest(nsIChannel * aChannel, nsISupports *ctxt);
NS_IMETHOD OnStopRequest(nsIChannel * aChannel, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg);
NS_IMETHOD GetContentLength(PRInt32 * aContentLength);
private:
@ -127,9 +127,3 @@ private:
};
#endif // nsMailboxProtocol_h___

Просмотреть файл

@ -62,7 +62,7 @@ NS_IMPL_ISUPPORTS_INHERITED(nsMsgMailboxParser, nsParseMailMessageState, nsIStre
// Whenever data arrives from the connection, core netlib notifices the protocol by calling
// OnDataAvailable. We then read and process the incoming data from the input stream.
NS_IMETHODIMP nsMsgMailboxParser::OnDataAvailable(nsIRequest *request, nsISupports *ctxt, nsIInputStream *aIStream, PRUint32 sourceOffset,
NS_IMETHODIMP nsMsgMailboxParser::OnDataAvailable(nsIChannel * /* aChannel */, nsISupports *ctxt, nsIInputStream *aIStream, PRUint32 sourceOffset,
PRUint32 aLength)
{
// right now, this really just means turn around and process the url
@ -73,7 +73,7 @@ NS_IMETHODIMP nsMsgMailboxParser::OnDataAvailable(nsIRequest *request, nsISuppor
return rv;
}
NS_IMETHODIMP nsMsgMailboxParser::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
NS_IMETHODIMP nsMsgMailboxParser::OnStartRequest(nsIChannel * /* aChannel */, nsISupports *ctxt)
{
nsTime currentTime;
m_startTime = currentTime;
@ -143,7 +143,7 @@ NS_IMETHODIMP nsMsgMailboxParser::OnStartRequest(nsIRequest *request, nsISupport
}
// stop binding is a "notification" informing us that the stream associated with aURL is going away.
NS_IMETHODIMP nsMsgMailboxParser::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg)
NS_IMETHODIMP nsMsgMailboxParser::OnStopRequest(nsIChannel * /* aChannel */, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg)
{
DoneParsingFolder(aStatus);
// what can we do? we can close the stream?

Просмотреть файл

@ -567,9 +567,9 @@ nsresult nsPop3Protocol::GetPassword(char ** aPassword, PRBool *okayValue)
}
// stop binding is a "notification" informing us that the stream associated with aURL is going away.
NS_IMETHODIMP nsPop3Protocol::OnStopRequest(nsIRequest *request, nsISupports * aContext, nsresult aStatus, const PRUnichar* aMsg)
NS_IMETHODIMP nsPop3Protocol::OnStopRequest(nsIChannel * aChannel, nsISupports * aContext, nsresult aStatus, const PRUnichar* aMsg)
{
nsresult rv = nsMsgProtocol::OnStopRequest(request, aContext, aStatus, aMsg);
nsresult rv = nsMsgProtocol::OnStopRequest(aChannel, aContext, aStatus, aMsg);
// turn off the server busy flag on stop request - we know we're done, right?
if (m_pop3Server)
{

Просмотреть файл

@ -258,7 +258,7 @@ public:
nsresult GetPassword(char ** aPassword, PRBool *okayValue);
NS_IMETHOD OnStopRequest(nsIRequest *request, nsISupports * aContext, nsresult aStatus, const PRUnichar* aMsg);
NS_IMETHOD OnStopRequest(nsIChannel * aChannel, nsISupports * aContext, nsresult aStatus, const PRUnichar* aMsg);
NS_IMETHOD Cancel(nsresult status);
// for nsMsgLineBuffer
virtual PRInt32 HandleLine(char *line, PRUint32 line_length);

Просмотреть файл

@ -45,7 +45,6 @@
#include "nsIMimeConverter.h"
#include "nsMsgMimeCID.h"
#include "prlog.h"
#include "nsIStreamContentInfo.h"
static PRLogModuleInfo * gMimeEmitterLogModule = nsnull;
@ -269,9 +268,7 @@ NS_IMETHODIMP nsMimeBaseEmitter::OnFull(nsIOutputStream* out)
PRUint32 bytesAvailable = 0;
rv = mInputStream->Available(&bytesAvailable);
NS_ASSERTION(NS_SUCCEEDED(rv), "Available failed");
// DOUGT - where did the request come from??!
rv = mOutListener->OnDataAvailable(/*mChannel*/nsnull, mURL, mInputStream, 0, bytesAvailable);
rv = mOutListener->OnDataAvailable(mChannel, mURL, mInputStream, 0, bytesAvailable);
}
else
rv = NS_ERROR_NULL_POINTER;
@ -522,12 +519,7 @@ nsMimeBaseEmitter::UpdateCharacterSet(const char *aCharset)
{
char *contentType = nsnull;
// check if the channel supports direct content info
nsCOMPtr<nsIStreamContentInfo> contentInfo = do_QueryInterface(mChannel);
if (!contentInfo)
return NS_ERROR_FAILURE;
if (NS_SUCCEEDED(contentInfo->GetContentType(&contentType)) && contentType)
if (NS_SUCCEEDED(mChannel->GetContentType(&contentType)) && contentType)
{
char *cPtr = (char *) PL_strcasestr(contentType, "charset=");
@ -552,7 +544,7 @@ nsMimeBaseEmitter::UpdateCharacterSet(const char *aCharset)
char *newContentType = (char *) PR_smprintf("%s; charset=%s", contentType, aCharset);
if (newContentType)
{
contentInfo->SetContentType(newContentType);
mChannel->SetContentType(newContentType);
PR_FREEIF(newContentType);
}
@ -858,8 +850,7 @@ nsMimeBaseEmitter::Complete()
PRUint32 bytesInStream;
nsresult rv2 = mInputStream->Available(&bytesInStream);
NS_ASSERTION(NS_SUCCEEDED(rv2), "Available failed");
// DOUGT - where did the request come from??!
rv2 = mOutListener->OnDataAvailable(/*mChannel*/nsnull, mURL, mInputStream, 0, bytesInStream);
rv2 = mOutListener->OnDataAvailable(mChannel, mURL, mInputStream, 0, bytesInStream);
NS_ASSERTION(NS_SUCCEEDED(rv2), "OnDataAvailable failed");
}

Просмотреть файл

@ -28,7 +28,6 @@
#include "nsMimeTypes.h"
#include "nsMimeStringResources.h"
#include "nsCRT.h"
#include "nsIStreamContentInfo.h"
#define MIME_SUPERCLASS mimeLeafClass
MimeDefClass(MimeInlineImage, MimeInlineImageClass,
@ -136,10 +135,7 @@ MimeInlineImage_parse_begin (MimeObject *obj)
mime_stream_data *msd = (mime_stream_data *) (obj->options->stream_closure);
if ( (msd) && (msd->channel) )
{
// check to see if the channel allows this
nsCOMPtr<nsIStreamContentInfo> contentInfo = do_QueryInterface(msd->channel);
if (contentInfo)
contentInfo->SetContentType(obj->content_type);
msd->channel->SetContentType(obj->content_type);
}
}

Просмотреть файл

@ -59,7 +59,7 @@
#include "nsICharsetConverterManager.h"
#include "nsICharsetAlias.h"
#include "nsMimeTypes.h"
#include "nsIStreamContentInfo.h"
#include "nsIIOService.h"
#include "nsIURI.h"
#include "nsIMsgWindow.h"
@ -1897,10 +1897,8 @@ ResetChannelCharset(MimeObject *obj)
char *ptr = PL_strstr(ct, "charset=");
if (ptr)
{
// check to see if the channel allows this
nsCOMPtr<nsIStreamContentInfo> contentInfo = do_QueryInterface(msd->channel);
if (contentInfo)
contentInfo->SetContentType(obj->content_type);
// First, setup the channel!
msd->channel->SetContentType(ct);
// Second, if this is a Save As operation, then we need to convert
// to override the output charset!

Просмотреть файл

@ -48,8 +48,7 @@
#include "nsNetUtil.h"
#include "mozITXTToHTMLConv.h"
#include "nsIMsgMailNewsUrl.h"
#include "nsStreamConverter.h"
#include "nsIStreamContentInfo.h"
#define PREF_MAIL_DISPLAY_GLYPH "mail.display_glyph"
#define PREF_MAIL_DISPLAY_STRUCT "mail.display_struct"
@ -597,11 +596,7 @@ NS_IMETHODIMP nsStreamConverter::Init(nsIURI *aURI, nsIStreamListener * aOutList
GetContentType(getter_Copies(contentTypeToUse));
// mscott --> my theory is that we don't need this fake outgoing channel. Let's use the
// original channel and just set our content type ontop of the original channel...
// check to see if the channel allows this
nsCOMPtr<nsIStreamContentInfo> contentInfo = do_QueryInterface(aChannel);
if (contentInfo)
contentInfo->SetContentType(contentTypeToUse);
aChannel->SetContentType(contentTypeToUse);
//rv = NS_NewInputStreamChannel(getter_AddRefs(mOutgoingChannel), aURI, nsnull, contentTypeToUse, -1);
//if (NS_FAILED(rv))
@ -807,7 +802,7 @@ nsStreamConverter::SetIdentity(nsIMsgIdentity * aIdentity)
// networking library...
//
nsresult
nsStreamConverter::OnDataAvailable(nsIRequest *request, nsISupports *ctxt,
nsStreamConverter::OnDataAvailable(nsIChannel * /* aChannel */, nsISupports *ctxt,
nsIInputStream *aIStream,
PRUint32 sourceOffset,
PRUint32 aLength)
@ -877,7 +872,7 @@ char *output = "\
// called only once, at the beginning of a URL load.
//
nsresult
nsStreamConverter::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
nsStreamConverter::OnStartRequest(nsIChannel * aChannel, nsISupports *ctxt)
{
#ifdef DEBUG_rhp
printf("nsStreamConverter::OnStartRequest()\n");
@ -890,22 +885,17 @@ nsStreamConverter::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
// here's a little bit of hackery....
// since the mime converter is now between the channel
// and the
if (request)
nsresult rv = NS_OK;
if (aChannel)
{
nsCOMPtr<nsIStreamContentInfo> contentInfo = do_QueryInterface(request);
if (contentInfo)
{
nsXPIDLCString contentType;
GetContentType(getter_Copies(contentType));
if (contentInfo)
contentInfo->SetContentType(contentType);
}
nsXPIDLCString contentType;
GetContentType(getter_Copies(contentType));
aChannel->SetContentType(contentType);
}
// forward the start rquest to any listeners
if (mOutListener)
mOutListener->OnStartRequest(request, ctxt);
mOutListener->OnStartRequest(aChannel, ctxt);
return NS_OK;
}
@ -914,7 +904,7 @@ nsStreamConverter::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
// called once when the networking library has finished processing the
//
nsresult
nsStreamConverter::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg)
nsStreamConverter::OnStopRequest(nsIChannel * aChannel, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg)
{
#ifdef DEBUG_rhp
printf("nsStreamConverter::OnStopRequest()\n");
@ -993,7 +983,7 @@ nsStreamConverter::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresul
// forward on top request to any listeners
if (mOutListener)
mOutListener->OnStopRequest(request, ctxt, status, errorMsg);
mOutListener->OnStopRequest(/* mOutgoingChannel */ aChannel, ctxt, status, errorMsg);
mAlreadyKnowOutputType = PR_FALSE;
@ -1057,6 +1047,7 @@ NS_IMETHODIMP nsStreamConverter::AsyncConvertData(const PRUnichar *aFromType, co
nsCOMPtr<nsIURI> aUri;
aChannel->GetURI(getter_AddRefs(aUri));
return Init(aUri, aListener, aChannel);
}

Просмотреть файл

@ -694,9 +694,9 @@ public:
nsNntpCacheStreamListener ();
virtual ~nsNntpCacheStreamListener();
nsresult Init(nsIStreamListener * aStreamListener, nsIChannel* channel, nsIMsgMailNewsUrl *aRunningUrl);
nsresult Init(nsIStreamListener * aStreamListener, nsIChannel * aChannelToUse, nsIMsgMailNewsUrl *aRunningUrl);
protected:
nsCOMPtr<nsIChannel> mChannelToUse;
nsCOMPtr<nsIChannel> mChannelToUse;
nsCOMPtr<nsIStreamListener> mListener;
nsCOMPtr<nsIMsgMailNewsUrl> mRunningUrl;
};
@ -718,37 +718,36 @@ nsNntpCacheStreamListener::nsNntpCacheStreamListener()
nsNntpCacheStreamListener::~nsNntpCacheStreamListener()
{}
nsresult nsNntpCacheStreamListener::Init(nsIStreamListener * aStreamListener, nsIChannel* channel,
nsresult nsNntpCacheStreamListener::Init(nsIStreamListener * aStreamListener, nsIChannel * aChannelToUse,
nsIMsgMailNewsUrl *aRunningUrl)
{
NS_ENSURE_ARG(aStreamListener);
NS_ENSURE_ARG(channel);
mChannelToUse = channel;
NS_ENSURE_ARG(aChannelToUse);
mChannelToUse = aChannelToUse;
mListener = aStreamListener;
mRunningUrl = aRunningUrl;
return NS_OK;
}
NS_IMETHODIMP
nsNntpCacheStreamListener::OnStartRequest(nsIRequest *request, nsISupports * aCtxt)
nsNntpCacheStreamListener::OnStartRequest(nsIChannel * aChannel, nsISupports * aCtxt)
{
nsCOMPtr <nsILoadGroup> loadGroup;
mChannelToUse->GetLoadGroup(getter_AddRefs(loadGroup));
if (loadGroup)
loadGroup->AddRequest(request, nsnull /* context isupports */);
return mListener->OnStartRequest(request, aCtxt);
loadGroup->AddChannel(mChannelToUse, nsnull /* context isupports */);
return mListener->OnStartRequest(mChannelToUse, aCtxt);
}
NS_IMETHODIMP
nsNntpCacheStreamListener::OnStopRequest(nsIRequest *request, nsISupports * aCtxt, nsresult aStatus, const PRUnichar* aMsg)
nsNntpCacheStreamListener::OnStopRequest(nsIChannel * aChannel, nsISupports * aCtxt, nsresult aStatus, const PRUnichar* aMsg)
{
nsresult rv = mListener->OnStopRequest(request, aCtxt, aStatus, aMsg);
nsresult rv = mListener->OnStopRequest(mChannelToUse, aCtxt, aStatus, aMsg);
nsCOMPtr <nsILoadGroup> loadGroup;
mChannelToUse->GetLoadGroup(getter_AddRefs(loadGroup));
if (loadGroup)
loadGroup->RemoveRequest(request, nsnull, aStatus, nsnull);
loadGroup->RemoveChannel(mChannelToUse, nsnull, aStatus, nsnull);
// clear out mem cache entry so we're not holding onto it.
if (mRunningUrl)
@ -760,14 +759,13 @@ nsNntpCacheStreamListener::OnStopRequest(nsIRequest *request, nsISupports * aCtx
}
NS_IMETHODIMP
nsNntpCacheStreamListener::OnDataAvailable(nsIRequest *request, nsISupports * aCtxt, nsIInputStream * aInStream, PRUint32 aSourceOffset, PRUint32 aCount)
nsNntpCacheStreamListener::OnDataAvailable(nsIChannel * aChannel, nsISupports * aCtxt, nsIInputStream * aInStream, PRUint32 aSourceOffset, PRUint32 aCount)
{
return mListener->OnDataAvailable(request, aCtxt, aInStream, aSourceOffset, aCount);
return mListener->OnDataAvailable(mChannelToUse, aCtxt, aInStream, aSourceOffset, aCount);
}
NS_IMETHODIMP nsNNTPProtocol::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt,
PRUint32 transferOffset, PRUint32 transferCount, nsIRequest **_retval)
NS_IMETHODIMP nsNNTPProtocol::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt)
{
nsresult rv;
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(m_runningURL, &rv);
@ -796,8 +794,7 @@ NS_IMETHODIMP nsNNTPProtocol::AsyncRead(nsIStreamListener *listener, nsISupports
nsMsgKey key = nsMsgKey_None;
rv = m_runningURL->GetMessageKey(&key);
nsCOMPtr<nsIFileChannel> fileChannel;
PRUint32 offset=0, size=0;
rv = folder->GetOfflineFileChannel(key, &offset, &size, getter_AddRefs(fileChannel));
rv = folder->GetOfflineFileChannel(key, getter_AddRefs(fileChannel));
// get the file channel from the folder, somehow (through the message or
// folder sink?) We also need to set the transfer offset to the message offset
if (fileChannel && NS_SUCCEEDED(rv))
@ -807,8 +804,7 @@ NS_IMETHODIMP nsNNTPProtocol::AsyncRead(nsIStreamListener *listener, nsISupports
nsNntpCacheStreamListener * cacheListener = new nsNntpCacheStreamListener();
NS_ADDREF(cacheListener);
cacheListener->Init(m_channelListener, NS_STATIC_CAST(nsIChannel *, this), mailnewsUrl);
nsCOMPtr<nsIRequest> request;
rv = fileChannel->AsyncRead(cacheListener, m_channelContext, offset, size, getter_AddRefs(request));
rv = fileChannel->AsyncRead(cacheListener, m_channelContext);
NS_RELEASE(cacheListener);
MarkCurrentMsgRead();
@ -844,13 +840,10 @@ NS_IMETHODIMP nsNNTPProtocol::AsyncRead(nsIStreamListener *listener, nsISupports
{
// we're going to fill up this cache entry,
// do we have a listener here?
nsIStreamListener *anotherListener = m_channelListener;
rv = cacheEntry->InterceptAsyncRead(anotherListener, 0, getter_AddRefs(m_channelListener));
nsCOMPtr<nsIRequest> request;
nsIStreamListener *listener = m_channelListener;
rv = cacheEntry->InterceptAsyncRead(listener, 0, getter_AddRefs(m_channelListener));
if (NS_SUCCEEDED(rv))
return nsMsgProtocol::AsyncRead(m_channelListener, ctxt,
transferOffset, transferCount,
getter_AddRefs(request));
return nsMsgProtocol::AsyncRead(m_channelListener, ctxt);
}
}
}
@ -867,10 +860,7 @@ NS_IMETHODIMP nsNNTPProtocol::AsyncRead(nsIStreamListener *listener, nsISupports
SetLoadGroup(m_loadGroup);
m_typeWanted = ARTICLE_WANTED;
cacheListener->Init(m_channelListener, NS_STATIC_CAST(nsIChannel *, this), mailnewsUrl);
nsCOMPtr<nsIRequest> request;
rv = cacheChannel->AsyncRead(cacheListener, m_channelContext,
transferOffset, transferCount,
getter_AddRefs(request));
rv = cacheChannel->AsyncRead(cacheListener, m_channelContext);
NS_RELEASE(cacheListener);
MarkCurrentMsgRead();
@ -885,8 +875,7 @@ NS_IMETHODIMP nsNNTPProtocol::AsyncRead(nsIStreamListener *listener, nsISupports
}
}
nsCOMPtr<nsIRequest> parentRequest;
return nsMsgProtocol::AsyncRead(listener, ctxt, transferOffset, transferCount, getter_AddRefs(parentRequest));
return nsMsgProtocol::AsyncRead(listener, ctxt);
}
nsresult nsNNTPProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer)
@ -1222,9 +1211,9 @@ nsresult nsNNTPProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer)
}
// stop binding is a "notification" informing us that the stream associated with aURL is going away.
NS_IMETHODIMP nsNNTPProtocol::OnStopRequest(nsIRequest *request, nsISupports * aContext, nsresult aStatus, const PRUnichar* aMsg)
NS_IMETHODIMP nsNNTPProtocol::OnStopRequest(nsIChannel * aChannel, nsISupports * aContext, nsresult aStatus, const PRUnichar* aMsg)
{
nsMsgProtocol::OnStopRequest(request, aContext, aStatus, aMsg);
nsMsgProtocol::OnStopRequest(aChannel, aContext, aStatus, aMsg);
// nsMsgProtocol::OnStopRequest() has called m_channelListener. There is
// no need to be called again in CloseSocket(). Let's clear it here.
@ -5413,7 +5402,7 @@ nsresult nsNNTPProtocol::CleanupAfterRunningUrl()
rv = m_channelListener->OnStopRequest(this, m_channelContext, NS_OK, nsnull);
if (m_loadGroup)
m_loadGroup->RemoveRequest(NS_STATIC_CAST(nsIRequest *, this), nsnull, NS_OK, nsnull);
m_loadGroup->RemoveChannel(NS_STATIC_CAST(nsIChannel *, this), nsnull, NS_OK, nsnull);
if (m_newsgroupList)
{
int status;

Просмотреть файл

@ -162,13 +162,13 @@ public:
virtual ~nsNNTPProtocol();
// stop binding is a "notification" informing us that the stream associated with aURL is going away.
NS_IMETHOD OnStopRequest(nsIRequest *request, nsISupports * aCtxt, nsresult aStatus, const PRUnichar* aMsg);
NS_IMETHOD OnStopRequest(nsIChannel * aChannel, nsISupports * aCtxt, nsresult aStatus, const PRUnichar* aMsg);
char * m_ProxyServer; /* proxy server hostname */
NS_IMETHOD Cancel(nsresult status); // handle stop button
NS_IMETHOD GetContentType(char * *aContentType);
NS_IMETHOD AsyncRead(nsIStreamListener *listener, nsISupports *ctxt, PRUint32 transferOffset, PRUint32 transferCount, nsIRequest **_retval);
NS_IMETHOD AsyncRead(nsIStreamListener *listener, nsISupports *ctxt);
nsresult LoadUrl(nsIURI * aURL, nsISupports * aConsumer);
private:

Просмотреть файл

@ -1594,13 +1594,9 @@ NS_IMETHODIMP nsNntpService::GetChromeUrlForTask(char **aChromeUrlForTask)
NS_IMETHODIMP
nsNntpService::HandleContent(const char * aContentType, const char * aCommand, const char * aWindowTarget, nsISupports * aWindowContext, nsIRequest *request)
nsNntpService::HandleContent(const char * aContentType, const char * aCommand, const char * aWindowTarget, nsISupports * aWindowContext, nsIChannel * aChannel)
{
nsresult rv = NS_OK;
if (!request) return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIChannel> aChannel;
request->GetParent(getter_AddRefs(aChannel));
if (!aChannel) return NS_ERROR_NULL_POINTER;
if (nsCRT::strcasecmp(aContentType, "x-application-newsgroup") == 0) {