зеркало из https://github.com/mozilla/pjs.git
Unification of LoadUrl signature to remove some warnings on Linux & Mac. (this is just the first step).
ParseURL returns a nsresult instead of a PRInt32.
This commit is contained in:
Родитель
0051b03950
Коммит
ff35c93a2a
|
@ -452,7 +452,7 @@ nsresult nsNNTPProtocol::Initialize(nsIURL * aURL)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsNNTPProtocol::LoadUrl(nsIURL * aURL, nsISupports * aConsumer, PRInt32 *status)
|
nsresult nsNNTPProtocol::LoadUrl(nsIURL * aURL, nsISupports * aConsumer)
|
||||||
{
|
{
|
||||||
PRBool bVal = FALSE;
|
PRBool bVal = FALSE;
|
||||||
char * hostAndPort = 0;
|
char * hostAndPort = 0;
|
||||||
|
@ -463,8 +463,6 @@ nsresult nsNNTPProtocol::LoadUrl(nsIURL * aURL, nsISupports * aConsumer, PRInt32
|
||||||
nsCOMPtr <nsINNTPNewsgroupPost> message;
|
nsCOMPtr <nsINNTPNewsgroupPost> message;
|
||||||
//char *message_id = 0;
|
//char *message_id = 0;
|
||||||
|
|
||||||
*status = 0;
|
|
||||||
|
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
|
|
||||||
m_articleNumber = -1;
|
m_articleNumber = -1;
|
||||||
|
@ -472,7 +470,7 @@ nsresult nsNNTPProtocol::LoadUrl(nsIURL * aURL, nsISupports * aConsumer, PRInt32
|
||||||
// Query the url for its nsINntpUrl interface...assert and fail to load if they passed us a non news url...
|
// Query the url for its nsINntpUrl interface...assert and fail to load if they passed us a non news url...
|
||||||
|
|
||||||
if (aConsumer) // did the caller pass in a display stream?
|
if (aConsumer) // did the caller pass in a display stream?
|
||||||
aConsumer->QueryInterface(kIWebShell, getter_AddRefs(m_displayConsumer));
|
rv = aConsumer->QueryInterface(kIWebShell, getter_AddRefs(m_displayConsumer));
|
||||||
|
|
||||||
if (aURL)
|
if (aURL)
|
||||||
{
|
{
|
||||||
|
@ -491,13 +489,10 @@ nsresult nsNNTPProtocol::LoadUrl(nsIURL * aURL, nsISupports * aConsumer, PRInt32
|
||||||
|
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
{
|
{
|
||||||
*status = -1;
|
|
||||||
goto FAIL;
|
goto FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
*status = ParseURL(aURL, &hostAndPort, &bVal, &group, &messageID, &commandSpecificData);
|
rv = ParseURL(aURL, &hostAndPort, &bVal, &group, &messageID, &commandSpecificData);
|
||||||
if (*status < 0)
|
|
||||||
goto FAIL;
|
|
||||||
|
|
||||||
// if we don't have a news host already, go get one...
|
// if we don't have a news host already, go get one...
|
||||||
if (!m_newsHost)
|
if (!m_newsHost)
|
||||||
|
@ -515,10 +510,9 @@ nsresult nsNNTPProtocol::LoadUrl(nsIURL * aURL, nsISupports * aConsumer, PRInt32
|
||||||
nsINNTPHost::GetIID(),
|
nsINNTPHost::GetIID(),
|
||||||
getter_AddRefs(m_newsHost));
|
getter_AddRefs(m_newsHost));
|
||||||
|
|
||||||
if (NS_FAILED(rv) || (!m_newsHost)) {
|
if (NS_FAILED(rv) || (!m_newsHost))
|
||||||
*status = -1;
|
|
||||||
goto FAIL;
|
goto FAIL;
|
||||||
}
|
|
||||||
// at this point, hostAndPort is really just the hostname
|
// at this point, hostAndPort is really just the hostname
|
||||||
// because we put a '\0' in for the colon, if there was one
|
// because we put a '\0' in for the colon, if there was one
|
||||||
m_newsHost->Initialize(hostAndPort /* really just hostname */, port ? port : NEWS_PORT);
|
m_newsHost->Initialize(hostAndPort /* really just hostname */, port ? port : NEWS_PORT);
|
||||||
|
@ -531,18 +525,12 @@ nsresult nsNNTPProtocol::LoadUrl(nsIURL * aURL, nsISupports * aConsumer, PRInt32
|
||||||
rv = m_newsHost->LoadNewsrc(newshosturi);
|
rv = m_newsHost->LoadNewsrc(newshosturi);
|
||||||
PR_FREEIF(newshosturi);
|
PR_FREEIF(newshosturi);
|
||||||
|
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv))
|
||||||
*status = -1;
|
|
||||||
goto FAIL;
|
goto FAIL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
PR_ASSERT(NS_SUCCEEDED(rv));
|
if (NS_FAILED(rv))
|
||||||
if (!NS_SUCCEEDED(rv))
|
|
||||||
{
|
|
||||||
*status = -1;
|
|
||||||
goto FAIL;
|
goto FAIL;
|
||||||
}
|
|
||||||
|
|
||||||
if (messageID && commandSpecificData && !PL_strcmp (commandSpecificData, "?cancel"))
|
if (messageID && commandSpecificData && !PL_strcmp (commandSpecificData, "?cancel"))
|
||||||
cancel = TRUE;
|
cancel = TRUE;
|
||||||
|
@ -751,30 +739,31 @@ nsresult nsNNTPProtocol::LoadUrl(nsIURL * aURL, nsISupports * aConsumer, PRInt32
|
||||||
PR_FREEIF (messageID);
|
PR_FREEIF (messageID);
|
||||||
PR_FREEIF (commandSpecificData);
|
PR_FREEIF (commandSpecificData);
|
||||||
|
|
||||||
if (*status < 0)
|
if (NS_FAILED(rv))
|
||||||
{
|
{
|
||||||
#ifdef UNREADY_CODE
|
#ifdef UNREADY_CODE
|
||||||
ce->URL_s->error_msg = NET_ExplainErrorDetails(*status);
|
ce->URL_s->error_msg = NET_ExplainErrorDetails(*status);
|
||||||
#endif
|
#endif
|
||||||
return NS_ERROR_FAILURE;
|
return rv;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// our first state is a process state so drive the state machine...
|
// our first state is a process state so drive the state machine...
|
||||||
PRBool transportOpen = PR_FALSE;
|
PRBool transportOpen = PR_FALSE;
|
||||||
m_transport->IsTransportOpen(&transportOpen);
|
rv = m_transport->IsTransportOpen(&transportOpen);
|
||||||
m_runningURL->SetUrlState(PR_TRUE, NS_OK); // set the url as a url currently being run...
|
m_runningURL->SetUrlState(PR_TRUE, NS_OK); // set the url as a url currently being run...
|
||||||
if (transportOpen == PR_FALSE)
|
if (!transportOpen)
|
||||||
{
|
{
|
||||||
m_nextStateAfterResponse = m_nextState;
|
m_nextStateAfterResponse = m_nextState;
|
||||||
m_nextState = NNTP_RESPONSE;
|
m_nextState = NNTP_RESPONSE;
|
||||||
m_transport->Open(m_runningURL); // opening the url will cause to get notified when the connection is established
|
rv = m_transport->Open(m_runningURL); // opening the url will cause to get notified when the connection is established
|
||||||
}
|
}
|
||||||
else // the connection is already open so we should begin processing our new url...
|
else // the connection is already open so we should begin processing our new url...
|
||||||
*status = ProcessProtocolState(m_runningURL, nsnull, 0);
|
return ProcessProtocolState(m_runningURL, nsnull, 0);
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return rv;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// stop binding is a "notification" informing us that the stream associated with aURL is going away.
|
// stop binding is a "notification" informing us that the stream associated with aURL is going away.
|
||||||
|
@ -829,7 +818,7 @@ NS_IMETHODIMP nsNNTPProtocol::OnStopBinding(nsIURL* aURL, nsresult aStatus, cons
|
||||||
So, we'll make sure we quote / in message IDs as %2F.
|
So, we'll make sure we quote / in message IDs as %2F.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
PRInt32 nsNNTPProtocol::ParseURL(nsIURL * aURL, char ** aHostAndPort, PRBool * bValP, char ** aGroup, char ** aMessageID,
|
nsresult nsNNTPProtocol::ParseURL(nsIURL * aURL, char ** aHostAndPort, PRBool * bValP, char ** aGroup, char ** aMessageID,
|
||||||
char ** aCommandSpecificData)
|
char ** aCommandSpecificData)
|
||||||
{
|
{
|
||||||
char * hostAndPort = NULL;
|
char * hostAndPort = NULL;
|
||||||
|
@ -989,8 +978,13 @@ PRInt32 nsNNTPProtocol::ParseURL(nsIURL * aURL, char ** aHostAndPort, PRBool * b
|
||||||
PR_FREEIF (message_id);
|
PR_FREEIF (message_id);
|
||||||
PR_FREEIF (command_specific_data);
|
PR_FREEIF (command_specific_data);
|
||||||
}
|
}
|
||||||
return status;
|
|
||||||
|
|
||||||
|
// mscott - this function might need to be re-written to use nsresults
|
||||||
|
// so we don't lose the nature of the error in this return code I'm adding.
|
||||||
|
if (status < 0)
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
else
|
||||||
|
return NS_OK;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Writes the data contained in dataBuffer into the current output stream. It also informs
|
* Writes the data contained in dataBuffer into the current output stream. It also informs
|
||||||
|
|
|
@ -158,7 +158,7 @@ public:
|
||||||
NS_IMETHOD Initialize(nsIURL * aURL);
|
NS_IMETHOD Initialize(nsIURL * aURL);
|
||||||
|
|
||||||
// aConsumer is typically a display stream you may want the results to be displayed into...
|
// aConsumer is typically a display stream you may want the results to be displayed into...
|
||||||
virtual nsresult LoadUrl(nsIURL * aURL, nsISupports * aConsumer /* consumer of the url */, PRInt32 * status);
|
virtual nsresult LoadUrl(nsIURL * aURL, nsISupports * aConsumer = nsnull);
|
||||||
|
|
||||||
// stop binding is a "notification" informing us that the stream associated with aURL is going away.
|
// stop binding is a "notification" informing us that the stream associated with aURL is going away.
|
||||||
NS_IMETHOD OnStopBinding(nsIURL* aURL, nsresult aStatus, const PRUnichar* aMsg);
|
NS_IMETHOD OnStopBinding(nsIURL* aURL, nsresult aStatus, const PRUnichar* aMsg);
|
||||||
|
@ -362,7 +362,7 @@ private:
|
||||||
// End of Protocol Methods
|
// End of Protocol Methods
|
||||||
////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
PRInt32 ParseURL(nsIURL * aURL, char ** aHostAndPort, PRBool * bValP, char ** aGroup, char ** aMessageID, char ** aCommandSpecificData);
|
nsresult ParseURL(nsIURL * aURL, char ** aHostAndPort, PRBool * bValP, char ** aGroup, char ** aMessageID, char ** aCommandSpecificData);
|
||||||
};
|
};
|
||||||
|
|
||||||
NS_BEGIN_EXTERN_C
|
NS_BEGIN_EXTERN_C
|
||||||
|
|
|
@ -349,10 +349,8 @@ nsresult nsNntpService::PostMessage(nsFilePath &pathToFile, const char *subject,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv))
|
||||||
PRInt32 status = 0;
|
rv = nntpProtocol->LoadUrl(nntpUrl, /* aConsumer */ nsnull);
|
||||||
rv = nntpProtocol->LoadUrl(nntpUrl, /* aConsumer */ nsnull, &status);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_retval)
|
if (_retval)
|
||||||
*_retval = nntpUrl; // transfer ref count
|
*_retval = nntpUrl; // transfer ref count
|
||||||
|
@ -392,9 +390,8 @@ nsNntpService::RunNewsUrl(nsString& urlString, nsISupports * aConsumer, nsIUrlLi
|
||||||
rv = newsgroup->Initialize(nsnull /* line */, nsnull /* set */, PR_FALSE /* subscribed */);
|
rv = newsgroup->Initialize(nsnull /* line */, nsnull /* set */, PR_FALSE /* subscribed */);
|
||||||
newsgroup->SetName((char *)((const char *)nsAutoCString(newsgroupName)));
|
newsgroup->SetName((char *)((const char *)nsAutoCString(newsgroupName)));
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
return rv;
|
return rv;
|
||||||
}
|
|
||||||
|
|
||||||
nntpUrl->SetNewsgroup(newsgroup);
|
nntpUrl->SetNewsgroup(newsgroup);
|
||||||
|
|
||||||
|
@ -409,10 +406,9 @@ nsNntpService::RunNewsUrl(nsString& urlString, nsISupports * aConsumer, nsIUrlLi
|
||||||
// almost there...now create a nntp protocol instance to run the url in...
|
// almost there...now create a nntp protocol instance to run the url in...
|
||||||
nntpProtocol = new nsNNTPProtocol();
|
nntpProtocol = new nsNNTPProtocol();
|
||||||
if (nntpProtocol) {
|
if (nntpProtocol) {
|
||||||
PRInt32 status = 0;
|
|
||||||
rv = nntpProtocol->Initialize(nntpUrl);
|
rv = nntpProtocol->Initialize(nntpUrl);
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
rv = nntpProtocol->LoadUrl(nntpUrl, aConsumer, &status);
|
rv = nntpProtocol->LoadUrl(nntpUrl, aConsumer);
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче