From f4f898af1f063ca73e9962b8cec9e44a5d8ff53f Mon Sep 17 00:00:00 2001 From: "jefft%netscape.com" Date: Sun, 14 Mar 1999 21:00:30 +0000 Subject: [PATCH] more reply/forward message implementation --- mailnews/compose/src/nsComposeAppCore.cpp | 65 ++++++++++++++++----- mailnews/compose/src/nsJSComposeAppCore.cpp | 12 ++-- 2 files changed, 58 insertions(+), 19 deletions(-) diff --git a/mailnews/compose/src/nsComposeAppCore.cpp b/mailnews/compose/src/nsComposeAppCore.cpp index d9725ec39d7..e34605ee1c9 100644 --- a/mailnews/compose/src/nsComposeAppCore.cpp +++ b/mailnews/compose/src/nsComposeAppCore.cpp @@ -54,6 +54,7 @@ // jefft #include "nsIXULWindowCallbacks.h" #include "nsIDocumentViewer.h" +#include "nsIRDFResource.h" static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID); static NS_DEFINE_IID(kIDocumentIID, nsIDocument::GetIID()); @@ -67,6 +68,7 @@ static NS_DEFINE_IID(kIMsgSendIID, NS_IMSGSEND_IID); static NS_DEFINE_CID(kMsgSendCID, NS_MSGSEND_CID); static NS_DEFINE_CID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID); +static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID); NS_BEGIN_EXTERN_C @@ -493,26 +495,41 @@ done: return NS_OK; } -NS_IMETHODIMP nsComposeAppCore::ReplyMessage(nsAutoString& url, nsIDOMXULTreeElement *tree, - nsIDOMNodeList *nodeList, nsIDOMMsgAppCore * msgAppCore, const PRInt32 replyType) +NS_IMETHODIMP nsComposeAppCore::ReplyMessage(nsAutoString& url, + nsIDOMXULTreeElement *tree, + nsIDOMNodeList *nodeList, + nsIDOMMsgAppCore * msgAppCore, + const PRInt32 replyType) { nsresult res; if (url && tree && nodeList && msgAppCore) { nsCOMPtr object; - res = msgAppCore->GetMessageHeader(tree, nodeList, getter_AddRefs(object)); + res = msgAppCore->GetRDFResourceForMessage(tree, nodeList, + getter_AddRefs(object)); if ((NS_SUCCEEDED(res)) && object) { nsCOMPtr message; - res = object->QueryInterface(nsIMessage::GetIID(), getter_AddRefs(message)); + res = object->QueryInterface(nsIMessage::GetIID(), + getter_AddRefs(message)); if ((NS_SUCCEEDED(res)) && message) { nsString aString; nsString bString = "Re: "; message->GetSubject(aString); - bString += aString; + bString = bString + aString; mMsgCompFields->SetSubject(bString.ToNewCString(), NULL); message->GetAuthor(aString); mMsgCompFields->SetTo(aString.ToNewCString(), NULL); + if (replyType == 1) + { + nsString cString, dString; + message->GetRecipients(cString); + message->GetCCList(dString); + if (cString.Length() > 0 && dString.Length() > 0) + cString = cString + ", "; + cString = cString + dString; + mMsgCompFields->SetCc(cString.ToNewCString(), NULL); + } /* We need to get more information out from the message. */ NewMessage(url); } @@ -521,27 +538,42 @@ NS_IMETHODIMP nsComposeAppCore::ReplyMessage(nsAutoString& url, nsIDOMXULTreeEle return NS_OK; } -NS_IMETHODIMP nsComposeAppCore::ForwardMessage(nsAutoString& url, nsIDOMXULTreeElement *tree, - nsIDOMNodeList *nodeList, nsIDOMMsgAppCore * msgAppCore, const PRInt32 forwardType) +NS_IMETHODIMP nsComposeAppCore::ForwardMessage(nsAutoString& url, + nsIDOMXULTreeElement *tree, + nsIDOMNodeList *nodeList, + nsIDOMMsgAppCore * msgAppCore, + const PRInt32 forwardType) { nsresult res; if (url && tree && nodeList && msgAppCore) { nsCOMPtr object; - res = msgAppCore->GetMessageHeader(tree, nodeList, getter_AddRefs(object)); + res = msgAppCore->GetRDFResourceForMessage(tree, nodeList, + getter_AddRefs(object)); if ((NS_SUCCEEDED(res)) && object) { nsCOMPtr message; - res = object->QueryInterface(nsIMessage::GetIID(), getter_AddRefs(message)); + res = object->QueryInterface(nsIMessage::GetIID(), + getter_AddRefs(message)); if ((NS_SUCCEEDED(res)) && message && mMsgCompFields) { nsString aString; nsString bString = "[Fwd: "; message->GetSubject(aString); - bString = bString + aString + "]"; + bString += aString; + bString += "]"; mMsgCompFields->SetSubject(bString.ToNewCString(), NULL); - message->GetAuthor(aString); - mMsgCompFields->SetTo(aString.ToNewCString(), NULL); /* We need to get more information out from the message. */ - NewMessage(url); + nsCOMPtr rdfResource; + res = object->QueryInterface(kIRDFResourceIID, + getter_AddRefs(rdfResource)); + if (rdfResource) + { + const char *uri = 0; + rdfResource->GetValue(&uri); + + nsString messageUri = uri; + + NewMessage(url); + } } } } @@ -549,8 +581,11 @@ NS_IMETHODIMP nsComposeAppCore::ForwardMessage(nsAutoString& url, nsIDOMXULTreeE } -NS_IMETHODIMP nsComposeAppCore::SendMessage(nsAutoString& aAddrTo, nsAutoString& aAddrCc, - nsAutoString& aAddrBcc, nsAutoString& aSubject, nsAutoString& aMsg) +NS_IMETHODIMP nsComposeAppCore::SendMessage(nsAutoString& aAddrTo, + nsAutoString& aAddrCc, + nsAutoString& aAddrBcc, + nsAutoString& aSubject, + nsAutoString& aMsg) { nsMsgCompPrefs pCompPrefs; char* pUserEmail = nsnull; diff --git a/mailnews/compose/src/nsJSComposeAppCore.cpp b/mailnews/compose/src/nsJSComposeAppCore.cpp index a5954c73ceb..4078287a39f 100644 --- a/mailnews/compose/src/nsJSComposeAppCore.cpp +++ b/mailnews/compose/src/nsJSComposeAppCore.cpp @@ -299,7 +299,8 @@ ComposeAppCoreReplyMessage(JSContext *cx, JSObject *obj, uintN argc, jsval *argv nsIDOMXULTreeElement * b1; nsIDOMNodeList * b2; nsIDOMMsgAppCore * b3; - long b4; + PRInt32 b4; + int32 i; const nsString typeName; *rval = JSVAL_NULL; @@ -328,7 +329,8 @@ ComposeAppCoreReplyMessage(JSContext *cx, JSObject *obj, uintN argc, jsval *argv cx, argv[3]); - b4 = argv[4]; + JS_ValueToInt32(cx, argv[4], &i); + b4 = i; if (!rBool || NS_OK != nativeThis->ReplyMessage(b0, b1, b2, b3, b4)) { return JS_FALSE; @@ -357,7 +359,8 @@ ComposeAppCoreForwardMessage(JSContext *cx, JSObject *obj, uintN argc, jsval *ar nsIDOMXULTreeElement * b1; nsIDOMNodeList * b2; nsIDOMMsgAppCore * b3; - long b4; + PRInt32 b4; + int32 i; const nsString typeName; *rval = JSVAL_NULL; @@ -386,7 +389,8 @@ ComposeAppCoreForwardMessage(JSContext *cx, JSObject *obj, uintN argc, jsval *ar cx, argv[3]); - b4 = argv[4]; + JS_ValueToInt32(cx, argv[4], &i); + b4 = 1; if (!rBool || NS_OK != nativeThis->ForwardMessage(b0, b1, b2, b3, b4)) { return JS_FALSE;