зеркало из https://github.com/mozilla/pjs.git
first part of fix for #28898 - switch SMTP server API to store the key not the server itself, for easier access from the account manager
r=sspitzer
This commit is contained in:
Родитель
71b0d461d0
Коммит
a3868c3b8b
|
@ -234,8 +234,10 @@ function PageDataToAccountData(pageData, accountData)
|
|||
server.rememberPassword = pageData.login.rememberPassword.value;
|
||||
}
|
||||
|
||||
dump("pageData.server = " + pageData.server + "\n");
|
||||
if (pageData.server) {
|
||||
if (pageData.server.smtphostname)
|
||||
dump("pageData.server.smtphostname.value = " + pageData.server.smtphostname + "\n");
|
||||
if (pageData.server.smtphostname.value)
|
||||
smtp.hostname = pageData.server.smtphostname.value;
|
||||
}
|
||||
}
|
||||
|
@ -304,12 +306,13 @@ function finishAccount(account, accountData) {
|
|||
|
||||
if (accountData.smtpCreateNewServer)
|
||||
smtpServer = smtpService.createSmtpServer();
|
||||
|
||||
|
||||
dump("Copying smtpServer (" + smtpServer + ") to accountData\n");
|
||||
copyObjectToInterface(smtpServer, accountData.smtp);
|
||||
|
||||
// some identities have 'preferred'
|
||||
if (accountData.smtpUsePreferredServer && destIdentity)
|
||||
destIdentity.smtpServer = smtpServer;
|
||||
destIdentity.smtpServerKey = smtpServer.key;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -25,8 +25,6 @@
|
|||
#include "nsIFileSpec.idl"
|
||||
#include "nsIMsgVCard.idl"
|
||||
|
||||
interface nsISmtpServer;
|
||||
|
||||
/*
|
||||
* this interface contains all the personal outgoing mail information
|
||||
* for a given person.
|
||||
|
@ -107,7 +105,7 @@ interface nsIMsgIdentity : nsISupports {
|
|||
* if this is set, this the smtp server that should be used
|
||||
* for the message send
|
||||
*/
|
||||
attribute nsISmtpServer smtpServer;
|
||||
attribute string smtpServerKey;
|
||||
|
||||
/* copy the attributes of the identity we pass in */
|
||||
void copy(in nsIMsgIdentity identity);
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include "nsIPref.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
#include "nsISmtpService.h"
|
||||
#include "nsMsgCompCID.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIRDFResource.h"
|
||||
|
@ -402,63 +401,12 @@ nsMsgIdentity::clearPrefEnum(const char *aPref, void *aClosure)
|
|||
prefs->ClearUserPref(aPref);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgIdentity::GetSmtpServer(nsISmtpServer **aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsISmtpServer> smtpServer =
|
||||
do_QueryReferent(m_smtpServer, &rv);
|
||||
|
||||
// try to load, but ignore the error and return null if nothing
|
||||
if (!smtpServer)
|
||||
loadSmtpServer(getter_AddRefs(smtpServer));
|
||||
|
||||
*aResult = smtpServer;
|
||||
NS_IF_ADDREF(*aResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgIdentity::loadSmtpServer(nsISmtpServer** aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsXPIDLCString smtpServerKey;
|
||||
rv = getCharPref("smtpServer", getter_Copies(smtpServerKey));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsISmtpService> smtpService =
|
||||
do_GetService(NS_SMTPSERVICE_PROGID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return smtpService->GetServerByKey(smtpServerKey, aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgIdentity::SetSmtpServer(nsISmtpServer *aServer)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
m_smtpServer = getter_AddRefs(NS_GetWeakReference(aServer, &rv));
|
||||
|
||||
if (aServer) {
|
||||
nsXPIDLCString smtpServerKey;
|
||||
rv = aServer->GetKey(getter_Copies(smtpServerKey));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
setCharPref("smtpServer", smtpServerKey);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_GETSET(nsMsgIdentity, VCard, nsIMsgVCard*, m_vCard);
|
||||
|
||||
NS_IMPL_GETTER_STR(nsMsgIdentity::GetKey, m_identityKey);
|
||||
|
||||
NS_IMPL_IDPREF_STR(SmtpServerKey, "smtpServer");
|
||||
NS_IMPL_IDPREF_WSTR(FullName, "fullName");
|
||||
NS_IMPL_IDPREF_STR(Email, "useremail");
|
||||
NS_IMPL_IDPREF_STR(ReplyTo, "reply_to");
|
||||
|
|
|
@ -101,8 +101,13 @@ nsresult nsSmtpService::SendMailMessage(nsIFileSpec * aFilePath,
|
|||
nsCOMPtr<nsISmtpServer> smtpServer;
|
||||
|
||||
// first try the identity's preferred server
|
||||
if (aSenderIdentity)
|
||||
rv = aSenderIdentity->GetSmtpServer(getter_AddRefs(smtpServer));
|
||||
if (aSenderIdentity) {
|
||||
nsXPIDLCString smtpServerKey;
|
||||
rv = aSenderIdentity->GetSmtpServerKey(getter_Copies(smtpServerKey));
|
||||
if (NS_SUCCEEDED(rv) && (const char *)smtpServerKey)
|
||||
rv = smtpService->GetServerByKey(smtpServerKey,
|
||||
getter_AddRefs(smtpServer));
|
||||
}
|
||||
|
||||
// fallback to the default
|
||||
if (NS_FAILED(rv) || !smtpServer)
|
||||
|
|
Загрузка…
Ссылка в новой задаче