part of mailnews audit --> use nsCOMPtr.

part of mailnews audit --> Conversion to NS_WITH_SERVICE
This commit is contained in:
mscott%netscape.com 1999-05-04 20:33:07 +00:00
parent aec350f68e
commit 9fd7908941

View File

@ -17,6 +17,7 @@
*/ */
#include "msgCore.h" #include "msgCore.h"
#include "nsCOMPtr.h"
#include "prprf.h" #include "prprf.h"
#include <stdio.h> #include <stdio.h>
@ -169,10 +170,11 @@ protected:
PRBool m_runningURL; PRBool m_runningURL;
PRBool m_runTestHarness; PRBool m_runTestHarness;
nsINetService * m_netService; nsCOMPtr<nsINetService> m_netService;
nsISmtpService * m_smtpService; nsISmtpService *m_smtpService;
nsISmtpUrl * m_smtpUrl; nsCOMPtr<nsISmtpUrl> m_smtpUrl;
nsresult SetupUrl(char *group);
nsresult SetupUrl(char *group);
PRBool m_protocolInitialized; PRBool m_protocolInitialized;
}; };
@ -191,13 +193,9 @@ nsresult nsSmtpTestDriver::OnStopRunningUrl(nsIURL * aUrl, nsresult aExitCode)
if (aUrl) if (aUrl)
{ {
// query it for a mailnews interface for now.... // query it for a mailnews interface for now....
nsIMsgMailNewsUrl * mailUrl = nsnull; nsCOMPtr<nsIMsgMailNewsUrl> mailUrl = do_QueryInterface(aUrl);
rv = aUrl->QueryInterface(nsIMsgMailNewsUrl::GetIID(), (void **) &mailUrl); if (mailUrl)
if (NS_SUCCEEDED(rv))
{
mailUrl->UnRegisterListener(this); mailUrl->UnRegisterListener(this);
NS_RELEASE(mailUrl);
}
} }
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@ -221,9 +219,7 @@ nsSmtpTestDriver::nsSmtpTestDriver(nsINetService * pNetService,
m_runningURL = PR_FALSE; m_runningURL = PR_FALSE;
m_runTestHarness = PR_TRUE; m_runTestHarness = PR_TRUE;
m_eventQueue = queue; m_eventQueue = queue;
m_netService = pNetService; m_netService = dont_QueryInterface(pNetService);
m_smtpUrl = nsnull;
NS_IF_ADDREF(m_netService);
InitializeTestDriver(); // prompts user for initialization information... InitializeTestDriver(); // prompts user for initialization information...
@ -235,7 +231,6 @@ nsSmtpTestDriver::nsSmtpTestDriver(nsINetService * pNetService,
nsSmtpTestDriver::~nsSmtpTestDriver() nsSmtpTestDriver::~nsSmtpTestDriver()
{ {
NS_IF_RELEASE(m_netService);
nsServiceManager::ReleaseService(kSmtpServiceCID, m_smtpService); // XXX probably need shutdown listener here nsServiceManager::ReleaseService(kSmtpServiceCID, m_smtpService); // XXX probably need shutdown listener here
} }
@ -248,11 +243,7 @@ nsresult nsSmtpTestDriver::RunDriver()
while (m_runTestHarness) while (m_runTestHarness)
{ {
if (m_runningURL == PR_FALSE) // can we run and dispatch another command? if (m_runningURL == PR_FALSE) // can we run and dispatch another command?
{
NS_IF_RELEASE(m_smtpUrl); // release our old url..
m_smtpUrl = nsnull;
status = ReadAndDispatchCommand(); // run a new url status = ReadAndDispatchCommand(); // run a new url
}
// if running url // if running url
#ifdef XP_UNIX #ifdef XP_UNIX
@ -417,7 +408,8 @@ nsresult nsSmtpTestDriver::OnSendMessageInFile()
nsIURL * url = nsnull; nsIURL * url = nsnull;
m_smtpService->SendMailMessage(filePath, recipients, this, &url); m_smtpService->SendMailMessage(filePath, recipients, this, &url);
if (url) if (url)
url->QueryInterface(nsISmtpUrl::GetIID(), (void **) &m_smtpUrl); m_smtpUrl = do_QueryInterface(url);
NS_IF_RELEASE(url); NS_IF_RELEASE(url);
@ -452,10 +444,8 @@ int main()
} }
// Create the Event Queue for this thread... // Create the Event Queue for this thread...
nsIEventQueueService* pEventQService; NS_WITH_SERVICE(nsIEventQueueService, pEventQService, kEventQueueServiceCID, &result);
result = nsServiceManager::GetService(kEventQueueServiceCID,
nsIEventQueueService::GetIID(),
(nsISupports**)&pEventQService);
if (NS_FAILED(result)) return result; if (NS_FAILED(result)) return result;
result = pEventQService->CreateThreadEventQueue(); result = pEventQService->CreateThreadEventQueue();