mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-05 15:59:45 +00:00
Add properties WrapColumn and UseHtml
This commit is contained in:
parent
6803bfe90e
commit
4d7d12d1c8
@ -53,6 +53,14 @@ class nsIDOMComposeAppCore : public nsIDOMBaseAppCore {
|
||||
/* long SendMessage2 (); */
|
||||
NS_IMETHOD SendMessage2(PRInt32 *_retval) = 0;
|
||||
|
||||
/* attribute bool useHtml; */
|
||||
NS_IMETHOD GetUseHtml(PRBool *aUseHtml) = 0;
|
||||
NS_IMETHOD SetUseHtml(PRBool aUseHtml) = 0;
|
||||
|
||||
/* readonly attribute long wrapColumn; */
|
||||
NS_IMETHOD GetWrapColumn(PRInt32 *aWrapColumn) = 0;
|
||||
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);
|
||||
static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, nsIDOMComposeAppCore *priv);
|
||||
|
@ -47,6 +47,9 @@ interface nsIDOMComposeAppCore : nsIDOMBaseAppCore {
|
||||
in nsAutoString subject,
|
||||
in nsAutoString msg);
|
||||
long SendMessage2();
|
||||
|
||||
attribute boolean useHtml;
|
||||
readonly attribute long wrappingPosition;
|
||||
};
|
||||
|
||||
/* hack to make MsgAppCore visible from AppCore */
|
||||
|
@ -55,6 +55,7 @@
|
||||
#include "nsIMsgCompose.h"
|
||||
#include "nsIMsgCompFields.h"
|
||||
#include "nsIMsgSend.h"
|
||||
#include "nsMsgCompPrefs.h"
|
||||
|
||||
// jefft
|
||||
#include "nsIXULWindowCallbacks.h"
|
||||
@ -144,6 +145,9 @@ public:
|
||||
nsAutoString& aSubject,
|
||||
nsAutoString& aMsg);
|
||||
NS_IMETHOD SendMessage2(PRInt32 * _retval);
|
||||
NS_IMETHOD GetUseHtml(PRBool *_retval);
|
||||
NS_IMETHOD SetUseHtml(PRBool aUseHtml);
|
||||
NS_IMETHOD GetWrapColumn(PRInt32 * _retval);
|
||||
|
||||
protected:
|
||||
|
||||
@ -161,11 +165,14 @@ protected:
|
||||
nsIWebShellWindow *mWebShellWindow;
|
||||
nsIDOMEditorAppCore *mEditor;
|
||||
|
||||
nsIMsgCompFields *mMsgCompFields;
|
||||
nsIMsgSend *mMsgSend;
|
||||
nsIMsgCompFields *mMsgCompFields;
|
||||
nsIMsgSend *mMsgSend;
|
||||
|
||||
nsAutoString mArgs;
|
||||
nsAutoString mArgs;
|
||||
|
||||
PRBool mUseHtml;
|
||||
PRInt32 mWrapColumn;
|
||||
|
||||
// ****** Hack Alert ***** Hack Alert ***** Hack Alert *****
|
||||
void HackToGetBody(PRInt32 what);
|
||||
};
|
||||
@ -229,6 +236,8 @@ static nsresult setAttribute( nsIWebShell *shell,
|
||||
//
|
||||
nsComposeAppCore::nsComposeAppCore()
|
||||
{
|
||||
nsMsgCompPrefs prefs;
|
||||
|
||||
NS_INIT_REFCNT();
|
||||
mScriptObject = nsnull;
|
||||
mWebShell = nsnull;
|
||||
@ -238,6 +247,8 @@ nsComposeAppCore::nsComposeAppCore()
|
||||
mEditor = nsnull;
|
||||
mMsgCompFields = nsnull;
|
||||
mMsgSend = nsnull;
|
||||
mUseHtml = prefs.GetUseHtml();
|
||||
mWrapColumn = prefs.GetWrapColumn();
|
||||
}
|
||||
|
||||
nsComposeAppCore::~nsComposeAppCore()
|
||||
@ -858,18 +869,18 @@ NS_IMETHODIMP nsComposeAppCore::SendMsg(nsAutoString& aAddrTo,
|
||||
if (mMsgSend)
|
||||
{
|
||||
mMsgSend->SendMessage(mMsgCompFields,
|
||||
"", // const char *smtp,
|
||||
PR_FALSE, // PRBool digest_p,
|
||||
PR_FALSE, // PRBool dont_deliver_p,
|
||||
nsMsgDeliverNow, // nsMsgDeliverMode mode,
|
||||
TEXT_HTML, // const char *attachment1_type,
|
||||
nsAutoCString(aMsg), // const char *attachment1_body,
|
||||
PL_strlen(nsAutoCString(aMsg)), // PRUint32 attachment1_body_length,
|
||||
NULL, // const struct nsMsgAttachmentData *attachments,
|
||||
NULL, // const struct nsMsgAttachedFile *preloaded_attachments,
|
||||
NULL, // nsMsgSendPart *relatedPart,
|
||||
NULL); // void (*message_delivery_done_callback)(MWContext *context, void *fe_data,
|
||||
// int status, const char *error_message))
|
||||
"", // const char *smtp,
|
||||
PR_FALSE, // PRBool digest_p,
|
||||
PR_FALSE, // PRBool dont_deliver_p,
|
||||
nsMsgDeliverNow, // nsMsgDeliverMode mode,
|
||||
mUseHtml?TEXT_HTML:TEXT_PLAIN, // const char *attachment1_type,
|
||||
nsAutoCString(aMsg), // const char *attachment1_body,
|
||||
PL_strlen(nsAutoCString(aMsg)), // PRUint32 attachment1_body_length,
|
||||
NULL, // const struct nsMsgAttachmentData *attachments,
|
||||
NULL, // const struct nsMsgAttachedFile *preloaded_attachments,
|
||||
NULL, // nsMsgSendPart *relatedPart,
|
||||
NULL); // void (*message_delivery_done_callback)(MWContext *context, void *fe_data,
|
||||
// int status, const char *error_message))
|
||||
}
|
||||
}
|
||||
if (nsnull != mScriptContext) {
|
||||
@ -942,8 +953,11 @@ NS_IMETHODIMP nsComposeAppCore::SendMessage2(PRInt32 * _retval)
|
||||
|
||||
if (mEditor)
|
||||
{
|
||||
mEditor->GetContentsAsText(msgBody);
|
||||
SendMsg(msgTo, msgCc, msgBcc, msgNewsgroup, msgSubject, msgBody);
|
||||
if (mUseHtml)
|
||||
mEditor->GetContentsAsHTML(msgBody);
|
||||
else
|
||||
mEditor->GetContentsAsText(msgBody);
|
||||
*_retval = SendMsg(msgTo, msgCc, msgBcc, msgNewsgroup, msgSubject, msgBody);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -951,7 +965,26 @@ NS_IMETHODIMP nsComposeAppCore::SendMessage2(PRInt32 * _retval)
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsComposeAppCore::GetUseHtml(PRBool *_retVal)
|
||||
{
|
||||
*_retVal = mUseHtml;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsComposeAppCore::SetUseHtml(PRBool aUseHtml)
|
||||
{
|
||||
mUseHtml = aUseHtml;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsComposeAppCore::GetWrapColumn(PRInt32 *_retval)
|
||||
{
|
||||
*_retval = mWrapColumn;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
extern "C"
|
||||
nsresult
|
||||
NS_NewComposeAppCore(const nsIID &aIID, void **aResult)
|
||||
|
@ -45,6 +45,14 @@ NS_DEF_PTR(nsIDOMComposeAppCore);
|
||||
NS_DEF_PTR(nsIDOMWindow);
|
||||
|
||||
|
||||
//
|
||||
// nsIDOMComposeAppCore property ids
|
||||
//
|
||||
enum nsIDOMComposeAppCore_slots {
|
||||
NSIDOMCOMPOSEAPPCORE_USEHTML = -1,
|
||||
NSIDOMCOMPOSEAPPCORE_WRAPCOLUMN = -2
|
||||
};
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// ComposeAppCore Properties Getter
|
||||
@ -61,7 +69,28 @@ GetComposeAppCoreProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case 0:
|
||||
case NSIDOMCOMPOSEAPPCORE_USEHTML:
|
||||
{
|
||||
PRBool prop;
|
||||
if (NS_OK == a->GetUseHtml(&prop)) {
|
||||
*vp = BOOLEAN_TO_JSVAL(prop);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case NSIDOMCOMPOSEAPPCORE_WRAPCOLUMN:
|
||||
{
|
||||
PRInt32 prop;
|
||||
if (NS_OK == a->GetWrapColumn(&prop)) {
|
||||
*vp = INT_TO_JSVAL(prop);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
@ -89,7 +118,17 @@ SetComposeAppCoreProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case 0:
|
||||
case NSIDOMCOMPOSEAPPCORE_USEHTML:
|
||||
{
|
||||
PRBool prop;
|
||||
if (PR_FALSE == nsJSUtils::nsConvertJSValToBool(&prop, cx, *vp)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
a->SetUseHtml(prop);
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
@ -418,6 +457,8 @@ JSClass ComposeAppCoreClass = {
|
||||
//
|
||||
static JSPropertySpec ComposeAppCoreProperties[] =
|
||||
{
|
||||
{"useHtml", NSIDOMCOMPOSEAPPCORE_USEHTML, JSPROP_ENUMERATE},
|
||||
{"wrapColumn", NSIDOMCOMPOSEAPPCORE_WRAPCOLUMN, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user