merge simple plugin into sdk, remove old sdk simple plugin. b=360955 rs=jst

This commit is contained in:
Josh Aas 2008-09-02 14:39:03 -04:00
Родитель 3e4fc64365
Коммит 82ba1ddef5
20 изменённых файлов: 44 добавлений и 1263 удалений

Просмотреть файл

@ -1,85 +0,0 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = npsimple
LIBRARY_NAME = npsimple
IS_COMPONENT = 1
MODULE_NAME = SimplePlugin
# Ack! we should not be using the internal API or linking against
# MOZ_COMPONENT_LIBS!
MOZILLA_INTERNAL_API = 1
REQUIRES = xpcom \
string \
plugin \
widget \
$(NULL)
# Make sure that it builds but don't install it
NO_DIST_INSTALL = 1
NO_INSTALL = 1
XPIDLSRCS = nsISimplePluginInstance.idl
CPPSRCS = npsimple.cpp
LOCAL_INCLUDES = -I$(srcdir)/.. -I$(srcdir)/../../public -I$(XPIDL_GEN_DIR)
EXTRA_DSO_LDOPTS += \
-L$(DIST)/lib \
-lgtksuperwin \
$(MOZ_COMPONENT_LIBS) \
$(NULL)
include $(topsrcdir)/config/rules.mk
CXXFLAGS += $(MOZ_TOOLKIT_REGISTRY_CFLAGS)
libs::
$(INSTALL) $(srcdir)/samples/embed-test.html $(DIST)/bin/res/samples
install::
$(SYSINSTALL) $(IFLAGS1) $(srcdir)/samples/embed-test.html $(DESTDIR)$(mozappdir)/res/samples

Просмотреть файл

@ -1,108 +0,0 @@
<HTML>
<H1> Simple XPConnect Scriptable Sample Plug-in </H1>
<p>
This sample plug-in demonstrates how to write a XPConnect-enabled plug-in. You
should see in the plug-in rectangle below with the text "Hello World". The text
box and buttons demostrate calling the scriptable xpcom interfaces of the plugin
from JavaScript.
<HR>
<center>
<EMBED type=application/x-simple name="simple1" width=400 height=300>
<script>
function GetText()
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
document.the_form.the_text.value =
document.simple1.nsISimplePluginInstance.text;
}
function SetText()
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
document.simple1.nsISimplePluginInstance.text =
document.the_form.the_text.value;
}
/*
// For JS evaluator below; unused.
var it = undefined; // persistent last special value.
function EvalIt() {
var inText = document.eval_form.eval_text.value;
dump(document.simple1);
try {
var result = eval(inText);
result = result ? result : "";
document.eval_form.result_text.value = result;
if (it)
document.eval_form.it_text.value = "it: " + it;
document.eval_form.eval_text.value = "";
} catch (err) {
document.eval_form.result_text.value = "Exn: " + err.toString();
}
return true;
}
*/
</script>
<form name ="the_form">
<INPUT TYPE="text" NAME="the_text" VALUE="some text" SIZE="25">
<input type=button value="Set Text" onclick='SetText()'>
<input type=button value="Get Text" onclick='GetText()'>
</form>
<!--
<hr>
<form name ="eval_form">
JavaScript evaluation for poking at the plugin ('document.simple1').<br>
input:<br>
<INPUT TYPE="text" NAME="eval_text" onchange = "EvalIt()" SIZE="80"><br>
result:<br>
<INPUT TYPE="text" NAME="result_text" SIZE="80"><br>
contents of 'it':<br>
<INPUT TYPE="text" NAME="it_text" SIZE="80">
<p>
<input type=button value="eval" onclick="EvalIt()">
</form>
-->
<hr>
</center>
<h4>Problems?</h4>
<ul>
<p><li><b>Can't load pluign</b>:
Copy the compiled plugin to your plugins directory
<p><li><b>JavaScript error in the Error console talking about how
XPConnect can't build a wrapper</b>:
Copy the type library (nsISimplePluginInstance.xpt) to the mozilla components
directory.
<p><li><b>Plugin loads, but when I push the 'Set Text' button the plugin text
is not updated</b>:
Are you not running Windows? Only the Windows version updates text the plugin
draws. But the calls from JS to the plugin should work on all platforms.
[We welcome fixes to the samples if you'd like to submit them]
</ul>
<HR>
</HTML>

Просмотреть файл

@ -1,72 +0,0 @@
<HTML>
<H1> Simple LiveConnect Sample Plug-in </H1>
<p> This sample plug-in demonstrates how to write a
LiveConnect-enabled plug-in. You should see in the plug-in rectangle
below the text "Hello World" and messages written to the Java Console
and to stdout to tell you what it's doing. And if you click the
JavaScript button, it will tell you another thing or two.
<HR>
<center>
<EMBED type=application/x-simple name="simple1" width=400 height=300>
<form>
<input type=button value="Click Me"
onclick='document.simple1.doit("Hello from JavaScript!")'>
</form>
<h4>Open the Java Console (under the Options menu) to see the
output!</h4>
</center>
<h4>Problems?</h4>
<ul>
<p><li><b>I don't see any output in the Java Console or to stdout</b>:
This is probably because the Simple.class file isn't installed
correctly. For Macintosh, the class file must be in "System
Folder:Preferences:Netscape Ÿ:Java:netscape-classes". (In the next beta
release it should be possible to simply place the class file in the
plugins directory.) For Windows, the class file should be in the Plug-in
folder along side the DLL.
<p><li><b>I still don't see any output in the Java Console or to
stdout</b>: This may be because you don't have your moz3_0.zip file in
the proper place. Try visiting a page with an applet to see if it
works. Also make sure that Java isn't disabled (under the Options
menu, Network Preferences..., Language).
<p><li><b>I get a dialog offering to download the plugin</b>: This is
most likely because the Plug-in file (npsimple.dll on Windows,
npsimple.so on Unix, or SimplePPC on PowerPC Mac) isn't installed in the
plug-in directory. Also check that the list of helpers (under Options,
General Preferences..., Helpers) contains an entry for type
application/x-simple-plugin that names the Simple LiveConnect Sample
Plug-in.
<p><li><b>I get Java Console output, but nothing to stdout</b>: If
you're on a Mac, forget it. You'll never see stdout. If you're on a
Windows machine and you launched the Navigator by double clicking an
icon, you also won't get any stdout.
<p><li><b>When I click the button, I get an error dialog from
JavaScript saying "Window.Function.Document.simple1 has no
properties."</b>: This is because the Simple.class file was not found
in the Plug-ins directory. You'll also notice that you're not getting
any messages to the console in this case.
<p><li><b>Other problems?</b>: Check with the Netscape
LiveConnect/Plug-in developer's news group, <a
href="snews://secnews/netscape.devs-plugins">
snews://secnews/netscape.devs-plugins</a>.
</ul>
<HR>
</HTML>

