зеркало из https://github.com/mozilla/pjs.git
part of mailnews audit --> use nsCOMPtr.
This commit is contained in:
Родитель
0e649a0395
Коммит
1f8ba398ee
|
@ -245,7 +245,7 @@ nsresult nsMailboxService::DisplayMessageNumber(const char *url,
|
|||
nsMsgKeyArray msgKeys;
|
||||
nsresult rv = NS_OK;
|
||||
// extract the message key for this message number and turn around and call the other displayMessage method on it...
|
||||
nsIMsgDatabase * mailDB = nsnull;
|
||||
nsCOMPtr<nsIMsgDatabase> mailDB;
|
||||
nsCOMPtr<nsIMsgDatabase> mailDBFactory;
|
||||
|
||||
rv = nsComponentManager::CreateInstance(kCMailDB,
|
||||
|
@ -256,7 +256,7 @@ nsresult nsMailboxService::DisplayMessageNumber(const char *url,
|
|||
// ALECF: convert uri->mailboxPath with nsLocalURI2Path
|
||||
if (NS_SUCCEEDED(rv) && mailDBFactory)
|
||||
rv = mailDBFactory->Open((nsFileSpec&) mailboxPath, PR_FALSE,
|
||||
(nsIMsgDatabase **) mailDB, PR_FALSE);
|
||||
(nsIMsgDatabase **) getter_AddRefs(mailDB), PR_FALSE);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && mailDB)
|
||||
{
|
||||
|
@ -280,8 +280,8 @@ nsresult nsMailboxService::DisplayMessageNumber(const char *url,
|
|||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (mailDB) // in case we slipped through the cracks without releasing the db...
|
||||
mailDB->Close(PR_TRUE); // does close implicitly release the db?
|
||||
if (mailDB)
|
||||
mailDB->Close(PR_TRUE);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
#include "nsPop3Sink.h"
|
||||
#include "nsPop3Protocol.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
nsPop3Service::nsPop3Service()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
@ -52,24 +54,23 @@ nsPop3Service::CheckForNewMail(nsIUrlListener * aUrlListener,
|
|||
char * popPassword = nsnull;
|
||||
char * hostname = nsnull;
|
||||
|
||||
nsIMsgIncomingServer *server = nsnull;
|
||||
nsIPop3URL * pop3Url = nsnull;
|
||||
nsCOMPtr<nsIMsgIncomingServer> server;
|
||||
nsCOMPtr<nsIPop3URL> pop3Url;
|
||||
|
||||
rv = popServer->QueryInterface(nsIMsgIncomingServer::GetIID(),
|
||||
(void **)&server);
|
||||
if (NS_SUCCEEDED(rv) && server) {
|
||||
server = do_QueryInterface(popServer);
|
||||
if (server)
|
||||
{
|
||||
// load up required server information
|
||||
server->GetUserName(&userName);
|
||||
server->GetPassword(&popPassword);
|
||||
server->GetHostName(&hostname);
|
||||
NS_RELEASE(server);
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv) && popServer)
|
||||
{
|
||||
// now construct a pop3 url...
|
||||
char * urlSpec = PR_smprintf("pop3://%s?check", hostname);
|
||||
rv = BuildPop3Url(urlSpec, popServer, &pop3Url);
|
||||
rv = BuildPop3Url(urlSpec, popServer, getter_AddRefs(pop3Url));
|
||||
PR_FREEIF(urlSpec);
|
||||
}
|
||||
|
||||
|
@ -89,9 +90,10 @@ nsPop3Service::CheckForNewMail(nsIUrlListener * aUrlListener,
|
|||
}
|
||||
|
||||
if (aURL && pop3Url) // we already have a ref count on pop3url...
|
||||
{
|
||||
*aURL = pop3Url; // transfer ref count to the caller...
|
||||
else
|
||||
NS_IF_RELEASE(pop3Url); // release our ref...
|
||||
NS_IF_ADDREF(*aURL);
|
||||
}
|
||||
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return rv;
|
||||
|
@ -107,19 +109,19 @@ nsresult nsPop3Service::GetNewMail(nsIUrlListener * aUrlListener,
|
|||
char * popPassword = nsnull;
|
||||
char * popHost = nsnull;
|
||||
|
||||
nsIMsgIncomingServer * server = nsnull;
|
||||
nsIPop3URL * pop3Url = nsnull;
|
||||
nsCOMPtr<nsIMsgIncomingServer> server;
|
||||
nsCOMPtr<nsIPop3URL> pop3Url;
|
||||
|
||||
rv = popServer->QueryInterface(nsIMsgIncomingServer::GetIID(),
|
||||
(void **)&server);
|
||||
// convert normal host to POP host.
|
||||
server = do_QueryInterface(popServer);
|
||||
|
||||
// convert normal host to POP host.
|
||||
// XXX - this doesn't handle QI failing very well
|
||||
if (NS_SUCCEEDED(rv) && server) {
|
||||
if (server)
|
||||
{
|
||||
// load up required server information
|
||||
server->GetUserName(&userName);
|
||||
server->GetPassword(&popPassword);
|
||||
server->GetHostName(&popHost);
|
||||
NS_IF_RELEASE(server);
|
||||
}
|
||||
|
||||
|
||||
|
@ -127,7 +129,7 @@ nsresult nsPop3Service::GetNewMail(nsIUrlListener * aUrlListener,
|
|||
{
|
||||
// now construct a pop3 url...
|
||||
char * urlSpec = PR_smprintf("pop3://%s", popHost);
|
||||
rv = BuildPop3Url(urlSpec, popServer, &pop3Url);
|
||||
rv = BuildPop3Url(urlSpec, popServer, getter_AddRefs(pop3Url));
|
||||
PR_FREEIF(urlSpec);
|
||||
}
|
||||
|
||||
|
@ -147,9 +149,10 @@ nsresult nsPop3Service::GetNewMail(nsIUrlListener * aUrlListener,
|
|||
}
|
||||
|
||||
if (aURL && pop3Url) // we already have a ref count on pop3url...
|
||||
{
|
||||
*aURL = pop3Url; // transfer ref count to the caller...
|
||||
else
|
||||
NS_IF_RELEASE(pop3Url); // release our ref...
|
||||
NS_IF_ADDREF(*aURL);
|
||||
}
|
||||
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return rv;
|
||||
|
@ -176,8 +179,7 @@ nsresult nsPop3Service::BuildPop3Url(const char * urlSpec,
|
|||
if (aUrl)
|
||||
rv = pop3Url->QueryInterface(nsIPop3URL::GetIID(), (void **) aUrl);
|
||||
else // hmmm delete is protected...what can we do here? no one has a ref cnt on the object...
|
||||
NS_IF_RELEASE(pop3Url);
|
||||
// delete pop3Url;
|
||||
NS_IF_RELEASE(pop3Url);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -44,7 +44,6 @@ nsPop3URL::nsPop3URL(nsISupports* aContainer, nsIURLGroup* aGroup)
|
|||
NS_INIT_REFCNT();
|
||||
|
||||
// nsIPop3URL specific code...
|
||||
m_pop3Sink = nsnull;
|
||||
m_errorMessage = nsnull;
|
||||
|
||||
// nsINetLibUrl specific state
|
||||
|
@ -62,7 +61,7 @@ nsPop3URL::nsPop3URL(nsISupports* aContainer, nsIURLGroup* aGroup)
|
|||
m_runningUrl = PR_FALSE;
|
||||
|
||||
nsComponentManager::CreateInstance(kUrlListenerManagerCID, nsnull, nsIUrlListenerManager::GetIID(),
|
||||
(void **) &m_urlListeners);
|
||||
(void **) getter_AddRefs(m_urlListeners));
|
||||
|
||||
m_container = aContainer;
|
||||
NS_IF_ADDREF(m_container);
|
||||
|
@ -71,7 +70,6 @@ nsPop3URL::nsPop3URL(nsISupports* aContainer, nsIURLGroup* aGroup)
|
|||
nsPop3URL::~nsPop3URL()
|
||||
{
|
||||
NS_IF_RELEASE(m_container);
|
||||
NS_IF_RELEASE(m_urlListeners);
|
||||
PR_FREEIF(m_errorMessage);
|
||||
|
||||
PR_FREEIF(m_spec);
|
||||
|
@ -80,10 +78,6 @@ nsPop3URL::~nsPop3URL()
|
|||
PR_FREEIF(m_file);
|
||||
PR_FREEIF(m_ref);
|
||||
PR_FREEIF(m_search);
|
||||
if (nsnull != m_URL_s)
|
||||
{
|
||||
// NET_DropURLStruct(m_URL_s);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_THREADSAFE_ADDREF(nsPop3URL);
|
||||
|
@ -133,11 +127,7 @@ nsresult nsPop3URL::SetPop3Sink(nsIPop3Sink* aPop3Sink)
|
|||
{
|
||||
NS_LOCK_INSTANCE();
|
||||
if (aPop3Sink)
|
||||
{
|
||||
NS_IF_RELEASE(m_pop3Sink);
|
||||
m_pop3Sink = aPop3Sink;
|
||||
NS_ADDREF(m_pop3Sink);
|
||||
}
|
||||
m_pop3Sink = dont_QueryInterface(aPop3Sink);
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -146,10 +136,10 @@ nsresult nsPop3URL::GetPop3Sink(nsIPop3Sink** aPop3Sink) const
|
|||
{
|
||||
NS_LOCK_INSTANCE();
|
||||
if (aPop3Sink)
|
||||
{
|
||||
{
|
||||
*aPop3Sink = m_pop3Sink;
|
||||
NS_IF_ADDREF(m_pop3Sink);
|
||||
}
|
||||
NS_IF_ADDREF(*aPop3Sink);
|
||||
}
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "nsIPop3URL.h"
|
||||
#include "nsIUrlListenerManager.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsINetlibURL.h" /* this should be temporary until Network N2 project lands */
|
||||
|
||||
class nsPop3URL : public nsIPop3URL, public nsINetlibURL
|
||||
|
@ -105,10 +106,10 @@ protected:
|
|||
PRBool m_runningUrl;
|
||||
|
||||
// manager of all of current url listeners....
|
||||
nsIUrlListenerManager * m_urlListeners;
|
||||
nsCOMPtr<nsIUrlListenerManager> m_urlListeners;
|
||||
|
||||
/* Pop3 specific event sinks */
|
||||
nsIPop3Sink* m_pop3Sink;
|
||||
nsCOMPtr<nsIPop3Sink> m_pop3Sink;
|
||||
|
||||
void ReconstructSpec(void);
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче