зеркало из https://github.com/mozilla/gecko-dev.git
fix for #26773, alert when there is a network error in mailnews. r=mscott, a=phil
This commit is contained in:
Родитель
515c3ce686
Коммит
09b7b9db4f
|
@ -87,6 +87,7 @@
|
|||
#include "nsIDocShellTreeOwner.h"
|
||||
#include "nsCURILoader.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsISocketTransportService.h"
|
||||
|
||||
#include "nsIHTTPChannel.h" // add this to the ick include list...we need it to QI for post data interface
|
||||
#include "nsHTTPEnums.h"
|
||||
|
|
|
@ -29,10 +29,12 @@
|
|||
#include "nsILoadGroup.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsFileStream.h"
|
||||
#include "nsINetSupportDialogService.h"
|
||||
#include "nsIDNSService.h"
|
||||
|
||||
static NS_DEFINE_CID(kNetSupportDialogCID, NS_NETSUPPORTDIALOG_CID);
|
||||
static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
|
||||
NS_IMPL_ISUPPORTS3(nsMsgProtocol, nsIStreamListener, nsIStreamObserver, nsIChannel)
|
||||
|
||||
nsMsgProtocol::nsMsgProtocol(nsIURI * aURL, nsIURI* originalURI)
|
||||
|
@ -213,6 +215,31 @@ NS_IMETHODIMP nsMsgProtocol::OnStopRequest(nsIChannel * aChannel, nsISupports *c
|
|||
if (m_channelListener)
|
||||
rv = m_channelListener->OnStopRequest(this, m_channelContext, aStatus, aMsg);
|
||||
|
||||
if (NS_FAILED(aStatus)) {
|
||||
NS_WITH_SERVICE(nsIPrompt, dialog, kNetSupportDialogCID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && dialog) {
|
||||
// todo, put this into a string bundle
|
||||
nsAutoString alertMsg("unknown error.");
|
||||
switch (aStatus) {
|
||||
case NS_ERROR_UNKNOWN_HOST:
|
||||
// todo, put this into a string bundle
|
||||
alertMsg = "Failed to connect to the server.";
|
||||
break;
|
||||
case NS_ERROR_CONNECTION_REFUSED:
|
||||
// todo, put this into a string bundle
|
||||
alertMsg = "Connection refused to the server.";
|
||||
break;
|
||||
case NS_ERROR_NET_TIMEOUT:
|
||||
// todo, put this into a string bundle
|
||||
alertMsg = "Connection to the server timed out.";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
dialog->Alert(alertMsg.GetUnicode());
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -250,3 +250,14 @@
|
|||
## @loc None
|
||||
5051=Enter your password
|
||||
|
||||
## @name IMAP_UNKNOWN_HOST_ERROR
|
||||
## @loc None
|
||||
5052=Failed to connect to the server.
|
||||
|
||||
## @name IMAP_IMAP_CONNECTION_REFUSED_ERROR
|
||||
## @loc None
|
||||
5053=Connection refused to the server.
|
||||
|
||||
## @name IMAP_NET_TIMEOUT_ERROR
|
||||
## @loc None
|
||||
5054=Connection to the server timed out.
|
||||
|
|
|
@ -589,9 +589,9 @@ nsImapIncomingServer::CloseCachedConnections()
|
|||
|
||||
nsresult rv = m_connectionCache->Count(&cnt);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
for (PRUint32 i = 0; i < cnt; i++)
|
||||
for (PRUint32 i = cnt; i>0; i--)
|
||||
{
|
||||
aSupport = getter_AddRefs(m_connectionCache->ElementAt(i));
|
||||
aSupport = getter_AddRefs(m_connectionCache->ElementAt(i-1));
|
||||
connection = do_QueryInterface(aSupport);
|
||||
if (connection)
|
||||
rv = connection->TellThreadToDie(PR_TRUE);
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include "nsICopyMsgStreamListener.h"
|
||||
#include "nsTextFormatter.h"
|
||||
#include "nsAutoLock.h"
|
||||
#include "nsIDNSService.h"
|
||||
|
||||
// for the memory cache...
|
||||
#include "nsINetDataCacheManager.h"
|
||||
|
@ -738,7 +739,8 @@ NS_IMETHODIMP nsImapProtocol::Run()
|
|||
me->m_imapMiscellaneousSink = null_nsCOMPtr();
|
||||
m_iThread = null_nsCOMPtr();
|
||||
|
||||
NS_RELEASE(me);
|
||||
//this is bogus, we need to find the leak
|
||||
//NS_RELEASE(me);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -795,7 +797,7 @@ nsImapProtocol::TellThreadToDie(PRBool isSaveToClose)
|
|||
|
||||
// if the connection is closed,then don't try to send data
|
||||
// to the connection.
|
||||
PRBool connectionIsLost = TestFlag(IMAP_CONNECTION_IS_OPEN);
|
||||
PRBool connectionIsLost = !TestFlag(IMAP_CONNECTION_IS_OPEN);
|
||||
|
||||
PRBool closeNeeded = GetServerStateParser().GetIMAPstate() ==
|
||||
nsImapServerResponseParser::kFolderSelected && isSaveToClose;
|
||||
|
@ -906,6 +908,8 @@ nsImapProtocol::ImapThreadMainLoop()
|
|||
ClearFlag(IMAP_FIRST_PASS_IN_THREAD);
|
||||
}
|
||||
|
||||
if (DeathSignalReceived()) break;
|
||||
|
||||
PR_EnterMonitor(m_urlReadyToRunMonitor);
|
||||
|
||||
PRStatus err;
|
||||
|
@ -936,7 +940,9 @@ void nsImapProtocol::EstablishServerConnection()
|
|||
|
||||
// record the fact that we've received a greeting for this connection so we don't ever
|
||||
// try to do it again..
|
||||
SetFlag(IMAP_RECEIVED_GREETING);
|
||||
if (serverResponse) {
|
||||
SetFlag(IMAP_RECEIVED_GREETING);
|
||||
}
|
||||
|
||||
if (!nsCRT::strncasecmp(serverResponse, "* OK", 4))
|
||||
{
|
||||
|
@ -1207,8 +1213,10 @@ PRBool nsImapProtocol::ProcessCurrentURL()
|
|||
nsCOMPtr<nsIImapIncomingServer> aImapServer = do_QueryInterface(m_server, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
aImapServer->RemoveConnection(this);
|
||||
TellThreadToDie(PR_FALSE);
|
||||
|
||||
if (!DeathSignalReceived()) {
|
||||
TellThreadToDie(PR_FALSE);
|
||||
}
|
||||
}
|
||||
return anotherUrlRun;
|
||||
}
|
||||
|
@ -1271,6 +1279,33 @@ NS_IMETHODIMP nsImapProtocol::OnStartRequest(nsIChannel * /* aChannel */, nsISup
|
|||
NS_IMETHODIMP nsImapProtocol::OnStopRequest(nsIChannel * /* aChannel */, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aMsg)
|
||||
{
|
||||
PR_CEnterMonitor(this);
|
||||
|
||||
PRBool killThread = PR_FALSE;
|
||||
|
||||
if (NS_FAILED(aStatus)) {
|
||||
switch (aStatus) {
|
||||
case NS_ERROR_UNKNOWN_HOST:
|
||||
AlertUserEventUsingId(IMAP_UNKNOWN_HOST_ERROR);
|
||||
killThread = PR_TRUE;
|
||||
break;
|
||||
case NS_ERROR_CONNECTION_REFUSED:
|
||||
AlertUserEventUsingId(IMAP_CONNECTION_REFUSED_ERROR);
|
||||
killThread = PR_TRUE;
|
||||
break;
|
||||
case NS_ERROR_NET_TIMEOUT:
|
||||
AlertUserEventUsingId(IMAP_NET_TIMEOUT_ERROR);
|
||||
killThread = PR_TRUE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (killThread == PR_TRUE) {
|
||||
ClearFlag(IMAP_CONNECTION_IS_OPEN);
|
||||
TellThreadToDie(PR_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
m_channel = null_nsCOMPtr();
|
||||
m_outputStream = null_nsCOMPtr();
|
||||
m_inputStream = null_nsCOMPtr();
|
||||
|
@ -3695,10 +3730,10 @@ char* nsImapProtocol::CreateNewLineFromSocket()
|
|||
m_eventQueue->ProcessPendingEvents();
|
||||
} while (TestFlag(IMAP_WAITING_FOR_DATA) && !DeathSignalReceived());
|
||||
}
|
||||
} while (!newLine); // until we get the next line and haven't been interrupted
|
||||
} while (!newLine && !DeathSignalReceived()); // until we get the next line and haven't been interrupted
|
||||
|
||||
Log("CreateNewLineFromSocket", nsnull, newLine);
|
||||
SetConnectionStatus(newLine && numBytesInLine ? 1 : 0); // set > 0 if string is not null or empty
|
||||
SetConnectionStatus(newLine && numBytesInLine ? 1 : -1); // set > 0 if string is not null or empty
|
||||
return newLine;
|
||||
}
|
||||
|
||||
|
|
|
@ -83,4 +83,8 @@ NS_END_EXTERN_C
|
|||
#define IMAP_SERVER_SAID 5049
|
||||
#define IMAP_DONE 5050
|
||||
#define IMAP_ENTER_PASSWORD_PROMPT_TITLE 5051
|
||||
#define IMAP_UNKNOWN_HOST_ERROR 5052
|
||||
#define IMAP_CONNECTION_REFUSED_ERROR 5053
|
||||
#define IMAP_NET_TIMEOUT_ERROR 5054
|
||||
|
||||
#endif /* _nsImapStringBundle_H__ */
|
||||
|
|
|
@ -448,6 +448,8 @@ nsNNTPProtocol::nsNNTPProtocol(nsIURI * aURL, nsIMsgWindow *aMsgWindow)
|
|||
if (aMsgWindow) {
|
||||
m_msgWindow = aMsgWindow;
|
||||
}
|
||||
|
||||
m_runningURL = null_nsCOMPtr();
|
||||
}
|
||||
|
||||
nsNNTPProtocol::~nsNNTPProtocol()
|
||||
|
@ -4927,4 +4929,4 @@ nsNNTPProtocol::SetProgressStatus(char *message)
|
|||
}
|
||||
}
|
||||
PR_FREEIF(progressMsg);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -248,7 +248,6 @@ NS_IMETHODIMP nsNntpUrl::GetURI(char ** aURI)
|
|||
{
|
||||
nsXPIDLCString spec;
|
||||
GetSpec(getter_Copies(spec));
|
||||
char * uri = nsnull;
|
||||
char * baseMessageURI;
|
||||
nsCreateNewsBaseMessageURI(spec, &baseMessageURI);
|
||||
nsCAutoString uriStr;
|
||||
|
|
|
@ -38,11 +38,7 @@
|
|||
#define NS_ERROR_NOT_CONNECTED \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 12)
|
||||
|
||||
#define NS_ERROR_CONNECTION_REFUSED \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 13)
|
||||
|
||||
#define NS_ERROR_NET_TIMEOUT \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 14)
|
||||
/* NS_ERROR_CONNECTION_REFUSED and NS_ERROR_NET_TIMEOUT moved to nsISocketTransportService.idl */
|
||||
|
||||
#define NS_ERROR_IN_PROGRESS \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 15)
|
||||
|
|
|
@ -67,4 +67,9 @@ interface nsISocketTransportService : nsISupports
|
|||
0x11d2, \
|
||||
{0x92, 0xb6, 0x00, 0x10, 0x5a, 0x1b, 0x0d, 0x64} \
|
||||
}
|
||||
|
||||
#define NS_ERROR_CONNECTION_REFUSED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 13)
|
||||
|
||||
#define NS_ERROR_NET_TIMEOUT NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 14)
|
||||
|
||||
%}
|
||||
|
|
|
@ -87,6 +87,7 @@
|
|||
#include "nsIDocShellTreeOwner.h"
|
||||
#include "nsCURILoader.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsISocketTransportService.h"
|
||||
|
||||
#include "nsIHTTPChannel.h" // add this to the ick include list...we need it to QI for post data interface
|
||||
#include "nsHTTPEnums.h"
|
||||
|
|
Загрузка…
Ссылка в новой задаче