add forward inline filter action, r=rkent, sr=standard8, bug 312025
This commit is contained in:
Родитель
5adea0a8cf
Коммит
3dfe86f9b6
|
@ -674,18 +674,17 @@ nsresult nsMsgFilterAfterTheFact::ApplyFilter(PRBool *aApplyMore)
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (!forwardTo.IsEmpty())
|
||||
{
|
||||
nsCOMPtr <nsIMsgComposeService> compService = do_GetService (NS_MSGCOMPOSESERVICE_CONTRACTID) ;
|
||||
if (compService)
|
||||
{
|
||||
nsCOMPtr<nsIMsgComposeService> compService =
|
||||
do_GetService(NS_MSGCOMPOSESERVICE_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
for (PRUint32 msgIndex = 0; msgIndex < m_searchHits.Length(); msgIndex++)
|
||||
{
|
||||
nsCOMPtr <nsIMsgDBHdr> msgHdr;
|
||||
m_searchHitHdrs->QueryElementAt(msgIndex, NS_GET_IID(nsIMsgDBHdr), getter_AddRefs(msgHdr));
|
||||
nsCOMPtr<nsIMsgDBHdr> msgHdr(do_QueryElementAt(m_searchHitHdrs,
|
||||
msgIndex));
|
||||
if (msgHdr)
|
||||
{
|
||||
rv = compService->ForwardMessage(NS_ConvertASCIItoUTF16(forwardTo), msgHdr, m_msgWindow, server);
|
||||
}
|
||||
}
|
||||
rv = compService->ForwardMessage(NS_ConvertASCIItoUTF16(forwardTo),
|
||||
msgHdr, m_msgWindow, server,
|
||||
nsIMsgComposeService::kForwardAsDefault);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ interface nsIMsgIdentity;
|
|||
interface nsIMsgIncomingServer;
|
||||
interface nsIMsgDBHdr;
|
||||
|
||||
[scriptable, uuid(ce5f77c8-f278-4ec7-b8dd-ea9dc84af137)]
|
||||
[scriptable, uuid(dbf4b3a7-dc38-4362-a620-ff5d22b3777c)]
|
||||
interface nsIMsgComposeService : nsISupports {
|
||||
|
||||
/* we need a msg window because when we forward inline we may need progress */
|
||||
|
@ -96,15 +96,29 @@ interface nsIMsgComposeService : nsISupports {
|
|||
*/
|
||||
nsIMsgComposeParams getParamsForMailto(in nsIURI aURI);
|
||||
|
||||
/**
|
||||
* @{
|
||||
* These constants control how to forward messages in forwardMessage.
|
||||
* kForwardAsDefault uses value of pref "mail.forward_message_mode".
|
||||
*/
|
||||
const unsigned long kForwardAsDefault = 0;
|
||||
const unsigned long kForwardAsAttachment = 1;
|
||||
const unsigned long kForwardInline = 2;
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* Allow filters to automatically forward a message to the given address(es).
|
||||
* @param forwardTo the address(es) to forward to
|
||||
* @param msgHdr the header of the message being replied to
|
||||
* @param msgWindow message window to use
|
||||
* @param server server to use for determining which account to send from
|
||||
* @param aForwardType - How to forward the message one of 3 values:
|
||||
* kForwardAsDefault, kForwardInline, or
|
||||
* kForwardAsAttachment.
|
||||
*/
|
||||
void forwardMessage(in AString forwardTo, in nsIMsgDBHdr msgHdr,
|
||||
in nsIMsgWindow msgWindow, in nsIMsgIncomingServer server);
|
||||
in nsIMsgWindow msgWindow, in nsIMsgIncomingServer server,
|
||||
in unsigned long aForwardType);
|
||||
|
||||
/**
|
||||
* Allow filters to automatically reply to a message. The reply message is
|
||||
|
|
|
@ -568,7 +568,8 @@ nsMsgComposeService::OpenComposeWindow(const char *msgComposeWindowURL, nsIMsgDB
|
|||
|
||||
return LoadDraftOrTemplate(uriToOpen, type == nsIMsgCompType::ForwardInline || type == nsIMsgCompType::Draft ?
|
||||
nsMimeOutput::nsMimeMessageDraftOrTemplate : nsMimeOutput::nsMimeMessageEditorTemplate,
|
||||
identity, originalMsgURI, origMsgHdr, type == nsIMsgCompType::ForwardInline, format, aMsgWindow);
|
||||
identity, originalMsgURI, origMsgHdr, type == nsIMsgCompType::ForwardInline,
|
||||
format == nsIMsgCompFormat::OppositeOfDefault, aMsgWindow);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIMsgComposeParams> pMsgComposeParams (do_CreateInstance(NS_MSGCOMPOSEPARAMS_CONTRACTID, &rv));
|
||||
|
@ -1212,12 +1213,56 @@ NS_IMETHODIMP nsMsgComposeService::ReplyWithTemplate(nsIMsgDBHdr *aMsgHdr, const
|
|||
return folder->AddMessageDispositionState(aMsgHdr, nsIMsgFolder::nsMsgDispositionState_Replied);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgComposeService::ForwardMessage(const nsAString &forwardTo, nsIMsgDBHdr *aMsgHdr,
|
||||
nsIMsgWindow *aMsgWindow, nsIMsgIncomingServer *aServer)
|
||||
NS_IMETHODIMP
|
||||
nsMsgComposeService::ForwardMessage(const nsAString &forwardTo,
|
||||
nsIMsgDBHdr *aMsgHdr,
|
||||
nsIMsgWindow *aMsgWindow,
|
||||
nsIMsgIncomingServer *aServer,
|
||||
PRUint32 aForwardType)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aMsgHdr);
|
||||
|
||||
nsresult rv;
|
||||
if (aForwardType == nsIMsgComposeService::kForwardAsDefault)
|
||||
{
|
||||
PRInt32 forwardPref = 0;
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
prefBranch->GetIntPref("mail.forward_message_mode", &forwardPref);
|
||||
// 0=default as attachment 2=forward as inline with attachments,
|
||||
// (obsolete 4.x value)1=forward as quoted (mapped to 2 in mozilla)
|
||||
aForwardType = forwardPref == 0 ? nsIMsgComposeService::kForwardAsAttachment :
|
||||
nsIMsgComposeService::kForwardInline;
|
||||
}
|
||||
nsCString msgUri;
|
||||
|
||||
nsCOMPtr<nsIMsgFolder> folder;
|
||||
aMsgHdr->GetFolder(getter_AddRefs(folder));
|
||||
if (!folder)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
folder->GetUriForMsg(aMsgHdr, msgUri);
|
||||
|
||||
// get the MsgIdentity for the above key using AccountManager
|
||||
nsCOMPtr<nsIMsgAccountManager> accountManager =
|
||||
do_GetService (NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIMsgAccount> account;
|
||||
nsCOMPtr<nsIMsgIdentity> identity;
|
||||
|
||||
rv = accountManager->FindAccountForServer(aServer, getter_AddRefs(account));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = account->GetDefaultIdentity(getter_AddRefs(identity));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (aForwardType == nsIMsgComposeService::kForwardInline)
|
||||
return RunMessageThroughMimeDraft(msgUri,
|
||||
nsMimeOutput::nsMimeMessageDraftOrTemplate,
|
||||
identity,
|
||||
msgUri.get(), aMsgHdr,
|
||||
PR_TRUE, forwardTo,
|
||||
PR_FALSE, aMsgWindow);
|
||||
|
||||
nsCOMPtr<nsIDOMWindowInternal> parentWindow;
|
||||
if (aMsgWindow)
|
||||
{
|
||||
|
@ -1227,41 +1272,14 @@ NS_IMETHODIMP nsMsgComposeService::ForwardMessage(const nsAString &forwardTo, ns
|
|||
parentWindow = do_GetInterface(docShell);
|
||||
NS_ENSURE_TRUE(parentWindow, NS_ERROR_FAILURE);
|
||||
}
|
||||
if ( NS_FAILED(rv) ) return rv ;
|
||||
// get the MsgIdentity for the above key using AccountManager
|
||||
nsCOMPtr <nsIMsgAccountManager> accountManager = do_GetService (NS_MSGACCOUNTMANAGER_CONTRACTID) ;
|
||||
if (NS_FAILED(rv) || (!accountManager) ) return rv ;
|
||||
|
||||
nsCOMPtr <nsIMsgAccount> account;
|
||||
nsCOMPtr <nsIMsgIdentity> identity;
|
||||
|
||||
rv = accountManager->FindAccountForServer(aServer, getter_AddRefs(account));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
account->GetDefaultIdentity(getter_AddRefs(identity));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// create the compose params object
|
||||
nsCOMPtr<nsIMsgComposeParams> pMsgComposeParams (do_CreateInstance(NS_MSGCOMPOSEPARAMS_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv) || (!pMsgComposeParams) ) return rv ;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIMsgCompFields> compFields = do_CreateInstance(NS_MSGCOMPFIELDS_CONTRACTID, &rv);
|
||||
|
||||
compFields->SetTo(forwardTo);
|
||||
nsCString msgUri;
|
||||
PRInt32 forwardType = 0;
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
if (prefBranch)
|
||||
prefBranch->GetIntPref("mail.forward_message_mode", &forwardType);
|
||||
|
||||
nsCOMPtr<nsIMsgFolder> folder;
|
||||
aMsgHdr->GetFolder(getter_AddRefs(folder));
|
||||
if (!folder)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
folder->GetUriForMsg(aMsgHdr, msgUri);
|
||||
// populate the compose params
|
||||
// right now, forward inline won't work, since that requires opening a compose window,
|
||||
// and would require major whackage of the compose code.
|
||||
pMsgComposeParams->SetType(/* forwardType ? nsIMsgCompType::ForwardInline : */nsIMsgCompType::ForwardAsAttachment);
|
||||
pMsgComposeParams->SetType(nsIMsgCompType::ForwardAsAttachment);
|
||||
pMsgComposeParams->SetFormat(nsIMsgCompFormat::Default);
|
||||
pMsgComposeParams->SetIdentity(identity);
|
||||
pMsgComposeParams->SetComposeFields(compFields);
|
||||
|
@ -1517,23 +1535,66 @@ nsresult
|
|||
nsMsgComposeService::LoadDraftOrTemplate(const nsACString& aMsgURI, nsMimeOutputType aOutType,
|
||||
nsIMsgIdentity * aIdentity, const char * aOriginalMsgURI,
|
||||
nsIMsgDBHdr * aOrigMsgHdr,
|
||||
PRBool aAddInlineHeaders,
|
||||
MSG_ComposeFormat format,
|
||||
PRBool aForwardInline,
|
||||
PRBool overrideComposeFormat,
|
||||
nsIMsgWindow *aMsgWindow)
|
||||
{
|
||||
return RunMessageThroughMimeDraft(aMsgURI, aOutType, aIdentity,
|
||||
aOriginalMsgURI, aOrigMsgHdr,
|
||||
aForwardInline, EmptyString(),
|
||||
overrideComposeFormat, aMsgWindow);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the aMsgURI message through libmime. We set various attributes of the
|
||||
* nsIMimeStreamConverter so mimedrft.cpp will know what to do with the message
|
||||
* when its done streaming. Usually that will be opening a compose window
|
||||
* with the contents of the message, but if forwardTo is non-empty, mimedrft.cpp
|
||||
* will forward the contents directly.
|
||||
*
|
||||
* @param aMsgURI URI to stream, which is the msgUri + any extra terms, e.g.,
|
||||
* "redirect=true".
|
||||
* @param aOutType nsMimeOutput::nsMimeMessageDraftOrTemplate or
|
||||
* nsMimeOutput::nsMimeMessageEditorTemplate
|
||||
* @param aIdentity identity to use for the new message
|
||||
* @param aOriginalMsgURI msgURI w/o any extra terms
|
||||
* @param aOrigMsgHdr nsIMsgDBHdr corresponding to aOriginalMsgURI
|
||||
* @param aForwardInline true if doing a forward inline
|
||||
* @param aForwardTo e-mail address to forward msg to. This is used for
|
||||
* forward inline message filter actions.
|
||||
* @param aOverrideComposeFormat True if the user had shift key down when
|
||||
doing a command that opens the compose window,
|
||||
* which means we switch the compose window used
|
||||
* from the default.
|
||||
* @param aMsgWindow msgWindow to pass into DisplayMessage.
|
||||
*/
|
||||
nsresult
|
||||
nsMsgComposeService::RunMessageThroughMimeDraft(
|
||||
const nsACString& aMsgURI, nsMimeOutputType aOutType,
|
||||
nsIMsgIdentity * aIdentity, const char * aOriginalMsgURI,
|
||||
nsIMsgDBHdr * aOrigMsgHdr,
|
||||
PRBool aForwardInline,
|
||||
const nsAString &aForwardTo,
|
||||
PRBool aOverrideComposeFormat,
|
||||
nsIMsgWindow *aMsgWindow)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr <nsIMsgMessageService> messageService;
|
||||
rv = GetMessageServiceFromURI(aMsgURI, getter_AddRefs(messageService));
|
||||
nsresult rv = GetMessageServiceFromURI(aMsgURI, getter_AddRefs(messageService));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Now, we can create a mime parser (nsIStreamConverter)!
|
||||
// Create a mime parser (nsIMimeStreamConverter)to do the conversion.
|
||||
nsCOMPtr<nsIMimeStreamConverter> mimeConverter =
|
||||
do_CreateInstance(NS_MAILNEWS_MIME_STREAM_CONVERTER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mimeConverter->SetMimeOutputType(aOutType); // Set the type of output for libmime
|
||||
mimeConverter->SetForwardInline(aAddInlineHeaders);
|
||||
mimeConverter->SetOverrideComposeFormat(format == nsIMsgCompFormat::OppositeOfDefault);
|
||||
mimeConverter->SetForwardInline(aForwardInline);
|
||||
if (!aForwardTo.IsEmpty())
|
||||
{
|
||||
mimeConverter->SetForwardInlineFilter(PR_TRUE);
|
||||
mimeConverter->SetForwardToAddress(aForwardTo);
|
||||
}
|
||||
mimeConverter->SetOverrideComposeFormat(aOverrideComposeFormat);
|
||||
mimeConverter->SetIdentity(aIdentity);
|
||||
mimeConverter->SetOriginalMsgURI(aOriginalMsgURI);
|
||||
mimeConverter->SetOrigMsgHdr(aOrigMsgHdr);
|
||||
|
|
|
@ -100,10 +100,20 @@ private:
|
|||
|
||||
nsresult LoadDraftOrTemplate(const nsACString& aMsgURI, nsMimeOutputType aOutType,
|
||||
nsIMsgIdentity * aIdentity, const char * aOriginalMsgURI,
|
||||
nsIMsgDBHdr * aOrigMsgHdr, PRBool aAddInlineHeaders,
|
||||
nsIMsgDBHdr * aOrigMsgHdr, PRBool aForwardInline,
|
||||
MSG_ComposeFormat format,
|
||||
nsIMsgWindow *aMsgWindow);
|
||||
|
||||
nsresult RunMessageThroughMimeDraft(const nsACString& aMsgURI,
|
||||
nsMimeOutputType aOutType,
|
||||
nsIMsgIdentity * aIdentity,
|
||||
const char * aOriginalMsgURI,
|
||||
nsIMsgDBHdr * aOrigMsgHdr,
|
||||
PRBool aForwardInline,
|
||||
const nsAString &forwardTo,
|
||||
PRBool overrideComposeFormat,
|
||||
nsIMsgWindow *aMsgWindow);
|
||||
|
||||
nsresult ShowCachedComposeWindow(nsIDOMWindowInternal *aComposeWindow, PRBool aShow);
|
||||
|
||||
// hash table mapping dom windows to nsIMsgCompose objects
|
||||
|
|
|
@ -3621,9 +3621,12 @@ NS_IMETHODIMP nsImapMailFolder::ApplyFilterHit(nsIMsgFilter *filter, nsIMsgWindo
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (!forwardTo.IsEmpty())
|
||||
{
|
||||
nsCOMPtr <nsIMsgComposeService> compService = do_GetService (NS_MSGCOMPOSESERVICE_CONTRACTID) ;
|
||||
if (compService)
|
||||
rv = compService->ForwardMessage(NS_ConvertASCIItoUTF16(forwardTo), msgHdr, msgWindow, server);
|
||||
nsCOMPtr<nsIMsgComposeService> compService =
|
||||
do_GetService (NS_MSGCOMPOSESERVICE_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = compService->ForwardMessage(NS_ConvertASCIItoUTF16(forwardTo),
|
||||
msgHdr, msgWindow, server,
|
||||
nsIMsgComposeService::kForwardAsDefault);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -2273,9 +2273,12 @@ nsresult nsParseNewMailState::ApplyForwardAndReplyFilter(nsIMsgWindow *msgWindow
|
|||
rv = m_rootFolder->GetServer(getter_AddRefs(server));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
{
|
||||
nsCOMPtr <nsIMsgComposeService> compService = do_GetService (NS_MSGCOMPOSESERVICE_CONTRACTID) ;
|
||||
if (compService)
|
||||
rv = compService->ForwardMessage(forwardStr, m_msgToForwardOrReply, msgWindow, server);
|
||||
nsCOMPtr<nsIMsgComposeService> compService =
|
||||
do_GetService (NS_MSGCOMPOSESERVICE_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = compService->ForwardMessage(forwardStr, m_msgToForwardOrReply,
|
||||
msgWindow, server,
|
||||
nsIMsgComposeService::kForwardAsDefault);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ interface nsIMimeStreamConverterListener : nsISupports{
|
|||
* converters. Most of the code is just stuff that has been moved out
|
||||
* of nsIStreamConverter.idl to make it more generic.
|
||||
*/
|
||||
[scriptable, uuid(ed861e40-6901-4bb0-b9ec-7a8e7a79bb0e)]
|
||||
[scriptable, uuid(d894c833-29c5-495b-880c-9a9f847bfdc9)]
|
||||
interface nsIMimeStreamConverter : nsISupports {
|
||||
|
||||
/**
|
||||
|
@ -97,10 +97,20 @@ interface nsIMimeStreamConverter : nsISupports {
|
|||
void SetMimeHeadersListener(in nsIMimeStreamConverterListener listener, in nsMimeOutputType aType);
|
||||
|
||||
/**
|
||||
* This is used for forward inline.
|
||||
* This is used for forward inline, both as a filter action, and from the UI.
|
||||
*/
|
||||
attribute PRBool forwardInline;
|
||||
attribute boolean forwardInline;
|
||||
|
||||
/**
|
||||
* This is used for a forward inline filter action. When streaming is done,
|
||||
* we won't open a compose window with the editor contents.
|
||||
*/
|
||||
attribute boolean forwardInlineFilter;
|
||||
|
||||
/**
|
||||
* Address for the forward inline filter to forward the message to.
|
||||
*/
|
||||
attribute AString forwardToAddress;
|
||||
/**
|
||||
* Use the opposite compose format, used for forward inline.
|
||||
*/
|
||||
|
|
|
@ -181,22 +181,20 @@ mime_dump_attachments ( nsMsgAttachmentData *attachData )
|
|||
}
|
||||
#endif
|
||||
|
||||
nsresult
|
||||
CreateTheComposeWindow(nsIMsgCompFields * compFields,
|
||||
nsresult CreateComposeParams(nsCOMPtr<nsIMsgComposeParams> &pMsgComposeParams,
|
||||
nsIMsgCompFields * compFields,
|
||||
nsMsgAttachmentData *attachmentList,
|
||||
MSG_ComposeType composeType,
|
||||
MSG_ComposeFormat composeFormat,
|
||||
nsIMsgIdentity * identity,
|
||||
const char *originalMsgURI,
|
||||
nsIMsgDBHdr * origMsgHdr
|
||||
)
|
||||
nsIMsgDBHdr *origMsgHdr)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
mime_dump_attachments ( attachmentList );
|
||||
#endif
|
||||
|
||||
nsresult rv;
|
||||
nsMsgAttachmentData *curAttachment = attachmentList;
|
||||
if (curAttachment)
|
||||
{
|
||||
|
@ -227,11 +225,6 @@ CreateTheComposeWindow(nsIMsgCompFields * compFields,
|
|||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIMsgComposeService> msgComposeService =
|
||||
do_GetService(kCMsgComposeServiceCID, &rv);
|
||||
if ((NS_FAILED(rv)) || (!msgComposeService))
|
||||
return rv;
|
||||
|
||||
MSG_ComposeFormat format = composeFormat; // Format to actually use.
|
||||
if (identity && composeType == nsIMsgCompType::ForwardInline)
|
||||
{
|
||||
|
@ -245,9 +238,9 @@ CreateTheComposeWindow(nsIMsgCompFields * compFields,
|
|||
nsIMsgCompFormat::HTML : nsIMsgCompFormat::PlainText;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIMsgComposeParams> pMsgComposeParams (do_CreateInstance(NS_MSGCOMPOSEPARAMS_CONTRACTID, &rv));
|
||||
if (NS_SUCCEEDED(rv) && pMsgComposeParams)
|
||||
{
|
||||
pMsgComposeParams = do_CreateInstance(NS_MSGCOMPOSEPARAMS_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
pMsgComposeParams->SetType(composeType);
|
||||
pMsgComposeParams->SetFormat(format);
|
||||
pMsgComposeParams->SetIdentity(identity);
|
||||
|
@ -256,10 +249,67 @@ CreateTheComposeWindow(nsIMsgCompFields * compFields,
|
|||
pMsgComposeParams->SetOriginalMsgURI(originalMsgURI);
|
||||
if (origMsgHdr)
|
||||
pMsgComposeParams->SetOrigMsgHdr(origMsgHdr);
|
||||
|
||||
rv = msgComposeService->OpenComposeWindowWithParams(nsnull /* default chrome */, pMsgComposeParams);
|
||||
return NS_OK;
|
||||
}
|
||||
return rv;
|
||||
|
||||
nsresult
|
||||
CreateTheComposeWindow(nsIMsgCompFields * compFields,
|
||||
nsMsgAttachmentData *attachmentList,
|
||||
MSG_ComposeType composeType,
|
||||
MSG_ComposeFormat composeFormat,
|
||||
nsIMsgIdentity * identity,
|
||||
const char * originalMsgURI,
|
||||
nsIMsgDBHdr * origMsgHdr
|
||||
)
|
||||
{
|
||||
nsCOMPtr<nsIMsgComposeParams> pMsgComposeParams;
|
||||
nsresult rv = CreateComposeParams(pMsgComposeParams, compFields,
|
||||
attachmentList,
|
||||
composeType,
|
||||
composeFormat,
|
||||
identity,
|
||||
originalMsgURI,
|
||||
origMsgHdr);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIMsgComposeService> msgComposeService =
|
||||
do_GetService(kCMsgComposeServiceCID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return msgComposeService->OpenComposeWindowWithParams(nsnull /* default chrome */, pMsgComposeParams);
|
||||
}
|
||||
|
||||
nsresult
|
||||
SendTheMessage(nsIMsgCompFields * compFields,
|
||||
nsMsgAttachmentData *attachmentList,
|
||||
MSG_ComposeType composeType,
|
||||
MSG_ComposeFormat composeFormat,
|
||||
nsIMsgIdentity * identity,
|
||||
const char * originalMsgURI,
|
||||
nsIMsgDBHdr * origMsgHdr)
|
||||
{
|
||||
nsCOMPtr<nsIMsgComposeParams> pMsgComposeParams;
|
||||
nsresult rv = CreateComposeParams(pMsgComposeParams, compFields,
|
||||
attachmentList,
|
||||
composeType,
|
||||
composeFormat,
|
||||
identity,
|
||||
originalMsgURI,
|
||||
origMsgHdr);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIMsgComposeService> msgComposeService =
|
||||
do_GetService(kCMsgComposeServiceCID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
// create the nsIMsgCompose object to send the object
|
||||
nsCOMPtr<nsIMsgCompose> pMsgCompose (do_CreateInstance(NS_MSGCOMPOSE_CONTRACTID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
/** initialize nsIMsgCompose, Send the message, wait for send completion response **/
|
||||
rv = pMsgCompose->Initialize(nsnull, pMsgComposeParams) ;
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
return pMsgCompose->SendMsg(nsIMsgSend::nsMsgDeliverNow, identity, nsnull, nsnull, nsnull) ;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -1463,14 +1513,15 @@ mime_parse_stream_complete (nsMIMESession *stream)
|
|||
bodyLen = strlen(body);
|
||||
}
|
||||
|
||||
PRUint32 newbodylen = bodyLen + 12; //+11 chars for <pre> & </pre> tags
|
||||
//+13 chars for <pre> & </pre> tags and CRLF
|
||||
PRUint32 newbodylen = bodyLen + 14;
|
||||
char* newbody = (char *)PR_MALLOC (newbodylen);
|
||||
if (newbody)
|
||||
{
|
||||
*newbody = 0;
|
||||
PL_strcatn(newbody, newbodylen, "<PRE>");
|
||||
PL_strcatn(newbody, newbodylen, body);
|
||||
PL_strcatn(newbody, newbodylen, "</PRE>");
|
||||
PL_strcatn(newbody, newbodylen, "</PRE>"CRLF);
|
||||
PR_Free(body);
|
||||
body = newbody;
|
||||
}
|
||||
|
@ -1529,6 +1580,14 @@ mime_parse_stream_complete (nsMIMESession *stream)
|
|||
fields->ConvertBodyToPlainText();
|
||||
if (mdd->overrideComposeFormat)
|
||||
composeFormat = nsIMsgCompFormat::OppositeOfDefault;
|
||||
if (mdd->forwardInlineFilter)
|
||||
{
|
||||
fields->SetTo(mdd->forwardToAddress);
|
||||
SendTheMessage(fields, newAttachData, nsIMsgCompType::ForwardInline,
|
||||
composeFormat, mdd->identity, mdd->originalMsgURI,
|
||||
mdd->origMsgHdr);
|
||||
}
|
||||
else
|
||||
CreateTheComposeWindow(fields, newAttachData, nsIMsgCompType::ForwardInline, composeFormat, mdd->identity, mdd->originalMsgURI, mdd->origMsgHdr);
|
||||
}
|
||||
else
|
||||
|
@ -2040,6 +2099,8 @@ mime_bridge_create_draft_stream(
|
|||
}
|
||||
|
||||
newPluginObj2->GetForwardInline(&mdd->forwardInline);
|
||||
newPluginObj2->GetForwardInlineFilter(&mdd->forwardInlineFilter);
|
||||
newPluginObj2->GetForwardToAddress(mdd->forwardToAddress);
|
||||
newPluginObj2->GetOverrideComposeFormat(&mdd->overrideComposeFormat);
|
||||
newPluginObj2->GetIdentity(getter_AddRefs(mdd->identity));
|
||||
newPluginObj2->GetOriginalMsgURI(&mdd->originalMsgURI);
|
||||
|
|
|
@ -156,7 +156,9 @@ struct mime_draft_data
|
|||
MimeDecoderData *decoder_data;
|
||||
char *mailcharset; // get it from CHARSET of Content-Type
|
||||
PRBool forwardInline;
|
||||
PRBool forwardInlineFilter;
|
||||
PRBool overrideComposeFormat; // Override compose format (for forward inline).
|
||||
nsString forwardToAddress;
|
||||
nsCOMPtr<nsIMsgIdentity> identity;
|
||||
char *originalMsgURI; // the original URI of the message we are currently processing
|
||||
nsCOMPtr<nsIMsgDBHdr> origMsgHdr;
|
||||
|
|
|
@ -526,10 +526,11 @@ nsStreamConverter::nsStreamConverter()
|
|||
{
|
||||
// Init member variables...
|
||||
mWrapperOutput = PR_FALSE;
|
||||
mBridgeStream = NULL;
|
||||
mBridgeStream = nsnull;
|
||||
mOutputFormat = "text/html";
|
||||
mAlreadyKnowOutputType = PR_FALSE;
|
||||
mForwardInline = PR_FALSE;
|
||||
mForwardInlineFilter = PR_FALSE;
|
||||
mOverrideComposeFormat = PR_FALSE;
|
||||
|
||||
mPendingRequest = nsnull;
|
||||
|
@ -787,9 +788,23 @@ nsStreamConverter::SetMimeHeadersListener(nsIMimeStreamConverterListener *listen
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsStreamConverter::SetForwardInline(PRBool forwardInline)
|
||||
nsStreamConverter::SetForwardInline(PRBool aForwardInline)
|
||||
{
|
||||
mForwardInline = forwardInline;
|
||||
mForwardInline = aForwardInline;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsStreamConverter::GetForwardToAddress(nsAString &aAddress)
|
||||
{
|
||||
aAddress = mForwardToAddress;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsStreamConverter::SetForwardToAddress(const nsAString &aAddress)
|
||||
{
|
||||
mForwardToAddress = aAddress;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -810,10 +825,25 @@ nsStreamConverter::SetOverrideComposeFormat(PRBool aOverrideComposeFormat)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsStreamConverter::GetForwardInline(PRBool *result)
|
||||
nsStreamConverter::GetForwardInline(PRBool *aResult)
|
||||
{
|
||||
if (!result) return NS_ERROR_NULL_POINTER;
|
||||
*result = mForwardInline;
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
*aResult = mForwardInline;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsStreamConverter::GetForwardInlineFilter(PRBool *aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
*aResult = mForwardInlineFilter;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsStreamConverter::SetForwardInlineFilter(PRBool aForwardInlineFilter)
|
||||
{
|
||||
mForwardInlineFilter = aForwardInlineFilter;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -100,7 +100,9 @@ private:
|
|||
|
||||
nsCOMPtr<nsIMimeStreamConverterListener> mMimeStreamConverterListener;
|
||||
PRBool mForwardInline;
|
||||
PRBool mForwardInlineFilter;
|
||||
PRBool mOverrideComposeFormat;
|
||||
nsString mForwardToAddress;
|
||||
nsCOMPtr<nsIMsgIdentity> mIdentity;
|
||||
nsCString mOriginalMsgURI;
|
||||
nsCOMPtr<nsIMsgDBHdr> mOrigMsgHdr;
|
||||
|
|
Загрузка…
Ссылка в новой задаче