mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-10 17:24:29 +00:00
#17956 is reply fails if message in local mail folder fix (by ducarroz) is to remove the temporary code. #18084 is sending email fails in certain cases the problem is we were sending the wrong info to the SMTP server. when we sent "MAIL FROM: <address>" to the SMTP server we sent the smtp username and not the full name built from the identity. most of the changes are to support passing the identity around. I also added code so that the smtp username is used on the mailto url spec. we'll need that later, when we support multiple smtp servers and ESMTP. r=alecf a=chofmann
This commit is contained in:
parent
72a56bb476
commit
b79f0bc070
@ -68,8 +68,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsSmtpUrl);
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
static PRInt32 g_InstanceCount = 0;
|
||||
static PRInt32 g_LockCount = 0;
|
||||
|
||||
static nsModuleComponentInfo components[] =
|
||||
{
|
||||
|
@ -82,7 +82,6 @@ interface nsIMsgCompose : nsISupports {
|
||||
void Initialize(in nsIDOMWindow aWindow, in wstring originalMsgURI,
|
||||
in MSG_ComposeType type, in MSG_ComposeFormat format,
|
||||
in nsIMsgCompFields compFields,
|
||||
in nsISupports object, /*object is temporary*/
|
||||
in nsIMsgIdentity identity);
|
||||
|
||||
/* ... */
|
||||
|
@ -35,8 +35,7 @@ interface nsIMsgComposeService : nsISupports {
|
||||
|
||||
/* ... */
|
||||
void OpenComposeWindow(in wstring msgComposeWindowURL, in wstring originalMsgURI, in MSG_ComposeType type, in MSG_ComposeFormat format,
|
||||
in nsISupports object,
|
||||
in nsIMsgIdentity identity); /*object is temporary*/
|
||||
in nsIMsgIdentity identity);
|
||||
|
||||
/* ... */
|
||||
void OpenComposeWindowWithValues(in wstring msgComposeWindowURL, in MSG_ComposeFormat format,
|
||||
|
@ -27,6 +27,7 @@ interface nsISmtpServer;
|
||||
interface nsIURI;
|
||||
interface nsIUrlListener;
|
||||
interface nsISupportsArray;
|
||||
interface nsIMsgIdentity;
|
||||
|
||||
[scriptable, uuid(FBAF0F10-CA9B-11d2-8063-006008128C4E)]
|
||||
interface nsISmtpService : nsISupports {
|
||||
@ -49,7 +50,7 @@ interface nsISmtpService : nsISupports {
|
||||
// default server
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void SendMailMessage(in nsIFileSpec aFilePath, in string aRecipients,
|
||||
void SendMailMessage(in nsIFileSpec aFilePath, in string aRecipients, in nsIMsgIdentity aSenderIdentity,
|
||||
in nsIUrlListener aUrlListener, in nsISmtpServer aServer,
|
||||
out nsIURI aURL);
|
||||
|
||||
|
@ -28,6 +28,8 @@
|
||||
#define SMTP_PORT 25
|
||||
%}
|
||||
|
||||
interface nsIMsgIdentity;
|
||||
|
||||
[scriptable, uuid(16ADF2F1-BBAD-11d2-804E-006008128C4E)]
|
||||
interface nsISmtpUrl : nsISupports {
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -64,12 +66,10 @@ interface nsISmtpUrl : nsISupports {
|
||||
// you need to call this function if you want to force the message to be posted
|
||||
// to the mailserver...
|
||||
|
||||
// mscott -- when we have identities it would be nice to just have an identity
|
||||
// interface here that would encapsulte things like username, domain, password,
|
||||
// etc...
|
||||
|
||||
// mscott - I found getting the user email address very cumbersome to use with an nsString -->
|
||||
// particularly when it came to parsing the user name and extracting the domain.....so I'm going to
|
||||
// change the get value to a const char **...
|
||||
attribute string UserEmailAddress;
|
||||
};
|
||||
// the user's full name and user's email address are encapsulated in the senderIdentity.
|
||||
// (the user's domain name can be glopped from the user's email address)
|
||||
//
|
||||
// NOTE: the SMTP username and SMTP server are in the mailto url
|
||||
// mailto://sspitzer@tintin/...
|
||||
attribute nsIMsgIdentity senderIdentity;
|
||||
};
|
||||
|
@ -211,7 +211,6 @@ nsresult nsMsgCompose::Initialize(nsIDOMWindow *aWindow,
|
||||
MSG_ComposeType type,
|
||||
MSG_ComposeFormat format,
|
||||
nsIMsgCompFields *compFields,
|
||||
nsISupports *object,
|
||||
nsIMsgIdentity *identity)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
@ -251,7 +250,7 @@ nsresult nsMsgCompose::Initialize(nsIDOMWindow *aWindow,
|
||||
|
||||
}
|
||||
|
||||
CreateMessage(originalMsgURI, type, format, compFields, object); //object is temporary
|
||||
CreateMessage(originalMsgURI, type, format, compFields);
|
||||
|
||||
return rv;
|
||||
}
|
||||
@ -632,8 +631,7 @@ nsresult nsMsgCompose::GetWrapLength(PRInt32 *aWrapLength)
|
||||
nsresult nsMsgCompose::CreateMessage(const PRUnichar * originalMsgURI,
|
||||
MSG_ComposeType type,
|
||||
MSG_ComposeFormat format,
|
||||
nsIMsgCompFields * compFields,
|
||||
nsISupports * object)
|
||||
nsIMsgCompFields * compFields)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
@ -644,12 +642,9 @@ nsresult nsMsgCompose::CreateMessage(const PRUnichar * originalMsgURI,
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* At this point, we have a list of URI of original message to reply to or forward but as the BE isn't ready yet,
|
||||
we still need to use the old patch... gather the information from the object and the temp file use to display the selected message*/
|
||||
if (object)
|
||||
{
|
||||
nsCOMPtr<nsIMessage> message;
|
||||
rv = object->QueryInterface(nsIMessage::GetIID(), getter_AddRefs(message));
|
||||
/* In case of forwarding multiple messages, originalMsgURI will contains several URI separated by a comma. */
|
||||
/* TODO: Need to extract only first URI, just in case...*/
|
||||
nsCOMPtr<nsIMessage> message = getter_AddRefs(GetIMessageFromURI(originalMsgURI));
|
||||
if ((NS_SUCCEEDED(rv)) && message)
|
||||
{
|
||||
nsString aString = "";
|
||||
@ -747,7 +742,6 @@ nsresult nsMsgCompose::CreateMessage(const PRUnichar * originalMsgURI,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ class nsMsgCompose : public nsIMsgCompose
|
||||
|
||||
private:
|
||||
nsresult _SendMsg(MSG_DeliverMode deliverMode, nsIMsgIdentity *identity, const PRUnichar *callback);
|
||||
nsresult CreateMessage(const PRUnichar * originalMsgURI, MSG_ComposeType type, MSG_ComposeFormat format, nsIMsgCompFields* compFields, nsISupports* object);
|
||||
nsresult CreateMessage(const PRUnichar * originalMsgURI, MSG_ComposeType type, MSG_ComposeFormat format, nsIMsgCompFields* compFields);
|
||||
void CleanUpRecipients(nsString& recipients);
|
||||
|
||||
nsMsgComposeSendListener *m_sendListener;
|
||||
|
@ -40,15 +40,6 @@ nsMsgComposeService::nsMsgComposeService()
|
||||
|
||||
NS_INIT_REFCNT();
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(m_msgQueue));
|
||||
|
||||
/*--- temporary hack ---*/
|
||||
int i;
|
||||
for (i = 0; i < 16; i ++)
|
||||
{
|
||||
hack_uri[i] = "";
|
||||
hack_object[i] = nsnull;
|
||||
}
|
||||
/*--- temporary hack ---*/
|
||||
}
|
||||
|
||||
|
||||
@ -92,28 +83,11 @@ static nsresult openWindow( const PRUnichar *chrome, const PRUnichar *args ) {
|
||||
NS_IMPL_ISUPPORTS(nsMsgComposeService, nsCOMTypeInfo<nsMsgComposeService>::GetIID());
|
||||
|
||||
nsresult nsMsgComposeService::OpenComposeWindow(const PRUnichar *msgComposeWindowURL, const PRUnichar *originalMsgURI,
|
||||
MSG_ComposeType type, MSG_ComposeFormat format, nsISupports *object,
|
||||
nsIMsgIdentity * identity)
|
||||
MSG_ComposeType type, MSG_ComposeFormat format, nsIMsgIdentity * identity)
|
||||
{
|
||||
nsAutoString args = "";
|
||||
nsresult rv;
|
||||
|
||||
/*--- temporary hack ---*/
|
||||
if (originalMsgURI)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 16; i ++)
|
||||
if (hack_uri[i].IsEmpty())
|
||||
{
|
||||
hack_uri[i] = originalMsgURI;
|
||||
hack_object[i] = object;
|
||||
if (hack_object[i])
|
||||
NS_ADDREF(hack_object[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*--- temporary hack ---*/
|
||||
|
||||
args.Append("type=");
|
||||
args.Append(type);
|
||||
args.Append(",");
|
||||
@ -224,32 +198,14 @@ nsresult nsMsgComposeService::InitCompose(nsIDOMWindow *aWindow,
|
||||
(void **) &msgCompose);
|
||||
if (NS_SUCCEEDED(rv) && msgCompose)
|
||||
{
|
||||
/*--- temporary hack ---*/
|
||||
int i;
|
||||
nsISupports * object = nsnull;
|
||||
if (originalMsgURI)
|
||||
for (i = 0; i < 16; i ++)
|
||||
if (hack_uri[i] == originalMsgURI)
|
||||
{
|
||||
hack_uri[i] = "";
|
||||
object = hack_object[i];
|
||||
hack_object[i] = nsnull;
|
||||
break;
|
||||
}
|
||||
/*--- temporary hack ---*/
|
||||
|
||||
// ducarroz: I am not quiet sure than dynamic_cast is supported on all platforms/compilers!
|
||||
// ducarroz: I am not quite sure than dynamic_cast is supported on all platforms/compilers!
|
||||
// nsIMsgCompFields* compFields = dynamic_cast<nsIMsgCompFields *>((nsIMsgCompFields *)compFieldsAddr);
|
||||
nsIMsgCompFields* compFields = (nsIMsgCompFields *)compFieldsAddr;
|
||||
msgCompose->Initialize(aWindow, originalMsgURI, type, format,
|
||||
compFields, object, identity);
|
||||
compFields, identity);
|
||||
NS_IF_RELEASE(compFields);
|
||||
m_msgQueue->AppendElement(msgCompose);
|
||||
*_retval = msgCompose;
|
||||
|
||||
/*--- temporary hack ---*/
|
||||
NS_IF_RELEASE(object);
|
||||
/*--- temporary hack ---*/
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
@ -32,12 +32,8 @@ public:
|
||||
|
||||
/* this macro defines QueryInterface, AddRef and Release for this class */
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIMSGCOMPOSESERVICE
|
||||
NS_DECL_NSIMSGCOMPOSESERVICE
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsISupportsArray> m_msgQueue;
|
||||
|
||||
//tempory hack
|
||||
nsString hack_uri[16];
|
||||
nsISupports* hack_object[16];
|
||||
};
|
||||
|
@ -2577,7 +2577,7 @@ nsMsgComposeAndSend::DeliverFileAsMail()
|
||||
NS_ADDREF_THIS();
|
||||
nsCOMPtr<nsIFileSpec> aFileSpec;
|
||||
NS_NewFileSpecWithSpec(*mTempFileSpec, getter_AddRefs(aFileSpec));
|
||||
rv = smtpService->SendMailMessage(aFileSpec, buf, mMailSendListener, nsnull, nsnull);
|
||||
rv = smtpService->SendMailMessage(aFileSpec, buf, mUserIdentity, mMailSendListener, nsnull, nsnull);
|
||||
}
|
||||
|
||||
PR_FREEIF(buf); // free the buf because we are done with it....
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsString.h"
|
||||
#include "nsTextFormater.h"
|
||||
#include "nsIMsgIdentity.h"
|
||||
|
||||
#include "prtime.h"
|
||||
#include "prlog.h"
|
||||
@ -297,17 +298,25 @@ void nsSmtpProtocol::Initialize(nsIURI * aURL)
|
||||
|
||||
const char * nsSmtpProtocol::GetUserDomainName()
|
||||
{
|
||||
nsresult rv;
|
||||
NS_PRECONDITION(m_runningURL, "we must be running a url in order to get the user's domain...");
|
||||
|
||||
if (m_runningURL)
|
||||
{
|
||||
const char *atSignMarker = nsnull;
|
||||
m_runningURL->GetUserEmailAddress(getter_Copies(m_mailAddr));
|
||||
if (m_mailAddr)
|
||||
{
|
||||
atSignMarker = PL_strchr(m_mailAddr, '@');
|
||||
return atSignMarker ? atSignMarker+1 : (const char *) m_mailAddr; // return const ptr into buffer in running url...
|
||||
nsCOMPtr <nsIMsgIdentity> senderIdentity;
|
||||
rv = m_runningURL->GetSenderIdentity(getter_AddRefs(senderIdentity));
|
||||
if (NS_FAILED(rv) || !senderIdentity) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
rv = senderIdentity->GetEmail(getter_Copies(m_mailAddr));
|
||||
if (NS_FAILED(rv) || !((const char *)m_mailAddr)) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
const char *atSignMarker = nsnull;
|
||||
atSignMarker = PL_strchr(m_mailAddr, '@');
|
||||
return atSignMarker ? atSignMarker+1 : (const char *) m_mailAddr; // return const ptr into buffer in running url...
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
@ -524,18 +533,30 @@ PRInt32 nsSmtpProtocol::ExtensionLoginResponse(nsIInputStream * inputStream, PRU
|
||||
|
||||
PRInt32 nsSmtpProtocol::SendHeloResponse(nsIInputStream * inputStream, PRUint32 length)
|
||||
{
|
||||
PRInt32 status = 0;
|
||||
PRInt32 status = 0;
|
||||
nsCAutoString buffer;
|
||||
nsresult rv;
|
||||
|
||||
// extract the email addresss
|
||||
nsXPIDLCString userAddress;
|
||||
m_runningURL->GetUserEmailAddress(getter_Copies(userAddress));
|
||||
// extract the email address and fullname
|
||||
nsXPIDLCString fullName;
|
||||
nsXPIDLCString emailAddress;
|
||||
|
||||
nsCOMPtr <nsIMsgIdentity> senderIdentity;
|
||||
rv = m_runningURL->GetSenderIdentity(getter_AddRefs(senderIdentity));
|
||||
if (NS_FAILED(rv) || !senderIdentity) {
|
||||
m_urlErrorState = NS_ERROR_COULD_NOT_GET_USERS_MAIL_ADDRESS;
|
||||
return(NS_ERROR_COULD_NOT_GET_USERS_MAIL_ADDRESS);
|
||||
}
|
||||
else {
|
||||
senderIdentity->GetEmail(getter_Copies(emailAddress));
|
||||
senderIdentity->GetFullName(getter_Copies(fullName));
|
||||
}
|
||||
|
||||
/* don't check for a HELO response because it can be bogus and
|
||||
* we don't care
|
||||
*/
|
||||
|
||||
if(!userAddress)
|
||||
if(!((const char *)emailAddress))
|
||||
{
|
||||
m_urlErrorState = NS_ERROR_COULD_NOT_GET_USERS_MAIL_ADDRESS;
|
||||
return(NS_ERROR_COULD_NOT_GET_USERS_MAIL_ADDRESS);
|
||||
@ -556,9 +577,9 @@ PRInt32 nsSmtpProtocol::SendHeloResponse(nsIInputStream * inputStream, PRUint32
|
||||
nsCOMTypeInfo<nsIMsgHeaderParser>::GetIID(),
|
||||
getter_AddRefs(parser));
|
||||
|
||||
char * s = nsnull;
|
||||
char *fullAddress = nsnull;
|
||||
if (parser)
|
||||
parser->MakeFullAddress(nsnull, nsnull, userAddress, &s);
|
||||
parser->MakeFullAddress(nsnull, fullName, emailAddress, &fullAddress);
|
||||
|
||||
#ifdef UNREADY_CODE
|
||||
if (CE_URL_S->msg_pane)
|
||||
@ -568,14 +589,14 @@ PRInt32 nsSmtpProtocol::SendHeloResponse(nsIInputStream * inputStream, PRUint32
|
||||
if (TestFlag(SMTP_EHLO_DSN_ENABLED))
|
||||
{
|
||||
PR_snprintf(buffer, sizeof(buffer),
|
||||
"MAIL FROM:<%.256s> RET=FULL ENVID=NS40112696JT" CRLF, s);
|
||||
"MAIL FROM:<%.256s> RET=FULL ENVID=NS40112696JT" CRLF, fullAddress);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef UNREADY_CODE
|
||||
FE_Alert (CE_WINDOW_ID, XP_GetString(XP_RETURN_RECEIPT_NOT_SUPPORT));
|
||||
#endif
|
||||
PR_snprintf(buffer, sizeof(buffer), "MAIL FROM:<%.256s>" CRLF, s);
|
||||
PR_snprintf(buffer, sizeof(buffer), "MAIL FROM:<%.256s>" CRLF, fullAddress);
|
||||
}
|
||||
}
|
||||
#ifdef UNREADY_CODE
|
||||
@ -586,17 +607,17 @@ PRInt32 nsSmtpProtocol::SendHeloResponse(nsIInputStream * inputStream, PRUint32
|
||||
#endif
|
||||
else
|
||||
{
|
||||
PR_snprintf(buffer, sizeof(buffer), "MAIL FROM:<%.256s>" CRLF, s);
|
||||
PR_snprintf(buffer, sizeof(buffer), "MAIL FROM:<%.256s>" CRLF, fullAddress);
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
buffer = "MAIL FROM:<";
|
||||
buffer += s;
|
||||
buffer += fullAddress;
|
||||
buffer += ">" CRLF;
|
||||
}
|
||||
PR_FREEIF (s);
|
||||
PR_FREEIF (fullAddress);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> url = do_QueryInterface(m_runningURL);
|
||||
@ -748,6 +769,9 @@ PRInt32 nsSmtpProtocol::AuthLoginResponse(nsIInputStream * stream, PRUint32 leng
|
||||
|
||||
PRInt32 nsSmtpProtocol::AuthLoginUsername()
|
||||
{
|
||||
// NOTE from sspitzer:
|
||||
// when it comes time to implement this, get the smtp user name from
|
||||
// the m_runningURL. don't get it from prefs.
|
||||
|
||||
#ifdef UNREADY_CODE
|
||||
char buffer[512];
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "nsSmtpProtocol.h"
|
||||
#include "nsIFileSpec.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIMsgIdentity.h"
|
||||
|
||||
typedef struct _findServerByKeyEntry {
|
||||
const char *key;
|
||||
@ -50,9 +51,13 @@ static NS_DEFINE_CID(kCSmtpUrlCID, NS_SMTPURL_CID);
|
||||
|
||||
nsresult
|
||||
NS_MsgBuildMailtoUrl(nsIFileSpec * aFilePath,
|
||||
const char* aHostName, const char* aSender,
|
||||
const char * aRecipients, nsIUrlListener *,
|
||||
const char* aSmtpHostName,
|
||||
const char* aSmtpUserName,
|
||||
const char* aRecipients,
|
||||
nsIMsgIdentity * aSenderIdentity,
|
||||
nsIUrlListener * aUrlListener,
|
||||
nsIURI ** aUrl);
|
||||
|
||||
nsresult NS_MsgLoadMailtoUrl(nsIURI * aUrl, nsISupports * aConsumer);
|
||||
|
||||
nsSmtpService::nsSmtpService()
|
||||
@ -94,8 +99,9 @@ static NS_DEFINE_CID(kSmtpServiceCID, NS_SMTPSERVICE_CID);
|
||||
|
||||
nsresult nsSmtpService::SendMailMessage(nsIFileSpec * aFilePath,
|
||||
const char * aRecipients,
|
||||
nsIUrlListener * aUrlListener,
|
||||
nsISmtpServer * aServer,
|
||||
nsIMsgIdentity * aSenderIdentity,
|
||||
nsIUrlListener * aUrlListener,
|
||||
nsISmtpServer * aServer,
|
||||
nsIURI ** aURL)
|
||||
{
|
||||
nsIURI * urlToRun = nsnull;
|
||||
@ -109,15 +115,15 @@ nsresult nsSmtpService::SendMailMessage(nsIFileSpec * aFilePath,
|
||||
|
||||
if (NS_SUCCEEDED(rv) && smtpServer)
|
||||
{
|
||||
nsXPIDLCString hostName;
|
||||
nsXPIDLCString senderName;
|
||||
nsXPIDLCString smtpHostName;
|
||||
nsXPIDLCString smtpUserName;
|
||||
|
||||
smtpServer->GetHostname(getter_Copies(hostName));
|
||||
smtpServer->GetUsername(getter_Copies(senderName));
|
||||
smtpServer->GetHostname(getter_Copies(smtpHostName));
|
||||
smtpServer->GetUsername(getter_Copies(smtpUserName));
|
||||
|
||||
if ((const char*)hostName)
|
||||
if ((const char*)smtpHostName)
|
||||
{
|
||||
rv = NS_MsgBuildMailtoUrl(aFilePath, hostName, senderName, aRecipients, aUrlListener, &urlToRun); // this ref counts urlToRun
|
||||
rv = NS_MsgBuildMailtoUrl(aFilePath, smtpHostName, smtpUserName, aRecipients, aSenderIdentity, aUrlListener, &urlToRun); // this ref counts urlToRun
|
||||
if (NS_SUCCEEDED(rv) && urlToRun)
|
||||
rv = NS_MsgLoadMailtoUrl(urlToRun, nsnull);
|
||||
|
||||
@ -137,8 +143,12 @@ nsresult nsSmtpService::SendMailMessage(nsIFileSpec * aFilePath,
|
||||
|
||||
// short cut function for creating a mailto url...
|
||||
nsresult NS_MsgBuildMailtoUrl(nsIFileSpec * aFilePath,
|
||||
const char* aHostName, const char* aSender,
|
||||
const char * aRecipients, nsIUrlListener * aUrlListener, nsIURI ** aUrl)
|
||||
const char* aSmtpHostName,
|
||||
const char* aSmtpUserName,
|
||||
const char * aRecipients,
|
||||
nsIMsgIdentity * aSenderIdentity,
|
||||
nsIUrlListener * aUrlListener,
|
||||
nsIURI ** aUrl)
|
||||
{
|
||||
// mscott: this function is a convience hack until netlib actually dispatches smtp urls.
|
||||
// in addition until we have a session to get a password, host and other stuff from, we need to use default values....
|
||||
@ -151,15 +161,19 @@ nsresult NS_MsgBuildMailtoUrl(nsIFileSpec * aFilePath,
|
||||
|
||||
if (NS_SUCCEEDED(rv) && smtpUrl)
|
||||
{
|
||||
char * urlSpec= PR_smprintf("mailto://%s:%d/%s",
|
||||
(const char*)aHostName, 25, aRecipients ? aRecipients : "");
|
||||
// this is complicated because the smtp username can be null
|
||||
char * urlSpec= PR_smprintf("mailto://%s%s%s:%d/%s",
|
||||
((const char*)aSmtpUserName)?(const char*)aSmtpUserName:"",
|
||||
((const char*)aSmtpUserName)?"@":"",
|
||||
(const char*)aSmtpHostName,
|
||||
SMTP_PORT, aRecipients ? aRecipients : "");
|
||||
if (urlSpec)
|
||||
{
|
||||
nsCOMPtr<nsIMsgMailNewsUrl> url = do_QueryInterface(smtpUrl);
|
||||
url->SetSpec(urlSpec);
|
||||
smtpUrl->SetPostMessageFile(aFilePath);
|
||||
// this cast is safe....it is necessary because of a bug to the xpidl compiler
|
||||
smtpUrl->SetUserEmailAddress(aSender);
|
||||
smtpUrl->SetSenderIdentity(aSenderIdentity);
|
||||
|
||||
url->RegisterListener(aUrlListener);
|
||||
PR_Free(urlSpec);
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "nsIURI.h"
|
||||
#include "nsSmtpUrl.h"
|
||||
#include "nsString.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
extern "C" {
|
||||
char * NET_SACopy (char **destination, const char *source);
|
||||
@ -281,10 +282,15 @@ nsresult nsSmtpUrl::ParseUrl()
|
||||
NS_LOCK_INSTANCE();
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// set the username
|
||||
nsXPIDLCString userName;
|
||||
rv = GetPreHost(getter_Copies(userName));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
m_userName = (const char *)userName;
|
||||
|
||||
// the recipients should consist of just the path part up to to the query
|
||||
// part
|
||||
|
||||
rv = GetFileName(&m_toPart);
|
||||
|
||||
// now parse out the search field...
|
||||
@ -304,31 +310,7 @@ nsresult nsSmtpUrl::ParseUrl()
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsSmtpUrl::GetUserEmailAddress(char ** aUserName)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (aUserName)
|
||||
*aUserName = m_userName.ToNewCString();
|
||||
else
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsSmtpUrl::SetUserEmailAddress(const char * aUserName)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (aUserName)
|
||||
{
|
||||
m_userName = aUserName;
|
||||
}
|
||||
else
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
nsresult nsSmtpUrl::GetMessageContents(char ** aToPart, char ** aCcPart, char ** aBccPart,
|
||||
NS_IMETHODIMP nsSmtpUrl::GetMessageContents(char ** aToPart, char ** aCcPart, char ** aBccPart,
|
||||
char ** aFromPart, char ** aFollowUpToPart, char ** aOrganizationPart,
|
||||
char ** aReplyToPart, char ** aSubjectPart, char ** aBodyPart, char ** aHtmlPart,
|
||||
char ** aReferencePart, char ** aAttachmentPart, char ** aPriorityPart,
|
||||
@ -371,7 +353,8 @@ nsresult nsSmtpUrl::GetMessageContents(char ** aToPart, char ** aCcPart, char **
|
||||
|
||||
// Caller must call PR_FREE on list when it is done with it. This list is a list of all
|
||||
// recipients to send the email to. each name is NULL terminated...
|
||||
nsresult nsSmtpUrl::GetAllRecipients(char ** aRecipientsList)
|
||||
NS_IMETHODIMP
|
||||
nsSmtpUrl::GetAllRecipients(char ** aRecipientsList)
|
||||
{
|
||||
if (aRecipientsList)
|
||||
*aRecipientsList = m_toPart ? nsCRT::strdup(m_toPart) : nsnull;
|
||||
@ -382,7 +365,7 @@ NS_IMPL_GETSET(nsSmtpUrl, PostMessage, PRBool, m_isPostMessage)
|
||||
|
||||
// the message can be stored in a file....allow accessors for getting and setting
|
||||
// the file name to post...
|
||||
nsresult nsSmtpUrl::SetPostMessageFile(nsIFileSpec * aFileSpec)
|
||||
NS_IMETHODIMP nsSmtpUrl::SetPostMessageFile(nsIFileSpec * aFileSpec)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (aFileSpec)
|
||||
@ -393,7 +376,7 @@ nsresult nsSmtpUrl::SetPostMessageFile(nsIFileSpec * aFileSpec)
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsSmtpUrl::GetPostMessageFile(nsIFileSpec ** aFileSpec)
|
||||
NS_IMETHODIMP nsSmtpUrl::GetPostMessageFile(nsIFileSpec ** aFileSpec)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (aFileSpec)
|
||||
@ -406,3 +389,23 @@ nsresult nsSmtpUrl::GetPostMessageFile(nsIFileSpec ** aFileSpec)
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSmtpUrl::GetSenderIdentity(nsIMsgIdentity * *aSenderIdentity)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aSenderIdentity);
|
||||
|
||||
*aSenderIdentity = m_senderIdentity;
|
||||
NS_ADDREF(*aSenderIdentity);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSmtpUrl::SetSenderIdentity(nsIMsgIdentity * aSenderIdentity)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aSenderIdentity);
|
||||
|
||||
m_senderIdentity = dont_QueryInterface(aSenderIdentity);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "nsISmtpUrl.h"
|
||||
#include "nsMsgMailNewsUrl.h"
|
||||
#include "nsIFileSpec.h"
|
||||
#include "nsIMsgIdentity.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsSmtpUrl : public nsISmtpUrl, public nsMsgMailNewsUrl
|
||||
@ -72,6 +73,7 @@ protected:
|
||||
/* Smtp specific event sinks */
|
||||
nsCString m_userName;
|
||||
nsCOMPtr<nsIFileSpec> m_fileName;
|
||||
nsCOMPtr<nsIMsgIdentity> m_senderIdentity;
|
||||
|
||||
// it is possible to encode the message to parse in the form of a url.
|
||||
// This function is used to decompose the search and path part into the bare
|
||||
|
@ -53,6 +53,7 @@
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsIFileSpec.h"
|
||||
#include "nsMsgCompCID.h"
|
||||
#include "nsIMsgIdentity.h"
|
||||
|
||||
#ifdef XP_PC
|
||||
#define XPCOM_DLL "xpcom32.dll"
|
||||
@ -411,7 +412,12 @@ nsresult nsSmtpTestDriver::OnSendMessageInFile()
|
||||
|
||||
|
||||
nsIURI * url = nsnull;
|
||||
m_smtpService->SendMailMessage(aIFileSpec, recipients, this, nsnull, &url);
|
||||
nsCOMPtr <nsIMsgIdentity> senderIdentity;
|
||||
senderIdentity = null_nsCOMPtr();
|
||||
|
||||
printf("passing in null for the sender identity will cause the send to fail, but at least it builds. I need to talk to rhp / mscott about this.\n");
|
||||
|
||||
m_smtpService->SendMailMessage(aIFileSpec, recipients, senderIdentity, this, nsnull, &url);
|
||||
if (url)
|
||||
m_smtpUrl = do_QueryInterface(url);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user