Fix for bug 95124. Add/update interfaces to pass a send listener and a smtp password when opening a compose window. R=bienvenu, SR=mscott

This commit is contained in:
ducarroz%netscape.com 2001-08-15 22:40:14 +00:00
Родитель 15bd513e75
Коммит cb00fbf56f
16 изменённых файлов: 232 добавлений и 93 удалений

Просмотреть файл

@ -185,10 +185,10 @@ interface nsIMsgCompose : nsISupports {
of the body to 0 (clean).
*/
attribute boolean bodyModified;
/* The following functions are for internal use, essentially for the listener */
/* ... */
[noscript] void setCiteReference(in nsString citeReference);
@ -201,18 +201,21 @@ interface nsIMsgCompose : nsISupports {
/* set any reply flags on the original message's folder */
[noscript] void processReplyFlags();
/* ... */
[noscript] void convertAndLoadComposeWindow(in nsIEditorShell aEditorShell, in nsStringRef aPrefix, in nsStringRef aBuf,
/* ... */
[noscript] void convertAndLoadComposeWindow(in nsIEditorShell aEditorShell, in nsStringRef aPrefix, in nsStringRef aBuf,
in nsStringRef aSignature, in boolean aQuoted, in boolean aHTMLEditor);
/* Tell the doc state listeners that the doc state has changed */
[noscript] void notifyStateListeners(in TStateListenerNotification aNotificationType, in nsresult aResult);
/* Tell the doc state listeners that the doc state has changed */
[noscript] void notifyStateListeners(in TStateListenerNotification aNotificationType, in nsresult aResult);
/* Retreive the progress object */
[noscript] nsIMsgProgress getProgress();
/* Retreive the message send object */
[noscript] nsIMsgSend getMessageSend();
/* Retreive the external send listener */
nsIMsgSendListener getExternalSendListener();
/* ... */
[noscript] void buildBodyMessageAndSignature();

Просмотреть файл

@ -25,6 +25,7 @@
#include "nsISupports.idl"
#include "nsIMsgIdentity.idl"
#include "nsIMsgCompFields.idl"
#include "nsIMsgSendListener.idl"
typedef long MSG_ComposeType;
@ -65,4 +66,7 @@ interface nsIMsgComposeParams : nsISupports {
attribute nsIMsgCompFields composeFields;
attribute boolean bodyIsLink;
attribute nsIMsgSendListener sendListener;
attribute string smtpPassword;
};

Просмотреть файл

@ -53,6 +53,9 @@ interface nsIMsgComposeService : nsISupports {
void OpenComposeWindowWithCompFields(in string msgComposeWindowURL, in MSG_ComposeType type, in MSG_ComposeFormat format,
in nsIMsgCompFields compFields, in nsIMsgIdentity identity);
/* ... */
void OpenComposeWindowWithParams(in string msgComposeWindowURL, in nsIMsgComposeParams params);
/* ... */
nsIMsgCompose InitCompose(in nsIDOMWindowInternal aWindow, in nsIMsgComposeParams params);

Просмотреть файл

@ -183,7 +183,8 @@ interface nsIMsgSend : nsISupports
in voidPtr relatedPart,
in nsIDOMWindowInternal parentWindow,
in nsIMsgProgress progress,
in nsIMsgSendListener aListener
in nsIMsgSendListener aListener,
in string password
);
@ -194,8 +195,9 @@ interface nsIMsgSend : nsISupports
in PRBool digest_p,
in nsMsgDeliverMode mode,
in nsIMsgDBHdr msgToReplace,
in nsIMsgSendListener aListener
);
in nsIMsgSendListener aListener,
in string password
);
/* Abort current send/save operation */
void abort();

Просмотреть файл

@ -48,19 +48,21 @@ interface nsISmtpService : nsISupports {
// If you don't care about listening to the url, feel free to pass in
// nsnull for that argument.
//
// You can also pass an SMTP server as an argument if you want to send
// this message with a specific server.. otherwise it will use the
// default server
// You can also pass an password as an argument if you want to prevent
// a dialog to popup if the password is needed for a secure transmission
//
// The server associate to the Sender Identity will be used or the default
// server.
//////////////////////////////////////////////////////////////////////////
void SendMailMessage(in nsIFileSpec aFilePath, in string aRecipients,
in nsIMsgIdentity aSenderIdentity,
in string aPassword,
in nsIUrlListener aUrlListener,
in nsISmtpServer aServer,
in nsIMsgStatusFeedback aStatusListener,
in nsIMsgStatusFeedback aStatusListener,
in nsIInterfaceRequestor aNotificationCallbacks,
out nsIURI aURL,
out nsIRequest aRequest);
out nsIRequest aRequest);
/**
* A copy of the array of SMTP servers, as stored in the preferences

Просмотреть файл

@ -650,6 +650,11 @@ nsresult nsMsgCompose::Initialize(nsIDOMWindowInternal *aWindow,
}
params->GetSendListener(getter_AddRefs(mExternalSendListener));
nsXPIDLCString smtpPassword;
params->GetSmtpPassword(getter_Copies(smtpPassword));
mSmtpPassword = (const char *)smtpPassword;
return CreateMessage(originalMsgURI, type, format, composeFields);
}
@ -806,7 +811,8 @@ nsresult nsMsgCompose::_SendMsg(MSG_DeliverMode deliverMode, nsIMsgIdentity *ide
nsnull, // nsMsgSendPart *relatedPart,
m_window, // nsIDOMWindowInternal *parentWindow;
mProgress, // nsIMsgProgress *progress,
sendListener); // listener
sendListener, // listener
mSmtpPassword.get());
// Cleanup converted body...
if (newBody)
@ -1286,7 +1292,7 @@ nsresult nsMsgCompose::CreateMessage(const char * originalMsgURI,
NS_IMETHODIMP nsMsgCompose::GetProgress(nsIMsgProgress **_retval)
{
NS_ENSURE_ARG(_retval);
NS_ENSURE_ARG_POINTER(_retval);
*_retval = mProgress;
NS_IF_ADDREF(*_retval);
return NS_OK;
@ -1294,12 +1300,20 @@ NS_IMETHODIMP nsMsgCompose::GetProgress(nsIMsgProgress **_retval)
NS_IMETHODIMP nsMsgCompose::GetMessageSend(nsIMsgSend **_retval)
{
NS_ENSURE_ARG(_retval);
NS_ENSURE_ARG_POINTER(_retval);
*_retval = mMsgSend;
NS_IF_ADDREF(*_retval);
return NS_OK;
}
NS_IMETHODIMP nsMsgCompose::GetExternalSendListener(nsIMsgSendListener **_retval)
{
NS_ENSURE_ARG_POINTER(_retval);
*_retval = mExternalSendListener;
NS_IF_ADDREF(*_retval);
return NS_OK;
}
NS_IMETHODIMP nsMsgCompose::SetCiteReference(nsString citeReference)
{
mCiteReference = citeReference;
@ -1959,6 +1973,16 @@ nsMsgComposeSendListener::OnStartSending(const char *aMsgID, PRUint32 aMsgSize)
#ifdef NS_DEBUG
printf("nsMsgComposeSendListener::OnStartSending()\n");
#endif
nsCOMPtr<nsIMsgCompose>compose = do_QueryReferent(mWeakComposeObj);
if (compose)
{
nsCOMPtr<nsIMsgSendListener> externalListener;
compose->GetExternalSendListener(getter_AddRefs(externalListener));
if (externalListener)
externalListener->OnStartSending(aMsgID, aMsgSize);
}
return NS_OK;
}
@ -1968,6 +1992,16 @@ nsMsgComposeSendListener::OnProgress(const char *aMsgID, PRUint32 aProgress, PRU
#ifdef NS_DEBUG
printf("nsMsgComposeSendListener::OnProgress()\n");
#endif
nsCOMPtr<nsIMsgCompose>compose = do_QueryReferent(mWeakComposeObj);
if (compose)
{
nsCOMPtr<nsIMsgSendListener> externalListener;
compose->GetExternalSendListener(getter_AddRefs(externalListener));
if (externalListener)
externalListener->OnProgress(aMsgID, aProgress, aProgressMax);
}
return NS_OK;
}
@ -1978,6 +2012,15 @@ nsMsgComposeSendListener::OnStatus(const char *aMsgID, const PRUnichar *aMsg)
printf("nsMsgComposeSendListener::OnStatus()\n");
#endif
nsCOMPtr<nsIMsgCompose>compose = do_QueryReferent(mWeakComposeObj);
if (compose)
{
nsCOMPtr<nsIMsgSendListener> externalListener;
compose->GetExternalSendListener(getter_AddRefs(externalListener));
if (externalListener)
externalListener->OnStatus(aMsgID, aMsg);
}
return NS_OK;
}
@ -2047,7 +2090,12 @@ nsresult nsMsgComposeSendListener::OnStopSending(const char *aMsgID, nsresult aS
if (progress)
progress->CloseProgressDialog(PR_TRUE);
}
}
nsCOMPtr<nsIMsgSendListener> externalListener;
compose->GetExternalSendListener(getter_AddRefs(externalListener));
if (externalListener)
externalListener->OnStopSending(aMsgID, aStatus, aMsg, returnFileSpec);
}
return rv;
}
@ -2057,8 +2105,15 @@ nsMsgComposeSendListener::OnGetDraftFolderURI(const char *aFolderURI)
{
nsCOMPtr<nsIMsgCompose>compose = do_QueryReferent(mWeakComposeObj);
if (compose)
{
compose->SetSavedFolderURI(aFolderURI);
nsCOMPtr<nsIMsgSendListener> externalListener;
compose->GetExternalSendListener(getter_AddRefs(externalListener));
if (externalListener)
externalListener->OnGetDraftFolderURI(aFolderURI);
}
return NS_OK;
}

Просмотреть файл

@ -126,6 +126,9 @@ private:
nsMsgDocumentStateListener *mDocumentListener;
MSG_ComposeType mType; //Message type
nsCOMPtr<nsISupportsArray> mStateListeners; // contents are nsISupports
nsCOMPtr<nsIMsgSendListener> mExternalSendListener;
nsCString mSmtpPassword;
friend class QuotingOutputStreamListener;
friend class nsMsgDocumentStateListener;

Просмотреть файл

@ -66,7 +66,7 @@ NS_IMETHODIMP nsMsgComposeParams::SetFormat(MSG_ComposeFormat aFormat)
return NS_OK;
}
/* attribute wstring originalMsgURI; */
/* attribute string originalMsgURI; */
NS_IMETHODIMP nsMsgComposeParams::GetOriginalMsgURI(char * *aOriginalMsgURI)
{
NS_ENSURE_ARG_POINTER(aOriginalMsgURI);
@ -133,3 +133,38 @@ NS_IMETHODIMP nsMsgComposeParams::SetBodyIsLink(PRBool aBodyIsLink)
mBodyIsLink = aBodyIsLink;
return NS_OK;
}
/* attribute nsIMsgSendLisneter sendListener; */
NS_IMETHODIMP nsMsgComposeParams::GetSendListener(nsIMsgSendListener * *aSendListener)
{
NS_ENSURE_ARG_POINTER(aSendListener);
if (mSendListener)
{
*aSendListener = mSendListener;
NS_ADDREF(*aSendListener);
}
else
*aSendListener = nsnull;
return NS_OK;
}
NS_IMETHODIMP nsMsgComposeParams::SetSendListener(nsIMsgSendListener * aSendListener)
{
mSendListener = aSendListener;
return NS_OK;
}
/* attribute string smtpPassword; */
NS_IMETHODIMP nsMsgComposeParams::GetSmtpPassword(char * *aSmtpPassword)
{
NS_ENSURE_ARG_POINTER(aSmtpPassword);
*aSmtpPassword = mSMTPPassword.ToNewCString();
return NS_OK;
}
NS_IMETHODIMP nsMsgComposeParams::SetSmtpPassword(const char * aSmtpPassword)
{
mSMTPPassword = aSmtpPassword;
return NS_OK;
}

Просмотреть файл

@ -39,4 +39,6 @@ public:
nsCOMPtr<nsIMsgIdentity> mIdentity;
nsCOMPtr<nsIMsgCompFields> mComposeFields;
PRBool mBodyIsLink;
nsCOMPtr<nsIMsgSendListener> mSendListener;
nsCString mSMTPPassword;
};

