Added nsIChannel::GetOriginalURI so that we can get back to the original chrome file (bug#17144). r=rpotts,mscott

This commit is contained in:
warren%netscape.com 1999-10-26 09:16:24 +00:00
Родитель 82c16c91b5
Коммит f50d3df7c0
62 изменённых файлов: 314 добавлений и 197 удалений

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

@ -26,7 +26,7 @@ interface nsIURI;
[uuid(829fe440-25e1-11d2-8160-006008119d7a)]
interface nsICodebasePrincipal : nsIPrincipal {
nsIURI GetURI();
readonly attribute nsIURI URI;
boolean SameOrigin(in nsIPrincipal other);
};

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

@ -142,6 +142,7 @@ NS_IMETHODIMP
nsChromeProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
nsILoadGroup *aGroup,
nsIEventSinkGetter* eventSinkGetter,
nsIURI* originalURI,
nsIChannel* *result)
{
nsresult rv;
@ -166,7 +167,7 @@ nsChromeProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
}
rv = serv->NewChannelFromURI(verb, chromeURI, aGroup, eventSinkGetter,
result);
originalURI ? originalURI : uri, result);
// Get a system principal for chrome and set the owner property
// of the result

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

@ -203,6 +203,7 @@ NS_IMETHODIMP
nsJSProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
nsILoadGroup *aGroup,
nsIEventSinkGetter* eventSinkGetter,
nsIURI* originalURI,
nsIChannel* *result)
{
NS_ENSURE_ARG_POINTER(uri);
@ -217,8 +218,8 @@ nsJSProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
(nsISupports**)&ownerPtr);
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIScriptContextOwner> owner = ownerPtr;
NS_RELEASE(ownerPtr);
nsCOMPtr<nsIScriptContextOwner> owner = ownerPtr;
NS_RELEASE(ownerPtr);
if (!owner)
return NS_ERROR_FAILURE;
@ -241,8 +242,8 @@ nsJSProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
nsCOMPtr<nsIPrincipal> principal;
if (hasPrincipal) {
// script is currently executing; get principal from that script
if (NS_FAILED(securityManager->GetSubjectPrincipal(getter_AddRefs(principal))))
return NS_ERROR_FAILURE;
if (NS_FAILED(securityManager->GetSubjectPrincipal(getter_AddRefs(principal))))
return NS_ERROR_FAILURE;
} else {
// No scripts currently executing; get principal from referrer of link
nsCOMPtr<nsIWebShell> webShell;
@ -254,7 +255,7 @@ nsJSProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
return NS_ERROR_FAILURE;
if (NS_FAILED(securityManager->CreateCodebasePrincipal(uri, getter_AddRefs(principal))))
return NS_ERROR_FAILURE;
}
}
//TODO Change this to GetSpec and then skip past the javascript:
@ -329,13 +330,13 @@ nsJSProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
// This is from the old code which need to be hack on a bit more:
#if 0 // plaintext is apparently busted
if (ret[0] != PRUnichar('<'))
ret.Insert("<plaintext>\n", 0);
if (ret[0] != PRUnichar('<'))
ret.Insert("<plaintext>\n", 0);
#endif
mLength = ret.Length();
PRUint32 resultSize = mLength + 1;
mResult = (char *)PR_Malloc(resultSize);
ret.ToCString(mResult, resultSize);
mLength = ret.Length();
PRUint32 resultSize = mLength + 1;
mResult = (char *)PR_Malloc(resultSize);
ret.ToCString(mResult, resultSize);
}
#endif
@ -349,7 +350,7 @@ nsJSProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
nsCOMPtr<nsISupports> s;
rv = NS_NewStringInputStream(getter_AddRefs(s), retString);
int length = PL_strlen(retString);
int length = PL_strlen(retString);
Recycle(retString);
if (NS_FAILED(rv))
@ -361,7 +362,7 @@ nsJSProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
nsIChannel* channel;
rv = serv->NewInputStreamChannel(uri, "text/html", length,
in, aGroup, &channel);
in, aGroup, originalURI, &channel);
if (NS_FAILED(rv))
return rv;

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

