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:
mscott%netscape.com 1999-06-07 22:31:37 +00:00
Родитель 0051b03950
Коммит ff35c93a2a
3 изменённых файлов: 30 добавлений и 40 удалений

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

@ -452,7 +452,7 @@ nsresult nsNNTPProtocol::Initialize(nsIURL * aURL)
return NS_OK;
}
nsresult nsNNTPProtocol::LoadUrl(nsIURL * aURL, nsISupports * aConsumer, PRInt32 *status)
nsresult nsNNTPProtocol::LoadUrl(nsIURL * aURL, nsISupports * aConsumer)
{
PRBool bVal = FALSE;
char * hostAndPort = 0;
@ -463,8 +463,6 @@ nsresult nsNNTPProtocol::LoadUrl(nsIURL * aURL, nsISupports * aConsumer, PRInt32
nsCOMPtr <nsINNTPNewsgroupPost> message;
//char *message_id = 0;
*status = 0;
nsresult rv = NS_OK;
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...
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)
{
@ -491,13 +489,10 @@ nsresult nsNNTPProtocol::LoadUrl(nsIURL * aURL, nsISupports * aConsumer, PRInt32
if (NS_FAILED(rv))
{
*status = -1;
goto FAIL;
}
*status = ParseURL(aURL, &hostAndPort, &bVal, &group, &messageID, &commandSpecificData);
if (*status < 0)
goto FAIL;
rv = ParseURL(aURL, &hostAndPort, &bVal, &group, &messageID, &commandSpecificData);
// if we don't have a news host already, go get one...
if (!m_newsHost)
@ -515,10 +510,9 @@ nsresult nsNNTPProtocol::LoadUrl(nsIURL * aURL, nsISupports * aConsumer, PRInt32
nsINNTPHost::GetIID(),
getter_AddRefs(m_newsHost));
if (NS_FAILED(rv) || (!m_newsHost)) {
*status = -1;
if (NS_FAILED(rv) || (!m_newsHost))
goto FAIL;
}
// at this point, hostAndPort is really just the hostname
// because we put a '\0' in for the colon, if there was one
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);
PR_FREEIF(newshosturi);
if (NS_FAILED(rv)) {
*status = -1;
if (NS_FAILED(rv))
goto FAIL;
}
}
PR_ASSERT(NS_SUCCEEDED(rv));
if (!NS_SUCCEEDED(rv))
{
*status = -1;
if (NS_FAILED(rv))
goto FAIL;
}
if (messageID && commandSpecificData && !PL_strcmp (commandSpecificData, "?cancel"))
cancel = TRUE;
@ -751,30 +739,31 @@ nsresult nsNNTPProtocol::LoadUrl(nsIURL * aURL, nsISupports * aConsumer, PRInt32
PR_FREEIF (messageID);
PR_FREEIF (commandSpecificData);
if (*status < 0)
if (NS_FAILED(rv))
{
#ifdef UNREADY_CODE
ce->URL_s->error_msg = NET_ExplainErrorDetails(*status);
#endif
return NS_ERROR_FAILURE;
return rv;
}
else
{
// our first state is a process state so drive the state machine...
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...
if (transportOpen == PR_FALSE)
if (!transportOpen)
{
m_nextStateAfterResponse = m_nextState;
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...
*status = ProcessProtocolState(m_runningURL, nsnull, 0);
return NS_OK;
return ProcessProtocolState(m_runningURL, nsnull, 0);
}
return rv;
}
// 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.
*/
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 * hostAndPort = NULL;
@ -989,8 +978,13 @@ PRInt32 nsNNTPProtocol::ParseURL(nsIURL * aURL, char ** aHostAndPort, PRBool * b
PR_FREEIF (message_id);
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

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

@ -158,7 +158,7 @@ public:
NS_IMETHOD Initialize(nsIURL * aURL);
// 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.
NS_IMETHOD OnStopBinding(nsIURL* aURL, nsresult aStatus, const PRUnichar* aMsg);
@ -362,7 +362,7 @@ private:
// 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

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

@ -349,10 +349,8 @@ nsresult nsNntpService::PostMessage(nsFilePath &pathToFile, const char *subject,
}
}
if (NS_SUCCEEDED(rv)) {
PRInt32 status = 0;
rv = nntpProtocol->LoadUrl(nntpUrl, /* aConsumer */ nsnull, &status);
}
if (NS_SUCCEEDED(rv))
rv = nntpProtocol->LoadUrl(nntpUrl, /* aConsumer */ nsnull);
if (_retval)
*_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 */);
newsgroup->SetName((char *)((const char *)nsAutoCString(newsgroupName)));
}
else {
else
return rv;
}
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...
nntpProtocol = new nsNNTPProtocol();
if (nntpProtocol) {
PRInt32 status = 0;
rv = nntpProtocol->Initialize(nntpUrl);
if (NS_FAILED(rv)) return rv;
rv = nntpProtocol->LoadUrl(nntpUrl, aConsumer, &status);
rv = nntpProtocol->LoadUrl(nntpUrl, aConsumer);
if (NS_FAILED(rv)) return rv;
}