Просмотреть файл

@ -1,12 +0,0 @@
<html>
<head>
<title>Embed Test</title>
</head>
<body>
<center>
<h1>Embed Test</h1>
<embed type="application/x-simple" text="Hello World">
</center>
</body>
</html>

Просмотреть файл

@ -35,44 +35,50 @@
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
DEPTH = ../../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
XPIDL_MODULE = npsimple
LIBRARY_NAME = npsimple
REQUIRES = xpcom \
plugin \
$(NULL)
MODULE = npsimple
LIBRARY_NAME = npsimple
IS_COMPONENT = 1
MODULE_NAME = SimplePlugin
NO_DIST_INSTALL = 1
# Ack! we should not be using the internal API or linking against
# MOZ_COMPONENT_LIBS!
MOZILLA_INTERNAL_API = 1
REQUIRES = xpcom \
string \
plugin \
widget \
$(NULL)
# Make sure that it builds but don't install it
NO_DIST_INSTALL = 1
NO_INSTALL = 1
CPPSRCS = nsScriptablePeer.cpp \
plugin.cpp \
$(NULL)
XPIDLSRCS = nsISimplePluginInstance.idl
XPIDLSRCS = nsISimplePlugin.idl
CPPSRCS = npsimple.cpp
SHARED_LIBRARY_LIBS = ../common/$(LIB_PREFIX)plugingate_s.$(LIB_SUFFIX)
LOCAL_INCLUDES = -I$(srcdir)/.. -I$(srcdir)/../../public -I$(XPIDL_GEN_DIR)
ifeq ($(OS_ARCH),WINNT)
DEFFILE = $(win_srcdir)/npsimple.def
RESFILE = npsimple.res
endif
EXTRA_DSO_LDOPTS += \
-L$(DIST)/lib \
-lgtksuperwin \
$(MOZ_COMPONENT_LIBS) \
$(NULL)
include $(topsrcdir)/config/rules.mk
DEFINES += -DMOZILLA_STRICT_API
CXXFLAGS += $(MOZ_TOOLKIT_REGISTRY_CFLAGS)
ifeq ($(OS_ARCH),Linux)
EXTRA_DSO_LDOPTS += $(XLDFLAGS) -rdynamic -lXi -lXext -lX11 -lm -lXt
endif
libs::
$(INSTALL) $(srcdir)/test.html $(DIST)/bin/res/samples
LOCAL_INCLUDES = -I./$(XPIDL_GEN_DIR) \
-I$(srcdir)/../include \
-I$(srcdir)/../../include \
$(NULL)
install::
$(SYSINSTALL) $(IFLAGS1) $(srcdir)/test.html $(DESTDIR)$(mozappdir)/res/samples