@ -242,7 +242,7 @@ NS_NewURItoFile(const char *in, nsFileSpec dirSpec, const char *out)
nsCOMPtr<nsIChannel> pChannel;
// Async reading thru the calls of the event sink interface
rv = serv->NewChannelFromURI("load", pURL, nsnull, nsnull,
rv = serv->NewChannelFromURI("load", pURL, nsnull, nsnull, nsnull,
getter_AddRefs(pChannel));
if (NS_FAILED(rv)) {
printf("ERROR: NewChannelFromURI failed for %s\n", in);

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

@ -212,7 +212,7 @@ ImageNetContextSyncImpl::GetURL(ilIURL* aURL,
// XXX NECKO what verb? what event sink getter
nsIChannel *channel = nsnull;
rv = service->NewChannelFromURI("load", uri, nsnull, nsnull, &channel);
rv = service->NewChannelFromURI("load", uri, nsnull, nsnull, nsnull, &channel);
NS_RELEASE(uri);
if (NS_FAILED(rv))
return -1;

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

@ -469,6 +469,7 @@ nsMessenger::OpenAttachment(const char * url, const char * displayName,
-1, // contentLength
nsnull, // inputStream
nsnull, // loadGroup
nsnull, // originalURI
getter_AddRefs(aListener->m_channel));
nsAutoString from, to;
from = "message/rfc822";
@ -596,6 +597,7 @@ nsMessenger::SaveAs(const char* url, PRBool asFile)
-1, // contentLength
nsnull, // inputStream
nsnull, // loadGroup
nsnull, // originalURI
getter_AddRefs(aListener->m_channel));
nsAutoString from, to;
from = "message/rfc822";

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

@ -30,7 +30,7 @@ static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
NS_IMPL_ISUPPORTS3(nsMsgProtocol, nsIStreamListener, nsIStreamObserver, nsIChannel)
nsMsgProtocol::nsMsgProtocol()
nsMsgProtocol::nsMsgProtocol(nsIURI * aURL, nsIURI* originalURI)
{
NS_INIT_REFCNT();
m_flags = 0;
@ -40,6 +40,8 @@ nsMsgProtocol::nsMsgProtocol()
m_tempMsgFileSpec = nsSpecialSystemDirectory(nsSpecialSystemDirectory::OS_TemporaryDirectory);
m_tempMsgFileSpec += "tempMessage.eml";
m_url = aURL;
m_originalUrl = originalURI ? originalURI : aURL;
}
nsMsgProtocol::~nsMsgProtocol()
@ -93,6 +95,7 @@ nsresult nsMsgProtocol::OpenFileSocket(nsIURI * aURL, const nsFileSpec * aFileSp
nsnull, // null base URI
nsnull, // null load group
nsnull, // null eventsink getter
nsnull, // originalURI
getter_AddRefs(m_channel));
PR_FREEIF(urlSpec);
@ -244,19 +247,18 @@ nsresult nsMsgProtocol::SetLoadGroup(nsILoadGroup * aLoadGroup)
return NS_OK;
}
NS_IMETHODIMP nsMsgProtocol::GetOriginalURI(nsIURI * *aURI)
{
*aURI = m_originalUrl;
NS_IF_ADDREF(*aURI);
return NS_OK;
}
NS_IMETHODIMP nsMsgProtocol::GetURI(nsIURI * *aURI)
{
nsresult rv = NS_OK;
if (aURI)
{
if (m_url)
rv = m_url->QueryInterface(NS_GET_IID(nsIURI), (void **) aURI);
else
*aURI = nsnull;
}
else
rv = NS_ERROR_NULL_POINTER;
return rv;
*aURI = m_url;
NS_IF_ADDREF(*aURI);
return NS_OK;
}
NS_IMETHODIMP nsMsgProtocol::OpenInputStream(PRUint32 startPosition, PRInt32 readCount, nsIInputStream **_retval)

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

@ -36,7 +36,7 @@
class NS_MSG_BASE nsMsgProtocol : public nsIStreamListener, public nsIChannel
{
public:
nsMsgProtocol();
nsMsgProtocol(nsIURI * aURL, nsIURI* originalURI);
virtual ~nsMsgProtocol();
NS_DECL_ISUPPORTS
@ -44,8 +44,8 @@ public:
NS_DECL_NSICHANNEL
NS_DECL_NSIREQUEST
NS_DECL_NSISTREAMLISTENER
NS_DECL_NSISTREAMOBSERVER
NS_DECL_NSISTREAMLISTENER
NS_DECL_NSISTREAMOBSERVER
// LoadUrl -- A protocol typically overrides this function, sets up any local state for the url and
// then calls the base class which opens the socket if it needs opened. If the socket is
@ -99,7 +99,8 @@ protected:
nsFileSpec m_tempMsgFileSpec; // we currently have a hack where displaying a msg involves writing it to a temp file first
// the following is a catch all for nsIChannel related data
nsCOMPtr<nsIURI> m_url; // the running url
nsCOMPtr<nsIURI> m_originalUrl; // the original url
nsCOMPtr<nsIURI> m_url; // the running url
nsCOMPtr<nsIStreamListener> m_channelListener;
nsCOMPtr<nsISupports> m_channelContext;
nsCOMPtr<nsILoadGroup> m_loadGroup;

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

@ -197,6 +197,7 @@ nsresult rv;
-1, // contentLength
nsnull, // inputStream
nsnull, // loadGroup
nsnull, // originalURI
getter_AddRefs(dummyChannel));
if (NS_FAILED(mimeParser->AsyncConvertData(nsnull, nsnull, nsnull, dummyChannel)))
{

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

@ -184,6 +184,7 @@ nsresult rv;
-1, // contentLength
nsnull, // inputStream
nsnull, // loadGroup
nsnull, // originalURI
getter_AddRefs(mQuoteChannel));
NS_ASSERTION(!mQuoteListener, "Oops quote listener exists\n");

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

@ -204,6 +204,7 @@ esmtp_value_encode(char *addr)
///////////////////////////////////////////////////////////////////////////////////////////
nsSmtpProtocol::nsSmtpProtocol(nsIURI * aURL)
: nsMsgProtocol(aURL, aURL)
{
Initialize(aURL);
}

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

@ -226,7 +226,9 @@ NS_IMETHODIMP nsSmtpService::NewURI(const char *aSpec, nsIURI *aBaseURI, nsIURI
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsSmtpService::NewChannel(const char *verb, nsIURI *aURI, nsILoadGroup *aGroup, nsIEventSinkGetter *eventSinkGetter, nsIChannel **_retval)
NS_IMETHODIMP nsSmtpService::NewChannel(const char *verb, nsIURI *aURI, nsILoadGroup *aGroup,
nsIEventSinkGetter *eventSinkGetter, nsIURI* originalURI,
nsIChannel **_retval)
{
// mscott - right now, I don't like the idea of returning channels to the caller. They just want us
// to run the url, they don't want a channel back...I'm going to be addressing this issue with

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

@ -200,7 +200,7 @@ nsURLFetcher::FireURLRequest(nsIURI *aURL, nsOutputFileStream *fOut,
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIChannel> channel;
rv = service->NewChannelFromURI("load", aURL, nsnull, nsnull, getter_AddRefs(channel));
rv = service->NewChannelFromURI("load", aURL, nsnull, nsnull, nsnull, getter_AddRefs(channel));
if (NS_FAILED(rv)) return rv;
rv = channel->AsyncRead(0, -1, nsnull, this);

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

@ -190,7 +190,7 @@ nsURLFetcher::FireURLRequest(nsIURI *aURL, nsOutputFileStream *fOut,
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIChannel> channel;
rv = service->NewChannelFromURI("load", aURL, nsnull, nsnull, getter_AddRefs(channel));
rv = service->NewChannelFromURI("load", aURL, nsnull, nsnull, nsnull, getter_AddRefs(channel));
if (NS_FAILED(rv)) return rv;
rv = channel->AsyncRead(0, -1, nsnull, this);

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

@ -6197,19 +6197,18 @@ NS_IMETHODIMP nsImapMockChannel::GetLoadGroup(nsILoadGroup * *aLoadGroup)
return NS_OK;
}
NS_IMETHODIMP nsImapMockChannel::GetOriginalURI(nsIURI * *aURI)
{
*aURI = m_originalUrl;
NS_IF_ADDREF(*aURI);
return NS_OK;
}
NS_IMETHODIMP nsImapMockChannel::GetURI(nsIURI * *aURI)
{
nsresult rv = NS_OK;
if (aURI)
{
if (m_url)
rv = m_url->QueryInterface(NS_GET_IID(nsIURI), (void **) aURI);
else
*aURI = nsnull;
}
else
rv = NS_ERROR_NULL_POINTER;
return rv;
*aURI = m_url;
NS_IF_ADDREF(*aURI);
return NS_OK;
}
NS_IMETHODIMP nsImapMockChannel::OpenInputStream(PRUint32 startPosition, PRInt32 readCount, nsIInputStream **_retval)

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

@ -552,6 +552,7 @@ protected:
// we CANNOT own the uri else we will have a circular ref count
// because the imap uri ref counts us....so don't think about
// turning this into a com ptr!
nsCOMPtr<nsIURI> m_originalUrl;
nsIURI * m_url;
nsCOMPtr<nsILoadGroup> m_loadGroup;
nsCOMPtr<nsIStreamListener> m_channelListener;

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

@ -435,7 +435,7 @@ nsImapService::FetchMessage(nsIImapUrl * aImapUrl,
if (NS_SUCCEEDED(rv) && aStreamListener)
{
nsCOMPtr<nsIChannel> aChannel;
rv = NewChannel(nsnull, url, nsnull, nsnull, getter_AddRefs(aChannel));
rv = NewChannel(nsnull, url, nsnull, nsnull, nsnull, getter_AddRefs(aChannel));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsISupports> aCtxt = do_QueryInterface(url);
@ -2178,7 +2178,9 @@ NS_IMETHODIMP nsImapService::NewURI(const char *aSpec, nsIURI *aBaseURI, nsIURI
return rv;
}
NS_IMETHODIMP nsImapService::NewChannel(const char *verb, nsIURI *aURI, nsILoadGroup *aGroup, nsIEventSinkGetter *eventSinkGetter, nsIChannel **_retval)
NS_IMETHODIMP nsImapService::NewChannel(const char *verb, nsIURI *aURI, nsILoadGroup *aGroup,
nsIEventSinkGetter *eventSinkGetter, nsIURI* originalURI,
nsIChannel **_retval)
{
// imap can't open and return a channel right away...the url needs to go in the imap url queue
// until we find a connection which can run the url..in order to satisfy necko, we're going to return
@ -2190,6 +2192,8 @@ NS_IMETHODIMP nsImapService::NewChannel(const char *verb, nsIURI *aURI, nsILoadG
if (NS_FAILED(rv)) return rv;
// XXX this mock channel stuff is wrong -- the channel really should be owning the URL
// and the originalURL, not the other way around
rv = imapUrl->GetMockChannel(getter_AddRefs(mockChannel));
if (NS_FAILED(rv) || !mockChannel) return rv;

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

@ -653,7 +653,7 @@ nsresult nsIMAP4TestDriver::OnTestUrlParsing()
printf("Host name test: %s\n", PL_strcmp(urlHost, hostName) == 0 ? "PASSED." : "FAILED!");
if (port > 0) // did the user try to test the port?
printf("Port test: %s\n", port == urlPort ? "PASSED." : "FAILED!");
printf("Port test: %s\n", port == (PRUint32)urlPort ? "PASSED." : "FAILED!");
NS_IF_RELEASE(imapUrl);
}

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

@ -56,10 +56,10 @@ static NS_DEFINE_CID(kCMailDB, NS_MAILDB_CID);
*/
#define OUTPUT_BUFFER_SIZE (4096*2)
nsMailboxProtocol::nsMailboxProtocol(nsIURI * aURL)
nsMailboxProtocol::nsMailboxProtocol(nsIURI * aURI, nsIURI* originalURI)
: nsMsgProtocol(aURI, originalURI)
{
Initialize(aURL);
SetUrl(aURL);
Initialize(aURI);
// initialize the pr log if it hasn't been initialiezed already
if (!MAILBOX)

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

@ -67,7 +67,7 @@ class nsMailboxProtocol : public nsMsgProtocol
public:
// Creating a protocol instance requires the URL which needs to be run AND it requires
// a transport layer.
nsMailboxProtocol(nsIURI * aURL);
nsMailboxProtocol(nsIURI * aURL, nsIURI* originalURI);
virtual ~nsMailboxProtocol();
// the consumer of the url might be something like an nsIWebShell....

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

@ -186,7 +186,7 @@ nsresult nsMailboxService::RunMailboxUrl(nsIURI * aMailboxUrl, nsISupports * aDi
{
// create a protocol instance to run the url..
nsresult rv = NS_OK;
nsMailboxProtocol * protocol = new nsMailboxProtocol(aMailboxUrl);
nsMailboxProtocol * protocol = new nsMailboxProtocol(aMailboxUrl, aMailboxUrl);
if (protocol)
{
@ -298,10 +298,12 @@ NS_IMETHODIMP nsMailboxService::NewURI(const char *aSpec, nsIURI *aBaseURI, nsIU
return rv;
}
NS_IMETHODIMP nsMailboxService::NewChannel(const char *verb, nsIURI *aURI, nsILoadGroup *aGroup, nsIEventSinkGetter *eventSinkGetter, nsIChannel **_retval)
NS_IMETHODIMP nsMailboxService::NewChannel(const char *verb, nsIURI *aURI, nsILoadGroup *aGroup,
nsIEventSinkGetter *eventSinkGetter, nsIURI* originalURI,
nsIChannel **_retval)
{
nsresult rv = NS_OK;
nsMailboxProtocol * protocol = new nsMailboxProtocol(aURI);
nsMailboxProtocol * protocol = new nsMailboxProtocol(aURI, originalURI);
protocol->SetLoadGroup(aGroup);
if (protocol)
{

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

@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
/* -*- 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.0 (the "NPL"); you may not use this file except in
@ -343,25 +343,27 @@ net_pop3_free_state(Pop3UidlHost* host)
Pop3AllocedString* tmp;
Pop3AllocedString* next;
while (host) {
h = host->next;
PR_Free(host->host);
PR_Free(host->user);
PL_HashTableDestroy(host->hash);
tmp = host->strings;
while (tmp) {
next = tmp->next;
PR_Free(tmp->str);
PR_Free(tmp);
tmp = next;
}
PR_Free(host);
host = h;
h = host->next;
PR_Free(host->host);
PR_Free(host->user);
PL_HashTableDestroy(host->hash);
tmp = host->strings;
while (tmp) {
next = tmp->next;
PR_Free(tmp->str);
PR_Free(tmp);
tmp = next;
}
PR_Free(host);
host = h;
}
}
// nsPop3Protocol class implementation
nsPop3Protocol::nsPop3Protocol(nsIURI* aURL) : nsMsgLineBuffer(NULL, PR_FALSE)
nsPop3Protocol::nsPop3Protocol(nsIURI* aURL)
: nsMsgLineBuffer(NULL, PR_FALSE),
nsMsgProtocol(aURL, aURL)
{
SetLookingForCRLF(MSG_LINEBREAK_LEN == 2);
Initialize(aURL);
@ -369,40 +371,40 @@ nsPop3Protocol::nsPop3Protocol(nsIURI* aURL) : nsMsgLineBuffer(NULL, PR_FALSE)
void nsPop3Protocol::Initialize(nsIURI * aURL)
{
nsresult rv = NS_OK;
m_pop3ConData = nsnull;
nsresult rv = NS_OK;
m_pop3ConData = nsnull;
m_pop3CapabilityFlags = POP3_AUTH_LOGIN_UNDEFINED |
POP3_XSENDER_UNDEFINED |
POP3_GURL_UNDEFINED |
POP3_UIDL_UNDEFINED |
POP3_TOP_UNDEFINED |
POP3_XTND_XLST_UNDEFINED;
m_pop3CapabilityFlags = POP3_AUTH_LOGIN_UNDEFINED |
POP3_XSENDER_UNDEFINED |
POP3_GURL_UNDEFINED |
POP3_UIDL_UNDEFINED |
POP3_TOP_UNDEFINED |
POP3_XTND_XLST_UNDEFINED;
m_pop3ConData = (Pop3ConData *)PR_NEWZAP(Pop3ConData);
m_totalBytesReceived = 0;
m_bytesInMsgReceived = 0;
m_totalFolderSize = 0;
m_totalDownloadSize = 0;
m_totalBytesReceived = 0;
m_pop3ConData = (Pop3ConData *)PR_NEWZAP(Pop3ConData);
m_totalBytesReceived = 0;
m_bytesInMsgReceived = 0;
m_totalFolderSize = 0;
m_totalDownloadSize = 0;
m_totalBytesReceived = 0;
PR_ASSERT(m_pop3ConData);
PR_ASSERT(m_pop3ConData);
if (aURL)
{
// extract out message feedback if there is any.
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(aURL);
if (mailnewsUrl)
mailnewsUrl->GetStatusFeedback(getter_AddRefs(m_statusFeedback));
if (aURL)
{
// extract out message feedback if there is any.
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(aURL);
if (mailnewsUrl)
mailnewsUrl->GetStatusFeedback(getter_AddRefs(m_statusFeedback));
m_nsIPop3URL = do_QueryInterface(aURL);
if (m_nsIPop3URL)
{
rv = OpenNetworkSocket(aURL);
}
} // if we got a url...
m_nsIPop3URL = do_QueryInterface(aURL);
if (m_nsIPop3URL)
{
rv = OpenNetworkSocket(aURL);
}
} // if we got a url...
m_lineStreamBuffer = new nsMsgLineStreamBuffer(OUTPUT_BUFFER_SIZE, CRLF, PR_TRUE);
m_lineStreamBuffer = new nsMsgLineStreamBuffer(OUTPUT_BUFFER_SIZE, CRLF, PR_TRUE);
}
nsPop3Protocol::~nsPop3Protocol()

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

@ -260,7 +260,9 @@ NS_IMETHODIMP nsPop3Service::NewURI(const char *aSpec, nsIURI *aBaseURI, nsIURI
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsPop3Service::NewChannel(const char *verb, nsIURI *aURI, nsILoadGroup *aGroup, nsIEventSinkGetter *eventSinkGetter, nsIChannel **_retval)
NS_IMETHODIMP nsPop3Service::NewChannel(const char *verb, nsIURI *aURI, nsILoadGroup *aGroup,
nsIEventSinkGetter *eventSinkGetter, nsIURI* originalURI,
nsIChannel **_retval)
{
// mscott - right now, I don't like the idea of returning channels to the caller. They just want us
// to run the url, they don't want a channel back...I'm going to be addressing this issue with

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

@ -155,7 +155,7 @@ MimeMultipartAppleDouble_parse_begin (MimeObject *obj)
newopt.fancy_headers_p = PR_TRUE;
newopt.headers = (all_headers_p ? MimeHeadersAll : MimeHeadersSome);
FAIL:
// FAIL:
PR_FREEIF(id);
PR_FREEIF(id_url);
PR_FREEIF(id_imap);

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

@ -420,7 +420,7 @@ NS_IMETHODIMP nsStreamConverter::Init(nsIURI *aURI, nsIStreamListener * aOutList
NS_WITH_SERVICE(nsIIOService, netService, kIOServiceCID, &rv);
rv = netService->NewInputStreamChannel(aURI, mOutputFormat,
-1, // XXX fix contentLength
nsnull, nsnull, getter_AddRefs(mOutgoingChannel));
nsnull, nsnull, nsnull, getter_AddRefs(mOutgoingChannel));
if (NS_FAILED(rv))
return rv;

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

@ -437,7 +437,8 @@ nsDummyBufferStream::QueryInterface(REFNSIID aIID, void** result)
return NS_ERROR_NO_INTERFACE;
}
nsNNTPProtocol::nsNNTPProtocol()
nsNNTPProtocol::nsNNTPProtocol(nsIURI * aURL)
: nsMsgProtocol(aURL, nsnull)
{
m_messageID = nsnull;
m_cancelFromHdr = nsnull;
@ -456,19 +457,14 @@ nsNNTPProtocol::~nsNNTPProtocol()
delete m_lineStreamBuffer;
}
nsresult nsNNTPProtocol::Initialize(nsIURI * aURL)
nsresult nsNNTPProtocol::Initialize(void)
{
nsresult rv = NS_OK;
if (!aURL)
return NS_ERROR_NULL_POINTER;
net_NewsChunkSize = DEFAULT_NEWS_CHUNK_SIZE;
SetUrl(aURL);
net_NewsChunkSize = DEFAULT_NEWS_CHUNK_SIZE;
rv = aURL->GetHost(getter_Copies(m_hostName));
rv = m_url->GetHost(getter_Copies(m_hostName));
if (NS_FAILED(rv)) return rv;
rv = aURL->GetPreHost(getter_Copies(m_userName));
rv = m_url->GetPreHost(getter_Copies(m_userName));
if (NS_FAILED(rv)) return rv;
// retrieve the AccountManager
@ -496,7 +492,7 @@ nsresult nsNNTPProtocol::Initialize(nsIURI * aURL)
}
}
NS_PRECONDITION(aURL, "invalid URL passed into NNTP Protocol");
NS_PRECONDITION(m_url, "invalid URL passed into NNTP Protocol");
// Right now, we haven't written an nsNNTPURL yet. When we do, we'll pull the event sink
// data out of it and set our event sink member variables from it. For now, just set them
@ -504,7 +500,7 @@ nsresult nsNNTPProtocol::Initialize(nsIURI * aURL)
// query the URL for a nsINNTPUrl
m_runningURL = do_QueryInterface(aURL);
m_runningURL = do_QueryInterface(m_url);
if (NS_SUCCEEDED(rv) && m_runningURL)
{
// okay, now fill in our event sinks...Note that each getter ref counts before
@ -521,7 +517,7 @@ nsresult nsNNTPProtocol::Initialize(nsIURI * aURL)
// call base class to set up the transport
rv = OpenNetworkSocket(aURL);
rv = OpenNetworkSocket(m_url);
m_dataBuf = (char *) PR_Malloc(sizeof(char) * OUTPUT_BUFFER_SIZE);
m_dataBufSize = OUTPUT_BUFFER_SIZE;

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

@ -145,11 +145,11 @@ class nsNNTPProtocol : public nsMsgProtocol
public:
// Creating a protocol instance requires the URL
// need to call Initialize after we do a new of nsNNTPProtocol
nsNNTPProtocol();
nsNNTPProtocol(nsIURI * aURL);
virtual ~nsNNTPProtocol();
// initialization function given a news url
NS_IMETHOD Initialize(nsIURI * aURL);
NS_IMETHOD Initialize(void);
// aConsumer is typically a display stream you may want the results to be displayed into...
virtual nsresult LoadUrl(nsIURI * aURL, nsISupports * aConsumer = nsnull);

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

@ -652,10 +652,10 @@ nsresult nsNntpService::PostMessage(nsIFileSpec *fileToPost, const char *newsgro
// almost there...now create a nntp protocol instance to run the url in...
nsNNTPProtocol *nntpProtocol = nsnull;
nntpProtocol = new nsNNTPProtocol();
nntpProtocol = new nsNNTPProtocol(mailnewsurl);
if (!nntpProtocol) return NS_ERROR_OUT_OF_MEMORY;;
rv = nntpProtocol->Initialize(mailnewsurl);
rv = nntpProtocol->Initialize();
if (NS_FAILED(rv)) return rv;
nsCOMPtr <nsINNTPNewsgroupPost> post;
@ -727,10 +727,10 @@ nsNntpService::RunNewsUrl(nsIURI * aUri, nsISupports * aConsumer)
// almost there...now create a nntp protocol instance to run the url in...
nsNNTPProtocol *nntpProtocol = nsnull;
nntpProtocol = new nsNNTPProtocol();
nntpProtocol = new nsNNTPProtocol(aUri);
if (!nntpProtocol) return NS_ERROR_OUT_OF_MEMORY;
nsresult rv = nntpProtocol->Initialize(aUri);
nsresult rv = nntpProtocol->Initialize();
if (NS_FAILED(rv)) return rv;
rv = nntpProtocol->LoadUrl(aUri, aConsumer);
@ -941,22 +941,18 @@ NS_IMETHODIMP nsNntpService::NewURI(const char *aSpec, nsIURI *aBaseURI, nsIURI
return rv;
}
NS_IMETHODIMP nsNntpService::NewChannel(const char *verb, nsIURI *aURI, nsILoadGroup *aGroup, nsIEventSinkGetter *eventSinkGetter, nsIChannel **_retval)
NS_IMETHODIMP nsNntpService::NewChannel(const char *verb, nsIURI *aURI, nsILoadGroup *aGroup,
nsIEventSinkGetter *eventSinkGetter, nsIURI* originalURI,
nsIChannel **_retval)
{
nsresult rv = NS_OK;
nsNNTPProtocol *nntpProtocol = new nsNNTPProtocol();
nsNNTPProtocol *nntpProtocol = new nsNNTPProtocol(aURI);
if (!nntpProtocol) return NS_ERROR_OUT_OF_MEMORY;
rv = nntpProtocol->Initialize(aURI);
rv = nntpProtocol->Initialize();
if (NS_FAILED(rv)) return rv;
nntpProtocol->SetLoadGroup(aGroup);
if (nntpProtocol)
{
rv = nntpProtocol->QueryInterface(NS_GET_IID(nsIChannel), (void **) _retval);
}
else
rv = NS_ERROR_NULL_POINTER;
return rv;
return nntpProtocol->QueryInterface(NS_GET_IID(nsIChannel), (void **) _retval);
}
NS_IMETHODIMP

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

@ -32,11 +32,16 @@ typedef unsigned long nsLoadFlags;
* It's abstract in that it doesn't provide a means to specify the
* location/destination of the data being accessed.
*/
[scriptable, uuid(89f4afe0-1868-11d3-9337-00104ba0fd40)]
[scriptable, uuid(2d905684-8b5c-11d3-8cd9-0060b0fc14a3)]
interface nsIChannel : nsIRequest
{
/**
* Returns the URL to which the channel refers.
* Returns the original URL used to construct the channel.
*/
readonly attribute nsIURI originalURI;
/**
* Returns the URL to which the channel currently refers.
*/
readonly attribute nsIURI URI;

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

@ -58,11 +58,19 @@ interface nsIIOService : nsISupports
* Creates a channel for a given URI. The eventSinkGetter is used to
* obtain the appropriate callbacks for the URI's protocol from the
* application.
*
* @param originalURI - Specifies the original URI which caused the creation
* of this channel. This can occur when the construction of one channel
* (e.g. for resource:) causes another channel to be created on its behalf
* (e.g. a file: channel), or if a redirect occurs, causing the current
* URL to become different from the original URL. If NULL, the aURI parameter
* will be used as the originalURI instead.
*/
nsIChannel newChannelFromURI(in string verb,
in nsIURI aURI,
in nsILoadGroup aLoadGroup,
in nsIEventSinkGetter eventSinkGetter);
in nsIEventSinkGetter eventSinkGetter,
in nsIURI originalURI);
/**
* Convenience routine that first creates a URI by calling NewURI, and
@ -72,7 +80,8 @@ interface nsIIOService : nsISupports
in string aSpec,
in nsIURI aBaseURI,
in nsILoadGroup aLoadGroup,
in nsIEventSinkGetter eventSinkGetter);
in nsIEventSinkGetter eventSinkGetter,
in nsIURI originalURI);
/**
* Get the application name string that will be used as part
@ -158,7 +167,8 @@ interface nsIIOService : nsISupports
in string contentType,
in long contentLength,
in nsIInputStream inStr,
in nsILoadGroup group);
in nsILoadGroup group,
in nsIURI originalURI);
};
%{C++

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

@ -40,10 +40,21 @@ interface nsIProtocolHandler : nsISupports
*/
nsIURI newURI(in string aSpec, in nsIURI aBaseURI);
/**
* Constructs a new channel for this protocol handler.
*
* @param originalURI - Specifies the original URI which caused the creation
* of this channel. This can occur when the construction of one channel
* (e.g. for resource:) causes another channel to be created on its behalf
* (e.g. a file: channel), or if a redirect occurs, causing the current
* URL to become different from the original URL. If NULL, the aURI parameter
* will be used as the originalURI instead.
*/
nsIChannel newChannel(in string verb,
in nsIURI aURI,
in nsILoadGroup aLoadGroup,
in nsIEventSinkGetter eventSinkGetter);
in nsIEventSinkGetter eventSinkGetter,
in nsIURI originalURI);
};
%{C++

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

@ -1046,6 +1046,12 @@ nsFileTransport::OnEmpty(nsIPipe* pipe)
// other nsIChannel methods:
////////////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP
nsFileTransport::GetOriginalURI(nsIURI * *aURI)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsFileTransport::GetURI(nsIURI * *aURI)
{

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

@ -213,6 +213,7 @@ NS_IMETHODIMP
nsIOService::NewChannelFromURI(const char* verb, nsIURI *aURI,
nsILoadGroup *aGroup,
nsIEventSinkGetter *eventSinkGetter,
nsIURI* originalURI,
nsIChannel **result)
{
nsresult rv;
@ -226,7 +227,8 @@ nsIOService::NewChannelFromURI(const char* verb, nsIURI *aURI,
if (NS_FAILED(rv)) return rv;
nsIChannel* channel;
rv = handler->NewChannel(verb, aURI, aGroup, eventSinkGetter, &channel);
rv = handler->NewChannel(verb, aURI, aGroup, eventSinkGetter,
originalURI, &channel);
if (NS_FAILED(rv)) return rv;
*result = channel;
@ -238,6 +240,7 @@ nsIOService::NewChannel(const char* verb, const char *aSpec,
nsIURI *aBaseURI,
nsILoadGroup *aGroup,
nsIEventSinkGetter *eventSinkGetter,
nsIURI* originalURI,
nsIChannel **result)
{
nsresult rv;
@ -245,7 +248,8 @@ nsIOService::NewChannel(const char* verb, const char *aSpec,
nsCOMPtr<nsIProtocolHandler> handler;
rv = NewURI(aSpec, aBaseURI, getter_AddRefs(uri), getter_AddRefs(handler));
if (NS_FAILED(rv)) return rv;
rv = handler->NewChannel(verb, uri, aGroup, eventSinkGetter, result);
rv = handler->NewChannel(verb, uri, aGroup, eventSinkGetter,
originalURI, result);
return rv;
}
@ -417,14 +421,14 @@ NS_IMETHODIMP
nsIOService::NewInputStreamChannel(nsIURI* uri, const char *contentType,
PRInt32 contentLength,
nsIInputStream *inStr, nsILoadGroup* group,
nsIChannel **result)
nsIURI* originalURI, nsIChannel **result)
{
nsresult rv;
nsInputStreamChannel* channel;
rv = nsInputStreamChannel::Create(nsnull, NS_GET_IID(nsIChannel),
(void**)&channel);
if (NS_FAILED(rv)) return rv;
rv = channel->Init(uri, contentType, contentLength, inStr, group);
rv = channel->Init(uri, contentType, contentLength, inStr, group, originalURI);
if (NS_FAILED(rv)) {
NS_RELEASE(channel);
return rv;

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

@ -57,9 +57,10 @@ nsInputStreamChannel::Create(nsISupports *aOuter, REFNSIID aIID,
nsresult
nsInputStreamChannel::Init(nsIURI* uri, const char* contentType,
PRInt32 contentLength,
nsIInputStream* in, nsILoadGroup* group)
PRInt32 contentLength, nsIInputStream* in,
nsILoadGroup* group, nsIURI* originalURI)
{
mOriginalURI = originalURI ? originalURI : uri;
mURI = uri;
mLoadGroup = group;
mContentLength = contentLength;
@ -117,6 +118,14 @@ nsInputStreamChannel::Resume(void)
////////////////////////////////////////////////////////////////////////////////
// nsIChannel methods:
NS_IMETHODIMP
nsInputStreamChannel::GetOriginalURI(nsIURI * *aURI)
{
*aURI = mOriginalURI;
NS_IF_ADDREF(*aURI);
return NS_OK;
}
NS_IMETHODIMP
nsInputStreamChannel::GetURI(nsIURI * *aURI)
{

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

@ -44,10 +44,11 @@ public:
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
nsresult Init(nsIURI* uri, const char* contentType,
PRInt32 contentLength,
nsIInputStream* in, nsILoadGroup* group);
PRInt32 contentLength, nsIInputStream* in,
nsILoadGroup* group, nsIURI* originalURI);
protected:
nsCOMPtr<nsIURI> mOriginalURI;
nsCOMPtr<nsIURI> mURI;
char* mContentType;
PRInt32 mContentLength;

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

@ -1421,7 +1421,7 @@ nsSocketTransport::OnStopLookup(nsISupports *aContext,
// --------------------------------------------------------------------------
//
NS_IMETHODIMP
nsSocketTransport::GetURI(nsIURI * *aURL)
nsSocketTransport::GetOriginalURI(nsIURI * *aURL)
{
nsStdURL *url;
url = new nsStdURL(nsnull);
@ -1434,6 +1434,12 @@ nsSocketTransport::GetURI(nsIURI * *aURL)
return rv;
}
NS_IMETHODIMP
nsSocketTransport::GetURI(nsIURI * *aURL)
{
return GetOriginalURI(aURL);
}
NS_IMETHODIMP
nsSocketTransport::AsyncOpen(nsIStreamObserver *observer, nsISupports* ctxt)
{

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

@ -29,8 +29,9 @@ interface nsIAboutModule : nsISupports
{
nsIChannel NewChannel(in string verb,
in nsIURI aURI,
in nsILoadGroup aGroup,
in nsIEventSinkGetter eventSinkGetter);
in nsILoadGroup aGroup,
in nsIEventSinkGetter eventSinkGetter,
in nsIURI originalURI);
};
%{C++

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

@ -32,6 +32,7 @@ nsAboutBlank::NewChannel(const char *verb,
nsIURI *aURI,
nsILoadGroup *aGroup,
nsIEventSinkGetter *eventSinkGetter,
nsIURI* originalURI,
nsIChannel **result)
{
nsresult rv;
@ -50,7 +51,7 @@ nsAboutBlank::NewChannel(const char *verb,
rv = serv->NewInputStreamChannel(aURI, "text/html",
nsCRT::strlen(kBlankPage),
in, aGroup, &channel);
in, aGroup, originalURI, &channel);
NS_RELEASE(in);
if (NS_FAILED(rv)) return rv;

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

@ -42,6 +42,7 @@ nsAboutBloat::NewChannel(const char *verb,
nsIURI *aURI,
nsILoadGroup *aGroup,
nsIEventSinkGetter *eventSinkGetter,
nsIURI* originalURI,
nsIChannel **result)
{
nsresult rv;
@ -136,7 +137,7 @@ nsAboutBloat::NewChannel(const char *verb,
nsIChannel* channel;
rv = serv->NewInputStreamChannel(aURI, "text/plain",
size, inStr, aGroup, &channel);
size, inStr, aGroup, originalURI, &channel);
if (NS_FAILED(rv)) return rv;
*result = channel;

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

@ -132,6 +132,7 @@ NS_IMETHODIMP
nsAboutProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
nsILoadGroup *aGroup,
nsIEventSinkGetter* eventSinkGetter,
nsIURI* originalURI,
nsIChannel* *result)
{
// about:what you ask?
@ -157,7 +158,7 @@ nsAboutProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
if (NS_SUCCEEDED(rv)) {
// The standard return case:
return aboutMod->NewChannel(verb, uri, aGroup, eventSinkGetter,
result);
originalURI, result);
}
// mumble...

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

@ -64,13 +64,15 @@ nsDataChannel::QueryInterface(const nsIID& aIID, void** aInstancePtr) {
nsresult
nsDataChannel::Init(const char* verb, nsIURI* uri, nsILoadGroup *aGroup,
nsIEventSinkGetter* getter) {
nsIEventSinkGetter* getter, nsIURI* originalURI)
{
// we don't care about event sinks in data
nsresult rv;
mDataStream = nsnull;
// Data urls contain all the data within the url string itself.
mOriginalURI = originalURI ? originalURI : uri;
mUrl = uri;
NS_ADDREF(mUrl);
@ -249,6 +251,14 @@ nsDataChannel::Resume(void)
////////////////////////////////////////////////////////////////////////////////
// nsIChannel methods:
NS_IMETHODIMP
nsDataChannel::GetOriginalURI(nsIURI * *aURI)
{
*aURI = mOriginalURI;
NS_ADDREF(*aURI);
return NS_OK;
}
NS_IMETHODIMP
nsDataChannel::GetURI(nsIURI * *aURI)
{

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

@ -50,10 +50,11 @@ public:
Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult);
nsresult Init(const char* verb, nsIURI* uri, nsILoadGroup *aGroup,
nsIEventSinkGetter* getter);
nsIEventSinkGetter* getter, nsIURI* originalURI);
nsresult ParseData();
protected:
nsCOMPtr<nsIURI> mOriginalURI;
nsIURI *mUrl;
nsIInputStream *mDataStream;
PRUint32 mLoadAttributes;

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

@ -105,14 +105,16 @@ NS_IMETHODIMP
nsDataHandler::NewChannel(const char* verb, nsIURI* url,
nsILoadGroup *aGroup,
nsIEventSinkGetter* eventSinkGetter,
nsIChannel* *result) {
nsIURI* originalURI,
nsIChannel* *result)
{
nsresult rv;
nsDataChannel* channel;
rv = nsDataChannel::Create(nsnull, NS_GET_IID(nsIDataChannel), (void**)&channel);
if (NS_FAILED(rv)) return rv;
rv = channel->Init(verb, url, aGroup, eventSinkGetter);
rv = channel->Init(verb, url, aGroup, eventSinkGetter, originalURI);
if (NS_FAILED(rv)) {
NS_RELEASE(channel);
return rv;

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

@ -60,12 +60,13 @@ nsFileChannel::nsFileChannel()
nsresult
nsFileChannel::Init(nsIFileProtocolHandler* handler, const char* command, nsIURI* uri,
nsILoadGroup *aGroup, nsIEventSinkGetter* getter)
nsILoadGroup *aGroup, nsIEventSinkGetter* getter, nsIURI* originalURI)
{
nsresult rv;
mGetter = getter;
mHandler = handler;
mOriginalURI = originalURI ? originalURI : uri;
mURI = uri;
mCommand = nsCRT::strdup(command);
if (mCommand == nsnull)
@ -200,6 +201,14 @@ nsFileChannel::Resume()
// From nsIChannel
////////////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP
nsFileChannel::GetOriginalURI(nsIURI * *aURI)
{
*aURI = mOriginalURI;
NS_ADDREF(*aURI);
return NS_OK;
}
NS_IMETHODIMP
nsFileChannel::GetURI(nsIURI * *aURI)
{
@ -727,6 +736,7 @@ nsFileChannel::CreateFileChannelFromFileSpec(nsFileSpec& spec, nsIFileChannel **
nsnull,
mLoadGroup,
mGetter,
nsnull,
&channel);
if (NS_FAILED(rv)) return rv;

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

@ -60,12 +60,13 @@ public:
Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult);
nsresult Init(nsIFileProtocolHandler* handler, const char* verb, nsIURI* uri,
nsILoadGroup *aGroup, nsIEventSinkGetter* getter);
nsILoadGroup *aGroup, nsIEventSinkGetter* getter, nsIURI* originalURI);
protected:
nsresult CreateFileChannelFromFileSpec(nsFileSpec& spec, nsIFileChannel** result);
protected:
nsCOMPtr<nsIURI> mOriginalURI;
nsCOMPtr<nsIURI> mURI;
nsCOMPtr<nsIFileProtocolHandler> mHandler;
nsCOMPtr<nsIEventSinkGetter> mGetter; // XXX it seems wrong keeping this -- used by GetParent

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

@ -143,6 +143,7 @@ NS_IMETHODIMP
nsFileProtocolHandler::NewChannel(const char* verb, nsIURI* url,
nsILoadGroup *aGroup,
nsIEventSinkGetter* eventSinkGetter,
nsIURI* originalURI,
nsIChannel* *result)
{
nsresult rv;
@ -151,7 +152,7 @@ nsFileProtocolHandler::NewChannel(const char* verb, nsIURI* url,
rv = nsFileChannel::Create(nsnull, NS_GET_IID(nsIFileChannel), (void**)&channel);
if (NS_FAILED(rv)) return rv;
rv = channel->Init(this, verb, url, aGroup, eventSinkGetter);
rv = channel->Init(this, verb, url, aGroup, eventSinkGetter, originalURI);
if (NS_FAILED(rv)) {
NS_RELEASE(channel);
return rv;
@ -178,6 +179,7 @@ nsFileProtocolHandler::NewChannelFromNativePath(const char* nativePath,
uri,
nsnull, // XXX bogus load group
nsnull, // XXX bogus getter
nsnull, // originalURI same as uri
(nsIChannel**)result);
NS_RELEASE(uri);
return rv;

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

@ -89,7 +89,8 @@ NS_IMPL_ISUPPORTS4(nsFTPChannel, nsIChannel, nsIFTPChannel, nsIStreamListener, n
nsresult
nsFTPChannel::Init(const char* verb, nsIURI* uri, nsILoadGroup *aGroup,
nsIEventSinkGetter* getter, nsIProtocolHandler* aHandler)
nsIEventSinkGetter* getter, nsIURI* originalURI,
nsIProtocolHandler* aHandler)
{
nsresult rv;
@ -99,6 +100,7 @@ nsFTPChannel::Init(const char* verb, nsIURI* uri, nsILoadGroup *aGroup,
if (mConnected)
return NS_ERROR_FAILURE;
mOriginalURI = originalURI ? originalURI : uri;
mUrl = uri;
NS_ADDREF(mUrl);
@ -210,6 +212,14 @@ nsFTPChannel::Resume(void)
////////////////////////////////////////////////////////////////////////////////
// nsIChannel methods:
NS_IMETHODIMP
nsFTPChannel::GetOriginalURI(nsIURI * *aURL)
{
*aURL = mOriginalURI;
NS_ADDREF(*aURL);
return NS_OK;
}
NS_IMETHODIMP
nsFTPChannel::GetURI(nsIURI * *aURL)
{

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

@ -59,10 +59,11 @@ public:
// and returns it so the protocol handler can cache it and
// join() it on shutdown.
nsresult Init(const char* verb, nsIURI* uri, nsILoadGroup *aGroup,
nsIEventSinkGetter* getter,
nsIEventSinkGetter* getter, nsIURI* originalURI,
nsIProtocolHandler* aHandler);
protected:
nsCOMPtr<nsIURI> mOriginalURI;
nsIURI* mUrl;
nsIEventQueue* mEventQueue;
nsIProgressEventSink* mEventSink;

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

@ -172,6 +172,7 @@ NS_IMETHODIMP
nsFtpProtocolHandler::NewChannel(const char* verb, nsIURI* url,
nsILoadGroup *aGroup,
nsIEventSinkGetter* eventSinkGetter,
nsIURI* originalURI,
nsIChannel* *result)
{
nsresult rv;
@ -180,7 +181,7 @@ nsFtpProtocolHandler::NewChannel(const char* verb, nsIURI* url,
rv = nsFTPChannel::Create(nsnull, NS_GET_IID(nsIFTPChannel), (void**)&channel);
if (NS_FAILED(rv)) return rv;
rv = channel->Init(verb, url, aGroup, eventSinkGetter, this);
rv = channel->Init(verb, url, aGroup, eventSinkGetter, originalURI, this);
if (NS_FAILED(rv)) {
NS_RELEASE(channel);
PR_LOG(gFTPLog, PR_LOG_DEBUG, ("nsFtpProtocolHandler::NewChannel() FAILED\n"));

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

@ -59,7 +59,9 @@ static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
nsHTTPChannel::nsHTTPChannel(nsIURI* i_URL,
const char *i_Verb,
nsIEventSinkGetter* i_EventSinkGetter,
nsIURI* originalURI,
nsHTTPHandler* i_Handler):
mOriginalURI(dont_QueryInterface(originalURI ? originalURI : i_URL)),
mURI(dont_QueryInterface(i_URL)),
mConnected(PR_FALSE),
mHandler(dont_QueryInterface(i_Handler)),
@ -198,16 +200,20 @@ nsHTTPChannel::Resume(void)
////////////////////////////////////////////////////////////////////////////////
// nsIChannel methods:
NS_IMETHODIMP
nsHTTPChannel::GetOriginalURI(nsIURI* *o_URL)
{
*o_URL = mOriginalURI;
NS_IF_ADDREF(*o_URL);
return NS_OK;
}
NS_IMETHODIMP
nsHTTPChannel::GetURI(nsIURI* *o_URL)
{
if (o_URL) {
*o_URL = mURI;
NS_IF_ADDREF(*o_URL);
return NS_OK;
} else {
return NS_ERROR_NULL_POINTER;
}
*o_URL = mURI;
NS_IF_ADDREF(*o_URL);
return NS_OK;
}
NS_IMETHODIMP
@ -768,7 +774,7 @@ nsresult nsHTTPChannel::Redirect(const char *aNewLocation,
#endif /* PR_LOGGING */
rv = serv->NewChannelFromURI(mVerb.GetBuffer(), newURI, mLoadGroup, mEventSinkGetter,
getter_AddRefs(channel));
mOriginalURI, getter_AddRefs(channel));
if (NS_FAILED(rv)) return rv;
// Copy the load attributes into the new channel...
@ -928,7 +934,7 @@ nsHTTPChannel::Authenticate(const char *iChallenge, nsIChannel **oChannel)
// This smells like a clone function... maybe there is a benefit in doing that, think. TODO.
rv = serv->NewChannelFromURI(mVerb.GetBuffer(), mURI,
mLoadGroup, mEventSinkGetter,
mLoadGroup, mEventSinkGetter, mOriginalURI,
getter_AddRefs(channel));
if (NS_FAILED(rv)) return rv;

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

@ -52,6 +52,7 @@ public:
nsHTTPChannel(nsIURI* i_URL,
const char* verb,
nsIEventSinkGetter* i_EventSinkGetter,
nsIURI* originalURI,
nsHTTPHandler* i_Handler);
virtual ~nsHTTPChannel();
@ -80,6 +81,7 @@ public:
nsresult SetUsingProxy(PRBool i_UsingProxy);
protected:
nsCOMPtr<nsIURI> mOriginalURI;
nsCOMPtr<nsIURI> mURI;
PRBool mConnected;
nsCOMPtr<nsHTTPHandler> mHandler;

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

@ -157,6 +157,7 @@ NS_METHOD
nsHTTPHandler::NewChannel(const char* verb, nsIURI* i_URL,
nsILoadGroup *aGroup,
nsIEventSinkGetter *eventSinkGetter,
nsIURI* originalURI,
nsIChannel **o_Instance)
{
nsresult rv;
@ -207,6 +208,7 @@ nsHTTPHandler::NewChannel(const char* verb, nsIURI* i_URL,
pChannel = new nsHTTPChannel(i_URL,
verb,
eventSinkGetter,
originalURI,
this);
if (pChannel) {
NS_ADDREF(pChannel);

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

@ -84,6 +84,7 @@ public:
NS_IMETHOD NewChannel(const char* verb, nsIURI* url,
nsILoadGroup *aGroup,
nsIEventSinkGetter *eventSinkGetter,
nsIURI* originalURI,
nsIChannel **_retval);
NS_IMETHOD NewURI(const char *aSpec, nsIURI *aBaseURI,

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

@ -298,6 +298,7 @@ NS_IMETHODIMP
nsResourceProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
nsILoadGroup *aGroup,
nsIEventSinkGetter* eventSinkGetter,
nsIURI* originalURI,
nsIChannel* *result)
{
nsresult rv;
@ -321,7 +322,7 @@ nsResourceProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
nsIChannel* channel;
rv = serv->NewChannel(verb, filePath, uri, aGroup, eventSinkGetter,
&channel);
originalURI, &channel);
nsCRT::free(filePath);
if (NS_FAILED(rv)) return rv;

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

@ -61,16 +61,16 @@ NS_IMPL_ISUPPORTS2(nsFTPDirListingConv, nsIStreamConverter, nsIStreamListener);
// No syncronous conversion at this time.
NS_IMETHODIMP
nsFTPDirListingConv::Convert(nsIInputStream *aFromStream,
const PRUnichar *aFromType,
const PRUnichar *aToType,
nsISupports *aCtxt, nsIInputStream **_retval) {
const PRUnichar *aFromType,
const PRUnichar *aToType,
nsISupports *aCtxt, nsIInputStream **_retval) {
return NS_ERROR_NOT_IMPLEMENTED;
}
// Stream converter service calls this to initialize the actual stream converter (us).
NS_IMETHODIMP
nsFTPDirListingConv::AsyncConvertData(const PRUnichar *aFromType, const PRUnichar *aToType,
nsIStreamListener *aListener, nsISupports *aCtxt) {
nsIStreamListener *aListener, nsISupports *aCtxt) {
NS_ASSERTION(aListener && aFromType && aToType, "null pointer passed into FTP dir listing converter");
nsresult rv;
@ -124,7 +124,7 @@ nsFTPDirListingConv::AsyncConvertData(const PRUnichar *aFromType, const PRUnicha
if (NS_FAILED(rv)) return rv;
rv = serv->NewInputStreamChannel(uri, "application/http-index-format", -1, // XXX fix contentLength
nsnull, nsnull, &mPartChannel);
nsnull, nsnull, nsnull, &mPartChannel);
NS_RELEASE(uri);
if (NS_FAILED(rv)) return rv;

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

@ -201,7 +201,7 @@ nsMultiMixedConv::OnDataAvailable(nsIChannel *channel, nsISupports *ctxt,
if (contentTypeStr.Length() < 1)
contentTypeStr = "text/html"; // default to text/html, that's all we'll ever see anyway
rv = serv->NewInputStreamChannel(partURI, contentTypeStr.GetBuffer(), contentLength,
nsnull, nsnull, &mPartChannel);
nsnull, nsnull, nsnull, &mPartChannel);
NS_RELEASE(partURI);
if (NS_FAILED(rv)) return rv;

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

@ -276,7 +276,7 @@ main(int argc, char* argv[])
if (NS_FAILED(rv)) return rv;
rv = serv->NewInputStreamChannel(dummyURI, "multipart/x-mixed-replace;boundary= --aBoundary",
-1, // XXX fix contentLength
nsnull, nsnull, &dummyChannel);
nsnull, nsnull, nsnull, &dummyChannel);
NS_RELEASE(dummyURI);
if (NS_FAILED(rv)) return rv;

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

@ -519,7 +519,7 @@ nsresult StartLoadingURL(const char* aUrlString)
// Async reading thru the calls of the event sink interface
rv = pService->NewChannelFromURI("load", pURL, nsnull, pMySink,
getter_AddRefs(pChannel));
nsnull, getter_AddRefs(pChannel));
if (NS_FAILED(rv)) {
printf("ERROR: NewChannelFromURI failed for %s\n", aUrlString);
return rv;

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

@ -60,7 +60,8 @@ NS_OpenURI(nsIChannel* *result, nsIURI* uri, nsILoadGroup *aGroup,
if (NS_FAILED(rv)) return rv;
nsIChannel* channel;
rv = serv->NewChannelFromURI("load", uri, aGroup, eventSinkGetter, &channel);
rv = serv->NewChannelFromURI("load", uri, aGroup, eventSinkGetter,
nsnull, &channel);
if (NS_FAILED(rv)) return rv;
*result = channel;

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

@ -384,7 +384,7 @@ int nsAccount::GetNCIValues(nsString MiddleValue)
nsIChannel *channel = nsnull;
// XXX NECKO verb? loadgroup? getter?
ret = service->NewChannel("load", Trial.ToNewCString(), nsnull, nsnull, nsnull, &channel);
ret = service->NewChannel("load", Trial.ToNewCString(), nsnull, nsnull, nsnull, nsnull, &channel);
if (NS_FAILED(ret)) return ret;
@ -498,7 +498,7 @@ int nsAccount::GetConfigValues(nsString fileName)
nsIChannel *channel = nsnull;
// XXX NECKO verb? loadgroup? getter?
ret = service->NewChannel("load", Trial.ToNewCString(), nsnull, nsnull, nsnull, &channel);
ret = service->NewChannel("load", Trial.ToNewCString(), nsnull, nsnull, nsnull, nsnull, &channel);
if (NS_FAILED(ret)) return ret;

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

@ -142,6 +142,7 @@ NS_IMETHODIMP
nsChromeProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
nsILoadGroup *aGroup,
nsIEventSinkGetter* eventSinkGetter,
nsIURI* originalURI,
nsIChannel* *result)
{
nsresult rv;
@ -166,7 +167,7 @@ nsChromeProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
}
rv = serv->NewChannelFromURI(verb, chromeURI, aGroup, eventSinkGetter,
result);
originalURI ? originalURI : uri, result);
// Get a system principal for chrome and set the owner property
// of the result

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

@ -30,22 +30,17 @@ static const char kURI[] = "chrome://global/content/about.html";
NS_IMETHODIMP
nsAbout::NewChannel(const char *verb,
nsIURI *aURI,
nsILoadGroup *aGroup,
nsIEventSinkGetter *eventSinkGetter,
nsIChannel **result)
nsIURI *aURI,
nsILoadGroup *aGroup,
nsIEventSinkGetter *eventSinkGetter,
nsIURI* originalURI,
nsIChannel **result)
{
nsresult rv;
nsCOMPtr<nsIURI> URI;
NS_WITH_SERVICE(nsIIOService, ioService, kIOServiceCID, &rv);
if ( NS_FAILED(rv) )
return rv;
rv = ioService->NewURI(kURI, NULL, getter_AddRefs(URI));
rv = ioService->NewChannelFromURI( verb, URI ,aGroup, eventSinkGetter, result);
return rv;
rv = ioService->NewChannel( verb, kURI, NULL ,aGroup, eventSinkGetter, originalURI, result);
return rv;
}