From a26d2332fd5f89c34d2ff92e86a1cb3fa6b4b0a6 Mon Sep 17 00:00:00 2001 From: "sspitzer%netscape.com" Date: Sun, 13 May 2001 05:27:35 +0000 Subject: [PATCH] fix for #77510. get posting a draft to work. pass in (but ignore) the nntp posting url until I clean up the code that uses it. sr=bienvenu --- mailnews/compose/src/nsMsgSend.cpp | 2 +- mailnews/news/public/nsINntpService.idl | 4 ++-- mailnews/news/src/nsNNTPProtocol.cpp | 1 + mailnews/news/src/nsNntpService.cpp | 16 ++++++++++------ mailnews/news/src/nsNntpService.h | 2 +- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/mailnews/compose/src/nsMsgSend.cpp b/mailnews/compose/src/nsMsgSend.cpp index 2358ad913c70..e6a068bd7eec 100644 --- a/mailnews/compose/src/nsMsgSend.cpp +++ b/mailnews/compose/src/nsMsgSend.cpp @@ -2985,7 +2985,7 @@ nsMsgComposeAndSend::DeliverFileAsNews() if (!msgWindow) return NS_ERROR_FAILURE; - rv = nntpService->PostMessage(fileToPost, mCompFields->GetNewsgroups(), mCompFields->GetNewshost(), uriListener, msgWindow, nsnull); + rv = nntpService->PostMessage(fileToPost, mCompFields->GetNewsgroups(), mCompFields->GetNewspostUrl(), uriListener, msgWindow, nsnull); if (NS_FAILED(rv)) return rv; } diff --git a/mailnews/news/public/nsINntpService.idl b/mailnews/news/public/nsINntpService.idl index 9dd9a5123cdb..a86b7230fff2 100644 --- a/mailnews/news/public/nsINntpService.idl +++ b/mailnews/news/public/nsINntpService.idl @@ -49,9 +49,9 @@ interface nsINntpService : nsISupports { */ void generateNewsHeaderValsForPosting(in string newsgroupsList, out string newsgroupsHeaderVal, out string newshostHeaderVal); - nsIURI postMessage (in nsIFileSpec fileToPost, in string newsgroupNames, in string newshostName, in nsIUrlListener aUrlListener, in nsIMsgWindow aMsgWindow); + nsIURI postMessage(in nsIFileSpec fileToPost, in string newsgroupNames, in string newspostingUrl, in nsIUrlListener aUrlListener, in nsIMsgWindow aMsgWindow); - nsIURI getNewNews (in nsINntpIncomingServer nntpServer, in string uri, in boolean getOld, in nsIUrlListener aUrlListener, in nsIMsgWindow aMsgWindow); + nsIURI getNewNews(in nsINntpIncomingServer nntpServer, in string uri, in boolean getOld, in nsIUrlListener aUrlListener, in nsIMsgWindow aMsgWindow); nsIURI cancelMessage(in string cancelURL, in string messageURI, in nsISupports aConsumer, in nsIUrlListener aUrlListener, in nsIMsgWindow aMsgWindow); diff --git a/mailnews/news/src/nsNNTPProtocol.cpp b/mailnews/news/src/nsNNTPProtocol.cpp index d58887c76b71..757914190b63 100644 --- a/mailnews/news/src/nsNNTPProtocol.cpp +++ b/mailnews/news/src/nsNNTPProtocol.cpp @@ -528,6 +528,7 @@ NS_IMETHODIMP nsNNTPProtocol::Initialize(nsIURI * aURL, nsIMsgWindow *aMsgWindow else { rv = OpenNetworkSocket(m_url, nsnull, ir); } + NS_ENSURE_SUCCESS(rv,rv); m_nextState = NNTP_LOGIN_RESPONSE; } else { diff --git a/mailnews/news/src/nsNntpService.cpp b/mailnews/news/src/nsNntpService.cpp index 74fde0ec8020..402f8520c96d 100644 --- a/mailnews/news/src/nsNntpService.cpp +++ b/mailnews/news/src/nsNntpService.cpp @@ -591,13 +591,20 @@ nsresult nsNntpService::FindHostFromGroup(nsCString &host, nsCString &groupName) } nsresult -nsNntpService::SetUpNntpUrlForPosting(nsINntpUrl *nntpUrl, const char *newsgroupsNames, const char *newshost, char **newsUrlSpec) +nsNntpService::SetUpNntpUrlForPosting(nsINntpUrl *nntpUrl, const char *newsgroupsNames, const char *newspostingUrl, char **newsUrlSpec) { nsresult rv = NS_OK; NS_ENSURE_ARG_POINTER(nntpUrl); NS_ENSURE_ARG_POINTER(newsgroupsNames); if (*newsgroupsNames == '\0') return NS_ERROR_FAILURE; + // XXX TODO rewrite this + // instead of using the hostname, we need to keep track of the current server id + // if newspostingUrl is non-null, we'll use that to determine the initial currentServer + // before we do that, I need to make sure the newspostingUrl we pass in is correct. + // until then, it is going to be safer to ignore it and try to determine the posting host + // from the newsgroups. + nsCAutoString host; // newsgroupsNames can be a comma seperated list of these: @@ -644,9 +651,6 @@ nsNntpService::SetUpNntpUrlForPosting(nsINntpUrl *nntpUrl, const char *newsgroup theRest.Left(currentHost, slashpos); theRest.Right(currentGroup, slashpos); } - else if (newshost && (*newshost != '\0')) { - currentHost.Assign(newshost); - } else { // str is "group" rv = FindHostFromGroup(currentHost, str); @@ -824,7 +828,7 @@ nsNntpService::GenerateNewsHeaderValsForPosting(const char *newsgroupsList, char } NS_IMETHODIMP -nsNntpService::PostMessage(nsIFileSpec *fileToPost, const char *newsgroupsNames, const char *newshost, nsIUrlListener * aUrlListener, nsIMsgWindow *aMsgWindow, nsIURI **_retval) +nsNntpService::PostMessage(nsIFileSpec *fileToPost, const char *newsgroupsNames, const char *newspostingUrl, nsIUrlListener * aUrlListener, nsIMsgWindow *aMsgWindow, nsIURI **_retval) { NS_ENSURE_ARG_POINTER(aMsgWindow); NS_ENSURE_ARG_POINTER(newsgroupsNames); @@ -843,7 +847,7 @@ nsNntpService::PostMessage(nsIFileSpec *fileToPost, const char *newsgroupsNames, NS_ENSURE_SUCCESS(rv,rv); nsXPIDLCString newsUrlSpec; - rv = SetUpNntpUrlForPosting(nntpUrl, newsgroupsNames, newshost, getter_Copies(newsUrlSpec)); + rv = SetUpNntpUrlForPosting(nntpUrl, newsgroupsNames, newspostingUrl, getter_Copies(newsUrlSpec)); NS_ENSURE_SUCCESS(rv,rv); nsCOMPtr mailnewsurl = do_QueryInterface(nntpUrl, &rv); diff --git a/mailnews/news/src/nsNntpService.h b/mailnews/news/src/nsNntpService.h index f3a99877a156..17f58bf089f2 100644 --- a/mailnews/news/src/nsNntpService.h +++ b/mailnews/news/src/nsNntpService.h @@ -69,7 +69,7 @@ public: protected: PRBool WeAreOffline(); - nsresult SetUpNntpUrlForPosting(nsINntpUrl * nntpUrl, const char *newsgroupNames, const char *newshost, char **newsUrlSpec); + nsresult SetUpNntpUrlForPosting(nsINntpUrl * nntpUrl, const char *newsgroupNames, const char *newspostingUrl, char **newsUrlSpec); nsresult FindHostFromGroup(nsCString &host, nsCString &groupName); nsresult FindServerWithNewsgroup(nsCString &host, nsCString &groupName);