Bug #7811 --> turn nsISmtpUrl.h into a fully scriptable IDL file. This involved changing several apis in the interface.
git-svn-id: svn://10.0.0.236/trunk@44378 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -22,13 +22,14 @@ XPIDLSRCS = \
|
||||
.\nsIMsgComposeService.idl \
|
||||
.\nsIMsgCompose.idl \
|
||||
.\nsIMsgCompFields.idl \
|
||||
.\nsIMsgQuote.idl \
|
||||
.\nsIMsgQuote.idl \
|
||||
.\nsIMsgSendListener.idl \
|
||||
.\nsIMsgSendLaterListener.idl \
|
||||
.\nsIMsgSend.idl \
|
||||
.\nsIMsgSendLaterListener.idl \
|
||||
.\nsIMsgSend.idl \
|
||||
.\nsIMsgSendLater.idl \
|
||||
.\nsIMsgDraft.idl \
|
||||
.\nsISmtpServer.idl \
|
||||
.\nsISmtpUrl.idl \
|
||||
$(NULL)
|
||||
|
||||
################################################################################
|
||||
@@ -40,7 +41,6 @@ EXPORTS = \
|
||||
nsMsgSendFact.h \
|
||||
nsMsgSendLaterFact.h \
|
||||
nsISmtpUrl.h \
|
||||
nsISmtpService.h \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
@@ -256,13 +256,12 @@ const char * nsSmtpProtocol::GetUserDomainName()
|
||||
|
||||
if (m_runningURL)
|
||||
{
|
||||
const char * mailAddr = nsnull;
|
||||
const char *atSignMarker = nsnull;
|
||||
m_runningURL->GetUserEmailAddress(&mailAddr);
|
||||
if (mailAddr)
|
||||
m_runningURL->GetUserEmailAddress(getter_Copies(m_mailAddr));
|
||||
if (m_mailAddr)
|
||||
{
|
||||
atSignMarker = PL_strchr(mailAddr, '@');
|
||||
return atSignMarker ? atSignMarker+1 : mailAddr; // return const ptr into buffer in running url...
|
||||
atSignMarker = PL_strchr(m_mailAddr, '@');
|
||||
return atSignMarker ? atSignMarker+1 : (const char *) m_mailAddr; // return const ptr into buffer in running url...
|
||||
}
|
||||
}
|
||||
|
||||
@@ -468,8 +467,8 @@ PRInt32 nsSmtpProtocol::SendHeloResponse(nsIInputStream * inputStream, PRUint32
|
||||
nsCAutoString buffer;
|
||||
|
||||
// extract the email addresss
|
||||
const char * userAddress = nsnull;
|
||||
m_runningURL->GetUserEmailAddress(&userAddress);
|
||||
nsXPIDLCString userAddress;
|
||||
m_runningURL->GetUserEmailAddress(getter_Copies(userAddress));
|
||||
|
||||
/* don't check for a HELO response because it can be bogus and
|
||||
* we don't care
|
||||
@@ -1002,13 +1001,15 @@ PRInt32 nsSmtpProtocol::SendDataResponse()
|
||||
|
||||
PRInt32 nsSmtpProtocol::SendMessageInFile()
|
||||
{
|
||||
const nsFilePath * filePath = nsnull;
|
||||
m_runningURL->GetPostMessageFile(&filePath);
|
||||
if (filePath && *filePath)
|
||||
nsCOMPtr<nsIFileSpec> fileSpec;
|
||||
m_runningURL->GetPostMessageFile(getter_AddRefs(fileSpec));
|
||||
if (fileSpec)
|
||||
{
|
||||
// mscott -- this function should be re-written to use the file url code so it can be
|
||||
// asynch
|
||||
nsInputFileStream * fileStream = new nsInputFileStream(nsFileSpec(*filePath), PR_RDONLY, 00700);
|
||||
nsFileSpec afileSpec;
|
||||
fileSpec->GetFileSpec(&afileSpec);
|
||||
nsInputFileStream * fileStream = new nsInputFileStream(afileSpec, PR_RDONLY, 00700);
|
||||
if (fileStream && fileStream->is_open())
|
||||
{
|
||||
PRInt32 amtInBuffer = 0;
|
||||
@@ -1135,7 +1136,7 @@ PRInt32 nsSmtpProtocol::SendPostData()
|
||||
|
||||
// check to see if url is a file..if it is...call our file handler...
|
||||
PRBool postMessageInFile = PR_TRUE;
|
||||
m_runningURL->IsPostMessage(&postMessageInFile);
|
||||
m_runningURL->GetPostMessage(&postMessageInFile);
|
||||
if (postMessageInFile)
|
||||
{
|
||||
return SendMessageInFile();
|
||||
@@ -1206,7 +1207,7 @@ nsresult nsSmtpProtocol::LoadUrl(nsIURI * aURL, nsISupports * /* aConsumer */)
|
||||
#endif
|
||||
|
||||
PRBool postMessage = PR_FALSE;
|
||||
m_runningURL->IsPostMessage(&postMessage);
|
||||
m_runningURL->GetPostMessage(&postMessage);
|
||||
|
||||
if(postMessage)
|
||||
{
|
||||
@@ -1221,14 +1222,14 @@ nsresult nsSmtpProtocol::LoadUrl(nsIURI * aURL, nsISupports * /* aConsumer */)
|
||||
doesn't matter.
|
||||
*/
|
||||
|
||||
char * addresses = nsnull;
|
||||
nsXPIDLCString addresses;
|
||||
nsCOMPtr<nsIMsgHeaderParser> parser;
|
||||
rv = nsComponentManager::CreateInstance(kHeaderParserCID,
|
||||
nsnull,
|
||||
nsCOMTypeInfo<nsIMsgHeaderParser>::GetIID(),
|
||||
getter_AddRefs(parser));
|
||||
|
||||
m_runningURL->GetAllRecipients(&addresses);
|
||||
m_runningURL->GetAllRecipients(getter_Copies(addresses));
|
||||
|
||||
if (NS_SUCCEEDED(rv) && parser)
|
||||
{
|
||||
@@ -1257,7 +1258,6 @@ nsresult nsSmtpProtocol::LoadUrl(nsIURI * aURL, nsISupports * /* aConsumer */)
|
||||
|
||||
m_addressCopy = addrs2;
|
||||
m_addresses = m_addressCopy;
|
||||
PR_FREEIF(addresses); // free our original addresses string...
|
||||
} // if parser
|
||||
} // if post message
|
||||
|
||||
|
||||
@@ -21,10 +21,11 @@
|
||||
|
||||
#include "nsMsgProtocol.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "rosetta.h"
|
||||
#include HG40855
|
||||
#include "nsISmtpUrl.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
/* states of the machine
|
||||
*/
|
||||
@@ -99,6 +100,7 @@ private:
|
||||
char *m_addresses;
|
||||
PRUint32 m_addressesLeft;
|
||||
char *m_verifyAddress;
|
||||
nsXPIDLCString m_mailAddr;
|
||||
|
||||
SmtpAuthMethod m_authMethod;
|
||||
|
||||
|
||||
@@ -152,8 +152,12 @@ nsresult NS_MsgBuildMailtoUrl(const nsFilePath& aFilePath,
|
||||
{
|
||||
nsCOMPtr<nsIMsgMailNewsUrl> url = do_QueryInterface(smtpUrl);
|
||||
url->SetSpec(urlSpec);
|
||||
smtpUrl->SetPostMessageFile(aFilePath);
|
||||
smtpUrl->SetUserEmailAddress(aSender);
|
||||
nsFileSpec aFileSpec (aFilePath);
|
||||
nsCOMPtr<nsIFileSpec> aIFileSpec;
|
||||
NS_NewFileSpecWithSpec(aFileSpec, getter_AddRefs(aIFileSpec));
|
||||
smtpUrl->SetPostMessageFile(aIFileSpec);
|
||||
// this cast is safe....it is necessary because of a bug to the xpidl compiler
|
||||
smtpUrl->SetUserEmailAddress((char *) aSender);
|
||||
url->RegisterListener(aUrlListener);
|
||||
PR_Free(urlSpec);
|
||||
}
|
||||
@@ -181,9 +185,6 @@ nsresult NS_MsgLoadMailtoUrl(nsIURI * aUrl, nsISupports * aConsumer)
|
||||
smtpUrl = do_QueryInterface(aUrl);
|
||||
if (smtpUrl)
|
||||
{
|
||||
const nsFilePath * fileName = nsnull;
|
||||
smtpUrl->GetPostMessageFile(&fileName);
|
||||
|
||||
// almost there...now create a nntp protocol instance to run the url in...
|
||||
smtpProtocol = new nsSmtpProtocol(aUrl);
|
||||
if (smtpProtocol == nsnull)
|
||||
|
||||
@@ -43,8 +43,7 @@ nsresult NS_NewSmtpUrl(const nsIID &aIID, void ** aInstancePtrResult)
|
||||
return NS_ERROR_NULL_POINTER; /* aInstancePtrResult was NULL....*/
|
||||
}
|
||||
|
||||
nsSmtpUrl::nsSmtpUrl() : nsMsgMailNewsUrl(),
|
||||
m_fileName("")
|
||||
nsSmtpUrl::nsSmtpUrl() : nsMsgMailNewsUrl()
|
||||
{
|
||||
// nsISmtpUrl specific state...
|
||||
m_toPart = nsnull;
|
||||
@@ -62,6 +61,8 @@ nsSmtpUrl::nsSmtpUrl() : nsMsgMailNewsUrl(),
|
||||
m_organizationPart = nsnull;
|
||||
m_replyToPart = nsnull;
|
||||
m_priorityPart = nsnull;
|
||||
m_fileName = nsnull;
|
||||
m_isPostMessage = PR_TRUE;
|
||||
}
|
||||
|
||||
nsSmtpUrl::~nsSmtpUrl()
|
||||
@@ -293,17 +294,17 @@ nsresult nsSmtpUrl::ParseUrl()
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsSmtpUrl::GetUserEmailAddress(const char ** aUserName)
|
||||
nsresult nsSmtpUrl::GetUserEmailAddress(char ** aUserName)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (aUserName)
|
||||
*aUserName = m_userName.GetBuffer();
|
||||
*aUserName = m_userName.ToNewCString();
|
||||
else
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsSmtpUrl::SetUserEmailAddress(const char * aUserName)
|
||||
nsresult nsSmtpUrl::SetUserEmailAddress(char * aUserName)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (aUserName)
|
||||
@@ -317,42 +318,42 @@ nsresult nsSmtpUrl::SetUserEmailAddress(const char * aUserName)
|
||||
}
|
||||
|
||||
|
||||
nsresult nsSmtpUrl::GetMessageContents(const char ** aToPart, const char ** aCcPart, const char ** aBccPart,
|
||||
const char ** aFromPart, const char ** aFollowUpToPart, const char ** aOrganizationPart,
|
||||
const char ** aReplyToPart, const char ** aSubjectPart, const char ** aBodyPart, const char ** aHtmlPart,
|
||||
const char ** aReferencePart, const char ** aAttachmentPart, const char ** aPriorityPart,
|
||||
const char ** aNewsgroupPart, const char ** aNewsHostPart, PRBool * aForcePlainText)
|
||||
nsresult 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,
|
||||
char ** aNewsgroupPart, char ** aNewsHostPart, PRBool * aForcePlainText)
|
||||
{
|
||||
if (aToPart)
|
||||
*aToPart = m_toPart;
|
||||
*aToPart = nsCRT::strdup(m_toPart);
|
||||
if (aCcPart)
|
||||
*aCcPart = m_ccPart;
|
||||
*aCcPart = nsCRT::strdup(m_ccPart);
|
||||
if (aBccPart)
|
||||
*aBccPart = m_bccPart;
|
||||
*aBccPart = nsCRT::strdup(m_bccPart);
|
||||
if (aFromPart)
|
||||
*aFromPart = m_fromPart;
|
||||
*aFromPart = nsCRT::strdup(m_fromPart);
|
||||
if (aFollowUpToPart)
|
||||
*aFollowUpToPart = m_followUpToPart;
|
||||
*aFollowUpToPart = nsCRT::strdup(m_followUpToPart);
|
||||
if (aOrganizationPart)
|
||||
*aOrganizationPart = m_organizationPart;
|
||||
*aOrganizationPart = nsCRT::strdup(m_organizationPart);
|
||||
if (aReplyToPart)
|
||||
*aReplyToPart = m_replyToPart;
|
||||
*aReplyToPart = nsCRT::strdup(m_replyToPart);
|
||||
if (aSubjectPart)
|
||||
*aSubjectPart = m_subjectPart;
|
||||
*aSubjectPart = nsCRT::strdup(m_subjectPart);
|
||||
if (aBodyPart)
|
||||
*aBodyPart = m_bodyPart;
|
||||
*aBodyPart = nsCRT::strdup(m_bodyPart);
|
||||
if (aHtmlPart)
|
||||
*aHtmlPart = m_htmlPart;
|
||||
*aHtmlPart = nsCRT::strdup(m_htmlPart);
|
||||
if (aReferencePart)
|
||||
*aReferencePart = m_referencePart;
|
||||
*aReferencePart = nsCRT::strdup(m_referencePart);
|
||||
if (aAttachmentPart)
|
||||
*aAttachmentPart = m_attachmentPart;
|
||||
*aAttachmentPart = nsCRT::strdup(m_attachmentPart);
|
||||
if (aPriorityPart)
|
||||
*aPriorityPart = m_priorityPart;
|
||||
*aPriorityPart = nsCRT::strdup(m_priorityPart);
|
||||
if (aNewsgroupPart)
|
||||
*aNewsgroupPart = m_newsgroupPart;
|
||||
*aNewsgroupPart = nsCRT::strdup(m_newsgroupPart);
|
||||
if (aNewsHostPart)
|
||||
*aNewsHostPart = m_newsHostPart;
|
||||
*aNewsHostPart = nsCRT::strdup(m_newsHostPart);
|
||||
if (aForcePlainText)
|
||||
*aForcePlainText = m_forcePlainText;
|
||||
return NS_OK;
|
||||
@@ -363,40 +364,35 @@ nsresult nsSmtpUrl::GetMessageContents(const char ** aToPart, const char ** aCcP
|
||||
nsresult nsSmtpUrl::GetAllRecipients(char ** aRecipientsList)
|
||||
{
|
||||
if (aRecipientsList)
|
||||
*aRecipientsList = m_toPart ? PL_strdup(m_toPart) : nsnull;
|
||||
*aRecipientsList = m_toPart ? nsCRT::strdup(m_toPart) : nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// is the url a post message url or a bring up the compose window url?
|
||||
nsresult nsSmtpUrl::IsPostMessage(PRBool * aPostMessage)
|
||||
{
|
||||
if (aPostMessage)
|
||||
*aPostMessage = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// used to set the url as a post message url...
|
||||
nsresult nsSmtpUrl::SetPostMessage(PRBool aPostMessage)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
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(const nsFilePath& aFileName)
|
||||
nsresult nsSmtpUrl::SetPostMessageFile(nsIFileSpec * aFileSpec)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (aFileName)
|
||||
m_fileName = aFileName;
|
||||
if (aFileSpec)
|
||||
m_fileName = dont_QueryInterface(aFileSpec);
|
||||
else
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsSmtpUrl::GetPostMessageFile(const nsFilePath ** aFileName)
|
||||
nsresult nsSmtpUrl::GetPostMessageFile(nsIFileSpec ** aFileSpec)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (aFileName)
|
||||
*aFileName = &m_fileName;
|
||||
if (aFileSpec)
|
||||
{
|
||||
*aFileSpec = m_fileName;
|
||||
NS_IF_ADDREF(*aFileSpec);
|
||||
}
|
||||
else
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
#include "nsISmtpUrl.h"
|
||||
#include "nsMsgMailNewsUrl.h"
|
||||
#include "nsIFileSpec.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsSmtpUrl : public nsISmtpUrl, public nsMsgMailNewsUrl
|
||||
{
|
||||
@@ -31,46 +33,9 @@ public:
|
||||
NS_IMETHOD SetSpec(char * aSpec);
|
||||
|
||||
// From nsISmtpUrl
|
||||
NS_DECL_NSISMTPURL
|
||||
|
||||
// mscott: I used to have individual getters for ALL of these fields but it was
|
||||
// getting way out of hand...besides in the actual protocol, we want all of these
|
||||
// fields anyway so why go through the extra step of making the protocol call
|
||||
// 12 get functions...
|
||||
NS_IMETHOD GetMessageContents(const char ** aToPart, const char ** aCcPart, const char ** aBccPart,
|
||||
const char ** aFromPart, const char ** aFollowUpToPart, const char ** aOrganizationPart,
|
||||
const char ** aReplyToPart, const char ** aSubjectPart, const char ** aBodyPart, const char ** aHtmlPart,
|
||||
const char ** aReferencePart, const char ** aAttachmentPart, const char ** aPriorityPart,
|
||||
const char ** aNewsgroupPart, const char ** aNewsHostPart, PRBool * aforcePlainText);
|
||||
|
||||
// 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...
|
||||
NS_IMETHOD GetAllRecipients(char ** aRecipientsList);
|
||||
|
||||
// is the url a post message url or a bring up the compose window url?
|
||||
NS_IMETHOD IsPostMessage(PRBool * aPostMessage);
|
||||
|
||||
// used to set the url as a post message url...
|
||||
NS_IMETHOD SetPostMessage(PRBool aPostMessage);
|
||||
|
||||
// the message can be stored in a file....allow accessors for getting and setting
|
||||
// the file name to post...
|
||||
NS_IMETHOD SetPostMessageFile(const nsFilePath& aFileName);
|
||||
NS_IMETHOD GetPostMessageFile(const nsFilePath ** aFileName);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// SMTP Url instance specific getters and setters --> info the protocol needs
|
||||
// to know in order to run the url...these are NOT event sinks which are things
|
||||
// the caller needs to know...
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// 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...
|
||||
NS_IMETHOD GetUserEmailAddress(const char ** aUserName);
|
||||
NS_IMETHOD SetUserEmailAddress(const char * aUserName);
|
||||
|
||||
// nsSmtpUrl
|
||||
|
||||
// nsSmtpUrl
|
||||
nsSmtpUrl();
|
||||
|
||||
protected:
|
||||
@@ -98,10 +63,11 @@ protected:
|
||||
|
||||
|
||||
PRBool m_forcePlainText;
|
||||
PRBool m_isPostMessage;
|
||||
|
||||
/* Smtp specific event sinks */
|
||||
nsCString m_userName;
|
||||
nsFilePath m_fileName;
|
||||
nsCOMPtr<nsIFileSpec> m_fileName;
|
||||
|
||||
// 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
|
||||
|
||||
Reference in New Issue
Block a user