Просмотреть файл

@ -311,6 +311,17 @@ nsresult nsMsgComposeService::OpenComposeWindowWithCompFields(const char *msgCom
return rv;
}
nsresult nsMsgComposeService::OpenComposeWindowWithParams(const char *msgComposeWindowURL,
nsIMsgComposeParams *params)
{
NS_ENSURE_ARG_POINTER(params);
#ifdef MSGCOMP_TRACE_PERFORMANCE
TimeStamp("Start opening the window", PR_TRUE);
#endif
return openWindow(msgComposeWindowURL, params);
}
nsresult nsMsgComposeService::InitCompose(nsIDOMWindowInternal *aWindow,
nsIMsgComposeParams *params,
nsIMsgCompose **_retval)

Просмотреть файл

@ -2667,7 +2667,8 @@ nsMsgComposeAndSend::Init(
const char *attachment1_body,
PRUint32 attachment1_body_length,
const nsMsgAttachmentData *attachments,
const nsMsgAttachedFile *preloaded_attachments)
const nsMsgAttachedFile *preloaded_attachments,
const char *password)
{
nsresult rv = NS_OK;
@ -2760,6 +2761,8 @@ nsMsgComposeAndSend::Init(
return rv;
}
mSmtpPassword = password;
return HackAttachments(attachments, preloaded_attachments);
}
@ -3027,7 +3030,7 @@ nsMsgComposeAndSend::DeliverFileAsMail()
nsCOMPtr<nsIMsgStatusFeedback> msgStatus (do_QueryInterface(mSendProgress));
rv = smtpService->SendMailMessage(aFileSpec, buf, mUserIdentity,
uriListener, nsnull, msgStatus,
mSmtpPassword.get(), uriListener, msgStatus,
callbacks, nsnull, getter_AddRefs(mRunningRequest));
}
@ -3521,7 +3524,8 @@ nsMsgComposeAndSend::CreateAndSendMessage(
void *relatedPart,
nsIDOMWindowInternal *parentWindow,
nsIMsgProgress *progress,
nsIMsgSendListener *aListener
nsIMsgSendListener *aListener,
const char *password
)
{
nsresult rv;
@ -3544,7 +3548,8 @@ nsMsgComposeAndSend::CreateAndSendMessage(
digest_p, dont_deliver_p, mode, msgToReplace,
attachment1_type, attachment1_body,
attachment1_body_length,
attachments, preloaded_attachments);
attachments, preloaded_attachments,
password);
if (NS_SUCCEEDED(rv))
return NS_OK;
@ -3556,12 +3561,13 @@ nsresult
nsMsgComposeAndSend::SendMessageFile(
nsIMsgIdentity *aUserIndentity,
nsIMsgCompFields *fields,
nsIFileSpec *sendIFileSpec,
nsIFileSpec *sendIFileSpec,
PRBool deleteSendFileOnCompletion,
PRBool digest_p,
nsMsgDeliverMode mode,
nsIMsgDBHdr *msgToReplace,
nsIMsgSendListener *aListener
nsIMsgSendListener *aListener,
const char *password
)
{
nsresult rv;
@ -3606,11 +3612,11 @@ nsMsgComposeAndSend::SendMessageFile(
rv = Init(aUserIndentity, (nsMsgCompFields *)fields, sendFileSpec,
digest_p, PR_FALSE, mode, msgToReplace,
nsnull, nsnull, nsnull,
nsnull, nsnull);
if (NS_SUCCEEDED(rv))
{
nsnull, nsnull,
password);
if (NS_SUCCEEDED(rv))
return DeliverMessage();
}
else
return rv;
}