Просмотреть файл

@ -1,6 +0,0 @@
LIBRARY NPSIMPLE
EXPORTS
NP_GetEntryPoints @1
NP_Initialize @2
NP_Shutdown @3

Просмотреть файл

@ -1,139 +0,0 @@
# Microsoft Developer Studio Project File - Name="npsimple" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=npsimple - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "npsimple.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "npsimple.mak" CFG="npsimple - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "npsimple - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "npsimple - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "npsimple - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NPSIMPLE_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\include" /I "..\..\include" /D "NDEBUG" /D "MOZILLA_STRICT_API" /D "XP_WIN" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NPSIMPLE_EXPORTS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib /nologo /dll /machine:I386
!ELSEIF "$(CFG)" == "npsimple - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "npsimple___Win32_Debug"
# PROP BASE Intermediate_Dir "npsimple___Win32_Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NPSIMPLE_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\include" /I "..\..\include" /D "XP_WIN32" /D "_DEBUG" /D "MOZILLA_STRICT_API" /D "XP_WIN" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NPSIMPLE_EXPORTS" /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
!ENDIF
# Begin Target
# Name "npsimple - Win32 Release"
# Name "npsimple - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=..\common\np_entry.cpp
# End Source File
# Begin Source File
SOURCE=..\common\npn_gate.cpp
# End Source File
# Begin Source File
SOURCE=..\common\npp_gate.cpp
# End Source File
# Begin Source File
SOURCE=.\npsimple.def
# End Source File
# Begin Source File
SOURCE=.\nsScriptablePeer.cpp
# End Source File
# Begin Source File
SOURCE=.\plugin.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\nsScriptablePeer.h
# End Source File
# Begin Source File
SOURCE=.\plugin.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\npsimple.rc
# End Source File
# End Group
# End Target
# End Project

Просмотреть файл

@ -1,29 +0,0 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "npsimple"=.\npsimple.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

Просмотреть файл

@ -1,112 +0,0 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "windows.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904e4"
BEGIN
VALUE "Comments", "\0"
VALUE "CompanyName", " \0"
VALUE "FileDescription", "npsimple\0"
VALUE "FileExtents", "spl\0"
VALUE "FileOpenName", "npsimple\0"
VALUE "FileVersion", "1, 0, 0, 1\0"
VALUE "InternalName", "npsimple\0"
VALUE "LegalCopyright", "Copyright © 2001\0"
VALUE "LegalTrademarks", "\0"
VALUE "MIMEType", "application/simple-plugin\0"
VALUE "OriginalFilename", "npsimple.dll\0"
VALUE "PrivateBuild", "\0"
VALUE "ProductName", "Simple Example Plugin for Mozilla\0"
VALUE "ProductVersion", "1, 0, 0, 1\0"
VALUE "SpecialBuild", "\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END
#endif // !_MAC
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

Просмотреть файл

@ -1,44 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
[scriptable, uuid(482e1890-1fe5-11d5-9cf8-0060b0fbd8ac)]
interface nsISimplePlugin : nsISupports {
readonly attribute string version;
};

Просмотреть файл

