зеркало из https://github.com/mozilla/gecko-dev.git
Sending a message no longer requires a host and from field because we can now extract that information from the current identity.
This commit is contained in:
Родитель
99c7af8413
Коммит
7acaee2865
|
@ -60,7 +60,7 @@ public:
|
|||
// If you don't care about listening to the url, feel free to pass in nsnull for that argument.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
NS_IMETHOD SendMailMessage(const nsFilePath& aFilePath, const nsString& hostName, const nsString& aSender, const nsString& aRecipients,
|
||||
NS_IMETHOD SendMailMessage(const nsFilePath& aFilePath, const nsString& aRecipients,
|
||||
nsIUrlListener * aUrlListener, nsIURL ** aURL) = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -4886,10 +4886,7 @@ void nsMsgSendMimeDeliveryState::DeliverFileAsMail ()
|
|||
nsresult rv = nsServiceManager::GetService(kSmtpServiceCID, nsISmtpService::GetIID(), (nsISupports **)&smtpService);
|
||||
if (NS_SUCCEEDED(rv) && smtpService)
|
||||
{
|
||||
if (pSmtpServer)
|
||||
rv = smtpService->SendMailMessage(filePath, pSmtpServer, m_fields->GetFrom(), buf, nsnull, nsnull);
|
||||
else
|
||||
rv = smtpService->SendMailMessage(filePath, "", m_fields->GetFrom(), buf, nsnull, nsnull);
|
||||
rv = smtpService->SendMailMessage(filePath, buf, nsnull, nsnull);
|
||||
nsServiceManager::ReleaseService(kSmtpServiceCID, smtpService);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
#include "nsINetService.h"
|
||||
#include "nsSmtpService.h"
|
||||
#include "nsIMsgMailSession.h"
|
||||
#include "nsIMsgIdentity.h"
|
||||
|
||||
#include "nsSmtpUrl.h"
|
||||
#include "nsSmtpProtocol.h"
|
||||
|
@ -44,23 +46,51 @@ nsSmtpService::~nsSmtpService()
|
|||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS(nsSmtpService, nsISmtpService::GetIID());
|
||||
|
||||
nsresult nsSmtpService::SendMailMessage(const nsFilePath& aFilePath, const nsString& aHostName, const nsString& aSender,
|
||||
const nsString& aRecipients, nsIUrlListener * aUrlListener, nsIURL ** aURL)
|
||||
|
||||
static NS_DEFINE_CID(kCMsgMailSessionCID, NS_MSGMAILSESSION_CID);
|
||||
|
||||
nsresult nsSmtpService::SendMailMessage(const nsFilePath& aFilePath, const nsString& aRecipients,
|
||||
nsIUrlListener * aUrlListener, nsIURL ** aURL)
|
||||
{
|
||||
nsIURL * urlToRun = nsnull;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
NS_LOCK_INSTANCE();
|
||||
rv = NS_MsgBuildMailtoUrl(aFilePath, aHostName, aSender, aRecipients, aUrlListener, &urlToRun); // this ref counts urlToRun
|
||||
if (NS_SUCCEEDED(rv) && urlToRun)
|
||||
{
|
||||
rv = NS_MsgLoadMailtoUrl(urlToRun, nsnull);
|
||||
}
|
||||
// get the current identity from the mail session....
|
||||
nsIMsgMailSession * mailSession = nsnull;
|
||||
rv = nsServiceManager::GetService(kCMsgMailSessionCID,
|
||||
nsIMsgMailSession::GetIID(),
|
||||
(nsISupports **) &mailSession);
|
||||
if (NS_SUCCEEDED(rv) && mailSession)
|
||||
{
|
||||
nsIMsgIdentity * identity = nsnull;
|
||||
rv = mailSession->GetCurrentIdentity(&identity);
|
||||
// now release the mail service because we are done with it
|
||||
nsServiceManager::ReleaseService(kCMsgMailSessionCID, mailSession);
|
||||
if (NS_SUCCEEDED(rv) && identity)
|
||||
{
|
||||
const char * hostName = nsnull;
|
||||
const char * senderName = nsnull;
|
||||
|
||||
if (aURL) // does the caller want a handle on the url?
|
||||
*aURL = urlToRun; // transfer our ref count to the caller....
|
||||
else
|
||||
NS_IF_RELEASE(urlToRun);
|
||||
identity->GetSmtpServer(&hostName);
|
||||
identity->GetUserName(&senderName);
|
||||
rv = NS_MsgBuildMailtoUrl(aFilePath, hostName, senderName, aRecipients, aUrlListener, &urlToRun); // this ref counts urlToRun
|
||||
if (NS_SUCCEEDED(rv) && urlToRun)
|
||||
{
|
||||
rv = NS_MsgLoadMailtoUrl(urlToRun, nsnull);
|
||||
}
|
||||
|
||||
if (aURL) // does the caller want a handle on the url?
|
||||
*aURL = urlToRun; // transfer our ref count to the caller....
|
||||
else
|
||||
NS_IF_RELEASE(urlToRun);
|
||||
|
||||
// release the identity
|
||||
NS_IF_RELEASE(identity);
|
||||
} // if we have an identity
|
||||
else
|
||||
NS_ASSERTION(0, "no current identity found for this user....");
|
||||
} // if we had a mail session
|
||||
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return rv;
|
||||
|
|
|
@ -50,8 +50,8 @@ public:
|
|||
// the returned URL.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
NS_IMETHOD SendMailMessage(const nsFilePath& aFilePath, const nsString& aHostName, const nsString& aSender,
|
||||
const nsString& aRecipients, nsIUrlListener * aUrlListener, nsIURL ** aURL);
|
||||
NS_IMETHOD SendMailMessage(const nsFilePath& aFilePath, const nsString& aRecipients, nsIUrlListener * aUrlListener,
|
||||
nsIURL ** aURL);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
// End support of nsISmtpService interface
|
||||
|
|
|
@ -392,20 +392,12 @@ nsresult nsSmtpTestDriver::OnSendMessageInFile()
|
|||
|
||||
recipients = PL_strdup(m_userData);
|
||||
|
||||
// now ask the user what their address is...
|
||||
PL_strcpy(m_userData, DEFAULT_SENDER);
|
||||
displayString = PR_smprintf("Email address of sender [%s]: ", m_userData);
|
||||
rv = PromptForUserDataAndBuildUrl(displayString);
|
||||
PR_FREEIF(displayString);
|
||||
|
||||
userName = PL_strdup(m_userData);
|
||||
|
||||
// SMTP is a connectionless protocol...so we always start with a new
|
||||
// SMTP protocol instance every time we launch a mailto url...
|
||||
|
||||
nsFilePath filePath (fileName);
|
||||
nsIURL * url = nsnull;
|
||||
m_smtpService->SendMailMessage(filePath, m_host, userName, recipients, this, &url);
|
||||
m_smtpService->SendMailMessage(filePath, recipients, this, &url);
|
||||
if (url)
|
||||
url->QueryInterface(nsISmtpUrl::GetIID(), (void **) &m_smtpUrl);
|
||||
NS_IF_RELEASE(url);
|
||||
|
|
Загрузка…
Ссылка в новой задаче