Fixes part of 18075. reviewed by jefft. Don't crash when doing get msg on a pop account

that has no incoming server.
This commit is contained in:
putterman%netscape.com 1999-12-07 23:35:05 +00:00
Родитель 63ccd07876
Коммит 69a30e8901
3 изменённых файлов: 25 добавлений и 5 удалений

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

@ -371,19 +371,27 @@ net_pop3_free_state(Pop3UidlHost* host)
nsPop3Protocol::nsPop3Protocol(nsIURI* aURL)
: nsMsgProtocol(aURL, aURL),
nsMsgLineBuffer(NULL, PR_FALSE)
nsMsgLineBuffer(NULL, PR_FALSE),
m_totalBytesReceived(0),
m_bytesInMsgReceived(0),
m_totalFolderSize(0),
m_totalDownloadSize(0),
m_lineStreamBuffer(nsnull),
m_pop3ConData(nsnull)
{
SetLookingForCRLF(MSG_LINEBREAK_LEN == 2);
Initialize(aURL);
}
void nsPop3Protocol::Initialize(nsIURI * aURL)
nsresult nsPop3Protocol::Initialize(nsIURI * aURL)
{
nsresult rv = NS_OK;
m_pop3ConData = (Pop3ConData *)PR_NEWZAP(Pop3ConData);
PR_ASSERT(m_pop3ConData);
if(!m_pop3ConData)
return NS_ERROR_OUT_OF_MEMORY;
m_totalBytesReceived = 0;
m_bytesInMsgReceived = 0;
m_totalFolderSize = 0;
@ -406,12 +414,18 @@ void nsPop3Protocol::Initialize(nsIURI * aURL)
m_url = do_QueryInterface(aURL);
rv = OpenNetworkSocket(aURL);
if(NS_FAILED(rv))
return rv;
} // if we got a url...
if (!POP3LOGMODULE)
POP3LOGMODULE = PR_NewLogModule("POP3");
m_lineStreamBuffer = new nsMsgLineStreamBuffer(OUTPUT_BUFFER_SIZE, CRLF, PR_TRUE);
if(!m_lineStreamBuffer)
return NS_ERROR_OUT_OF_MEMORY;
return rv;
}
nsPop3Protocol::~nsPop3Protocol()

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

@ -245,6 +245,7 @@ public:
nsPop3Protocol(nsIURI* aURL);
virtual ~nsPop3Protocol();
nsresult Initialize(nsIURI * aURL);
virtual nsresult LoadUrl(nsIURI *aURL, nsISupports * aConsumer = nsnull);
const char* GetUsername() { return m_username.GetBuffer(); };
@ -278,7 +279,6 @@ private:
PRUint32 sourceOffset, PRUint32 length);
virtual nsresult CloseSocket();
virtual PRInt32 SendData(nsIURI * aURL, const char * dataBuffer);
void Initialize(nsIURI * aURL);
nsCOMPtr<nsIURI> m_url;
nsCOMPtr<nsIPop3Sink> m_nsIPop3Sink;

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

@ -127,7 +127,7 @@ nsresult nsPop3Service::GetNewMail(nsIUrlListener * aUrlListener,
}
if (NS_SUCCEEDED(rv) && url)
RunPopUrl(server, url);
rv = RunPopUrl(server, url);
if (popHost) PL_strfree(popHost);
@ -223,6 +223,12 @@ nsresult nsPop3Service::RunPopUrl(nsIMsgIncomingServer * aServer, nsIURI * aUrlT
nsPop3Protocol * protocol = new nsPop3Protocol(aUrlToRun);
if (protocol)
{
rv = protocol->Initialize(aUrlToRun);
if(NS_FAILED(rv))
{
delete protocol;
return rv;
}
protocol->SetUsername(userName);
rv = protocol->LoadUrl(aUrlToRun);
}