add forward inline filter action, r=rkent, sr=standard8, bug 312025
This commit is contained in:
Родитель
5adea0a8cf
Коммит
3dfe86f9b6
|
@ -669,23 +669,22 @@ nsresult nsMsgFilterAfterTheFact::ApplyFilter(PRBool *aApplyMore)
|
||||||
{
|
{
|
||||||
nsCString forwardTo;
|
nsCString forwardTo;
|
||||||
filterAction->GetStrValue(forwardTo);
|
filterAction->GetStrValue(forwardTo);
|
||||||
nsCOMPtr <nsIMsgIncomingServer> server;
|
nsCOMPtr<nsIMsgIncomingServer> server;
|
||||||
rv = m_curFolder->GetServer(getter_AddRefs(server));
|
rv = m_curFolder->GetServer(getter_AddRefs(server));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
if (!forwardTo.IsEmpty())
|
if (!forwardTo.IsEmpty())
|
||||||
{
|
{
|
||||||
nsCOMPtr <nsIMsgComposeService> compService = do_GetService (NS_MSGCOMPOSESERVICE_CONTRACTID) ;
|
nsCOMPtr<nsIMsgComposeService> compService =
|
||||||
if (compService)
|
do_GetService(NS_MSGCOMPOSESERVICE_CONTRACTID, &rv);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
for (PRUint32 msgIndex = 0; msgIndex < m_searchHits.Length(); msgIndex++)
|
||||||
{
|
{
|
||||||
for (PRUint32 msgIndex = 0; msgIndex < m_searchHits.Length(); msgIndex++)
|
nsCOMPtr<nsIMsgDBHdr> msgHdr(do_QueryElementAt(m_searchHitHdrs,
|
||||||
{
|
msgIndex));
|
||||||
nsCOMPtr <nsIMsgDBHdr> msgHdr;
|
if (msgHdr)
|
||||||
m_searchHitHdrs->QueryElementAt(msgIndex, NS_GET_IID(nsIMsgDBHdr), getter_AddRefs(msgHdr));
|
rv = compService->ForwardMessage(NS_ConvertASCIItoUTF16(forwardTo),
|
||||||
if (msgHdr)
|
msgHdr, m_msgWindow, server,
|
||||||
{
|
nsIMsgComposeService::kForwardAsDefault);
|
||||||
rv = compService->ForwardMessage(NS_ConvertASCIItoUTF16(forwardTo), msgHdr, m_msgWindow, server);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ interface nsIMsgIdentity;
|
||||||
interface nsIMsgIncomingServer;
|
interface nsIMsgIncomingServer;
|
||||||
interface nsIMsgDBHdr;
|
interface nsIMsgDBHdr;
|
||||||
|
|
||||||
[scriptable, uuid(ce5f77c8-f278-4ec7-b8dd-ea9dc84af137)]
|
[scriptable, uuid(dbf4b3a7-dc38-4362-a620-ff5d22b3777c)]
|
||||||
interface nsIMsgComposeService : nsISupports {
|
interface nsIMsgComposeService : nsISupports {
|
||||||
|
|
||||||
/* we need a msg window because when we forward inline we may need progress */
|
/* 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);
|
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).
|
* Allow filters to automatically forward a message to the given address(es).
|
||||||
* @param forwardTo the address(es) to forward to
|
* @param forwardTo the address(es) to forward to
|
||||||
* @param msgHdr the header of the message being replied to
|
* @param msgHdr the header of the message being replied to
|
||||||
* @param msgWindow message window to use
|
* @param msgWindow message window to use
|
||||||
* @param server server to use for determining which account to send from
|
* @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,
|
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
|
* 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 ?
|
return LoadDraftOrTemplate(uriToOpen, type == nsIMsgCompType::ForwardInline || type == nsIMsgCompType::Draft ?
|
||||||
nsMimeOutput::nsMimeMessageDraftOrTemplate : nsMimeOutput::nsMimeMessageEditorTemplate,
|
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));
|
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);
|
return folder->AddMessageDispositionState(aMsgHdr, nsIMsgFolder::nsMsgDispositionState_Replied);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsMsgComposeService::ForwardMessage(const nsAString &forwardTo, nsIMsgDBHdr *aMsgHdr,
|
NS_IMETHODIMP
|
||||||
nsIMsgWindow *aMsgWindow, nsIMsgIncomingServer *aServer)
|
nsMsgComposeService::ForwardMessage(const nsAString &forwardTo,
|
||||||
|
nsIMsgDBHdr *aMsgHdr,
|
||||||
|
nsIMsgWindow *aMsgWindow,
|
||||||
|
nsIMsgIncomingServer *aServer,
|
||||||
|
PRUint32 aForwardType)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aMsgHdr);
|
NS_ENSURE_ARG_POINTER(aMsgHdr);
|
||||||
|
|
||||||
nsresult rv;
|
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;
|
nsCOMPtr<nsIDOMWindowInternal> parentWindow;
|
||||||
if (aMsgWindow)
|
if (aMsgWindow)
|
||||||
{
|
{
|
||||||
|
@ -1227,41 +1272,14 @@ NS_IMETHODIMP nsMsgComposeService::ForwardMessage(const nsAString &forwardTo, ns
|
||||||
parentWindow = do_GetInterface(docShell);
|
parentWindow = do_GetInterface(docShell);
|
||||||
NS_ENSURE_TRUE(parentWindow, NS_ERROR_FAILURE);
|
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
|
// create the compose params object
|
||||||
nsCOMPtr<nsIMsgComposeParams> pMsgComposeParams (do_CreateInstance(NS_MSGCOMPOSEPARAMS_CONTRACTID, &rv));
|
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) ;
|
nsCOMPtr<nsIMsgCompFields> compFields = do_CreateInstance(NS_MSGCOMPFIELDS_CONTRACTID, &rv);
|
||||||
|
|
||||||
compFields->SetTo(forwardTo);
|
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
|
// populate the compose params
|
||||||
// right now, forward inline won't work, since that requires opening a compose window,
|
pMsgComposeParams->SetType(nsIMsgCompType::ForwardAsAttachment);
|
||||||
// and would require major whackage of the compose code.
|
|
||||||
pMsgComposeParams->SetType(/* forwardType ? nsIMsgCompType::ForwardInline : */nsIMsgCompType::ForwardAsAttachment);
|
|
||||||
pMsgComposeParams->SetFormat(nsIMsgCompFormat::Default);
|
pMsgComposeParams->SetFormat(nsIMsgCompFormat::Default);
|
||||||
pMsgComposeParams->SetIdentity(identity);
|
pMsgComposeParams->SetIdentity(identity);
|
||||||
pMsgComposeParams->SetComposeFields(compFields);
|
pMsgComposeParams->SetComposeFields(compFields);
|
||||||
|
@ -1517,23 +1535,66 @@ nsresult
|
||||||
nsMsgComposeService::LoadDraftOrTemplate(const nsACString& aMsgURI, nsMimeOutputType aOutType,
|
nsMsgComposeService::LoadDraftOrTemplate(const nsACString& aMsgURI, nsMimeOutputType aOutType,
|
||||||
nsIMsgIdentity * aIdentity, const char * aOriginalMsgURI,
|
nsIMsgIdentity * aIdentity, const char * aOriginalMsgURI,
|
||||||
nsIMsgDBHdr * aOrigMsgHdr,
|
nsIMsgDBHdr * aOrigMsgHdr,
|
||||||
PRBool aAddInlineHeaders,
|
PRBool aForwardInline,
|
||||||
MSG_ComposeFormat format,
|
PRBool overrideComposeFormat,
|
||||||
nsIMsgWindow *aMsgWindow)
|
nsIMsgWindow *aMsgWindow)
|
||||||
{
|
{
|
||||||
nsresult rv;
|
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)
|
||||||
|
{
|
||||||
nsCOMPtr <nsIMsgMessageService> messageService;
|
nsCOMPtr <nsIMsgMessageService> messageService;
|
||||||
rv = GetMessageServiceFromURI(aMsgURI, getter_AddRefs(messageService));
|
nsresult rv = GetMessageServiceFromURI(aMsgURI, getter_AddRefs(messageService));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
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 =
|
nsCOMPtr<nsIMimeStreamConverter> mimeConverter =
|
||||||
do_CreateInstance(NS_MAILNEWS_MIME_STREAM_CONVERTER_CONTRACTID, &rv);
|
do_CreateInstance(NS_MAILNEWS_MIME_STREAM_CONVERTER_CONTRACTID, &rv);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
mimeConverter->SetMimeOutputType(aOutType); // Set the type of output for libmime
|
mimeConverter->SetMimeOutputType(aOutType); // Set the type of output for libmime
|
||||||
mimeConverter->SetForwardInline(aAddInlineHeaders);
|
mimeConverter->SetForwardInline(aForwardInline);
|
||||||
mimeConverter->SetOverrideComposeFormat(format == nsIMsgCompFormat::OppositeOfDefault);
|
if (!aForwardTo.IsEmpty())
|
||||||
|
{
|
||||||
|
mimeConverter->SetForwardInlineFilter(PR_TRUE);
|
||||||
|
mimeConverter->SetForwardToAddress(aForwardTo);
|
||||||
|
}
|
||||||
|
mimeConverter->SetOverrideComposeFormat(aOverrideComposeFormat);
|
||||||
mimeConverter->SetIdentity(aIdentity);
|
mimeConverter->SetIdentity(aIdentity);
|
||||||
mimeConverter->SetOriginalMsgURI(aOriginalMsgURI);
|
mimeConverter->SetOriginalMsgURI(aOriginalMsgURI);
|
||||||
mimeConverter->SetOrigMsgHdr(aOrigMsgHdr);
|
mimeConverter->SetOrigMsgHdr(aOrigMsgHdr);
|
||||||
|
|
|
@ -100,10 +100,20 @@ private:
|
||||||
|
|
||||||
nsresult LoadDraftOrTemplate(const nsACString& aMsgURI, nsMimeOutputType aOutType,
|
nsresult LoadDraftOrTemplate(const nsACString& aMsgURI, nsMimeOutputType aOutType,
|
||||||
nsIMsgIdentity * aIdentity, const char * aOriginalMsgURI,
|
nsIMsgIdentity * aIdentity, const char * aOriginalMsgURI,
|
||||||
nsIMsgDBHdr * aOrigMsgHdr, PRBool aAddInlineHeaders,
|
nsIMsgDBHdr * aOrigMsgHdr, PRBool aForwardInline,
|
||||||
MSG_ComposeFormat format,
|
MSG_ComposeFormat format,
|
||||||
nsIMsgWindow *aMsgWindow);
|
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);
|
nsresult ShowCachedComposeWindow(nsIDOMWindowInternal *aComposeWindow, PRBool aShow);
|
||||||
|
|
||||||
// hash table mapping dom windows to nsIMsgCompose objects
|
// hash table mapping dom windows to nsIMsgCompose objects
|
||||||
|
|
|
@ -3616,14 +3616,17 @@ NS_IMETHODIMP nsImapMailFolder::ApplyFilterHit(nsIMsgFilter *filter, nsIMsgWindo
|
||||||
{
|
{
|
||||||
nsCString forwardTo;
|
nsCString forwardTo;
|
||||||
filterAction->GetStrValue(forwardTo);
|
filterAction->GetStrValue(forwardTo);
|
||||||
nsCOMPtr <nsIMsgIncomingServer> server;
|
nsCOMPtr<nsIMsgIncomingServer> server;
|
||||||
rv = GetServer(getter_AddRefs(server));
|
rv = GetServer(getter_AddRefs(server));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
if (!forwardTo.IsEmpty())
|
if (!forwardTo.IsEmpty())
|
||||||
{
|
{
|
||||||
nsCOMPtr <nsIMsgComposeService> compService = do_GetService (NS_MSGCOMPOSESERVICE_CONTRACTID) ;
|
nsCOMPtr<nsIMsgComposeService> compService =
|
||||||
if (compService)
|
do_GetService (NS_MSGCOMPOSESERVICE_CONTRACTID, &rv);
|
||||||
rv = compService->ForwardMessage(NS_ConvertASCIItoUTF16(forwardTo), msgHdr, msgWindow, server);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
rv = compService->ForwardMessage(NS_ConvertASCIItoUTF16(forwardTo),
|
||||||
|
msgHdr, msgWindow, server,
|
||||||
|
nsIMsgComposeService::kForwardAsDefault);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -2273,9 +2273,12 @@ nsresult nsParseNewMailState::ApplyForwardAndReplyFilter(nsIMsgWindow *msgWindow
|
||||||
rv = m_rootFolder->GetServer(getter_AddRefs(server));
|
rv = m_rootFolder->GetServer(getter_AddRefs(server));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
{
|
{
|
||||||
nsCOMPtr <nsIMsgComposeService> compService = do_GetService (NS_MSGCOMPOSESERVICE_CONTRACTID) ;
|
nsCOMPtr<nsIMsgComposeService> compService =
|
||||||
if (compService)
|
do_GetService (NS_MSGCOMPOSESERVICE_CONTRACTID, &rv);
|
||||||
rv = compService->ForwardMessage(forwardStr, m_msgToForwardOrReply, msgWindow, server);
|
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
|
* converters. Most of the code is just stuff that has been moved out
|
||||||
* of nsIStreamConverter.idl to make it more generic.
|
* 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 {
|
interface nsIMimeStreamConverter : nsISupports {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -97,10 +97,20 @@ interface nsIMimeStreamConverter : nsISupports {
|
||||||
void SetMimeHeadersListener(in nsIMimeStreamConverterListener listener, in nsMimeOutputType aType);
|
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.
|
* Use the opposite compose format, used for forward inline.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -181,22 +181,20 @@ mime_dump_attachments ( nsMsgAttachmentData *attachData )
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
nsresult
|
nsresult CreateComposeParams(nsCOMPtr<nsIMsgComposeParams> &pMsgComposeParams,
|
||||||
CreateTheComposeWindow(nsIMsgCompFields * compFields,
|
nsIMsgCompFields * compFields,
|
||||||
nsMsgAttachmentData *attachmentList,
|
nsMsgAttachmentData *attachmentList,
|
||||||
MSG_ComposeType composeType,
|
MSG_ComposeType composeType,
|
||||||
MSG_ComposeFormat composeFormat,
|
MSG_ComposeFormat composeFormat,
|
||||||
nsIMsgIdentity * identity,
|
nsIMsgIdentity * identity,
|
||||||
const char * originalMsgURI,
|
const char *originalMsgURI,
|
||||||
nsIMsgDBHdr * origMsgHdr
|
nsIMsgDBHdr *origMsgHdr)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
nsresult rv;
|
|
||||||
|
|
||||||
#ifdef NS_DEBUG
|
#ifdef NS_DEBUG
|
||||||
mime_dump_attachments ( attachmentList );
|
mime_dump_attachments ( attachmentList );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
nsresult rv;
|
||||||
nsMsgAttachmentData *curAttachment = attachmentList;
|
nsMsgAttachmentData *curAttachment = attachmentList;
|
||||||
if (curAttachment)
|
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.
|
MSG_ComposeFormat format = composeFormat; // Format to actually use.
|
||||||
if (identity && composeType == nsIMsgCompType::ForwardInline)
|
if (identity && composeType == nsIMsgCompType::ForwardInline)
|
||||||
{
|
{
|
||||||
|
@ -245,21 +238,78 @@ CreateTheComposeWindow(nsIMsgCompFields * compFields,
|
||||||
nsIMsgCompFormat::HTML : nsIMsgCompFormat::PlainText;
|
nsIMsgCompFormat::HTML : nsIMsgCompFormat::PlainText;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIMsgComposeParams> pMsgComposeParams (do_CreateInstance(NS_MSGCOMPOSEPARAMS_CONTRACTID, &rv));
|
pMsgComposeParams = do_CreateInstance(NS_MSGCOMPOSEPARAMS_CONTRACTID, &rv);
|
||||||
if (NS_SUCCEEDED(rv) && pMsgComposeParams)
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
{
|
|
||||||
pMsgComposeParams->SetType(composeType);
|
|
||||||
pMsgComposeParams->SetFormat(format);
|
|
||||||
pMsgComposeParams->SetIdentity(identity);
|
|
||||||
pMsgComposeParams->SetComposeFields(compFields);
|
|
||||||
if (originalMsgURI)
|
|
||||||
pMsgComposeParams->SetOriginalMsgURI(originalMsgURI);
|
|
||||||
if (origMsgHdr)
|
|
||||||
pMsgComposeParams->SetOrigMsgHdr(origMsgHdr);
|
|
||||||
|
|
||||||
rv = msgComposeService->OpenComposeWindowWithParams(nsnull /* default chrome */, pMsgComposeParams);
|
pMsgComposeParams->SetType(composeType);
|
||||||
}
|
pMsgComposeParams->SetFormat(format);
|
||||||
return rv;
|
pMsgComposeParams->SetIdentity(identity);
|
||||||
|
pMsgComposeParams->SetComposeFields(compFields);
|
||||||
|
if (originalMsgURI)
|
||||||
|
pMsgComposeParams->SetOriginalMsgURI(originalMsgURI);
|
||||||
|
if (origMsgHdr)
|
||||||
|
pMsgComposeParams->SetOrigMsgHdr(origMsgHdr);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
nsresult
|
||||||
|
@ -1463,14 +1513,15 @@ mime_parse_stream_complete (nsMIMESession *stream)
|
||||||
bodyLen = strlen(body);
|
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);
|
char* newbody = (char *)PR_MALLOC (newbodylen);
|
||||||
if (newbody)
|
if (newbody)
|
||||||
{
|
{
|
||||||
*newbody = 0;
|
*newbody = 0;
|
||||||
PL_strcatn(newbody, newbodylen, "<PRE>");
|
PL_strcatn(newbody, newbodylen, "<PRE>");
|
||||||
PL_strcatn(newbody, newbodylen, body);
|
PL_strcatn(newbody, newbodylen, body);
|
||||||
PL_strcatn(newbody, newbodylen, "</PRE>");
|
PL_strcatn(newbody, newbodylen, "</PRE>"CRLF);
|
||||||
PR_Free(body);
|
PR_Free(body);
|
||||||
body = newbody;
|
body = newbody;
|
||||||
}
|
}
|
||||||
|
@ -1529,7 +1580,15 @@ mime_parse_stream_complete (nsMIMESession *stream)
|
||||||
fields->ConvertBodyToPlainText();
|
fields->ConvertBodyToPlainText();
|
||||||
if (mdd->overrideComposeFormat)
|
if (mdd->overrideComposeFormat)
|
||||||
composeFormat = nsIMsgCompFormat::OppositeOfDefault;
|
composeFormat = nsIMsgCompFormat::OppositeOfDefault;
|
||||||
CreateTheComposeWindow(fields, newAttachData, nsIMsgCompType::ForwardInline, composeFormat, mdd->identity, mdd->originalMsgURI, mdd->origMsgHdr);
|
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
|
else
|
||||||
{
|
{
|
||||||
|
@ -2040,6 +2099,8 @@ mime_bridge_create_draft_stream(
|
||||||
}
|
}
|
||||||
|
|
||||||
newPluginObj2->GetForwardInline(&mdd->forwardInline);
|
newPluginObj2->GetForwardInline(&mdd->forwardInline);
|
||||||
|
newPluginObj2->GetForwardInlineFilter(&mdd->forwardInlineFilter);
|
||||||
|
newPluginObj2->GetForwardToAddress(mdd->forwardToAddress);
|
||||||
newPluginObj2->GetOverrideComposeFormat(&mdd->overrideComposeFormat);
|
newPluginObj2->GetOverrideComposeFormat(&mdd->overrideComposeFormat);
|
||||||
newPluginObj2->GetIdentity(getter_AddRefs(mdd->identity));
|
newPluginObj2->GetIdentity(getter_AddRefs(mdd->identity));
|
||||||
newPluginObj2->GetOriginalMsgURI(&mdd->originalMsgURI);
|
newPluginObj2->GetOriginalMsgURI(&mdd->originalMsgURI);
|
||||||
|
|
|
@ -156,7 +156,9 @@ struct mime_draft_data
|
||||||
MimeDecoderData *decoder_data;
|
MimeDecoderData *decoder_data;
|
||||||
char *mailcharset; // get it from CHARSET of Content-Type
|
char *mailcharset; // get it from CHARSET of Content-Type
|
||||||
PRBool forwardInline;
|
PRBool forwardInline;
|
||||||
|
PRBool forwardInlineFilter;
|
||||||
PRBool overrideComposeFormat; // Override compose format (for forward inline).
|
PRBool overrideComposeFormat; // Override compose format (for forward inline).
|
||||||
|
nsString forwardToAddress;
|
||||||
nsCOMPtr<nsIMsgIdentity> identity;
|
nsCOMPtr<nsIMsgIdentity> identity;
|
||||||
char *originalMsgURI; // the original URI of the message we are currently processing
|
char *originalMsgURI; // the original URI of the message we are currently processing
|
||||||
nsCOMPtr<nsIMsgDBHdr> origMsgHdr;
|
nsCOMPtr<nsIMsgDBHdr> origMsgHdr;
|
||||||
|
|
|
@ -526,10 +526,11 @@ nsStreamConverter::nsStreamConverter()
|
||||||
{
|
{
|
||||||
// Init member variables...
|
// Init member variables...
|
||||||
mWrapperOutput = PR_FALSE;
|
mWrapperOutput = PR_FALSE;
|
||||||
mBridgeStream = NULL;
|
mBridgeStream = nsnull;
|
||||||
mOutputFormat = "text/html";
|
mOutputFormat = "text/html";
|
||||||
mAlreadyKnowOutputType = PR_FALSE;
|
mAlreadyKnowOutputType = PR_FALSE;
|
||||||
mForwardInline = PR_FALSE;
|
mForwardInline = PR_FALSE;
|
||||||
|
mForwardInlineFilter = PR_FALSE;
|
||||||
mOverrideComposeFormat = PR_FALSE;
|
mOverrideComposeFormat = PR_FALSE;
|
||||||
|
|
||||||
mPendingRequest = nsnull;
|
mPendingRequest = nsnull;
|
||||||
|
@ -787,9 +788,23 @@ nsStreamConverter::SetMimeHeadersListener(nsIMimeStreamConverterListener *listen
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
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;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -810,10 +825,25 @@ nsStreamConverter::SetOverrideComposeFormat(PRBool aOverrideComposeFormat)
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsStreamConverter::GetForwardInline(PRBool *result)
|
nsStreamConverter::GetForwardInline(PRBool *aResult)
|
||||||
{
|
{
|
||||||
if (!result) return NS_ERROR_NULL_POINTER;
|
NS_ENSURE_ARG_POINTER(aResult);
|
||||||
*result = mForwardInline;
|
*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;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,8 +48,8 @@
|
||||||
#include "nsStringGlue.h"
|
#include "nsStringGlue.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
|
|
||||||
class nsStreamConverter : public nsIStreamConverter, public nsIMimeStreamConverter {
|
class nsStreamConverter : public nsIStreamConverter, public nsIMimeStreamConverter {
|
||||||
public:
|
public:
|
||||||
nsStreamConverter();
|
nsStreamConverter();
|
||||||
virtual ~nsStreamConverter();
|
virtual ~nsStreamConverter();
|
||||||
|
|
||||||
|
@ -100,7 +100,9 @@ private:
|
||||||
|
|
||||||
nsCOMPtr<nsIMimeStreamConverterListener> mMimeStreamConverterListener;
|
nsCOMPtr<nsIMimeStreamConverterListener> mMimeStreamConverterListener;
|
||||||
PRBool mForwardInline;
|
PRBool mForwardInline;
|
||||||
|
PRBool mForwardInlineFilter;
|
||||||
PRBool mOverrideComposeFormat;
|
PRBool mOverrideComposeFormat;
|
||||||
|
nsString mForwardToAddress;
|
||||||
nsCOMPtr<nsIMsgIdentity> mIdentity;
|
nsCOMPtr<nsIMsgIdentity> mIdentity;
|
||||||
nsCString mOriginalMsgURI;
|
nsCString mOriginalMsgURI;
|
||||||
nsCOMPtr<nsIMsgDBHdr> mOrigMsgHdr;
|
nsCOMPtr<nsIMsgDBHdr> mOrigMsgHdr;
|
||||||
|
@ -112,6 +114,6 @@ private:
|
||||||
#endif
|
#endif
|
||||||
nsIRequest * mPendingRequest; // used when we need to delay to fire onStartRequest
|
nsIRequest * mPendingRequest; // used when we need to delay to fire onStartRequest
|
||||||
nsISupports * mPendingContext; // used when we need to delay to fire onStartRequest
|
nsISupports * mPendingContext; // used when we need to delay to fire onStartRequest
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* nsStreamConverter_h_ */
|
#endif /* nsStreamConverter_h_ */
|
||||||
|
|
Загрузка…
Ссылка в новой задаче