@ -1,123 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// ==============================
// ! Scriptability related code !
// ==============================
/////////////////////////////////////////////////////
//
// This file implements the nsScriptablePeer object
// The native methods of this class are supposed to
// be callable from JavaScript
//
#include "plugin.h"
static NS_DEFINE_IID(kISimplePluginIID, NS_ISIMPLEPLUGIN_IID);
static NS_DEFINE_IID(kIClassInfoIID, NS_ICLASSINFO_IID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
nsScriptablePeer::nsScriptablePeer(nsPluginInstance* aPlugin)
{
mPlugin = aPlugin;
mRefCnt = 0;
}
nsScriptablePeer::~nsScriptablePeer()
{
}
// AddRef, Release and QueryInterface are common methods and must
// be implemented for any interface
NS_IMETHODIMP_(nsrefcnt) nsScriptablePeer::AddRef()
{
++mRefCnt;
return mRefCnt;
}
NS_IMETHODIMP_(nsrefcnt) nsScriptablePeer::Release()
{
--mRefCnt;
if (mRefCnt == 0) {
delete this;
return 0;
}
return mRefCnt;
}
// here nsScriptablePeer should return three interfaces it can be asked for by their iid's
// static casts are necessary to ensure that correct pointer is returned
NS_IMETHODIMP nsScriptablePeer::QueryInterface(const nsIID& aIID, void** aInstancePtr)
{
if(!aInstancePtr)
return NS_ERROR_NULL_POINTER;
if(aIID.Equals(kISimplePluginIID)) {
*aInstancePtr = static_cast<nsISimplePlugin*>(this);
AddRef();
return NS_OK;
}
if(aIID.Equals(kIClassInfoIID)) {
*aInstancePtr = static_cast<nsIClassInfo*>(this);
AddRef();
return NS_OK;
}
if(aIID.Equals(kISupportsIID)) {
*aInstancePtr = static_cast<nsISupports*>((static_cast<nsISimplePlugin*>(this)));
AddRef();
return NS_OK;
}
return NS_NOINTERFACE;
}
void nsScriptablePeer::SetInstance(nsPluginInstance* plugin)
{
mPlugin = plugin;
}
//
// the following method will be callable from JavaScript
//
NS_IMETHODIMP nsScriptablePeer::GetVersion(char * *aVersion)
{
if (mPlugin)
mPlugin->getVersion(aVersion);
return NS_OK;
}

Просмотреть файл

@ -1,108 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// ==============================
// ! Scriptability related code !
// ==============================
//
// nsScriptablePeer - xpconnect scriptable peer
//
#ifndef __nsScriptablePeer_h__
#define __nsScriptablePeer_h__
#include "nsISimplePlugin.h"
#include "nsIClassInfo.h"
#include "nsIProgrammingLanguage.h"
class nsPluginInstance;
// We must implement nsIClassInfo because it signals the
// Mozilla Security Manager to allow calls from JavaScript.
class nsClassInfoMixin : public nsIClassInfo
{
// These flags are used by the DOM and security systems to signal that
// JavaScript callers are allowed to call this object's scritable methods.
NS_IMETHOD GetFlags(PRUint32 *aFlags)
{*aFlags = nsIClassInfo::PLUGIN_OBJECT | nsIClassInfo::DOM_OBJECT;
return NS_OK;}
NS_IMETHOD GetImplementationLanguage(PRUint32 *aImplementationLanguage)
{*aImplementationLanguage = nsIProgrammingLanguage::CPLUSPLUS;
return NS_OK;}
// The rest of the methods can safely return error codes...
NS_IMETHOD GetInterfaces(PRUint32 *count, nsIID * **array)
{return NS_ERROR_NOT_IMPLEMENTED;}
NS_IMETHOD GetHelperForLanguage(PRUint32 language, nsISupports **_retval)
{return NS_ERROR_NOT_IMPLEMENTED;}
NS_IMETHOD GetContractID(char * *aContractID)
{return NS_ERROR_NOT_IMPLEMENTED;}
NS_IMETHOD GetClassDescription(char * *aClassDescription)
{return NS_ERROR_NOT_IMPLEMENTED;}
NS_IMETHOD GetClassID(nsCID * *aClassID)
{return NS_ERROR_NOT_IMPLEMENTED;}
NS_IMETHOD GetClassIDNoAlloc(nsCID *aClassIDNoAlloc)
{return NS_ERROR_NOT_IMPLEMENTED;}
};
class nsScriptablePeer : public nsISimplePlugin,
public nsClassInfoMixin
{
public:
nsScriptablePeer(nsPluginInstance* plugin);
~nsScriptablePeer();
public:
// methods from nsISupports
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef();
NS_IMETHOD_(nsrefcnt) Release();
protected:
nsrefcnt mRefCnt;
public:
// native methods callable from JavaScript
NS_DECL_NSISIMPLEPLUGIN
void SetInstance(nsPluginInstance* plugin);
protected:
nsPluginInstance* mPlugin;
};
#endif

Просмотреть файл

@ -1,253 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "plugin.h"
#include "nsIServiceManager.h"
#include "nsIMemory.h"
#include "nsISupportsUtils.h" // this is where some useful macros defined
// service manager which will give the access to all public browser services
// we will use memory service as an illustration
nsIServiceManager * gServiceManager = NULL;
// Unix needs this
#ifdef XP_UNIX
#define MIME_TYPES_HANDLED "application/simple-plugin"
#define PLUGIN_NAME "Simple Plugin Example for Mozilla"
#define MIME_TYPES_DESCRIPTION MIME_TYPES_HANDLED"::"PLUGIN_NAME
#define PLUGIN_DESCRIPTION PLUGIN_NAME " (Plug-ins SDK sample)"
char* NPP_GetMIMEDescription(void)
{
return(MIME_TYPES_DESCRIPTION);
}
// get values per plugin
NPError NS_PluginGetValue(NPPVariable aVariable, void *aValue)
{
NPError err = NPERR_NO_ERROR;
switch (aVariable) {
case NPPVpluginNameString:
*((char **)aValue) = PLUGIN_NAME;
break;
case NPPVpluginDescriptionString:
*((char **)aValue) = PLUGIN_DESCRIPTION;
break;
default:
err = NPERR_INVALID_PARAM;
break;
}
return err;
}
#endif //XP_UNIX
//////////////////////////////////////
//
// general initialization and shutdown
//
NPError NS_PluginInitialize()
{
// this is probably a good place to get the service manager
// note that Mozilla will add reference, so do not forget to release
nsISupports * sm = NULL;
NPN_GetValue(NULL, NPNVserviceManager, &sm);
// Mozilla returns nsIServiceManager so we can use it directly; doing QI on
// nsISupports here can still be more appropriate in case something is changed
// in the future so we don't need to do casting of any sort.
if(sm) {
sm->QueryInterface(NS_GET_IID(nsIServiceManager), (void**)&gServiceManager);
NS_RELEASE(sm);
}
return NPERR_NO_ERROR;
}
void NS_PluginShutdown()
{
// we should release the service manager
NS_IF_RELEASE(gServiceManager);
gServiceManager = NULL;
}
/////////////////////////////////////////////////////////////
//
// construction and destruction of our plugin instance object
//
nsPluginInstanceBase * NS_NewPluginInstance(nsPluginCreateData * aCreateDataStruct)
{
if(!aCreateDataStruct)
return NULL;
nsPluginInstance * plugin = new nsPluginInstance(aCreateDataStruct->instance);
return plugin;
}
void NS_DestroyPluginInstance(nsPluginInstanceBase * aPlugin)
{
if(aPlugin)
delete (nsPluginInstance *)aPlugin;
}
////////////////////////////////////////
//
// nsPluginInstance class implementation
//
nsPluginInstance::nsPluginInstance(NPP aInstance) : nsPluginInstanceBase(),
mInstance(aInstance),
mInitialized(FALSE),
mScriptablePeer(NULL)
{
mString[0] = '\0';
}
nsPluginInstance::~nsPluginInstance()
{
// mScriptablePeer may be also held by the browser
// so releasing it here does not guarantee that it is over
// we should take precaution in case it will be called later
// and zero its mPlugin member
mScriptablePeer->SetInstance(NULL);
NS_IF_RELEASE(mScriptablePeer);
}
NPBool nsPluginInstance::init(NPWindow* aWindow)
{
if(aWindow == NULL)
return FALSE;
mInitialized = TRUE;
return TRUE;
}
void nsPluginInstance::shut()
{
mInitialized = FALSE;
}
NPBool nsPluginInstance::isInitialized()
{
return mInitialized;
}
void nsPluginInstance::getVersion(char* *aVersion)
{
const char *ua = NPN_UserAgent(mInstance);
char*& version = *aVersion;
// although we can use NPAPI NPN_MemAlloc call to allocate memory:
// version = (char*)NPN_MemAlloc(strlen(ua) + 1);
// for illustration purposed we use the service manager to access
// the memory service provided by Mozilla
nsIMemory * nsMemoryService = NULL;
if (gServiceManager) {
// get service using its contract id and use it to allocate the memory
gServiceManager->GetServiceByContractID("@mozilla.org/xpcom/memory-service;1", NS_GET_IID(nsIMemory), (void **)&nsMemoryService);
if(nsMemoryService)
version = (char *)nsMemoryService->Alloc(strlen(ua) + 1);
}
if (version)
strcpy(version, ua);
// release service
NS_IF_RELEASE(nsMemoryService);
}
// ==============================
// ! Scriptability related code !
// ==============================
//
// here the plugin is asked by Mozilla to tell if it is scriptable
// we should return a valid interface id and a pointer to
// nsScriptablePeer interface which we should have implemented
// and which should be defined in the corressponding *.xpt file
// in the bin/components folder
NPError nsPluginInstance::GetValue(NPPVariable aVariable, void *aValue)
{
NPError rv = NPERR_NO_ERROR;
switch (aVariable) {
case NPPVpluginScriptableInstance: {
// addref happens in getter, so we don't addref here
nsISimplePlugin * scriptablePeer = getScriptablePeer();
if (scriptablePeer) {
*(nsISupports **)aValue = scriptablePeer;
} else
rv = NPERR_OUT_OF_MEMORY_ERROR;
}
break;
case NPPVpluginScriptableIID: {
static nsIID scriptableIID = NS_ISIMPLEPLUGIN_IID;
nsIID* ptr = (nsIID *)NPN_MemAlloc(sizeof(nsIID));
if (ptr) {
*ptr = scriptableIID;
*(nsIID **)aValue = ptr;
} else
rv = NPERR_OUT_OF_MEMORY_ERROR;
}
break;
default:
break;
}
return rv;
}
// ==============================
// ! Scriptability related code !
// ==============================
//
// this method will return the scriptable object (and create it if necessary)
nsScriptablePeer* nsPluginInstance::getScriptablePeer()
{
if (!mScriptablePeer) {
mScriptablePeer = new nsScriptablePeer(this);
if(!mScriptablePeer)
return NULL;
NS_ADDREF(mScriptablePeer);
}
// add reference for the caller requesting the object
NS_ADDREF(mScriptablePeer);
return mScriptablePeer;
}

Просмотреть файл

@ -1,73 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __PLUGIN_H__
#define __PLUGIN_H__
#include "pluginbase.h"
#include "nsScriptablePeer.h"
class nsPluginInstance : public nsPluginInstanceBase
{
public:
nsPluginInstance(NPP aInstance);
~nsPluginInstance();
NPBool init(NPWindow* aWindow);
void shut();
NPBool isInitialized();
// we need to provide implementation of this method as it will be
// used by Mozilla to retrieve the scriptable peer
// and couple of other things on Unix
NPError GetValue(NPPVariable variable, void *value);
// locals
void getVersion(char* *aVersion);
nsScriptablePeer* getScriptablePeer();
private:
NPP mInstance;
NPBool mInitialized;
nsScriptablePeer * mScriptablePeer;
public:
char mString[128];
};
#endif // __PLUGIN_H__

Просмотреть файл

@ -1,12 +0,0 @@
Before building the project the following must be done.
1. ..\..\bin\xpidl -m header -I..\..\idl nsISimplePlugin.idl
This will generate nsISimplePlugin.h which is needed to successfuly
compile the plugin
2. ..\..\bin\xpidl -m typelib -I..\..\idl nsISimplePlugin.idl
This will create nsISimplePlugin.xpt file which should go to the
Mozilla Components folder.
Mechanism of accessing the service manager is implemented in Mozilla
builds starting with 0.9.4. It will not work with Netscape 6.1.

Просмотреть файл

@ -1,20 +0,0 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by simple.rc
//
#define IDD_MAIN 101
#define IDC_BUTTON_GO 1002
#define IDC_STATIC_UA 1003
#define IDC_BUTTON1 1005
#define IDC_BUTTON_DONT 1005
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1006
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

Просмотреть файл

@ -1,41 +1,12 @@
<HTML>
<HEAD>
<TITLE>Simple Plug-in Test</TITLE>
</HEAD>
<BODY>
<html>
<head>
<title>Simple Test</title>
</head>
<center>
<h1> XPConnect Scriptable Sample Plug-in </h1>
</center>
This page contains a testcase which demonstrates the work of scriptable
plug-in with Mozilla. This example plug-in has no native GUI and does not
draw anything in the plugin window. Clicking on the button will result in calling
native plugin method from JavaScript. Show Version will instruct the plug-in
to retrieve the Mozilla user agent string and return it to JavaScript to show
in the alert box.
<br><br>
<center>
<embed type="application/simple-plugin" width=1 height=1 hidden="true"><br>
<script>
var embed = document.embeds[0];
function ShowVersion()
{
alert(embed.version);
}
</script>
<br>
<form name="formname">
<input type=button value="Show Version" onclick='ShowVersion()'>
</form>
</center>
</BODY>
</HTML>
<body>
<center>
<h1>Simple Test</h1>
<embed type="application/x-simple" text="Hello World">
</center>
</body>
</html>