From 008becef89d287fee91645d9f2e2891a113ef33e Mon Sep 17 00:00:00 2001 From: "ducarroz%netscape.com" Date: Fri, 12 Mar 1999 20:39:16 +0000 Subject: [PATCH] Add ReplyMessage, ForwardMessage and SendMessage2 interface git-svn-id: svn://10.0.0.236/trunk@23970 18797224-902f-48f8-a5cc-f745e15eee43 --- .../compose/public/nsIDOMComposeAppCore.h | 11 +- .../compose/public/nsIDOMComposeAppCore.idl | 3 + .../mailnews/compose/src/nsComposeAppCore.cpp | 26 +++- .../compose/src/nsJSComposeAppCore.cpp | 138 +++++++++++++++++- 4 files changed, 171 insertions(+), 7 deletions(-) diff --git a/mozilla/mailnews/compose/public/nsIDOMComposeAppCore.h b/mozilla/mailnews/compose/public/nsIDOMComposeAppCore.h index d3c46522f59..af1ec837a9f 100644 --- a/mozilla/mailnews/compose/public/nsIDOMComposeAppCore.h +++ b/mozilla/mailnews/compose/public/nsIDOMComposeAppCore.h @@ -38,9 +38,18 @@ class nsIDOMComposeAppCore : public nsIDOMBaseAppCore { /* void NewMessage (in nsAutoString url); */ NS_IMETHOD NewMessage(nsAutoString& url) = 0; - /* void SendMessage (in nsAutoString addrTo, in nsAutoString addrCc, in nsAutoString addrBcc, in nsAutoString subject, in nsAutoString msg); */ + /* void ReplyMessage (in nsString url, in nsISupports originalMessage, in long type); */ + NS_IMETHOD ReplyMessage(nsAutoString& url, nsISupports * originalMessage, const PRInt32 type) = 0; + + /* void ForwardMessage (in nsString url, in nsISupports originalMessage, in long type); */ + NS_IMETHOD ForwardMessage(nsAutoString& url, nsISupports * originalMessage, const PRInt32 type) = 0; + + /* void SendMessage (in nsAutoString addrTo, in nsAutoString addrCc, in nsAutoString addrBcc, in nsAutoString subject, in nsAutoString msg); */ NS_IMETHOD SendMessage(nsAutoString& addrTo, nsAutoString& addrCc, nsAutoString& addrBcc, nsAutoString& subject, nsAutoString& msg) = 0; + /* void SendMessage2 (); */ + NS_IMETHOD SendMessage2(PRInt32 *_retval) = 0; + #ifdef XPIDL_JS_STUBS static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx); static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, nsIDOMComposeAppCore *priv); diff --git a/mozilla/mailnews/compose/public/nsIDOMComposeAppCore.idl b/mozilla/mailnews/compose/public/nsIDOMComposeAppCore.idl index ef81aa69bb0..2ebcf1838f9 100644 --- a/mozilla/mailnews/compose/public/nsIDOMComposeAppCore.idl +++ b/mozilla/mailnews/compose/public/nsIDOMComposeAppCore.idl @@ -31,9 +31,12 @@ interface nsIDOMComposeAppCore : nsIDOMBaseAppCore { void SetWindow(in nsIDOMWindow ptr); void CompleteCallback(in nsString script); void NewMessage(in nsString url); + void ReplyMessage(in nsString url, in nsISupports originalMessage, in long type); + void ForwardMessage(in nsString url, in nsISupports originalMessage, in long type); void SendMessage(in nsString addrTo, in nsString addrCc, in nsString addrBcc, in nsString subject, in nsString msg); + long SendMessage2(); }; /* hack to make MsgAppCore visible from AppCore */ diff --git a/mozilla/mailnews/compose/src/nsComposeAppCore.cpp b/mozilla/mailnews/compose/src/nsComposeAppCore.cpp index 8454220ae05..ffef3054b9e 100644 --- a/mozilla/mailnews/compose/src/nsComposeAppCore.cpp +++ b/mozilla/mailnews/compose/src/nsComposeAppCore.cpp @@ -89,8 +89,11 @@ public: NS_IMETHOD CompleteCallback(nsAutoString& aScript); NS_IMETHOD SetWindow(nsIDOMWindow* aWin); NS_IMETHOD NewMessage(nsAutoString& aUrl); + NS_IMETHOD ReplyMessage(nsAutoString& url, nsISupports * originalMessage, const PRInt32 type); + NS_IMETHOD ForwardMessage(nsAutoString& url, nsISupports * originalMessage, const PRInt32 type); NS_IMETHOD SendMessage(nsAutoString& aAddrTo, nsAutoString& aAddrCc, nsAutoString& aAddrBcc, nsAutoString& aSubject, nsAutoString& aMsg); + NS_IMETHOD SendMessage2(PRInt32 * _retval); protected: @@ -323,6 +326,20 @@ done: return NS_OK; } +NS_IMETHODIMP nsComposeAppCore::ReplyMessage(nsAutoString& url, nsISupports * originalMessage, + const PRInt32 type) +{ + NewMessage(url); + return NS_OK; +} + +NS_IMETHODIMP nsComposeAppCore::ForwardMessage(nsAutoString& url, nsISupports * originalMessage, + const PRInt32 type) +{ + NewMessage(url); + return NS_OK; +} + NS_IMETHODIMP nsComposeAppCore::SendMessage(nsAutoString& aAddrTo, nsAutoString& aAddrCc, nsAutoString& aAddrBcc, nsAutoString& aSubject, nsAutoString& aMsg) { @@ -391,7 +408,14 @@ NS_IMETHODIMP nsComposeAppCore::SendMessage(nsAutoString& aAddrTo, nsAutoString& return NS_OK; } - + +NS_IMETHODIMP nsComposeAppCore::SendMessage2(PRInt32 * _retval) +{ +// Need to retreive the fields here and then call the SendMessage() +// nsComposeAppCore::SendMessage(...) + return NS_OK; +} + extern "C" nsresult NS_NewComposeAppCore(nsIDOMComposeAppCore **aResult) diff --git a/mozilla/mailnews/compose/src/nsJSComposeAppCore.cpp b/mozilla/mailnews/compose/src/nsJSComposeAppCore.cpp index 635f653ae44..a4db1f584b5 100644 --- a/mozilla/mailnews/compose/src/nsJSComposeAppCore.cpp +++ b/mozilla/mailnews/compose/src/nsJSComposeAppCore.cpp @@ -243,6 +243,97 @@ ComposeAppCoreNewMessage(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, return JS_TRUE; } +// +// Native method ReplyMessage +// +PR_STATIC_CALLBACK(JSBool) +ComposeAppCoreReplyMessage(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMComposeAppCore *nativeThis = (nsIDOMComposeAppCore*)JS_GetPrivate(cx, obj); + JSBool rBool = JS_FALSE; + nsAutoString b0; + nsISupports * b1; + const nsString typeName; + long b2; + + *rval = JSVAL_NULL; + + // If there's no private data, this must be the prototype, so ignore + if (nsnull == nativeThis) { + return JS_TRUE; + } + + if (argc >= 3) { + + nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]); + + rBool = nsJSUtils::nsConvertJSValToObject((nsISupports**)&b1, nsISupports::GetIID(), + typeName, + cx, + argv[1]); + + b2 = argv[2]; + + if (!rBool && NS_OK != nativeThis->ReplyMessage(b0, b1, b2)) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + else { + JS_ReportError(cx, "Function ReplyMessage requires 3 parameters"); + return JS_FALSE; + } + + return JS_TRUE; +} + + +// +// Native method ForwardMessage +// +PR_STATIC_CALLBACK(JSBool) +ComposeAppCoreForwardMessage(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMComposeAppCore *nativeThis = (nsIDOMComposeAppCore*)JS_GetPrivate(cx, obj); + JSBool rBool = JS_FALSE; + nsAutoString b0; + nsISupports * b1; + const nsString typeName; + long b2; + + *rval = JSVAL_NULL; + + // If there's no private data, this must be the prototype, so ignore + if (nsnull == nativeThis) { + return JS_TRUE; + } + + if (argc >= 3) { + + nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]); + + rBool = nsJSUtils::nsConvertJSValToObject((nsISupports**)&b1, nsISupports::GetIID(), + typeName, + cx, + argv[1]); + + b2 = argv[2]; + + if (!rBool && NS_OK != nativeThis->ForwardMessage(b0, b1, b2)) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + else { + JS_ReportError(cx, "Function ForwardMessage requires 3 parameters"); + return JS_FALSE; + } + + return JS_TRUE; +} + // // Native method SendMessage @@ -280,7 +371,41 @@ ComposeAppCoreSendMessage(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, *rval = JSVAL_VOID; } else { - JS_ReportError(cx, "Function SendMessage requires 6 parameters"); + JS_ReportError(cx, "Function SendMessage requires 5 parameters"); + return JS_FALSE; + } + + return JS_TRUE; +} + + +// +// Native method SendMessage2 +// +PR_STATIC_CALLBACK(JSBool) +ComposeAppCoreSendMessage2(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMComposeAppCore *nativeThis = (nsIDOMComposeAppCore*)JS_GetPrivate(cx, obj); + JSBool rBool = JS_FALSE; + PRInt32 b0; + + *rval = JSVAL_NULL; + + // If there's no private data, this must be the prototype, so ignore + if (nsnull == nativeThis) { + return JS_TRUE; + } + + if (argc >= 0) { + + if (NS_OK != nativeThis->SendMessage2(&b0)) { + return JS_FALSE; + } + + *rval = (jsval) b0; + } + else { + JS_ReportError(cx, "Function SendMessage requires 1 parameters"); return JS_FALSE; } @@ -320,10 +445,13 @@ static JSPropertySpec ComposeAppCoreProperties[] = // static JSFunctionSpec ComposeAppCoreMethods[] = { - {"SetWindow", ComposeAppCoreSetWindow, 1}, - {"CompleteCallback", ComposeAppCoreCompleteCallback, 1}, - {"NewMessage", ComposeAppCoreNewMessage, 1}, - {"SendMessage", ComposeAppCoreSendMessage, 5}, + {"SetWindow", ComposeAppCoreSetWindow, 1}, + {"CompleteCallback", ComposeAppCoreCompleteCallback, 1}, + {"NewMessage", ComposeAppCoreNewMessage, 1}, + {"ReplyMessage", ComposeAppCoreReplyMessage, 3}, + {"ForwardMessage", ComposeAppCoreForwardMessage, 3}, + {"SendMessage", ComposeAppCoreSendMessage, 5}, + {"SendMessage2", ComposeAppCoreSendMessage2, 0}, {0} };