From fece31ac28c6ccd6ecca19c22c17c2e581dcc5ab Mon Sep 17 00:00:00 2001 From: "sspitzer%netscape.com" Date: Tue, 19 Sep 2000 22:40:52 +0000 Subject: [PATCH] part of the fix for #46888. after cancelling a news message, you can't select another message. fix by naving@netscape.com. r=sspitzer,a=mscott also a couple bullet proofing fixes to prevent crashes. git-svn-id: svn://10.0.0.236/trunk@79556 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/docshell/base/nsWebShell.cpp | 5 +- .../psm-glue/src/nsSecureBrowserUIImpl.cpp | 13 ++-- mozilla/mailnews/news/src/nsNNTPProtocol.cpp | 60 +++++++++++++------ mozilla/mailnews/news/src/nsNNTPProtocol.h | 1 + 4 files changed, 56 insertions(+), 23 deletions(-) diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index adc56c1a4a0..d2ae08dece7 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -1005,7 +1005,10 @@ nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader, if(mDocLoader == loader && NS_FAILED(aStatus)) { nsXPIDLCString host; - nsresult hostResult = aURL->GetHost(getter_Copies(host)); + nsresult hostResult = NS_ERROR_FAILURE; + if (aURL) { + hostResult = aURL->GetHost(getter_Copies(host)); + } if (NS_SUCCEEDED(hostResult) && host) { CBufDescriptor buf((const char *)host, PR_TRUE, PL_strlen(host) + 1); diff --git a/mozilla/extensions/psm-glue/src/nsSecureBrowserUIImpl.cpp b/mozilla/extensions/psm-glue/src/nsSecureBrowserUIImpl.cpp index f123d5c3a92..54cd4836ad0 100644 --- a/mozilla/extensions/psm-glue/src/nsSecureBrowserUIImpl.cpp +++ b/mozilla/extensions/psm-glue/src/nsSecureBrowserUIImpl.cpp @@ -315,12 +315,15 @@ nsSecureBrowserUIImpl::OnStateChange(nsIWebProgress* aWebProgress, eventSink = do_GetInterface(requestor); nsCOMPtr loadingURI; - channel->GetURI(getter_AddRefs(loadingURI)); - + res = channel->GetURI(getter_AddRefs(loadingURI)); + NS_ASSERTION(NS_SUCCEEDED(res),"GetURI failed"); + #if defined(DEBUG) - nsXPIDLCString temp; - loadingURI->GetSpec(getter_Copies(temp)); - PR_LOG(gSecureDocLog, PR_LOG_DEBUG, ("SecureUI:%p: OnStateChange: %x :%s\n", this, aProgressStateFlags,(const char*)temp)); + if (loadingURI) { + nsXPIDLCString temp; + loadingURI->GetSpec(getter_Copies(temp)); + PR_LOG(gSecureDocLog, PR_LOG_DEBUG, ("SecureUI:%p: OnStateChange: %x :%s\n", this, aProgressStateFlags,(const char*)temp)); + } #endif // A Document is starting to load... diff --git a/mozilla/mailnews/news/src/nsNNTPProtocol.cpp b/mozilla/mailnews/news/src/nsNNTPProtocol.cpp index 1ee7f871220..0aecd03ac55 100644 --- a/mozilla/mailnews/news/src/nsNNTPProtocol.cpp +++ b/mozilla/mailnews/news/src/nsNNTPProtocol.cpp @@ -544,7 +544,7 @@ NS_IMETHODIMP nsNNTPProtocol::Initialize(nsIURI * aURL, nsIMsgWindow *aMsgWindow if (NS_FAILED(rv)) return rv; } - NS_PRECONDITION(m_url, "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 @@ -868,10 +868,19 @@ nsresult nsNNTPProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer) m_typeWanted = LIST_WANTED; } else { - nsXPIDLCString newsgroupURI; - rv = aURL->GetSpec(getter_Copies(newsgroupURI)); + + nsXPIDLCString username; + rv = aURL->GetUsername(getter_Copies(username)); if (NS_FAILED(rv)) return(rv); - + + nsXPIDLCString hostname; + rv = aURL->GetHost(getter_Copies(hostname)); + if (NS_FAILED(rv)) return(rv); + + nsXPIDLCString newsgroupURI; + rv = CreateNewsFolderURI((const char *)username,(const char *)hostname,(const char *)m_currentGroup,getter_Copies(newsgroupURI)); + if (NS_FAILED(rv)) return rv; + PRBool containsGroup = PR_TRUE; NS_ASSERTION(m_nntpServer,"no nntp server"); if (m_nntpServer) { @@ -2304,7 +2313,7 @@ PRInt32 nsNNTPProtocol::ReadArticle(nsIInputStream * inputStream, PRUint32 lengt rv = m_runningURL->GetMessageHeader(getter_AddRefs(msgHdr)); - if (NS_SUCCEEDED(rv)) { + if (NS_SUCCEEDED(rv) && msgHdr) { msgHdr->MarkRead(PR_TRUE); } @@ -2409,22 +2418,13 @@ nsNNTPProtocol::SetNewsFolder() // xxx todo: I need to fix this so this is passed in when I create the nsNNTPProtocol if (!m_newsFolder) { - nsCAutoString folderURI("news://"); - - if ((const char *)m_userName) { - folderURI += (const char *)m_userName; - folderURI += "@"; - } - folderURI += (const char *)m_hostName; - + nsXPIDLCString folderURI; nsXPIDLCString newsgroupName; rv = m_runningURL->GetNewsgroupName(getter_Copies(newsgroupName)); if (NS_FAILED(rv)) return rv; - if ((const char *)newsgroupName) { - folderURI += "/"; - folderURI += (const char *)newsgroupName; - } + rv = CreateNewsFolderURI((const char *)m_userName,(const char *)m_hostName, (const char *)newsgroupName, getter_Copies(folderURI)); + if (NS_FAILED(rv)) return rv; rv = InitializeNewsFolderFromUri((const char *)folderURI); if (NS_FAILED(rv)) return rv; @@ -2432,6 +2432,32 @@ nsNNTPProtocol::SetNewsFolder() return NS_OK; } +nsresult +nsNNTPProtocol::CreateNewsFolderURI(const char *username, const char *hostname, const char *newsgroupname, char **uri) +{ + nsCAutoString folderURI("news://"); + + if ((const char *)username) { + folderURI += (const char *)username; + folderURI += "@"; + } + folderURI += (const char *)hostname; + + if ((const char *)newsgroupname) { + folderURI += "/"; + folderURI += (const char *)newsgroupname; + } + + if (!uri) return NS_ERROR_NULL_POINTER; + + *uri = PL_strdup((const char *)folderURI); + if (!*uri) return NS_ERROR_OUT_OF_MEMORY; +#ifdef DEBUG_sspitzer + printf("news uri=%s\n",*uri); +#endif /* DEBUG_sspitzer */ + return NS_OK; +} + PRInt32 nsNNTPProtocol::BeginAuthorization() { char * command = 0; diff --git a/mozilla/mailnews/news/src/nsNNTPProtocol.h b/mozilla/mailnews/news/src/nsNNTPProtocol.h index 6a5b5b57021..98aa9b722a2 100644 --- a/mozilla/mailnews/news/src/nsNNTPProtocol.h +++ b/mozilla/mailnews/news/src/nsNNTPProtocol.h @@ -397,6 +397,7 @@ private: void SetProgressBarPercent(PRUint32 aProgress, PRUint32 aProgressMax); nsresult SetProgressStatus(const PRUnichar *aMessage); nsresult SetNewsFolder(); /* sets m_newsFolder, if not already set */ + nsresult CreateNewsFolderURI (const char *username, const char *hostname, const char *newsgroupname, char **uri); nsresult InitializeNewsFolderFromUri(const char *uri); void TimerCallback(); nsCOMPtr mInputStream;