зеркало из https://github.com/mozilla/pjs.git
fix for #31715. pass the nsIMsgWindow when trying to post a message.
(we may need it, if we have to authenticate the use for posting.) also, clean up the code to handle NS_ERROR_* properly.
This commit is contained in:
Родитель
3b69378fba
Коммит
5fc7d2ab75
|
@ -2869,7 +2869,19 @@ nsMsgComposeAndSend::DeliverFileAsNews()
|
|||
SetStatusMessage( msg );
|
||||
PR_FREEIF(msg);
|
||||
|
||||
rv = nntpService->PostMessage(fileToPost, mCompFields->GetNewsgroups(), mNewsPostListener, nsnull);
|
||||
nsCOMPtr <nsIMsgMailSession> mailSession = do_GetService(kMsgMailSessionCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (!mailSession) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIMsgWindow> msgWindow;
|
||||
rv = mailSession->GetTemporaryMsgWindow(getter_AddRefs(msgWindow));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (!msgWindow) return NS_ERROR_FAILURE;
|
||||
|
||||
rv = nntpService->PostMessage(fileToPost, mCompFields->GetNewsgroups(), mNewsPostListener, msgWindow, nsnull);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
|
|
@ -36,7 +36,7 @@ interface nsINntpService : nsISupports {
|
|||
|
||||
string convertNewsgroupsString(in string newsgroupsStr);
|
||||
|
||||
nsIURI postMessage (in nsIFileSpec fileToPost, in string newsgroupNames, in nsIUrlListener aUrlListener);
|
||||
nsIURI postMessage (in nsIFileSpec fileToPost, in string newsgroupNames, in nsIUrlListener aUrlListener, in nsIMsgWindow aMsgWindow);
|
||||
|
||||
nsIURI getNewNews (in nsINntpIncomingServer nntpServer, in string uri, in nsIUrlListener aUrlListener, in nsIMsgWindow aMsgWindow);
|
||||
|
||||
|
|
|
@ -1174,7 +1174,7 @@ PRInt32 nsNNTPProtocol::NewsResponse(nsIInputStream * inputStream, PRUint32 leng
|
|||
((m_responseCode != MK_NNTP_RESPONSE_AUTHINFO_REQUIRE) &&
|
||||
(m_responseCode != MK_NNTP_RESPONSE_AUTHINFO_SIMPLE_REQUIRE))) {
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIPrompt, dialog, kCNetSupportDialogCID, &rv);
|
||||
nsCOMPtr <nsIPrompt> dialog = do_GetService(kCNetSupportDialogCID, &rv);
|
||||
if (NS_SUCCEEDED(rv) || dialog) {
|
||||
nsXPIDLString errorText;
|
||||
GetNewsStringByName("errorFromServer", getter_Copies(errorText));
|
||||
|
@ -2366,6 +2366,7 @@ PRInt32 nsNNTPProtocol::BeginAuthorization()
|
|||
}
|
||||
|
||||
if (NS_FAILED(rv) || !cachedUsername) {
|
||||
rv = NS_OK;
|
||||
#ifdef DEBUG_NEWS
|
||||
printf("ask for the news username\n");
|
||||
#endif /* DEBUG_NEWS */
|
||||
|
@ -2373,14 +2374,23 @@ PRInt32 nsNNTPProtocol::BeginAuthorization()
|
|||
nsXPIDLString usernamePromptText;
|
||||
GetNewsStringByName("enterUsername", getter_Copies(usernamePromptText));
|
||||
if (m_newsFolder) {
|
||||
|
||||
if (!m_msgWindow) {
|
||||
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(m_runningURL);
|
||||
if (mailnewsurl) {
|
||||
rv = mailnewsurl->GetMsgWindow(getter_AddRefs(m_msgWindow));
|
||||
}
|
||||
}
|
||||
rv = m_newsFolder->GetGroupUsernameWithUI(usernamePromptText, nsnull, m_msgWindow, getter_Copies(username));
|
||||
}
|
||||
|
||||
if (!m_msgWindow) {
|
||||
#ifdef DEBUG_NEWS
|
||||
printf("unable to get the msg window\n");
|
||||
#endif /* DEBUG_NEWS */
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = m_newsFolder->GetGroupUsernameWithUI(usernamePromptText, nsnull, m_msgWindow, getter_Copies(username));
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("we don't know the folder\n");
|
||||
|
@ -2486,6 +2496,8 @@ PRInt32 nsNNTPProtocol::AuthorizationResponse()
|
|||
rv = m_newsFolder->GetGroupPassword(getter_Copies(cachedPassword));
|
||||
}
|
||||
if (NS_FAILED(rv) || !cachedPassword) {
|
||||
rv = NS_OK;
|
||||
|
||||
#ifdef DEBUG_NEWS
|
||||
printf("ask for the news password\n");
|
||||
#endif /* DEBUG_NEWS */
|
||||
|
@ -2502,7 +2514,17 @@ PRInt32 nsNNTPProtocol::AuthorizationResponse()
|
|||
rv = mailnewsurl->GetMsgWindow(getter_AddRefs(m_msgWindow));
|
||||
}
|
||||
}
|
||||
rv = m_newsFolder->GetGroupPasswordWithUI(passwordPromptText, passwordPromptTitleText, m_msgWindow, getter_Copies(password));
|
||||
|
||||
if (!m_msgWindow) {
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
#ifdef DEBUG_NEWS
|
||||
printf("unable to get the msg window\n");
|
||||
#endif /* DEBUG_NEWS */
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = m_newsFolder->GetGroupPasswordWithUI(passwordPromptText, passwordPromptTitleText, m_msgWindow, getter_Copies(password));
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("we don't know the folder\n");
|
||||
|
@ -3746,7 +3768,7 @@ PRInt32 nsNNTPProtocol::DoCancel()
|
|||
cancelInfo.old_from = m_cancelFromHdr;
|
||||
cancelInfo.from = nsnull;
|
||||
|
||||
NS_WITH_SERVICE(nsIPrompt, dialog, kCNetSupportDialogCID, &rv);
|
||||
nsCOMPtr <nsIPrompt> dialog = do_GetService(kCNetSupportDialogCID, &rv);
|
||||
if (NS_FAILED(rv) || !dialog) return -1; /* unable to get the dialog service */
|
||||
|
||||
NS_ASSERTION (id && newsgroups, "null ptr");
|
||||
|
@ -4795,9 +4817,6 @@ nsresult nsNNTPProtocol::ProcessProtocolState(nsIURI * url, nsIInputStream * inp
|
|||
break;
|
||||
|
||||
case NNTP_ERROR:
|
||||
#ifdef DEBUG_NEWS
|
||||
printf("NNTP_ERROR!\n");
|
||||
#endif
|
||||
#if 0 // mscott 01/04/99. This should be temporary until I figure out what to do with this code.....
|
||||
if(cd->stream)
|
||||
{
|
||||
|
|
|
@ -1311,7 +1311,7 @@ nsMsgNewsFolder::GetGroupUsernameWithUI(const PRUnichar * aPromptMessage, const
|
|||
nsIMsgWindow* aMsgWindow,
|
||||
char **aGroupUsername)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsresult rv = NS_ERROR_FAILURE;;
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aMsgWindow);
|
||||
NS_ENSURE_ARG_POINTER(aGroupUsername);
|
||||
|
|
|
@ -723,11 +723,12 @@ nsresult nsNntpService::ConvertNewsgroupsString(const char *newsgroupsNames, cha
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsNntpService::PostMessage(nsIFileSpec *fileToPost, const char *newsgroupsNames, nsIUrlListener * aUrlListener, nsIURI **_retval)
|
||||
nsresult nsNntpService::PostMessage(nsIFileSpec *fileToPost, const char *newsgroupsNames, nsIUrlListener * aUrlListener, nsIMsgWindow *aMsgWindow, nsIURI **_retval)
|
||||
{
|
||||
#ifdef DEBUG_NEWS
|
||||
printf("nsNntpService::PostMessage(??,%s,??,??)\n",newsgroupsNames);
|
||||
#endif
|
||||
if (!aMsgWindow) return NS_ERROR_NULL_POINTER;
|
||||
if (!newsgroupsNames) return NS_ERROR_NULL_POINTER;
|
||||
if (PL_strlen(newsgroupsNames) == 0) return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -756,7 +757,7 @@ 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(mailnewsurl, nsnull);
|
||||
nntpProtocol = new nsNNTPProtocol(mailnewsurl, aMsgWindow);
|
||||
if (!nntpProtocol) return NS_ERROR_OUT_OF_MEMORY;;
|
||||
|
||||
rv = nntpProtocol->Initialize();
|
||||
|
|
Загрузка…
Ссылка в новой задаче