зеркало из https://github.com/mozilla/gecko-dev.git
Removing old cfm build files. Use the CFM_LAST_RITES tag to resurrect. r=macdev
This commit is contained in:
Родитель
ab240daa5f
Коммит
213fe95837
|
@ -1,96 +0,0 @@
|
|||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="GENERATOR" content="Mozilla/4.61 (Macintosh; I; PPC) [Netscape]">
|
||||
<title>MRJ Plugin Build Instructions</title>
|
||||
</head>
|
||||
<body bgcolor="#C0C0C0" link="#333333" vlink="#FF0000">
|
||||
|
||||
<center>
|
||||
<h2>
|
||||
MRJ Plugin Build Instructions</h2></center>
|
||||
|
||||
<center><i>(as of 2.V.2000)</i>
|
||||
<p>
|
||||
<hr></center>
|
||||
|
||||
<center>
|
||||
<h3>
|
||||
In 6ish or 8ish Easy Steps</h3></center>
|
||||
|
||||
<center><font size=-1>(this requires the general mac build environment
|
||||
as described on the <a href="http://www.mozilla.org/build/mac.html">Mozilla
|
||||
Mac Build Page</a>)</font></center>
|
||||
|
||||
<h4>
|
||||
Mac build environment additions:</h4>
|
||||
|
||||
<ol>
|
||||
<li>
|
||||
In order to keep with the myth that we "don't use ANYTHING relative to
|
||||
CodeWarrior MPW", copy the <b>StdCLib</b> stubs library from MPW (in CodeWarrior
|
||||
MPW:Interfaces&Libraries:Libraries:SharedLibraries) to <b>Metrowerks
|
||||
CodeWarrior:MacOS Support:Universal:Libraries:StubLibraries:</b></li>
|
||||
|
||||
<li>
|
||||
Now copy <b>jni.h</b> and <b>jni_md.h</b> from the latest <a href="ftp://ftp.apple.com/developer/Development_Kits/">MRJ
|
||||
SDK (MRJ_SDK_2.2 or later)</a> to <b>Metrowerks CodeWarrior:MacOS Support:Universal:Interfaces:CIncludes:</b></li>
|
||||
</ol>
|
||||
|
||||
<h4>
|
||||
Importing the CW project file:</h4>
|
||||
|
||||
<ol>
|
||||
<li>
|
||||
The current project file is stored as an importable XML file named <b>MRJPlugin.xml,</b>
|
||||
so you can do one of the following:</li>
|
||||
|
||||
<ol>
|
||||
<li>
|
||||
Run the AppleScript file called "MRJPlugin.import", and load the resultant
|
||||
CW project file in CodeWarrior</li>
|
||||
|
||||
<li>
|
||||
Or: from CW file menu, choose "Import Project..." and select the XML file.</li>
|
||||
</ol>
|
||||
</ol>
|
||||
|
||||
<h4>
|
||||
Building the plugin:</h4>
|
||||
|
||||
<ol>
|
||||
<li>
|
||||
Build the <i>MRJPlugin</i> target - this should automatically first build
|
||||
the <i>BackwardAdaptot</i> target. If it doesn't do this, do it by hand
|
||||
by choosing the <i>BackwardAdaptor</i> target and building.</li>
|
||||
|
||||
<li>
|
||||
Build the project <b>mozilla:js:macbuild:LiveConnectClasses.mcp</b>, and
|
||||
make an alias to the file <b>liveconnect.jar in mozilla:plugin:oji:MRJ:plugin:</b>;
|
||||
if <b>liveconnect.jar</b> cannot be found in <b>mozilla:js:macbuild:</b>
|
||||
after the build is successful, it can be found in <b>mozilla:dist:liveconnect:</b></li>
|
||||
|
||||
<li>
|
||||
Build the project <b>mozilla:plugin:oji:MRJ:testing:ConsoleApplet.mcp</b>,
|
||||
and make an alias to the file <b>ConsoleApplet.jar</b> in <b>mozilla:plugin:oji:MRJ:plugin:</b>.</li>
|
||||
|
||||
<li>
|
||||
Finally, build the <i>MRJPlugin.jar</i> target</li>
|
||||
|
||||
<li>
|
||||
To install the 5.X plugin, find the plugins folder for the debug; it should
|
||||
be <b>mozilla:dist:viewer_debug:Plugins:</b>. Drag both <b>MRJInABox</b>
|
||||
and <b>MRJPlugin.jar</b> into this folder. To install the 4.X plugin, drag
|
||||
both <b>MRJPlugin</b> and <b>MRJPlugin.jar</b> into your "Plug-ins" folder
|
||||
located inside your Netscape Communicator folder.</li>
|
||||
</ol>
|
||||
|
||||
<center>Well that's it. You should now have a working build of the MRJ
|
||||
plugin.
|
||||
<p>
|
||||
<hr>
|
||||
<p>If you have comments or suggestions, email <a href="mailto:beard@netscape.com">beard@netscape.com</a></center>
|
||||
|
||||
</body>
|
||||
</html>
|
Двоичные данные
plugin/oji/MRJ/plugin/MRJPlugin.jar
Двоичные данные
plugin/oji/MRJ/plugin/MRJPlugin.jar
Двоичный файл не отображается.
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Двоичные данные
plugin/oji/MRJ/plugin/Resources/Dialogs.rsrc
Двоичные данные
plugin/oji/MRJ/plugin/Resources/Dialogs.rsrc
Двоичный файл не отображается.
Двоичные данные
plugin/oji/MRJ/plugin/Resources/Strings.rsrc
Двоичные данные
plugin/oji/MRJ/plugin/Resources/Strings.rsrc
Двоичный файл не отображается.
Двоичные данные
plugin/oji/MRJ/plugin/Resources/Version.rsrc
Двоичные данные
plugin/oji/MRJ/plugin/Resources/Version.rsrc
Двоичный файл не отображается.
|
@ -1,74 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
AWTUtils.java
|
||||
*/
|
||||
|
||||
package netscape.oji;
|
||||
|
||||
|
||||
import java.awt.Container;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Point;
|
||||
|
||||
import com.apple.mrj.internal.awt.PrintingPort;
|
||||
|
||||
public class AWTUtils {
|
||||
/**
|
||||
* Prints the components of a specified Container.
|
||||
*/
|
||||
public static void printContainer(Container container, int printingPort, int originX, int originY, Object notifier) {
|
||||
try {
|
||||
// obtain a graphics object to draw with.
|
||||
PrintingPort printer = new PrintingPort(printingPort, originX, originY);
|
||||
Graphics graphics = printer.getGraphics(container);
|
||||
|
||||
// print the specified container.
|
||||
container.printAll(graphics);
|
||||
|
||||
graphics.dispose();
|
||||
printer.dispose();
|
||||
} finally {
|
||||
// if caller is waiting for this to complete, then notify.
|
||||
if (notifier != null) {
|
||||
synchronized(notifier) {
|
||||
notifier.notifyAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,296 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
AltWindowHandling.cpp
|
||||
|
||||
Due to a hole in the OJI API, 6.x still not able to open a new
|
||||
window from Java w/o a hack. thePluginManager2->RegisterWindow
|
||||
is doing nothing. Here I add Patrick's workaround used in 4.x.
|
||||
File will be used from TopLevelFrame::showHide()
|
||||
This code comes from the CPluginManager class in BackwardAdaptor.cpp.
|
||||
If the API is fixed, can remove this file and the two calls to it.
|
||||
|
||||
*/
|
||||
|
||||
#include <Controls.h>
|
||||
#include <Events.h>
|
||||
|
||||
#include "nsIPluginManager2.h"
|
||||
#include "EventFilter.h"
|
||||
#include "nsIEventHandler.h"
|
||||
|
||||
#include "AltWindowHandling.h"
|
||||
|
||||
RegisteredWindow* theRegisteredWindows = NULL;
|
||||
RegisteredWindow* theActiveWindow = NULL;
|
||||
Boolean mEventFiltersInstalled = nil;
|
||||
|
||||
Boolean EventFilter(EventRecord* event);
|
||||
Boolean MenuFilter(long menuSelection);
|
||||
RegisteredWindow** GetRegisteredWindow(nsPluginPlatformWindowRef window);
|
||||
|
||||
NS_METHOD
|
||||
AltRegisterWindow(nsIEventHandler* handler, nsPluginPlatformWindowRef window)
|
||||
{
|
||||
theRegisteredWindows = new RegisteredWindow(theRegisteredWindows, handler, window);
|
||||
|
||||
#ifdef XP_MAC
|
||||
// use jGNE to obtain events for registered windows.
|
||||
if (!mEventFiltersInstalled) {
|
||||
::InstallEventFilters(&EventFilter, &MenuFilter);
|
||||
mEventFiltersInstalled = true;
|
||||
}
|
||||
|
||||
// plugin expects the window to be shown and selected at this point.
|
||||
|
||||
SInt16 variant = ::GetWVariant(window);
|
||||
if (variant == plainDBox) {
|
||||
::ShowHide(window, true);
|
||||
::BringToFront(window);
|
||||
} else {
|
||||
::ShowWindow(window);
|
||||
::SelectWindow(window);
|
||||
}
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
AltUnregisterWindow(nsIEventHandler* handler, nsPluginPlatformWindowRef window)
|
||||
{
|
||||
RegisteredWindow** link = GetRegisteredWindow(window);
|
||||
if (link != NULL) {
|
||||
RegisteredWindow* registeredWindow = *link;
|
||||
if (registeredWindow == theActiveWindow)
|
||||
theActiveWindow = NULL;
|
||||
*link = registeredWindow->mNext;
|
||||
delete registeredWindow;
|
||||
}
|
||||
|
||||
#ifdef XP_MAC
|
||||
::HideWindow(window);
|
||||
|
||||
// if no windows registered, remove the filter.
|
||||
if (theRegisteredWindows == NULL) {
|
||||
::RemoveEventFilters();
|
||||
mEventFiltersInstalled = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static void sendActivateEvent(nsIEventHandler* handler, WindowRef window, Boolean active)
|
||||
{
|
||||
EventRecord event;
|
||||
::OSEventAvail(0, &event);
|
||||
event.what = activateEvt;
|
||||
event.message = UInt32(window);
|
||||
if (active)
|
||||
event.modifiers |= activeFlag;
|
||||
else
|
||||
event.modifiers &= ~activeFlag;
|
||||
|
||||
nsPluginEvent pluginEvent = { &event, window };
|
||||
PRBool handled = PR_FALSE;
|
||||
|
||||
handler->HandleEvent(&pluginEvent, &handled);
|
||||
}
|
||||
|
||||
RegisteredWindow** GetRegisteredWindow(nsPluginPlatformWindowRef window)
|
||||
{
|
||||
RegisteredWindow** link = &theRegisteredWindows;
|
||||
RegisteredWindow* registeredWindow = *link;
|
||||
while (registeredWindow != NULL) {
|
||||
if (registeredWindow->mWindow == window)
|
||||
return link;
|
||||
link = ®isteredWindow->mNext;
|
||||
registeredWindow = *link;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
RegisteredWindow* FindRegisteredWindow(nsPluginPlatformWindowRef window);
|
||||
RegisteredWindow* FindRegisteredWindow(nsPluginPlatformWindowRef window)
|
||||
{
|
||||
RegisteredWindow** link = GetRegisteredWindow(window);
|
||||
return (link != NULL ? *link : NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method filters events using a very low-level mechanism known as a jGNE filter.
|
||||
* This filter gets first crack at all events before they are returned by WaitNextEvent
|
||||
* or EventAvail. One trickiness is that the filter runs in all processes, so care
|
||||
* must be taken not to act on events if the browser's process isn't current.
|
||||
* So far, with activates, updates, and mouse clicks, it works quite well.
|
||||
*/
|
||||
Boolean EventFilter(EventRecord* event)
|
||||
{
|
||||
Boolean filteredEvent = false;
|
||||
|
||||
WindowRef window = WindowRef(event->message);
|
||||
nsPluginEvent pluginEvent = { event, window };
|
||||
EventRecord simulatedEvent;
|
||||
|
||||
RegisteredWindow* registeredWindow;
|
||||
PRBool handled = PR_FALSE;
|
||||
|
||||
// see if this event is for one of our registered windows.
|
||||
switch (event->what) {
|
||||
case nullEvent:
|
||||
// See if the frontmost window is one of our registered windows.
|
||||
// we want to somehow deliver mouse enter/leave events.
|
||||
window = ::FrontWindow();
|
||||
registeredWindow = FindRegisteredWindow(window);
|
||||
if (registeredWindow != NULL) {
|
||||
simulatedEvent = *event;
|
||||
simulatedEvent.what = nsPluginEventType_AdjustCursorEvent;
|
||||
pluginEvent.event = &simulatedEvent;
|
||||
pluginEvent.window = registeredWindow->mWindow;
|
||||
registeredWindow->mHandler->HandleEvent(&pluginEvent, &handled);
|
||||
}
|
||||
break;
|
||||
case keyDown:
|
||||
case keyUp:
|
||||
case autoKey:
|
||||
// See if the frontmost window is one of our registered windows.
|
||||
window = ::FrontWindow();
|
||||
registeredWindow = FindRegisteredWindow(window);
|
||||
if (registeredWindow != NULL) {
|
||||
pluginEvent.window = window;
|
||||
registeredWindow->mHandler->HandleEvent(&pluginEvent, &handled);
|
||||
filteredEvent = true;
|
||||
}
|
||||
break;
|
||||
case mouseDown:
|
||||
// use FindWindow to see if the click was in one our registered windows.
|
||||
short partCode = FindWindow(event->where, &window);
|
||||
switch (partCode) {
|
||||
case inContent:
|
||||
case inDrag:
|
||||
case inGrow:
|
||||
case inGoAway:
|
||||
case inZoomIn:
|
||||
case inZoomOut:
|
||||
case inCollapseBox:
|
||||
case inProxyIcon:
|
||||
registeredWindow = FindRegisteredWindow(window);
|
||||
if (registeredWindow != NULL) {
|
||||
// make sure this window has been activated before passing it the click.
|
||||
if (theActiveWindow == NULL) {
|
||||
sendActivateEvent(registeredWindow->mHandler, window, true);
|
||||
theActiveWindow = registeredWindow;
|
||||
}
|
||||
pluginEvent.window = window;
|
||||
registeredWindow->mHandler->HandleEvent(&pluginEvent, &handled);
|
||||
filteredEvent = true;
|
||||
} else if (theActiveWindow != NULL) {
|
||||
// a click is going into an unregistered window, if we are active,
|
||||
// the browser doesn't seem to be generating a deactivate event.
|
||||
// I think this is because PowerPlant is managing the windows, dang it.
|
||||
window = theActiveWindow->mWindow;
|
||||
sendActivateEvent(theActiveWindow->mHandler, window, false);
|
||||
::HiliteWindow(window, false);
|
||||
theActiveWindow = NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case activateEvt:
|
||||
registeredWindow = FindRegisteredWindow(window);
|
||||
if (registeredWindow != NULL) {
|
||||
registeredWindow->mHandler->HandleEvent(&pluginEvent, &handled);
|
||||
filteredEvent = true;
|
||||
theActiveWindow = registeredWindow;
|
||||
}
|
||||
break;
|
||||
case updateEvt:
|
||||
registeredWindow = FindRegisteredWindow(window);
|
||||
if (registeredWindow != NULL) {
|
||||
GrafPtr port; GetPort(&port); SetPort(window); BeginUpdate(window);
|
||||
registeredWindow->mHandler->HandleEvent(&pluginEvent, &handled);
|
||||
EndUpdate(window); SetPort(port);
|
||||
filteredEvent = true;
|
||||
}
|
||||
break;
|
||||
case osEvt:
|
||||
if ((event->message & osEvtMessageMask) == (suspendResumeMessage << 24)) {
|
||||
registeredWindow = theActiveWindow;
|
||||
if (registeredWindow != NULL) {
|
||||
window = registeredWindow->mWindow;
|
||||
Boolean active = (event->message & resumeFlag) != 0;
|
||||
sendActivateEvent(registeredWindow->mHandler, window, active);
|
||||
pluginEvent.window = window;
|
||||
registeredWindow->mHandler->HandleEvent(&pluginEvent, &handled);
|
||||
::HiliteWindow(window, active);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return filteredEvent;
|
||||
}
|
||||
|
||||
// TODO: find out what range of menus Communicator et. al. uses.
|
||||
enum {
|
||||
kBaseMenuID = 20000,
|
||||
kBaseSubMenuID = 200
|
||||
};
|
||||
|
||||
static PRInt16 nextMenuID = kBaseMenuID;
|
||||
static PRInt16 nextSubMenuID = kBaseSubMenuID;
|
||||
|
||||
Boolean MenuFilter(long menuSelection)
|
||||
{
|
||||
if (theActiveWindow != NULL) {
|
||||
UInt16 menuID = (menuSelection >> 16);
|
||||
if ((menuID >= kBaseMenuID && menuID < nextMenuID) || (menuID >= kBaseSubMenuID && menuID < nextSubMenuID)) {
|
||||
EventRecord menuEvent;
|
||||
::OSEventAvail(0, &menuEvent);
|
||||
menuEvent.what = nsPluginEventType_MenuCommandEvent;
|
||||
menuEvent.message = menuSelection;
|
||||
|
||||
WindowRef window = theActiveWindow->mWindow;
|
||||
nsPluginEvent pluginEvent = { &menuEvent, window };
|
||||
PRBool handled = PR_FALSE;
|
||||
theActiveWindow->mHandler->HandleEvent(&pluginEvent, &handled);
|
||||
|
||||
return handled;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
AltWindowHandling.h
|
||||
*/
|
||||
|
||||
typedef struct RegisteredWindow {
|
||||
RegisteredWindow* mNext;
|
||||
nsIEventHandler* mHandler;
|
||||
nsPluginPlatformWindowRef mWindow;
|
||||
|
||||
RegisteredWindow(RegisteredWindow* next, nsIEventHandler* handler, nsPluginPlatformWindowRef window)
|
||||
: mNext(next), mHandler(handler), mWindow(window)
|
||||
{
|
||||
NS_ADDREF(mHandler);
|
||||
}
|
||||
|
||||
~RegisteredWindow()
|
||||
{
|
||||
NS_RELEASE(mHandler);
|
||||
}
|
||||
} RegisteredWindow;
|
||||
|
||||
NS_METHOD
|
||||
AltRegisterWindow(nsIEventHandler* handler, nsPluginPlatformWindowRef window);
|
||||
|
||||
NS_METHOD
|
||||
AltUnregisterWindow(nsIEventHandler* handler, nsPluginPlatformWindowRef window);
|
|
@ -1,58 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
AsyncMessage.h
|
||||
|
||||
Base class for messages that are executed asynchronously, during MRJSession idle time.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "MRJSession.h"
|
||||
|
||||
class AsyncMessage : public NativeMessage {
|
||||
public:
|
||||
AsyncMessage(MRJSession* session) : mSession(session) {}
|
||||
virtual ~AsyncMessage() {}
|
||||
|
||||
void send(Boolean async = false);
|
||||
|
||||
protected:
|
||||
MRJSession* mSession;
|
||||
};
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,409 +0,0 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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
|
||||
* Sun Microsystems, Inc. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
/*
|
||||
CSecureEnv.h
|
||||
|
||||
Rewritten for use with MRJ plugin by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
#ifndef CSecureJNI2_h___
|
||||
#define CSecureJNI_h___
|
||||
|
||||
#include "nsISecureEnv.h"
|
||||
#include "nsIThreadManager.h"
|
||||
#include "SupportsMixin.h"
|
||||
#include "nsAgg.h"
|
||||
|
||||
class MRJPlugin;
|
||||
class MRJSession;
|
||||
|
||||
class Monitor;
|
||||
class nsIThreadManager;
|
||||
class nsIJVMManager;
|
||||
|
||||
class JavaMessage;
|
||||
class JavaMessageQueue;
|
||||
|
||||
class CSecureEnv : public nsISecureEnv, public nsIRunnable, private SupportsMixin {
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// from nsISupports and AggregatedQueryInterface:
|
||||
|
||||
// NS_DECL_AGGREGATED
|
||||
DECL_SUPPORTS_MIXIN
|
||||
|
||||
static NS_METHOD Create(MRJPlugin* plugin, JNIEnv* proxyEnv, const nsIID& aIID, void* *aInstancePtr);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// from nsISecureJNI2:
|
||||
|
||||
|
||||
/**
|
||||
* Create new Java object in LiveConnect.
|
||||
*
|
||||
* @param clazz -- Java Class object.
|
||||
* @param methodID -- Method id
|
||||
* @param args -- arguments for invoking the constructor.
|
||||
* @param result -- return new Java object.
|
||||
* @param ctx -- security context
|
||||
*/
|
||||
NS_IMETHOD NewObject(/*[in]*/ jclass clazz,
|
||||
/*[in]*/ jmethodID methodID,
|
||||
/*[in]*/ jvalue *args,
|
||||
/*[out]*/ jobject* result,
|
||||
/*[in]*/ nsISecurityContext* ctx = NULL);
|
||||
|
||||
/**
|
||||
* Invoke method on Java object in LiveConnect.
|
||||
*
|
||||
* @param type -- Return type
|
||||
* @param obj -- Java object.
|
||||
* @param methodID -- method id
|
||||
* @param args -- arguments for invoking the constructor.
|
||||
* @param result -- return result of invocation.
|
||||
* @param ctx -- security context
|
||||
*/
|
||||
NS_IMETHOD CallMethod(/*[in]*/ jni_type type,
|
||||
/*[in]*/ jobject obj,
|
||||
/*[in]*/ jmethodID methodID,
|
||||
/*[in]*/ jvalue *args,
|
||||
/*[out]*/ jvalue* result,
|
||||
/*[in]*/ nsISecurityContext* ctx = NULL);
|
||||
|
||||
/**
|
||||
* Invoke non-virtual method on Java object in LiveConnect.
|
||||
*
|
||||
* @param type -- Return type
|
||||
* @param obj -- Java object.
|
||||
* @param clazz -- Class object
|
||||
* @param methodID -- method id
|
||||
* @param args -- arguments for invoking the constructor.
|
||||
* @param ctx -- security context
|
||||
* @param result -- return result of invocation.
|
||||
*/
|
||||
NS_IMETHOD CallNonvirtualMethod(/*[in]*/ jni_type type,
|
||||
/*[in]*/ jobject obj,
|
||||
/*[in]*/ jclass clazz,
|
||||
/*[in]*/ jmethodID methodID,
|
||||
/*[in]*/ jvalue *args,
|
||||
/*[out]*/ jvalue* result,
|
||||
/*[in]*/ nsISecurityContext* ctx = NULL);
|
||||
|
||||
/**
|
||||
* Get a field on Java object in LiveConnect.
|
||||
*
|
||||
* @param type -- Return type
|
||||
* @param obj -- Java object.
|
||||
* @param fieldID -- field id
|
||||
* @param result -- return field value
|
||||
* @param ctx -- security context
|
||||
*/
|
||||
NS_IMETHOD GetField(/*[in]*/ jni_type type,
|
||||
/*[in]*/ jobject obj,
|
||||
/*[in]*/ jfieldID fieldID,
|
||||
/*[out]*/ jvalue* result,
|
||||
/*[in]*/ nsISecurityContext* ctx = NULL);
|
||||
|
||||
/**
|
||||
* Set a field on Java object in LiveConnect.
|
||||
*
|
||||
* @param type -- Return type
|
||||
* @param obj -- Java object.
|
||||
* @param fieldID -- field id
|
||||
* @param val -- field value to set
|
||||
* @param ctx -- security context
|
||||
*/
|
||||
NS_IMETHOD SetField(/*[in]*/ jni_type type,
|
||||
/*[in]*/ jobject obj,
|
||||
/*[in]*/ jfieldID fieldID,
|
||||
/*[in]*/ jvalue val,
|
||||
/*[in]*/ nsISecurityContext* ctx = NULL);
|
||||
|
||||
/**
|
||||
* Invoke static method on Java object in LiveConnect.
|
||||
*
|
||||
* @param type -- Return type
|
||||
* @param clazz -- Class object.
|
||||
* @param methodID -- method id
|
||||
* @param args -- arguments for invoking the constructor.
|
||||
* @param result -- return result of invocation.
|
||||
* @param ctx -- security context
|
||||
*/
|
||||
NS_IMETHOD CallStaticMethod(/*[in]*/ jni_type type,
|
||||
/*[in]*/ jclass clazz,
|
||||
/*[in]*/ jmethodID methodID,
|
||||
/*[in]*/ jvalue *args,
|
||||
/*[out]*/ jvalue* result,
|
||||
/*[in]*/ nsISecurityContext* ctx = NULL);
|
||||
|
||||
/**
|
||||
* Get a static field on Java object in LiveConnect.
|
||||
*
|
||||
* @param type -- Return type
|
||||
* @param clazz -- Class object.
|
||||
* @param fieldID -- field id
|
||||
* @param result -- return field value
|
||||
* @param ctx -- security context
|
||||
*/
|
||||
NS_IMETHOD GetStaticField(/*[in]*/ jni_type type,
|
||||
/*[in]*/ jclass clazz,
|
||||
/*[in]*/ jfieldID fieldID,
|
||||
/*[out]*/ jvalue* result,
|
||||
/*[in]*/ nsISecurityContext* ctx = NULL);
|
||||
|
||||
|
||||
/**
|
||||
* Set a static field on Java object in LiveConnect.
|
||||
*
|
||||
* @param type -- Return type
|
||||
* @param clazz -- Class object.
|
||||
* @param fieldID -- field id
|
||||
* @param val -- field value to set
|
||||
* @param ctx -- security context
|
||||
*/
|
||||
NS_IMETHOD SetStaticField(/*[in]*/ jni_type type,
|
||||
/*[in]*/ jclass clazz,
|
||||
/*[in]*/ jfieldID fieldID,
|
||||
/*[in]*/ jvalue val,
|
||||
/*[in]*/ nsISecurityContext* ctx = NULL);
|
||||
|
||||
|
||||
NS_IMETHOD GetVersion(/*[out]*/ jint* version);
|
||||
|
||||
NS_IMETHOD DefineClass(/*[in]*/ const char* name,
|
||||
/*[in]*/ jobject loader,
|
||||
/*[in]*/ const jbyte *buf,
|
||||
/*[in]*/ jsize len,
|
||||
/*[out]*/ jclass* clazz);
|
||||
|
||||
NS_IMETHOD FindClass(/*[in]*/ const char* name,
|
||||
/*[out]*/ jclass* clazz);
|
||||
|
||||
NS_IMETHOD GetSuperclass(/*[in]*/ jclass sub,
|
||||
/*[out]*/ jclass* super);
|
||||
|
||||
NS_IMETHOD IsAssignableFrom(/*[in]*/ jclass sub,
|
||||
/*[in]*/ jclass super,
|
||||
/*[out]*/ jboolean* result);
|
||||
|
||||
NS_IMETHOD Throw(/*[in]*/ jthrowable obj,
|
||||
/*[out]*/ jint* result);
|
||||
|
||||
NS_IMETHOD ThrowNew(/*[in]*/ jclass clazz,
|
||||
/*[in]*/ const char *msg,
|
||||
/*[out]*/ jint* result);
|
||||
|
||||
NS_IMETHOD ExceptionOccurred(/*[out]*/ jthrowable* result);
|
||||
|
||||
NS_IMETHOD ExceptionDescribe(void);
|
||||
|
||||
NS_IMETHOD ExceptionClear(void);
|
||||
|
||||
NS_IMETHOD FatalError(/*[in]*/ const char* msg);
|
||||
|
||||
NS_IMETHOD NewGlobalRef(/*[in]*/ jobject lobj,
|
||||
/*[out]*/ jobject* result);
|
||||
|
||||
NS_IMETHOD DeleteGlobalRef(/*[in]*/ jobject gref);
|
||||
|
||||
NS_IMETHOD DeleteLocalRef(/*[in]*/ jobject obj);
|
||||
|
||||
NS_IMETHOD IsSameObject(/*[in]*/ jobject obj1,
|
||||
/*[in]*/ jobject obj2,
|
||||
/*[out]*/ jboolean* result);
|
||||
|
||||
NS_IMETHOD AllocObject(/*[in]*/ jclass clazz,
|
||||
/*[out]*/ jobject* result);
|
||||
|
||||
NS_IMETHOD GetObjectClass(/*[in]*/ jobject obj,
|
||||
/*[out]*/ jclass* result);
|
||||
|
||||
NS_IMETHOD IsInstanceOf(/*[in]*/ jobject obj,
|
||||
/*[in]*/ jclass clazz,
|
||||
/*[out]*/ jboolean* result);
|
||||
|
||||
NS_IMETHOD GetMethodID(/*[in]*/ jclass clazz,
|
||||
/*[in]*/ const char* name,
|
||||
/*[in]*/ const char* sig,
|
||||
/*[out]*/ jmethodID* id);
|
||||
|
||||
NS_IMETHOD GetFieldID(/*[in]*/ jclass clazz,
|
||||
/*[in]*/ const char* name,
|
||||
/*[in]*/ const char* sig,
|
||||
/*[out]*/ jfieldID* id);
|
||||
|
||||
NS_IMETHOD GetStaticMethodID(/*[in]*/ jclass clazz,
|
||||
/*[in]*/ const char* name,
|
||||
/*[in]*/ const char* sig,
|
||||
/*[out]*/ jmethodID* id);
|
||||
|
||||
NS_IMETHOD GetStaticFieldID(/*[in]*/ jclass clazz,
|
||||
/*[in]*/ const char* name,
|
||||
/*[in]*/ const char* sig,
|
||||
/*[out]*/ jfieldID* id);
|
||||
|
||||
NS_IMETHOD NewString(/*[in]*/ const jchar* unicode,
|
||||
/*[in]*/ jsize len,
|
||||
/*[out]*/ jstring* result);
|
||||
|
||||
NS_IMETHOD GetStringLength(/*[in]*/ jstring str,
|
||||
/*[out]*/ jsize* result);
|
||||
|
||||
NS_IMETHOD GetStringChars(/*[in]*/ jstring str,
|
||||
/*[in]*/ jboolean *isCopy,
|
||||
/*[out]*/ const jchar** result);
|
||||
|
||||
NS_IMETHOD ReleaseStringChars(/*[in]*/ jstring str,
|
||||
/*[in]*/ const jchar *chars);
|
||||
|
||||
NS_IMETHOD NewStringUTF(/*[in]*/ const char *utf,
|
||||
/*[out]*/ jstring* result);
|
||||
|
||||
NS_IMETHOD GetStringUTFLength(/*[in]*/ jstring str,
|
||||
/*[out]*/ jsize* result);
|
||||
|
||||
NS_IMETHOD GetStringUTFChars(/*[in]*/ jstring str,
|
||||
/*[in]*/ jboolean *isCopy,
|
||||
/*[out]*/ const char** result);
|
||||
|
||||
NS_IMETHOD ReleaseStringUTFChars(/*[in]*/ jstring str,
|
||||
/*[in]*/ const char *chars);
|
||||
|
||||
NS_IMETHOD GetArrayLength(/*[in]*/ jarray array,
|
||||
/*[out]*/ jsize* result);
|
||||
|
||||
NS_IMETHOD NewObjectArray(/*[in]*/ jsize len,
|
||||
/*[in]*/ jclass clazz,
|
||||
/*[in]*/ jobject init,
|
||||
/*[out]*/ jobjectArray* result);
|
||||
|
||||
NS_IMETHOD GetObjectArrayElement(/*[in]*/ jobjectArray array,
|
||||
/*[in]*/ jsize index,
|
||||
/*[out]*/ jobject* result);
|
||||
|
||||
NS_IMETHOD SetObjectArrayElement(/*[in]*/ jobjectArray array,
|
||||
/*[in]*/ jsize index,
|
||||
/*[in]*/ jobject val);
|
||||
|
||||
NS_IMETHOD NewArray(/*[in]*/ jni_type element_type,
|
||||
/*[in]*/ jsize len,
|
||||
/*[out]*/ jarray* result);
|
||||
|
||||
NS_IMETHOD GetArrayElements(/*[in]*/ jni_type type,
|
||||
/*[in]*/ jarray array,
|
||||
/*[in]*/ jboolean *isCopy,
|
||||
/*[out]*/ void* result);
|
||||
|
||||
NS_IMETHOD ReleaseArrayElements(/*[in]*/ jni_type type,
|
||||
/*[in]*/ jarray array,
|
||||
/*[in]*/ void *elems,
|
||||
/*[in]*/ jint mode);
|
||||
|
||||
NS_IMETHOD GetArrayRegion(/*[in]*/ jni_type type,
|
||||
/*[in]*/ jarray array,
|
||||
/*[in]*/ jsize start,
|
||||
/*[in]*/ jsize len,
|
||||
/*[out]*/ void* buf);
|
||||
|
||||
NS_IMETHOD SetArrayRegion(/*[in]*/ jni_type type,
|
||||
/*[in]*/ jarray array,
|
||||
/*[in]*/ jsize start,
|
||||
/*[in]*/ jsize len,
|
||||
/*[in]*/ void* buf);
|
||||
|
||||
NS_IMETHOD RegisterNatives(/*[in]*/ jclass clazz,
|
||||
/*[in]*/ const JNINativeMethod *methods,
|
||||
/*[in]*/ jint nMethods,
|
||||
/*[out]*/ jint* result);
|
||||
|
||||
NS_IMETHOD UnregisterNatives(/*[in]*/ jclass clazz,
|
||||
/*[out]*/ jint* result);
|
||||
|
||||
NS_IMETHOD MonitorEnter(/*[in]*/ jobject obj,
|
||||
/*[out]*/ jint* result);
|
||||
|
||||
NS_IMETHOD MonitorExit(/*[in]*/ jobject obj,
|
||||
/*[out]*/ jint* result);
|
||||
|
||||
NS_IMETHOD GetJavaVM(/*[in]*/ JavaVM **vm,
|
||||
/*[out]*/ jint* result);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// from nsIRunnable:
|
||||
|
||||
NS_IMETHOD Run();
|
||||
|
||||
CSecureEnv(MRJPlugin* plugin, JNIEnv* proxyEnv, JNIEnv* javaEnv = NULL);
|
||||
virtual ~CSecureEnv(void);
|
||||
|
||||
/**
|
||||
* Called by the native run method, to connect the
|
||||
* thread and the secure env.
|
||||
*/
|
||||
void initialize(JNIEnv* javaEnv, jboolean* isRunning, JavaMessageQueue* javaQueue, JavaMessageQueue* nativeQueue);
|
||||
|
||||
jboolean isInitialized() { return mJavaQueue != NULL; }
|
||||
|
||||
void setProxyEnv(JNIEnv* proxyEnv) { mProxyEnv = proxyEnv; }
|
||||
JNIEnv* getProxyEnv() { return mProxyEnv; }
|
||||
|
||||
void setJavaEnv(JNIEnv* javaEnv) { mJavaEnv = javaEnv; }
|
||||
JNIEnv* getJavaEnv() { return mJavaEnv; }
|
||||
|
||||
MRJSession* getSession() { return mSession; }
|
||||
nsIThreadManager* getThreadManager() { return mThreadManager; }
|
||||
|
||||
void getMessageQueues(JavaMessageQueue*& javaQueue, JavaMessageQueue*& nativeQueue)
|
||||
{
|
||||
javaQueue = mJavaQueue;
|
||||
nativeQueue = mNativeQueue;
|
||||
}
|
||||
|
||||
void sendMessageToJava(JavaMessage* msg);
|
||||
void sendMessageFromJava(JNIEnv* javaEnv, JavaMessage* msg, Boolean busyWaiting = false);
|
||||
void messageLoop(JNIEnv* env, JavaMessage* msgToSend, JavaMessageQueue* sendQueue, JavaMessageQueue* receiveQueue, Boolean busyWaiting = false);
|
||||
|
||||
protected:
|
||||
|
||||
MRJPlugin* mPlugin;
|
||||
JNIEnv* mProxyEnv;
|
||||
MRJSession* mSession;
|
||||
nsIThreadManager* mThreadManager;
|
||||
|
||||
JNIEnv* mJavaEnv;
|
||||
jboolean* mIsRunning;
|
||||
JavaMessageQueue* mJavaQueue;
|
||||
JavaMessageQueue* mNativeQueue;
|
||||
|
||||
private:
|
||||
// support for SupportsMixin.
|
||||
static const InterfaceInfo sInterfaces[];
|
||||
static const UInt32 kInterfaceCount;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the secure JNI associated with the current thread (if any).
|
||||
*/
|
||||
CSecureEnv* GetSecureJNI(JNIEnv* env, jobject thread);
|
||||
|
||||
#endif // CSecureJNI2_h___
|
|
@ -1,331 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
TopLevelFrame.cpp
|
||||
|
||||
An MRJFrame sub-class that manages the behavior of a top-level window
|
||||
running inside the Communicator.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
#include <Controls.h>
|
||||
#include <Events.h>
|
||||
|
||||
#include "EmbeddedFrame.h"
|
||||
#include "EmbeddedFramePluginInstance.h"
|
||||
#include "MRJPlugin.h"
|
||||
#include "MRJSession.h"
|
||||
|
||||
#include "nsIPluginInstancePeer.h"
|
||||
#include "nsIOutputStream.h"
|
||||
#include "JSEvaluator.h"
|
||||
#include "LocalPort.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
static void UnsetPort(GrafPtr port);
|
||||
|
||||
EmbeddedFrame::EmbeddedFrame(MRJPluginInstance* pluginInstance, JMFrameRef frameRef, JMFrameKind kind,
|
||||
const Rect* initialBounds, Boolean resizeable)
|
||||
: MRJFrame(frameRef),
|
||||
mPluginInstance(NULL), mEvaluator(NULL), mWindow(NULL), mBounds(*initialBounds)
|
||||
{
|
||||
Boolean hasGoAway = true;
|
||||
SInt16 windowProc = documentProc;
|
||||
SInt16 resizeHeight = resizeable ? 15 : 0;
|
||||
|
||||
switch (kind) {
|
||||
case eBorderlessModelessWindowFrame:
|
||||
hasGoAway = false;
|
||||
windowProc = plainDBox;
|
||||
// mBounds.bottom += resizeHeight;
|
||||
resizeable = false;
|
||||
break;
|
||||
case eModelessWindowFrame:
|
||||
case eModelessDialogFrame:
|
||||
hasGoAway = true;
|
||||
windowProc = resizeable ? zoomDocProc : documentProc;
|
||||
// mBounds.bottom += resizeHeight;
|
||||
break;
|
||||
case eModalWindowFrame:
|
||||
hasGoAway = true;
|
||||
// We have to allow resizeable modal windows.
|
||||
windowProc = resizeable ? documentProc : movableDBoxProc;
|
||||
break;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
// Note: opening a new window on a stream using the following code crashes 4.X browsers.
|
||||
// The problem is that the window has no URL assigned to it, and so some variables are
|
||||
// unitialized and the browser crashes in a call to strlen().
|
||||
|
||||
class NewStreamMessage : public NativeMessage {
|
||||
nsIPluginInstancePeer* mPeer;
|
||||
const char* mType;
|
||||
public:
|
||||
NewStreamMessage(nsIPluginInstancePeer* peer, const char* type) : mPeer(peer), mType(type) {}
|
||||
|
||||
virtual void execute() {
|
||||
nsIOutputStream* output = NULL;
|
||||
if (mPeer->NewStream(mType, "_new", &output) == NS_OK) {
|
||||
// write some data to the stream.
|
||||
output->Close();
|
||||
NS_RELEASE(output);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// open a stream of type "application/x-java-frame", which should cause a full-screen plugin to get created for a Java frame's
|
||||
// behalf. communicate with the other instance via this stream.
|
||||
nsIPluginInstancePeer* peer = NULL;
|
||||
if (pluginInstance->GetPeer(&peer) == NS_OK) {
|
||||
NewStreamMessage msg(peer, "application/x-java-frame");
|
||||
pluginInstance->getSession()->sendMessage(&msg);
|
||||
NS_RELEASE(peer);
|
||||
}
|
||||
|
||||
#else
|
||||
// var w = window.open('', '_new','resizable=no,status=no,width=200,height=200'); d = w.document; d.open(); d.write('<BODY MARGINHEIGHT=0 MARGINWIDTH=0>Hi</BODY>'); d.close();
|
||||
|
||||
static UInt32 embeddedFrameCounter = 0;
|
||||
|
||||
// Use JavaScript to create a window with an <EMBED TYPE="application/x-java-frame"> tag.
|
||||
const char* kEmbeddedFrameScript = "var w = window.open('','__MRJ_JAVA_FRAME_%d__','resizable=no,status=no,width=%d,height=%d,screenX=%d,screenY=%d');"
|
||||
"var d = w.document; d.open();"
|
||||
"d.writeln('<BODY BGCOLOR=#FFFFFF MARGINWIDTH=0 MARGINHEIGHT=0> <EMBED TYPE=application/x-java-frame WIDTH=%d HEIGHT=%d JAVAFRAME=%08X>');"
|
||||
"d.close();";
|
||||
|
||||
int width = mBounds.right - mBounds.left;
|
||||
int height = mBounds.bottom - mBounds.top;
|
||||
int screenX = mBounds.left;
|
||||
int screenY = mBounds.top;
|
||||
|
||||
char* script = new char[::strlen(kEmbeddedFrameScript) + 100];
|
||||
::sprintf(script, kEmbeddedFrameScript, ++embeddedFrameCounter, width, height, screenX, screenY, width, height, this);
|
||||
|
||||
JSEvaluator* evaluator = new JSEvaluator(pluginInstance);
|
||||
evaluator->AddRef();
|
||||
|
||||
// create the window. It will have been created after returning from eval.
|
||||
const char* result = evaluator->eval(script);
|
||||
|
||||
evaluator->Release();
|
||||
|
||||
delete[] script;
|
||||
|
||||
#endif
|
||||
|
||||
if (mWindow != NULL) {
|
||||
Point zeroPt = { 0, 0 };
|
||||
::JMSetFrameVisibility(mFrameRef, mWindow, zeroPt, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
EmbeddedFrame::~EmbeddedFrame()
|
||||
{
|
||||
if (mPluginInstance != NULL)
|
||||
mPluginInstance->setFrame(NULL);
|
||||
|
||||
// make sure the window is hidden (and unregistered with the browser).
|
||||
showHide(false);
|
||||
|
||||
// make sure this port isn't ever current again.
|
||||
::UnsetPort(mWindow);
|
||||
|
||||
// if (mWindow != NULL)
|
||||
// ::DisposeWindow(mWindow);
|
||||
}
|
||||
|
||||
void EmbeddedFrame::setSize(const Rect* newSize)
|
||||
{
|
||||
mBounds = *newSize;
|
||||
|
||||
if (mWindow != NULL) {
|
||||
SInt16 width = newSize->right - newSize->left;
|
||||
SInt16 height = newSize->bottom - newSize->top;
|
||||
::SizeWindow(mWindow, width, height, true);
|
||||
::MoveWindow(mWindow, newSize->left, newSize->top, false);
|
||||
}
|
||||
}
|
||||
|
||||
void EmbeddedFrame::invalRect(const Rect* invalidRect)
|
||||
{
|
||||
if (mWindow != NULL) {
|
||||
::InvalRect(invalidRect);
|
||||
}
|
||||
}
|
||||
|
||||
void EmbeddedFrame::showHide(Boolean visible)
|
||||
{
|
||||
if (mWindow != NULL && visible != IsWindowVisible(mWindow)) {
|
||||
if (visible) {
|
||||
// Have to notify the browser that this window exists, so that it will receive events.
|
||||
::ShowWindow(mWindow);
|
||||
::SelectWindow(mWindow);
|
||||
} else {
|
||||
::HideWindow(mWindow);
|
||||
}
|
||||
|
||||
// ::ShowHide(mWindow, visible);
|
||||
}
|
||||
}
|
||||
|
||||
void EmbeddedFrame::setTitle(const StringPtr title)
|
||||
{
|
||||
if (mWindow != NULL) {
|
||||
::SetWTitle(mWindow, title);
|
||||
}
|
||||
}
|
||||
|
||||
void EmbeddedFrame::checkUpdate()
|
||||
{
|
||||
}
|
||||
|
||||
void EmbeddedFrame::reorder(ReorderRequest request)
|
||||
{
|
||||
switch (request) {
|
||||
case eBringToFront: /* bring the window to front */
|
||||
break;
|
||||
case eSendToBack: /* send the window to back */
|
||||
break;
|
||||
case eSendBehindFront: /* send the window behind the front window */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void EmbeddedFrame::setResizeable(Boolean resizeable)
|
||||
{
|
||||
// this might have to recreate the window, no?
|
||||
}
|
||||
|
||||
static void computeBounds(WindowRef window, Rect* bounds)
|
||||
{
|
||||
LocalPort port(window);
|
||||
port.Enter();
|
||||
|
||||
Point position = { 0, 0 };
|
||||
::LocalToGlobal(&position);
|
||||
|
||||
*bounds = window->portRect;
|
||||
|
||||
port.Exit();
|
||||
|
||||
::OffsetRect(bounds, position.h, position.v);
|
||||
}
|
||||
|
||||
void EmbeddedFrame::activate(Boolean active)
|
||||
{
|
||||
focusEvent(active);
|
||||
MRJFrame::activate(active);
|
||||
}
|
||||
|
||||
void EmbeddedFrame::click(const EventRecord* event)
|
||||
{
|
||||
Point where = event->where;
|
||||
SInt16 modifiers = event->modifiers;
|
||||
WindowRef hitWindow;
|
||||
short partCode = ::FindWindow(where, &hitWindow);
|
||||
switch (partCode) {
|
||||
case inContent:
|
||||
::SelectWindow(mWindow);
|
||||
MRJFrame::click(event);
|
||||
break;
|
||||
case inDrag:
|
||||
Rect bounds = (**GetGrayRgn()).rgnBBox;
|
||||
DragWindow(mWindow, where, &bounds);
|
||||
computeBounds(mWindow, &mBounds);
|
||||
break;
|
||||
case inGrow:
|
||||
Rect limits = { 30, 30, 5000, 5000 };
|
||||
long result = GrowWindow(mWindow, where, &limits);
|
||||
if (result != 0) {
|
||||
short width = (result & 0xFFFF);
|
||||
short height = (result >> 16) & 0xFFFF;
|
||||
Rect newBounds;
|
||||
topLeft(newBounds) = topLeft(mBounds);
|
||||
newBounds.right = newBounds.left + width;
|
||||
newBounds.bottom = newBounds.top + height;
|
||||
::JMSetFrameSize(mFrameRef, &newBounds);
|
||||
}
|
||||
break;
|
||||
case inGoAway:
|
||||
if (::TrackGoAway(mWindow, where))
|
||||
::JMFrameGoAway(mFrameRef);
|
||||
break;
|
||||
case inZoomIn:
|
||||
case inZoomOut:
|
||||
if (::TrackBox(mWindow, where, partCode)) {
|
||||
ZoomWindow(mWindow, partCode, true);
|
||||
computeBounds(mWindow, &mBounds);
|
||||
::JMSetFrameSize(mFrameRef, &mBounds);
|
||||
}
|
||||
break;
|
||||
case inCollapseBox:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void EmbeddedFrame::setPluginInstance(EmbeddedFramePluginInstance* embeddedInstance)
|
||||
{
|
||||
mPluginInstance = embeddedInstance;
|
||||
}
|
||||
|
||||
void EmbeddedFrame::setWindow(WindowRef window)
|
||||
{
|
||||
mWindow = window;
|
||||
}
|
||||
|
||||
WindowRef EmbeddedFrame::getWindow()
|
||||
{
|
||||
return mWindow;
|
||||
}
|
||||
|
||||
GrafPtr EmbeddedFrame::getPort()
|
||||
{
|
||||
return mWindow;
|
||||
}
|
||||
|
||||
static void UnsetPort(GrafPtr port)
|
||||
{
|
||||
GrafPtr curPort;
|
||||
::GetPort(&curPort);
|
||||
if (curPort == port) {
|
||||
::GetWMgrPort(&port);
|
||||
::SetPort(port);
|
||||
}
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
EmbeddedFrame.h
|
||||
|
||||
An MRJFrame sub-class that manages the behavior of a top-level window
|
||||
running inside the Communicator.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "MRJFrame.h"
|
||||
|
||||
#ifndef __MACWINDOWS__
|
||||
#include <MacWindows.h>
|
||||
#endif
|
||||
|
||||
class MRJPluginInstance;
|
||||
class EmbeddedFramePluginInstance;
|
||||
class JSEvaluator;
|
||||
|
||||
class EmbeddedFrame : public MRJFrame {
|
||||
public:
|
||||
EmbeddedFrame(MRJPluginInstance* pluginInstance, JMFrameRef frameRef, JMFrameKind kind, const Rect* initialBounds, Boolean resizeable);
|
||||
virtual ~EmbeddedFrame();
|
||||
|
||||
virtual void setSize(const Rect* newSize);
|
||||
virtual void invalRect(const Rect* invalidRect);
|
||||
virtual void showHide(Boolean visible);
|
||||
virtual void setTitle(const StringPtr title);
|
||||
virtual void checkUpdate();
|
||||
virtual void reorder(ReorderRequest request);
|
||||
virtual void setResizeable(Boolean resizeable);
|
||||
|
||||
virtual void activate(Boolean active);
|
||||
virtual void click(const EventRecord* event);
|
||||
|
||||
void setPluginInstance(EmbeddedFramePluginInstance* embeddedInstance);
|
||||
|
||||
void setWindow(WindowRef window);
|
||||
WindowRef getWindow();
|
||||
|
||||
protected:
|
||||
virtual GrafPtr getPort();
|
||||
|
||||
private:
|
||||
EmbeddedFramePluginInstance* mPluginInstance;
|
||||
JSEvaluator* mEvaluator;
|
||||
WindowRef mWindow;
|
||||
Rect mBounds;
|
||||
};
|
|
@ -1,126 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
EmbeddedFramePluginInstance.cpp
|
||||
*/
|
||||
|
||||
#include "EmbeddedFramePluginInstance.h"
|
||||
#include "EmbeddedFrame.h"
|
||||
#include "MRJPlugin.h"
|
||||
|
||||
#include "nsIPluginInstancePeer.h"
|
||||
#include "nsIPluginTagInfo.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
EmbeddedFramePluginInstance::EmbeddedFramePluginInstance()
|
||||
: mPeer(NULL), mFrame(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
EmbeddedFramePluginInstance::~EmbeddedFramePluginInstance()
|
||||
{
|
||||
if (mFrame != NULL)
|
||||
delete mFrame;
|
||||
}
|
||||
|
||||
NS_METHOD EmbeddedFramePluginInstance::Initialize(nsIPluginInstancePeer* peer)
|
||||
{
|
||||
mPeer = peer;
|
||||
NS_ADDREF(mPeer);
|
||||
|
||||
nsIPluginTagInfo* tagInfo = NULL;
|
||||
if (mPeer->QueryInterface(NS_GET_IID(nsIPluginTagInfo), (void **)&tagInfo) == NS_OK) {
|
||||
const char* frameValue = NULL;
|
||||
if (tagInfo->GetAttribute("JAVAFRAME", &frameValue) == NS_OK) {
|
||||
sscanf(frameValue, "%X", &mFrame);
|
||||
}
|
||||
if (mFrame != NULL)
|
||||
mFrame->setPluginInstance(this);
|
||||
NS_RELEASE(tagInfo);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD EmbeddedFramePluginInstance::GetPeer(nsIPluginInstancePeer* *resultingPeer)
|
||||
{
|
||||
if (mPeer != NULL) {
|
||||
*resultingPeer = mPeer;
|
||||
mPeer->AddRef();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD EmbeddedFramePluginInstance::Destroy()
|
||||
{
|
||||
NS_IF_RELEASE(mPeer);
|
||||
|
||||
// assume that Java will release this frame.
|
||||
if (mFrame != NULL) {
|
||||
mFrame->showHide(false);
|
||||
// delete mFrame;
|
||||
mFrame = NULL;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD EmbeddedFramePluginInstance::SetWindow(nsPluginWindow* pluginWindow)
|
||||
{
|
||||
if (mFrame != NULL) {
|
||||
if (pluginWindow != NULL)
|
||||
mFrame->setWindow(WindowRef(pluginWindow->window->port));
|
||||
else
|
||||
mFrame->setWindow(NULL);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD EmbeddedFramePluginInstance::HandleEvent(nsPluginEvent* pluginEvent, PRBool* eventHandled)
|
||||
{
|
||||
if (mFrame != NULL)
|
||||
*eventHandled = mFrame->handleEvent(pluginEvent->event);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void EmbeddedFramePluginInstance::setFrame(EmbeddedFrame* frame)
|
||||
{
|
||||
mFrame = frame;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(EmbeddedFramePluginInstance, nsIPluginInstance)
|
|
@ -1,196 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
EmbeddedFramePluginInstance.h
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "nsIPluginInstance.h"
|
||||
|
||||
class EmbeddedFrame;
|
||||
class MRJPluginInstance;
|
||||
|
||||
class EmbeddedFramePluginInstance : public nsIPluginInstance {
|
||||
public:
|
||||
EmbeddedFramePluginInstance();
|
||||
virtual ~EmbeddedFramePluginInstance();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
/**
|
||||
* Initializes a newly created plugin instance, passing to it the plugin
|
||||
* instance peer which it should use for all communication back to the browser.
|
||||
*
|
||||
* @param peer - the corresponding plugin instance peer
|
||||
* @result - NS_OK if this operation was successful
|
||||
*/
|
||||
NS_IMETHOD
|
||||
Initialize(nsIPluginInstancePeer* peer);
|
||||
|
||||
/**
|
||||
* Returns a reference back to the plugin instance peer. This method is
|
||||
* used whenever the browser needs to obtain the peer back from a plugin
|
||||
* instance. The implementation of this method should be sure to increment
|
||||
* the reference count on the peer by calling AddRef.
|
||||
*
|
||||
* @param resultingPeer - the resulting plugin instance peer
|
||||
* @result - NS_OK if this operation was successful
|
||||
*/
|
||||
NS_IMETHOD
|
||||
GetPeer(nsIPluginInstancePeer* *resultingPeer);
|
||||
|
||||
/**
|
||||
* Called to instruct the plugin instance to start. This will be called after
|
||||
* the plugin is first created and initialized, and may be called after the
|
||||
* plugin is stopped (via the Stop method) if the plugin instance is returned
|
||||
* to in the browser window's history.
|
||||
*
|
||||
* @result - NS_OK if this operation was successful
|
||||
*/
|
||||
NS_IMETHOD
|
||||
Start(void)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to instruct the plugin instance to stop, thereby suspending its state.
|
||||
* This method will be called whenever the browser window goes on to display
|
||||
* another page and the page containing the plugin goes into the window's history
|
||||
* list.
|
||||
*
|
||||
* @result - NS_OK if this operation was successful
|
||||
*/
|
||||
NS_IMETHOD
|
||||
Stop(void)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to instruct the plugin instance to destroy itself. This is called when
|
||||
* it become no longer possible to return to the plugin instance, either because
|
||||
* the browser window's history list of pages is being trimmed, or because the
|
||||
* window containing this page in the history is being closed.
|
||||
*
|
||||
* @result - NS_OK if this operation was successful
|
||||
*/
|
||||
NS_IMETHOD
|
||||
Destroy(void);
|
||||
|
||||
/**
|
||||
* Called when the window containing the plugin instance changes.
|
||||
*
|
||||
* (Corresponds to NPP_SetWindow.)
|
||||
*
|
||||
* @param window - the plugin window structure
|
||||
* @result - NS_OK if this operation was successful
|
||||
*/
|
||||
NS_IMETHOD
|
||||
SetWindow(nsPluginWindow* window);
|
||||
|
||||
/**
|
||||
* Called to tell the plugin that the initial src/data stream is
|
||||
* ready. Expects the plugin to return a nsIPluginStreamListener.
|
||||
*
|
||||
* (Corresponds to NPP_NewStream.)
|
||||
*
|
||||
* @param listener - listener the browser will use to give the plugin the data
|
||||
* @result - NS_OK if this operation was successful
|
||||
*/
|
||||
NS_IMETHOD
|
||||
NewStream(nsIPluginStreamListener** listener)
|
||||
{
|
||||
*listener = NULL;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to instruct the plugin instance to print itself to a printer.
|
||||
*
|
||||
* (Corresponds to NPP_Print.)
|
||||
*
|
||||
* @param platformPrint - platform-specific printing information
|
||||
* @result - NS_OK if this operation was successful
|
||||
*/
|
||||
NS_IMETHOD
|
||||
Print(nsPluginPrint* platformPrint)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of a variable associated with the plugin instance.
|
||||
*
|
||||
* @param variable - the plugin instance variable to get
|
||||
* @param value - the address of where to store the resulting value
|
||||
* @result - NS_OK if this operation was successful
|
||||
*/
|
||||
NS_IMETHOD
|
||||
GetValue(nsPluginInstanceVariable variable, void *value)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles an event. An nsIEventHandler can also get registered with with
|
||||
* nsIPluginManager2::RegisterWindow and will be called whenever an event
|
||||
* comes in for that window.
|
||||
*
|
||||
* Note that for Unix and Mac the nsPluginEvent structure is different
|
||||
* from the old NPEvent structure -- it's no longer the native event
|
||||
* record, but is instead a struct. This was done for future extensibility,
|
||||
* and so that the Mac could receive the window argument too. For Windows
|
||||
* and OS2, it's always been a struct, so there's no change for them.
|
||||
*
|
||||
* (Corresponds to NPP_HandleEvent.)
|
||||
*
|
||||
* @param event - the event to be handled
|
||||
* @param handled - set to PR_TRUE if event was handled
|
||||
* @result - NS_OK if this operation was successful
|
||||
*/
|
||||
NS_IMETHOD
|
||||
HandleEvent(nsPluginEvent* event, PRBool* handled);
|
||||
|
||||
void setFrame(EmbeddedFrame* frame);
|
||||
|
||||
private:
|
||||
nsIPluginInstancePeer* mPeer;
|
||||
MRJPluginInstance* mParentInstance;
|
||||
EmbeddedFrame* mFrame;
|
||||
};
|
|
@ -1,175 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
EventFilter.cpp
|
||||
|
||||
Provides a generalized event filtering service.
|
||||
|
||||
Patches WaitNextEvent for events, and MenuSelect for menus.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
#include "EventFilter.h"
|
||||
|
||||
#include <MixedMode.h>
|
||||
#include <Memory.h>
|
||||
#include <LowMem.h>
|
||||
#include <Menus.h>
|
||||
#include <Patches.h>
|
||||
#include <Traps.h>
|
||||
|
||||
enum {
|
||||
uppWaitNextEventProcInfo = kPascalStackBased
|
||||
| RESULT_SIZE(SIZE_CODE(sizeof(Boolean)))
|
||||
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(EventMask)))
|
||||
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(EventRecord*)))
|
||||
| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(UInt32)))
|
||||
| STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(RgnHandle))),
|
||||
uppMenuSelectProcInfo = kPascalStackBased
|
||||
| RESULT_SIZE(SIZE_CODE(sizeof(long)))
|
||||
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(Point)))
|
||||
};
|
||||
|
||||
static pascal Boolean NewWaitNextEvent(EventMask eventMask, EventRecord* event, UInt32 sleep, RgnHandle mouseRgn);
|
||||
static pascal long NewMenuSelect(Point where);
|
||||
|
||||
enum {
|
||||
kIsToolboxTrap = (1 << 11)
|
||||
};
|
||||
|
||||
inline TrapType getTrapType(UInt16 trapNum)
|
||||
{
|
||||
return ((trapNum & kIsToolboxTrap) != 0 ? kToolboxTrapType : kOSTrapType);
|
||||
}
|
||||
|
||||
static UniversalProcPtr SwapTrapAddress(UInt16 trapNum, UniversalProcPtr newTrapAddress)
|
||||
{
|
||||
TrapType type = getTrapType(trapNum);
|
||||
UniversalProcPtr oldTrapAddress = NGetTrapAddress(trapNum, type);
|
||||
NSetTrapAddress(newTrapAddress, trapNum, type);
|
||||
return oldTrapAddress;
|
||||
}
|
||||
|
||||
struct Patch {
|
||||
UInt16 trap;
|
||||
RoutineDescriptor descriptor;
|
||||
UniversalProcPtr original;
|
||||
|
||||
void Install() { original = SwapTrapAddress(trap, &descriptor); }
|
||||
void Remove() { SwapTrapAddress(trap, original); original = NULL; }
|
||||
};
|
||||
|
||||
static Patch WaitNextEventPatch = {
|
||||
_WaitNextEvent,
|
||||
BUILD_ROUTINE_DESCRIPTOR(uppWaitNextEventProcInfo, NewWaitNextEvent),
|
||||
NULL
|
||||
};
|
||||
|
||||
static Patch MenuSelectPatch = {
|
||||
_MenuSelect,
|
||||
BUILD_ROUTINE_DESCRIPTOR(uppMenuSelectProcInfo, NewMenuSelect),
|
||||
NULL
|
||||
};
|
||||
|
||||
static EventFilterProcPtr theEventFilter;
|
||||
static MenuFilterProcPtr theMenuFilter;
|
||||
|
||||
OSStatus InstallEventFilters(EventFilterProcPtr eventFilter, MenuFilterProcPtr menuFilter)
|
||||
{
|
||||
if (theEventFilter == NULL) {
|
||||
theEventFilter = eventFilter;
|
||||
theMenuFilter = menuFilter;
|
||||
|
||||
// Patch WNE, which will be used to filter events.
|
||||
WaitNextEventPatch.Install();
|
||||
|
||||
// Patch MenuSelect, which will be used to filter menu selections.
|
||||
MenuSelectPatch.Install();
|
||||
|
||||
return noErr;
|
||||
}
|
||||
return paramErr;
|
||||
}
|
||||
|
||||
OSStatus RemoveEventFilters()
|
||||
{
|
||||
if (theEventFilter != NULL) {
|
||||
WaitNextEventPatch.Remove();
|
||||
MenuSelectPatch.Remove();
|
||||
|
||||
theEventFilter = NULL;
|
||||
theMenuFilter = NULL;
|
||||
|
||||
return noErr;
|
||||
}
|
||||
return paramErr;
|
||||
}
|
||||
|
||||
static pascal Boolean NewWaitNextEvent(EventMask eventMask, EventRecord* event, UInt32 sleep, RgnHandle mouseRgn)
|
||||
{
|
||||
Boolean gotEvent = CALL_FOUR_PARAMETER_UPP(WaitNextEventPatch.original, uppWaitNextEventProcInfo, eventMask, event, sleep, mouseRgn);
|
||||
if (true) {
|
||||
// prevent recursive calls to the filter.
|
||||
static Boolean inFilter = false;
|
||||
if (! inFilter) {
|
||||
inFilter = true;
|
||||
Boolean filteredEvent = theEventFilter(event);
|
||||
if (filteredEvent) {
|
||||
// consume the event by making it a nullEvent.
|
||||
event->what = nullEvent;
|
||||
gotEvent = false;
|
||||
}
|
||||
inFilter = false;
|
||||
}
|
||||
}
|
||||
return gotEvent;
|
||||
}
|
||||
|
||||
static pascal long NewMenuSelect(Point where)
|
||||
{
|
||||
long menuSelection = CALL_ONE_PARAMETER_UPP(MenuSelectPatch.original, uppMenuSelectProcInfo, where);
|
||||
if (menuSelection != 0) {
|
||||
Boolean filteredEvent = theMenuFilter(menuSelection);
|
||||
if (filteredEvent) {
|
||||
// consume the menu selection by zeroing it out.
|
||||
menuSelection = 0;
|
||||
}
|
||||
}
|
||||
return menuSelection;
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
EventFilter.h
|
||||
|
||||
Provides a generalized event filtering service.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
#ifndef __EVENTS__
|
||||
#include <Events.h>
|
||||
#endif
|
||||
|
||||
typedef Boolean (*EventFilterProcPtr) (EventRecord* event);
|
||||
typedef Boolean (*MenuFilterProcPtr) (long menuSelection);
|
||||
|
||||
OSStatus InstallEventFilters(EventFilterProcPtr eventFilter, MenuFilterProcPtr menuFilter);
|
||||
OSStatus RemoveEventFilters();
|
Двоичные данные
plugin/oji/MRJ/plugin/Source/JMURLConnection
Двоичные данные
plugin/oji/MRJ/plugin/Source/JMURLConnection
Двоичный файл не отображается.
|
@ -1 +0,0 @@
|
|||
JMURLSetCallbacks
|
|
@ -1,262 +0,0 @@
|
|||
/*
|
||||
JMURLConnection.h
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __JMURLConnection__
|
||||
#define __JMURLConnection__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if PRAGMA_IMPORT_SUPPORTED
|
||||
#pragma import on
|
||||
#endif
|
||||
|
||||
#if PRAGMA_ALIGN_SUPPORTED
|
||||
#pragma options align=mac68k
|
||||
#endif
|
||||
|
||||
typedef void* JMURLConnectionRef;
|
||||
typedef void* JMURLInputStreamRef;
|
||||
typedef void* JMURLOutputStreamRef;
|
||||
|
||||
enum JMURLConnectionOptions
|
||||
{
|
||||
eDefault = 0,
|
||||
eNoCaching = (1 << 2),
|
||||
eNoUserInteraction = (1 << 3),
|
||||
eNoRedirection = (1 << 4)
|
||||
};
|
||||
|
||||
typedef enum JMURLConnectionOptions JMURLConnectionOptions;
|
||||
|
||||
typedef CALLBACK_API_C(OSStatus, JMURLOpenConnectionProcPtr)(
|
||||
/* in URL = */ JMTextRef url,
|
||||
/* in RequestMethod = */ JMTextRef requestMethod,
|
||||
/* in ConnectionOptions = */ JMURLConnectionOptions options,
|
||||
/* in AppletViewer = */ JMAppletViewerRef appletViewer,
|
||||
/* out URLConnectionRef = */ JMURLConnectionRef* urlConnectionRef
|
||||
);
|
||||
|
||||
typedef CALLBACK_API_C(OSStatus, JMURLCloseConnectionProcPtr)(
|
||||
/* in URLConnectionRef = */ JMURLConnectionRef urlConnectionRef
|
||||
);
|
||||
|
||||
typedef CALLBACK_API_C(Boolean, JMURLUsingProxyProcPtr)(
|
||||
/* in URLConnectionRef = */ JMURLConnectionRef urlConnectionRef
|
||||
);
|
||||
|
||||
typedef CALLBACK_API_C(OSStatus, JMURLGetCookieProcPtr)(
|
||||
/* in URLConnectionRef = */ JMURLConnectionRef urlConnectionRef,
|
||||
/* out CookieValue = */ JMTextRef* cookie
|
||||
);
|
||||
|
||||
typedef CALLBACK_API_C(OSStatus, JMURLSetCookieProcPtr)(
|
||||
/* in URLConnectionRef = */ JMURLConnectionRef urlConnectionRef,
|
||||
/* in CookieValue = */ JMTextRef cookie
|
||||
);
|
||||
|
||||
typedef CALLBACK_API_C(OSStatus, JMURLSetRequestPropertiesProcPtr)(
|
||||
/* in URLConnectionRef = */ JMURLConnectionRef urlConnectionRef,
|
||||
/* in NumberOfProperties = */ int numberOfProperties,
|
||||
/* in PropertyNames = */ JMTextRef* keys,
|
||||
/* in Values = */ JMTextRef* value
|
||||
);
|
||||
|
||||
typedef CALLBACK_API_C(OSStatus, JMURLGetResponsePropertiesCountProcPtr)(
|
||||
/* in URLConnectionRef = */ JMURLInputStreamRef iStreamRef,
|
||||
/* out numberOfProperties = */ int* numberOfProperties
|
||||
);
|
||||
|
||||
/*
|
||||
* JManager allocates memory to hold the specified number of (properties)
|
||||
* JMTextRefs. The proc is expected to create new JMTextRefs that should
|
||||
* be shoved in the array passed. The JManager takes care of disposing
|
||||
* these JMTextRefs.
|
||||
*/
|
||||
typedef CALLBACK_API_C(OSStatus, JMURLGetResponsePropertiesProcPtr)(
|
||||
/* in URLConnectionRef = */ JMURLInputStreamRef iStreamRef,
|
||||
/* in numberOfProperties = */ int numberOfProperties,
|
||||
/* out PropertyNames = */ JMTextRef* keys,
|
||||
/* out Values = */ JMTextRef* values
|
||||
);
|
||||
|
||||
typedef CALLBACK_API_C(OSStatus, JMURLOpenInputStreamProcPtr)(
|
||||
/* in URLConnectionRef = */ JMURLConnectionRef urlConnectionRef,
|
||||
/* out URLStreamRef = */ JMURLInputStreamRef* urlInputStreamRef
|
||||
);
|
||||
|
||||
typedef CALLBACK_API_C(OSStatus, JMURLOpenOutputStreamProcPtr)(
|
||||
/* in URLConnectionRef = */ JMURLConnectionRef urlConnectionRef,
|
||||
/* out URLOutputStreamRef = */ JMURLOutputStreamRef* urlOutputStreamRef
|
||||
);
|
||||
|
||||
typedef CALLBACK_API_C(OSStatus, JMURLCloseInputStreamProcPtr)(
|
||||
/* in URLInputStreamRef = */ JMURLInputStreamRef urlInputStreamRef
|
||||
);
|
||||
|
||||
typedef CALLBACK_API_C(OSStatus, JMURLCloseOutputStreamProcPtr)(
|
||||
/* in URLOutputStreamRef = */ JMURLOutputStreamRef urlOutputStreamRef
|
||||
);
|
||||
|
||||
typedef CALLBACK_API_C(OSStatus, JMURLReadProcPtr)(
|
||||
/* in URLConnectionRef = */ JMURLInputStreamRef iStreamRef,
|
||||
/* out Buffer = */ void* buffer,
|
||||
/* in BufferSize = */ UInt32 bufferSize,
|
||||
/* out BytesRead = */ SInt32* bytesRead
|
||||
);
|
||||
|
||||
typedef CALLBACK_API_C(OSStatus, JMURLWriteProcPtr)(
|
||||
/* in URLConnectionRef = */ JMURLOutputStreamRef oStreamRef,
|
||||
/* in Buffer = */ void* buffer,
|
||||
/* in BytesToWrite = */ SInt32 bytesToWrite
|
||||
);
|
||||
|
||||
struct JMURLCallbacks {
|
||||
UInt32 fVersion; /* should be set to kJMVersion */
|
||||
JMURLOpenConnectionProcPtr fOpenConnection;
|
||||
JMURLCloseConnectionProcPtr fCloseConnection;
|
||||
JMURLUsingProxyProcPtr fUsingProxy;
|
||||
JMURLGetCookieProcPtr fGetCookie;
|
||||
JMURLSetCookieProcPtr fSetCookie;
|
||||
JMURLSetRequestPropertiesProcPtr fSetRequestProperties;
|
||||
JMURLGetResponsePropertiesCountProcPtr fGetResponsePropertiesCount;
|
||||
JMURLGetResponsePropertiesProcPtr fGetResponseProperties;
|
||||
JMURLOpenInputStreamProcPtr fOpenInputStream;
|
||||
JMURLOpenOutputStreamProcPtr fOpenOutputStream;
|
||||
JMURLCloseInputStreamProcPtr fCloseInputStream;
|
||||
JMURLCloseOutputStreamProcPtr fCloseOutputStream;
|
||||
JMURLReadProcPtr fRead;
|
||||
JMURLWriteProcPtr fWrite;
|
||||
};
|
||||
|
||||
typedef struct JMURLCallbacks JMURLCallbacks;
|
||||
|
||||
EXTERN_API_C(OSStatus)
|
||||
JMURLSetCallbacks(
|
||||
JMSessionRef session,
|
||||
const char* protocol,
|
||||
JMURLCallbacks* cb
|
||||
);
|
||||
|
||||
EXTERN_API_C(OSStatus)
|
||||
JMURLOpenConnection(
|
||||
/* in JMSessionRef = */ JMSessionRef session,
|
||||
/* in URL = */ JMTextRef url,
|
||||
/* in RequestMethod = */ JMTextRef requestMethod,
|
||||
/* in ConnectionOptions = */ JMURLConnectionOptions options,
|
||||
/* in AppletViewer = */ JMAppletViewerRef appletViewer,
|
||||
/* out URLConnectionRef = */ JMURLConnectionRef* urlConnectionRef
|
||||
);
|
||||
|
||||
EXTERN_API_C(OSStatus)
|
||||
JMURLCloseConnection(
|
||||
/* in JMSessionRef = */ JMSessionRef session,
|
||||
/* in URLConnectionRef = */ JMURLConnectionRef urlConnectionRef
|
||||
);
|
||||
|
||||
EXTERN_API_C(Boolean)
|
||||
JMURLUsingProxy(
|
||||
/* in JMSessionRef = */ JMSessionRef session,
|
||||
/* in URLConnectionRef = */ JMURLConnectionRef urlConnectionRef
|
||||
);
|
||||
|
||||
EXTERN_API_C(OSStatus)
|
||||
JMURLGetCookie(
|
||||
/* in JMSessionRef = */ JMSessionRef session,
|
||||
/* in URLConnectionRef = */ JMURLConnectionRef urlConnectionRef,
|
||||
/* out CookieValue = */ JMTextRef* cookie
|
||||
);
|
||||
|
||||
EXTERN_API_C(OSStatus)
|
||||
JMURLSetCookie(
|
||||
/* in JMSessionRef = */ JMSessionRef session,
|
||||
/* in URLConnectionRef = */ JMURLConnectionRef urlConnectionRef,
|
||||
/* in CookieValue = */ JMTextRef cookie
|
||||
);
|
||||
|
||||
EXTERN_API_C(OSStatus)
|
||||
JMURLSetRequestProperties(
|
||||
/* in JMSessionRef = */ JMSessionRef session,
|
||||
/* in URLConnectionRef = */ JMURLConnectionRef urlConnectionRef,
|
||||
/* in NumberOfProperties = */ int numberOfProperties,
|
||||
/* in PropertyNames = */ JMTextRef* keys,
|
||||
/* in Values = */ JMTextRef* value
|
||||
);
|
||||
|
||||
EXTERN_API_C(OSStatus)
|
||||
JMURLGetResponsePropertiesCount(
|
||||
/* in JMSessionRef = */ JMSessionRef session,
|
||||
/* in InputStreamRef = */ JMURLInputStreamRef iStreamRef,
|
||||
/* out numberOfProperties = */ int* numberOfProperties
|
||||
);
|
||||
|
||||
EXTERN_API_C(OSStatus)
|
||||
JMURLGetResponseProperties(
|
||||
/* in JMSessionRef = */ JMSessionRef session,
|
||||
/* in InputStreamRef = */ JMURLInputStreamRef iStreamRef,
|
||||
/* in numberOfProperties = */ int numberOfProperties,
|
||||
/* out PropertyNames = */ JMTextRef* keys,
|
||||
/* out Values = */ JMTextRef* values
|
||||
);
|
||||
|
||||
EXTERN_API_C(OSStatus)
|
||||
JMURLOpenInputStream(
|
||||
/* in JMSessionRef = */ JMSessionRef session,
|
||||
/* in URLConnectionRef = */ JMURLConnectionRef urlConnectionRef,
|
||||
/* out URLInputStreamRef = */ JMURLInputStreamRef* urlInputStreamRef
|
||||
);
|
||||
|
||||
EXTERN_API_C(OSStatus)
|
||||
JMURLOpenOutputStream(
|
||||
/* in JMSessionRef = */ JMSessionRef session,
|
||||
/* in URLConnectionRef = */ JMURLConnectionRef urlConnectionRef,
|
||||
/* out URLOutputStreamRef = */ JMURLOutputStreamRef* urlOutputStreamRef
|
||||
);
|
||||
|
||||
EXTERN_API_C(OSStatus)
|
||||
JMURLCloseInputStream(
|
||||
/* in JMSessionRef = */ JMSessionRef session,
|
||||
/* in URLInputStreamRef = */ JMURLInputStreamRef urlInputStreamRef
|
||||
);
|
||||
|
||||
EXTERN_API_C(OSStatus)
|
||||
JMURLCloseOutputStream(
|
||||
/* in JMSessionRef = */ JMSessionRef session,
|
||||
/* in URLOutputStreamRef = */ JMURLOutputStreamRef urlOutputStreamRef
|
||||
);
|
||||
|
||||
EXTERN_API_C(OSStatus)
|
||||
JMURLRead(
|
||||
/* in JMSessionRef = */ JMSessionRef session,
|
||||
/* in URLInputStreamRef = */ JMURLInputStreamRef urlInputStreamRef,
|
||||
/* out Buffer = */ void* buffer,
|
||||
/* in BufferSize = */ UInt32 bufferSize,
|
||||
/* out BytesRead = */ SInt32* bytesRead
|
||||
);
|
||||
|
||||
EXTERN_API_C(OSStatus)
|
||||
JMURLWrite(
|
||||
/* in JMSessionRef = */ JMSessionRef session,
|
||||
/* in URLOutputStreamRef = */ JMURLOutputStreamRef urlOutputStreamRef,
|
||||
/* in Buffer = */ void* buffer,
|
||||
/* in BytesToWrite = */ SInt32 bytesToWrite
|
||||
);
|
||||
|
||||
#if PRAGMA_ALIGN_SUPPORTED
|
||||
#pragma options align=reset
|
||||
#endif
|
||||
|
||||
#if PRAGMA_IMPORT_SUPPORTED
|
||||
#pragma import off
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __JMURLConnection__ */
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
JNIThread.java
|
||||
|
||||
Provides a communication channel between native threads and Java threads.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
package netscape.oji;
|
||||
|
||||
public class JNIThread extends Thread {
|
||||
private int fSecureEnv;
|
||||
|
||||
public JNIThread(int secureEnv) {
|
||||
super("JNIThread->0x" + Integer.toHexString(secureEnv));
|
||||
fSecureEnv = secureEnv;
|
||||
setPriority(NORM_PRIORITY);
|
||||
// setPriority(MAX_PRIORITY);
|
||||
start();
|
||||
}
|
||||
|
||||
public native void run();
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
JNIUtils.java
|
||||
*/
|
||||
|
||||
package netscape.oji;
|
||||
|
||||
public class JNIUtils {
|
||||
/**
|
||||
* Returns a local reference for a passed-in global reference.
|
||||
*/
|
||||
public static Object NewLocalRef(Object object) {
|
||||
return object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the currently running thread.
|
||||
*/
|
||||
public static Object GetCurrentThread() {
|
||||
return Thread.currentThread();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Stub SecurityManager class, to expose access to class loaders.
|
||||
*/
|
||||
static class StubSecurityManager extends SecurityManager {
|
||||
public ClassLoader getCurrentClassLoader() {
|
||||
return currentClassLoader();
|
||||
}
|
||||
}
|
||||
|
||||
private static StubSecurityManager stubManager = new StubSecurityManager();
|
||||
|
||||
/**
|
||||
* Returns the current class loader.
|
||||
*/
|
||||
public static Object GetCurrentClassLoader() {
|
||||
return stubManager.getCurrentClassLoader();
|
||||
}
|
||||
|
||||
public static Object GetObjectClassLoader(Object object) {
|
||||
return object.getClass().getClassLoader();
|
||||
}
|
||||
}
|
|
@ -1,130 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
JSEvaluator.cpp
|
||||
*/
|
||||
|
||||
#include "JSEvaluator.h"
|
||||
#include "MRJPlugin.h"
|
||||
#include "MRJSession.h"
|
||||
#include "MRJMonitor.h"
|
||||
#include "nsIPluginManager.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
extern nsIPluginManager* thePluginManager;
|
||||
|
||||
JSEvaluator::JSEvaluator(MRJPluginInstance* pluginInstance)
|
||||
: mPluginInstance(pluginInstance)
|
||||
{
|
||||
NS_ADDREF(pluginInstance);
|
||||
mSession = pluginInstance->getSession();
|
||||
mJSMonitor = new MRJMonitor(mSession);
|
||||
}
|
||||
|
||||
JSEvaluator::~JSEvaluator()
|
||||
{
|
||||
NS_IF_RELEASE(mPluginInstance);
|
||||
if (mJSMonitor != NULL)
|
||||
delete mJSMonitor;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(JSEvaluator, nsIPluginStreamListener)
|
||||
|
||||
const char* JSEvaluator::eval(const char* script)
|
||||
{
|
||||
JNIEnv* env = mSession->getCurrentEnv();
|
||||
nsIPluginStreamListener* listener = this;
|
||||
|
||||
mJSMonitor->enter();
|
||||
|
||||
while (mScript != NULL) {
|
||||
// some other thread is evaluating a script.
|
||||
mJSMonitor->wait();
|
||||
}
|
||||
|
||||
// construct a "javascript:" URL from the passed-in script.
|
||||
const char* kJavaScriptPrefix = "javascript:";
|
||||
mScript = new char[strlen(kJavaScriptPrefix) + strlen(script) + 1];
|
||||
if (mScript != NULL) {
|
||||
strcpy(mScript, kJavaScriptPrefix);
|
||||
strcat(mScript, script);
|
||||
|
||||
// start an async evaluation of this script.
|
||||
nsresult result = thePluginManager->GetURL((nsIPluginInstance*)mPluginInstance, mScript, NULL, (nsIPluginStreamListener*)this);
|
||||
|
||||
// default result is NULL, in case JavaScript returns undefined value.
|
||||
if (mResult != NULL) {
|
||||
delete[] mResult;
|
||||
mResult = NULL;
|
||||
}
|
||||
|
||||
// need to block until the result is ready.
|
||||
mJSMonitor->wait();
|
||||
|
||||
// can now delete the script.
|
||||
delete[] mScript;
|
||||
mScript = NULL;
|
||||
}
|
||||
|
||||
mJSMonitor->notifyAll();
|
||||
|
||||
mJSMonitor->exit();
|
||||
|
||||
return mResult;
|
||||
}
|
||||
|
||||
NS_METHOD JSEvaluator::OnDataAvailable(nsIPluginStreamInfo* pluginInfo, nsIInputStream* input, PRUint32 length)
|
||||
{
|
||||
// hopefully all our data is available.
|
||||
mResult = new char[length + 1];
|
||||
if (mResult != NULL) {
|
||||
if (input->Read(mResult, length, &length) == NS_OK) {
|
||||
// We've delayed processing the applet tag, because we
|
||||
// don't know the location of the curren document yet.
|
||||
mResult[length] = '\0';
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD JSEvaluator::OnStopBinding(nsIPluginStreamInfo* pluginInfo, nsresult status)
|
||||
{
|
||||
// the stream has been closed, notify any waiting Java threads.
|
||||
mJSMonitor->notifyAll();
|
||||
return NS_OK;
|
||||
}
|
|
@ -1,131 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
JSEvaluator.h
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "nsIPluginStreamListener.h"
|
||||
|
||||
#ifndef JNI_H
|
||||
#include "jni.h"
|
||||
#endif
|
||||
|
||||
class MRJMonitor;
|
||||
class MRJSession;
|
||||
class MRJPluginInstance;
|
||||
|
||||
class JSEvaluator : public nsIPluginStreamListener {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
JSEvaluator(MRJPluginInstance* pluginInstance);
|
||||
virtual ~JSEvaluator();
|
||||
|
||||
const char* eval(const char* script);
|
||||
|
||||
const char* getResult()
|
||||
{
|
||||
return mResult;
|
||||
}
|
||||
|
||||
// nsIPluginStreamListener implementation.
|
||||
|
||||
/**
|
||||
* Notify the observer that the URL has started to load. This method is
|
||||
* called only once, at the beginning of a URL load.<BR><BR>
|
||||
*
|
||||
* @return The return value is currently ignored. In the future it may be
|
||||
* used to cancel the URL load..
|
||||
*/
|
||||
NS_IMETHOD
|
||||
OnStartBinding(nsIPluginStreamInfo* pluginInfo)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify the client that data is available in the input stream. This
|
||||
* method is called whenver data is written into the input stream by the
|
||||
* networking library...<BR><BR>
|
||||
*
|
||||
* @param aIStream The input stream containing the data. This stream can
|
||||
* be either a blocking or non-blocking stream.
|
||||
* @param length The amount of data that was just pushed into the stream.
|
||||
* @return The return value is currently ignored.
|
||||
*/
|
||||
NS_IMETHOD
|
||||
OnDataAvailable(nsIPluginStreamInfo* pluginInfo, nsIInputStream* input, PRUint32 length);
|
||||
|
||||
NS_IMETHOD
|
||||
OnFileAvailable(nsIPluginStreamInfo* pluginInfo, const char* fileName)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify the observer that the URL has finished loading. This method is
|
||||
* called once when the networking library has finished processing the
|
||||
* URL transaction initiatied via the nsINetService::Open(...) call.<BR><BR>
|
||||
*
|
||||
* This method is called regardless of whether the URL loaded successfully.<BR><BR>
|
||||
*
|
||||
* @param status Status code for the URL load.
|
||||
* @param msg A text string describing the error.
|
||||
* @return The return value is currently ignored.
|
||||
*/
|
||||
NS_IMETHOD
|
||||
OnStopBinding(nsIPluginStreamInfo* pluginInfo, nsresult status);
|
||||
|
||||
/**
|
||||
* What is this method supposed to do?
|
||||
*/
|
||||
NS_IMETHOD
|
||||
GetStreamType(nsPluginStreamType *result)
|
||||
{
|
||||
*result = nsPluginStreamType_Normal;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
MRJPluginInstance* mPluginInstance;
|
||||
MRJSession* mSession;
|
||||
MRJMonitor* mJSMonitor;
|
||||
char* mScript;
|
||||
char* mResult;
|
||||
};
|
|
@ -1,82 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
JavaMessageQueue.h
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef JNI_H
|
||||
#include "jni.h"
|
||||
#endif
|
||||
|
||||
class Monitor;
|
||||
|
||||
class JavaMessage {
|
||||
public:
|
||||
JavaMessage() : mNext(NULL) {}
|
||||
virtual ~JavaMessage() {}
|
||||
|
||||
void setNext(JavaMessage* next) { mNext = next; }
|
||||
JavaMessage* getNext() { return mNext; }
|
||||
|
||||
virtual void execute(JNIEnv* env) = 0;
|
||||
|
||||
private:
|
||||
JavaMessage* mNext;
|
||||
};
|
||||
|
||||
class JavaMessageQueue {
|
||||
public:
|
||||
JavaMessageQueue(Monitor* monitor);
|
||||
|
||||
void putMessage(JavaMessage* msg);
|
||||
JavaMessage* getMessage();
|
||||
|
||||
void enter();
|
||||
void exit();
|
||||
|
||||
void wait();
|
||||
void wait(long long millis);
|
||||
void notify();
|
||||
|
||||
private:
|
||||
// Message queue.
|
||||
JavaMessage* mFirst;
|
||||
JavaMessage* mLast;
|
||||
Monitor* mMonitor;
|
||||
};
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,53 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
LiveConnectNativeMethods.h
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "nsError.h"
|
||||
|
||||
#include "jni.h"
|
||||
|
||||
class MRJPlugin;
|
||||
|
||||
nsresult InitLiveConnectSupport(MRJPlugin* jvmPlugin);
|
||||
nsresult ShutdownLiveConnectSupport(void);
|
||||
|
||||
jobject Wrap_JSObject(JNIEnv* env, jint js_obj);
|
||||
jint Unwrap_JSObject(JNIEnv* env, jobject java_wrapper_obj);
|
|
@ -1,72 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
LocalPort.h
|
||||
|
||||
Simple utility class to put a Quickdraw GrafPort into a known state.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Quickdraw.h>
|
||||
|
||||
class LocalPort {
|
||||
public:
|
||||
LocalPort(GrafPtr port)
|
||||
{
|
||||
fPort = port;
|
||||
fOrigin.h = fOrigin.v = 0;
|
||||
}
|
||||
|
||||
LocalPort(GrafPtr port, Point origin)
|
||||
{
|
||||
fPort = port;
|
||||
fOrigin.h = origin.h;
|
||||
fOrigin.v = origin.v;
|
||||
}
|
||||
|
||||
void Enter();
|
||||
void Exit();
|
||||
|
||||
private:
|
||||
GrafPtr fPort;
|
||||
Point fOrigin;
|
||||
GrafPtr fOldPort;
|
||||
Point fOldOrigin;
|
||||
};
|
|
@ -1,396 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
MRJConsole.cpp
|
||||
|
||||
Implements the JVM console interface.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
#include <Appearance.h>
|
||||
#include <Gestalt.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "MRJConsole.h"
|
||||
#include "MRJPlugin.h"
|
||||
#include "MRJSession.h"
|
||||
#include "TopLevelFrame.h"
|
||||
|
||||
#include "nsIPluginManager2.h"
|
||||
|
||||
extern nsIPluginManager2* thePluginManager2;
|
||||
|
||||
MRJConsole* theConsole = NULL;
|
||||
|
||||
const InterfaceInfo MRJConsole::sInterfaces[] = {
|
||||
{ NS_IJVMCONSOLE_IID, INTERFACE_OFFSET(MRJConsole, nsIJVMConsole) },
|
||||
{ NS_IEVENTHANDLER_IID, INTERFACE_OFFSET(MRJConsole, nsIEventHandler) },
|
||||
};
|
||||
const UInt32 MRJConsole::kInterfaceCount = sizeof(sInterfaces) / sizeof(InterfaceInfo);
|
||||
|
||||
MRJConsole::MRJConsole(MRJPlugin* plugin)
|
||||
: SupportsMixin(this, sInterfaces, kInterfaceCount, (nsIPlugin*) plugin),
|
||||
mPlugin(plugin), mSession(NULL), mIsInitialized(PR_FALSE),
|
||||
mConsoleClass(NULL), mInitMethod(NULL), mDisposeMethod(NULL),
|
||||
mShowMethod(NULL), mHideMethod(NULL), mVisibleMethod(NULL), mPrintMethod(NULL), mFinishMethod(NULL),
|
||||
mResults(NULL), mContext(NULL), mFrame(NULL)
|
||||
{
|
||||
// Initialize();
|
||||
}
|
||||
|
||||
MRJConsole::~MRJConsole()
|
||||
{
|
||||
theConsole = NULL;
|
||||
|
||||
if (mSession != NULL) {
|
||||
JNIEnv* env = mSession->getCurrentEnv();
|
||||
|
||||
if (mConsoleClass != NULL) {
|
||||
if (mDisposeMethod != NULL)
|
||||
env->CallStaticVoidMethod(mConsoleClass, mDisposeMethod);
|
||||
env->DeleteGlobalRef(mConsoleClass);
|
||||
mConsoleClass = NULL;
|
||||
}
|
||||
|
||||
if (mResults != NULL) {
|
||||
env->DeleteGlobalRef(mResults);
|
||||
mResults = NULL;
|
||||
}
|
||||
|
||||
if (mContext != NULL) {
|
||||
JMDisposeAWTContext(mContext);
|
||||
mContext = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NS_METHOD MRJConsole::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
nsresult result = queryInterface(aIID, aInstancePtr);
|
||||
if (result == NS_NOINTERFACE)
|
||||
result = mPlugin->queryInterface(aIID, aInstancePtr);
|
||||
return result;
|
||||
}
|
||||
nsrefcnt MRJConsole::AddRef() { return addRef(); }
|
||||
nsrefcnt MRJConsole::Release() { return release(); }
|
||||
|
||||
#pragma mark ***** MRJConsole *****
|
||||
|
||||
NS_METHOD MRJConsole::Show()
|
||||
{
|
||||
Initialize();
|
||||
|
||||
if (mShowMethod != NULL) {
|
||||
CallConsoleMethod(mShowMethod);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_METHOD MRJConsole::Hide()
|
||||
{
|
||||
Initialize();
|
||||
|
||||
if (mHideMethod != NULL) {
|
||||
CallConsoleMethod(mHideMethod);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_METHOD MRJConsole::IsVisible(PRBool* isVisible)
|
||||
{
|
||||
// don't initialize here, because if we haven't been initialized, it can't be visible.
|
||||
*isVisible = PR_FALSE;
|
||||
if (mVisibleMethod != NULL) {
|
||||
CallConsoleMethod(mVisibleMethod, mResults);
|
||||
jboolean isCopy;
|
||||
JNIEnv* env = mSession->getCurrentEnv();
|
||||
jboolean* elements = env->GetBooleanArrayElements(mResults, &isCopy);
|
||||
*isVisible = elements[0];
|
||||
env->ReleaseBooleanArrayElements(mResults, elements, JNI_ABORT);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Prints a message to the Java console. The encodingName specifies the
|
||||
// encoding of the message, and if NULL, specifies the default platform
|
||||
// encoding.
|
||||
|
||||
NS_METHOD MRJConsole::Print(const char* msg, const char* encodingName)
|
||||
{
|
||||
Initialize();
|
||||
|
||||
if (mPrintMethod != NULL) {
|
||||
JNIEnv* env = mSession->getCurrentEnv();
|
||||
jstring jmsg = env->NewStringUTF(msg);
|
||||
jvalue args[1]; args[0].l = jmsg;
|
||||
JMExecJNIStaticMethodInContext(mContext, env, mConsoleClass, mPrintMethod, 1, args);
|
||||
env->DeleteLocalRef(jmsg);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Writes a message to the Java console immediately, in the current thread.
|
||||
|
||||
void MRJConsole::write(const void *message, UInt32 messageLengthInBytes)
|
||||
{
|
||||
if (mPrintMethod != NULL) {
|
||||
char* buffer = new char[messageLengthInBytes + 1];
|
||||
if (buffer != NULL) {
|
||||
memcpy(buffer, message, messageLengthInBytes);
|
||||
buffer[messageLengthInBytes] = '\0';
|
||||
|
||||
JNIEnv* env = mSession->getCurrentEnv();
|
||||
jstring jmsg = env->NewStringUTF(buffer);
|
||||
if (jmsg != NULL) {
|
||||
env->CallStaticVoidMethod(mConsoleClass, mPrintMethod, jmsg);
|
||||
env->DeleteLocalRef(jmsg);
|
||||
}
|
||||
|
||||
delete buffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NS_METHOD MRJConsole::HandleEvent(nsPluginEvent* pluginEvent, PRBool* eventHandled)
|
||||
{
|
||||
*eventHandled = PR_TRUE;
|
||||
|
||||
if (pluginEvent != NULL) {
|
||||
EventRecord* event = pluginEvent->event;
|
||||
|
||||
if (event->what == nullEvent) {
|
||||
// Give MRJ another quantum of time.
|
||||
MRJSession* session = mPlugin->getSession();
|
||||
session->idle(kDefaultJMTime);
|
||||
} else {
|
||||
TopLevelFrame* frame = mFrame;
|
||||
if (frame != NULL) {
|
||||
switch (event->what) {
|
||||
case nsPluginEventType_GetFocusEvent:
|
||||
frame->focusEvent(true);
|
||||
break;
|
||||
|
||||
case nsPluginEventType_LoseFocusEvent:
|
||||
frame->focusEvent(false);
|
||||
break;
|
||||
|
||||
case nsPluginEventType_AdjustCursorEvent:
|
||||
frame->idle(event->modifiers);
|
||||
break;
|
||||
|
||||
case nsPluginEventType_MenuCommandEvent:
|
||||
frame->menuSelected(event->message, event->modifiers);
|
||||
break;
|
||||
|
||||
default:
|
||||
*eventHandled = frame->handleEvent(event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
OSStatus MRJConsole::CallConsoleMethod(jmethodID method)
|
||||
{
|
||||
JNIEnv* env = mSession->getCurrentEnv();
|
||||
OSStatus status = JMExecJNIStaticMethodInContext(mContext, env, mConsoleClass, method, 0, NULL);
|
||||
env->CallStaticVoidMethod(mConsoleClass, mFinishMethod);
|
||||
return status;
|
||||
}
|
||||
|
||||
OSStatus MRJConsole::CallConsoleMethod(jmethodID method, jobject arg)
|
||||
{
|
||||
jvalue args[1];
|
||||
args[0].l = arg;
|
||||
JNIEnv* env = mSession->getCurrentEnv();
|
||||
OSStatus status = JMExecJNIStaticMethodInContext(mContext, env, mConsoleClass, method, 1, args);
|
||||
env->CallStaticVoidMethod(mConsoleClass, mFinishMethod);
|
||||
return status;
|
||||
}
|
||||
|
||||
static OSStatus requestFrame(JMAWTContextRef contextRef, JMFrameRef frameRef, JMFrameKind kind,
|
||||
const Rect* initialBounds, Boolean resizeable, JMFrameCallbacks* cb)
|
||||
{
|
||||
extern JMFrameCallbacks theFrameCallbacks;
|
||||
// set up the viewer frame's callbacks.
|
||||
BlockMoveData(&theFrameCallbacks, cb, sizeof(theFrameCallbacks));
|
||||
|
||||
MRJConsole* thisConsole = NULL;
|
||||
OSStatus status = ::JMGetAWTContextData(contextRef, (JMClientData*)&thisConsole);
|
||||
if (status == noErr && thePluginManager2 != NULL) {
|
||||
// Can only do this safely if we are using the new API.
|
||||
TopLevelFrame* frame = new TopLevelFrame(thisConsole, frameRef, kind, initialBounds, resizeable);
|
||||
status = ::JMSetFrameData(frameRef, frame);
|
||||
thisConsole->setFrame(frame);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
static OSStatus releaseFrame(JMAWTContextRef contextRef, JMFrameRef frameRef)
|
||||
{
|
||||
MRJConsole* thisConsole = NULL;
|
||||
OSStatus status = ::JMGetAWTContextData(contextRef, (JMClientData*)&thisConsole);
|
||||
MRJFrame* thisFrame = NULL;
|
||||
status = ::JMGetFrameData(frameRef, (JMClientData*)&thisFrame);
|
||||
if (thisFrame != NULL) {
|
||||
status = ::JMSetFrameData(frameRef, NULL);
|
||||
thisConsole->setFrame(NULL);
|
||||
delete thisFrame;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
static SInt16 getUniqueMenuID(JMAWTContextRef contextRef, Boolean isSubmenu)
|
||||
{
|
||||
MRJConsole* thisConsole = NULL;
|
||||
OSStatus status = ::JMGetAWTContextData(contextRef, (JMClientData*)&thisConsole);
|
||||
if (thePluginManager2 != NULL) {
|
||||
PRInt16 menuID;
|
||||
if (thePluginManager2->AllocateMenuID(thisConsole, isSubmenu, &menuID) == NS_OK)
|
||||
return menuID;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static Boolean appearanceManagerExists()
|
||||
{
|
||||
long response = 0;
|
||||
return (Gestalt(gestaltAppearanceAttr, &response) == noErr && (response & (1 << gestaltAppearanceExists)));
|
||||
}
|
||||
|
||||
static OSStatus JMTextToStr255(JMTextRef textRef, Str255 str)
|
||||
{
|
||||
UInt32 length = 0;
|
||||
OSStatus status = JMGetTextBytes(textRef, kTextEncodingMacRoman, &str[1], sizeof(Str255) - 1, &length);
|
||||
if (status == noErr)
|
||||
str[0] = (unsigned char)(status == noErr ? length : 0);
|
||||
return status;
|
||||
}
|
||||
|
||||
inline int min(int x, int y) { return (x <= y ? x : y); }
|
||||
|
||||
static void push(StringPtr dest, StringPtr str)
|
||||
{
|
||||
int length = dest[0];
|
||||
int newLength = min(255, length + str[0]);
|
||||
if (newLength > length)
|
||||
::BlockMoveData(&str[1], &dest[1] + length, newLength - length);
|
||||
}
|
||||
|
||||
static void exceptionOccurred(JMAWTContextRef context, JMTextRef exceptionName, JMTextRef exceptionMsg, JMTextRef stackTrace)
|
||||
{
|
||||
// why not display this using the Appearance Manager's wizzy new alert?
|
||||
if (appearanceManagerExists()) {
|
||||
OSStatus status;
|
||||
Str255 preason = { '\0' }, pmessage = { '\0'}, ptrace = { '\0' };
|
||||
if (exceptionName != NULL) {
|
||||
status = ::JMTextToStr255(exceptionName, preason);
|
||||
if (exceptionMsg != NULL) {
|
||||
status = ::JMTextToStr255(exceptionMsg, pmessage);
|
||||
push(preason, "\p (");
|
||||
push(preason, pmessage);
|
||||
push(preason, "\p)");
|
||||
}
|
||||
}
|
||||
|
||||
if (stackTrace != NULL)
|
||||
status = ::JMTextToStr255(stackTrace, ptrace);
|
||||
|
||||
SInt16 itemHit = 0;
|
||||
OSErr result = ::StandardAlert(kAlertPlainAlert, preason, ptrace, NULL, &itemHit);
|
||||
}
|
||||
}
|
||||
|
||||
void MRJConsole::Initialize()
|
||||
{
|
||||
if (mIsInitialized)
|
||||
return;
|
||||
|
||||
mSession = mPlugin->getSession();
|
||||
JNIEnv* env = mSession->getCurrentEnv();
|
||||
|
||||
jclass consoleClass = env->FindClass("netscape/oji/MRJConsole");
|
||||
if (consoleClass == NULL) return;
|
||||
mConsoleClass = (jclass) env->NewGlobalRef(consoleClass);
|
||||
|
||||
mInitMethod = env->GetStaticMethodID(consoleClass, "init", "()V");
|
||||
mDisposeMethod = env->GetStaticMethodID(consoleClass, "dispose", "()V");
|
||||
mShowMethod = env->GetStaticMethodID(consoleClass, "show", "()V");
|
||||
mHideMethod = env->GetStaticMethodID(consoleClass, "hide", "()V");
|
||||
mVisibleMethod = env->GetStaticMethodID(consoleClass, "visible", "([Z)V");
|
||||
mPrintMethod = env->GetStaticMethodID(consoleClass, "print", "(Ljava/lang/String;)V");
|
||||
mFinishMethod = env->GetStaticMethodID(consoleClass, "finish", "()V");
|
||||
|
||||
jbooleanArray results = env->NewBooleanArray(1);
|
||||
mResults = (jbooleanArray) env->NewGlobalRef(results);
|
||||
env->DeleteLocalRef(results);
|
||||
|
||||
// Create an AWT context to work in.
|
||||
|
||||
JMAWTContextCallbacks callbacks = {
|
||||
kJMVersion, /* should be set to kJMVersion */
|
||||
&requestFrame, /* a new frame is being created. */
|
||||
&releaseFrame, /* an existing frame is being destroyed. */
|
||||
&getUniqueMenuID, /* a new menu will be created with this id. */
|
||||
&exceptionOccurred, /* just some notification that some recent operation caused an exception. You can't do anything really from here. */
|
||||
};
|
||||
OSStatus status = ::JMNewAWTContext(&mContext, mSession->getSessionRef(), &callbacks, this);
|
||||
|
||||
// Finally, call the Java initialize method, and wait for it to complete.
|
||||
|
||||
if (mInitMethod != NULL && status == noErr) {
|
||||
status = JMExecJNIStaticMethodInContext(mContext, env, consoleClass, mInitMethod, 0, NULL);
|
||||
env->CallStaticVoidMethod(mConsoleClass, mFinishMethod);
|
||||
}
|
||||
env->DeleteLocalRef(consoleClass);
|
||||
|
||||
mIsInitialized = (status == noErr);
|
||||
|
||||
if (mIsInitialized)
|
||||
theConsole = this;
|
||||
}
|
|
@ -1,128 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
MRJConsole.h
|
||||
|
||||
Implements the JVM console interface.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
#ifndef CALL_NOT_IN_CARBON
|
||||
#define CALL_NOT_IN_CARBON 1
|
||||
#endif
|
||||
|
||||
#include "nsIJVMConsole.h"
|
||||
#include "nsIEventHandler.h"
|
||||
#include "SupportsMixin.h"
|
||||
|
||||
#include "jni.h"
|
||||
#include <JManager.h>
|
||||
|
||||
class MRJPlugin;
|
||||
class MRJSession;
|
||||
class TopLevelFrame;
|
||||
|
||||
class MRJConsole : public nsIJVMConsole,
|
||||
public nsIEventHandler,
|
||||
public SupportsMixin {
|
||||
public:
|
||||
MRJConsole(MRJPlugin* plugin);
|
||||
virtual ~MRJConsole();
|
||||
|
||||
// NS_DECL_ISUPPORTS
|
||||
// DECL_SUPPORTS_MIXIN
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||
|
||||
// nsIJVMConsole methods.
|
||||
|
||||
NS_IMETHOD
|
||||
Show(void);
|
||||
|
||||
NS_IMETHOD
|
||||
Hide(void);
|
||||
|
||||
NS_IMETHOD
|
||||
IsVisible(PRBool* isVisible);
|
||||
|
||||
// Prints a message to the Java console. The encodingName specifies the
|
||||
// encoding of the message, and if NULL, specifies the default platform
|
||||
// encoding.
|
||||
NS_IMETHOD
|
||||
Print(const char* msg, const char* encodingName = NULL);
|
||||
|
||||
NS_IMETHOD
|
||||
HandleEvent(nsPluginEvent* event, PRBool* eventHandled);
|
||||
|
||||
// Private implementation methods.
|
||||
|
||||
void setFrame(TopLevelFrame* frame) { mFrame = frame; }
|
||||
|
||||
void write(const void *message, UInt32 messageLengthInBytes);
|
||||
|
||||
private:
|
||||
// Private implementation methods.
|
||||
OSStatus CallConsoleMethod(jmethodID method);
|
||||
OSStatus CallConsoleMethod(jmethodID method, jobject arg);
|
||||
|
||||
void Initialize();
|
||||
|
||||
private:
|
||||
MRJPlugin* mPlugin;
|
||||
MRJSession* mSession;
|
||||
PRBool mIsInitialized;
|
||||
|
||||
jclass mConsoleClass;
|
||||
jmethodID mInitMethod;
|
||||
jmethodID mDisposeMethod;
|
||||
jmethodID mShowMethod;
|
||||
jmethodID mHideMethod;
|
||||
jmethodID mVisibleMethod;
|
||||
jmethodID mPrintMethod;
|
||||
jmethodID mFinishMethod;
|
||||
|
||||
jbooleanArray mResults;
|
||||
|
||||
JMAWTContextRef mContext;
|
||||
TopLevelFrame* mFrame;
|
||||
|
||||
// support for SupportsMixin.
|
||||
static const InterfaceInfo sInterfaces[];
|
||||
static const UInt32 kInterfaceCount;
|
||||
};
|
|
@ -1,241 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
MJRConsole.java
|
||||
|
||||
Simple Java console for MRJ.
|
||||
|
||||
All methods are called asynchronously, using JMExecJNIStaticMethodInContext(). After posting
|
||||
each call this way, MRJConsole.finish() is called, which waits on MRJConsole.class. Each
|
||||
public method calls MRJConsole.done(), which notifies. This should probably be changed
|
||||
to a pure Java approach.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
package netscape.oji;
|
||||
|
||||
import java.io.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
class ConsoleWindow extends Frame {
|
||||
TextArea text;
|
||||
|
||||
ConsoleWindow(String title) {
|
||||
super("Java Console");
|
||||
|
||||
addWindowListener(
|
||||
new WindowAdapter() {
|
||||
public void windowClosing(WindowEvent e) {
|
||||
hide();
|
||||
}
|
||||
});
|
||||
|
||||
add(text = new TextArea());
|
||||
setSize(300, 200);
|
||||
|
||||
ActionListener dumpThreadsListener =
|
||||
new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
dumpThreads();
|
||||
}
|
||||
};
|
||||
|
||||
// Create a console menu.
|
||||
MenuBar menuBar = new MenuBar();
|
||||
Menu consoleMenu = new Menu("Console");
|
||||
consoleMenu.add(newItem("Dump Threads", dumpThreadsListener));
|
||||
|
||||
menuBar.add(consoleMenu);
|
||||
setMenuBar(menuBar);
|
||||
}
|
||||
|
||||
private MenuItem newItem(String title, ActionListener listener) {
|
||||
MenuItem item = new MenuItem(title);
|
||||
item.addActionListener(listener);
|
||||
return item;
|
||||
}
|
||||
|
||||
public void dumpThreads() {
|
||||
System.out.println("Dumping threads...");
|
||||
}
|
||||
}
|
||||
|
||||
public class MRJConsole {
|
||||
// Save primordial System streams.
|
||||
private static InputStream in;
|
||||
private static PrintStream out;
|
||||
private static PrintStream err;
|
||||
private static ConsoleWindow window;
|
||||
|
||||
native static int readLine(byte[] buffer, int offset, int length);
|
||||
native static void writeLine(byte[] buffer, int offset, int length);
|
||||
|
||||
private static class Input extends InputStream {
|
||||
byte[] buffer = new byte[1024];
|
||||
int position = 0;
|
||||
int count = 0;
|
||||
|
||||
private void fillBuffer() throws EOFException {
|
||||
// int length = readLine(buffer, 0, buffer.length);
|
||||
int length = 1024;
|
||||
if (length == -1)
|
||||
throw new EOFException();
|
||||
count = length;
|
||||
position = 0;
|
||||
}
|
||||
|
||||
public int read() throws IOException {
|
||||
synchronized(this) {
|
||||
if (position >= count)
|
||||
fillBuffer();
|
||||
return buffer[position++];
|
||||
}
|
||||
}
|
||||
|
||||
public int read(byte[] b, int offset, int length) throws IOException {
|
||||
synchronized(this) {
|
||||
// only fill the buffer at the outset, always returns at most one line of data.
|
||||
if (position >= count)
|
||||
fillBuffer();
|
||||
int initialOffset = offset;
|
||||
while (offset < length && position < count) {
|
||||
b[offset++] = buffer[position++];
|
||||
}
|
||||
return (offset - initialOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class Output extends OutputStream implements Runnable {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
|
||||
public Output() {
|
||||
Thread flusher = new Thread(this, getClass().getName() + "-Flusher");
|
||||
flusher.setDaemon(true);
|
||||
flusher.start();
|
||||
}
|
||||
|
||||
public synchronized void write(int b) throws IOException {
|
||||
this.buffer.append((char)b);
|
||||
notify();
|
||||
}
|
||||
|
||||
public synchronized void write(byte[] buffer, int offset, int count) throws IOException {
|
||||
this.buffer.append(new String(buffer, 0, offset, count));
|
||||
notify();
|
||||
}
|
||||
|
||||
public synchronized void flush() throws IOException {
|
||||
String value = this.buffer.toString();
|
||||
window.text.append(value);
|
||||
this.buffer.setLength(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* When I/O occurs, it is placed in a StringBuffer, which is flushed in a different thread.
|
||||
* This prevents deadlocks that could occur when the AWT itself is printing messages.
|
||||
*/
|
||||
public synchronized void run() {
|
||||
for (;;) {
|
||||
try {
|
||||
wait();
|
||||
flush();
|
||||
} catch (InterruptedException ie) {
|
||||
} catch (IOException ioe) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class Error extends Output {}
|
||||
|
||||
public static void init() {
|
||||
in = System.in;
|
||||
out = System.out;
|
||||
err = System.err;
|
||||
|
||||
window = new ConsoleWindow("Java Console");
|
||||
|
||||
System.setIn(new Input());
|
||||
System.setOut(new PrintStream(new Output()));
|
||||
System.setErr(new PrintStream(new Error()));
|
||||
|
||||
done();
|
||||
}
|
||||
|
||||
public static void dispose() {
|
||||
System.setIn(in);
|
||||
System.setOut(out);
|
||||
System.setErr(err);
|
||||
window.dispose();
|
||||
window = null;
|
||||
done();
|
||||
}
|
||||
|
||||
public static void show() {
|
||||
window.show();
|
||||
done();
|
||||
}
|
||||
|
||||
public static void hide() {
|
||||
window.hide();
|
||||
done();
|
||||
}
|
||||
|
||||
public static void visible(boolean[] result) {
|
||||
result[0] = window.isVisible();
|
||||
done();
|
||||
}
|
||||
|
||||
public static void print(String text) {
|
||||
System.out.print(text);
|
||||
done();
|
||||
}
|
||||
|
||||
public static synchronized void finish() {
|
||||
try {
|
||||
MRJConsole.class.wait();
|
||||
} catch (InterruptedException ie) {
|
||||
}
|
||||
}
|
||||
|
||||
private static synchronized void done() {
|
||||
MRJConsole.class.notify();
|
||||
}
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,168 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
MRJContext.h
|
||||
|
||||
Manages Java content using the MacOS Runtime for Java.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "jni.h"
|
||||
#include "JManager.h"
|
||||
#include "nsIPluginTagInfo2.h"
|
||||
|
||||
//
|
||||
// Instance state information about the plugin.
|
||||
//
|
||||
// *Developers*: Use this struct to hold per-instance
|
||||
// information that you'll need in the
|
||||
// various functions in this file.
|
||||
//
|
||||
|
||||
class MRJSession;
|
||||
class MRJPluginInstance;
|
||||
class nsIPluginInstancePeer;
|
||||
struct nsPluginWindow;
|
||||
class MRJFrame;
|
||||
class MRJPage;
|
||||
struct MRJPageAttributes;
|
||||
class MRJSecurityContext;
|
||||
|
||||
struct nsPluginPoint {
|
||||
PRInt32 x;
|
||||
PRInt32 y;
|
||||
};
|
||||
|
||||
class MRJContext {
|
||||
public:
|
||||
MRJContext(MRJSession* session, MRJPluginInstance* instance);
|
||||
~MRJContext();
|
||||
|
||||
void processAppletTag();
|
||||
Boolean createContext();
|
||||
JMAWTContextRef getContextRef();
|
||||
JMAppletViewerRef getViewerRef();
|
||||
|
||||
void setProxyInfoForURL(char * url, JMProxyType proxyType);
|
||||
Boolean appletLoaded();
|
||||
Boolean loadApplet();
|
||||
Boolean isActive();
|
||||
|
||||
void suspendApplet();
|
||||
void resumeApplet();
|
||||
|
||||
jobject getApplet();
|
||||
|
||||
void idle(short modifiers);
|
||||
void drawApplet();
|
||||
void printApplet(nsPluginWindow* printingWindow);
|
||||
|
||||
void activate(Boolean active);
|
||||
void resume(Boolean inFront);
|
||||
|
||||
void click(const EventRecord* event, MRJFrame* frame);
|
||||
void keyPress(long message, short modifiers);
|
||||
void keyRelease(long message, short modifiers);
|
||||
|
||||
void setWindow(nsPluginWindow* pluginWindow);
|
||||
Boolean inspectWindow();
|
||||
|
||||
MRJFrame* findFrame(WindowRef window);
|
||||
GrafPtr getPort();
|
||||
|
||||
void showFrames();
|
||||
void hideFrames();
|
||||
void releaseFrames();
|
||||
|
||||
void setDocumentBase(const char* documentBase);
|
||||
const char* getDocumentBase();
|
||||
|
||||
void setAppletHTML(const char* appletHTML, nsPluginTagType tagType);
|
||||
const char* getAppletHTML();
|
||||
|
||||
void setSecurityContext(MRJSecurityContext* context);
|
||||
MRJSecurityContext* getSecurityContext();
|
||||
|
||||
private:
|
||||
void localToFrame(Point* pt);
|
||||
void ensureValidPort();
|
||||
void synchronizeClipping();
|
||||
void synchronizeVisibility();
|
||||
|
||||
static OSStatus requestFrame(JMAWTContextRef context, JMFrameRef newFrame, JMFrameKind kind,
|
||||
const Rect *initialBounds, Boolean resizeable, JMFrameCallbacks *callbacks);
|
||||
static OSStatus releaseFrame(JMAWTContextRef context, JMFrameRef oldFrame);
|
||||
static SInt16 getUniqueMenuID(JMAWTContextRef context, Boolean isSubmenu);
|
||||
static void exceptionOccurred(JMAWTContextRef context, JMTextRef exceptionName, JMTextRef exceptionMsg, JMTextRef stackTrace);
|
||||
|
||||
static void showDocument(JMAppletViewerRef viewer, JMTextRef urlString, JMTextRef windowName);
|
||||
static void setStatusMessage(JMAppletViewerRef viewer, JMTextRef statusMsg);
|
||||
|
||||
void showURL(const char* url, const char* target);
|
||||
void showStatus(const char* message);
|
||||
SInt16 allocateMenuID(Boolean isSubmenu);
|
||||
|
||||
OSStatus createFrame(JMFrameRef frameRef, JMFrameKind kind, const Rect* initialBounds, Boolean resizeable);
|
||||
|
||||
// Finds a suitable MRJPage object for this document URL, or creates one.
|
||||
MRJPage* findPage(const MRJPageAttributes& attributes);
|
||||
|
||||
static CGrafPtr getEmptyPort();
|
||||
|
||||
private:
|
||||
MRJPluginInstance* mPluginInstance;
|
||||
MRJSession* mSession;
|
||||
JMSessionRef mSessionRef;
|
||||
nsIPluginInstancePeer* mPeer;
|
||||
JMAppletLocatorRef mLocator;
|
||||
JMAWTContextRef mContext;
|
||||
JMAppletViewerRef mViewer;
|
||||
JMFrameRef mViewerFrame;
|
||||
Boolean mIsActive;
|
||||
nsPluginPoint mCachedOrigin;
|
||||
nsPluginRect mCachedClipRect;
|
||||
RgnHandle mPluginClipping;
|
||||
nsPluginWindow* mPluginWindow;
|
||||
CGrafPtr mPluginPort;
|
||||
char* mDocumentBase;
|
||||
char* mAppletHTML;
|
||||
MRJPage* mPage;
|
||||
MRJSecurityContext* mSecurityContext;
|
||||
};
|
|
@ -1,223 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
MRJFrame.cpp
|
||||
|
||||
Encapsulates a JManager frame.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
#include "MRJFrame.h"
|
||||
#include "LocalPort.h"
|
||||
#include "nsplugindefs.h"
|
||||
|
||||
MRJFrame::MRJFrame(JMFrameRef frameRef)
|
||||
: mFrameRef(frameRef), mActive(false), mFocused(false)
|
||||
{
|
||||
}
|
||||
|
||||
MRJFrame::~MRJFrame()
|
||||
{
|
||||
}
|
||||
|
||||
/* Stub implementations. */
|
||||
void MRJFrame::setSize(const Rect* newSize) {}
|
||||
void MRJFrame::invalRect(const Rect* invalidRect) {}
|
||||
void MRJFrame::showHide(Boolean visible) {}
|
||||
void MRJFrame::setTitle(const StringPtr title) {}
|
||||
void MRJFrame::checkUpdate() {}
|
||||
void MRJFrame::reorder(ReorderRequest request) {}
|
||||
void MRJFrame::setResizeable(Boolean resizeable) {}
|
||||
|
||||
Boolean MRJFrame::handleEvent(const EventRecord* event)
|
||||
{
|
||||
Boolean eventHandled = true;
|
||||
|
||||
switch (event->what) {
|
||||
case nsPluginEventType_AdjustCursorEvent:
|
||||
idle(event->modifiers);
|
||||
break;
|
||||
|
||||
case ::mouseDown:
|
||||
click(event);
|
||||
break;
|
||||
|
||||
case keyDown:
|
||||
case autoKey:
|
||||
keyPress(event->message, event->modifiers);
|
||||
break;
|
||||
|
||||
case keyUp:
|
||||
keyRelease(event->message, event->modifiers);
|
||||
break;
|
||||
|
||||
case updateEvt:
|
||||
update();
|
||||
break;
|
||||
|
||||
case activateEvt:
|
||||
activate((event->modifiers & activeFlag) != 0);
|
||||
break;
|
||||
|
||||
#if 0
|
||||
case osEvt:
|
||||
resume((event->message & resumeFlag) != 0);
|
||||
eventHandled = false;
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
eventHandled = false;
|
||||
break;
|
||||
}
|
||||
|
||||
return eventHandled;
|
||||
}
|
||||
|
||||
void MRJFrame::idle(SInt16 modifiers)
|
||||
{
|
||||
LocalPort port(getPort());
|
||||
port.Enter();
|
||||
|
||||
Point pt;
|
||||
::GetMouse(&pt);
|
||||
::JMFrameMouseOver(mFrameRef, pt, modifiers);
|
||||
|
||||
port.Exit();
|
||||
}
|
||||
|
||||
void MRJFrame::update()
|
||||
{
|
||||
GrafPtr framePort = getPort();
|
||||
if (framePort != NULL)
|
||||
::JMFrameUpdate(mFrameRef, framePort->clipRgn);
|
||||
}
|
||||
|
||||
void MRJFrame::activate(Boolean active)
|
||||
{
|
||||
if (mActive != active) {
|
||||
mActive = active;
|
||||
::JMFrameActivate(mFrameRef, active);
|
||||
}
|
||||
}
|
||||
|
||||
void MRJFrame::focusEvent(Boolean gotFocus)
|
||||
{
|
||||
if (&::JMFrameFocus != NULL) {
|
||||
if (gotFocus != mFocused) {
|
||||
if (gotFocus) {
|
||||
// HACK, until focus really works.
|
||||
if (mActive != gotFocus) {
|
||||
mActive = gotFocus;
|
||||
::JMFrameActivate(mFrameRef, gotFocus);
|
||||
}
|
||||
}
|
||||
mFocused = gotFocus;
|
||||
::JMFrameFocus(mFrameRef, gotFocus);
|
||||
}
|
||||
} else {
|
||||
if (mActive != gotFocus) {
|
||||
mActive = gotFocus;
|
||||
::JMFrameActivate(mFrameRef, gotFocus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MRJFrame::resume(Boolean inFront)
|
||||
{
|
||||
::JMFrameResume(mFrameRef, inFront);
|
||||
}
|
||||
|
||||
void MRJFrame::click(const EventRecord* event)
|
||||
{
|
||||
// make the frame's port current, and move its origin to (0, 0).
|
||||
// this is needed to transform the mouse click location to frame coordinates.
|
||||
LocalPort port(getPort());
|
||||
port.Enter();
|
||||
|
||||
Point localWhere = event->where;
|
||||
::GlobalToLocal(&localWhere);
|
||||
click(event, localWhere);
|
||||
|
||||
// restore the plugin port's origin, and restore the current port.
|
||||
port.Exit();
|
||||
}
|
||||
|
||||
void MRJFrame::click(const EventRecord* event, Point localWhere)
|
||||
{
|
||||
if (&::JMFrameClickWithEventRecord != NULL)
|
||||
::JMFrameClickWithEventRecord(mFrameRef, localWhere, event);
|
||||
else
|
||||
::JMFrameClick(mFrameRef, localWhere, event->modifiers);
|
||||
}
|
||||
|
||||
void MRJFrame::keyPress(UInt32 message, SInt16 modifiers)
|
||||
{
|
||||
::JMFrameKey(mFrameRef, message & charCodeMask, (message & keyCodeMask) >> 8, modifiers);
|
||||
}
|
||||
|
||||
void MRJFrame::keyRelease(UInt32 message, SInt16 modifiers)
|
||||
{
|
||||
::JMFrameKeyRelease(mFrameRef, message & charCodeMask, (message & keyCodeMask) >> 8, modifiers);
|
||||
}
|
||||
|
||||
void MRJFrame::menuSelected(UInt32 message, SInt16 modifiers)
|
||||
{
|
||||
MenuHandle menu = ::GetMenuHandle(short(message >> 16));
|
||||
if (menu != NULL) {
|
||||
short item = short(message);
|
||||
if (&::JMMenuSelectedWithModifiers != NULL)
|
||||
::JMMenuSelectedWithModifiers(::JMGetFrameContext(mFrameRef), menu, item, modifiers);
|
||||
else
|
||||
::JMMenuSelected(::JMGetFrameContext(mFrameRef), menu, item);
|
||||
}
|
||||
}
|
||||
|
||||
void MRJFrame::print(GrafPtr printingPort, Point frameOrigin)
|
||||
{
|
||||
#if 0
|
||||
// this doesn't work, as Apple hasn't implemented it yet.
|
||||
OSStatus status = JMDrawFrameInPort(mFrameRef, printingPort, frameOrigin, printingPort->clipRgn, false);
|
||||
if (status != noErr) {
|
||||
::MoveTo(10, 12);
|
||||
::TextFont(0);
|
||||
::TextSize(12);
|
||||
::DrawString("\pMRJPlugin: printing failed.");
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -1,95 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
MRJFrame.h
|
||||
|
||||
Encapsulates a JManager frame.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef CALL_NOT_IN_CARBON
|
||||
#define CALL_NOT_IN_CARBON 1
|
||||
#endif
|
||||
|
||||
#include "jni.h"
|
||||
#include "JManager.h"
|
||||
|
||||
struct EventRecord;
|
||||
struct nsPluginPrint;
|
||||
|
||||
class MRJFrame {
|
||||
public:
|
||||
MRJFrame(JMFrameRef frameRef);
|
||||
virtual ~MRJFrame();
|
||||
|
||||
/** Methods used to implement the JMFrame callback protocol. */
|
||||
virtual void setSize(const Rect* newSize);
|
||||
virtual void invalRect(const Rect* invalidRect);
|
||||
virtual void showHide(Boolean visible);
|
||||
virtual void setTitle(const StringPtr title);
|
||||
virtual void checkUpdate();
|
||||
virtual void reorder(ReorderRequest request);
|
||||
virtual void setResizeable(Boolean resizeable);
|
||||
|
||||
/** Methods to handle various events. */
|
||||
virtual Boolean handleEvent(const EventRecord* event);
|
||||
|
||||
virtual void idle(SInt16 modifiers);
|
||||
virtual void update();
|
||||
virtual void activate(Boolean active);
|
||||
virtual void resume(Boolean inFront);
|
||||
virtual void click(const EventRecord* event);
|
||||
virtual void click(const EventRecord* event, Point localWhere);
|
||||
virtual void keyPress(UInt32 message, SInt16 modifiers);
|
||||
virtual void keyRelease(UInt32 message, SInt16 modifiers);
|
||||
|
||||
virtual void focusEvent(Boolean gotFocus);
|
||||
virtual void menuSelected(UInt32 message, SInt16 modifiers);
|
||||
|
||||
virtual void print(GrafPtr printingPort, Point frameOrigin);
|
||||
|
||||
protected:
|
||||
virtual GrafPtr getPort() = 0;
|
||||
|
||||
protected:
|
||||
JMFrameRef mFrameRef;
|
||||
Boolean mActive;
|
||||
Boolean mFocused;
|
||||
};
|
|
@ -1,138 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
MRJMonitor.cpp
|
||||
|
||||
Provides a C++ interface to Java monitors.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
#include "MRJMonitor.h"
|
||||
#include "MRJSession.h"
|
||||
|
||||
MRJMonitor::MRJMonitor(MRJSession* session, jobject monitor)
|
||||
: mSession(session), mMonitor(NULL), mWaitMethod(NULL), mNotifyMethod(NULL), mNotifyAllMethod(NULL)
|
||||
{
|
||||
JNIEnv* env = mSession->getCurrentEnv();
|
||||
jclass javaLangObject = env->FindClass("java/lang/Object");
|
||||
if (javaLangObject != NULL) {
|
||||
// look up method IDs.
|
||||
mWaitMethod = env->GetMethodID(javaLangObject, "wait", "()V");
|
||||
mTimedWaitMethod = env->GetMethodID(javaLangObject, "wait", "(J)V");
|
||||
mNotifyMethod = env->GetMethodID(javaLangObject, "notify", "()V");
|
||||
mNotifyAllMethod = env->GetMethodID(javaLangObject, "notifyAll", "()V");
|
||||
|
||||
Boolean allocateMonitor = (monitor == NULL);
|
||||
if (allocateMonitor)
|
||||
monitor = env->AllocObject(javaLangObject);
|
||||
|
||||
if (monitor != NULL)
|
||||
mMonitor = env->NewGlobalRef(monitor);
|
||||
|
||||
if (allocateMonitor)
|
||||
env->DeleteLocalRef(monitor);
|
||||
|
||||
env->DeleteLocalRef(javaLangObject);
|
||||
}
|
||||
}
|
||||
|
||||
MRJMonitor::~MRJMonitor()
|
||||
{
|
||||
if (mMonitor != NULL) {
|
||||
JNIEnv* env = mSession->getCurrentEnv();
|
||||
env->DeleteGlobalRef(mMonitor);
|
||||
mMonitor = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void MRJMonitor::enter()
|
||||
{
|
||||
JNIEnv* env = mSession->getCurrentEnv();
|
||||
env->MonitorEnter(mMonitor);
|
||||
}
|
||||
|
||||
void MRJMonitor::exit()
|
||||
{
|
||||
JNIEnv* env = mSession->getCurrentEnv();
|
||||
env->MonitorExit(mMonitor);
|
||||
}
|
||||
|
||||
void MRJMonitor::wait()
|
||||
{
|
||||
if (mMonitor != NULL && mWaitMethod != NULL) {
|
||||
JNIEnv* env = mSession->getCurrentEnv();
|
||||
env->MonitorEnter(mMonitor);
|
||||
env->CallVoidMethod(mMonitor, mWaitMethod);
|
||||
env->MonitorExit(mMonitor);
|
||||
}
|
||||
}
|
||||
|
||||
void MRJMonitor::wait(long long millis)
|
||||
{
|
||||
if (mMonitor != NULL && mWaitMethod != NULL) {
|
||||
JNIEnv* env = mSession->getCurrentEnv();
|
||||
env->MonitorEnter(mMonitor);
|
||||
env->CallVoidMethod(mMonitor, mTimedWaitMethod, jlong(millis));
|
||||
env->MonitorExit(mMonitor);
|
||||
}
|
||||
}
|
||||
|
||||
void MRJMonitor::notify()
|
||||
{
|
||||
if (mMonitor != NULL && mNotifyMethod != NULL) {
|
||||
JNIEnv* env = mSession->getCurrentEnv();
|
||||
env->MonitorEnter(mMonitor);
|
||||
env->CallVoidMethod(mMonitor, mNotifyMethod);
|
||||
env->MonitorExit(mMonitor);
|
||||
}
|
||||
}
|
||||
|
||||
void MRJMonitor::notifyAll()
|
||||
{
|
||||
if (mMonitor != NULL && mNotifyAllMethod != NULL) {
|
||||
JNIEnv* env = mSession->getCurrentEnv();
|
||||
env->MonitorEnter(mMonitor);
|
||||
env->CallVoidMethod(mMonitor, mNotifyAllMethod);
|
||||
env->MonitorExit(mMonitor);
|
||||
}
|
||||
}
|
||||
|
||||
jobject MRJMonitor::getObject()
|
||||
{
|
||||
return mMonitor;
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
MRJMonitor.h
|
||||
|
||||
Provides a C++ interface to Java monitors.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
#include "Monitor.h"
|
||||
|
||||
#ifndef JNI_H
|
||||
#include "jni.h"
|
||||
#endif
|
||||
|
||||
class MRJSession;
|
||||
|
||||
class MRJMonitor : public Monitor {
|
||||
public:
|
||||
MRJMonitor(MRJSession* session, jobject monitor = NULL);
|
||||
~MRJMonitor();
|
||||
|
||||
virtual void enter();
|
||||
virtual void exit();
|
||||
|
||||
virtual void wait();
|
||||
virtual void wait(long long millis);
|
||||
virtual void notify();
|
||||
virtual void notifyAll();
|
||||
|
||||
virtual jobject getObject();
|
||||
|
||||
private:
|
||||
MRJSession* mSession;
|
||||
jobject mMonitor;
|
||||
jmethodID mWaitMethod;
|
||||
jmethodID mTimedWaitMethod;
|
||||
jmethodID mNotifyMethod;
|
||||
jmethodID mNotifyAllMethod;
|
||||
};
|
|
@ -1,417 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
MRJNetworking.cpp
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
#include <TextCommon.h>
|
||||
#include <JManager.h>
|
||||
#include "JMURLConnection.h"
|
||||
|
||||
#include "MRJNetworking.h"
|
||||
#include "MRJContext.h"
|
||||
#include "MRJPlugin.h"
|
||||
#include "MRJSession.h"
|
||||
#include "MRJMonitor.h"
|
||||
#include "nsIPluginManager2.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
extern nsIPluginManager* thePluginManager; // now in badaptor.cpp.
|
||||
extern nsIPluginManager2* thePluginManager2;
|
||||
|
||||
static char* JMTextToEncoding(JMTextRef textRef, JMTextEncoding encoding)
|
||||
{
|
||||
UInt32 length = 0;
|
||||
OSStatus status = ::JMGetTextLengthInBytes(textRef, encoding, &length);
|
||||
if (status != noErr)
|
||||
return NULL;
|
||||
char* text = new char[length + 1];
|
||||
if (text != NULL) {
|
||||
UInt32 actualLength;
|
||||
status = ::JMGetTextBytes(textRef, encoding, text, length, &actualLength);
|
||||
if (status != noErr) {
|
||||
delete text;
|
||||
return NULL;
|
||||
}
|
||||
text[length] = '\0';
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
class MRJInputStream : public nsIPluginStreamListener {
|
||||
MRJMonitor mMonitor;
|
||||
typedef std::vector<char> buffer_t;
|
||||
buffer_t mBuffer;
|
||||
size_t mOffset;
|
||||
bool mComplete;
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
MRJInputStream(MRJSession* session)
|
||||
: mMonitor(session), mOffset(0), mComplete(false)
|
||||
{
|
||||
mBuffer.reserve(8192);
|
||||
}
|
||||
|
||||
NS_IMETHOD
|
||||
OnStartBinding(nsIPluginStreamInfo* pluginInfo)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD
|
||||
OnDataAvailable(nsIPluginStreamInfo* pluginInfo, nsIInputStream* input, PRUint32 length);
|
||||
|
||||
NS_IMETHOD
|
||||
OnFileAvailable(nsIPluginStreamInfo* pluginInfo, const char* fileName)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD
|
||||
OnStopBinding(nsIPluginStreamInfo* pluginInfo, nsresult status)
|
||||
{
|
||||
if (!mComplete) {
|
||||
mComplete = true;
|
||||
mMonitor.notify();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD
|
||||
GetStreamType(nsPluginStreamType *result)
|
||||
{
|
||||
*result = nsPluginStreamType_Normal;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
OSStatus read(void* buffer, SInt32 bufferSize, SInt32* bytesRead);
|
||||
};
|
||||
NS_IMPL_ISUPPORTS1(MRJInputStream, nsIPluginStreamListener);
|
||||
|
||||
NS_IMETHODIMP
|
||||
MRJInputStream::OnDataAvailable(nsIPluginStreamInfo* pluginInfo, nsIInputStream* input, PRUint32 length)
|
||||
{
|
||||
size_t oldSize = mBuffer.size();
|
||||
mBuffer.resize(oldSize + length);
|
||||
buffer_t::iterator buffer = mBuffer.begin() + oldSize;
|
||||
input->Read(buffer, length, &length);
|
||||
mMonitor.notify();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
OSStatus MRJInputStream::read(void* buffer, SInt32 bufferSize, SInt32* bytesRead)
|
||||
{
|
||||
size_t sz = mBuffer.size();
|
||||
while (mOffset >= sz && !mComplete) {
|
||||
// wait until there is some data to read.
|
||||
mMonitor.wait();
|
||||
sz = mBuffer.size();
|
||||
}
|
||||
|
||||
SInt32 available = (sz - mOffset);
|
||||
if (bufferSize > available)
|
||||
bufferSize = available;
|
||||
|
||||
if (bufferSize <= 0 && mComplete) {
|
||||
*bytesRead = 0;
|
||||
return noErr;
|
||||
}
|
||||
|
||||
::BlockMoveData(mBuffer.begin() + mOffset, buffer, bufferSize);
|
||||
*bytesRead = bufferSize;
|
||||
mOffset += bufferSize;
|
||||
|
||||
return noErr;
|
||||
}
|
||||
|
||||
class MRJURLConnection {
|
||||
public:
|
||||
MRJURLConnection(JMTextRef url, JMTextRef requestMethod,
|
||||
JMURLConnectionOptions options,
|
||||
JMAppletViewerRef appletViewer);
|
||||
|
||||
~MRJURLConnection();
|
||||
|
||||
MRJPluginInstance* getInstance();
|
||||
const char* getURL();
|
||||
const char* getRequestMethod();
|
||||
Boolean getUsingProxy();
|
||||
|
||||
private:
|
||||
MRJPluginInstance* mInstance;
|
||||
char* mURL;
|
||||
char* mRequestMethod;
|
||||
JMURLConnectionOptions mOptions;
|
||||
Boolean mUsingProxy;
|
||||
};
|
||||
|
||||
MRJURLConnection::MRJURLConnection(JMTextRef url, JMTextRef requestMethod,
|
||||
JMURLConnectionOptions options,
|
||||
JMAppletViewerRef appletViewer)
|
||||
: mInstance(0), mURL(0), mRequestMethod(0), mOptions(options), mUsingProxy(false)
|
||||
{
|
||||
MRJPluginInstance* instance = MRJPluginInstance::getInstances();
|
||||
if (appletViewer != NULL) {
|
||||
while (instance != NULL) {
|
||||
MRJContext* context = instance->getContext();
|
||||
if (context->getViewerRef() == appletViewer) {
|
||||
mInstance = instance;
|
||||
break;
|
||||
}
|
||||
instance = instance->getNextInstance();
|
||||
}
|
||||
} else {
|
||||
// any instance will do?
|
||||
mInstance = instance;
|
||||
NS_IF_ADDREF(instance);
|
||||
}
|
||||
|
||||
TextEncoding utf8 = ::CreateTextEncoding(kTextEncodingUnicodeDefault,
|
||||
kTextEncodingDefaultVariant,
|
||||
kUnicodeUTF8Format);
|
||||
|
||||
// pull the text out of the url and requestMethod.
|
||||
mURL = ::JMTextToEncoding(url, utf8);
|
||||
mRequestMethod = ::JMTextToEncoding(requestMethod, utf8);
|
||||
|
||||
// see if a proxy will be used for this URL.
|
||||
if (thePluginManager2 != NULL) {
|
||||
char* proxyForURL = NULL;
|
||||
if (thePluginManager2->FindProxyForURL(mURL, &proxyForURL) == NS_OK) {
|
||||
mUsingProxy = (::strcmp("DIRECT", proxyForURL) != 0);
|
||||
delete[] proxyForURL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MRJURLConnection::~MRJURLConnection()
|
||||
{
|
||||
delete[] mURL;
|
||||
delete[] mRequestMethod;
|
||||
}
|
||||
|
||||
inline MRJPluginInstance* MRJURLConnection::getInstance()
|
||||
{
|
||||
return mInstance;
|
||||
}
|
||||
|
||||
inline const char* MRJURLConnection::getURL()
|
||||
{
|
||||
return mURL;
|
||||
}
|
||||
|
||||
inline const char* MRJURLConnection::getRequestMethod()
|
||||
{
|
||||
return mRequestMethod;
|
||||
}
|
||||
|
||||
inline Boolean MRJURLConnection::getUsingProxy()
|
||||
{
|
||||
return mUsingProxy;
|
||||
}
|
||||
|
||||
static OSStatus openConnection(
|
||||
/* in URL = */ JMTextRef url,
|
||||
/* in RequestMethod = */ JMTextRef requestMethod,
|
||||
/* in ConnectionOptions = */ JMURLConnectionOptions options,
|
||||
/* in AppletViewer = */ JMAppletViewerRef appletViewer,
|
||||
/* out URLConnectionRef = */ JMURLConnectionRef* urlConnectionRef
|
||||
)
|
||||
{
|
||||
MRJURLConnection* connection = new MRJURLConnection(url, requestMethod,
|
||||
options, appletViewer);
|
||||
*urlConnectionRef = connection;
|
||||
return noErr;
|
||||
}
|
||||
|
||||
static OSStatus closeConnection(
|
||||
/* in URLConnectionRef = */ JMURLConnectionRef urlConnectionRef
|
||||
)
|
||||
{
|
||||
MRJURLConnection* connection = reinterpret_cast<MRJURLConnection*>(urlConnectionRef);
|
||||
delete connection;
|
||||
return noErr;
|
||||
}
|
||||
|
||||
static Boolean usingProxy(
|
||||
/* in URLConnectionRef = */ JMURLConnectionRef urlConnectionRef
|
||||
)
|
||||
{
|
||||
MRJURLConnection* connection = reinterpret_cast<MRJURLConnection*>(urlConnectionRef);
|
||||
return connection->getUsingProxy();
|
||||
}
|
||||
|
||||
static OSStatus getCookie(
|
||||
/* in URLConnectionRef = */ JMURLConnectionRef urlConnectionRef,
|
||||
/* out CookieValue = */ JMTextRef* cookie
|
||||
)
|
||||
{
|
||||
return paramErr;
|
||||
}
|
||||
|
||||
static OSStatus setCookie(
|
||||
/* in URLConnectionRef = */ JMURLConnectionRef urlConnectionRef,
|
||||
/* in CookieValue = */ JMTextRef cookie
|
||||
)
|
||||
{
|
||||
return paramErr;
|
||||
}
|
||||
|
||||
static OSStatus setRequestProperties(
|
||||
/* in URLConnectionRef = */ JMURLConnectionRef urlConnectionRef,
|
||||
/* in NumberOfProperties = */ int numberOfProperties,
|
||||
/* in PropertyNames = */ JMTextRef* keys,
|
||||
/* in Values = */ JMTextRef* value
|
||||
)
|
||||
{
|
||||
return paramErr;
|
||||
}
|
||||
|
||||
static OSStatus getResponsePropertiesCount(
|
||||
/* in URLConnectionRef = */ JMURLInputStreamRef urlInputStreamRef,
|
||||
/* out numberOfProperties = */ int* numberOfProperties
|
||||
)
|
||||
{
|
||||
if (numberOfProperties == NULL)
|
||||
return paramErr;
|
||||
*numberOfProperties = 0;
|
||||
return noErr;
|
||||
}
|
||||
|
||||
static OSStatus getResponseProperties(
|
||||
/* in URLConnectionRef = */ JMURLInputStreamRef urlInputStreamRef,
|
||||
/* in numberOfProperties = */ int numberOfProperties,
|
||||
/* out PropertyNames = */ JMTextRef* keys,
|
||||
/* out Values = */ JMTextRef* values
|
||||
)
|
||||
{
|
||||
return noErr;
|
||||
}
|
||||
|
||||
static OSStatus openInputStream(
|
||||
/* in URLConnectionRef = */ JMURLConnectionRef urlConnectionRef,
|
||||
/* out URLStreamRef = */ JMURLInputStreamRef* urlInputStreamRef
|
||||
)
|
||||
{
|
||||
MRJURLConnection* connection = reinterpret_cast<MRJURLConnection*>(urlConnectionRef);
|
||||
MRJInputStream* inputStream = new MRJInputStream(connection->getInstance()->getSession());
|
||||
inputStream->AddRef();
|
||||
*urlInputStreamRef = inputStream;
|
||||
|
||||
nsIPluginInstance* pluginInstance = connection->getInstance();
|
||||
nsIPluginStreamListener* listener = inputStream;
|
||||
nsresult rv = thePluginManager->GetURL(pluginInstance, connection->getURL(), NULL, listener);
|
||||
|
||||
return noErr;
|
||||
}
|
||||
|
||||
static OSStatus openOutputStream(
|
||||
/* in URLConnectionRef = */ JMURLConnectionRef urlConnectionRef,
|
||||
/* out URLOutputStreamRef = */ JMURLOutputStreamRef* urlOutputStreamRef
|
||||
)
|
||||
{
|
||||
return paramErr;
|
||||
}
|
||||
|
||||
static OSStatus closeInputStream(
|
||||
/* in URLInputStreamRef = */ JMURLInputStreamRef urlInputStreamRef
|
||||
)
|
||||
{
|
||||
MRJInputStream* inputStream = reinterpret_cast<MRJInputStream*>(urlInputStreamRef);
|
||||
inputStream->Release();
|
||||
return noErr;
|
||||
}
|
||||
|
||||
static OSStatus closeOutputStream(
|
||||
/* in URLOutputStreamRef = */ JMURLOutputStreamRef urlOutputStreamRef
|
||||
)
|
||||
{
|
||||
return paramErr;
|
||||
}
|
||||
|
||||
static OSStatus readInputStream(
|
||||
/* in URLConnectionRef = */ JMURLInputStreamRef urlInputStreamRef,
|
||||
/* out Buffer = */ void* buffer,
|
||||
/* in BufferSize = */ UInt32 bufferSize,
|
||||
/* out BytesRead = */ SInt32* bytesRead
|
||||
)
|
||||
{
|
||||
MRJInputStream* inputStream = reinterpret_cast<MRJInputStream*>(urlInputStreamRef);
|
||||
return inputStream->read(buffer, bufferSize, bytesRead);
|
||||
}
|
||||
|
||||
static OSStatus writeOutputStream(
|
||||
/* in URLConnectionRef = */ JMURLOutputStreamRef oStreamRef,
|
||||
/* in Buffer = */ void* buffer,
|
||||
/* in BytesToWrite = */ SInt32 bytesToWrite
|
||||
)
|
||||
{
|
||||
return paramErr;
|
||||
}
|
||||
|
||||
static JMURLCallbacks theURLCallbacks = {
|
||||
kJMVersion,
|
||||
&openConnection, &closeConnection,
|
||||
&usingProxy, &getCookie, &setCookie,
|
||||
&setRequestProperties,
|
||||
&getResponsePropertiesCount,
|
||||
&getResponseProperties,
|
||||
&openInputStream, &openOutputStream,
|
||||
&closeInputStream, &closeOutputStream,
|
||||
&readInputStream, &writeOutputStream
|
||||
};
|
||||
|
||||
OSStatus OpenMRJNetworking(MRJSession* session)
|
||||
{
|
||||
OSStatus rv = paramErr;
|
||||
if (&::JMURLSetCallbacks != 0) {
|
||||
rv = ::JMURLSetCallbacks(session->getSessionRef(),
|
||||
"http", &theURLCallbacks);
|
||||
rv = ::JMURLSetCallbacks(session->getSessionRef(),
|
||||
"https", &theURLCallbacks);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
OSStatus CloseMRJNetworking(MRJSession* session)
|
||||
{
|
||||
return noErr;
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
MRJNetworking.h
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __MACTYPES__
|
||||
#include <MacTypes.h>
|
||||
#endif
|
||||
|
||||
class MRJSession;
|
||||
|
||||
OSStatus OpenMRJNetworking(MRJSession* session);
|
||||
OSStatus CloseMRJNetworking(MRJSession* session);
|
|
@ -1,153 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
MRJPage.cpp
|
||||
|
||||
Encapsulates the new MRJ Page API, which loads applets into a common context.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
#include "MRJPage.h"
|
||||
#include "MRJSession.h"
|
||||
|
||||
#include "StringUtils.h"
|
||||
|
||||
MRJPage::MRJPage(MRJSession* session, UInt32 documentID, const char* codeBase, const char* archive, Boolean mayScript)
|
||||
: mRefCount(0), mNextPage(NULL), mSession(session), mPageRef(NULL),
|
||||
mDocumentID(documentID), mCodeBase(strdup(codeBase)), mArchive(strdup(archive)), mMayScript(mayScript)
|
||||
{
|
||||
pushPage();
|
||||
|
||||
if (&::JMNewAppletPage != NULL) {
|
||||
OSStatus status = ::JMNewAppletPage(&mPageRef, session->getSessionRef());
|
||||
if (status != noErr) mPageRef = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
MRJPage::MRJPage(MRJSession* session, const MRJPageAttributes& attributes)
|
||||
: mRefCount(0), mNextPage(NULL), mSession(session), mPageRef(NULL),
|
||||
mDocumentID(attributes.documentID), mCodeBase(strdup(attributes.codeBase)),
|
||||
mArchive(strdup(attributes.archive)), mMayScript(attributes.mayScript)
|
||||
{
|
||||
pushPage();
|
||||
|
||||
if (&::JMNewAppletPage != NULL) {
|
||||
OSStatus status = ::JMNewAppletPage(&mPageRef, session->getSessionRef());
|
||||
if (status != noErr) mPageRef = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
MRJPage::~MRJPage()
|
||||
{
|
||||
popPage();
|
||||
|
||||
if (&::JMDisposeAppletPage != NULL && mPageRef != NULL) {
|
||||
OSStatus status = ::JMDisposeAppletPage(mPageRef);
|
||||
mPageRef = NULL;
|
||||
}
|
||||
|
||||
if (mCodeBase != NULL) {
|
||||
delete[] mCodeBase;
|
||||
mCodeBase = NULL;
|
||||
}
|
||||
|
||||
if (mArchive != NULL) {
|
||||
delete[] mArchive;
|
||||
mArchive = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
UInt16 MRJPage::AddRef()
|
||||
{
|
||||
return (++mRefCount);
|
||||
}
|
||||
|
||||
UInt16 MRJPage::Release()
|
||||
{
|
||||
UInt16 result = --mRefCount;
|
||||
if (result == 0) {
|
||||
delete this;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Boolean MRJPage::createContext(JMAWTContextRef* outContext, const JMAWTContextCallbacks * callbacks, JMClientData data)
|
||||
{
|
||||
OSStatus status = noErr;
|
||||
if (&::JMNewAWTContextInPage != NULL && mPageRef != NULL) {
|
||||
status = ::JMNewAWTContextInPage(outContext, mSession->getSessionRef(), mPageRef, callbacks, data);
|
||||
} else {
|
||||
status = ::JMNewAWTContext(outContext, mSession->getSessionRef(), callbacks, data);
|
||||
}
|
||||
return (status == noErr);
|
||||
}
|
||||
|
||||
static MRJPage* thePageList = NULL;
|
||||
|
||||
MRJPage* MRJPage::getFirstPage()
|
||||
{
|
||||
return thePageList;
|
||||
}
|
||||
|
||||
MRJPage* MRJPage::getNextPage()
|
||||
{
|
||||
return mNextPage;
|
||||
}
|
||||
|
||||
void MRJPage::pushPage()
|
||||
{
|
||||
// put this on the global list of pages.
|
||||
mNextPage = thePageList;
|
||||
thePageList = this;
|
||||
}
|
||||
|
||||
void MRJPage::popPage()
|
||||
{
|
||||
// Remove this page from the global list.
|
||||
MRJPage** link = &thePageList;
|
||||
MRJPage* page = *link;
|
||||
while (page != NULL) {
|
||||
if (page == this) {
|
||||
*link = mNextPage;
|
||||
mNextPage = NULL;
|
||||
break;
|
||||
}
|
||||
link = &page->mNextPage;
|
||||
page = *link;
|
||||
}
|
||||
}
|
|
@ -1,106 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
MRJPage.h
|
||||
|
||||
Encapsulates the MRJ data structure.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
#ifndef __TYPES__
|
||||
#include <Types.h>
|
||||
#endif
|
||||
|
||||
#ifndef CALL_NOT_IN_CARBON
|
||||
#define CALL_NOT_IN_CARBON 1
|
||||
#endif
|
||||
|
||||
#include "JManager.h"
|
||||
|
||||
// For now.
|
||||
typedef struct OpaqueJMAppletPageRef* JMAppletPageRef;
|
||||
|
||||
class MRJSession;
|
||||
|
||||
struct MRJPageAttributes {
|
||||
UInt32 documentID;
|
||||
const char* codeBase;
|
||||
const char* archive;
|
||||
Boolean mayScript;
|
||||
};
|
||||
|
||||
class MRJPage {
|
||||
public:
|
||||
MRJPage(MRJSession* session, UInt32 documentID, const char* codeBase, const char* archive, Boolean mayScript);
|
||||
MRJPage(MRJSession* session, const MRJPageAttributes& attributes);
|
||||
~MRJPage();
|
||||
|
||||
// Pages are reference counted.
|
||||
UInt16 AddRef(void);
|
||||
UInt16 Release(void);
|
||||
|
||||
JMAppletPageRef getPageRef() { return mPageRef; }
|
||||
|
||||
UInt32 getDocumentID() { return mDocumentID; }
|
||||
const char* getCodeBase() { return mCodeBase; }
|
||||
const char* getArchive() { return mArchive; }
|
||||
Boolean getMayScript() { return mMayScript; }
|
||||
|
||||
// Creating AWTContexts.
|
||||
Boolean createContext(JMAWTContextRef* outContext,
|
||||
const JMAWTContextCallbacks * callbacks,
|
||||
JMClientData data);
|
||||
|
||||
// Accessing the list of instances.
|
||||
static MRJPage* getFirstPage(void);
|
||||
MRJPage* getNextPage(void);
|
||||
|
||||
private:
|
||||
void pushPage();
|
||||
void popPage();
|
||||
|
||||
private:
|
||||
UInt16 mRefCount;
|
||||
MRJPage* mNextPage;
|
||||
MRJSession* mSession;
|
||||
JMAppletPageRef mPageRef;
|
||||
UInt32 mDocumentID;
|
||||
char* mCodeBase;
|
||||
char* mArchive;
|
||||
Boolean mMayScript;
|
||||
};
|
|
@ -1,941 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
MRJPlugin.cpp
|
||||
|
||||
XP COM Plugin Implementation.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
#include "MRJPlugin.h"
|
||||
#include "MRJSession.h"
|
||||
#include "MRJContext.h"
|
||||
#include "MRJFrame.h"
|
||||
#include "MRJConsole.h"
|
||||
#include "EmbeddedFramePluginInstance.h"
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsMemory.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIJVMManager.h"
|
||||
#include "nsIJVMPluginTagInfo.h"
|
||||
#include "nsIPluginManager2.h"
|
||||
#include "nsIPluginInstancePeer.h"
|
||||
#include "nsIWindowlessPlugInstPeer.h"
|
||||
#include "LiveConnectNativeMethods.h"
|
||||
#include "CSecureEnv.h"
|
||||
#include "EventFilter.h"
|
||||
#include "nsObsoleteModuleLoading.h"
|
||||
|
||||
#include <Resources.h>
|
||||
|
||||
static nsIServiceManager* theServiceManager = NULL;
|
||||
static nsIServiceManagerObsolete* theServiceManagerObsolete = NULL;
|
||||
|
||||
extern nsIServiceManager* theServiceManager; // needs to be in badaptor.cpp.
|
||||
extern nsIPluginManager* thePluginManager; // now in badaptor.cpp.
|
||||
extern nsIPlugin* thePlugin;
|
||||
|
||||
nsIPluginManager2* thePluginManager2 = NULL;
|
||||
nsIMemory* theMemoryAllocator = NULL; // should also be provided by badaptor.cpp.
|
||||
|
||||
FSSpec thePluginSpec;
|
||||
short thePluginRefnum = -1;
|
||||
|
||||
// Common interface IDs.
|
||||
|
||||
static NS_DEFINE_IID(kPluginCID, NS_PLUGIN_CID);
|
||||
static NS_DEFINE_IID(kPluginManagerCID, NS_PLUGINMANAGER_CID);
|
||||
#ifdef MRJPLUGIN_4X
|
||||
static NS_DEFINE_IID(kMemoryCID, NS_MEMORY_CID);
|
||||
#endif
|
||||
static NS_DEFINE_IID(kJVMManagerCID, NS_JVMMANAGER_CID);
|
||||
|
||||
static NS_DEFINE_IID(kIWindowlessPluginInstancePeerIID, NS_IWINDOWLESSPLUGININSTANCEPEER_IID);
|
||||
|
||||
const char* MRJPlugin::PLUGIN_VERSION = "eerieQuarkDoll.v.b1";
|
||||
|
||||
|
||||
nsresult MRJPlugin::GetService(const nsCID& aCID, const nsIID& aIID, void* *aService)
|
||||
{
|
||||
if (theServiceManager)
|
||||
return theServiceManager->GetService(aCID, aIID, aService);
|
||||
if (theServiceManagerObsolete)
|
||||
return theServiceManagerObsolete->GetService(aCID, aIID, (nsISupports **)aService);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult MRJPlugin::GetService(const char* aContractID, const nsIID& aIID, void* *aService)
|
||||
{
|
||||
if (theServiceManager)
|
||||
return theServiceManager->GetServiceByContractID(aContractID, aIID, aService);
|
||||
if (theServiceManagerObsolete)
|
||||
return theServiceManagerObsolete->GetService(aContractID, aIID, (nsISupports **)aService);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
#pragma export on
|
||||
|
||||
nsresult NSGetFactory(nsISupports* serviceManager, const nsCID &aClass, const char *aClassName, const char *aContractID, nsIFactory **aFactory)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
if (theServiceManager == NULL && theServiceManagerObsolete == NULL) {
|
||||
if (NS_FAILED(serviceManager->QueryInterface(NS_GET_IID(nsIServiceManager), (void**)&theServiceManager)))
|
||||
if (NS_FAILED(serviceManager->QueryInterface(NS_GET_IID(nsIServiceManagerObsolete), (void**)&theServiceManagerObsolete)))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Our global operator new wants to use nsIMalloc to do all of its allocation.
|
||||
// This should be available from the Service Manager.
|
||||
#ifdef MRJPLUGIN_4X
|
||||
if (MRJPlugin::GetService(kMemoryCID, NS_GET_IID(nsIMemory), (void**)&theMemoryAllocator) != NS_OK)
|
||||
return NS_ERROR_FAILURE;
|
||||
#else
|
||||
if (NS_FAILED(MRJPlugin::GetService("@mozilla.org/xpcom/memory-service;1", NS_GET_IID(nsIMemory), (void **)&theMemoryAllocator)))
|
||||
return NS_ERROR_FAILURE;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (aClass.Equals(kPluginCID)) {
|
||||
MRJPlugin* pluginFactory = new MRJPlugin();
|
||||
pluginFactory->AddRef();
|
||||
*aFactory = pluginFactory;
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
#pragma export off
|
||||
|
||||
extern "C" {
|
||||
|
||||
pascal OSErr __initialize(const CFragInitBlock *initBlock);
|
||||
pascal void __terminate(void);
|
||||
|
||||
#if defined(MRJPLUGIN_GC)
|
||||
pascal OSErr __NSInitialize(const CFragInitBlock* initBlock);
|
||||
pascal void __NSTerminate(void);
|
||||
#define __initialize __NSInitialize
|
||||
#define __terminate __NSTerminate
|
||||
#endif
|
||||
|
||||
pascal OSErr MRJPlugin__initialize(const CFragInitBlock *initBlock);
|
||||
pascal void MRJPlugin__terminate(void);
|
||||
|
||||
}
|
||||
|
||||
pascal OSErr MRJPlugin__initialize(const CFragInitBlock *initBlock)
|
||||
{
|
||||
OSErr err = __initialize(initBlock);
|
||||
if (err != noErr) return err;
|
||||
|
||||
if (initBlock->fragLocator.where == kDataForkCFragLocator) {
|
||||
thePluginSpec = *initBlock->fragLocator.u.onDisk.fileSpec;
|
||||
|
||||
// is it always the case that the plugin's resource file is open now?
|
||||
thePluginRefnum = ::FSpOpenResFile(&thePluginSpec, fsRdPerm);
|
||||
}
|
||||
|
||||
return noErr;
|
||||
}
|
||||
|
||||
pascal void MRJPlugin__terminate()
|
||||
{
|
||||
#ifdef MRJPLUGIN_4X
|
||||
// Make sure the event filters are removed.
|
||||
RemoveEventFilters();
|
||||
#endif
|
||||
|
||||
__terminate();
|
||||
|
||||
// last ditch release of the memory allocator.
|
||||
if (theMemoryAllocator != NULL) {
|
||||
theMemoryAllocator->Release();
|
||||
theMemoryAllocator = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// The MEAT of the plugin.
|
||||
//
|
||||
|
||||
#pragma mark *** MRJPlugin ***
|
||||
|
||||
const InterfaceInfo MRJPlugin::sInterfaces[] = {
|
||||
{ NS_IPLUGIN_IID, INTERFACE_OFFSET(MRJPlugin, nsIPlugin) },
|
||||
{ NS_IJVMPLUGIN_IID, INTERFACE_OFFSET(MRJPlugin, nsIJVMPlugin) },
|
||||
{ NS_IRUNNABLE_IID, INTERFACE_OFFSET(MRJPlugin, nsIRunnable) },
|
||||
};
|
||||
const UInt32 MRJPlugin::kInterfaceCount = sizeof(sInterfaces) / sizeof(InterfaceInfo);
|
||||
|
||||
MRJPlugin::MRJPlugin()
|
||||
: SupportsMixin(this, sInterfaces, kInterfaceCount),
|
||||
mManager(NULL), mThreadManager(NULL), mSession(NULL), mConsole(NULL), mIsEnabled(false), mPluginThreadID(NULL)
|
||||
{
|
||||
// make this singleton instance visible.
|
||||
::thePlugin = this;
|
||||
}
|
||||
|
||||
MRJPlugin::~MRJPlugin()
|
||||
{
|
||||
// make sure the plugin is no longer visible.
|
||||
::thePlugin = NULL;
|
||||
|
||||
// Release the console.
|
||||
if (mConsole != NULL) {
|
||||
mConsole->Release();
|
||||
mConsole = NULL;
|
||||
}
|
||||
|
||||
// tear down the MRJ session, if it exists.
|
||||
if (mSession != NULL) {
|
||||
delete mSession;
|
||||
mSession = NULL;
|
||||
}
|
||||
|
||||
// Release the manager?
|
||||
if (mManager != NULL) {
|
||||
mManager->Release();
|
||||
mManager = NULL;
|
||||
}
|
||||
|
||||
if (mThreadManager != NULL) {
|
||||
mThreadManager->Release();
|
||||
mThreadManager = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* MRJPlugin aggregates MRJConsole, so that it can be QI'd to be an nsIJVMConsole.
|
||||
* To save code size, we use the SupportsMixin class instead of the macros in
|
||||
* nsAgg.h. SupportsMixin::queryInterface, addRef, and release are all local
|
||||
* operations, regardless of aggregation. The capitalized versions take aggregation
|
||||
* into account.
|
||||
*/
|
||||
NS_METHOD MRJPlugin::QueryInterface(const nsIID& aIID, void** instancePtr)
|
||||
{
|
||||
nsresult result = queryInterface(aIID, instancePtr);
|
||||
if (result == NS_NOINTERFACE) {
|
||||
result = mConsole->queryInterface(aIID, instancePtr);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_METHOD MRJPlugin::CreateInstance(nsISupports *aOuter, const nsIID& aIID, void **aResult)
|
||||
{
|
||||
nsresult result = StartupJVM();
|
||||
if (result == NS_OK) {
|
||||
MRJPluginInstance* instance = new MRJPluginInstance(this);
|
||||
if (instance == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
result = instance->QueryInterface(aIID, aResult);
|
||||
if (result != NS_OK)
|
||||
delete instance;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#define NS_APPLET_MIME_TYPE "application/x-java-applet"
|
||||
|
||||
NS_METHOD MRJPlugin::CreatePluginInstance(nsISupports *aOuter, REFNSIID aIID, const char* aPluginMIMEType, void **aResult)
|
||||
{
|
||||
nsresult result = NS_NOINTERFACE;
|
||||
|
||||
if (::strcmp(aPluginMIMEType, "application/x-java-frame") == 0) {
|
||||
// create a special plugin instance that manages an embedded frame.
|
||||
EmbeddedFramePluginInstance* instance = new EmbeddedFramePluginInstance();
|
||||
nsresult result = instance->QueryInterface(aIID, aResult);
|
||||
if (result != NS_OK)
|
||||
delete instance;
|
||||
} else {
|
||||
// assume it's some kind of an applet.
|
||||
result = CreateInstance(aOuter, aIID, aResult);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_METHOD MRJPlugin::Initialize()
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
// try to get a plugin manager.
|
||||
if (thePluginManager == NULL) {
|
||||
result = MRJPlugin::GetService(kPluginManagerCID, NS_GET_IID(nsIPluginManager), (void**)&thePluginManager);
|
||||
if (result != NS_OK || thePluginManager == NULL)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// see if the enhanced plugin manager exists.
|
||||
if (thePluginManager2 == NULL) {
|
||||
if (thePluginManager->QueryInterface(NS_GET_IID(nsIPluginManager2), (void**)&thePluginManager2) != NS_OK)
|
||||
thePluginManager2 = NULL;
|
||||
}
|
||||
|
||||
// try to get a JVM manager. we have to be able to run without one.
|
||||
if (MRJPlugin::GetService(kJVMManagerCID, NS_GET_IID(nsIJVMManager), (void**)&mManager) != NS_OK)
|
||||
mManager = NULL;
|
||||
|
||||
// try to get a Thread manager.
|
||||
if (mManager != NULL) {
|
||||
if (mManager->QueryInterface(NS_GET_IID(nsIThreadManager), (void**)&mThreadManager) != NS_OK)
|
||||
mThreadManager = NULL;
|
||||
|
||||
if (mThreadManager != NULL)
|
||||
mThreadManager->GetCurrentThread(&mPluginThreadID);
|
||||
}
|
||||
|
||||
// create a console, only if there's user interface for it.
|
||||
if (thePluginManager2 != NULL) {
|
||||
mConsole = new MRJConsole(this);
|
||||
mConsole->AddRef();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_METHOD MRJPlugin::Shutdown()
|
||||
{
|
||||
// shutdown LiveConnect.
|
||||
ShutdownLiveConnectSupport();
|
||||
|
||||
// release our reference to the plugin manager(s).
|
||||
NS_IF_RELEASE(thePluginManager2);
|
||||
NS_IF_RELEASE(thePluginManager);
|
||||
|
||||
// release our reference to the service manager.
|
||||
NS_IF_RELEASE(theServiceManager);
|
||||
NS_IF_RELEASE(theServiceManagerObsolete);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD MRJPlugin::GetMIMEDescription(const char* *result)
|
||||
{
|
||||
*result = NS_JVM_MIME_TYPE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD MRJPlugin::GetValue(nsPluginVariable variable, void *value)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_METHOD MRJPlugin::SetValue(nsPluginVariable variable, void *value)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
MRJSession* MRJPlugin::getSession()
|
||||
{
|
||||
StartupJVM();
|
||||
return mSession;
|
||||
}
|
||||
|
||||
nsIJVMManager* MRJPlugin::getManager()
|
||||
{
|
||||
return mManager;
|
||||
}
|
||||
|
||||
nsIThreadManager* MRJPlugin::getThreadManager()
|
||||
{
|
||||
return mThreadManager;
|
||||
}
|
||||
|
||||
NS_METHOD MRJPlugin::StartupJVM()
|
||||
{
|
||||
if (mSession == NULL) {
|
||||
// start a session with MRJ.
|
||||
mSession = new MRJSession();
|
||||
if (mSession->getStatus() != noErr) {
|
||||
// how can we signal an error?
|
||||
delete mSession;
|
||||
mSession = NULL;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
#if 0
|
||||
// Apply the initialization args.
|
||||
if (initArgs != NULL && initArgs->version >= nsJVMInitArgs_Version) {
|
||||
const char* classPathAdditions = initArgs->classpathAdditions;
|
||||
if (classPathAdditions != NULL) {
|
||||
// what format will this be in? UNIX paths, separated by ':' characters.
|
||||
char* paths = new char[1 + strlen(classPathAdditions)];
|
||||
if (paths != NULL) {
|
||||
strcpy(paths, classPathAdditions);
|
||||
char* path = strtok(paths, ":");
|
||||
while (path != NULL) {
|
||||
static char urlPrefix[] = { "file://" };
|
||||
char* fileURL = new char[sizeof(urlPrefix) + strlen(path)];
|
||||
if (fileURL != NULL) {
|
||||
strcat(strcpy(fileURL, urlPrefix), path);
|
||||
mSession->addURLToClassPath(fileURL);
|
||||
delete[] fileURL;
|
||||
}
|
||||
path = strtok(NULL, ":");
|
||||
}
|
||||
delete[] paths;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Add "MRJPlugin.jar" to the class path.
|
||||
FSSpec jarFileSpec = { thePluginSpec.vRefNum, thePluginSpec.parID, "\pMRJPlugin.jar" };
|
||||
mSession->addToClassPath(jarFileSpec);
|
||||
|
||||
InitLiveConnectSupport(this);
|
||||
|
||||
#if 0
|
||||
// start our idle thread.
|
||||
if (mThreadManager != NULL) {
|
||||
PRUint32 threadID;
|
||||
mThreadManager->CreateThread(&threadID, this);
|
||||
}
|
||||
#endif
|
||||
|
||||
mIsEnabled = true;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD MRJPlugin::ShutdownJVM(PRBool fullShutdown)
|
||||
{
|
||||
if (fullShutdown) {
|
||||
nsresult rv = ShutdownLiveConnectSupport();
|
||||
|
||||
if (mSession != NULL) {
|
||||
delete mSession;
|
||||
mSession = NULL;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD MRJPlugin::AddToClassPath(const char* dirPath)
|
||||
{
|
||||
if (mSession != NULL) {
|
||||
mSession->addToClassPath(dirPath);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_METHOD MRJPlugin::GetClassPath(const char* *result)
|
||||
{
|
||||
char* classPath = mSession->getProperty("java.class.path");
|
||||
*result = classPath;
|
||||
return (classPath != NULL ? NS_OK : NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
NS_METHOD MRJPlugin::GetJavaWrapper(JNIEnv* env, jint jsobj, jobject *jobj)
|
||||
{
|
||||
// use jsobj as key into a table.
|
||||
// if not in the table, then create a new netscape.javascript.JSObject that references this.
|
||||
*jobj = Wrap_JSObject(env, jsobj);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD MRJPlugin::UnwrapJavaWrapper(JNIEnv* jenv, jobject jobj, jint* obj)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_METHOD MRJPlugin::GetJavaVM(JavaVM* *result)
|
||||
{
|
||||
*result = NULL;
|
||||
if (StartupJVM() == NS_OK) {
|
||||
*result = mSession->getJavaVM();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsrefcnt MRJPlugin::GetJNIEnv(JNIEnv* *result)
|
||||
{
|
||||
JNIEnv* env = NULL;
|
||||
if (StartupJVM() == NS_OK) {
|
||||
#if 1
|
||||
env = mSession->getCurrentEnv();
|
||||
#else
|
||||
JDK1_1AttachArgs args;
|
||||
JavaVM* vm = mSession->getJavaVM();
|
||||
jint result = vm->AttachCurrentThread(&env, &args);
|
||||
if (result != 0)
|
||||
env = NULL;
|
||||
#endif
|
||||
}
|
||||
*result = env;
|
||||
return 1;
|
||||
}
|
||||
|
||||
nsrefcnt MRJPlugin::ReleaseJNIEnv(JNIEnv* env)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
NS_METHOD MRJPlugin::CreateSecureEnv(JNIEnv* proxyEnv, nsISecureEnv* *outSecureEnv)
|
||||
{
|
||||
*outSecureEnv = NULL;
|
||||
nsresult rv = StartupJVM();
|
||||
if (rv == NS_OK) {
|
||||
// Need to spawn a new JVM communication thread here.
|
||||
NS_DEFINE_IID(kISecureEnvIID, NS_ISECUREENV_IID);
|
||||
rv = CSecureEnv::Create(this, proxyEnv, kISecureEnvIID, (void**)outSecureEnv);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_METHOD MRJPlugin::SpendTime(PRUint32 timeMillis)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
// Only do this if there aren't any plugin instances.
|
||||
if (MRJPluginInstance::getInstances() == NULL) {
|
||||
if (mSession == NULL)
|
||||
result = StartupJVM();
|
||||
if (mSession != NULL)
|
||||
mSession->idle(timeMillis);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_METHOD MRJPlugin::Run()
|
||||
{
|
||||
while (mSession != NULL) {
|
||||
mSession->idle();
|
||||
mThreadManager->Sleep();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
MRJPluginInstance* MRJPlugin::getPluginInstance(jobject applet)
|
||||
{
|
||||
JNIEnv* env = mSession->getCurrentEnv();
|
||||
MRJPluginInstance* instance = MRJPluginInstance::getInstances();
|
||||
while (instance != NULL) {
|
||||
jobject object = NULL;
|
||||
if (instance->GetJavaObject(&object) == NS_OK && env->IsSameObject(applet, object)) {
|
||||
instance->AddRef();
|
||||
return instance;
|
||||
}
|
||||
instance = instance->getNextInstance();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
MRJPluginInstance* MRJPlugin::getPluginInstance(JNIEnv* jenv)
|
||||
{
|
||||
// Apple will provide an API that maps a JNIEnv to an JMAWTContextRef. We can map this to the MRJContext/Applet/Instance.
|
||||
MRJPluginInstance* instance = MRJPluginInstance::getInstances();
|
||||
if (&::JMJNIToAWTContext != NULL) {
|
||||
JMAWTContextRef contextRef = ::JMJNIToAWTContext(mSession->getSessionRef(), jenv);
|
||||
if (contextRef != NULL) {
|
||||
while (instance != NULL) {
|
||||
if (instance->getContext()->getContextRef() == contextRef) {
|
||||
instance->AddRef();
|
||||
return instance;
|
||||
}
|
||||
instance = instance->getNextInstance();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (instance != NULL) {
|
||||
instance->AddRef();
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Boolean MRJPlugin::inPluginThread()
|
||||
{
|
||||
Boolean result = false;
|
||||
nsPluginThread *currentThreadID = NULL;
|
||||
|
||||
if (mThreadManager != NULL)
|
||||
mThreadManager->GetCurrentThread(¤tThreadID);
|
||||
if ((NULL != currentThreadID) && (NULL != mPluginThreadID)) {
|
||||
if (currentThreadID == mPluginThreadID) {
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#pragma mark *** MRJPluginInstance ***
|
||||
|
||||
const InterfaceInfo MRJPluginInstance::sInterfaces[] = {
|
||||
{ NS_IPLUGININSTANCE_IID, INTERFACE_OFFSET(MRJPluginInstance, nsIPluginInstance) },
|
||||
{ NS_IJVMPLUGININSTANCE_IID, INTERFACE_OFFSET(MRJPluginInstance, nsIJVMPluginInstance) },
|
||||
{ NS_IEVENTHANDLER_IID, INTERFACE_OFFSET(MRJPluginInstance, nsIEventHandler) },
|
||||
};
|
||||
const UInt32 MRJPluginInstance::kInterfaceCount = sizeof(sInterfaces) / sizeof(InterfaceInfo);
|
||||
|
||||
MRJPluginInstance::MRJPluginInstance(MRJPlugin* plugin)
|
||||
: SupportsMixin(this, sInterfaces, kInterfaceCount),
|
||||
mPeer(NULL), mWindowlessPeer(NULL),
|
||||
mPlugin(plugin), mSession(plugin->getSession()),
|
||||
mContext(NULL), mApplet(NULL), mPluginWindow(NULL),
|
||||
mNext(NULL)
|
||||
{
|
||||
// add this instance to the instance list.
|
||||
pushInstance();
|
||||
|
||||
// Tell the plugin we are retaining a reference.
|
||||
mPlugin->AddRef();
|
||||
}
|
||||
|
||||
MRJPluginInstance::~MRJPluginInstance()
|
||||
{
|
||||
// Remove this instance from the global list.
|
||||
popInstance();
|
||||
|
||||
#if 0
|
||||
if (mContext != NULL) {
|
||||
delete mContext;
|
||||
mContext = NULL;
|
||||
}
|
||||
|
||||
if (mPlugin != NULL) {
|
||||
mPlugin->Release();
|
||||
mPlugin = NULL;
|
||||
}
|
||||
|
||||
if (mWindowlessPeer != NULL) {
|
||||
mWindowlessPeer->Release();
|
||||
mWindowlessPeer = NULL;
|
||||
}
|
||||
|
||||
if (mPeer != NULL) {
|
||||
mPeer->Release();
|
||||
mPeer = NULL;
|
||||
}
|
||||
|
||||
if (mApplet != NULL) {
|
||||
JNIEnv* env = mSession->getCurrentEnv();
|
||||
env->DeleteGlobalRef(mApplet);
|
||||
mApplet = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static const char* kGetCodeBaseScriptURL = "javascript:var href = window.location.href; href.substring(0, href.lastIndexOf('/') + 1)";
|
||||
static const char* kGetDocumentBaseScriptURL = "javascript:window.location";
|
||||
|
||||
static bool hasTagInfo(nsISupports* supports)
|
||||
{
|
||||
nsIJVMPluginTagInfo* tagInfo;
|
||||
if (supports->QueryInterface(NS_GET_IID(nsIJVMPluginTagInfo), (void **)&tagInfo) == NS_OK) {
|
||||
NS_RELEASE(tagInfo);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
NS_METHOD MRJPluginInstance::Initialize(nsIPluginInstancePeer* peer)
|
||||
{
|
||||
// Tell the peer we are retaining a reference.
|
||||
mPeer = peer;
|
||||
mPeer->AddRef();
|
||||
|
||||
// See if we have a windowless peer.
|
||||
nsresult result = mPeer->QueryInterface(kIWindowlessPluginInstancePeerIID, (void **)&mWindowlessPeer);
|
||||
if (result != NS_OK) mWindowlessPeer = NULL;
|
||||
|
||||
// create a context for the applet we will run.
|
||||
mContext = new MRJContext(mSession, this);
|
||||
|
||||
if (hasTagInfo(mPeer)) {
|
||||
mContext->processAppletTag();
|
||||
mContext->createContext();
|
||||
} else {
|
||||
// we'll be using JavaScript to create windows.
|
||||
// fire up a JavaScript URL to get the current document's location.
|
||||
nsIPluginInstance* pluginInstance = this;
|
||||
nsIPluginStreamListener* listener = this;
|
||||
result = thePluginManager->GetURL(pluginInstance, kGetDocumentBaseScriptURL, NULL, listener);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD MRJPluginInstance::OnDataAvailable(nsIPluginStreamInfo* pluginInfo, nsIInputStream* input, PRUint32 length)
|
||||
{
|
||||
// hopefully all our data is available.
|
||||
char* documentBase = new char[length + 1];
|
||||
if (documentBase != NULL) {
|
||||
if (input->Read(documentBase, length, &length) == NS_OK) {
|
||||
// We've delayed processing the applet tag, because we
|
||||
// don't know the location of the current document yet.
|
||||
documentBase[length] = '\0';
|
||||
|
||||
// set up the default document location, which can be used to compute relative CODEBASE, etc.
|
||||
mContext->setDocumentBase(documentBase);
|
||||
delete[] documentBase;
|
||||
|
||||
mContext->processAppletTag();
|
||||
mContext->createContext();
|
||||
|
||||
// SetWindow may be called at an inopportune time.
|
||||
if (mPluginWindow != NULL)
|
||||
mContext->setWindow(mPluginWindow);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD MRJPluginInstance::GetPeer(nsIPluginInstancePeer* *result)
|
||||
{
|
||||
mPeer->AddRef();
|
||||
*result = mPeer;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD MRJPluginInstance::Start()
|
||||
{
|
||||
// Take this moment to show the applet's frames (if any).
|
||||
mContext->showFrames();
|
||||
|
||||
mContext->resumeApplet();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD MRJPluginInstance::Stop()
|
||||
{
|
||||
// Take this moment to hide the applet's frames.
|
||||
mContext->hideFrames();
|
||||
|
||||
mContext->suspendApplet();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD MRJPluginInstance::Destroy()
|
||||
{
|
||||
// Use this opportunity to break any cycles that might exist, and reduce
|
||||
// reference counts to their minimum values.
|
||||
if (mContext != NULL) {
|
||||
delete mContext;
|
||||
mContext = NULL;
|
||||
}
|
||||
|
||||
if (mPlugin != NULL) {
|
||||
mPlugin->Release();
|
||||
mPlugin = NULL;
|
||||
}
|
||||
|
||||
if (mWindowlessPeer != NULL) {
|
||||
mWindowlessPeer->Release();
|
||||
mWindowlessPeer = NULL;
|
||||
}
|
||||
|
||||
if (mPeer != NULL) {
|
||||
mPeer->Release();
|
||||
mPeer = NULL;
|
||||
}
|
||||
|
||||
if (mApplet != NULL) {
|
||||
JNIEnv* env = mSession->getCurrentEnv();
|
||||
env->DeleteGlobalRef(mApplet);
|
||||
mApplet = NULL;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/** FIXME: Need an intelligent way to track changes to the NPPluginWindow. */
|
||||
|
||||
NS_METHOD MRJPluginInstance::SetWindow(nsPluginWindow* pluginWindow)
|
||||
{
|
||||
mPluginWindow = pluginWindow;
|
||||
|
||||
mContext->setWindow(pluginWindow);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD MRJPluginInstance::HandleEvent(nsPluginEvent* pluginEvent, PRBool* eventHandled)
|
||||
{
|
||||
*eventHandled = PR_TRUE;
|
||||
Boolean isUpdate;
|
||||
|
||||
if (pluginEvent != NULL) {
|
||||
EventRecord* event = pluginEvent->event;
|
||||
|
||||
#if 0
|
||||
// Check for clipping changes.
|
||||
if (event->what == nsPluginEventType_ClippingChangedEvent) {
|
||||
mContext->setClipping(RgnHandle(event->message));
|
||||
return NS_OK;
|
||||
}
|
||||
#else
|
||||
// Check for coordinate/clipping changes.
|
||||
isUpdate = (event->what == updateEvt);
|
||||
inspectInstance(isUpdate);
|
||||
#endif
|
||||
|
||||
if (event->what == nullEvent) {
|
||||
// Give MRJ another quantum of time.
|
||||
mSession->idle(kDefaultJMTime); // now SpendTime does this.
|
||||
|
||||
#if 0
|
||||
// check for pending update events.
|
||||
if (CheckUpdate(event)) {
|
||||
MRJFrame* frame = mContext->findFrame(WindowRef(event->message));
|
||||
if (frame != NULL)
|
||||
frame->update();
|
||||
}
|
||||
#endif
|
||||
|
||||
} else {
|
||||
MRJFrame* frame = mContext->findFrame(WindowRef(pluginEvent->window));
|
||||
if (frame != NULL) {
|
||||
switch (event->what) {
|
||||
case nsPluginEventType_GetFocusEvent:
|
||||
frame->focusEvent(true);
|
||||
break;
|
||||
|
||||
case nsPluginEventType_LoseFocusEvent:
|
||||
frame->focusEvent(false);
|
||||
break;
|
||||
|
||||
case nsPluginEventType_AdjustCursorEvent:
|
||||
frame->idle(event->modifiers);
|
||||
break;
|
||||
|
||||
case nsPluginEventType_MenuCommandEvent:
|
||||
frame->menuSelected(event->message, event->modifiers);
|
||||
break;
|
||||
|
||||
default:
|
||||
*eventHandled = frame->handleEvent(event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD MRJPluginInstance::Print(nsPluginPrint* platformPrint)
|
||||
{
|
||||
if (platformPrint->mode == nsPluginMode_Embedded) {
|
||||
mContext->printApplet(&platformPrint->print.embedPrint.window);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_METHOD MRJPluginInstance::GetValue(nsPluginInstanceVariable variable, void *value)
|
||||
{
|
||||
switch (variable) {
|
||||
case nsPluginInstanceVariable_WindowlessBool:
|
||||
*(PRBool*)value = PR_FALSE;
|
||||
break;
|
||||
case nsPluginInstanceVariable_TransparentBool:
|
||||
*(PRBool*)value = PR_FALSE;
|
||||
break;
|
||||
case nsPluginInstanceVariable_DoCacheBool:
|
||||
*(PRBool*)value = PR_FALSE;
|
||||
break;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD MRJPluginInstance::GetJavaObject(jobject *result)
|
||||
{
|
||||
if (mApplet == NULL) {
|
||||
jobject applet = mContext->getApplet();
|
||||
JNIEnv* env = mSession->getCurrentEnv();
|
||||
mApplet = env->NewGlobalRef(applet);
|
||||
}
|
||||
*result = mApplet;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Accessing the list of instances.
|
||||
|
||||
static MRJPluginInstance* theInstances = NULL;
|
||||
|
||||
void MRJPluginInstance::pushInstance()
|
||||
{
|
||||
mNext = theInstances;
|
||||
theInstances = this;
|
||||
}
|
||||
|
||||
void MRJPluginInstance::popInstance()
|
||||
{
|
||||
MRJPluginInstance** link = &theInstances;
|
||||
MRJPluginInstance* instance = *link;
|
||||
while (instance != NULL) {
|
||||
if (instance == this) {
|
||||
*link = mNext;
|
||||
mNext = NULL;
|
||||
break;
|
||||
}
|
||||
link = &instance->mNext;
|
||||
instance = *link;
|
||||
}
|
||||
}
|
||||
|
||||
MRJPluginInstance* MRJPluginInstance::getInstances()
|
||||
{
|
||||
return theInstances;
|
||||
}
|
||||
|
||||
MRJPluginInstance* MRJPluginInstance::getNextInstance()
|
||||
{
|
||||
return mNext;
|
||||
}
|
||||
|
||||
MRJContext* MRJPluginInstance::getContext()
|
||||
{
|
||||
return mContext;
|
||||
}
|
||||
|
||||
MRJSession* MRJPluginInstance::getSession()
|
||||
{
|
||||
return mSession;
|
||||
}
|
||||
|
||||
void MRJPluginInstance::inspectInstance(Boolean isUpdateEvt)
|
||||
{
|
||||
if (mContext != NULL && mContext->inspectWindow() && !isUpdateEvt && mWindowlessPeer != NULL)
|
||||
mWindowlessPeer->ForceRedraw();
|
||||
}
|
|
@ -1,491 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
MRJPlugin.h
|
||||
|
||||
MRJPlugin encapsulates the global state of the MRJ plugin as a single COM object.
|
||||
MRJPluginInstance represents an instance of the MRJ plugin.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "nsIPlugin.h"
|
||||
#include "nsIJVMPlugin.h"
|
||||
#include "nsIThreadManager.h"
|
||||
#include "nsIPluginInstance.h"
|
||||
#include "nsIJVMPluginInstance.h"
|
||||
#include "nsIEventHandler.h"
|
||||
#include "nsIPluginStreamListener.h"
|
||||
#include "SupportsMixin.h"
|
||||
|
||||
class MRJPlugin;
|
||||
class MRJPluginInstance;
|
||||
class MRJSession;
|
||||
class MRJContext;
|
||||
class MRJConsole;
|
||||
|
||||
class nsIJVMManager;
|
||||
|
||||
class MRJPlugin : public nsIPlugin, public nsIJVMPlugin,
|
||||
public nsIRunnable, public SupportsMixin {
|
||||
public:
|
||||
MRJPlugin();
|
||||
virtual ~MRJPlugin();
|
||||
|
||||
static nsresult GetService(const nsCID &aCID, const nsIID& aIID, void* *aService);
|
||||
static nsresult GetService(const char* aContractID, const nsIID& aIID, void* *aService);
|
||||
|
||||
static const char* PLUGIN_VERSION;
|
||||
|
||||
// Currently, this is a singleton, statically allocated object.
|
||||
void operator delete(void* ptr) {}
|
||||
|
||||
// NS_DECL_ISUPPORTS
|
||||
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void) { return addRef(); }
|
||||
NS_IMETHOD_(nsrefcnt) Release(void) { return release(); }
|
||||
|
||||
// The Release method on NPIPlugin corresponds to NPP_Shutdown.
|
||||
|
||||
// The old NPP_New call has been factored into two plugin instance methods:
|
||||
//
|
||||
// NewInstance -- called once, after the plugin instance is created. This
|
||||
// method is used to initialize the new plugin instance (although the actual
|
||||
// plugin instance object will be created by the plugin manager).
|
||||
//
|
||||
// NPIPluginInstance::Start -- called when the plugin instance is to be
|
||||
// started. This happens in two circumstances: (1) after the plugin instance
|
||||
// is first initialized, and (2) after a plugin instance is returned to
|
||||
// (e.g. by going back in the window history) after previously being stopped
|
||||
// by the Stop method.
|
||||
|
||||
// nsIFactory Methods.
|
||||
|
||||
NS_IMETHOD
|
||||
CreateInstance(nsISupports *aOuter, const nsIID& aIID, void **aResult);
|
||||
|
||||
NS_IMETHOD
|
||||
LockFactory(PRBool aLock) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
|
||||
// nsIPlugin Methods.
|
||||
|
||||
/**
|
||||
* Creates a new plugin instance, based on the MIME type. This
|
||||
* allows different impelementations to be created depending on
|
||||
* the specified MIME type.
|
||||
*/
|
||||
NS_IMETHOD CreatePluginInstance(nsISupports *aOuter, REFNSIID aIID,
|
||||
const char* aPluginMIMEType,
|
||||
void **aResult);
|
||||
|
||||
/**
|
||||
* Initializes the plugin and will be called before any new instances are
|
||||
* created. This separates out the phase when a plugin is loaded just to
|
||||
* query for its mime type from the phase when a plugin is used for real.
|
||||
* The plugin should load up any resources at this point.
|
||||
* @result - NS_OK if this operation was successful
|
||||
*/
|
||||
NS_IMETHOD
|
||||
Initialize(void);
|
||||
|
||||
/**
|
||||
* Called when the browser is done with the plugin factory, or when
|
||||
* the plugin is disabled by the user.
|
||||
*
|
||||
* (Corresponds to NPP_Shutdown.)
|
||||
*
|
||||
* @result - NS_OK if this operation was successful
|
||||
*/
|
||||
NS_IMETHOD
|
||||
Shutdown(void);
|
||||
|
||||
/**
|
||||
* Returns the MIME description for the plugin. The MIME description
|
||||
* is a colon-separated string containg the plugin MIME type, plugin
|
||||
* data file extension, and plugin name, e.g.:
|
||||
*
|
||||
* "application/x-simple-plugin:smp:Simple LiveConnect Sample Plug-in"
|
||||
*
|
||||
* (Corresponds to NPP_GetMIMEDescription.)
|
||||
*
|
||||
* @param resultingDesc - the resulting MIME description
|
||||
* @result - NS_OK if this operation was successful
|
||||
*/
|
||||
NS_IMETHOD
|
||||
GetMIMEDescription(const char* *result);
|
||||
|
||||
/**
|
||||
* Returns the value of a variable associated with the plugin.
|
||||
*
|
||||
* (Corresponds to NPP_GetValue.)
|
||||
*
|
||||
* @param variable - the plugin variable to get
|
||||
* @param value - the address of where to store the resulting value
|
||||
* @result - NS_OK if this operation was successful
|
||||
*/
|
||||
NS_IMETHOD
|
||||
GetValue(nsPluginVariable variable, void *value);
|
||||
|
||||
// (Corresponds to NPP_SetValue.)
|
||||
NS_IMETHOD
|
||||
SetValue(nsPluginVariable variable, void *value);
|
||||
|
||||
// JVM Plugin Methods.
|
||||
|
||||
// This method us used to start the Java virtual machine.
|
||||
// It sets up any global state necessary to host Java programs.
|
||||
// Note that calling this method is distinctly separate from
|
||||
// initializing the nsIJVMPlugin object (done by the Initialize
|
||||
// method).
|
||||
NS_IMETHOD
|
||||
StartupJVM(void);
|
||||
|
||||
// This method us used to stop the Java virtual machine.
|
||||
// It tears down any global state necessary to host Java programs.
|
||||
// The fullShutdown flag specifies whether the browser is quitting
|
||||
// (PR_TRUE) or simply whether the JVM is being shut down (PR_FALSE).
|
||||
NS_IMETHOD
|
||||
ShutdownJVM(PRBool fullShutdown);
|
||||
|
||||
// Causes the JVM to append a new directory to its classpath.
|
||||
// If the JVM doesn't support this operation, an error is returned.
|
||||
NS_IMETHOD
|
||||
AddToClassPath(const char* dirPath);
|
||||
|
||||
// Causes the JVM to remove a directory from its classpath.
|
||||
// If the JVM doesn't support this operation, an error is returned.
|
||||
NS_IMETHOD
|
||||
RemoveFromClassPath(const char* dirPath)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
// Returns the current classpath in use by the JVM.
|
||||
NS_IMETHOD
|
||||
GetClassPath(const char* *result);
|
||||
|
||||
NS_IMETHOD
|
||||
GetJavaWrapper(JNIEnv* env, jint jsobj, jobject *jobj);
|
||||
|
||||
NS_IMETHOD
|
||||
GetJavaVM(JavaVM* *result);
|
||||
|
||||
// nsIJNIPlugin Methods.
|
||||
|
||||
// Find or create a JNIEnv for the current thread.
|
||||
// Returns NULL if an error occurs.
|
||||
NS_IMETHOD_(nsrefcnt)
|
||||
GetJNIEnv(JNIEnv* *result);
|
||||
|
||||
// This method must be called when the caller is done using the JNIEnv.
|
||||
// This decrements a refcount associated with it may free it.
|
||||
NS_IMETHOD_(nsrefcnt)
|
||||
ReleaseJNIEnv(JNIEnv* env);
|
||||
|
||||
/**
|
||||
* This creates a new secure communication channel with Java. The second parameter,
|
||||
* nativeEnv, if non-NULL, will be the actual thread for Java communication.
|
||||
* Otherwise, a new thread should be created.
|
||||
* @param proxyEnv the env to be used by all clients on the browser side
|
||||
* @return outSecureEnv the secure environment used by the proxyEnv
|
||||
*/
|
||||
NS_IMETHOD
|
||||
CreateSecureEnv(JNIEnv* proxyEnv, nsISecureEnv* *outSecureEnv);
|
||||
|
||||
/**
|
||||
* Gives time to the JVM from the main event loop of the browser. This is
|
||||
* necessary when there aren't any plugin instances around, but Java threads exist.
|
||||
*/
|
||||
NS_IMETHOD
|
||||
SpendTime(PRUint32 timeMillis);
|
||||
|
||||
/**
|
||||
* The Run method gives time to the JVM periodically. This makes SpendTIme() obsolete.
|
||||
*/
|
||||
NS_IMETHOD
|
||||
Run();
|
||||
|
||||
// NON-INTERFACE methods, for internal use only.
|
||||
|
||||
MRJSession* getSession();
|
||||
nsIJVMManager* getManager();
|
||||
nsIThreadManager* getThreadManager();
|
||||
|
||||
MRJPluginInstance* getPluginInstance(jobject applet);
|
||||
MRJPluginInstance* getPluginInstance(JNIEnv* jenv);
|
||||
|
||||
Boolean inPluginThread();
|
||||
|
||||
NS_IMETHOD
|
||||
UnwrapJavaWrapper(JNIEnv* jenv, jobject jobj, jint* obj);
|
||||
|
||||
private:
|
||||
nsIJVMManager* mManager;
|
||||
nsIThreadManager* mThreadManager;
|
||||
MRJSession* mSession;
|
||||
MRJConsole* mConsole;
|
||||
nsPluginThread *mPluginThreadID;
|
||||
Boolean mIsEnabled;
|
||||
|
||||
// support for SupportsMixin.
|
||||
static const InterfaceInfo sInterfaces[];
|
||||
static const UInt32 kInterfaceCount;
|
||||
};
|
||||
|
||||
class MRJPluginInstance : public nsIPluginInstance, public nsIJVMPluginInstance,
|
||||
public nsIEventHandler, public nsIPluginStreamListener,
|
||||
private SupportsMixin {
|
||||
public:
|
||||
MRJPluginInstance(MRJPlugin* plugin);
|
||||
virtual ~MRJPluginInstance();
|
||||
|
||||
// NS_DECL_ISUPPORTS
|
||||
DECL_SUPPORTS_MIXIN
|
||||
|
||||
// (Corresponds to NPP_HandleEvent.)
|
||||
NS_IMETHOD
|
||||
HandleEvent(nsPluginEvent* event, PRBool* handled);
|
||||
|
||||
/**
|
||||
* Initializes a newly created plugin instance, passing to it the plugin
|
||||
* instance peer which it should use for all communication back to the browser.
|
||||
*
|
||||
* @param peer - the corresponding plugin instance peer
|
||||
* @result - NS_OK if this operation was successful
|
||||
*/
|
||||
NS_IMETHOD
|
||||
Initialize(nsIPluginInstancePeer* peer);
|
||||
|
||||
/**
|
||||
* Returns a reference back to the plugin instance peer. This method is
|
||||
* used whenever the browser needs to obtain the peer back from a plugin
|
||||
* instance. The implementation of this method should be sure to increment
|
||||
* the reference count on the peer by calling AddRef.
|
||||
*
|
||||
* @param resultingPeer - the resulting plugin instance peer
|
||||
* @result - NS_OK if this operation was successful
|
||||
*/
|
||||
NS_IMETHOD
|
||||
GetPeer(nsIPluginInstancePeer* *result);
|
||||
|
||||
/**
|
||||
* Called to instruct the plugin instance to start. This will be called after
|
||||
* the plugin is first created and initialized, and may be called after the
|
||||
* plugin is stopped (via the Stop method) if the plugin instance is returned
|
||||
* to in the browser window's history.
|
||||
*
|
||||
* @result - NS_OK if this operation was successful
|
||||
*/
|
||||
NS_IMETHOD
|
||||
Start(void);
|
||||
|
||||
/**
|
||||
* Called to instruct the plugin instance to stop, thereby suspending its state.
|
||||
* This method will be called whenever the browser window goes on to display
|
||||
* another page and the page containing the plugin goes into the window's history
|
||||
* list.
|
||||
*
|
||||
* @result - NS_OK if this operation was successful
|
||||
*/
|
||||
NS_IMETHOD
|
||||
Stop(void);
|
||||
|
||||
/**
|
||||
* Called to instruct the plugin instance to destroy itself. This is called when
|
||||
* it become no longer possible to return to the plugin instance, either because
|
||||
* the browser window's history list of pages is being trimmed, or because the
|
||||
* window containing this page in the history is being closed.
|
||||
*
|
||||
* @result - NS_OK if this operation was successful
|
||||
*/
|
||||
NS_IMETHOD
|
||||
Destroy(void);
|
||||
|
||||
/**
|
||||
* Called when the window containing the plugin instance changes.
|
||||
*
|
||||
* (Corresponds to NPP_SetWindow.)
|
||||
*
|
||||
* @param window - the plugin window structure
|
||||
* @result - NS_OK if this operation was successful
|
||||
*/
|
||||
NS_IMETHOD
|
||||
SetWindow(nsPluginWindow* window);
|
||||
|
||||
/**
|
||||
* Called to tell the plugin that the initial src/data stream is
|
||||
* ready. Expects the plugin to return a nsIPluginStreamListener.
|
||||
*
|
||||
* (Corresponds to NPP_NewStream.)
|
||||
*
|
||||
* @param listener - listener the browser will use to give the plugin the data
|
||||
* @result - NS_OK if this operation was successful
|
||||
*/
|
||||
NS_IMETHOD
|
||||
NewStream(nsIPluginStreamListener** listener)
|
||||
{
|
||||
*listener = this;
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to instruct the plugin instance to print itself to a printer.
|
||||
*
|
||||
* (Corresponds to NPP_Print.)
|
||||
*
|
||||
* @param platformPrint - platform-specific printing information
|
||||
* @result - NS_OK if this operation was successful
|
||||
*/
|
||||
NS_IMETHOD
|
||||
Print(nsPluginPrint* platformPrint);
|
||||
|
||||
/**
|
||||
* Returns the value of a variable associated with the plugin instance.
|
||||
*
|
||||
* @param variable - the plugin instance variable to get
|
||||
* @param value - the address of where to store the resulting value
|
||||
* @result - NS_OK if this operation was successful
|
||||
*/
|
||||
NS_IMETHOD
|
||||
GetValue(nsPluginInstanceVariable variable, void *value);
|
||||
|
||||
// nsIJVMPluginInstance methods.
|
||||
|
||||
// This method is called when LiveConnect wants to find the Java object
|
||||
// associated with this plugin instance, e.g. the Applet or JavaBean object.
|
||||
NS_IMETHOD
|
||||
GetJavaObject(jobject *result);
|
||||
|
||||
NS_IMETHOD
|
||||
GetText(const char* *result)
|
||||
{
|
||||
*result = NULL;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIPluginStreamListener implementation.
|
||||
|
||||
/**
|
||||
* Notify the observer that the URL has started to load. This method is
|
||||
* called only once, at the beginning of a URL load.<BR><BR>
|
||||
*
|
||||
* @return The return value is currently ignored. In the future it may be
|
||||
* used to cancel the URL load..
|
||||
*/
|
||||
NS_IMETHOD
|
||||
OnStartBinding(nsIPluginStreamInfo* pluginInfo)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify the client that data is available in the input stream. This
|
||||
* method is called whenver data is written into the input stream by the
|
||||
* networking library...<BR><BR>
|
||||
*
|
||||
* @param aIStream The input stream containing the data. This stream can
|
||||
* be either a blocking or non-blocking stream.
|
||||
* @param length The amount of data that was just pushed into the stream.
|
||||
* @return The return value is currently ignored.
|
||||
*/
|
||||
NS_IMETHOD
|
||||
OnDataAvailable(nsIPluginStreamInfo* pluginInfo, nsIInputStream* input, PRUint32 length);
|
||||
|
||||
NS_IMETHOD
|
||||
OnFileAvailable(nsIPluginStreamInfo* pluginInfo, const char* fileName)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify the observer that the URL has finished loading. This method is
|
||||
* called once when the networking library has finished processing the
|
||||
* URL transaction initiatied via the nsINetService::Open(...) call.<BR><BR>
|
||||
*
|
||||
* This method is called regardless of whether the URL loaded successfully.<BR><BR>
|
||||
*
|
||||
* @param status Status code for the URL load.
|
||||
* @param msg A text string describing the error.
|
||||
* @return The return value is currently ignored.
|
||||
*/
|
||||
NS_IMETHOD
|
||||
OnStopBinding(nsIPluginStreamInfo* pluginInfo, nsresult status)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* What is this method supposed to do?
|
||||
*/
|
||||
NS_IMETHOD
|
||||
GetStreamType(nsPluginStreamType *result)
|
||||
{
|
||||
*result = nsPluginStreamType_Normal;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Accessing the list of instances.
|
||||
static MRJPluginInstance* getInstances(void);
|
||||
MRJPluginInstance* getNextInstance(void);
|
||||
|
||||
MRJContext* getContext(void);
|
||||
MRJSession* getSession(void);
|
||||
|
||||
private:
|
||||
void pushInstance(void);
|
||||
void popInstance(void);
|
||||
void inspectInstance(Boolean isUpdateEvt);
|
||||
|
||||
private:
|
||||
nsIPluginInstancePeer* mPeer;
|
||||
nsIWindowlessPluginInstancePeer* mWindowlessPeer;
|
||||
MRJPlugin* mPlugin;
|
||||
MRJSession* mSession;
|
||||
MRJContext* mContext;
|
||||
jobject mApplet;
|
||||
nsPluginWindow* mPluginWindow;
|
||||
|
||||
// maintain a list of instances.
|
||||
MRJPluginInstance* mNext;
|
||||
|
||||
// support for SupportsMixin.
|
||||
static const InterfaceInfo sInterfaces[];
|
||||
static const UInt32 kInterfaceCount;
|
||||
};
|
|
@ -1,49 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
MRJPlugin.java
|
||||
*/
|
||||
|
||||
import netscape.plugin.Plugin;
|
||||
|
||||
class MRJPlugin extends Plugin {
|
||||
MRJPlugin() {}
|
||||
|
||||
public native Object getField(String name, String signature);
|
||||
public native void setField(String name, String signature, Object value);
|
||||
public native Object callMethod(String name, String signature, Object[] args);
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
MRJPlugin_4.x_config.h
|
||||
|
||||
Global configuration defines used by the MRJ plugin.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
#include "MacHeaders.h"
|
||||
|
||||
#define MRJPLUGIN_4X 1
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
MRJPlugin_GC_config.h
|
||||
|
||||
Global configuration defines used by the MRJ plugin.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
#include "MacHeaders.h"
|
||||
|
||||
#define MRJPLUGIN_GC 1
|
|
@ -1,47 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
MRJPlugin_config.h
|
||||
|
||||
Global configuration defines used by the MRJ plugin.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
#include "MacHeaders.h"
|
||||
|
||||
/* #define NEW_PLUGIN_STREAM_API */
|
|
@ -1,59 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "nsISecurityContext.h"
|
||||
|
||||
class nsILiveconnect;
|
||||
|
||||
class MRJSecurityContext : public nsISecurityContext {
|
||||
public:
|
||||
MRJSecurityContext(const char* location);
|
||||
~MRJSecurityContext();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Implies(const char* target, const char* action, PRBool *bAllowedAccess);
|
||||
NS_IMETHOD GetOrigin(char* buf, int len);
|
||||
NS_IMETHOD GetCertificateID(char* buf, int len);
|
||||
|
||||
nsILiveconnect* getConnection() { return mConnection; }
|
||||
|
||||
private:
|
||||
char* mLocation;
|
||||
nsILiveconnect* mConnection;
|
||||
};
|
|
@ -1,541 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
MRJSession.cpp
|
||||
|
||||
Encapsulates a session with the MacOS Runtime for Java.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
#include "MRJSession.h"
|
||||
#include "MRJPlugin.h"
|
||||
#include "MRJContext.h"
|
||||
#include "MRJConsole.h"
|
||||
#include "MRJMonitor.h"
|
||||
#include "MRJNetworking.h"
|
||||
|
||||
#include <ControlDefinitions.h>
|
||||
#include <string.h>
|
||||
#include <Memory.h>
|
||||
#include <Files.h>
|
||||
#include <Dialogs.h>
|
||||
#include <Appearance.h>
|
||||
#include <Resources.h>
|
||||
|
||||
#if (UNIVERSAL_INTERFACES_VERSION >= 0x0330)
|
||||
#include <ControlDefinitions.h>
|
||||
#endif
|
||||
|
||||
extern MRJConsole* theConsole;
|
||||
extern short thePluginRefnum;
|
||||
|
||||
static Str255 consoleOutFilename = "\pMRJPluginAppletOutput";
|
||||
static bool fileCreated = false;
|
||||
|
||||
static SInt32 java_stdin(JMSessionRef session, void *buffer, SInt32 maxBufferLength)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
static Boolean java_exit(JMSessionRef session, SInt32 status)
|
||||
{
|
||||
return false; /* not allowed in a plugin. */
|
||||
}
|
||||
|
||||
static void getItemText(DialogPtr dialog, DialogItemIndex index, ResType textTag, char str[256])
|
||||
{
|
||||
ControlHandle control;
|
||||
if (::GetDialogItemAsControl(dialog, index, &control) == noErr) {
|
||||
Size textSize;
|
||||
::GetControlDataSize(control, kControlNoPart, textTag, &textSize);
|
||||
if (textSize > 255) textSize = 255;
|
||||
::GetControlData(control, kControlNoPart, textTag, textSize, (Ptr)str, &textSize);
|
||||
str[textSize] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
static void miniEgg () {
|
||||
|
||||
#if 0
|
||||
|
||||
long count = 0;
|
||||
OSErr myErr;
|
||||
short myVRef;
|
||||
long myDirID;
|
||||
FSSpec mySpec;
|
||||
short refNum;
|
||||
Str255 holder;
|
||||
|
||||
myErr = FindFolder(kOnSystemDisk, kPreferencesFolderType, kDontCreateFolder, &myVRef, &myDirID);
|
||||
|
||||
if (myErr == noErr) {
|
||||
|
||||
myErr = FSMakeFSSpec(myVRef, myDirID, "\pFileName", &mySpec);
|
||||
|
||||
if ((myErr != noErr) && (myErr != fnfErr)) {
|
||||
return;
|
||||
}
|
||||
|
||||
myErr = FSpCreate(&mySpec, 'ttxt', 'TEXT', smSystemScript);
|
||||
|
||||
// if it exists just exit.
|
||||
if (myErr != noErr) {
|
||||
return;
|
||||
}
|
||||
|
||||
//we care if this errs, but not enough to impede mozilla running.
|
||||
myErr = FSpOpenDF(&mySpec, fsWrPerm, &refNum);
|
||||
|
||||
if (myErr != noErr) {
|
||||
return;
|
||||
}
|
||||
|
||||
sprintf((char *)holder, "egg line1\r");
|
||||
count = strlen((char *)holder);
|
||||
myErr = FSWrite(refNum, &count, holder);
|
||||
|
||||
sprintf((char *)holder, "egg line2\r");
|
||||
count = strlen((char *)holder);
|
||||
myErr = FSWrite(refNum, &count, holder);
|
||||
|
||||
sprintf((char *)holder, "egg line3\r");
|
||||
count = strlen((char *)holder);
|
||||
myErr = FSWrite(refNum, &count, holder);
|
||||
|
||||
// ...
|
||||
|
||||
FlushVol("\p", refNum);
|
||||
myErr = FSClose(refNum);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
static void debug_out(const void *label, const void *message, UInt32 messageLengthInBytes)
|
||||
{
|
||||
long count = 0;
|
||||
OSErr myErr;
|
||||
short myVRef;
|
||||
long myDirID;
|
||||
FSSpec mySpec;
|
||||
short refNum;
|
||||
Str255 holder;
|
||||
|
||||
myErr = Gestalt(gestaltFindFolderAttr, &count);
|
||||
|
||||
if ((myErr != noErr) || (! (count & (1 << gestaltFindFolderPresent)))) {
|
||||
return;
|
||||
}
|
||||
|
||||
myErr = FindFolder(kOnSystemDisk, kPreferencesFolderType, kDontCreateFolder, &myVRef, &myDirID);
|
||||
|
||||
if (myErr == noErr) {
|
||||
|
||||
myErr = FSMakeFSSpec(myVRef, myDirID, consoleOutFilename, &mySpec);
|
||||
|
||||
if ((myErr != noErr) && (myErr != fnfErr)) {
|
||||
return;
|
||||
}
|
||||
|
||||
//will err if file exists, we don't care.
|
||||
myErr = FSpCreate(&mySpec, 'ttxt', 'TEXT', smSystemScript);
|
||||
|
||||
//we care if this errs, but not enough to impede mozilla running.
|
||||
myErr = FSpOpenDF(&mySpec, fsWrPerm, &refNum);
|
||||
|
||||
if (myErr != noErr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (! fileCreated) {
|
||||
//write over
|
||||
miniEgg();
|
||||
myErr = SetEOF(refNum, 0);
|
||||
|
||||
fileCreated = true;
|
||||
sprintf((char *)holder, "MRJ Console Output.\rMRJ Plugin Version: %s\r--------------------\r", MRJPlugin::PLUGIN_VERSION);
|
||||
|
||||
count = strlen((char *)holder);
|
||||
myErr = FSWrite(refNum, &count, holder);
|
||||
|
||||
} else {
|
||||
//append
|
||||
myErr = SetFPos(refNum, fsFromLEOF, 0);
|
||||
}
|
||||
|
||||
count = strlen((char *)label);
|
||||
myErr = FSWrite(refNum, &count, label);
|
||||
|
||||
count = messageLengthInBytes;
|
||||
myErr = FSWrite(refNum, &count, message);
|
||||
|
||||
count = 1;
|
||||
myErr = FSWrite(refNum, &count, "\r");
|
||||
|
||||
FlushVol("\p", refNum);
|
||||
myErr = FSClose(refNum);
|
||||
}
|
||||
|
||||
|
||||
// Str255 pmsg;
|
||||
//if (myErr != noErr) {
|
||||
//Str255 bla;
|
||||
//sprintf((char *)bla, "FSpOpenDF error: %d", myErr);
|
||||
//pmsg[0] = strlen((char *)bla);
|
||||
//::BlockMoveData(bla, &pmsg[1], pmsg[0]);
|
||||
//::DebugStr(pmsg);
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
static void java_stdout(JMSessionRef session, const void *message, SInt32 messageLengthInBytes)
|
||||
{
|
||||
if (theConsole != NULL) {
|
||||
theConsole->write(message, messageLengthInBytes);
|
||||
} else {
|
||||
debug_out("[System.out] ", message, messageLengthInBytes);
|
||||
}
|
||||
}
|
||||
|
||||
static void java_stderr(JMSessionRef session, const void *message, SInt32 messageLengthInBytes)
|
||||
{
|
||||
if (theConsole != NULL) {
|
||||
theConsole->write(message, messageLengthInBytes);
|
||||
} else {
|
||||
debug_out("[System.err] ", message, messageLengthInBytes);
|
||||
}
|
||||
}
|
||||
|
||||
static ControlHandle getItemControl(DialogPtr dialog, DialogItemIndex index)
|
||||
{
|
||||
ControlHandle control;
|
||||
if (::GetDialogItemAsControl(dialog, index, &control) == noErr)
|
||||
return control;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
enum {
|
||||
kUserNameIndex = 3,
|
||||
kPasswordIndex,
|
||||
kAuthenticationDialog = 128
|
||||
};
|
||||
|
||||
static Boolean java_authenticate(JMSessionRef session, const char *url, const char *realm, char userName[255], char password[255])
|
||||
{
|
||||
Boolean result = false;
|
||||
if (thePluginRefnum != -1) {
|
||||
// ensure resources come from the plugin (yuck!).
|
||||
short oldRefnum = ::CurResFile();
|
||||
::UseResFile(thePluginRefnum);
|
||||
|
||||
DialogRecord storage;
|
||||
DialogPtr dialog = ::GetNewDialog(kAuthenticationDialog, &storage, WindowPtr(-1));
|
||||
if (dialog != NULL) {
|
||||
// set up default buttons.
|
||||
::SetDialogDefaultItem(dialog, kStdOkItemIndex);
|
||||
::SetDialogCancelItem(dialog, kStdCancelItemIndex);
|
||||
::SetDialogTracksCursor(dialog, true);
|
||||
|
||||
// set up default keyboard focus.
|
||||
ControlHandle userNameControl = getItemControl(dialog, kUserNameIndex);
|
||||
if (userNameControl != NULL)
|
||||
::SetKeyboardFocus(dialog, userNameControl, kControlFocusNextPart);
|
||||
|
||||
::ShowWindow(dialog);
|
||||
|
||||
DialogItemIndex itemHit = 0;
|
||||
do {
|
||||
::ModalDialog(ModalFilterUPP(NULL), &itemHit);
|
||||
} while (itemHit != 1 && itemHit != 2);
|
||||
|
||||
if (itemHit == 1) {
|
||||
getItemText(dialog, kUserNameIndex, kControlEditTextTextTag, userName);
|
||||
getItemText(dialog, kPasswordIndex, kControlEditTextPasswordTag, password);
|
||||
result = true;
|
||||
}
|
||||
|
||||
::CloseDialog(dialog);
|
||||
::UseResFile(oldRefnum);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static void java_lowmem(JMSessionRef session)
|
||||
{
|
||||
/* can ask Netscape to purge some memory. */
|
||||
// NPN_MemFlush(512 * 1024);
|
||||
}
|
||||
|
||||
MRJSession::MRJSession()
|
||||
: mSession(NULL), mStatus(noErr), mMainEnv(NULL), mFirst(NULL), mLast(NULL), mMessageMonitor(NULL), mLockCount(0)
|
||||
{
|
||||
// Make sure JManager exists.
|
||||
if (&::JMGetVersion != NULL && ::JMGetVersion() >= kJMVersion) {
|
||||
static JMSessionCallbacks callbacks = {
|
||||
kJMVersion, /* should be set to kJMVersion */
|
||||
&java_stdout, /* JM will route "stdout" to this function. */
|
||||
&java_stderr, /* JM will route "stderr" to this function. */
|
||||
&java_stdin, /* read from console - can be nil for default behavior (no console IO) */
|
||||
&java_exit, /* handle System.exit(int) requests */
|
||||
&java_authenticate, /* present basic authentication dialog */
|
||||
&java_lowmem /* Low Memory notification Proc */
|
||||
};
|
||||
|
||||
JMTextRef nameRef = NULL;
|
||||
JMTextRef valueRef = NULL;
|
||||
OSStatus status = noErr;
|
||||
|
||||
mStatus = ::JMOpenSession(&mSession, eJManager2Defaults, eCheckRemoteCode,
|
||||
&callbacks, kTextEncodingMacRoman, NULL);
|
||||
|
||||
// capture the main environment, so it can be distinguished from true Java threads.
|
||||
if (mStatus == noErr) {
|
||||
mMainEnv = ::JMGetCurrentEnv(mSession);
|
||||
|
||||
// create a monitor for the message queue to unblock Java threads.
|
||||
mMessageMonitor = new MRJMonitor(this);
|
||||
|
||||
#ifdef MRJPLUGIN_4X
|
||||
// hook up MRJ networking layer, to permit SSL, etc.
|
||||
::OpenMRJNetworking(this);
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
mStatus = kJMVersionError;
|
||||
}
|
||||
}
|
||||
|
||||
MRJSession::~MRJSession()
|
||||
{
|
||||
#ifdef MRJPLUGIN_4X
|
||||
// is this perhaps too late?
|
||||
::CloseMRJNetworking(this);
|
||||
#endif
|
||||
|
||||
if (mMessageMonitor != NULL) {
|
||||
mMessageMonitor->notifyAll();
|
||||
delete mMessageMonitor;
|
||||
}
|
||||
|
||||
if (mSession != NULL) {
|
||||
mStatus = ::JMCloseSession(mSession);
|
||||
mSession = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
JMSessionRef MRJSession::getSessionRef()
|
||||
{
|
||||
return mSession;
|
||||
}
|
||||
|
||||
JNIEnv* MRJSession::getCurrentEnv()
|
||||
{
|
||||
return ::JMGetCurrentEnv(mSession);
|
||||
}
|
||||
|
||||
JNIEnv* MRJSession::getMainEnv()
|
||||
{
|
||||
return mMainEnv;
|
||||
}
|
||||
|
||||
JavaVM* MRJSession::getJavaVM()
|
||||
{
|
||||
JNIEnv* env = ::JMGetCurrentEnv(mSession);
|
||||
JavaVM* vm = NULL;
|
||||
env->GetJavaVM(&vm);
|
||||
return vm;
|
||||
}
|
||||
|
||||
Boolean MRJSession::onMainThread()
|
||||
{
|
||||
JNIEnv* env = ::JMGetCurrentEnv(mSession);
|
||||
return (env == mMainEnv);
|
||||
}
|
||||
|
||||
inline StringPtr c2p(const char* cstr, StringPtr pstr)
|
||||
{
|
||||
pstr[0] = (unsigned char)strlen(cstr);
|
||||
::BlockMoveData(cstr, pstr + 1, pstr[0]);
|
||||
return pstr;
|
||||
}
|
||||
|
||||
Boolean MRJSession::addToClassPath(const FSSpec& fileSpec)
|
||||
{
|
||||
return (::JMAddToClassPath(mSession, &fileSpec) == noErr);
|
||||
}
|
||||
|
||||
Boolean MRJSession::addToClassPath(const char* dirPath)
|
||||
{
|
||||
// Need to convert the path into an FSSpec, and add it MRJ's class path.
|
||||
Str255 path;
|
||||
FSSpec pathSpec;
|
||||
OSStatus status = ::FSMakeFSSpec(0, 0, c2p(dirPath, path), &pathSpec);
|
||||
if (status == noErr)
|
||||
status = ::JMAddToClassPath(mSession, &pathSpec);
|
||||
return (status == noErr);
|
||||
}
|
||||
|
||||
Boolean MRJSession::addURLToClassPath(const char* fileURL)
|
||||
{
|
||||
OSStatus status = noErr;
|
||||
// Need to convert the URL into an FSSpec, and add it MRJ's class path.
|
||||
JMTextRef urlRef = NULL;
|
||||
status = ::JMNewTextRef(mSession, &urlRef, kTextEncodingMacRoman, fileURL, strlen(fileURL));
|
||||
if (status == noErr) {
|
||||
FSSpec pathSpec;
|
||||
status = ::JMURLToFSS(mSession, urlRef, &pathSpec);
|
||||
if (status == noErr)
|
||||
status = ::JMAddToClassPath(mSession, &pathSpec);
|
||||
::JMDisposeTextRef(urlRef);
|
||||
}
|
||||
|
||||
return (status == noErr);
|
||||
}
|
||||
|
||||
char* MRJSession::getProperty(const char* propertyName)
|
||||
{
|
||||
char* result = NULL;
|
||||
OSStatus status = noErr;
|
||||
JMTextRef nameRef = NULL, valueRef = NULL;
|
||||
status = ::JMNewTextRef(mSession, &nameRef, kTextEncodingMacRoman, propertyName, strlen(propertyName));
|
||||
if (status == noErr) {
|
||||
status = ::JMGetSessionProperty(mSession, nameRef, &valueRef);
|
||||
::JMDisposeTextRef(nameRef);
|
||||
if (status == noErr && valueRef != NULL) {
|
||||
UInt32 valueLength = 0;
|
||||
status = ::JMGetTextLengthInBytes(valueRef, kTextEncodingMacRoman, &valueLength);
|
||||
if (status == noErr) {
|
||||
result = new char[valueLength + 1];
|
||||
if (result != NULL) {
|
||||
UInt32 actualLength;
|
||||
status = ::JMGetTextBytes(valueRef, kTextEncodingMacRoman, result, valueLength, &actualLength);
|
||||
result[valueLength] = '\0';
|
||||
}
|
||||
::JMDisposeTextRef(valueRef);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void MRJSession::setStatus(OSStatus status)
|
||||
{
|
||||
mStatus = status;
|
||||
}
|
||||
|
||||
OSStatus MRJSession::getStatus()
|
||||
{
|
||||
return mStatus;
|
||||
}
|
||||
|
||||
void MRJSession::idle(UInt32 milliseconds)
|
||||
{
|
||||
// Each call to idle processes a single message.
|
||||
dispatchMessage();
|
||||
|
||||
// Guard against entering the VM multiple times.
|
||||
if (mLockCount == 0) {
|
||||
lock();
|
||||
mStatus = ::JMIdle(mSession, milliseconds);
|
||||
unlock();
|
||||
}
|
||||
#if 0
|
||||
else {
|
||||
// sleep the current thread.
|
||||
JNIEnv* env = getCurrentEnv();
|
||||
jclass threadClass = env->FindClass("java/lang/Thread");
|
||||
if (threadClass != NULL) {
|
||||
jmethodID sleepMethod = env->GetStaticMethodID(threadClass, "sleep", "(J)V");
|
||||
env->CallStaticVoidMethod(threadClass, sleepMethod, jlong(milliseconds));
|
||||
env->DeleteLocalRef(threadClass);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void MRJSession::sendMessage(NativeMessage* message, Boolean async)
|
||||
{
|
||||
// can't block the main env, otherwise messages will never be processed!
|
||||
if (onMainThread()) {
|
||||
message->execute();
|
||||
} else {
|
||||
postMessage(message);
|
||||
if (!async)
|
||||
mMessageMonitor->wait();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Put a message on the queue.
|
||||
*/
|
||||
void MRJSession::postMessage(NativeMessage* message)
|
||||
{
|
||||
if (mFirst == NULL) {
|
||||
mFirst = mLast = message;
|
||||
} else {
|
||||
mLast->setNext(message);
|
||||
mLast = message;
|
||||
}
|
||||
message->setNext(NULL);
|
||||
}
|
||||
|
||||
void MRJSession::dispatchMessage()
|
||||
{
|
||||
if (mFirst != NULL) {
|
||||
NativeMessage* message = mFirst;
|
||||
mFirst = message->getNext();
|
||||
if (mFirst == NULL) mLast = NULL;
|
||||
|
||||
message->setNext(NULL);
|
||||
message->execute();
|
||||
mMessageMonitor->notify();
|
||||
}
|
||||
}
|
||||
|
||||
void MRJSession::lock()
|
||||
{
|
||||
++mLockCount;
|
||||
}
|
||||
|
||||
void MRJSession::unlock()
|
||||
{
|
||||
--mLockCount;
|
||||
}
|
|
@ -1,120 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
MRJSession.h
|
||||
|
||||
Encapsulates a session with the MacOS Runtime for Java.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef CALL_NOT_IN_CARBON
|
||||
#define CALL_NOT_IN_CARBON 1
|
||||
#endif
|
||||
|
||||
#include "jni.h"
|
||||
#include "JManager.h"
|
||||
|
||||
class NativeMessage {
|
||||
public:
|
||||
NativeMessage() : mNext(NULL) {}
|
||||
|
||||
virtual void execute() = 0;
|
||||
|
||||
void setNext(NativeMessage* next) { mNext = next; }
|
||||
NativeMessage* getNext() { return mNext; }
|
||||
|
||||
private:
|
||||
NativeMessage* mNext;
|
||||
};
|
||||
|
||||
// FIXME: need an interface for setting security options, etc.
|
||||
|
||||
class MRJContext;
|
||||
class Monitor;
|
||||
|
||||
class MRJSession {
|
||||
public:
|
||||
MRJSession();
|
||||
virtual ~MRJSession();
|
||||
|
||||
JMSessionRef getSessionRef();
|
||||
|
||||
JNIEnv* getCurrentEnv();
|
||||
JNIEnv* getMainEnv();
|
||||
JavaVM* getJavaVM();
|
||||
|
||||
Boolean onMainThread();
|
||||
|
||||
Boolean addToClassPath(const FSSpec& fileSpec);
|
||||
Boolean addToClassPath(const char* dirPath);
|
||||
Boolean addURLToClassPath(const char* fileURL);
|
||||
|
||||
char* getProperty(const char* propertyName);
|
||||
|
||||
void setStatus(OSStatus status);
|
||||
OSStatus getStatus();
|
||||
|
||||
void idle(UInt32 milliseconds = kDefaultJMTime);
|
||||
|
||||
void sendMessage(NativeMessage* message, Boolean async = false);
|
||||
|
||||
/**
|
||||
* Used to prevent reentering the VM.
|
||||
*/
|
||||
void lock();
|
||||
void unlock();
|
||||
|
||||
private:
|
||||
void postMessage(NativeMessage* message);
|
||||
void dispatchMessage();
|
||||
|
||||
private:
|
||||
JMSessionRef mSession;
|
||||
OSStatus mStatus;
|
||||
|
||||
JNIEnv* mMainEnv;
|
||||
|
||||
// Message queue.
|
||||
NativeMessage* mFirst;
|
||||
NativeMessage* mLast;
|
||||
Monitor* mMessageMonitor;
|
||||
|
||||
UInt32 mLockCount;
|
||||
};
|
|
@ -1,58 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
Monitor.h
|
||||
|
||||
Abstract class representing monitors.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
class Monitor {
|
||||
public:
|
||||
virtual ~Monitor() {}
|
||||
|
||||
virtual void enter() = 0;
|
||||
virtual void exit() = 0;
|
||||
|
||||
virtual void wait() = 0;
|
||||
virtual void wait(long long millis) = 0;
|
||||
virtual void notify() = 0;
|
||||
virtual void notifyAll() = 0;
|
||||
};
|
|
@ -1,106 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
NativeMonitor.cpp
|
||||
|
||||
Provides a C++ interface to native monitors.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
#include "NativeMonitor.h"
|
||||
#include "MRJSession.h"
|
||||
#include "nsIThreadManager.h"
|
||||
|
||||
NativeMonitor::NativeMonitor(MRJSession* session, nsIThreadManager* manager, void* address)
|
||||
: mSession(session), mManager(manager), mAddress(address)
|
||||
{
|
||||
if (address == NULL)
|
||||
mAddress = this;
|
||||
}
|
||||
|
||||
NativeMonitor::~NativeMonitor() {}
|
||||
|
||||
void NativeMonitor::enter()
|
||||
{
|
||||
mManager->EnterMonitor(mAddress);
|
||||
}
|
||||
|
||||
void NativeMonitor::exit()
|
||||
{
|
||||
mManager->ExitMonitor(mAddress);
|
||||
}
|
||||
|
||||
void NativeMonitor::wait()
|
||||
{
|
||||
// this is weird hackery, but we don't want to let the VM be reentered while we wait on a native monitor.
|
||||
Boolean inJavaThread = (mSession->getMainEnv() != mSession->getCurrentEnv());
|
||||
if (inJavaThread)
|
||||
mSession->lock();
|
||||
|
||||
if (mManager->EnterMonitor(mAddress) == NS_OK) {
|
||||
mManager->Wait(mAddress);
|
||||
mManager->ExitMonitor(mAddress);
|
||||
}
|
||||
|
||||
if (inJavaThread)
|
||||
mSession->unlock();
|
||||
}
|
||||
|
||||
void NativeMonitor::wait(long long millis)
|
||||
{
|
||||
if (mManager->EnterMonitor(mAddress) == NS_OK) {
|
||||
mManager->Wait(mAddress, PRUint32(millis));
|
||||
mManager->ExitMonitor(mAddress);
|
||||
}
|
||||
}
|
||||
|
||||
void NativeMonitor::notify()
|
||||
{
|
||||
if (mManager->EnterMonitor(mAddress) == NS_OK) {
|
||||
mManager->Notify(mAddress);
|
||||
mManager->ExitMonitor(mAddress);
|
||||
}
|
||||
}
|
||||
|
||||
void NativeMonitor::notifyAll()
|
||||
{
|
||||
if (mManager->EnterMonitor(mAddress) == NS_OK) {
|
||||
mManager->NotifyAll(mAddress);
|
||||
mManager->ExitMonitor(mAddress);
|
||||
}
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
NativeMonitor.h
|
||||
|
||||
Provides a C++ interface to native monitors.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
#include "Monitor.h"
|
||||
|
||||
class MRJSession;
|
||||
class nsIThreadManager;
|
||||
|
||||
class NativeMonitor : public Monitor {
|
||||
public:
|
||||
NativeMonitor(MRJSession* session, nsIThreadManager* manager, void* address = NULL);
|
||||
virtual ~NativeMonitor();
|
||||
|
||||
virtual void enter();
|
||||
virtual void exit();
|
||||
|
||||
virtual void wait();
|
||||
virtual void wait(long long millis);
|
||||
virtual void notify();
|
||||
virtual void notifyAll();
|
||||
|
||||
private:
|
||||
MRJSession* mSession;
|
||||
nsIThreadManager* mManager;
|
||||
void* mAddress;
|
||||
};
|
|
@ -1,67 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
PluginNew.cpp
|
||||
|
||||
new & delete operators for plugins.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
#include <new.h>
|
||||
|
||||
#include "jni.h"
|
||||
#include "nsIMemory.h"
|
||||
|
||||
// Warning: this forces all C++ allocation to go through Navigator's memory allocation
|
||||
// Routines. As such, static constructors that use operator new may not work. This can
|
||||
// be fixed if we delay static construction (see the call to __InitCode__() in npmac.cpp).
|
||||
|
||||
extern nsIMemory* theMemoryAllocator;
|
||||
|
||||
void* operator new(size_t size)
|
||||
{
|
||||
if (theMemoryAllocator != NULL)
|
||||
return theMemoryAllocator->Alloc(size);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void operator delete(void* ptr)
|
||||
{
|
||||
if (ptr != NULL && theMemoryAllocator != NULL)
|
||||
theMemoryAllocator->Free(ptr);
|
||||
}
|
|
@ -1,164 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
PrintingPort.java
|
||||
|
||||
Wraps a Quickdraw printing port and provides a way to image on it
|
||||
with a java.awt.Graphics object.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
package com.apple.mrj.internal.awt;
|
||||
|
||||
import com.apple.mrj.macos.generated.RectStruct;
|
||||
import com.apple.mrj.macos.generated.QuickdrawFunctions;
|
||||
import java.awt.*;
|
||||
|
||||
public class PrintingPort implements GraphicsHost {
|
||||
private int mPrintingPort;
|
||||
private int mOriginX;
|
||||
private int mOriginY;
|
||||
private PortManager mPortManager;
|
||||
private QDPipeline mPipeline;
|
||||
private Rectangle mClipping;
|
||||
|
||||
public PrintingPort(int printingPort, int originX, int originY) {
|
||||
mPrintingPort = printingPort;
|
||||
mOriginX = originX;
|
||||
mOriginY = originY;
|
||||
mPortManager = new PortManager(printingPort, 0, 0, PortManager.kPrinting, 0);
|
||||
mPipeline = new QDPipeline();
|
||||
mPortManager.setPipeline(mPipeline);
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
// dispose of port manager flushes the pipeline.
|
||||
if (mPortManager != null) {
|
||||
mPortManager.dispose();
|
||||
mPortManager = null;
|
||||
}
|
||||
if (mPipeline != null) {
|
||||
mPipeline.dispose();
|
||||
mPipeline = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static final short MAXSHORT = 32767, MINSHORT = -32768;
|
||||
|
||||
static short pinToShort(int value) {
|
||||
if (value > MAXSHORT)
|
||||
return MAXSHORT;
|
||||
else if (value < MINSHORT)
|
||||
return MINSHORT;
|
||||
return (short) value;
|
||||
}
|
||||
|
||||
final class PrintingGraphics extends QDGraphics {
|
||||
/** Creates a new PrintingGraphics. You must call <code>initialize</code> on it next. */
|
||||
public PrintingGraphics() {
|
||||
super();
|
||||
}
|
||||
|
||||
public synchronized Graphics create() {
|
||||
if( !internalMarkHostInUse ( ) )
|
||||
throw new AWTError("Using invalid Graphics object");
|
||||
try {
|
||||
return (new PrintingGraphics()).initialize(this,fXoff,fYoff,fClip);
|
||||
} finally {
|
||||
internalDoneUsingHost ( );
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized Graphics create(int x, int y, int width, int height) {
|
||||
if( !internalMarkHostInUse() )
|
||||
throw new AWTError("Using invalid Graphics object");
|
||||
try {
|
||||
VToolkit.intersect(sRectangle, fClip, fXoff+x,fYoff+y,width,height);
|
||||
return (new PrintingGraphics()).initialize(this,fXoff+x,fYoff+y,sRectangle);
|
||||
} finally {
|
||||
internalDoneUsingHost ( );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Override QDGraphics.restore(), to reset origin and clipping during drawing.
|
||||
*/
|
||||
void restore() {
|
||||
super.restore();
|
||||
|
||||
int port = VAWTDirect.FastGetThePort();
|
||||
if (port != mPrintingPort)
|
||||
QuickdrawFunctions.SetPort(mPrintingPort);
|
||||
|
||||
// restore default orgin.
|
||||
QuickdrawFunctions.SetOrigin((short)0, (short)0);
|
||||
|
||||
// set up correct clipping.
|
||||
QDRectStruct clipRect = new QDRectStruct();
|
||||
clipRect.Set(pinToShort(mClipping.x), pinToShort(mClipping.y),
|
||||
pinToShort(mClipping.x + mClipping.width), pinToShort(mClipping.y + mClipping.width));
|
||||
QuickdrawFunctions.ClipRect(clipRect);
|
||||
|
||||
if (port != mPrintingPort)
|
||||
QuickdrawFunctions.SetPort(port);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a graphics object that wraps the specified printing port.
|
||||
* Assumes that the underlying port's coordinate system is already
|
||||
* set up to have (0, 0) as the upper left corner.
|
||||
*/
|
||||
public Graphics getGraphics(Component component) {
|
||||
mClipping = component.getBounds();
|
||||
mClipping.x = mOriginX; mClipping.y = mOriginY;
|
||||
QDGraphics graphics = new PrintingGraphics();
|
||||
graphics.initialize(mPrintingPort, this, mPortManager,
|
||||
mOriginX, mOriginY, mClipping, component.getForeground(),
|
||||
component.getFont());
|
||||
return graphics;
|
||||
}
|
||||
|
||||
/** methods to satisfy GraphicsHost interface. */
|
||||
public void graphicsCreated(QDGraphics g) throws OutOfMemoryError {}
|
||||
public void graphicsDisposed(QDGraphics g) {}
|
||||
public RGBColorValue getBackgroundRGB() { return new RGBColorValue(Color.white); }
|
||||
public void repaint(RectStruct r) {}
|
||||
public boolean markInUse() { return (mPortManager != null); }
|
||||
public void doneUsingIt() {}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
/*
|
||||
RunnableMixin.cpp
|
||||
|
||||
Provides a mixin nsIRunnable implementation.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
#include "RunnableMixin.h"
|
||||
|
||||
const InterfaceInfo RunnableMixin::sInterfaces[] = {
|
||||
{ NS_IRUNNABLE_IID, INTERFACE_OFFSET(RunnableMixin, nsIRunnable) },
|
||||
};
|
||||
const UInt32 RunnableMixin::kInterfaceCount = sizeof(sInterfaces) / sizeof(InterfaceInfo);
|
||||
|
||||
RunnableMixin::RunnableMixin()
|
||||
: SupportsMixin(this, sInterfaces, kInterfaceCount)
|
||||
{
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
RunnableMixin.h
|
||||
|
||||
Provides a mixin nsIRunnable implementation.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "nsIThreadManager.h"
|
||||
#include "SupportsMixin.h"
|
||||
|
||||
class RunnableMixin : public nsIRunnable, private SupportsMixin {
|
||||
public:
|
||||
RunnableMixin();
|
||||
|
||||
DECL_SUPPORTS_MIXIN
|
||||
|
||||
NS_IMETHOD Run() = 0;
|
||||
|
||||
private:
|
||||
// support for SupportsMixin.
|
||||
static const InterfaceInfo sInterfaces[];
|
||||
static const UInt32 kInterfaceCount;
|
||||
};
|
|
@ -1,86 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
StringUtils.cpp
|
||||
*/
|
||||
|
||||
#include "StringUtils.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
inline unsigned char toupper(unsigned char c)
|
||||
{
|
||||
return (c >= 'a' && c <= 'z') ? (c - ('a' - 'A')) : c;
|
||||
}
|
||||
|
||||
int strcasecmp(const char * str1, const char * str2)
|
||||
{
|
||||
#if !__POWERPC__
|
||||
|
||||
const unsigned char * p1 = (unsigned char *) str1;
|
||||
const unsigned char * p2 = (unsigned char *) str2;
|
||||
unsigned char c1, c2;
|
||||
|
||||
while (toupper(c1 = *p1++) == toupper(c2 = *p2++))
|
||||
if (!c1)
|
||||
return(0);
|
||||
|
||||
#else
|
||||
|
||||
const unsigned char * p1 = (unsigned char *) str1 - 1;
|
||||
const unsigned char * p2 = (unsigned char *) str2 - 1;
|
||||
unsigned long c1, c2;
|
||||
|
||||
while (toupper(c1 = *++p1) == toupper(c2 = *++p2))
|
||||
if (!c1)
|
||||
return(0);
|
||||
|
||||
#endif
|
||||
|
||||
return(toupper(c1) - toupper(c2));
|
||||
}
|
||||
|
||||
char* strdup(const char* str)
|
||||
{
|
||||
if (str != NULL) {
|
||||
char* result = new char[::strlen(str) + 1];
|
||||
if (result != NULL)
|
||||
::strcpy(result, str);
|
||||
return result;
|
||||
}
|
||||
return NULL;
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
StringUtils.h
|
||||
|
||||
String utilities.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* Case-insensitive string comparison.
|
||||
*/
|
||||
int strcasecmp(const char * str1, const char * str2);
|
||||
|
||||
/**
|
||||
* Duplicates a C string, returns NULL if failed, or passed NULL.
|
||||
*/
|
||||
char* strdup(const char* str);
|
|
@ -1,167 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
SupportsMixin.cpp
|
||||
|
||||
Experimental way to implement nsISupports interface.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
#include "SupportsMixin.h"
|
||||
#include "nsAgg.h"
|
||||
|
||||
// Standard nsISupport method implementations.
|
||||
|
||||
#ifdef SUPPORT_AGGREGATION
|
||||
|
||||
SupportsMixin::SupportsMixin(void* instance, const InterfaceInfo interfaces[], UInt32 interfaceCount, nsISupports* outer)
|
||||
: mInstance(instance), mRefCount(0), mInterfaces(interfaces), mInterfaceCount(interfaceCount), mOuter(outer)
|
||||
{
|
||||
if (mOuter != NULL)
|
||||
mInner = new Inner(this);
|
||||
}
|
||||
|
||||
SupportsMixin::~SupportsMixin()
|
||||
{
|
||||
if (mRefCount > 0) {
|
||||
::DebugStr("\pmRefCount > 0!");
|
||||
}
|
||||
if (mInner != NULL)
|
||||
delete mInner;
|
||||
}
|
||||
|
||||
/**
|
||||
* The uppercase versions QueryInterface, AddRef, and Release are meant to be called by subclass
|
||||
* implementations. They take aggregation into account.
|
||||
*/
|
||||
nsresult SupportsMixin::OuterQueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
// first, see if we really implement this interface.
|
||||
nsresult result = queryInterface(aIID, aInstancePtr);
|
||||
// if not, then delegate to the outer object, if any.
|
||||
if (result != NS_OK && mOuter != NULL)
|
||||
return mOuter->QueryInterface(aIID, aInstancePtr);
|
||||
else
|
||||
return result;
|
||||
}
|
||||
|
||||
nsrefcnt SupportsMixin::OuterAddRef()
|
||||
{
|
||||
nsrefcnt result = addRef();
|
||||
if (mOuter != NULL)
|
||||
return mOuter->AddRef();
|
||||
return result;
|
||||
}
|
||||
|
||||
nsrefcnt SupportsMixin::OuterRelease()
|
||||
{
|
||||
if (mOuter != NULL) {
|
||||
nsIOuter* outer = NULL;
|
||||
nsISupports* supports = mOuter;
|
||||
static NS_DEFINE_IID(kIOuterIID, NS_IOUTER_IID);
|
||||
if (mRefCount == 1 && supports->QueryInterface(kIOuterIID, &outer) == NS_OK) {
|
||||
outer->ReleaseInner(mInner);
|
||||
outer->Release();
|
||||
} else
|
||||
release();
|
||||
return supports->Release();
|
||||
} else {
|
||||
return release();
|
||||
}
|
||||
}
|
||||
|
||||
#else /* !SUPPORT_AGGREGATION */
|
||||
|
||||
SupportsMixin::SupportsMixin(void* instance, const InterfaceInfo interfaces[], UInt32 interfaceCount, nsISupports* /* outer */)
|
||||
: mInstance(instance), mRefCount(0), mInterfaces(interfaces), mInterfaceCount(interfaceCount)
|
||||
{
|
||||
}
|
||||
|
||||
SupportsMixin::~SupportsMixin()
|
||||
{
|
||||
if (mRefCount > 0) {
|
||||
::DebugStr("\pmRefCount > 0!");
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* !SUPPORT_AGGREGATION */
|
||||
|
||||
/**
|
||||
* The lowercase implementations of queryInterface, addRef, and release all act locally
|
||||
* on the current object, regardless of aggregation. They are meant to be called by
|
||||
* aggregating outer objects.
|
||||
*/
|
||||
NS_IMETHODIMP SupportsMixin::queryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
if (aInstancePtr == NULL) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
// first check to see if it's one of our known interfaces.
|
||||
// need to solve the non-left inheritance graph case.
|
||||
const InterfaceInfo* interfaces = mInterfaces;
|
||||
UInt32 count = mInterfaceCount;
|
||||
for (UInt32 i = 0; i < count; i++) {
|
||||
if (aIID.Equals(interfaces[i].mIID)) {
|
||||
*aInstancePtr = (void*) (UInt32(mInstance) + interfaces[i].mOffset);
|
||||
addRef();
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
// finally, does the interface match nsISupports?
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtr = (void*) mInstance;
|
||||
addRef();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt) SupportsMixin::addRef()
|
||||
{
|
||||
return ++mRefCount;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt) SupportsMixin::release()
|
||||
{
|
||||
if (--mRefCount == 0) {
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
return mRefCount;
|
||||
}
|
|
@ -1,121 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
SupportsMixin.h
|
||||
|
||||
Experimental way to implement nsISupports interface.
|
||||
|
||||
Uses table-driven approach for fast lookup.
|
||||
|
||||
Aggregation support isn't quite here yet, it requires a helper object that is referenced only by the outer object,
|
||||
whose QueryInterace, AddRef, and Release act only locally (i.e. they call queryInterface, addRef, and release).
|
||||
However, if we're not using aggregation (hardly ever are) it seems wasteful to define the helper object.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
// #define SUPPORT_AGGREGATION
|
||||
|
||||
struct InterfaceInfo {
|
||||
nsID mIID; // the IID of this interface.
|
||||
UInt32 mOffset; // the offset of this interface.
|
||||
};
|
||||
|
||||
class SupportsMixin {
|
||||
public:
|
||||
// These act locally on the current object, and are meant to be called by sub-classes.
|
||||
nsresult queryInterface(const nsIID& aIID, void** aInstancePtr);
|
||||
nsrefcnt addRef(void);
|
||||
nsrefcnt release(void);
|
||||
|
||||
protected:
|
||||
SupportsMixin(void* instance, const InterfaceInfo interfaces[], UInt32 interfaceCount, nsISupports* outer = NULL);
|
||||
virtual ~SupportsMixin();
|
||||
|
||||
#ifdef SUPPORT_AGGREGATION
|
||||
NS_METHOD OuterQueryInterface(REFNSIID aIID, void** aInstancePtr);
|
||||
NS_METHOD_(nsrefcnt) OuterAddRef(void);
|
||||
NS_METHOD_(nsrefcnt) OuterRelease(void);
|
||||
#endif
|
||||
|
||||
private:
|
||||
void* mInstance;
|
||||
nsrefcnt mRefCount;
|
||||
const InterfaceInfo* mInterfaces;
|
||||
UInt32 mInterfaceCount;
|
||||
|
||||
#ifdef SUPPORT_AGGREGATION
|
||||
nsISupports* mOuter;
|
||||
|
||||
class Inner : public nsISupports {
|
||||
public:
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) { return mSupports->queryInterface(aIID, aInstancePtr); }
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void) { return mSupports->addRef(); }
|
||||
NS_IMETHOD_(nsrefcnt) Release(void) { return mSupports->release(); }
|
||||
|
||||
Inner(SupportsMixin* supports) : mSupports(supports) {}
|
||||
|
||||
private:
|
||||
SupportsMixin* mSupports;
|
||||
};
|
||||
|
||||
Inner* mInner;
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef SUPPORT_AGGREGATION
|
||||
|
||||
#define DECL_SUPPORTS_MIXIN \
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) { return OuterQueryInterface(aIID, aInstancePtr); } \
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void) { return OuterAddRef(); } \
|
||||
NS_IMETHOD_(nsrefcnt) Release(void) { return OuterRelease(); }
|
||||
|
||||
#else
|
||||
|
||||
#define DECL_SUPPORTS_MIXIN \
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) { return queryInterface(aIID, aInstancePtr); } \
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void) { return addRef(); } \
|
||||
NS_IMETHOD_(nsrefcnt) Release(void) { return release(); }
|
||||
|
||||
#endif
|
||||
|
||||
#define INTERFACE_OFFSET(leafType, interfaceType) \
|
||||
UInt32((interfaceType*) ((leafType*)0))
|
|
@ -1,304 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
TopLevelFrame.cpp
|
||||
|
||||
An MRJFrame sub-class that manages the behavior of a top-level window
|
||||
running inside the Communicator.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
#include <Controls.h>
|
||||
#include <Events.h>
|
||||
|
||||
#include "TopLevelFrame.h"
|
||||
#include "LocalPort.h"
|
||||
|
||||
#include "nsIPluginManager2.h"
|
||||
#include "nsIEventHandler.h"
|
||||
|
||||
#if !defined(MRJPLUGIN_4X)
|
||||
#define USE_ALT_WINDOW_HANDLING
|
||||
#endif
|
||||
|
||||
#ifdef USE_ALT_WINDOW_HANDLING
|
||||
#include "AltWindowHandling.h"
|
||||
#endif
|
||||
|
||||
#include "nsIEventHandler.h"
|
||||
#include "AltWindowHandling.h"
|
||||
|
||||
extern nsIPluginManager2* thePluginManager2;
|
||||
|
||||
static void UnsetPort(GrafPtr port);
|
||||
static short getModifiers();
|
||||
|
||||
TopLevelFrame::TopLevelFrame(nsIEventHandler* handler, JMFrameRef frameRef, JMFrameKind kind,
|
||||
const Rect* initialBounds, Boolean resizeable)
|
||||
: MRJFrame(frameRef),
|
||||
mHandler(handler), mWindow(NULL), mBounds(*initialBounds)
|
||||
{
|
||||
Boolean hasGoAway = true;
|
||||
SInt16 windowProc = documentProc;
|
||||
SInt16 resizeHeight = resizeable ? 15 : 0;
|
||||
|
||||
switch (kind) {
|
||||
case eBorderlessModelessWindowFrame:
|
||||
hasGoAway = false;
|
||||
windowProc = plainDBox;
|
||||
// mBounds.bottom += resizeHeight;
|
||||
resizeable = false;
|
||||
break;
|
||||
case eModelessWindowFrame:
|
||||
case eModelessDialogFrame:
|
||||
hasGoAway = true;
|
||||
windowProc = resizeable ? zoomDocProc : documentProc;
|
||||
// mBounds.bottom += resizeHeight;
|
||||
break;
|
||||
case eModalWindowFrame:
|
||||
hasGoAway = true;
|
||||
// We have to allow resizeable modal windows.
|
||||
windowProc = resizeable ? documentProc : movableDBoxProc;
|
||||
break;
|
||||
}
|
||||
|
||||
mWindow = ::NewCWindow(NULL, &mBounds, "\p", false, windowProc, WindowPtr(-1), hasGoAway, long(this));
|
||||
if (mWindow != NULL) {
|
||||
Point zeroPt = { 0, 0 };
|
||||
::JMSetFrameVisibility(frameRef, mWindow, zeroPt, mWindow->clipRgn);
|
||||
}
|
||||
}
|
||||
|
||||
TopLevelFrame::~TopLevelFrame()
|
||||
{
|
||||
// make sure the window is hidden (and unregistered with the browser).
|
||||
showHide(false);
|
||||
|
||||
// make sure this port isn't ever current again.
|
||||
::UnsetPort(mWindow);
|
||||
|
||||
if (mWindow != NULL)
|
||||
::DisposeWindow(mWindow);
|
||||
}
|
||||
|
||||
void TopLevelFrame::setSize(const Rect* newSize)
|
||||
{
|
||||
mBounds = *newSize;
|
||||
|
||||
if (mWindow != NULL) {
|
||||
SInt16 width = newSize->right - newSize->left;
|
||||
SInt16 height = newSize->bottom - newSize->top;
|
||||
::SizeWindow(mWindow, width, height, true);
|
||||
::MoveWindow(mWindow, newSize->left, newSize->top, false);
|
||||
}
|
||||
}
|
||||
|
||||
void TopLevelFrame::invalRect(const Rect* invalidRect)
|
||||
{
|
||||
if (mWindow != NULL) {
|
||||
::InvalRect(invalidRect);
|
||||
}
|
||||
}
|
||||
|
||||
void TopLevelFrame::showHide(Boolean visible)
|
||||
{
|
||||
if (mWindow != NULL && visible != IsWindowVisible(mWindow)) {
|
||||
if (visible) {
|
||||
#if !defined(USE_ALT_WINDOW_HANDLING)
|
||||
// Have to notify the browser that this window exists, so that it will receive events.
|
||||
thePluginManager2->RegisterWindow(mHandler, mWindow);
|
||||
// the plugin manager takes care of showing the window.
|
||||
// ::ShowWindow(mWindow);
|
||||
// ::SelectWindow(mWindow);
|
||||
#else
|
||||
AltRegisterWindow(mHandler, mWindow);
|
||||
#endif
|
||||
} else {
|
||||
#if defined(USE_ALT_WINDOW_HANDLING)
|
||||
AltUnregisterWindow(mHandler, mWindow);
|
||||
#else
|
||||
// the plugin manager takes care of hiding the window.
|
||||
// ::HideWindow(mWindow);
|
||||
// Let the browser know it doesn't have to send events anymore.
|
||||
thePluginManager2->UnregisterWindow(mHandler, mWindow);
|
||||
#endif
|
||||
activate(false);
|
||||
}
|
||||
|
||||
// ::ShowHide(mWindow, visible);
|
||||
}
|
||||
}
|
||||
|
||||
void TopLevelFrame::setTitle(const StringPtr title)
|
||||
{
|
||||
if (mWindow != NULL) {
|
||||
::SetWTitle(mWindow, title);
|
||||
}
|
||||
}
|
||||
|
||||
void TopLevelFrame::checkUpdate()
|
||||
{
|
||||
}
|
||||
|
||||
void TopLevelFrame::reorder(ReorderRequest request)
|
||||
{
|
||||
switch (request) {
|
||||
case eBringToFront: /* bring the window to front */
|
||||
::BringToFront(mWindow);
|
||||
break;
|
||||
case eSendToBack: /* send the window to back */
|
||||
::SendBehind(mWindow, NULL);
|
||||
break;
|
||||
case eSendBehindFront: /* send the window behind the front window */
|
||||
WindowPtr frontWindow = ::FrontWindow();
|
||||
if (mWindow == frontWindow) {
|
||||
::SendBehind(mWindow, GetNextWindow(mWindow));
|
||||
} else {
|
||||
::SendBehind(mWindow, frontWindow);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void TopLevelFrame::setResizeable(Boolean resizeable)
|
||||
{
|
||||
// this might have to recreate the window, no?
|
||||
}
|
||||
|
||||
static void computeBounds(WindowRef window, Rect* bounds)
|
||||
{
|
||||
LocalPort port(window);
|
||||
port.Enter();
|
||||
|
||||
Point position = { 0, 0 };
|
||||
::LocalToGlobal(&position);
|
||||
|
||||
*bounds = window->portRect;
|
||||
|
||||
port.Exit();
|
||||
|
||||
::OffsetRect(bounds, position.h, position.v);
|
||||
}
|
||||
|
||||
void TopLevelFrame::activate(Boolean active)
|
||||
{
|
||||
focusEvent(active);
|
||||
MRJFrame::activate(active);
|
||||
}
|
||||
|
||||
void TopLevelFrame::click(const EventRecord* event)
|
||||
{
|
||||
Point where = event->where;
|
||||
SInt16 modifiers = event->modifiers;
|
||||
WindowRef hitWindow;
|
||||
short partCode = ::FindWindow(where, &hitWindow);
|
||||
switch (partCode) {
|
||||
case inContent:
|
||||
::SelectWindow(mWindow);
|
||||
MRJFrame::click(event);
|
||||
break;
|
||||
case inDrag:
|
||||
{
|
||||
Rect bounds = (**GetGrayRgn()).rgnBBox;
|
||||
DragWindow(mWindow, where, &bounds);
|
||||
computeBounds(mWindow, &bounds);
|
||||
::JMSetFrameSize(mFrameRef, &bounds);
|
||||
|
||||
Point zeroPt = { 0, 0 };
|
||||
::JMSetFrameVisibility(mFrameRef, mWindow, zeroPt, mWindow->clipRgn);
|
||||
}
|
||||
break;
|
||||
case inGrow:
|
||||
Rect limits = { 30, 30, 5000, 5000 };
|
||||
long result = GrowWindow(mWindow, where, &limits);
|
||||
if (result != 0) {
|
||||
short width = (result & 0xFFFF);
|
||||
short height = (result >> 16) & 0xFFFF;
|
||||
Rect newBounds;
|
||||
topLeft(newBounds) = topLeft(mBounds);
|
||||
newBounds.right = newBounds.left + width;
|
||||
newBounds.bottom = newBounds.top + height;
|
||||
::JMSetFrameSize(mFrameRef, &newBounds);
|
||||
|
||||
Point zeroPt = { 0, 0 };
|
||||
::JMSetFrameVisibility(mFrameRef, mWindow, zeroPt, mWindow->clipRgn);
|
||||
}
|
||||
break;
|
||||
case inGoAway:
|
||||
if (::TrackGoAway(mWindow, where))
|
||||
::JMFrameGoAway(mFrameRef);
|
||||
break;
|
||||
case inZoomIn:
|
||||
case inZoomOut:
|
||||
if (::TrackBox(mWindow, where, partCode)) {
|
||||
ZoomWindow(mWindow, partCode, true);
|
||||
computeBounds(mWindow, &mBounds);
|
||||
::JMSetFrameSize(mFrameRef, &mBounds);
|
||||
}
|
||||
break;
|
||||
case inCollapseBox:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
WindowRef TopLevelFrame::getWindow()
|
||||
{
|
||||
return mWindow;
|
||||
}
|
||||
|
||||
GrafPtr TopLevelFrame::getPort()
|
||||
{
|
||||
return mWindow;
|
||||
}
|
||||
|
||||
static void UnsetPort(GrafPtr port)
|
||||
{
|
||||
GrafPtr curPort;
|
||||
::GetPort(&curPort);
|
||||
if (curPort == port) {
|
||||
::GetWMgrPort(&port);
|
||||
::SetPort(port);
|
||||
}
|
||||
}
|
||||
|
||||
static short getModifiers()
|
||||
{
|
||||
EventRecord event;
|
||||
::OSEventAvail(0, &event);
|
||||
return event.modifiers;
|
||||
}
|
|
@ -1,81 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
TopLevelFrame.h
|
||||
|
||||
An MRJFrame sub-class that manages the behavior of a top-level window
|
||||
running inside the Communicator.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "MRJFrame.h"
|
||||
|
||||
#ifndef __MACWINDOWS__
|
||||
#include <MacWindows.h>
|
||||
#endif
|
||||
|
||||
class nsIEventHandler;
|
||||
|
||||
class TopLevelFrame : public MRJFrame {
|
||||
public:
|
||||
TopLevelFrame(nsIEventHandler* handler, JMFrameRef frameRef, JMFrameKind kind, const Rect* initialBounds, Boolean resizeable);
|
||||
virtual ~TopLevelFrame();
|
||||
|
||||
virtual void setSize(const Rect* newSize);
|
||||
virtual void invalRect(const Rect* invalidRect);
|
||||
virtual void showHide(Boolean visible);
|
||||
virtual void setTitle(const StringPtr title);
|
||||
virtual void checkUpdate();
|
||||
virtual void reorder(ReorderRequest request);
|
||||
virtual void setResizeable(Boolean resizeable);
|
||||
|
||||
virtual void activate(Boolean active);
|
||||
virtual void click(const EventRecord* event);
|
||||
|
||||
WindowRef getWindow();
|
||||
|
||||
protected:
|
||||
virtual GrafPtr getPort();
|
||||
|
||||
private:
|
||||
nsIEventHandler* mHandler;
|
||||
WindowRef mWindow;
|
||||
Rect mBounds;
|
||||
};
|
|
@ -1,151 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
jGNE.cpp
|
||||
|
||||
Provides a generalized jGNE filtering service.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
#include "jGNE.h"
|
||||
|
||||
#include <MixedMode.h>
|
||||
#include <Memory.h>
|
||||
#include <LowMem.h>
|
||||
#include <TextUtils.h>
|
||||
|
||||
/**
|
||||
* A 68K jump vector.
|
||||
*/
|
||||
#pragma options align=mac68k
|
||||
|
||||
struct Jump {
|
||||
unsigned short jmp;
|
||||
UniversalProcPtr addr;
|
||||
};
|
||||
|
||||
#pragma options align=reset
|
||||
|
||||
static void GNEFilter(EventRecord *event, Boolean* result);
|
||||
|
||||
static RoutineDescriptor theGNEFilterDescriptor = BUILD_ROUTINE_DESCRIPTOR(uppGetNextEventFilterProcInfo, GNEFilter);
|
||||
static Jump* theGNEFilterJump;
|
||||
static GetNextEventFilterUPP theOldGNEFilterUPP = NULL;
|
||||
static EventFilterProcPtr theEventFilter = NULL;
|
||||
|
||||
static Str63 theAppName;
|
||||
|
||||
OSStatus InstallEventFilter(EventFilterProcPtr filter)
|
||||
{
|
||||
if (theEventFilter == NULL) {
|
||||
theEventFilter = filter;
|
||||
|
||||
// record the current application's name.
|
||||
StringPtr currentAppName = LMGetCurApName();
|
||||
::BlockMoveData(currentAppName, theAppName, 1 + currentAppName[0]);
|
||||
|
||||
// allocate a jump vector in the System heap, so it will be retained after termination.
|
||||
if (theGNEFilterJump == NULL) {
|
||||
theGNEFilterJump = (Jump*) NewPtrSys(sizeof(Jump));
|
||||
if (theGNEFilterJump == NULL)
|
||||
return MemError();
|
||||
|
||||
theGNEFilterJump->jmp = 0x4EF9;
|
||||
theGNEFilterJump->addr = &theGNEFilterDescriptor;
|
||||
|
||||
// get previous event filter routine.
|
||||
theOldGNEFilterUPP = LMGetGNEFilter();
|
||||
LMSetGNEFilter(GetNextEventFilterUPP(theGNEFilterJump));
|
||||
} else {
|
||||
// our previously allocated Jump is still installed, use it.
|
||||
theOldGNEFilterUPP = theGNEFilterJump->addr;
|
||||
theGNEFilterJump->addr = &theGNEFilterDescriptor;
|
||||
}
|
||||
|
||||
return noErr;
|
||||
}
|
||||
return paramErr;
|
||||
}
|
||||
|
||||
OSStatus RemoveEventFilter()
|
||||
{
|
||||
if (theEventFilter != NULL) {
|
||||
// It's only truly safe to remove our filter, if nobody else installed one after us.
|
||||
if (LMGetGNEFilter() == GetNextEventFilterUPP(theGNEFilterJump)) {
|
||||
// can safely restore the old filter.
|
||||
LMSetGNEFilter(theOldGNEFilterUPP);
|
||||
DisposePtr(Ptr(theGNEFilterJump));
|
||||
theGNEFilterJump = NULL;
|
||||
} else {
|
||||
// modify the jump instruction to point to the previous filter.
|
||||
theGNEFilterJump->addr = theOldGNEFilterUPP;
|
||||
}
|
||||
theOldGNEFilterUPP = NULL;
|
||||
theEventFilter = NULL;
|
||||
return noErr;
|
||||
}
|
||||
return paramErr;
|
||||
}
|
||||
|
||||
static void GNEFilter(EventRecord *event, Boolean* result)
|
||||
{
|
||||
// call next filter in chain first.
|
||||
if (theOldGNEFilterUPP != NULL)
|
||||
CallGetNextEventFilterProc(theOldGNEFilterUPP, event, result);
|
||||
|
||||
// now, let the filter proc have a crack at the event.
|
||||
if (*result) {
|
||||
// only call the filter if called in the current application's context.
|
||||
/* if (::EqualString(theAppName, LMGetCurApName(), true, true)) */
|
||||
{
|
||||
// prevent recursive calls to the filter.
|
||||
static Boolean inFilter = false;
|
||||
if (! inFilter) {
|
||||
inFilter = true;
|
||||
Boolean filteredEvent = theEventFilter(event);
|
||||
if (filteredEvent) {
|
||||
// consume the event by making it a nullEvent.
|
||||
event->what = nullEvent;
|
||||
*result = false;
|
||||
}
|
||||
inFilter = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
jGNE.h
|
||||
|
||||
Provides a generalized jGNE filtering service.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
#ifndef __EVENTS__
|
||||
#include <Events.h>
|
||||
#endif
|
||||
|
||||
typedef Boolean (*EventFilterProcPtr) (EventRecord* event);
|
||||
|
||||
OSStatus InstallEventFilter(EventFilterProcPtr filter);
|
||||
OSStatus RemoveEventFilter();
|
|
@ -1,708 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
//
|
||||
// npmac.cpp
|
||||
//
|
||||
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
#include <Processes.h>
|
||||
#include <Gestalt.h>
|
||||
#include <CodeFragments.h>
|
||||
#include <Timer.h>
|
||||
#include <Resources.h>
|
||||
#include <ToolUtils.h>
|
||||
|
||||
#define XP_MAC 1
|
||||
#define NDEBUG 1
|
||||
|
||||
//
|
||||
// A4Stuff.h contains the definition of EnterCodeResource and
|
||||
// EnterCodeResource, used for setting up the code resource¹s
|
||||
// globals for 68K (analagous to the function SetCurrentA5
|
||||
// defined by the toolbox).
|
||||
//
|
||||
// A4Stuff does not exist as of CW 7. Define them to nothing.
|
||||
//
|
||||
|
||||
#if defined(__MWERKS__) && (__MWERKS__ >= 0x2400)
|
||||
#define EnterCodeResource()
|
||||
#define ExitCodeResource()
|
||||
#else
|
||||
#include <A4Stuff.h>
|
||||
#endif
|
||||
|
||||
#include "jri.h"
|
||||
#include "npapi.h"
|
||||
|
||||
//
|
||||
// The Mixed Mode procInfos defined in npupp.h assume Think C-
|
||||
// style calling conventions. These conventions are used by
|
||||
// Metrowerks with the exception of pointer return types, which
|
||||
// in Metrowerks 68K are returned in A0, instead of the standard
|
||||
// D0. Thus, since NPN_MemAlloc and NPN_UserAgent return pointers,
|
||||
// Mixed Mode will return the values to a 68K plugin in D0, but
|
||||
// a 68K plugin compiled by Metrowerks will expect the result in
|
||||
// A0. The following pragma forces Metrowerks to use D0 instead.
|
||||
//
|
||||
#ifdef __MWERKS__
|
||||
#ifndef powerc
|
||||
#pragma pointers_in_D0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "npupp.h"
|
||||
|
||||
#ifdef __MWERKS__
|
||||
#ifndef powerc
|
||||
#pragma pointers_in_A0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// The following fix for static initializers (which fixes a preious
|
||||
// incompatibility with some parts of PowerPlant, was submitted by
|
||||
// Jan Ulbrich.
|
||||
#ifdef __MWERKS__
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#ifndef powerc
|
||||
extern void __InitCode__(void);
|
||||
#else
|
||||
extern void __sinit(void);
|
||||
#define __InitCode__ __sinit
|
||||
#endif
|
||||
extern void __destroy_global_chain(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // __cplusplus
|
||||
#endif // __MWERKS__
|
||||
|
||||
//
|
||||
// Define PLUGIN_TRACE to 1 to have the wrapper functions emit
|
||||
// DebugStr messages whenever they are called.
|
||||
//
|
||||
#define PLUGIN_TRACE 0
|
||||
|
||||
#if PLUGIN_TRACE
|
||||
#define PLUGINDEBUGSTR(msg) ::DebugStr(msg)
|
||||
#else
|
||||
#define PLUGINDEBUGSTR
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
QDGlobals* gQDPtr; // Pointer to Netscape¹s QuickDraw globals
|
||||
short gResFile; // Refnum of the plugin¹s resource file
|
||||
NPNetscapeFuncs gNetscapeFuncs; // Function table for procs in Netscape called by plugin
|
||||
|
||||
|
||||
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
//
|
||||
// Wrapper functions for all calls from the plugin to Netscape.
|
||||
// These functions let the plugin developer just call the APIs
|
||||
// as documented and defined in npapi.h, without needing to know
|
||||
// about the function table and call macros in npupp.h.
|
||||
//
|
||||
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
|
||||
void NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor)
|
||||
{
|
||||
*plugin_major = NP_VERSION_MAJOR;
|
||||
*plugin_minor = NP_VERSION_MINOR;
|
||||
*netscape_major = gNetscapeFuncs.version >> 8; // Major version is in high byte
|
||||
*netscape_minor = gNetscapeFuncs.version & 0xFF; // Minor version is in low byte
|
||||
}
|
||||
|
||||
NPError NPN_GetURLNotify(NPP instance, const char* url, const char* window, void* notifyData)
|
||||
{
|
||||
int navMinorVers = gNetscapeFuncs.version & 0xFF;
|
||||
NPError err;
|
||||
|
||||
if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
|
||||
{
|
||||
err = CallNPN_GetURLNotifyProc(gNetscapeFuncs.geturlnotify, instance, url, window, notifyData);
|
||||
}
|
||||
else
|
||||
{
|
||||
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
NPError NPN_GetURL(NPP instance, const char* url, const char* window)
|
||||
{
|
||||
return CallNPN_GetURLProc(gNetscapeFuncs.geturl, instance, url, window);
|
||||
}
|
||||
|
||||
NPError NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file, void* notifyData)
|
||||
{
|
||||
int navMinorVers = gNetscapeFuncs.version & 0xFF;
|
||||
NPError err;
|
||||
|
||||
if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
|
||||
{
|
||||
err = CallNPN_PostURLNotifyProc(gNetscapeFuncs.posturlnotify, instance, url,
|
||||
window, len, buf, file, notifyData);
|
||||
}
|
||||
else
|
||||
{
|
||||
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
NPError NPN_PostURL(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file)
|
||||
{
|
||||
return CallNPN_PostURLProc(gNetscapeFuncs.posturl, instance, url, window, len, buf, file);
|
||||
}
|
||||
|
||||
NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
|
||||
{
|
||||
return CallNPN_RequestReadProc(gNetscapeFuncs.requestread, stream, rangeList);
|
||||
}
|
||||
|
||||
NPError NPN_NewStream(NPP instance, NPMIMEType type, const char* window, NPStream** stream)
|
||||
{
|
||||
int navMinorVers = gNetscapeFuncs.version & 0xFF;
|
||||
NPError err;
|
||||
|
||||
if( navMinorVers >= NPVERS_HAS_STREAMOUTPUT )
|
||||
{
|
||||
err = CallNPN_NewStreamProc(gNetscapeFuncs.newstream, instance, type, window, stream);
|
||||
}
|
||||
else
|
||||
{
|
||||
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
int32 NPN_Write(NPP instance, NPStream* stream, int32 len, void* buffer)
|
||||
{
|
||||
int navMinorVers = gNetscapeFuncs.version & 0xFF;
|
||||
NPError err;
|
||||
|
||||
if( navMinorVers >= NPVERS_HAS_STREAMOUTPUT )
|
||||
{
|
||||
err = CallNPN_WriteProc(gNetscapeFuncs.write, instance, stream, len, buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
|
||||
{
|
||||
int navMinorVers = gNetscapeFuncs.version & 0xFF;
|
||||
NPError err;
|
||||
|
||||
if( navMinorVers >= NPVERS_HAS_STREAMOUTPUT )
|
||||
{
|
||||
err = CallNPN_DestroyStreamProc(gNetscapeFuncs.destroystream, instance, stream, reason);
|
||||
}
|
||||
else
|
||||
{
|
||||
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
void NPN_Status(NPP instance, const char* message)
|
||||
{
|
||||
CallNPN_StatusProc(gNetscapeFuncs.status, instance, message);
|
||||
}
|
||||
|
||||
const char* NPN_UserAgent(NPP instance)
|
||||
{
|
||||
return CallNPN_UserAgentProc(gNetscapeFuncs.uagent, instance);
|
||||
}
|
||||
|
||||
#define DEBUG_MEMORY 0
|
||||
|
||||
void* NPN_MemAlloc(uint32 size)
|
||||
{
|
||||
#if DEBUG_MEMORY
|
||||
return (void*) NewPtrClear(size);
|
||||
#else
|
||||
return CallNPN_MemAllocProc(gNetscapeFuncs.memalloc, size);
|
||||
#endif
|
||||
}
|
||||
|
||||
void NPN_MemFree(void* ptr)
|
||||
{
|
||||
#if DEBUG_MEMORY
|
||||
DisposePtr(Ptr(ptr));
|
||||
#else
|
||||
CallNPN_MemFreeProc(gNetscapeFuncs.memfree, ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
uint32 NPN_MemFlush(uint32 size)
|
||||
{
|
||||
return CallNPN_MemFlushProc(gNetscapeFuncs.memflush, size);
|
||||
}
|
||||
|
||||
void NPN_ReloadPlugins(NPBool reloadPages)
|
||||
{
|
||||
CallNPN_ReloadPluginsProc(gNetscapeFuncs.reloadplugins, reloadPages);
|
||||
}
|
||||
|
||||
|
||||
JRIEnv* NPN_GetJavaEnv(void)
|
||||
{
|
||||
return CallNPN_GetJavaEnvProc( gNetscapeFuncs.getJavaEnv );
|
||||
}
|
||||
|
||||
jref NPN_GetJavaPeer(NPP instance)
|
||||
{
|
||||
return CallNPN_GetJavaPeerProc( gNetscapeFuncs.getJavaPeer, instance );
|
||||
}
|
||||
|
||||
NPError NPN_GetValue(NPP instance, NPNVariable variable, void *value)
|
||||
{
|
||||
return CallNPN_GetValueProc( gNetscapeFuncs.getvalue, instance, variable, value);
|
||||
}
|
||||
|
||||
NPError NPN_SetValue(NPP instance, NPPVariable variable, void *value)
|
||||
{
|
||||
return CallNPN_SetValueProc( gNetscapeFuncs.setvalue, instance, variable, value);
|
||||
}
|
||||
|
||||
void NPN_InvalidateRect(NPP instance, NPRect *rect)
|
||||
{
|
||||
CallNPN_InvalidateRectProc( gNetscapeFuncs.invalidaterect, instance, rect);
|
||||
}
|
||||
|
||||
void NPN_InvalidateRegion(NPP instance, NPRegion region)
|
||||
{
|
||||
CallNPN_InvalidateRegionProc( gNetscapeFuncs.invalidateregion, instance, region);
|
||||
}
|
||||
|
||||
void NPN_ForceRedraw(NPP instance)
|
||||
{
|
||||
CallNPN_ForceRedrawProc( gNetscapeFuncs.forceredraw, instance);
|
||||
}
|
||||
|
||||
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
//
|
||||
// Wrapper functions for all calls from Netscape to the plugin.
|
||||
// These functions let the plugin developer just create the APIs
|
||||
// as documented and defined in npapi.h, without needing to
|
||||
// install those functions in the function table or worry about
|
||||
// setting up globals for 68K plugins.
|
||||
//
|
||||
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
NPError Private_Initialize(void);
|
||||
void Private_Shutdown(void);
|
||||
NPError Private_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved);
|
||||
NPError Private_Destroy(NPP instance, NPSavedData** save);
|
||||
NPError Private_SetWindow(NPP instance, NPWindow* window);
|
||||
NPError Private_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype);
|
||||
NPError Private_DestroyStream(NPP instance, NPStream* stream, NPError reason);
|
||||
int32 Private_WriteReady(NPP instance, NPStream* stream);
|
||||
int32 Private_Write(NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer);
|
||||
void Private_StreamAsFile(NPP instance, NPStream* stream, const char* fname);
|
||||
void Private_Print(NPP instance, NPPrint* platformPrint);
|
||||
int16 Private_HandleEvent(NPP instance, void* event);
|
||||
void Private_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData);
|
||||
jref Private_GetJavaClass(void);
|
||||
|
||||
|
||||
NPError Private_Initialize(void)
|
||||
{
|
||||
NPError err;
|
||||
EnterCodeResource();
|
||||
PLUGINDEBUGSTR("\pInitialize;g;");
|
||||
err = NPP_Initialize();
|
||||
ExitCodeResource();
|
||||
return err;
|
||||
}
|
||||
|
||||
void Private_Shutdown(void)
|
||||
{
|
||||
EnterCodeResource();
|
||||
PLUGINDEBUGSTR("\pShutdown;g;");
|
||||
NPP_Shutdown();
|
||||
|
||||
__destroy_global_chain();
|
||||
|
||||
ExitCodeResource();
|
||||
}
|
||||
|
||||
|
||||
NPError Private_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved)
|
||||
{
|
||||
EnterCodeResource();
|
||||
NPError ret = NPP_New(pluginType, instance, mode, argc, argn, argv, saved);
|
||||
PLUGINDEBUGSTR("\pNew;g;");
|
||||
ExitCodeResource();
|
||||
return ret;
|
||||
}
|
||||
|
||||
NPError Private_Destroy(NPP instance, NPSavedData** save)
|
||||
{
|
||||
NPError err;
|
||||
EnterCodeResource();
|
||||
PLUGINDEBUGSTR("\pDestroy;g;");
|
||||
err = NPP_Destroy(instance, save);
|
||||
ExitCodeResource();
|
||||
return err;
|
||||
}
|
||||
|
||||
NPError Private_SetWindow(NPP instance, NPWindow* window)
|
||||
{
|
||||
NPError err;
|
||||
EnterCodeResource();
|
||||
PLUGINDEBUGSTR("\pSetWindow;g;");
|
||||
err = NPP_SetWindow(instance, window);
|
||||
ExitCodeResource();
|
||||
return err;
|
||||
}
|
||||
|
||||
NPError Private_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype)
|
||||
{
|
||||
NPError err;
|
||||
EnterCodeResource();
|
||||
PLUGINDEBUGSTR("\pNewStream;g;");
|
||||
err = NPP_NewStream(instance, type, stream, seekable, stype);
|
||||
ExitCodeResource();
|
||||
return err;
|
||||
}
|
||||
|
||||
int32 Private_WriteReady(NPP instance, NPStream* stream)
|
||||
{
|
||||
int32 result;
|
||||
EnterCodeResource();
|
||||
PLUGINDEBUGSTR("\pWriteReady;g;");
|
||||
result = NPP_WriteReady(instance, stream);
|
||||
ExitCodeResource();
|
||||
return result;
|
||||
}
|
||||
|
||||
int32 Private_Write(NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer)
|
||||
{
|
||||
int32 result;
|
||||
EnterCodeResource();
|
||||
PLUGINDEBUGSTR("\pWrite;g;");
|
||||
result = NPP_Write(instance, stream, offset, len, buffer);
|
||||
ExitCodeResource();
|
||||
return result;
|
||||
}
|
||||
|
||||
void Private_StreamAsFile(NPP instance, NPStream* stream, const char* fname)
|
||||
{
|
||||
EnterCodeResource();
|
||||
PLUGINDEBUGSTR("\pStreamAsFile;g;");
|
||||
NPP_StreamAsFile(instance, stream, fname);
|
||||
ExitCodeResource();
|
||||
}
|
||||
|
||||
|
||||
NPError Private_DestroyStream(NPP instance, NPStream* stream, NPError reason)
|
||||
{
|
||||
NPError err;
|
||||
EnterCodeResource();
|
||||
PLUGINDEBUGSTR("\pDestroyStream;g;");
|
||||
err = NPP_DestroyStream(instance, stream, reason);
|
||||
ExitCodeResource();
|
||||
return err;
|
||||
}
|
||||
|
||||
int16 Private_HandleEvent(NPP instance, void* event)
|
||||
{
|
||||
int16 result;
|
||||
EnterCodeResource();
|
||||
PLUGINDEBUGSTR("\pHandleEvent;g;");
|
||||
result = NPP_HandleEvent(instance, event);
|
||||
ExitCodeResource();
|
||||
return result;
|
||||
}
|
||||
|
||||
void Private_Print(NPP instance, NPPrint* platformPrint)
|
||||
{
|
||||
EnterCodeResource();
|
||||
PLUGINDEBUGSTR("\pPrint;g;");
|
||||
NPP_Print(instance, platformPrint);
|
||||
ExitCodeResource();
|
||||
}
|
||||
|
||||
void Private_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData)
|
||||
{
|
||||
EnterCodeResource();
|
||||
PLUGINDEBUGSTR("\pURLNotify;g;");
|
||||
NPP_URLNotify(instance, url, reason, notifyData);
|
||||
ExitCodeResource();
|
||||
}
|
||||
|
||||
|
||||
jref Private_GetJavaClass(void)
|
||||
{
|
||||
EnterCodeResource();
|
||||
PLUGINDEBUGSTR("\pGetJavaClass;g;");
|
||||
|
||||
jref clazz = NPP_GetJavaClass();
|
||||
ExitCodeResource();
|
||||
if (clazz)
|
||||
{
|
||||
JRIEnv* env = NPN_GetJavaEnv();
|
||||
return (jref)JRI_NewGlobalRef(env, clazz);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void SetUpQD(void);
|
||||
|
||||
void SetUpQD(void)
|
||||
{
|
||||
ProcessSerialNumber PSN;
|
||||
FSSpec myFSSpec;
|
||||
Str63 name;
|
||||
ProcessInfoRec infoRec;
|
||||
OSErr result = noErr;
|
||||
CFragConnectionID connID;
|
||||
Str255 errName;
|
||||
|
||||
//
|
||||
// Memorize the plugin¹s resource file
|
||||
// refnum for later use.
|
||||
//
|
||||
gResFile = CurResFile();
|
||||
|
||||
//
|
||||
// Ask the system if CFM is available.
|
||||
//
|
||||
long response;
|
||||
OSErr err = Gestalt(gestaltCFMAttr, &response);
|
||||
Boolean hasCFM = BitTst(&response, 31-gestaltCFMPresent);
|
||||
|
||||
if (hasCFM)
|
||||
{
|
||||
//
|
||||
// GetProcessInformation takes a process serial number and
|
||||
// will give us back the name and FSSpec of the application.
|
||||
// See the Process Manager in IM.
|
||||
//
|
||||
infoRec.processInfoLength = sizeof(ProcessInfoRec);
|
||||
infoRec.processName = name;
|
||||
infoRec.processAppSpec = &myFSSpec;
|
||||
|
||||
PSN.highLongOfPSN = 0;
|
||||
PSN.lowLongOfPSN = kCurrentProcess;
|
||||
|
||||
result = GetProcessInformation(&PSN, &infoRec);
|
||||
if (result != noErr)
|
||||
PLUGINDEBUGSTR("\pFailed in GetProcessInformation");
|
||||
}
|
||||
else
|
||||
//
|
||||
// If no CFM installed, assume it must be a 68K app.
|
||||
//
|
||||
result = -1;
|
||||
|
||||
if (result == noErr)
|
||||
{
|
||||
//
|
||||
// Now that we know the app name and FSSpec, we can call GetDiskFragment
|
||||
// to get a connID to use in a subsequent call to FindSymbol (it will also
|
||||
// return the address of ³main² in app, which we ignore). If GetDiskFragment
|
||||
// returns an error, we assume the app must be 68K.
|
||||
//
|
||||
Ptr mainAddr;
|
||||
result = GetDiskFragment(infoRec.processAppSpec, 0L, 0L, infoRec.processName,
|
||||
kReferenceCFrag, &connID, (Ptr*)&mainAddr, errName);
|
||||
}
|
||||
|
||||
if (result == noErr)
|
||||
{
|
||||
//
|
||||
// The app is a PPC code fragment, so call FindSymbol
|
||||
// to get the exported ³qd² symbol so we can access its
|
||||
// QuickDraw globals.
|
||||
//
|
||||
CFragSymbolClass symClass;
|
||||
result = FindSymbol(connID, "\pqd", (Ptr*)&gQDPtr, &symClass);
|
||||
if (result != noErr)
|
||||
PLUGINDEBUGSTR("\pFailed in FindSymbol qd");
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// The app is 68K, so use its A5 to compute the address
|
||||
// of its QuickDraw globals.
|
||||
//
|
||||
gQDPtr = (QDGlobals*)(*((long*)SetCurrentA5()) - (sizeof(QDGlobals) - sizeof(GrafPtr)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
NPError main(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs, NPP_ShutdownUPP* unloadUpp);
|
||||
|
||||
#pragma export on
|
||||
|
||||
#if GENERATINGCFM
|
||||
RoutineDescriptor mainRD = BUILD_ROUTINE_DESCRIPTOR(uppNPP_MainEntryProcInfo, main);
|
||||
#endif
|
||||
|
||||
#pragma export off
|
||||
|
||||
|
||||
NPError main(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs, NPP_ShutdownUPP* unloadUpp)
|
||||
{
|
||||
EnterCodeResource();
|
||||
PLUGINDEBUGSTR("\pmain");
|
||||
|
||||
NPError err = NPERR_NO_ERROR;
|
||||
|
||||
//
|
||||
// Ensure that everything Netscape passed us is valid!
|
||||
//
|
||||
if ((nsTable == NULL) || (pluginFuncs == NULL) || (unloadUpp == NULL))
|
||||
err = NPERR_INVALID_FUNCTABLE_ERROR;
|
||||
|
||||
//
|
||||
// Check the ³major² version passed in Netscape¹s function table.
|
||||
// We won¹t load if the major version is newer than what we expect.
|
||||
// Also check that the function tables passed in are big enough for
|
||||
// all the functions we need (they could be bigger, if Netscape added
|
||||
// new APIs, but that¹s OK with us -- we¹ll just ignore them).
|
||||
//
|
||||
if (err == NPERR_NO_ERROR)
|
||||
{
|
||||
if ((nsTable->version >> 8) > NP_VERSION_MAJOR) // Major version is in high byte
|
||||
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
// if (nsTable->size < sizeof(NPNetscapeFuncs))
|
||||
// err = NPERR_INVALID_FUNCTABLE_ERROR;
|
||||
// if (pluginFuncs->size < sizeof(NPPluginFuncs))
|
||||
// err = NPERR_INVALID_FUNCTABLE_ERROR;
|
||||
}
|
||||
|
||||
|
||||
if (err == NPERR_NO_ERROR)
|
||||
{
|
||||
//
|
||||
// Copy all the fields of Netscape¹s function table into our
|
||||
// copy so we can call back into Netscape later. Note that
|
||||
// we need to copy the fields one by one, rather than assigning
|
||||
// the whole structure, because the Netscape function table
|
||||
// could actually be bigger than what we expect.
|
||||
//
|
||||
|
||||
int navMinorVers = nsTable->version & 0xFF;
|
||||
|
||||
gNetscapeFuncs.version = nsTable->version;
|
||||
gNetscapeFuncs.size = nsTable->size;
|
||||
gNetscapeFuncs.posturl = nsTable->posturl;
|
||||
gNetscapeFuncs.geturl = nsTable->geturl;
|
||||
gNetscapeFuncs.requestread = nsTable->requestread;
|
||||
gNetscapeFuncs.newstream = nsTable->newstream;
|
||||
gNetscapeFuncs.write = nsTable->write;
|
||||
gNetscapeFuncs.destroystream = nsTable->destroystream;
|
||||
gNetscapeFuncs.status = nsTable->status;
|
||||
gNetscapeFuncs.uagent = nsTable->uagent;
|
||||
gNetscapeFuncs.memalloc = nsTable->memalloc;
|
||||
gNetscapeFuncs.memfree = nsTable->memfree;
|
||||
gNetscapeFuncs.memflush = nsTable->memflush;
|
||||
gNetscapeFuncs.reloadplugins = nsTable->reloadplugins;
|
||||
if( navMinorVers >= NPVERS_HAS_LIVECONNECT )
|
||||
{
|
||||
gNetscapeFuncs.getJavaEnv = nsTable->getJavaEnv;
|
||||
gNetscapeFuncs.getJavaPeer = nsTable->getJavaPeer;
|
||||
}
|
||||
if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
|
||||
{
|
||||
gNetscapeFuncs.geturlnotify = nsTable->geturlnotify;
|
||||
gNetscapeFuncs.posturlnotify = nsTable->posturlnotify;
|
||||
}
|
||||
gNetscapeFuncs.getvalue = nsTable->getvalue;
|
||||
gNetscapeFuncs.setvalue = nsTable->setvalue;
|
||||
gNetscapeFuncs.invalidaterect = nsTable->invalidaterect;
|
||||
gNetscapeFuncs.invalidateregion = nsTable->invalidateregion;
|
||||
gNetscapeFuncs.forceredraw = nsTable->forceredraw;
|
||||
|
||||
// defer static constructors until the global functions are initialized.
|
||||
__InitCode__();
|
||||
|
||||
//
|
||||
// Set up the plugin function table that Netscape will use to
|
||||
// call us. Netscape needs to know about our version and size
|
||||
// and have a UniversalProcPointer for every function we implement.
|
||||
//
|
||||
pluginFuncs->version = (NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR;
|
||||
pluginFuncs->size = sizeof(NPPluginFuncs);
|
||||
pluginFuncs->newp = NewNPP_NewProc(Private_New);
|
||||
pluginFuncs->destroy = NewNPP_DestroyProc(Private_Destroy);
|
||||
pluginFuncs->setwindow = NewNPP_SetWindowProc(Private_SetWindow);
|
||||
pluginFuncs->newstream = NewNPP_NewStreamProc(Private_NewStream);
|
||||
pluginFuncs->destroystream = NewNPP_DestroyStreamProc(Private_DestroyStream);
|
||||
pluginFuncs->asfile = NewNPP_StreamAsFileProc(Private_StreamAsFile);
|
||||
pluginFuncs->writeready = NewNPP_WriteReadyProc(Private_WriteReady);
|
||||
pluginFuncs->write = NewNPP_WriteProc(Private_Write);
|
||||
pluginFuncs->print = NewNPP_PrintProc(Private_Print);
|
||||
pluginFuncs->event = NewNPP_HandleEventProc(Private_HandleEvent);
|
||||
if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
|
||||
{
|
||||
pluginFuncs->urlnotify = NewNPP_URLNotifyProc(Private_URLNotify);
|
||||
}
|
||||
if( navMinorVers >= NPVERS_HAS_LIVECONNECT )
|
||||
{
|
||||
pluginFuncs->javaClass = (JRIGlobalRef) Private_GetJavaClass();
|
||||
}
|
||||
*unloadUpp = NewNPP_ShutdownProc(Private_Shutdown);
|
||||
SetUpQD();
|
||||
err = Private_Initialize();
|
||||
}
|
||||
|
||||
ExitCodeResource();
|
||||
return err;
|
||||
}
|
|
@ -1,150 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
nsLiveConnect.cpp
|
||||
*/
|
||||
|
||||
#include "nsLiveconnect.h"
|
||||
#include "MRJMonitor.h"
|
||||
#include "MRJPlugin.h"
|
||||
#include "nsIPluginManager.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
extern nsIPluginManager* thePluginManager;
|
||||
|
||||
const InterfaceInfo nsLiveconnect::sInterfaces[] = {
|
||||
{ NS_ILIVECONNECT_IID, INTERFACE_OFFSET(nsLiveconnect, nsILiveconnect) },
|
||||
{ NS_IPLUGINSTREAMLISTENER_IID, INTERFACE_OFFSET(nsLiveconnect, nsIPluginStreamListener) },
|
||||
};
|
||||
const UInt32 nsLiveconnect::kInterfaceCount = sizeof(sInterfaces) / sizeof(InterfaceInfo);
|
||||
|
||||
nsLiveconnect::nsLiveconnect()
|
||||
: SupportsMixin(this, sInterfaces, kInterfaceCount),
|
||||
mJavaScriptMonitor(NULL), mScript(NULL), mResult(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
nsLiveconnect::~nsLiveconnect()
|
||||
{
|
||||
if (mJavaScriptMonitor != NULL)
|
||||
delete mJavaScriptMonitor;
|
||||
}
|
||||
|
||||
static char* u2c(const jchar *ustr, jsize length)
|
||||
{
|
||||
char* result = new char[length + 1];
|
||||
if (result != NULL) {
|
||||
char* cstr = result;
|
||||
while (length-- > 0) {
|
||||
*cstr++ = (char) *ustr++;
|
||||
}
|
||||
*cstr = '\0';
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
const char* kJavaScriptPrefix = "javascript:";
|
||||
|
||||
NS_METHOD
|
||||
nsLiveconnect::Eval(JNIEnv *env, jsobject obj, const jchar *script, jsize length, void* principalsArray[],
|
||||
int numPrincipals, nsISupports *securitySupports, jobject *outResult)
|
||||
{
|
||||
MRJPluginInstance* pluginInstance = (MRJPluginInstance*) obj;
|
||||
nsIPluginStreamListener* listener = this;
|
||||
|
||||
if (mJavaScriptMonitor == NULL)
|
||||
mJavaScriptMonitor = new MRJMonitor(pluginInstance->getSession());
|
||||
|
||||
mJavaScriptMonitor->enter();
|
||||
|
||||
while (mScript != NULL) {
|
||||
// some other thread is evaluating a script.
|
||||
mJavaScriptMonitor->wait();
|
||||
}
|
||||
|
||||
// convert the script to ASCII, construct a "javascript:" URL.
|
||||
char* cscript = u2c(script, length);
|
||||
mScript = new char[strlen(kJavaScriptPrefix) + length + 1];
|
||||
strcpy(mScript, kJavaScriptPrefix);
|
||||
strcat(mScript, cscript);
|
||||
delete[] cscript;
|
||||
nsresult result = thePluginManager->GetURL((nsIPluginInstance*)pluginInstance, mScript, NULL, listener);
|
||||
|
||||
// need to block until the result is ready.
|
||||
mJavaScriptMonitor->wait();
|
||||
|
||||
// default result is NULL, in case JavaScript returns undefined value.
|
||||
*outResult = NULL;
|
||||
|
||||
// result should now be ready, convert it to a Java string and return.
|
||||
if (mResult != NULL) {
|
||||
*outResult = env->NewStringUTF(mResult);
|
||||
delete[] mResult;
|
||||
mResult = NULL;
|
||||
}
|
||||
|
||||
delete[] mScript;
|
||||
mScript = NULL;
|
||||
|
||||
mJavaScriptMonitor->notifyAll();
|
||||
|
||||
mJavaScriptMonitor->exit();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsLiveconnect::OnDataAvailable(nsIPluginStreamInfo* pluginInfo, nsIInputStream* input, PRUint32 length)
|
||||
{
|
||||
// hopefully all our data is available.
|
||||
mResult = new char[length + 1];
|
||||
if (mResult != NULL) {
|
||||
if (input->Read(mResult, length, &length) == NS_OK) {
|
||||
// We've delayed processing the applet tag, because we
|
||||
// don't know the location of the curren document yet.
|
||||
mResult[length] = '\0';
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsLiveconnect::OnStopBinding(nsIPluginStreamInfo* pluginInfo, nsresult status)
|
||||
{
|
||||
// the stream has been closed, notify any waiting Java threads.
|
||||
mJavaScriptMonitor->notifyAll();
|
||||
return NS_OK;
|
||||
}
|
|
@ -1,270 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
nsLiveConnect.h
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "nsILiveconnect.h"
|
||||
#include "nsIPluginStreamListener.h"
|
||||
#include "SupportsMixin.h"
|
||||
|
||||
class MRJMonitor;
|
||||
|
||||
class nsLiveconnect : public nsILiveconnect,
|
||||
public nsIPluginStreamListener,
|
||||
private SupportsMixin {
|
||||
public:
|
||||
DECL_SUPPORTS_MIXIN
|
||||
|
||||
nsLiveconnect();
|
||||
virtual ~nsLiveconnect();
|
||||
|
||||
/**
|
||||
* get member of a Native JSObject for a given name.
|
||||
*
|
||||
* @param obj - A Native JS Object.
|
||||
* @param name - Name of a member.
|
||||
* @param pjobj - return parameter as a java object representing
|
||||
* the member. If it is a basic data type it is converted to
|
||||
* a corresponding java type. If it is a NJSObject, then it is
|
||||
* wrapped up as java wrapper netscape.javascript.JSObject.
|
||||
*/
|
||||
NS_IMETHOD
|
||||
GetMember(JNIEnv *env, jsobject jsobj, const jchar *name, jsize length, void* principalsArray[],
|
||||
int numPrincipals, nsISupports *securitySupports, jobject *pjobj)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* get member of a Native JSObject for a given index.
|
||||
*
|
||||
* @param obj - A Native JS Object.
|
||||
* @param slot - Index of a member.
|
||||
* @param pjobj - return parameter as a java object representing
|
||||
* the member.
|
||||
*/
|
||||
NS_IMETHOD
|
||||
GetSlot(JNIEnv *env, jsobject jsobj, jint slot, void* principalsArray[],
|
||||
int numPrincipals, nsISupports *securitySupports, jobject *pjobj)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* set member of a Native JSObject for a given name.
|
||||
*
|
||||
* @param obj - A Native JS Object.
|
||||
* @param name - Name of a member.
|
||||
* @param jobj - Value to set. If this is a basic data type, it is converted
|
||||
* using standard JNI calls but if it is a wrapper to a JSObject
|
||||
* then a internal mapping is consulted to convert to a NJSObject.
|
||||
*/
|
||||
NS_IMETHOD
|
||||
SetMember(JNIEnv *env, jsobject jsobj, const jchar* name, jsize length, jobject jobj, void* principalsArray[],
|
||||
int numPrincipals, nsISupports *securitySupports)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* set member of a Native JSObject for a given index.
|
||||
*
|
||||
* @param obj - A Native JS Object.
|
||||
* @param index - Index of a member.
|
||||
* @param jobj - Value to set. If this is a basic data type, it is converted
|
||||
* using standard JNI calls but if it is a wrapper to a JSObject
|
||||
* then a internal mapping is consulted to convert to a NJSObject.
|
||||
*/
|
||||
NS_IMETHOD
|
||||
SetSlot(JNIEnv *env, jsobject jsobj, jint slot, jobject jobj, void* principalsArray[],
|
||||
int numPrincipals, nsISupports *securitySupports)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* remove member of a Native JSObject for a given name.
|
||||
*
|
||||
* @param obj - A Native JS Object.
|
||||
* @param name - Name of a member.
|
||||
*/
|
||||
NS_IMETHOD
|
||||
RemoveMember(JNIEnv *env, jsobject jsobj, const jchar* name, jsize length, void* principalsArray[],
|
||||
int numPrincipals, nsISupports *securitySupports)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* call a method of Native JSObject.
|
||||
*
|
||||
* @param obj - A Native JS Object.
|
||||
* @param name - Name of a method.
|
||||
* @param jobjArr - Array of jobjects representing parameters of method being caled.
|
||||
* @param pjobj - return value.
|
||||
*/
|
||||
NS_IMETHOD
|
||||
Call(JNIEnv *env, jsobject jsobj, const jchar* name, jsize length, jobjectArray jobjArr, void* principalsArray[],
|
||||
int numPrincipals, nsISupports *securitySupports, jobject *pjobj)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluate a script with a Native JS Object representing scope.
|
||||
*
|
||||
* @param obj - A Native JS Object.
|
||||
* @param principalsArray - Array of principals to be used to compare privileges.
|
||||
* @param numPrincipals - Number of principals being passed.
|
||||
* @param script - Script to be executed.
|
||||
* @param pjobj - return value.
|
||||
*/
|
||||
NS_IMETHOD
|
||||
Eval(JNIEnv *env, jsobject obj, const jchar *script, jsize length, void* principalsArray[],
|
||||
int numPrincipals, nsISupports *securitySupports, jobject *outResult);
|
||||
|
||||
/**
|
||||
* Get the window object for a plugin instance.
|
||||
*
|
||||
* @param pJavaObject - Either a jobject or a pointer to a plugin instance
|
||||
* representing the java object.
|
||||
* @param pjobj - return value. This is a native js object
|
||||
* representing the window object of a frame
|
||||
* in which a applet/bean resides.
|
||||
*/
|
||||
NS_IMETHOD
|
||||
GetWindow(JNIEnv *env, void *pJavaObject, void* principalsArray[],
|
||||
int numPrincipals, nsISupports *securitySupports, jsobject *pobj)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finalize a JSObject instance.
|
||||
*
|
||||
* @param env - JNIEnv on which the call is being made.
|
||||
* @param obj - A Native JS Object.
|
||||
*/
|
||||
NS_IMETHOD
|
||||
FinalizeJSObject(JNIEnv *env, jsobject jsobj)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a JSObject to a string.
|
||||
*
|
||||
* @param env - JNIEnv on which the call is being made.
|
||||
* @param obj - A Native JS Object.
|
||||
* @param jstring - Return value as a jstring representing a JS object.
|
||||
*/
|
||||
NS_IMETHOD
|
||||
ToString(JNIEnv *env, jsobject obj, jstring *pjstring)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
// nsIPluginStreamListener implementation.
|
||||
|
||||
/**
|
||||
* Notify the observer that the URL has started to load. This method is
|
||||
* called only once, at the beginning of a URL load.<BR><BR>
|
||||
*
|
||||
* @return The return value is currently ignored. In the future it may be
|
||||
* used to cancel the URL load..
|
||||
*/
|
||||
NS_IMETHOD
|
||||
OnStartBinding(nsIPluginStreamInfo* pluginInfo)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify the client that data is available in the input stream. This
|
||||
* method is called whenver data is written into the input stream by the
|
||||
* networking library...<BR><BR>
|
||||
*
|
||||
* @param aIStream The input stream containing the data. This stream can
|
||||
* be either a blocking or non-blocking stream.
|
||||
* @param length The amount of data that was just pushed into the stream.
|
||||
* @return The return value is currently ignored.
|
||||
*/
|
||||
NS_IMETHOD
|
||||
OnDataAvailable(nsIPluginStreamInfo* pluginInfo, nsIInputStream* input, PRUint32 length);
|
||||
|
||||
NS_IMETHOD
|
||||
OnFileAvailable(nsIPluginStreamInfo* pluginInfo, const char* fileName)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify the observer that the URL has finished loading. This method is
|
||||
* called once when the networking library has finished processing the
|
||||
* URL transaction initiatied via the nsINetService::Open(...) call.<BR><BR>
|
||||
*
|
||||
* This method is called regardless of whether the URL loaded successfully.<BR><BR>
|
||||
*
|
||||
* @param status Status code for the URL load.
|
||||
* @param msg A text string describing the error.
|
||||
* @return The return value is currently ignored.
|
||||
*/
|
||||
NS_IMETHOD
|
||||
OnStopBinding(nsIPluginStreamInfo* pluginInfo, nsresult status);
|
||||
|
||||
/**
|
||||
* What is this method supposed to do?
|
||||
*/
|
||||
NS_IMETHOD
|
||||
GetStreamType(nsPluginStreamType *result)
|
||||
{
|
||||
*result = nsPluginStreamType_Normal;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
MRJMonitor* mJavaScriptMonitor;
|
||||
char* mScript;
|
||||
char* mResult;
|
||||
|
||||
// support for SupportsMixin.
|
||||
static const InterfaceInfo sInterfaces[];
|
||||
static const UInt32 kInterfaceCount;
|
||||
};
|
Двоичные данные
plugin/oji/MRJ/plugin/netscape.plugin.jar
Двоичные данные
plugin/oji/MRJ/plugin/netscape.plugin.jar
Двоичный файл не отображается.
|
@ -1,118 +0,0 @@
|
|||
/*
|
||||
Console.java
|
||||
|
||||
Simple console that lets an Applet attach to the system console.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
package netscape.console;
|
||||
|
||||
import java.io.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class Console {
|
||||
// Save primordial System streams.
|
||||
private static InputStream in;
|
||||
private static PrintStream out;
|
||||
private static PrintStream err;
|
||||
private static TextArea console;
|
||||
|
||||
private static class Input extends InputStream {
|
||||
byte[] buffer = new byte[1024];
|
||||
int position = 0;
|
||||
int count = 0;
|
||||
|
||||
private void fillBuffer() throws EOFException {
|
||||
// int length = readLine(buffer, 0, buffer.length);
|
||||
int length = 1024;
|
||||
if (length == -1)
|
||||
throw new EOFException();
|
||||
count = length;
|
||||
position = 0;
|
||||
}
|
||||
|
||||
public int read() throws IOException {
|
||||
synchronized(this) {
|
||||
if (position >= count)
|
||||
fillBuffer();
|
||||
return buffer[position++];
|
||||
}
|
||||
}
|
||||
|
||||
public int read(byte[] b, int offset, int length) throws IOException {
|
||||
synchronized(this) {
|
||||
// only fill the buffer at the outset, always returns at most one line of data.
|
||||
if (position >= count)
|
||||
fillBuffer();
|
||||
int initialOffset = offset;
|
||||
while (offset < length && position < count) {
|
||||
b[offset++] = buffer[position++];
|
||||
}
|
||||
return (offset - initialOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class Output extends OutputStream implements Runnable {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
|
||||
public Output() {
|
||||
Thread flusher = new Thread(this, getClass().getName() + "-Flusher");
|
||||
flusher.setDaemon(true);
|
||||
flusher.start();
|
||||
}
|
||||
|
||||
public synchronized void write(int b) throws IOException {
|
||||
this.buffer.append((char)b);
|
||||
notify();
|
||||
}
|
||||
|
||||
public synchronized void write(byte[] buffer, int offset, int count) throws IOException {
|
||||
this.buffer.append(new String(buffer, 0, offset, count));
|
||||
notify();
|
||||
}
|
||||
|
||||
public synchronized void flush() throws IOException {
|
||||
String value = this.buffer.toString();
|
||||
console.append(value);
|
||||
this.buffer.setLength(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* When I/O occurs, it is placed in a StringBuffer, which is flushed in a different thread.
|
||||
* This prevents deadlocks that could occur when the AWT itself is printing messages.
|
||||
*/
|
||||
public synchronized void run() {
|
||||
for (;;) {
|
||||
try {
|
||||
wait();
|
||||
flush();
|
||||
} catch (InterruptedException ie) {
|
||||
} catch (IOException ioe) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class Error extends Output {}
|
||||
|
||||
public static void init(TextArea text) {
|
||||
in = System.in;
|
||||
out = System.out;
|
||||
err = System.err;
|
||||
console = text;
|
||||
|
||||
System.setIn(new Input());
|
||||
System.setOut(new PrintStream(new Output()));
|
||||
System.setErr(new PrintStream(new Error()));
|
||||
}
|
||||
|
||||
public static void dispose() {
|
||||
System.setIn(in);
|
||||
System.setOut(out);
|
||||
System.setErr(err);
|
||||
|
||||
console = null;
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>Java Console</TITLE>
|
||||
</HEAD>
|
||||
|
||||
<BODY BGCOLOR=#FFFFFF MARGINHEIGHT=0 MARGINWIDTH=0>
|
||||
|
||||
<EMBED
|
||||
TYPE = "application/x-java-applet"
|
||||
NAME = "ConsoleApplet"
|
||||
BORDER = "5"
|
||||
WIDTH = "600"
|
||||
HEIGHT = "400"
|
||||
CODE = "netscape/console/ConsoleApplet.class"
|
||||
>
|
||||
</EMBED>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
|
@ -1,100 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
ConsoleApplet.java
|
||||
|
||||
Simple Java console for MRJ.
|
||||
|
||||
A trusted applet that provides simple console services for the MRJ plugin.
|
||||
The applet's classes must be installed in the MRJClasses folder, because
|
||||
it alters the System.in/out/err streams.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
package netscape.console;
|
||||
|
||||
import java.io.*;
|
||||
import java.awt.*;
|
||||
import java.applet.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class ConsoleApplet extends Applet {
|
||||
TextArea console;
|
||||
|
||||
public ConsoleApplet() {
|
||||
setLayout(new BorderLayout());
|
||||
add(console = new TextArea(), BorderLayout.CENTER);
|
||||
|
||||
Panel panel = new Panel();
|
||||
add(panel, BorderLayout.SOUTH);
|
||||
|
||||
// clear console button.
|
||||
ActionListener clearConsoleListener = new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
console.setText("");
|
||||
}
|
||||
};
|
||||
|
||||
Button clearConsole = new Button("Clear");
|
||||
clearConsole.addActionListener(clearConsoleListener);
|
||||
panel.add(clearConsole);
|
||||
|
||||
// dump threads button.
|
||||
ActionListener dumpThreadsListener = new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
dumpThreads();
|
||||
}
|
||||
};
|
||||
|
||||
Button dumpThreads = new Button("Dump Threads");
|
||||
dumpThreads.addActionListener(dumpThreadsListener);
|
||||
panel.add(dumpThreads);
|
||||
}
|
||||
|
||||
public void init() {
|
||||
Console.init(console);
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
Console.dispose();
|
||||
}
|
||||
|
||||
public void dumpThreads() {
|
||||
System.out.println("Dumping threads...");
|
||||
}
|
||||
}
|
Двоичные данные
plugin/oji/MRJ/testing/ConsoleApplet/ConsoleApplet.mcp
Двоичные данные
plugin/oji/MRJ/testing/ConsoleApplet/ConsoleApplet.mcp
Двоичный файл не отображается.
|
@ -1,14 +0,0 @@
|
|||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>Launching the Java Console.</TITLE>
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
|
||||
<SCRIPT>
|
||||
window.open("ConsoleApplet.html", "__MRJ_JAVA_CONSOLE__", "resizable=no,width=600,height=400");
|
||||
window.history.back();
|
||||
</SCRIPT>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
|
@ -1,2 +0,0 @@
|
|||
To use this applet with the MRJ plugin, you must install "ConsoleApplet.jar" in your
|
||||
MRJClasses folder.
|
|
@ -1 +0,0 @@
|
|||
Put an alias to AppletClasses.jar in this directory to test.
|
|
@ -1,41 +0,0 @@
|
|||
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
|
||||
<TITLE>MRJ In A Box</TITLE>
|
||||
|
||||
|
||||
</HEAD>
|
||||
<BODY>
|
||||
<H2>What is MRJ In A Box?</H2>
|
||||
|
||||
Makes a Java applet run with an embed tag.<P>
|
||||
|
||||
<HR>
|
||||
|
||||
<SCRIPT LANGUAGE="JavaScript">
|
||||
|
||||
function codebase()
|
||||
{
|
||||
var url = window.location;
|
||||
var href = url.href;
|
||||
return href.substring(0, href.lastIndexOf("/") + 1);
|
||||
}
|
||||
|
||||
/* <!-- CODEBASE = "&{codebase();};" --> */
|
||||
|
||||
</SCRIPT>
|
||||
|
||||
<EMBED
|
||||
TYPE = "application/x-java-vm"
|
||||
NAME = "TrivialApplet"
|
||||
BORDER = "5"
|
||||
WIDTH = "200"
|
||||
HEIGHT = "200"
|
||||
ARCHIVE = "AppletClasses.jar"
|
||||
CODE = "TrivialApplet.class"
|
||||
URL = "http://home.netscape.com">
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
|
@ -1,18 +0,0 @@
|
|||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>JS Test</TITLE>
|
||||
</HEAD>
|
||||
|
||||
<EMBED
|
||||
TYPE = "application/x-java-vm"
|
||||
NAME = "JSApplet"
|
||||
BORDER = "5"
|
||||
WIDTH = "400"
|
||||
HEIGHT = "48"
|
||||
ARCHIVE = "JSApplet.jar"
|
||||
CODE = "JSApplet.class"
|
||||
>
|
||||
</EMBED>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
|
@ -1,95 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
JSApplet.java
|
||||
|
||||
Tests JSObject.eval.
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
import java.awt.*;
|
||||
import java.applet.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
import netscape.javascript.JSObject;
|
||||
|
||||
public class JSApplet extends Applet {
|
||||
TextField text;
|
||||
|
||||
public void init() {
|
||||
setLayout(new BorderLayout());
|
||||
add(text = new TextField(), BorderLayout.CENTER);
|
||||
|
||||
Panel panel = new Panel();
|
||||
add(panel, BorderLayout.SOUTH);
|
||||
|
||||
// eval button.
|
||||
ActionListener evalListener = new ActionListener() {
|
||||
JSObject window;
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (window == null)
|
||||
window = JSObject.getWindow(JSApplet.this);
|
||||
Object result = window.eval(text.getText());
|
||||
if (result != null)
|
||||
System.out.println(result);
|
||||
text.selectAll();
|
||||
}
|
||||
};
|
||||
|
||||
Button evalButton = new Button("eval");
|
||||
evalButton.addActionListener(evalListener);
|
||||
text.addActionListener(evalListener);
|
||||
panel.add(evalButton);
|
||||
|
||||
// clear button.
|
||||
ActionListener clearConsoleListener = new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
text.setText("");
|
||||
}
|
||||
};
|
||||
|
||||
Button clearConsole = new Button("clear");
|
||||
clearConsole.addActionListener(clearConsoleListener);
|
||||
panel.add(clearConsole);
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
}
|
||||
}
|
Двоичные данные
plugin/oji/MRJ/testing/JSApplet/JSApplet.mcp
Двоичные данные
plugin/oji/MRJ/testing/JSApplet/JSApplet.mcp
Двоичный файл не отображается.
|
@ -1,35 +0,0 @@
|
|||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>Testing LiveConnect</TITLE>
|
||||
</HEAD>
|
||||
|
||||
<SCRIPT LANGUAGE="JavaScript">
|
||||
|
||||
var System = java.lang.System;
|
||||
var StringPtr = Packages.com.apple.MacOS.StringPtr;
|
||||
|
||||
function writeln(text)
|
||||
{
|
||||
document.write("<P>", text, "</P>");
|
||||
}
|
||||
|
||||
function println(text)
|
||||
{
|
||||
var pstr = new StringPtr(text);
|
||||
pstr.DebugStr();
|
||||
// System.out.println(text);
|
||||
writeln(text);
|
||||
}
|
||||
|
||||
function helloWorld()
|
||||
{
|
||||
println("hello Gecko.");
|
||||
}
|
||||
|
||||
helloWorld();
|
||||
|
||||
</SCRIPT>
|
||||
|
||||
<BODY onload="helloWorld();">
|
||||
</BODY>
|
||||
</HTML>
|
|
@ -1,32 +0,0 @@
|
|||
import java.awt.event.*;
|
||||
import java.applet.*;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class TestApplet extends JApplet implements ActionListener
|
||||
{
|
||||
TestFrame tFrame;
|
||||
|
||||
public void init()
|
||||
{
|
||||
getContentPane().setLayout(new BorderLayout());
|
||||
TestPanel tPanel = new TestPanel();
|
||||
getContentPane().add("Center", tPanel);
|
||||
|
||||
Button showBtn = new Button("Show");
|
||||
showBtn.addActionListener(this);
|
||||
Panel bottomPanel = new Panel();
|
||||
bottomPanel.setLayout(new FlowLayout());
|
||||
bottomPanel.add(showBtn);
|
||||
getContentPane().add("South", bottomPanel);
|
||||
|
||||
tFrame = new TestFrame();
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
tFrame.setVisible(true);
|
||||
// tFrame.dispose();
|
||||
}
|
||||
|
||||
}
|
Двоичные данные
plugin/oji/MRJ/testing/SwingApplet/TestApplet.mcp
Двоичные данные
plugin/oji/MRJ/testing/SwingApplet/TestApplet.mcp
Двоичный файл не отображается.
|
@ -1,27 +0,0 @@
|
|||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class TestFrame extends JFrame implements ActionListener
|
||||
{
|
||||
public TestFrame()
|
||||
{
|
||||
Container pane = getContentPane();
|
||||
pane.setLayout(new BorderLayout());
|
||||
TestPanel tPanel = new TestPanel();
|
||||
pane.add("Center", tPanel);
|
||||
Button closeBtn = new Button("Close");
|
||||
closeBtn.addActionListener(this);
|
||||
Panel bottomPanel = new Panel();
|
||||
bottomPanel.setLayout(new FlowLayout());
|
||||
bottomPanel.add(closeBtn);
|
||||
pane.add("South", bottomPanel);
|
||||
pack();
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class TestPanel extends JPanel
|
||||
{
|
||||
public TestPanel()
|
||||
{
|
||||
setLayout(new GridLayout(3,2));
|
||||
for(int ctr=1; ctr<=3; ctr++ )
|
||||
{
|
||||
add( new JLabel("Label " + ctr));
|
||||
add( new JTextField());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<body>
|
||||
<embed
|
||||
TYPE = "application/x-java-vm"
|
||||
NAME = "TestApplet"
|
||||
PLUGINSPAGE = "http://www.mozilla.org/oji/"
|
||||
code="TestApplet.class"
|
||||
archive="TestApplet.jar"
|
||||
width="200"
|
||||
height="100"
|
||||
>
|
||||
</embed>
|
||||
</body>
|
Двоичные данные
plugin/oji/MRJ/testing/TrivialApplet/MyApplet.mcp
Двоичные данные
plugin/oji/MRJ/testing/TrivialApplet/MyApplet.mcp
Двоичный файл не отображается.
|
@ -1,70 +0,0 @@
|
|||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>TrivialApplet</TITLE>
|
||||
</HEAD>
|
||||
|
||||
<SCRIPT LANGUAGE="JavaScript">
|
||||
|
||||
var System = java.lang.System;
|
||||
|
||||
function writeln(text)
|
||||
{
|
||||
document.write("<P>", text, "</P>");
|
||||
}
|
||||
|
||||
function println(text)
|
||||
{
|
||||
System.out.println(text);
|
||||
}
|
||||
|
||||
function examineApplets()
|
||||
{
|
||||
var applets = document.applets;
|
||||
println("applets.length = " + applets.length);
|
||||
}
|
||||
|
||||
function examineTrivialApplet(applet)
|
||||
{
|
||||
// applet.print("url = " + applet.urlField.getText());
|
||||
println("url = " + applet.urlField.getText());
|
||||
}
|
||||
|
||||
</SCRIPT>
|
||||
|
||||
<!-- <BODY onload="examineApplets();"> -->
|
||||
|
||||
<BODY>
|
||||
|
||||
<P>
|
||||
<APPLET
|
||||
ARCHIVE="AppletClasses.jar"
|
||||
NAME="TrivialApplet"
|
||||
CODE="TrivialApplet.class"
|
||||
MAYSCRIPT="true"
|
||||
WIDTH=200 HEIGHT=200>
|
||||
<PARAM NAME="URL" VALUE="http://home.netscape.com">
|
||||
</APPLET>
|
||||
</P>
|
||||
|
||||
<HR>
|
||||
|
||||
<a href="TrivialApplet.java">The source.</a>
|
||||
|
||||
<form>
|
||||
|
||||
<P>
|
||||
|
||||
<input type=button
|
||||
onclick="examineApplets();"
|
||||
value="examineApplets()">
|
||||
|
||||
<input type=button
|
||||
onclick="examineTrivialApplet(document.TrivialApplet);"
|
||||
value="examineTrivialApplet()">
|
||||
|
||||
</P>
|
||||
|
||||
</form>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
|
@ -1,207 +0,0 @@
|
|||
/*
|
||||
Trivial applet that displays a string - 4/96 PNL
|
||||
*/
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.applet.Applet;
|
||||
import java.net.URL;
|
||||
import java.net.MalformedURLException;
|
||||
|
||||
import netscape.javascript.JSObject;
|
||||
|
||||
class AboutBox extends Frame {
|
||||
AboutBox(Menu aboutMenu, ActionListener[] actionListeners) {
|
||||
super("About Applet");
|
||||
|
||||
addWindowListener(
|
||||
new WindowAdapter() {
|
||||
public void windowClosing(WindowEvent e) {
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
|
||||
Button okButton = new Button("OK");
|
||||
okButton.addActionListener(
|
||||
new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
|
||||
// Annoying use of flow layout managers.
|
||||
Panel labelPanel = new Panel();
|
||||
Panel buttonPanel = new Panel();
|
||||
Panel fieldPanel = new Panel();
|
||||
|
||||
labelPanel.add(new Label("This applet's about box..."));
|
||||
buttonPanel.add(okButton);
|
||||
|
||||
fieldPanel.add(new TextField(20));
|
||||
fieldPanel.add(new TextField(20));
|
||||
|
||||
add(labelPanel, "North");
|
||||
add(buttonPanel, "Center");
|
||||
add(fieldPanel, "South");
|
||||
|
||||
// test menu bar stuff.
|
||||
MenuBar menuBar = new MenuBar();
|
||||
aboutMenu = (Menu) cloneMenu(aboutMenu);
|
||||
for (int i = 0; i < actionListeners.length; i++)
|
||||
aboutMenu.getItem(i).addActionListener(actionListeners[i]);
|
||||
menuBar.add(aboutMenu);
|
||||
setMenuBar(menuBar);
|
||||
|
||||
pack();
|
||||
show();
|
||||
}
|
||||
|
||||
private MenuItem cloneMenu(MenuItem oldItem) {
|
||||
if (oldItem instanceof Menu) {
|
||||
Menu oldMenu = (Menu) oldItem;
|
||||
Menu newMenu = new Menu(oldMenu.getLabel());
|
||||
int count = oldMenu.getItemCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
newMenu.add(cloneMenu(oldMenu.getItem(i)));
|
||||
}
|
||||
return newMenu;
|
||||
} else {
|
||||
MenuItem newItem = new MenuItem(oldItem.getLabel());
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ExceptionThread extends Thread {
|
||||
ExceptionThread() {
|
||||
start();
|
||||
}
|
||||
|
||||
public void run() {
|
||||
throw new Error("this is an error!");
|
||||
}
|
||||
}
|
||||
|
||||
public class TrivialApplet extends Applet {
|
||||
public Button goButton;
|
||||
public Button aboutButton;
|
||||
public TextField urlField;
|
||||
public PopupMenu contextMenu;
|
||||
public Menu aboutMenu;
|
||||
public ActionListener[] actionListeners;
|
||||
private static int appletCount;
|
||||
|
||||
public void init() {
|
||||
++appletCount;
|
||||
|
||||
goButton = new Button("Go");
|
||||
aboutButton = new Button("About");
|
||||
|
||||
String urlText = getParameter("URL");
|
||||
if (urlText == null)
|
||||
urlText = "http://www.apple.com";
|
||||
|
||||
urlField = new TextField(urlText);
|
||||
|
||||
ActionListener goListener =
|
||||
new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
URL location = new URL(urlField.getText());
|
||||
System.out.println("going to URL: " + location);
|
||||
JSObject window = JSObject.getWindow(TrivialApplet.this);
|
||||
if (window != null) {
|
||||
//window.eval("alert('going to location " + location + "');");
|
||||
window.eval("println('" + location + "')");
|
||||
}
|
||||
getAppletContext().showDocument(location, "_new");
|
||||
} catch (MalformedURLException mfue) {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ActionListener aboutListener =
|
||||
new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new AboutBox(aboutMenu, actionListeners);
|
||||
}
|
||||
};
|
||||
|
||||
goButton.addActionListener(goListener);
|
||||
aboutButton.addActionListener(aboutListener);
|
||||
|
||||
add(goButton);
|
||||
add(aboutButton);
|
||||
add(urlField);
|
||||
|
||||
// Try a pop-up menu, and a menu in the menubar.
|
||||
contextMenu = new PopupMenu();
|
||||
aboutMenu = new Menu("About");
|
||||
|
||||
contextMenu.add(newItem("About", aboutListener));
|
||||
aboutMenu.add(newItem("About", aboutListener));
|
||||
|
||||
contextMenu.add(newItem("Go", goListener));
|
||||
aboutMenu.add(newItem("Go", goListener));
|
||||
|
||||
ActionListener errorListener = new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new ExceptionThread();
|
||||
}
|
||||
};
|
||||
contextMenu.add(newItem("Error", errorListener));
|
||||
aboutMenu.add(newItem("Error", errorListener));
|
||||
|
||||
ActionListener[] listeners = { aboutListener, goListener, errorListener };
|
||||
actionListeners = listeners;
|
||||
|
||||
add(contextMenu);
|
||||
|
||||
// add a mouse listener that causes the pop-up to appear appropriately.
|
||||
MouseListener mouseListener = new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
e.consume();
|
||||
contextMenu.show(TrivialApplet.this, e.getX(), e.getY());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
addMouseListener(mouseListener);
|
||||
}
|
||||
|
||||
private MenuItem newItem(String title, ActionListener listener) {
|
||||
MenuItem item = new MenuItem(title);
|
||||
item.addActionListener(listener);
|
||||
return item;
|
||||
}
|
||||
|
||||
private Frame getFrame() {
|
||||
Component p = this;
|
||||
while (p != null && !(p instanceof Frame))
|
||||
p = getParent();
|
||||
return (Frame)p;
|
||||
}
|
||||
|
||||
// public void paint( Graphics g ) {}
|
||||
|
||||
public boolean mouseEnter(Event evt, int x, int y) {
|
||||
showStatus("Welcome!");
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean mouseExit(Event evt, int x, int y) {
|
||||
showStatus("See you later!");
|
||||
return true;
|
||||
}
|
||||
|
||||
public void print(String message) {
|
||||
JSObject window = JSObject.getWindow(this);
|
||||
Object[] args = { message };
|
||||
window.call("println", args);
|
||||
}
|
||||
|
||||
public int getAppletCount() {
|
||||
return appletCount;
|
||||
}
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>TrivialApplets</TITLE>
|
||||
</HEAD>
|
||||
|
||||
<SCRIPT LANGUAGE="JavaScript">
|
||||
|
||||
var System = java.lang.System;
|
||||
var println = System.out.println;
|
||||
|
||||
function writeln(text)
|
||||
{
|
||||
document.write("<P>", text, "</P>");
|
||||
}
|
||||
|
||||
function examineApplets()
|
||||
{
|
||||
var applets = document.applets;
|
||||
println("applets.length = " + applets.length);
|
||||
}
|
||||
|
||||
function examineTrivialApplet(applet)
|
||||
{
|
||||
applet.print("url = " + applet.urlField.getText());
|
||||
applet.print("appletCount = " + applet.getAppletCount());
|
||||
}
|
||||
|
||||
</SCRIPT>
|
||||
|
||||
<BODY>
|
||||
|
||||
<HR>
|
||||
|
||||
<APPLET
|
||||
ARCHIVE="AppletClasses.jar"
|
||||
NAME="TrivialApplet_0"
|
||||
CODE="TrivialApplet.class"
|
||||
MAYSCRIPT="true"
|
||||
WIDTH=200 HEIGHT=200>
|
||||
<PARAM NAME="URL" VALUE="http://home.netscape.com">
|
||||
</APPLET>
|
||||
|
||||
<HR>
|
||||
|
||||
<APPLET
|
||||
ARCHIVE="AppletClasses.jar"
|
||||
NAME="TrivialApplet_1"
|
||||
CODE="TrivialApplet.class"
|
||||
MAYSCRIPT="true"
|
||||
WIDTH=200 HEIGHT=200>
|
||||
<PARAM NAME="URL" VALUE="http://www.apple.com">
|
||||
</APPLET>
|
||||
|
||||
<HR>
|
||||
|
||||
<P>
|
||||
<a href="TrivialApplet.java">The source.</a>
|
||||
</P>
|
||||
|
||||
<FORM>
|
||||
|
||||
<INPUT type=button
|
||||
onclick="examineApplets();"
|
||||
value="examineApplets()">
|
||||
|
||||
<INPUT type=button
|
||||
onclick="examineTrivialApplet(document.applets[0]);"
|
||||
value="examineTrivialApplet(0)">
|
||||
|
||||
<INPUT type=button
|
||||
onclick="examineTrivialApplet(document.applets[1]);"
|
||||
value="examineTrivialApplet(1)">
|
||||
|
||||
</FORM>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
|
@ -1,393 +0,0 @@
|
|||
/*
|
||||
File: JavaEmbedding/JavaApplet.h
|
||||
|
||||
Contains: interface to embedding a Java Applet in a Carbon Control
|
||||
|
||||
Version: JavaEmbedding-3~36
|
||||
|
||||
Copyright: © 2000-2001 by Apple Computer, Inc., all rights reserved.
|
||||
|
||||
Bugs?: For bug reports, consult the following page on
|
||||
the World Wide Web:
|
||||
|
||||
http://developer.apple.com/bugreporter/
|
||||
|
||||
*/
|
||||
#ifndef __JAVAAPPLET__
|
||||
#define __JAVAAPPLET__
|
||||
|
||||
#if __MACHO__
|
||||
#ifndef __CORESERVICES__
|
||||
#include <CoreServices/CoreServices.h>
|
||||
#endif
|
||||
|
||||
#ifndef __JAVACONTROL__
|
||||
#include <JavaEmbedding/JavaControl.h>
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#ifndef __CFURL__
|
||||
#include <CFURL.h>
|
||||
#endif
|
||||
|
||||
#ifndef __JAVACONTROL__
|
||||
#include <JavaControl.h>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if PRAGMA_ONCE
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if PRAGMA_STRUCT_ALIGN
|
||||
#pragma options align=mac68k
|
||||
#elif PRAGMA_STRUCT_PACKPUSH
|
||||
#pragma pack(push, 2)
|
||||
#elif PRAGMA_STRUCT_PACK
|
||||
#pragma pack(2)
|
||||
#endif
|
||||
|
||||
#if PRAGMA_ENUM_ALWAYSINT
|
||||
#if defined(__fourbyteints__) && !__fourbyteints__
|
||||
#define __JAVAAPPLET__RESTORE_TWOBYTEINTS
|
||||
#pragma fourbyteints on
|
||||
#endif
|
||||
#pragma enumsalwaysint on
|
||||
#elif PRAGMA_ENUM_OPTIONS
|
||||
#pragma option enum=int
|
||||
#elif PRAGMA_ENUM_PACK
|
||||
#if __option(pack_enums)
|
||||
#define __JAVAAPPLET__RESTORE_PACKED_ENUMS
|
||||
#pragma options(!pack_enums)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* AppletDescriptor
|
||||
*
|
||||
* Discussion:
|
||||
* The structure for describing applet. This is used as the
|
||||
* definition of the applet to create when you call CreateJavaApplet.
|
||||
*/
|
||||
struct AppletDescriptor {
|
||||
CFURLRef docBase;
|
||||
CFURLRef codeBase;
|
||||
|
||||
/*
|
||||
* The attributes found in the <applet ...> tag formatted as a
|
||||
* CFDictionary of CFStrings. For attributes like height and width
|
||||
* they should be in screen coordinates. some Applets define them as
|
||||
* % (for example 90%) and should be converted to pixels before put
|
||||
* into the dictionary.
|
||||
*/
|
||||
CFDictionaryRef htmlAttrs;
|
||||
|
||||
/*
|
||||
* The parameters to the applet formatted as a CFDictionary of
|
||||
* CFStrings. These are typically found in <param ...> tags inside of
|
||||
* the applet tag.
|
||||
*/
|
||||
CFDictionaryRef appletParams;
|
||||
};
|
||||
typedef struct AppletDescriptor AppletDescriptor;
|
||||
|
||||
/*
|
||||
* AppletArena
|
||||
*
|
||||
* Discussion:
|
||||
* This is an opaque type that represents an AppletArena - an applet
|
||||
* arena represents a single classloader, so all applets that share
|
||||
* an arena share a common classloader.
|
||||
*/
|
||||
typedef struct OpaqueAppletArena* AppletArena;
|
||||
/*
|
||||
kUniqueArena is the value to pass to CreateJavaApplet if you want the applet to be created
|
||||
in a unique arena. A unique arena is one which is guaranteed not to be shared with
|
||||
any other applet running in this Java VM. This is the appropriate default value to
|
||||
pass to CreateJavaApplet.
|
||||
*/
|
||||
#define kUniqueArena ((AppletArena)NULL)
|
||||
|
||||
/*
|
||||
* JE_ShowDocumentCallback
|
||||
*
|
||||
* Discussion:
|
||||
* Type of a callback function used for show document (link) message
|
||||
* from an applet.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* applet:
|
||||
* The applet which sent this show document message.
|
||||
*
|
||||
* url:
|
||||
* The url to load.
|
||||
*
|
||||
* windowName:
|
||||
* A string definition of where to open the url. Null means open
|
||||
* in place, other strings are defined in the HTML spec, like
|
||||
* "_top" means the parent window of the applet if it happens to
|
||||
* be in a frame, etc.
|
||||
*
|
||||
* userData:
|
||||
* Data specified when this callback was registered using
|
||||
* RegisterShowDocumentCallback.
|
||||
*/
|
||||
typedef CALLBACK_API_C( void , JE_ShowDocumentCallback )(jobject applet, CFURLRef url, CFStringRef windowName, void *userData);
|
||||
|
||||
/*
|
||||
* JE_SetStatusCallback
|
||||
*
|
||||
* Discussion:
|
||||
* Type of a callback function used for a status message from an
|
||||
* applet.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* applet:
|
||||
* The applet which sent this status message.
|
||||
*
|
||||
* statusMessage:
|
||||
* The message to be displayed.
|
||||
*
|
||||
* userData:
|
||||
* Data specified when this callback was registered using
|
||||
* RegisterStatusCallback.
|
||||
*/
|
||||
typedef CALLBACK_API_C( void , JE_SetStatusCallback )(jobject applet, CFStringRef statusMessage, void *userData);
|
||||
/*
|
||||
* CreateAppletArena()
|
||||
*
|
||||
* Discussion:
|
||||
* Create an applet arena. By default each applet you create will
|
||||
* have its own "arena". By creating an applet arena, and passing
|
||||
* that arena into two or more CreateJavaApplet calls, those applets
|
||||
* will share a single classloader and thus be able to communicate
|
||||
* with each other through static objects.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* outNewArena:
|
||||
* The newly created applet arena.
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.1 and later in Carbon.framework
|
||||
* CarbonLib: not available
|
||||
* Non-Carbon CFM: not available
|
||||
*/
|
||||
extern OSStatus
|
||||
CreateAppletArena(AppletArena * outNewArena);
|
||||
|
||||
|
||||
/*
|
||||
* CreateJavaApplet()
|
||||
*
|
||||
* Discussion:
|
||||
* Creates a java applet from a descriptor.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* env:
|
||||
* The JNI environment for the current thread.
|
||||
*
|
||||
* applet:
|
||||
* A full descriptor of the applet being loaded. See
|
||||
* AppletDescriptor.
|
||||
*
|
||||
* trusted:
|
||||
* Whether this applet should be loaded as trusted.
|
||||
*
|
||||
* arena:
|
||||
* The arena for this applet. If this is set to null then a new
|
||||
* arena will be created. This is the typcial case for applets.
|
||||
*
|
||||
* outJavaFrame:
|
||||
* The applet itself to be used for registering callbacks and
|
||||
* creating controls.
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.1 and later in Carbon.framework
|
||||
* CarbonLib: not available
|
||||
* Non-Carbon CFM: not available
|
||||
*/
|
||||
extern OSStatus
|
||||
CreateJavaApplet(
|
||||
JNIEnv * env,
|
||||
AppletDescriptor applet,
|
||||
Boolean trusted,
|
||||
AppletArena arena, /* can be NULL */
|
||||
jobject * outJavaFrame);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* AppletState
|
||||
*
|
||||
* Summary:
|
||||
* Constants that are passed to SetJavaAppletState.
|
||||
*/
|
||||
|
||||
enum AppletState {
|
||||
kAppletStart = 1, /* Starts the applet processing 3.*/
|
||||
kAppletStop = 2, /* Halts the applet, but it can be started again.*/
|
||||
kAppletDestroy = 4 /* Tears down the applet.*/
|
||||
};
|
||||
typedef enum AppletState AppletState;
|
||||
|
||||
|
||||
/*
|
||||
* SetJavaAppletState()
|
||||
*
|
||||
* Discussion:
|
||||
* Sets the state of the current applet as defined by the applet
|
||||
* spec. Applets can be started and stopped many times, but
|
||||
* destroying them is final.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* env:
|
||||
* The JNI environment for the current VM and thread.
|
||||
*
|
||||
* inAppletFrame:
|
||||
* The applet to register the status callback (from
|
||||
* CreateJavaApplet).
|
||||
*
|
||||
* inNewState:
|
||||
* Host defined data passed into showStatusFunction.
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.1 and later in Carbon.framework
|
||||
* CarbonLib: not available
|
||||
* Non-Carbon CFM: not available
|
||||
*/
|
||||
extern OSStatus
|
||||
SetJavaAppletState(
|
||||
JNIEnv * env,
|
||||
jobject inAppletFrame,
|
||||
AppletState inNewState);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* RegisterStatusCallback()
|
||||
*
|
||||
* Discussion:
|
||||
* Registers your function that will be called to update the
|
||||
* applet's status area. Status typically is put in a web browser as
|
||||
* a text area at the bottom of the page.
|
||||
*
|
||||
* Note that this callback will be called from a preemptive thread,
|
||||
* and if the host application is using cooperative threads they
|
||||
* will need to push this into their own event system in order to
|
||||
* handle this correctly.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* env:
|
||||
* The JNI environment for the current VM and thread.
|
||||
*
|
||||
* inJavaFrame:
|
||||
* The applet to register the status callback (from
|
||||
* CreateJavaApplet).
|
||||
*
|
||||
* showStatusFunction:
|
||||
* The function that will be called when the applet calls
|
||||
* showStatus(...).
|
||||
*
|
||||
* userData:
|
||||
* Host defined data passed into showStatusFunction.
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.1 and later in Carbon.framework
|
||||
* CarbonLib: not available
|
||||
* Non-Carbon CFM: not available
|
||||
*/
|
||||
extern OSStatus
|
||||
RegisterStatusCallback(
|
||||
JNIEnv * env,
|
||||
jobject inJavaFrame,
|
||||
JE_SetStatusCallback showStatusFunction,
|
||||
void * userData);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* RegisterShowDocumentCallback()
|
||||
*
|
||||
* Discussion:
|
||||
* Registers your function that will be called when the applet
|
||||
* behaves like a hyperlink. This will be called to move an
|
||||
* embedding host application to a new URL.
|
||||
*
|
||||
* Note that this callback will be called from a preemptive thread,
|
||||
* and if the host application is using cooperative threads they
|
||||
* will need to push this into their own event system in order to
|
||||
* handle this correctly.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* env:
|
||||
* The JNI environment for the current VM and thread.
|
||||
*
|
||||
* inJavaFrame:
|
||||
* The applet to register the show document callback (from
|
||||
* CreateJavaApplet).
|
||||
*
|
||||
* showDocumentFunction:
|
||||
* The function that will be called when the applet calls
|
||||
* showDocument().
|
||||
*
|
||||
* userData:
|
||||
* Host defined data passed into showDocumentFunction.
|
||||
*
|
||||
* Result:
|
||||
* An operating system status code.
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.1 and later in Carbon.framework
|
||||
* CarbonLib: not available
|
||||
* Non-Carbon CFM: not available
|
||||
*/
|
||||
extern OSStatus
|
||||
RegisterShowDocumentCallback(
|
||||
JNIEnv * env,
|
||||
jobject inJavaFrame,
|
||||
JE_ShowDocumentCallback showDocumentFunction,
|
||||
void * userData);
|
||||
|
||||
|
||||
|
||||
|
||||
#if PRAGMA_ENUM_ALWAYSINT
|
||||
#pragma enumsalwaysint reset
|
||||
#ifdef __JAVAAPPLET__RESTORE_TWOBYTEINTS
|
||||
#pragma fourbyteints off
|
||||
#endif
|
||||
#elif PRAGMA_ENUM_OPTIONS
|
||||
#pragma option enum=reset
|
||||
#elif defined(__JAVAAPPLET__RESTORE_PACKED_ENUMS)
|
||||
#pragma options(pack_enums)
|
||||
#endif
|
||||
|
||||
#if PRAGMA_STRUCT_ALIGN
|
||||
#pragma options align=reset
|
||||
#elif PRAGMA_STRUCT_PACKPUSH
|
||||
#pragma pack(pop)
|
||||
#elif PRAGMA_STRUCT_PACK
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __JAVAAPPLET__ */
|
||||
|
|
@ -1,461 +0,0 @@
|
|||
/*
|
||||
File: JavaEmbedding/JavaControl.h
|
||||
|
||||
Contains: interface to embedding Java code in a Carbon Control
|
||||
|
||||
Version: JavaEmbedding-3~36
|
||||
|
||||
Copyright: © 2000-2001 by Apple Computer, Inc., all rights reserved.
|
||||
|
||||
Bugs?: For bug reports, consult the following page on
|
||||
the World Wide Web:
|
||||
|
||||
http://developer.apple.com/bugreporter/
|
||||
|
||||
*/
|
||||
#ifndef __JAVACONTROL__
|
||||
#define __JAVACONTROL__
|
||||
|
||||
#if __MACHO__
|
||||
#ifndef __HITOOLBOX__
|
||||
#include <HIToolbox/HIToolbox.h>
|
||||
#endif
|
||||
|
||||
#include <JavaVM/jni.h>
|
||||
#else
|
||||
#include <jni.h>
|
||||
#endif
|
||||
|
||||
#if PRAGMA_ONCE
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if PRAGMA_STRUCT_ALIGN
|
||||
#pragma options align=mac68k
|
||||
#elif PRAGMA_STRUCT_PACKPUSH
|
||||
#pragma pack(push, 2)
|
||||
#elif PRAGMA_STRUCT_PACK
|
||||
#pragma pack(2)
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Summary:
|
||||
* JavaControl Embedding errors
|
||||
*
|
||||
* Discussion:
|
||||
* The following are all errors which can be returned from the
|
||||
* routines contained in this file. Most are self explanatory.
|
||||
*/
|
||||
enum {
|
||||
errJavaEmbeddingNotYetImplemented = -9950,
|
||||
errJavaEmbeddingIntializationFailed = -9962, /* previously errClassConstructorNotFound, errClassNotFound, and errMethodNotFound*/
|
||||
errJavaEmbeddingMissingURL = -9955, /* previously errMissingURL*/
|
||||
errJavaEmbeddingCouldNotCreateApplet = -9956, /* previously errCouldNotCreateApplet*/
|
||||
errJavaEmbeddingCouldNotEmbedFrame = -9957, /* previously errCouldNotEmbedFrame */
|
||||
errJavaEmbeddingCouldNotConvertURL = -9958, /* previously errCouldNotConvertURL*/
|
||||
errJavaEmbeddingNotAFrame = -9959, /* previously errNotAFrame*/
|
||||
errJavaEmbeddingControlNotEmbedded = -9960, /* previously errControlNotEmbedded*/
|
||||
errJavaEmbeddingExceptionThrown = -9961 /* previously errExceptionThrown*/
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* MoveAndClipJavaControl()
|
||||
*
|
||||
* Summary:
|
||||
* Positions the control in the containing window, and sets the clip
|
||||
* bounds for drawing.
|
||||
*
|
||||
* Discussion:
|
||||
* All coordinates are local to the host window, and 0,0 is the top
|
||||
* left corner of the content area of the host window - just below
|
||||
* the title bar.
|
||||
* Usually a call to MoveAndClipJavaControl is followed by a call to
|
||||
* DrawJavaControl.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* env:
|
||||
* The JNI Environment for the current thread.
|
||||
*
|
||||
* theControl:
|
||||
* The Java control (applet).
|
||||
*
|
||||
* posX:
|
||||
* The x position of the control.
|
||||
*
|
||||
* posY:
|
||||
* The y position of the control.
|
||||
*
|
||||
* clipX:
|
||||
* The left of the clip region.
|
||||
*
|
||||
* clipY:
|
||||
* The top of the clip region.
|
||||
*
|
||||
* clipWidth:
|
||||
* The width of the clip region. (Notice this is not right, but
|
||||
* width)
|
||||
*
|
||||
* clipHeight:
|
||||
* The height of the clip region. (Notice this is not bottom, but
|
||||
* height)
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.1 and later in Carbon.framework
|
||||
* CarbonLib: not available
|
||||
* Non-Carbon CFM: not available
|
||||
*/
|
||||
extern OSStatus
|
||||
MoveAndClipJavaControl(
|
||||
JNIEnv * env,
|
||||
ControlRef theControl,
|
||||
int posX,
|
||||
int posY,
|
||||
int clipX,
|
||||
int clipY,
|
||||
int clipWidth,
|
||||
int clipHeight);
|
||||
|
||||
|
||||
/*
|
||||
* SizeJavaControl()
|
||||
*
|
||||
* Summary:
|
||||
* Sets the size of the Java control.
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.1 and later in Carbon.framework
|
||||
* CarbonLib: not available
|
||||
* Non-Carbon CFM: not available
|
||||
*/
|
||||
extern OSStatus
|
||||
SizeJavaControl(
|
||||
JNIEnv * env,
|
||||
ControlRef theControl,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
|
||||
/*
|
||||
* ShowHideJavaControl()
|
||||
*
|
||||
* Summary:
|
||||
* Makes a Java control visible or invisible.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* env:
|
||||
* The JNI Environment for the current thread.
|
||||
*
|
||||
* theControl:
|
||||
* The Java control (applet).
|
||||
*
|
||||
* visible:
|
||||
* True shows the control.
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.1 and later in Carbon.framework
|
||||
* CarbonLib: not available
|
||||
* Non-Carbon CFM: not available
|
||||
*/
|
||||
extern OSStatus
|
||||
ShowHideJavaControl(
|
||||
JNIEnv * env,
|
||||
ControlRef theControl,
|
||||
Boolean visible);
|
||||
|
||||
|
||||
/*
|
||||
* StopJavaControlAsyncDrawing()
|
||||
*
|
||||
* Summary:
|
||||
* Stops a Java applet from drawing asynchonously.
|
||||
*
|
||||
* Discussion:
|
||||
* Many applets are used for animation and they draw themselves at
|
||||
* times other than when the control is drawn. In order to handle
|
||||
* things like live resize and scrolling a host app must be able to
|
||||
* suspend asynchronous drawing otherwise a draw may occur before
|
||||
* the host app is able to reposition/reclip the control thus
|
||||
* causing drawing in the wrong location. When async drawing is off
|
||||
* normal paint events in an applet are ignored. Only
|
||||
* DrawJavaControl events are allowed to paint. This allows
|
||||
* temporary fine grained control of when an applet can paint, and
|
||||
* should only be used when needed.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* env:
|
||||
* The JNI Environment for the current thread.
|
||||
*
|
||||
* theControl:
|
||||
* The Java control (applet).
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.1 and later in Carbon.framework
|
||||
* CarbonLib: not available
|
||||
* Non-Carbon CFM: not available
|
||||
*/
|
||||
extern OSStatus
|
||||
StopJavaControlAsyncDrawing(
|
||||
JNIEnv * env,
|
||||
ControlRef theControl);
|
||||
|
||||
|
||||
/*
|
||||
* RestartJavaControlAsyncDrawing()
|
||||
*
|
||||
* Summary:
|
||||
* Allows a Java applet to draw asynchonously.
|
||||
*
|
||||
* Discussion:
|
||||
* This should be called when it is safe again for an applet to draw
|
||||
* asynchronously. See StopJavaControlAsyncDrawing.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* env:
|
||||
* The JNI Environment for the current thread.
|
||||
*
|
||||
* theControl:
|
||||
* The Java control (applet).
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.1 and later in Carbon.framework
|
||||
* CarbonLib: not available
|
||||
* Non-Carbon CFM: not available
|
||||
*/
|
||||
extern OSStatus
|
||||
RestartJavaControlAsyncDrawing(
|
||||
JNIEnv * env,
|
||||
ControlRef theControl);
|
||||
|
||||
|
||||
/*
|
||||
* DrawJavaControl()
|
||||
*
|
||||
* Summary:
|
||||
* Causes a Java control that to be drawn.
|
||||
*
|
||||
* Discussion:
|
||||
* This should be called whenever the host app needs the
|
||||
* applet/control to be redrawn. In the case where Async drawing is
|
||||
* paused, DrawJavaControl will still cause the applet to draw. So
|
||||
* if the host app is stopping async drawing for something like live
|
||||
* scrolling, if there are convenient times the host app should call
|
||||
* DrawJavaControl (usually after a call to MoveAndClipJavaControl)
|
||||
* to provide some feedback to the user.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* env:
|
||||
* The JNI Environment for the current thread.
|
||||
*
|
||||
* theControl:
|
||||
* The corresponding Java control (applet) that is to be drawn.
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.1 and later in Carbon.framework
|
||||
* CarbonLib: not available
|
||||
* Non-Carbon CFM: not available
|
||||
*/
|
||||
extern OSStatus
|
||||
DrawJavaControl(
|
||||
JNIEnv * env,
|
||||
ControlRef theControl);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
========================================================================================
|
||||
UTILITY API - functions to determine the status of a window or control
|
||||
========================================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
* GetJavaWindowFromWindow()
|
||||
*
|
||||
* Discussion:
|
||||
* Given a native Carbon window this returns the corresponding Java
|
||||
* window.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* env:
|
||||
* The JNI Environment for the current thread.
|
||||
*
|
||||
* inMacWindow:
|
||||
* A reference to a native window.
|
||||
*
|
||||
* outJavaWindow:
|
||||
* The corresponding Java window.
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.1 and later in Carbon.framework
|
||||
* CarbonLib: not available
|
||||
* Non-Carbon CFM: not available
|
||||
*/
|
||||
extern OSStatus
|
||||
GetJavaWindowFromWindow(
|
||||
JNIEnv * env,
|
||||
WindowRef inMacWindow,
|
||||
jobject * outJavaWindow);
|
||||
|
||||
|
||||
/*
|
||||
* GetWindowFromJavaWindow()
|
||||
*
|
||||
* Discussion:
|
||||
* Given a Java window this returns the corresponding native Carbon
|
||||
* window.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* env:
|
||||
* The JNI Environment for the current thread.
|
||||
*
|
||||
* inJavaWindow:
|
||||
* A reference to a Java window.
|
||||
*
|
||||
* outMacWindow:
|
||||
* The corresponding native window.
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.1 and later in Carbon.framework
|
||||
* CarbonLib: not available
|
||||
* Non-Carbon CFM: not available
|
||||
*/
|
||||
extern OSStatus
|
||||
GetWindowFromJavaWindow(
|
||||
JNIEnv * env,
|
||||
jobject inJavaWindow,
|
||||
WindowRef * outMacWindow);
|
||||
|
||||
|
||||
/*
|
||||
* GetJavaFrameFromControl()
|
||||
*
|
||||
* Discussion:
|
||||
* Given an embedded control this returns the corresponding Java
|
||||
* applet frame.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* env:
|
||||
* The JNI Environment for the current thread.
|
||||
*
|
||||
* inMacControl:
|
||||
* A reference to the control for the applet.
|
||||
*
|
||||
* outJavaFrame:
|
||||
* The applet reference.
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.1 and later in Carbon.framework
|
||||
* CarbonLib: not available
|
||||
* Non-Carbon CFM: not available
|
||||
*/
|
||||
extern OSStatus
|
||||
GetJavaFrameFromControl(
|
||||
JNIEnv * env,
|
||||
ControlRef inMacControl,
|
||||
jobject * outJavaFrame);
|
||||
|
||||
|
||||
/*
|
||||
* GetControlFromJavaFrame()
|
||||
*
|
||||
* Discussion:
|
||||
* Given a Java applet frame reference this returns the embedded
|
||||
* control.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* env:
|
||||
* The JNI Environment for the current thread.
|
||||
*
|
||||
* inJavaFrame:
|
||||
* The applet reference obtained from CreateJavaApplet.
|
||||
*
|
||||
* outMacControl:
|
||||
* A reference to the control for the applet.
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.1 and later in Carbon.framework
|
||||
* CarbonLib: not available
|
||||
* Non-Carbon CFM: not available
|
||||
*/
|
||||
extern OSStatus
|
||||
GetControlFromJavaFrame(
|
||||
JNIEnv * env,
|
||||
jobject inJavaFrame,
|
||||
ControlRef * outMacControl);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* CreateJavaControl()
|
||||
*
|
||||
* Discussion:
|
||||
* Creates a control for the specified applet whose content is drawn
|
||||
* and events processed by java.
|
||||
* All communication to this control should be through the APIs
|
||||
* specified here in JavaControl.h.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* env:
|
||||
* The JNI Environment for the current thread.
|
||||
*
|
||||
* inNativeWindow:
|
||||
* The carbon window that will host the applet.
|
||||
*
|
||||
* inBounds:
|
||||
* The starting location for the applet.
|
||||
*
|
||||
* inAppletFrame:
|
||||
* The applet reference obtained from CreateJavaApplet.
|
||||
*
|
||||
* inVisible:
|
||||
* True if the applet should start out hidden.
|
||||
*
|
||||
* outControl:
|
||||
* A reference to the control that is created for the applet.
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.1 and later in Carbon.framework
|
||||
* CarbonLib: not available
|
||||
* Non-Carbon CFM: not available
|
||||
*/
|
||||
extern OSStatus
|
||||
CreateJavaControl(
|
||||
JNIEnv * env,
|
||||
WindowRef inNativeWindow,
|
||||
const Rect * inBounds,
|
||||
jobject inAppletFrame,
|
||||
Boolean inVisible,
|
||||
ControlRef * outControl);
|
||||
|
||||
|
||||
|
||||
#if PRAGMA_STRUCT_ALIGN
|
||||
#pragma options align=reset
|
||||
#elif PRAGMA_STRUCT_PACKPUSH
|
||||
#pragma pack(pop)
|
||||
#elif PRAGMA_STRUCT_PACK
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __JAVACONTROL__ */
|
||||
|
Двоичные данные
plugin/oji/MRJCarbon/MRJSDK/JavaFrameworks/JavaEmbeddingLib
Двоичные данные
plugin/oji/MRJCarbon/MRJSDK/JavaFrameworks/JavaEmbeddingLib
Двоичный файл не отображается.
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,22 +0,0 @@
|
|||
/*
|
||||
* @(#)jni_md.h 1.12 00/02/02
|
||||
*
|
||||
* Copyright 1996-2000 Sun Microsystems, Inc. All Rights Reserved.
|
||||
*
|
||||
* This software is the proprietary information of Sun Microsystems, Inc.
|
||||
* Use is subject to license terms.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _JAVASOFT_JNI_MD_H_
|
||||
#define _JAVASOFT_JNI_MD_H_
|
||||
|
||||
#define JNIEXPORT
|
||||
#define JNIIMPORT
|
||||
#define JNICALL
|
||||
|
||||
typedef long jint;
|
||||
typedef long long jlong;
|
||||
typedef signed char jbyte;
|
||||
|
||||
#endif /* !_JAVASOFT_JNI_MD_H_ */
|
|
@ -1,108 +0,0 @@
|
|||
Changes since 1.0:
|
||||
|
||||
1. Fixed a crash caused by leaving pending Java exceptions in a JNIEnv, when loading
|
||||
LiveConnect classes that were incompatible with ours. Thanks Apple!
|
||||
|
||||
2. Worked around a change to com.apple.mrj.JavaEmbedding.JE_AppletViewer in Jaguar's JVM
|
||||
that was no longer implementing the java.applet.AppletContext. Now reading the panel field,
|
||||
which is an instance of a sun.applet.AppletPanel, which has a getApplet() method.
|
||||
|
||||
3. Worked around Apple's shipped netscape.* classes by prepending MRJPlugin.jar to the
|
||||
boot classpath, instead of adding it to the regular application class path.
|
||||
|
||||
Changes since 1.0fc2:
|
||||
|
||||
1. Return correct value when mouse clicks occur within the applet. The browser is still
|
||||
initiating drags when it shouldn't. This should be fixed in Mozilla 1.0.1.
|
||||
|
||||
2. Built the plugin as a Mac OS X bundle to simplify installation.
|
||||
|
||||
Changes since 1.0fc1:
|
||||
|
||||
1. Fixed crash resulting from stale reference to an nsIPluginInstancePeer held by the Carbon
|
||||
event loop timer used for both status messages and opening new browser documents from Java.
|
||||
|
||||
2. Made all SupportsMixin::addRef/release thread-safe, since a Java thread is calling
|
||||
AddRef on an MRJPluginInstance in the event loop timer.
|
||||
|
||||
Changes since 1.0b2:
|
||||
|
||||
1. Added call to SizeJavaControl() when processing window size changes. This causes the applet
|
||||
to be correctly resized before calling MoveAndClipJavaControl().
|
||||
|
||||
2. Fixed LiveConnect method that was causing stale plugin instance references to be retained
|
||||
in the active plugin list.
|
||||
|
||||
3. Changed TimedMessage handling so it uses the system memory allocators. This fixes some issues
|
||||
that we were seeing when Carbon event handlers were being fired during event processing.
|
||||
|
||||
4. Added versioning strings to the mimetype list to improve compatibility with websites that
|
||||
insist on declaring their applets using the "x-java-applet;version=x.x.x" format.
|
||||
|
||||
Changes since 1.0b1:
|
||||
|
||||
1. Repaired Security Context code that was broken by the checkin for bug 124042. This code now
|
||||
uses standard character strings instead of Mozilla string classes.
|
||||
|
||||
2. Fixed code that was causing recursive painting calls.
|
||||
|
||||
Changes since 1.0d8:
|
||||
|
||||
1. Unescape file:// URLs when processing them. This allows us to launch local applets when there
|
||||
is a space in the pathname leading to the applet (i.e. "/Volume/Applet Folder/applet").
|
||||
|
||||
Changes since 1.0d7:
|
||||
|
||||
1. Added support for relative height and width. This fixes problems with apples failing to load
|
||||
because their height or width was specified as a percentage value.
|
||||
|
||||
2. Removed checks for zero height and width when instantiating the applet. This was keeping
|
||||
some applets from being created.
|
||||
|
||||
3. Fixed Unicode to UTF-8 conversion on strings that were being passed to the status bar.
|
||||
|
||||
Changes since 1.0d6:
|
||||
|
||||
1. Using cfref template class to simplify and guard releases of CFTypeRef objects. This fixes
|
||||
several crashing bugs.
|
||||
|
||||
Changes since 1.0d5:
|
||||
|
||||
1. Converting between HFS+ paths POSIX paths when processing URLs. This fixes bugzilla bug #108519
|
||||
and addresses a mismatch between the way Mozilla (FizzillaCFM) and Java represent paths. Mozilla
|
||||
uses HFS+ file paths, and simply converts them to URLs with the same path elements. Java uses the
|
||||
POSIX representation, where the boot volume is simply "/" and all other volumes appear under
|
||||
"/Volumes". The workaround code is a little messy, and is only necessary for file: URLs.
|
||||
|
||||
2. Added NULL check to showDocumentCallback as a workaround for bug #108054. For some strange reason,
|
||||
url is NULL when that applet calls getAppletContext().showDocument(url, "_blank").
|
||||
|
||||
Changes since 1.0d4:
|
||||
|
||||
1. Need an applet object for LiveConnect. Is it available? Doing a little digging,
|
||||
I find that the applet's frame is an instance of com.apple.mrj.JavaEmbedding.JE_AppletViewer.
|
||||
This class has a getApplet(String) method, which should do the trick. I need to tell Apple that
|
||||
I am calling its methods. Actually, getApplet()/getApplets() is part of the interface
|
||||
java.applet.AppletContext, which the applet frame's class implements. For applets that have
|
||||
a name attribute in their HTML element, then getApplet(String) can be used. If a name attribute
|
||||
isn't specified, then AppletContext.getApplets() can be used, which returns a java.util.Enumeration,
|
||||
and presumably the first applet it returns is the one we want.
|
||||
|
||||
2. Created JNIRunnable, LiveConnectProxy classes to implement a rudimentary security architecture.
|
||||
Slowly removing cross thread calls, which are terribly slow and didn't actually do anything for
|
||||
security.
|
||||
|
||||
Changes since 1.0d3:
|
||||
|
||||
1. Added system version check to make sure only runs on 10.1 or later.
|
||||
|
||||
2. Talked to Scott Kovatch, he told me how to interact with applet
|
||||
security. Added code to netscape.oji.JNIThread's constructor to start the thread
|
||||
using a privileged action. ** Doesn't work, since code isn't in boot class path. **
|
||||
|
||||
3. Added code to netscape.oji.MRJSession to install com.apple.mrj.JavaEmbedding.JE_AppletSecurity
|
||||
as the system security manager, so that it is always there, not just after applets run.
|
||||
|
||||
4. Added MRJPlugin.properties to configure the plugin.
|
||||
|
||||
5. Added MRJPlugin.policy so that classes in MRJPlugin.jar can execute with all privileges.
|
Двоичные данные
plugin/oji/MRJCarbon/plugin/English.lproj/InfoPlist.strings
Двоичные данные
plugin/oji/MRJCarbon/plugin/English.lproj/InfoPlist.strings
Двоичный файл не отображается.
|
@ -1,7 +0,0 @@
|
|||
MRJPluginCarbon v1.0.1 Install Notes
|
||||
|
||||
This short document explains how to install the MRJ Plugin for Mac OS X. The process for installing the plugin has been greatly simplified from previous releases. Simply drag the file MRJPluginCarbon into the folder
|
||||
|
||||
/Library/Internet Plug-Ins
|
||||
|
||||
This will make the MRJ Plugin for Mac OS X available to all installations of Netscape Gecko based browsers.
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче