зеркало из https://github.com/mozilla/pjs.git
part of mailnews audit --> Conversion to NS_WITH_SERVICE
part of mailnews audit --> use nsCOMPtr.
This commit is contained in:
Родитель
2e30d4a0f5
Коммит
ce876238b3
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "msgCore.h" // precompiled header...
|
#include "msgCore.h" // precompiled header...
|
||||||
|
#include "nsCOMPtr.h"
|
||||||
|
|
||||||
#ifdef XP_PC
|
#ifdef XP_PC
|
||||||
#include <windows.h> // for InterlockedIncrement
|
#include <windows.h> // for InterlockedIncrement
|
||||||
|
@ -56,16 +57,12 @@ nsresult nsSmtpService::SendMailMessage(const nsFilePath& aFilePath, const nsStr
|
||||||
|
|
||||||
NS_LOCK_INSTANCE();
|
NS_LOCK_INSTANCE();
|
||||||
// get the current identity from the mail session....
|
// get the current identity from the mail session....
|
||||||
nsIMsgMailSession * mailSession = nsnull;
|
NS_WITH_SERVICE(nsIMsgMailSession, mailSession, kCMsgMailSessionCID, &rv);
|
||||||
rv = nsServiceManager::GetService(kCMsgMailSessionCID,
|
|
||||||
nsIMsgMailSession::GetIID(),
|
|
||||||
(nsISupports **) &mailSession);
|
|
||||||
if (NS_SUCCEEDED(rv) && mailSession)
|
if (NS_SUCCEEDED(rv) && mailSession)
|
||||||
{
|
{
|
||||||
nsIMsgIdentity * identity = nsnull;
|
nsCOMPtr<nsIMsgIdentity> identity;
|
||||||
rv = mailSession->GetCurrentIdentity(&identity);
|
rv = mailSession->GetCurrentIdentity(getter_AddRefs(identity));
|
||||||
// now release the mail service because we are done with it
|
|
||||||
nsServiceManager::ReleaseService(kCMsgMailSessionCID, mailSession);
|
|
||||||
if (NS_SUCCEEDED(rv) && identity)
|
if (NS_SUCCEEDED(rv) && identity)
|
||||||
{
|
{
|
||||||
char * hostName = nsnull;
|
char * hostName = nsnull;
|
||||||
|
@ -86,9 +83,6 @@ nsresult nsSmtpService::SendMailMessage(const nsFilePath& aFilePath, const nsStr
|
||||||
*aURL = urlToRun; // transfer our ref count to the caller....
|
*aURL = urlToRun; // transfer our ref count to the caller....
|
||||||
else
|
else
|
||||||
NS_IF_RELEASE(urlToRun);
|
NS_IF_RELEASE(urlToRun);
|
||||||
|
|
||||||
// release the identity
|
|
||||||
NS_IF_RELEASE(identity);
|
|
||||||
} // if we have an identity
|
} // if we have an identity
|
||||||
else
|
else
|
||||||
NS_ASSERTION(0, "no current identity found for this user....");
|
NS_ASSERTION(0, "no current identity found for this user....");
|
||||||
|
@ -145,7 +139,7 @@ nsresult NS_MsgLoadMailtoUrl(nsIURL * aUrl, nsISupports * aConsumer)
|
||||||
// for our mail news demo....
|
// for our mail news demo....
|
||||||
|
|
||||||
// for now, assume the url is a news url and load it....
|
// for now, assume the url is a news url and load it....
|
||||||
nsISmtpUrl *smtpUrl = nsnull;
|
nsCOMPtr <nsISmtpUrl> smtpUrl;
|
||||||
nsSmtpProtocol *smtpProtocol = nsnull;
|
nsSmtpProtocol *smtpProtocol = nsnull;
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
|
|
||||||
|
@ -153,22 +147,20 @@ nsresult NS_MsgLoadMailtoUrl(nsIURL * aUrl, nsISupports * aConsumer)
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
// turn the url into an smtp url...
|
// turn the url into an smtp url...
|
||||||
rv = aUrl->QueryInterface(nsISmtpUrl::GetIID(), (void **) &smtpUrl);
|
smtpUrl = do_QueryInterface(aUrl);
|
||||||
if (NS_SUCCEEDED(rv) && smtpUrl)
|
if (smtpUrl)
|
||||||
{
|
{
|
||||||
const nsFilePath * fileName = nsnull;
|
const nsFilePath * fileName = nsnull;
|
||||||
smtpUrl->GetPostMessageFile(&fileName);
|
smtpUrl->GetPostMessageFile(&fileName);
|
||||||
|
|
||||||
// almost there...now create a nntp protocol instance to run the url in...
|
// almost there...now create a nntp protocol instance to run the url in...
|
||||||
smtpProtocol = new nsSmtpProtocol(smtpUrl);
|
smtpProtocol = new nsSmtpProtocol(smtpUrl);
|
||||||
if (smtpProtocol == nsnull)
|
if (smtpProtocol == nsnull)
|
||||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||||
else
|
else
|
||||||
smtpProtocol->LoadURL(smtpUrl); // protocol will get destroyed when url is completed...
|
smtpProtocol->LoadURL(smtpUrl); // protocol will get destroyed when url is completed...
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IF_RELEASE(smtpUrl);
|
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче