зеркало из https://github.com/mozilla/pjs.git
Initial check in
This commit is contained in:
Родитель
75ce123dcc
Коммит
406468f411
|
@ -22,6 +22,8 @@ srcdir = @srcdir@
|
|||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = public src resources
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..\..
|
||||
|
||||
DIRS=public src resources
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* DO NOT EDIT. THIS FILE IS GENERATED FROM nsIDOMComposeAppCore.idl
|
||||
*/
|
||||
|
||||
#ifndef __gen_nsIDOMComposeAppCore_h__
|
||||
#define __gen_nsIDOMComposeAppCore_h__
|
||||
|
||||
#include "nsISupports.h" /* interface nsISupports */
|
||||
#include "nsIDOMWindow.h" /* interface nsIDOMWindow */
|
||||
#include "nsIDOMBaseAppCore.h" /* interface nsIDOMBaseAppCore */
|
||||
|
||||
|
||||
/* starting interface nsIDOMComposeAppCore */
|
||||
|
||||
/* {D4779C9A-CAA6-11d2-A6F2-0060B0EB39B5} */
|
||||
#define NS_IDOMCOMPOSEAPPCORE_IID_STR "D4779C9A-CAA6-11d2-A6F2-0060B0EB39B5"
|
||||
#define NS_IDOMCOMPOSEAPPCORE_IID \
|
||||
{0xd4779c9a, 0xcaa6, 0x11d2, \
|
||||
{ 0xa6, 0xf2, 0x0, 0x60, 0xb0, 0xeb, 0x39, 0xb5 }}
|
||||
|
||||
class nsIDOMComposeAppCore : public nsIDOMBaseAppCore {
|
||||
public:
|
||||
static const nsIID& IID() {
|
||||
static nsIID iid = NS_IDOMCOMPOSEAPPCORE_IID;
|
||||
return iid;
|
||||
}
|
||||
|
||||
/* void SetWindow (in nsIDOMWindow ptr); */
|
||||
NS_IMETHOD SetWindow(nsIDOMWindow *ptr) = 0;
|
||||
|
||||
/* void MailCompleteCallback (); */
|
||||
NS_IMETHOD CompleteCallback(const nsString& aScript) = 0;
|
||||
|
||||
/* void NewMessage (); */
|
||||
NS_IMETHOD NewMessage() = 0;
|
||||
|
||||
/* void SendMessage (); */
|
||||
NS_IMETHOD SendMessage(const nsString& aAddrTo, const nsString& aSubject, const nsString& aMsg) = 0;
|
||||
};
|
||||
|
||||
|
||||
extern "C" NS_DOM
|
||||
nsresult
|
||||
NS_InitComposeAppCoreClass(nsIScriptContext *aContext, void **aPrototype, JSObject * aParentProto);
|
||||
|
||||
#endif /* __gen_nsIDOMComposeAppCore_h__ */
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
/* this should eventually derive from some sort of BaseAppCore */
|
||||
|
||||
#include "nsIDOMBaseAppCore.idl"
|
||||
#include "nsIDOMWindow.idl"
|
||||
|
||||
[object, uuid(D4779C9A-CAA6-11d2-A6F2-0060B0EB39B5)]
|
||||
interface nsIDOMComposeAppCore : nsIDOMBaseAppCore {
|
||||
|
||||
void SetWindow(in nsIDOMWindow ptr);
|
||||
void CompleteCallback(in wstring script);
|
||||
void NewMessage();
|
||||
void SendMessage(in wstring addrTo, in wstring subject, in wstring msg);
|
||||
};
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
<html>
|
||||
<head>
|
||||
|
||||
<style type="text/css">
|
||||
/* This style sheet should be in a seperate file */
|
||||
|
||||
FIELDSET {
|
||||
background-color: rgb(192, 192, 192);
|
||||
border: 2px groove rgb(192, 192, 192);
|
||||
display: inline;
|
||||
margin-left: 10px;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
LEGEND {
|
||||
background-color:rgb(192, 192, 192);
|
||||
border: none ;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
|
||||
BODY,TD {
|
||||
font-family: Sans-Serif;
|
||||
background-color: #C0C0C0;
|
||||
}
|
||||
|
||||
LABEL {
|
||||
background-color: #C0C0C0;
|
||||
margin: 0px 0px 0px 0px;
|
||||
padding-left: 0px;
|
||||
padding-right: 0px;
|
||||
}
|
||||
|
||||
BODY,TD,INPUT {
|
||||
font-size: 9pt;
|
||||
}
|
||||
|
||||
BODY {
|
||||
margin: 0px 0px 0px 0px;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<center>
|
||||
<p><form ENCTYPE="text/plain" onSubmit="return submitForms()"></center>
|
||||
<TABLE bgcolor="#C0C0C0">
|
||||
<TR>
|
||||
<TD>
|
||||
<fieldset width="100%" height="100%" >
|
||||
<legend align=left> Info </legend>
|
||||
<TABLE width="100%" height="100%">
|
||||
<TR>
|
||||
<TD>Address:</TD>
|
||||
<TD width="100%"><input type="text" name="addrTo" ></TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>Subject:</TD>
|
||||
<TD><input type="text" name="subject" id="subject"></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</fieldset>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<fieldset width="100%" height="100%" >
|
||||
<legend align=left> Message </legend>
|
||||
<TEXTAREA cols=40 rows=20 name="mailbody"></TEXTAREA>
|
||||
</fieldset>
|
||||
</TD>
|
||||
</TR></TABLE>
|
||||
</form>
|
||||
</center>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,37 @@
|
|||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
srcdir = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
||||
EXPORT_RESOURCE_SAMPLES = \
|
||||
./Compose.html \
|
||||
./ComposeToobar.xml \
|
||||
./ComposeFrame.html \
|
||||
$(NULL)
|
||||
|
||||
install::
|
||||
$(INSTALL) $(EXPORT_RESOURCE_SAMPLES) $(DIST)/bin/res/samples
|
|
@ -0,0 +1,34 @@
|
|||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
MODULE=compose
|
||||
IGNORE_MANIFEST=1
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
install:: $(DLL)
|
||||
$(MAKE_INSTALL) Compose.html $(DIST)\bin\res\samples
|
||||
$(MAKE_INSTALL) ComposeToolbar.xml $(DIST)\bin\res\samples
|
||||
$(MAKE_INSTALL) ComposeFrame.html $(DIST)\bin\res\samples
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\bin\$(DLLNAME)
|
||||
rm -f $(DIST)\bin\res\samples\Compose.html
|
||||
rm -f $(DIST)\bin\res\samples\ComposeToolbar.xml
|
||||
rm -f $(DIST)\bin\res\samples\ComposeFrame.html
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
srcdir = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
LIBRARY_NAME=compose
|
||||
|
||||
CPPSRCS = \
|
||||
nsComposeFactory.cpp \
|
||||
nsJSComposeAppCore.cpp \
|
||||
nsComposeAppCore.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
nsMsgAppCore.h \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
IGNORE_MANIFEST=1
|
||||
|
||||
MAKE_OBJ_TYPE = DLL
|
||||
MODULE=compose
|
||||
EXPORTS = \
|
||||
nscomposeAppCore.h \
|
||||
nsJScomposeAppCore.h \
|
||||
$(NULL)
|
||||
|
||||
DLLNAME=compose.dll
|
||||
LIBNAME=compose.lib
|
||||
DLL=.\$(OBJDIR)\$(DLLNAME)
|
||||
|
||||
DEFINES=-D_IMPL_NS_DOM -DWIN32_LEAN_AND_MEAN
|
||||
|
||||
OBJS = \
|
||||
.\$(OBJDIR)\nscomposeFactory.obj \
|
||||
.\$(OBJDIR)\nsJScomposeAppCore.obj \
|
||||
.\$(OBJDIR)\nscomposeAppCore.obj \
|
||||
$(NULL)
|
||||
|
||||
LCFLAGS = \
|
||||
$(LCFLAGS) \
|
||||
$(DEFINES) \
|
||||
$(NULL)
|
||||
|
||||
LINCS= \
|
||||
-I$(XPDIST)\public\compose \
|
||||
-I$(XPDIST)\public\messenger \
|
||||
-I$(XPDIST)\public\js \
|
||||
-I$(XPDIST)\public\netlib \
|
||||
-I$(XPDIST)\public\network \
|
||||
-I$(XPDIST)\public\dom \
|
||||
-I$(XPDIST)\public\xpcom \
|
||||
-I$(XPDIST)\public\util \
|
||||
-I$(XPDIST)\public\nspr2 \
|
||||
-I$(XPDIST)\public\pref \
|
||||
-I$(XPDIST)\public\raptor \
|
||||
-I$(XPDIST)\public\appcores \
|
||||
-I$(XPDIST)\public\mailnews \
|
||||
-I$(XPDIST)\public\security \
|
||||
$(NULL)
|
||||
|
||||
LLIBS = \
|
||||
$(DIST)\lib\netlib.lib \
|
||||
$(DIST)\lib\xpcom32.lib \
|
||||
$(DIST)\lib\xppref32.lib \
|
||||
$(DIST)\lib\xplib.lib \
|
||||
$(DIST)\lib\js3250.lib \
|
||||
$(DIST)\lib\jsdombase_s.lib \
|
||||
$(DIST)\lib\raptorbase.lib \
|
||||
$(DIST)\lib\raptorgfxwin.lib\
|
||||
$(LIBNSPR) \
|
||||
$(DIST)\lib\libplc21.lib \
|
||||
$(DIST)\lib\nntp.lib \
|
||||
$(DIST)\lib\nntpTest.lib \
|
||||
# $(DIST)\lib\msgCore.lib \
|
||||
$(DIST)\lib\msgCompose.lib \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\lib\$(LIBNAME)
|
||||
rm -f $(DIST)\bin\$(DLLNAME)
|
||||
|
||||
install:: $(DLL)
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME) $(DIST)\bin
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(LIBNAME) $(DIST)\lib
|
||||
$(MAKE_INSTALL) $(DLL) $(DIST)\bin
|
|
@ -0,0 +1,362 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsIDOMComposeAppCore.h"
|
||||
#include "nsComposeAppCore.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIDOMBaseAppCore.h"
|
||||
#include "nsJSComposeAppCore.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIScriptContextOwner.h"
|
||||
|
||||
/* rhp - for access to webshell */
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIWebShellWindow.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsAppShellCIDs.h"
|
||||
#include "nsIAppShellService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIURL.h"
|
||||
|
||||
#include "nsMsgCompCID.h"
|
||||
#include "nsIMsgCompose.h"
|
||||
#include "nsIMsgCompFields.h"
|
||||
#include "nsIMsgSend.h"
|
||||
|
||||
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||
static NS_DEFINE_IID(kIDocumentIID, nsIDocument::IID());
|
||||
static NS_DEFINE_IID(kIMsgComposeIID, NS_IMSGCOMPOSE_IID);
|
||||
static NS_DEFINE_CID(kMsgComposeCID, NS_MSGCOMPOSE_CID);
|
||||
|
||||
static NS_DEFINE_IID(kIMsgCompFieldsIID, NS_IMSGCOMPFIELDS_IID);
|
||||
static NS_DEFINE_CID(kMsgCompFieldsCID, NS_MSGCOMPFIELDS_CID);
|
||||
|
||||
static NS_DEFINE_IID(kIMsgSendIID, NS_IMSGSEND_IID);
|
||||
static NS_DEFINE_CID(kMsgSendCID, NS_MSGSEND_CID);
|
||||
|
||||
NS_BEGIN_EXTERN_C
|
||||
|
||||
//nsresult NS_MailNewsLoadUrl(const nsString& urlString, nsISupports * aConsumer);
|
||||
|
||||
NS_END_EXTERN_C
|
||||
|
||||
// we need this because of an egcs 1.0 (and possibly gcc) compiler bug
|
||||
// that doesn't allow you to call ::nsISupports::IID() inside of a class
|
||||
// that multiply inherits from nsISupports
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
class nsComposeAppCore : public nsIDOMComposeAppCore,
|
||||
public nsIScriptObjectOwner
|
||||
{
|
||||
|
||||
public:
|
||||
nsComposeAppCore();
|
||||
virtual ~nsComposeAppCore();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_IDOMBASEAPPCORE
|
||||
|
||||
// nsIScriptObjectOwner
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
|
||||
NS_IMETHOD SetScriptObject(void* aScriptObject);
|
||||
|
||||
// nsIComposeAppCore
|
||||
NS_IMETHOD CompleteCallback(const nsString& aScript);
|
||||
NS_IMETHOD SetWindow(nsIDOMWindow* aWin);
|
||||
NS_IMETHOD NewMessage();
|
||||
NS_IMETHOD SendMessage(const nsString& aAddrTo, const nsString& aSubject, const nsString& aMsg);
|
||||
|
||||
protected:
|
||||
|
||||
nsIScriptContext * GetScriptContext(nsIDOMWindow * aWin);
|
||||
|
||||
nsString mId;
|
||||
nsString mScript;
|
||||
void *mScriptObject;
|
||||
nsIScriptContext *mScriptContext;
|
||||
|
||||
/* rhp - need this to drive message display */
|
||||
nsIDOMWindow *mWindow;
|
||||
nsIWebShell *mWebShell;
|
||||
};
|
||||
|
||||
//
|
||||
// nsComposeAppCore
|
||||
//
|
||||
nsComposeAppCore::nsComposeAppCore()
|
||||
{
|
||||
mScriptObject = nsnull;
|
||||
mWebShell = nsnull;
|
||||
mScriptObject = nsnull;
|
||||
mScriptContext = nsnull;
|
||||
mWindow = nsnull;
|
||||
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsComposeAppCore::~nsComposeAppCore()
|
||||
{
|
||||
NS_IF_RELEASE(mScriptContext);
|
||||
NS_IF_RELEASE(mWindow);
|
||||
}
|
||||
|
||||
nsIScriptContext *
|
||||
nsComposeAppCore::GetScriptContext(nsIDOMWindow * aWin)
|
||||
{
|
||||
nsIScriptContext * scriptContext = nsnull;
|
||||
if (nsnull != aWin) {
|
||||
nsIDOMDocument * domDoc;
|
||||
aWin->GetDocument(&domDoc);
|
||||
if (nsnull != domDoc) {
|
||||
nsIDocument * doc;
|
||||
if (NS_OK == domDoc->QueryInterface(kIDocumentIID,(void**)&doc)) {
|
||||
nsIScriptContextOwner * owner = doc->GetScriptContextOwner();
|
||||
if (nsnull != owner) {
|
||||
owner->GetScriptContext(&scriptContext);
|
||||
NS_RELEASE(owner);
|
||||
}
|
||||
NS_RELEASE(doc);
|
||||
}
|
||||
NS_RELEASE(domDoc);
|
||||
}
|
||||
}
|
||||
return scriptContext;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// nsISupports
|
||||
//
|
||||
NS_IMPL_ADDREF(nsComposeAppCore);
|
||||
NS_IMPL_RELEASE(nsComposeAppCore);
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsComposeAppCore::QueryInterface(REFNSIID aIID,void** aInstancePtr)
|
||||
{
|
||||
if (aInstancePtr == NULL) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
// Always NULL result, in case of failure
|
||||
*aInstancePtr = NULL;
|
||||
|
||||
if ( aIID.Equals(kIScriptObjectOwnerIID)) {
|
||||
*aInstancePtr = (void*) ((nsIScriptObjectOwner*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
if ( aIID.Equals(nsIDOMBaseAppCore::IID())) {
|
||||
*aInstancePtr = (void*) ((nsIDOMBaseAppCore*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
else if ( aIID.Equals(nsIDOMComposeAppCore::IID()) ) {
|
||||
*aInstancePtr = (void*) (nsIDOMComposeAppCore*)this;
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
else if ( aIID.Equals(kISupportsIID) ) {
|
||||
*aInstancePtr = (void*)(nsISupports*) (nsIScriptObjectOwner *) this;
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
//
|
||||
// nsIScriptObjectOwner
|
||||
//
|
||||
nsresult
|
||||
nsComposeAppCore::GetScriptObject(nsIScriptContext *aContext, void **aScriptObject)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aScriptObject, "null arg");
|
||||
nsresult res = NS_OK;
|
||||
if (nsnull == mScriptObject)
|
||||
{
|
||||
res = NS_NewScriptComposeAppCore(aContext,
|
||||
(nsISupports *)(nsIDOMComposeAppCore*)this,
|
||||
nsnull,
|
||||
&mScriptObject);
|
||||
}
|
||||
|
||||
*aScriptObject = mScriptObject;
|
||||
return res;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComposeAppCore::SetScriptObject(void* aScriptObject)
|
||||
{
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//
|
||||
// nsIDOMBaseAppCore
|
||||
//
|
||||
nsresult
|
||||
nsComposeAppCore::Init(const nsString& aId)
|
||||
{
|
||||
printf("Init\n");
|
||||
mId = aId;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsComposeAppCore::GetId(nsString& aId)
|
||||
{
|
||||
printf("GetID\n");
|
||||
aId = mId;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//
|
||||
// nsIComposeAppCore
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsComposeAppCore::SetWindow(nsIDOMWindow* aWin)
|
||||
{
|
||||
mWindow = aWin;
|
||||
NS_ADDREF(mWindow);
|
||||
mScriptContext = GetScriptContext(aWin);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsComposeAppCore::CompleteCallback(const nsString& aScript)
|
||||
{
|
||||
mScript = aScript;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsComposeAppCore::NewMessage()
|
||||
{
|
||||
static NS_DEFINE_CID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
|
||||
|
||||
nsIAppShellService* appShell;
|
||||
char * urlstr=nsnull;
|
||||
nsresult rv;
|
||||
nsString controllerCID;
|
||||
|
||||
urlstr = "resource:/res/samples/compose.html";
|
||||
rv = nsServiceManager::GetService(kAppShellServiceCID,
|
||||
nsIAppShellService::IID(),
|
||||
(nsISupports**)&appShell);
|
||||
nsIURL* url;
|
||||
nsIWidget* newWindow;
|
||||
|
||||
rv = NS_NewURL(&url, urlstr);
|
||||
if (NS_FAILED(rv)) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
controllerCID = "6B75BB61-BD41-11d2-9D31-00805F8ADDDE";
|
||||
appShell->CreateTopLevelWindow(url, controllerCID, newWindow, nsnull);
|
||||
done:
|
||||
NS_RELEASE(url);
|
||||
if (nsnull != appShell) {
|
||||
nsServiceManager::ReleaseService(kAppShellServiceCID, appShell);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsComposeAppCore::SendMessage(const nsString& aAddrTo, const nsString& aSubject, const nsString& aMsg)
|
||||
{
|
||||
if (nsnull == mScriptContext) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
printf("----------------------------\n");
|
||||
printf("-- Sending Mail Message\n");
|
||||
printf("----------------------------\n");
|
||||
printf("To: %s \nSub: %s \nMsg: %s\n", aAddrTo.ToNewCString(), aSubject.ToNewCString(), aMsg.ToNewCString());
|
||||
printf("----------------------------\n");
|
||||
|
||||
{
|
||||
nsIMsgCompose *pMsgCompose;
|
||||
nsIMsgCompFields *pMsgCompFields;
|
||||
nsIMsgSend *pMsgSend;
|
||||
nsresult res;
|
||||
|
||||
// register our dll
|
||||
nsRepository::RegisterFactory(kMsgComposeCID, "msgcompose.dll", PR_FALSE, PR_FALSE);
|
||||
nsRepository::RegisterFactory(kMsgCompFieldsCID, "msgcompose.dll", PR_FALSE, PR_FALSE);
|
||||
nsRepository::RegisterFactory(kMsgSendCID, "msgcompose.dll", PR_FALSE, PR_FALSE);
|
||||
|
||||
res = nsRepository::CreateInstance(kMsgSendCID,
|
||||
NULL,
|
||||
kIMsgSendIID,
|
||||
(void **) &pMsgSend);
|
||||
|
||||
if (res == NS_OK && pMsgSend) {
|
||||
printf("We succesfully obtained a nsIMsgSend interface....\n");
|
||||
pMsgSend->Test();
|
||||
|
||||
res = nsRepository::CreateInstance(kMsgCompFieldsCID,
|
||||
NULL,
|
||||
kIMsgCompFieldsIID,
|
||||
(void **) &pMsgCompFields);
|
||||
if (res == NS_OK && pMsgCompFields) {
|
||||
pMsgCompFields->SetFrom("qatest02@netscape.com", NULL);
|
||||
pMsgCompFields->SetTo(aAddrTo.ToNewCString(), NULL);
|
||||
pMsgCompFields->SetSubject(aSubject.ToNewCString(), NULL);
|
||||
pMsgCompFields->SetBody(aMsg.ToNewCString(), NULL);
|
||||
|
||||
pMsgSend->SendMessage(pMsgCompFields);
|
||||
|
||||
pMsgCompFields->Release();
|
||||
}
|
||||
|
||||
printf("Releasing the interface now...\n");
|
||||
pMsgSend->Release();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (nsnull != mScriptContext) {
|
||||
const char* url = "";
|
||||
PRBool isUndefined = PR_FALSE;
|
||||
nsString rVal;
|
||||
mScriptContext->EvaluateString(mScript, url, 0, rVal, &isUndefined);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
nsresult
|
||||
NS_NewComposeAppCore(nsIDOMComposeAppCore **aResult)
|
||||
{
|
||||
if (!aResult) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsComposeAppCore *appcore = new nsComposeAppCore();
|
||||
if (appcore) {
|
||||
return appcore->QueryInterface(nsIDOMComposeAppCore::IID(),
|
||||
(void **)aResult);
|
||||
|
||||
}
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
|
@ -0,0 +1,175 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
|
||||
#include "nsIFactory.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsComposeAppCore.h"
|
||||
|
||||
#include "nsRepository.h"
|
||||
|
||||
#include "pratom.h"
|
||||
|
||||
static NS_DEFINE_CID(kCComposeAppCoreCID, NS_COMPOSEAPPCORE_CID);
|
||||
|
||||
static PRInt32 g_InstanceCount = 0;
|
||||
static PRInt32 g_LockCount = 0;
|
||||
|
||||
|
||||
class nsComposeFactory : public nsIFactory {
|
||||
public:
|
||||
// nsISupports methods
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsComposeFactory(const nsCID &aClass);
|
||||
|
||||
// nsIFactory methods
|
||||
NS_IMETHOD CreateInstance(nsISupports *aOuter, const nsIID &aIID, void **aResult);
|
||||
NS_IMETHOD LockFactory(PRBool aLock);
|
||||
|
||||
protected:
|
||||
virtual ~nsComposeFactory();
|
||||
|
||||
private:
|
||||
nsCID mClassID;
|
||||
};
|
||||
|
||||
nsComposeFactory::nsComposeFactory(const nsCID &aClass)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
PR_AtomicIncrement(&g_InstanceCount);
|
||||
mClassID = aClass;
|
||||
}
|
||||
|
||||
nsComposeFactory::~nsComposeFactory()
|
||||
{
|
||||
PR_AtomicDecrement(&g_InstanceCount);
|
||||
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsComposeFactory::QueryInterface(const nsIID &aIID, void **aResult)
|
||||
{
|
||||
if (aResult == NULL)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// Always NULL result, in case of failure
|
||||
*aResult = NULL;
|
||||
|
||||
// we support two interfaces....nsISupports and nsFactory.....
|
||||
if (aIID.Equals(::nsISupports::IID()))
|
||||
*aResult = (void *)(nsISupports*)this;
|
||||
else if (aIID.Equals(nsIFactory::IID()))
|
||||
*aResult = (void *)(nsIFactory*)this;
|
||||
|
||||
if (*aResult == NULL)
|
||||
return NS_NOINTERFACE;
|
||||
|
||||
AddRef(); // Increase reference count for caller
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsComposeFactory)
|
||||
NS_IMPL_RELEASE(nsComposeFactory)
|
||||
|
||||
nsresult
|
||||
nsComposeFactory::CreateInstance(nsISupports *aOuter, const nsIID &aIID, void **aResult)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
nsISupports *inst = nsnull;
|
||||
|
||||
if (aResult == NULL)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aResult = NULL;
|
||||
|
||||
// get the interface this factory instance is supposed to create
|
||||
if (mClassID.Equals(kCComposeAppCoreCID)) {
|
||||
res = NS_NewComposeAppCore((nsIDOMComposeAppCore **)&inst);
|
||||
}
|
||||
|
||||
// get the requested interface on the newly created class
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
res = inst->QueryInterface(aIID, aResult);
|
||||
NS_RELEASE(inst);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
nsresult nsComposeFactory::LockFactory(PRBool aLock)
|
||||
{
|
||||
// Not implemented in simplest case.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// begin DLL exports
|
||||
//
|
||||
nsresult
|
||||
NSGetFactory(const nsCID &aClass,
|
||||
nsISupports *serviceMgr,
|
||||
nsIFactory **aFactory)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("compose: NSGetFactory()\n");
|
||||
#endif
|
||||
if (nsnull == aFactory)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// for now this factory implements only the compose CID.
|
||||
*aFactory = new nsComposeFactory(aClass);
|
||||
|
||||
if (aFactory)
|
||||
return (*aFactory)->QueryInterface(nsIFactory::IID(), (void**)aFactory); // they want a Factory Interface so give it to them
|
||||
else
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
||||
PRBool
|
||||
NSCanUnload()
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("compose: NSCanUnload()\n");
|
||||
#endif
|
||||
return PRBool(g_InstanceCount == 0 && g_LockCount == 0);
|
||||
}
|
||||
|
||||
nsresult
|
||||
NSRegisterSelf(const char *fullpath)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("compose: NSRegisterSelf()\n");
|
||||
#endif
|
||||
return nsRepository::RegisterFactory(kCComposeAppCoreCID, fullpath,
|
||||
PR_TRUE, PR_TRUE);
|
||||
}
|
||||
|
||||
nsresult
|
||||
NSUnregisterSelf(const char *fullpath)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("compose: NSUnregisterSelf()\n");
|
||||
#endif
|
||||
return nsRepository::UnregisterFactory(kCComposeAppCoreCID, fullpath);
|
||||
}
|
|
@ -0,0 +1,475 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMComposeAppCore.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIScriptNameSpaceManager.h"
|
||||
#include "nsRepository.h"
|
||||
#include "nsDOMCID.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIComposeAppCoreIID, NS_IDOMCOMPOSEAPPCORE_IID);
|
||||
static NS_DEFINE_IID(kIWindowIID, NS_IDOMWINDOW_IID);
|
||||
|
||||
NS_DEF_PTR(nsIDOMComposeAppCore);
|
||||
NS_DEF_PTR(nsIDOMWindow);
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// ComposeAppCore Properties Getter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
GetComposeAppCoreProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMComposeAppCore *a = (nsIDOMComposeAppCore*)JS_GetPrivate(cx, obj);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == a) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case 0:
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// ComposeAppCore Properties Setter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
SetComposeAppCoreProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMComposeAppCore *a = (nsIDOMComposeAppCore*)JS_GetPrivate(cx, obj);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == a) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case 0:
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// ComposeAppCore finalizer
|
||||
//
|
||||
PR_STATIC_CALLBACK(void)
|
||||
FinalizeComposeAppCore(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
nsJSUtils::nsGenericFinalize(cx, obj);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// ComposeAppCore enumerate
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
EnumerateComposeAppCore(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
return nsJSUtils::nsGenericEnumerate(cx, obj);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// ComposeAppCore resolve
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ResolveComposeAppCore(JSContext *cx, JSObject *obj, jsval id)
|
||||
{
|
||||
return nsJSUtils::nsGenericResolve(cx, obj, id);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method SetWindow
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ComposeAppCoreSetWindow(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMComposeAppCore *nativeThis = (nsIDOMComposeAppCore*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsIDOMWindowPtr 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 >= 1) {
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0,
|
||||
kIWindowIID,
|
||||
"Window",
|
||||
cx,
|
||||
argv[0])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (NS_OK != nativeThis->SetWindow(b0)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function SetWindow requires 1 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method CompleteCallback
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ComposeAppCoreCompleteCallback(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMComposeAppCore *nativeThis = (nsIDOMComposeAppCore*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsAutoString 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 >= 1) {
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]);
|
||||
|
||||
if (NS_OK != nativeThis->CompleteCallback(b0)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function CompleteCallback requires 1 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method NewMessage
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ComposeAppCoreNewMessage(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMComposeAppCore *nativeThis = (nsIDOMComposeAppCore*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
|
||||
*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->NewMessage()) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function NewMessage requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method SendMessage
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ComposeAppCoreSendMessage(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMComposeAppCore *nativeThis = (nsIDOMComposeAppCore*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsAutoString b0;
|
||||
nsAutoString b1;
|
||||
nsAutoString 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]);
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b1, cx, argv[1]);
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b2, cx, argv[2]);
|
||||
|
||||
if (NS_OK != nativeThis->SendMessage(b0, b1, b2)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function SendMessage requires 3 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// class for ComposeAppCore
|
||||
//
|
||||
JSClass ComposeAppCoreClass = {
|
||||
"ComposeAppCore",
|
||||
JSCLASS_HAS_PRIVATE,
|
||||
JS_PropertyStub,
|
||||
JS_PropertyStub,
|
||||
GetComposeAppCoreProperty,
|
||||
SetComposeAppCoreProperty,
|
||||
EnumerateComposeAppCore,
|
||||
ResolveComposeAppCore,
|
||||
JS_ConvertStub,
|
||||
FinalizeComposeAppCore
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// ComposeAppCore class properties
|
||||
//
|
||||
static JSPropertySpec ComposeAppCoreProperties[] =
|
||||
{
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// ComposeAppCore class methods
|
||||
//
|
||||
static JSFunctionSpec ComposeAppCoreMethods[] =
|
||||
{
|
||||
{"SetWindow", ComposeAppCoreSetWindow, 1},
|
||||
{"CompleteCallback", ComposeAppCoreCompleteCallback, 1},
|
||||
{"NewMessage", ComposeAppCoreNewMessage, 0},
|
||||
{"SendMessage", ComposeAppCoreSendMessage, 3},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// ComposeAppCore constructor
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ComposeAppCore(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsresult result;
|
||||
nsIID classID;
|
||||
nsIScriptContext* context = (nsIScriptContext*)JS_GetContextPrivate(cx);
|
||||
nsIScriptNameSpaceManager* manager;
|
||||
nsIDOMComposeAppCore *nativeThis;
|
||||
nsIScriptObjectOwner *owner = nsnull;
|
||||
|
||||
static NS_DEFINE_IID(kIDOMComposeAppCoreIID, NS_IDOMCOMPOSEAPPCORE_IID);
|
||||
|
||||
result = context->GetNameSpaceManager(&manager);
|
||||
if (NS_OK != result) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
result = manager->LookupName("ComposeAppCore", PR_TRUE, classID);
|
||||
NS_RELEASE(manager);
|
||||
if (NS_OK != result) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
result = nsRepository::CreateInstance(classID,
|
||||
nsnull,
|
||||
kIDOMComposeAppCoreIID,
|
||||
(void **)&nativeThis);
|
||||
if (NS_OK != result) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
// XXX We should be calling Init() on the instance
|
||||
|
||||
result = nativeThis->QueryInterface(kIScriptObjectOwnerIID, (void **)&owner);
|
||||
if (NS_OK != result) {
|
||||
NS_RELEASE(nativeThis);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
owner->SetScriptObject((void *)obj);
|
||||
JS_SetPrivate(cx, obj, nativeThis);
|
||||
|
||||
NS_RELEASE(owner);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
//
|
||||
// ComposeAppCore class initialization
|
||||
//
|
||||
nsresult NS_InitComposeAppCoreClass(nsIScriptContext *aContext, void **aPrototype, JSObject * aParentProto)
|
||||
{
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
JSObject *proto = nsnull;
|
||||
JSObject *constructor = nsnull;
|
||||
JSObject *parent_proto = aParentProto;
|
||||
JSObject *global = JS_GetGlobalObject(jscontext);
|
||||
jsval vp;
|
||||
|
||||
if ((PR_TRUE != JS_LookupProperty(jscontext, global, "ComposeAppCore", &vp)) ||
|
||||
!JSVAL_IS_OBJECT(vp) ||
|
||||
((constructor = JSVAL_TO_OBJECT(vp)) == nsnull) ||
|
||||
(PR_TRUE != JS_LookupProperty(jscontext, JSVAL_TO_OBJECT(vp), "prototype", &vp)) ||
|
||||
!JSVAL_IS_OBJECT(vp)) {
|
||||
#if 0
|
||||
if (NS_OK != NS_InitBaseAppCoreClass(aContext, (void **)&parent_proto)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
#endif
|
||||
|
||||
proto = JS_InitClass(jscontext, // context
|
||||
global, // global object
|
||||
parent_proto, // parent proto
|
||||
&ComposeAppCoreClass, // JSClass
|
||||
ComposeAppCore, // JSNative ctor
|
||||
0, // ctor args
|
||||
ComposeAppCoreProperties, // proto props
|
||||
ComposeAppCoreMethods, // proto funcs
|
||||
nsnull, // ctor props (static)
|
||||
nsnull); // ctor funcs (static)
|
||||
if (nsnull == proto) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
}
|
||||
else if ((nsnull != constructor) && JSVAL_IS_OBJECT(vp)) {
|
||||
proto = JSVAL_TO_OBJECT(vp);
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (aPrototype) {
|
||||
*aPrototype = proto;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Method for creating a new ComposeAppCore JavaScript object
|
||||
//
|
||||
extern "C" NS_DOM nsresult NS_NewScriptComposeAppCore(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptComposeAppCore");
|
||||
JSObject *proto;
|
||||
JSObject *parent;
|
||||
nsIScriptObjectOwner *owner;
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
nsresult result = NS_OK;
|
||||
nsIDOMComposeAppCore *aComposeAppCore;
|
||||
|
||||
if (nsnull == aParent) {
|
||||
parent = nsnull;
|
||||
}
|
||||
else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
|
||||
if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) {
|
||||
NS_RELEASE(owner);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_RELEASE(owner);
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (NS_OK != NS_InitComposeAppCoreClass(aContext, (void **)&proto, parent)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
result = aSupports->QueryInterface(kIComposeAppCoreIID, (void **)&aComposeAppCore);
|
||||
if (NS_OK != result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// create a js object for this class
|
||||
*aReturn = JS_NewObject(jscontext, &ComposeAppCoreClass, proto, parent);
|
||||
if (nsnull != *aReturn) {
|
||||
// connect the native object to the js object
|
||||
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aComposeAppCore);
|
||||
}
|
||||
else {
|
||||
NS_RELEASE(aComposeAppCore);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
Загрузка…
Ссылка в новой задаче