Просмотреть файл

@ -234,7 +234,8 @@ public:
const char *attachment1_body,
PRUint32 attachment1_body_length,
const nsMsgAttachmentData *attachments,
const nsMsgAttachedFile *preloaded_attachments);
const nsMsgAttachedFile *preloaded_attachments,
const char *password);
//
// Setup the composition fields
@ -382,6 +383,8 @@ protected:
private:
// will set m_attachment1_body & m_attachment1_body_length;
nsresult EnsureLineBreaks(const char *body, PRUint32 body_len);
nsCString mSmtpPassword; // store the smtp Password use during a send
};
//

Просмотреть файл

@ -522,7 +522,8 @@ nsCOMPtr<nsIMsgSend> pMsgSend = nsnull;
PR_FALSE, // PRBool digest_p,
nsIMsgSend::nsMsgDeliverNow, // nsMsgDeliverMode mode,
nsnull, // nsIMsgDBHdr *msgToReplace,
sendListener);
sendListener,
nsnull);
NS_IF_RELEASE(sendListener);
return rv;
}

Просмотреть файл

@ -92,8 +92,8 @@ NS_IMPL_ISUPPORTS2(nsSmtpService, nsISmtpService, nsIProtocolHandler);
nsresult nsSmtpService::SendMailMessage(nsIFileSpec * aFilePath,
const char * aRecipients,
nsIMsgIdentity * aSenderIdentity,
const char * aPassword,
nsIUrlListener * aUrlListener,
nsISmtpServer * aServer,
nsIMsgStatusFeedback *aStatusFeedback,
nsIInterfaceRequestor* aNotificationCallbacks,
nsIURI ** aURL,
@ -119,6 +119,9 @@ nsresult nsSmtpService::SendMailMessage(nsIFileSpec * aFilePath,
if (NS_SUCCEEDED(rv) && smtpServer)
{
if (aPassword && *aPassword)
smtpServer->SetPassword(aPassword);
nsXPIDLCString smtpHostName;
nsXPIDLCString smtpUserName;

Просмотреть файл

@ -610,23 +610,23 @@ nsresult nsEudoraCompose::SendTheMessage( nsIFileSpec *pMsg)
ExtractType( bodyType);
ExtractCharset( headerVal);
// Use platform charset as default if the msg doesn't specify one
// (ie, no 'charset' param in the Content-Type: header). As the last
// (ie, no 'charset' param in the Content-Type: header). As the last
// resort we'll use the mail defaul charset.
if (! headerVal.Length())
if (! headerVal.Length())
{
headerVal = nsMsgI18NFileSystemCharset();
if (! headerVal.Length())
{ // last resort
if (!m_defCharset.Length())
{
char *pSet = nsMsgI18NGetDefaultMailCharset();
m_defCharset.AssignWithConversion(pSet);
nsCRT::free( pSet);
}
headerVal = m_defCharset;
}
if (! headerVal.Length())
{ // last resort
if (!m_defCharset.Length())
{
char *pSet = nsMsgI18NGetDefaultMailCharset();
m_defCharset.AssignWithConversion(pSet);
nsCRT::free( pSet);
}
headerVal = m_defCharset;
}
}
m_pMsgFields->SetCharacterSet( nsAutoCString(headerVal) );
m_pMsgFields->SetCharacterSet( nsAutoCString(headerVal) );
charSet = headerVal;
GetHeaderValue( m_pHeaders, m_headerLen, "CC:", headerVal);
if (headerVal.Length())
@ -677,41 +677,45 @@ nsresult nsEudoraCompose::SendTheMessage( nsIFileSpec *pMsg)
if (NS_FAILED( rv)) {
rv = m_pSendProxy->CreateAndSendMessage( nsnull, // no editor shell
m_pIdentity, // dummy identity
m_pMsgFields, // message fields
PR_FALSE, // digest = NO
PR_TRUE, // dont_deliver = YES, make a file
nsIMsgSend::nsMsgDeliverNow, // mode
nsnull, // no message to replace
pMimeType, // body type
m_pBody, // body pointer
m_bodyLen, // body length
nsnull, // remote attachment data
pAttach, // local attachments
nsnull, // related part
nsnull, // parent window
nsnull, // progress listener
m_pListener); // listener
rv = m_pSendProxy->CreateAndSendMessage(
nsnull, // no editor shell
m_pIdentity, // dummy identity
m_pMsgFields, // message fields
PR_FALSE, // digest = NO
PR_TRUE, // dont_deliver = YES, make a file
nsIMsgSend::nsMsgDeliverNow, // mode
nsnull, // no message to replace
pMimeType, // body type
m_pBody, // body pointer
m_bodyLen, // body length
nsnull, // remote attachment data
pAttach, // local attachments
nsnull, // related part
nsnull, // parent window
nsnull, // progress listener
m_pListener, // listener
nsnull); // password
}
else {
rv = m_pSendProxy->CreateAndSendMessage( nsnull, // no editor shell
m_pIdentity, // dummy identity
m_pMsgFields, // message fields
PR_FALSE, // digest = NO
PR_TRUE, // dont_deliver = YES, make a file
nsIMsgSend::nsMsgDeliverNow, // mode
nsnull, // no message to replace
pMimeType, // body type
body, // body pointer
body.Length(), // body length
nsnull, // remote attachment data
pAttach, // local attachments
nsnull, // related part
nsnull, // parent window
nsnull, // progress listener
m_pListener); // listener
rv = m_pSendProxy->CreateAndSendMessage(
nsnull, // no editor shell
m_pIdentity, // dummy identity
m_pMsgFields, // message fields
PR_FALSE, // digest = NO
PR_TRUE, // dont_deliver = YES, make a file
nsIMsgSend::nsMsgDeliverNow, // mode
nsnull, // no message to replace
pMimeType, // body type
body, // body pointer
body.Length(), // body length
nsnull, // remote attachment data
pAttach, // local attachments
nsnull, // related part
nsnull, // parent window
nsnull, // progress listener
m_pListener, // listener
nsnull); // password
}

Просмотреть файл

@ -621,22 +621,24 @@ nsresult nsOutlookCompose::SendTheMessage( nsIFileSpec *pMsg)
// IMPORT_LOG0( "Outlook compose calling CreateAndSendMessage\n");
nsMsgAttachedFile *pAttach = GetLocalAttachments();
rv = m_pSendProxy->CreateAndSendMessage( nsnull, // no editor shell
m_pIdentity, // dummy identity
m_pMsgFields, // message fields
PR_FALSE, // digest = NO
PR_TRUE, // dont_deliver = YES, make a file
rv = m_pSendProxy->CreateAndSendMessage(
nsnull, // no editor shell
m_pIdentity, // dummy identity
m_pMsgFields, // message fields
PR_FALSE, // digest = NO
PR_TRUE, // dont_deliver = YES, make a file
nsIMsgSend::nsMsgDeliverNow, // mode
nsnull, // no message to replace
pMimeType, // body type
m_pBody, // body pointer
m_bodyLen, // body length
nsnull, // remote attachment data
pAttach, // local attachments
nsnull, // related part
nsnull, // parent window
nsnull, // progress listener
m_pListener); // listener
nsnull, // no message to replace
pMimeType, // body type
m_pBody, // body pointer
m_bodyLen, // body length
nsnull, // remote attachment data
pAttach, // local attachments
nsnull, // related part
nsnull, // parent window
nsnull, // progress listener
m_pListener, // listener
nsnull); // password
// IMPORT_LOG0( "Returned from CreateAndSendMessage\n");