Initial checkin of Java Util classes and the Java Wrapper to WebShell

Util docs:  http://www.mozilla.org/projects/blackwood/java-util/
Java Wrapper to WebShell docs: http://www.mozilla.org/projects/blackwood/webclient/


git-svn-id: svn://10.0.0.236/trunk@41569 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
edburns%acm.org
1999-07-30 01:03:12 +00:00
parent cab1eacb84
commit 186006f8a6
34 changed files with 6956 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
#!nmake
#
# The contents of this file are subject to the Mozilla Public License
# Version 1.0 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
# the License for the specific language governing rights and limitations
# under the License.
#
# The Initial Developer of the Original Code is Sun Microsystems,
# Inc. Portions created by Sun are Copyright (C) 1999 Sun
# Microsystems, Inc. All Rights Reserved.
IGNORE_MANIFEST=1
#//------------------------------------------------------------------------
#//
#// Makefile to build the java wrapper to mozilla
#//
#//------------------------------------------------------------------------
#//------------------------------------------------------------------------
#//
#// Specify the depth of the current directory relative to the
#// root of NS
#//
#//------------------------------------------------------------------------
DEPTH = ..\..
DIRS = classes \
src
include <$(DEPTH)\config\rules.mak>

View File

@@ -0,0 +1,67 @@
Here lies the MozWebShell java wrapper to mozilla M8.
Authors: Kirk Baker <kbaker@eb.com>
Ian Wilkinson <iw@ennoble.co>
Build hacking and packaging: Ed Burns <edburns@acm.org>
Requirements:
* built M8 mozilla tree for WinNT4.0
* JDK1.1.7 or greater
* built org.mozilla.util java classes (see NOTE_UTIL)
* Perl 5 perl.exe must be in your path
How To Build:
* make it so the directory in which this file resides is a child of your
top level mozilla\java directory
* Copy the files .\config\buildpkg.bat and .\config\outofdate.pl to
mozilla\config. These file were modified after M8 and the
modifications are required to build java.
* make sure the environment var JDKHOME is set to your jdk installation
directory, ie SET JDKHOME=C:\jdk1.1.8
* type "nmake /f makefile.win all" and hope for the best
* Due to bug 10561 (http://bugzilla.mozilla.org/show_bug.cgi?id=10561)
one must do a horrendous workaround:
In the directory mozilla/dist/WIN32_D.OBJ/bin, copy the components.reg
file and the components directory to the following places:
C:\WINNT\System32
%JDKHOME%\jre\bin
How to Run:
* once the build has successfully completed, run this batch file:
.\src\WIN32_D.OBJ\runem.bat <opt: YOUR_URL>
Note that YOUR_URL is probably necessary since firewall support wasn't
working in M8.
Problems:
* clobber_all doesn't remove the .class files from dist\classes. You
have to do this manually.
* post to netscape.public.mozilla.java newsgroup
General notes:
* Please update the ChangeLog (changelo) when you make changes.
NOTE_UTIL:
* this package depends on the org.mozilla.util classes, which can be
found in the mozilla tree under mozilla\java\util. They are a
separate checkout and build. Once you check out the org.mozilla.util
classes, see the README in the mozilla\java\util\README.

View File

@@ -0,0 +1,13 @@
Wed Jul 28 12:17:30 1999 <edbuns@acm.org>
* Renamed MozWebShell to webclient.BrowserControl
* Moved util classes into separate package
* updated README accordingly
Mon Jul 26 21:32:18 1999 <edburns@acm.org>
* Prepared the initial checkin of MozWebShell. Need to rename to
org.mozilla.webclient.BrowserControl.

View File

@@ -0,0 +1,56 @@
#!nmake
#
# The contents of this file are subject to the Mozilla Public License
# Version 1.0 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
# the License for the specific language governing rights and limitations
# under the License.
#
# The Initial Developer of the Original Code is Sun Microsystems,
# Inc. Portions created by Sun are Copyright (C) 1999 Sun
# Microsystems, Inc. All Rights Reserved.
IGNORE_MANIFEST=1
#//------------------------------------------------------------------------
#//
#// Makefile to build the java portion of the java wrapper to mozilla
#//
#//------------------------------------------------------------------------
#//------------------------------------------------------------------------
#//
#// Specify the depth of the current directory relative to the
#// root of NS
#//
#//------------------------------------------------------------------------
DEPTH= ..\..\..
# PENDING(edburns): find out where this should really get defined
JAVA_OR_NSJVM=1
NO_CAFE=1
include <$(DEPTH)\config\config.mak>
JAR_WEBCLIENT_CLASSES = org\mozilla\webclient \
org\mozilla\webclient\test
!ifdef JAVA_OR_NSJVM
JDIRS = $(JAR_WEBCLIENT_CLASSES)
!endif
WEBCLIENT_JAR_NAME=webclient(VERSION_NUMBER).jar
JAVAC_PROG=$(JDKHOME)\bin\javac
export::
@echo +++ Checking that org.mozilla.util classes have been built...
if not exist $(MOZ_SRC)\mozilla\dist\classes\org\mozilla\util\Assert.class \
stopbuild.exe
include <$(DEPTH)\config\rules.mak>

View File

@@ -0,0 +1,39 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The original code is RaptorCanvas
*
* The Initial Developer of the Original Code is Kirk Baker <kbaker@eb.com> and * Ian Wilkinson <iw@ennoble.com
*/
package org.mozilla.webclient;
// BrowserControl.java
/**
*
* <B>BrowserControl</B> simply declares the composition of the core and extended
* interfaces.
*
* @version $Id: BrowserControl.java,v 1.1 1999-07-30 01:03:03 edburns%acm.org Exp $
*
* @see org.mozilla.webclient.BrowserControlCore
* @see org.mozilla.webclient.BrowserControlExtended
*
*/
public interface BrowserControl extends BrowserControlCore, BrowserControlExtended
{
} // end of interface BrowserControl

View File

@@ -0,0 +1,240 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The original code is RaptorCanvas
*
* The Initial Developer of the Original Code is Kirk Baker <kbaker@eb.com> and * Ian Wilkinson <iw@ennoble.com
*/
package org.mozilla.webclient;
// BrowserControlCanvas.java
import org.mozilla.util.Assert;
import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;
import java.awt.*;
/**
*
* BrowserControlCanvas is the principal class for embedding
* the Mozilla WebShell into the Java framework.
* This component represents the proxy for the native
* WebShell class as provided by the nsIWebShell
* interface.
*
* @see org.mozilla.webclient.BrowserControl
*
* @author Kirk Baker
* @author Ian Wilkinson
* <P>
* <B>Lifetime And Scope</B> <P>
* See concrete subclasses for scope info.
* @version $Id: BrowserControlCanvas.java,v 1.1 1999-07-30 01:03:04 edburns%acm.org Exp $
* @see org.mozilla.webclient.Win32BrowserControlCanvas
*/
import java.awt.*;
import java.awt.Canvas;
import java.awt.event.*;
import sun.awt.*;
public abstract class BrowserControlCanvas extends Canvas
{
//
// Class Variables
//
private static int webShellCount = 0;
//
// Instance Variables
//
// Attribute Instance Variables
private boolean initializeOK;
private boolean boundsValid;
private boolean hasFocus;
// Relationship Instance Variables
private BrowserControl webShell;
private int nativeWindow;
private Rectangle windowRelativeBounds;
// PENDING(edburns): Is this needed: // private BrowserControlIdleThread idleThread;
//
// Constructors and Initializers
//
/**
* Initialize the BrowserControlMozillaShim. For now,
* this initializes the Mozilla registry.
*/
public BrowserControlCanvas ()
{
nativeWindow = 0;
webShell = null;
initializeOK = false;
boundsValid = false;
hasFocus = false;
try {
BrowserControlMozillaShim.initialize();
} catch (Exception e) {
System.out.println(e.toString());
}
} // BrowserControlCanvas() ctor
/**
* Obtain the native window handle for this component's
* peer.
*/
abstract protected int getWindow(DrawingSurfaceInfo dsi);
//
// Methods from Canvas
//
/**
* Instantiate the Mozilla WebShell container.
*/
public void addNotify ()
{
super.addNotify();
DrawingSurface ds = (DrawingSurface)this.getPeer();
DrawingSurfaceInfo dsi = ds.getDrawingSurfaceInfo();
windowRelativeBounds = new Rectangle();
// We must lock() the DrawingSurfaceInfo before
// accessing its native window handle.
dsi.lock();
nativeWindow = getWindow(dsi);
try {
Rectangle r = new Rectangle(getBoundsRelativeToWindow());
webShell = new BrowserControlImpl(nativeWindow, r);
} catch (Exception e) {
dsi.unlock();
System.out.println(e.toString());
return;
}
dsi.unlock();
initializeOK = true;
webShellCount++;
/*
requestFocus();
*/
} // addNotify()
public BrowserControl getWebShell ()
{
return webShell;
} // getWebShell()
protected Point getEventCoordsLocalToWindow(MouseEvent evt)
{
Rectangle localBounds = getBoundsRelativeToWindow();
int windowLocalX = evt.getX() + localBounds.x;
int windowLocalY = evt.getY() + localBounds.y;
return new Point(windowLocalX, windowLocalY);
} // getEventCoordsLocalToWindow()
protected Rectangle getWindowBounds ()
{// Throw an Exception?
Container parent = getParent();
if (parent != null) {
do {
// if the parent is a window, then return its bounds
if (parent instanceof Window == true) {
return parent.getBounds();
}
parent = parent.getParent();
} while (parent != null);
}
return new Rectangle();
} // getWindowBounds()
protected Rectangle getBoundsRelativeToWindow ()
{
if (boundsValid) {
return windowRelativeBounds;
}
Container parent = getParent();
Point ourLoc = getLocation();
Rectangle ourBounds = getBounds();
if (parent != null) {
do {
// if the parent is a window, then don't adjust to its offset
// and look no further
if (parent instanceof Window == true) {
break;
}
Point parentLoc = parent.getLocation();
ourLoc.translate(-parentLoc.x, -parentLoc.y);
parent = parent.getParent();
} while (parent != null);
}
windowRelativeBounds.setBounds(-ourLoc.x, -ourLoc.y, ourBounds.width, ourBounds.height);
boundsValid = true;
return windowRelativeBounds;
} // getBoundsRelativeToWindow()
public void setBounds(int x, int y, int w, int h)
{
super.setBounds(x, y, w, h);
if (webShell != null) {
System.out.println("in BrowserControlCanvas setBounds: x = " + x + " y = " + y + " w = " + w + " h = " + h);
try {
webShell.setBounds(new Rectangle(0, 0, w - 1, h - 1));
}
catch(Exception ex) {
}
}
}
public void setBounds(Rectangle rect)
{
super.setBounds(rect);
}
} // class BrowserControlCanvas
// EOF

View File

@@ -0,0 +1,119 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
*
* The Initial Developer of the Original Code is Sun Microsystems,
* Inc. Portions created by Sun are Copyright (C) 1997, 1998, 1999 Sun
* Microsystems, Inc. All Rights Reserved.
*/
package org.mozilla.webclient;
// BrowserControlCanvasFactory.java
import org.mozilla.util.Assert;
import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;
/**
*
* <B>BrowserControlCanvasFactory</B> creates concrete instances of BrowserControlCanvas
* <B>Lifetime And Scope</B> <P>
* This is a static class, it is neven instantiated.
*
* @version $Id: BrowserControlCanvasFactory.java,v 1.1 1999-07-30 01:03:04 edburns%acm.org Exp $
*
* @see org.mozilla.webclient.test.EmbeddedMozilla
*/
public class BrowserControlCanvasFactory extends Object
{
//
// Protected Constants
//
//
// Class Variables
//
//
// Instance Variables
//
// Attribute Instance Variables
// Relationship Instance Variables
//
// Constructors and Initializers
//
public BrowserControlCanvasFactory()
{
Assert.assert(false, "This class shouldn't be constructed.");
}
//
// Class methods
//
public static BrowserControlCanvas newBrowserControlCanvas()
{
BrowserControlCanvas result = null;
// PENDING(edburns): do some magic to determine the right kind of
// BrowserControlCanvas to instantiate
Class browserControlCanvasClass = null;
String className = "org.mozilla.webclient.Win32BrowserControlCanvas";
try {
if (null != (browserControlCanvasClass = Class.forName(className))) {
result = (BrowserControlCanvas) browserControlCanvasClass.newInstance();
}
}
catch (Exception e) {
System.out.println(e.getMessage());
}
return result;
}
//
// General Methods
//
// ----UNIT_TEST_START
//
// Test methods
//
public static void main(String [] args)
{
Assert.setEnabled(true);
Log.setApplicationName("BrowserControlCanvasFactory");
Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: BrowserControlCanvasFactory.java,v 1.1 1999-07-30 01:03:04 edburns%acm.org Exp $");
BrowserControlCanvas canvas = BrowserControlCanvasFactory.newBrowserControlCanvas();
Assert.assert(null != canvas);
}
// ----UNIT_TEST_END
} // end of class BrowserControlCanvasFactory

View File

@@ -0,0 +1,52 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The original code is RaptorCanvas
*
* The Initial Developer of the Original Code is Kirk Baker <kbaker@eb.com> and * Ian Wilkinson <iw@ennoble.com
*/
package org.mozilla.webclient;
// BrowserControlCore.java
/**
*
* <B>BrowserControlCore</B> Defines the core methods for browsing
*
* @version $Id: BrowserControlCore.java,v 1.1 1999-07-30 01:03:04 edburns%acm.org Exp $
*
* @see org.mozilla.webclient.BrowserControlExtended
* @see org.mozilla.webclient.BrowserControl
*
*/
public interface BrowserControlCore
{
public void loadURL(String urlString) throws Exception;
public void stop() throws Exception;
public boolean canBack() throws Exception;
public boolean canForward() throws Exception;
public boolean back() throws Exception;
public boolean forward() throws Exception;
public int getNativeWebShell();
} // end of interface BrowserControlCore

View File

@@ -0,0 +1,62 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The original code is RaptorCanvas
*
* The Initial Developer of the Original Code is Kirk Baker <kbaker@eb.com> and * Ian Wilkinson <iw@ennoble.com
*/
package org.mozilla.webclient;
// BrowserControlExtended.java
import java.awt.Rectangle;
/**
*
* <B>BrowserControlExtended</B> defines the interface for extended browser
* functionality
*
* @version $Id: BrowserControlExtended.java,v 1.1 1999-07-30 01:03:05 edburns%acm.org Exp $
*
* @see org.mozilla.webclient.BrowserControlCore
* */
public interface BrowserControlExtended
{
public void show () throws Exception;
public void hide () throws Exception;
public void setBounds (Rectangle bounds) throws Exception;
public void moveTo (int x, int y) throws Exception;
public void setFocus () throws Exception;
public void removeFocus () throws Exception;
public void repaint (boolean forceRepaint) throws Exception;
public boolean goTo (int historyIndex) throws Exception;
public int getHistoryLength () throws Exception;
public int getHistoryIndex () throws Exception;
public String getURL (int historyIndex) throws Exception;
} // end of interface BrowserControlExtended

View File

@@ -0,0 +1,245 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The original code is RaptorCanvas
*
* The Initial Developer of the Original Code is Kirk Baker <kbaker@eb.com> and * Ian Wilkinson <iw@ennoble.com
*/
package org.mozilla.webclient;
// BrowserControlImpl.java
import org.mozilla.util.Assert;
import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;
import java.awt.Rectangle;
/**
*
* <B>BrowserControlImpl</B> provides the implementation for BrowserControl
*
* <B>Lifetime And Scope</B> <P>
*
* @version $Id: BrowserControlImpl.java,v 1.1 1999-07-30 01:03:05 edburns%acm.org Exp $
*
* @see org.mozilla.webclient.BrowserControl
*
*/
public class BrowserControlImpl extends Object implements BrowserControl
{
//
// Protected Constants
//
//
// Class Variables
//
//
// Instance Variables
//
// Attribute Instance Variables
// Relationship Instance Variables
/**
* a handle to the actual mozilla webShell
*/
private int nativeWebShell;
//
// Constructors and Initializers
//
public BrowserControlImpl(int windowPtr, Rectangle bounds) throws Exception
{
nativeWebShell = BrowserControlMozillaShim.webShellCreate(windowPtr, bounds);
}
//
// Class methods
//
//
// General Methods
//
//
// Methods from BrowserControl
//
public void loadURL(String urlString) throws Exception
{
BrowserControlMozillaShim.webShellLoadURL(nativeWebShell, urlString);
}
public void stop() throws Exception
{
BrowserControlMozillaShim.webShellStop(nativeWebShell);
}
public void show () throws Exception
{
BrowserControlMozillaShim.webShellShow(nativeWebShell);
}
public void hide () throws Exception
{
BrowserControlMozillaShim.webShellHide(nativeWebShell);
}
public void setBounds (Rectangle bounds) throws Exception
{
BrowserControlMozillaShim.webShellSetBounds(nativeWebShell, bounds);
}
public void moveTo (int x, int y) throws Exception
{
BrowserControlMozillaShim.webShellMoveTo(nativeWebShell, x, y);
}
/**
*
*/
public void setFocus () throws Exception
{
BrowserControlMozillaShim.webShellSetFocus(nativeWebShell);
}
/**
*
*/
public void removeFocus () throws Exception
{
BrowserControlMozillaShim.webShellRemoveFocus(nativeWebShell);
}
/**
*
*/
public void repaint (boolean forceRepaint) throws Exception
{
BrowserControlMozillaShim.webShellRepaint(nativeWebShell, forceRepaint);
}
/**
*
*/
public boolean canBack () throws Exception
{
return BrowserControlMozillaShim.webShellCanBack(nativeWebShell);
}
/**
*
*/
public boolean canForward () throws Exception
{
return BrowserControlMozillaShim.webShellCanForward(nativeWebShell);
}
/**
*
*/
public boolean back () throws Exception
{
return BrowserControlMozillaShim.webShellBack(nativeWebShell);
}
/**
*
*/
public boolean forward () throws Exception
{
return BrowserControlMozillaShim.webShellForward(nativeWebShell);
}
/**
*
*/
public boolean goTo (int historyIndex) throws Exception
{
return BrowserControlMozillaShim.webShellGoTo(nativeWebShell, historyIndex);
}
/**
*
*/
public int getHistoryLength () throws Exception
{
return BrowserControlMozillaShim.webShellGetHistoryLength(nativeWebShell);
}
/**
*
*/
public int getHistoryIndex () throws Exception
{
return BrowserControlMozillaShim.webShellGetHistoryIndex(nativeWebShell);
}
/**
*
*/
public String getURL (int historyIndex) throws Exception
{
return BrowserControlMozillaShim.webShellGetURL(nativeWebShell, historyIndex);
}
/**
*
*/
public int getNativeWebShell ()
{
return nativeWebShell;
}
/**
*
*/
public void finalize ()
{
try {
BrowserControlMozillaShim.webShellDelete(nativeWebShell);
}
catch (Exception ex) {
System.out.println(ex.toString());
}
nativeWebShell = 0;
}
// ----UNIT_TEST_START
//
// Test methods
//
public static void main(String [] args)
{
Assert.setEnabled(true);
// BrowserControlImpl me = new BrowserControlImpl();
Log.setApplicationName("BrowserControlImpl");
Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: BrowserControlImpl.java,v 1.1 1999-07-30 01:03:05 edburns%acm.org Exp $");
}
// ----UNIT_TEST_END
} // end of class BrowserControlImpl

View File

@@ -0,0 +1,572 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The original code is RaptorCanvas
*
* The Initial Developer of the Original Code is Kirk Baker <kbaker@eb.com> and * Ian Wilkinson <iw@ennoble.com
*/
package org.mozilla.webclient;
// MWebShellMozillaShim.java
import org.mozilla.util.Assert;
import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;
import java.awt.*;
/**
*
* <B>MWebShellMozillaShim</B> is a class with native methods that
* provides the glue between MWebShell and nsIWebShell. <P>
* WAS: instance <P>
* <B>Lifetime And Scope</B> <P>
* There is one instance of this class and all of the exposed methods
* are static.
* @version $Id: BrowserControlMozillaShim.java,v 1.1 1999-07-30 01:03:05 edburns%acm.org Exp $
*
* @see org.mozilla.webclient.BrowserControlImpl
*
*/
public class BrowserControlMozillaShim extends Object
{
//
// Protected Constants
//
//
// Class Variables
//
private static boolean initialized = false;
private static BrowserControlMozillaShim instance = null;
private static Object lock = null;
//
// Instance Variables
//
// Attribute Instance Variables
// Relationship Instance Variables
//
// Constructors and Initializers
//
public BrowserControlMozillaShim()
{
super();
lock = new Object();
}
//
// Class methods
//
public static void initialize () throws Exception
{
if (!initialized) {
instance = new BrowserControlMozillaShim();
try {
System.loadLibrary("webclient");
}
catch (java.lang.UnsatisfiedLinkError e) {
throw new Exception("Unable to open native webclient library");
}
instance.nativeInitialize();
initialized = true;
}
}
public static void terminate () throws Exception
{
synchronized(lock) {
if (initialized) {
instance.nativeTerminate();
initialized = false;
}
}
}
public static void processEvents(int theWebShell)
{
synchronized(lock) {
if (initialized) {
instance.nativeProcessEvents(theWebShell);
}
}
}
//
// Window events
//
public static void sendKeyDownEvent (int widgetPtr,
char keyChar, int keyCode,
int modifiers, int eventTime)
{
synchronized(lock) {
if (initialized) {
instance.nativeSendKeyDownEvent(widgetPtr,
keyChar, keyCode, modifiers,
eventTime);
}
}
}
public static void sendKeyUpEvent (int widgetPtr,
char keyChar, int keyCode,
int modifiers, int eventTime)
{
synchronized(lock) {
if (initialized) {
instance.nativeSendKeyUpEvent(widgetPtr, keyChar,
keyCode, modifiers, eventTime);
}
}
}
public static void sendMouseEvent (int windowPtr, int widgetPtr,
int widgetX, int widgetY,
int windowX, int windowY,
int mouseMessage, int numClicks,
int modifiers, int eventTime)
{
synchronized(lock) {
if (initialized) {
instance.nativeSendMouseEvent(windowPtr, widgetPtr,
widgetX, widgetY,
windowX, windowY,
mouseMessage, numClicks,
modifiers, eventTime);
}
}
}
public static void idleEvent (int windowPtr)
{
synchronized(lock) {
if (initialized) {
instance.nativeIdleEvent(windowPtr, 0);
}
}
}
public static void updateEvent (int windowPtr)
{
synchronized(lock) {
if (initialized) {
instance.nativeUpdateEvent(windowPtr, 0);
}
}
}
//
// Widget methods
//
public static int widgetCreate (int windowPtr,
Rectangle bounds) throws Exception
{
synchronized(lock) {
if (initialized) {
return(instance.nativeWidgetCreate(windowPtr,
bounds.x, bounds.y,
bounds.width + 1, bounds.height + 1));
} else {
return 0;
}
}
}
public static void widgetDelete (int widgetPtr) throws Exception
{
synchronized(lock) {
if (initialized) {
instance.nativeWidgetDelete(widgetPtr);
}
}
}
public static void widgetResize (int widgetPtr, Rectangle bounds,
boolean repaint)
{
synchronized(lock) {
if (initialized) {
instance.nativeWidgetResize(widgetPtr, bounds.x, bounds.y, bounds.width + 1, bounds.height + 1, repaint);
}
}
}
public static void widgetResize (int widgetPtr, int width,
int height, boolean repaint)
{
synchronized(lock) {
if (initialized) {
instance.nativeWidgetResize(widgetPtr, 0, 0, width + 1, height + 1, repaint);
}
}
}
public static void widgetEnable (int widgetPtr, boolean enable)
{
synchronized(lock) {
if (initialized) {
instance.nativeWidgetEnable(widgetPtr, enable);
}
}
}
public static void widgetShow (int widgetPtr, boolean show)
{
synchronized(lock) {
if (initialized) {
instance.nativeWidgetShow(widgetPtr, show);
}
}
}
public static void widgetInvalidate (int widgetPtr, boolean isSynchronous)
{
synchronized(lock) {
if (initialized) {
instance.nativeWidgetInvalidate(widgetPtr, isSynchronous);
}
}
}
public static void widgetUpdate (int widgetPtr)
{
synchronized(lock) {
if (initialized) {
instance.nativeWidgetUpdate(widgetPtr);
}
}
}
//
// WebShell methods
//
public static int webShellCreate (int windowPtr,
Rectangle bounds) throws Exception
{
synchronized(lock) {
if (initialized) {
return(instance.nativeWebShellCreate(windowPtr, bounds.x, bounds.y, bounds.width + 1, bounds.height + 1));
}
else {
throw new Exception("Error: unable to create native nsIWebShell");
}
}
}
public static void webShellDelete (int webShellPtr) throws Exception
{
synchronized(lock) {
if (initialized) {
instance.nativeWebShellDelete(webShellPtr);
}
}
}
public static void webShellLoadURL (int webShellPtr,
String urlString) throws Exception
{
synchronized(lock) {
if (initialized) {
instance.nativeWebShellLoadURL(webShellPtr, urlString);
}
}
}
public static void webShellStop (int webShellPtr) throws Exception
{
synchronized(lock) {
if (initialized) {
instance.nativeWebShellStop(webShellPtr);
}
}
}
public static void webShellShow (int webShellPtr) throws Exception
{
synchronized(lock) {
if (initialized) {
instance.nativeWebShellShow(webShellPtr);
}
}
}
public static void webShellHide (int webShellPtr) throws Exception
{
synchronized(lock) {
if (initialized) {
instance.nativeWebShellHide(webShellPtr);
}
}
}
public static void webShellSetBounds (int webShellPtr,
Rectangle bounds) throws Exception
{
synchronized(lock) {
if (initialized) {
instance.nativeWebShellSetBounds(webShellPtr, bounds.x, bounds.y, bounds.width + 1, bounds.height + 1);
}
}
}
public static void webShellMoveTo (int webShellPtr,
int x, int y) throws Exception
{
synchronized(lock) {
if (initialized) {
instance.nativeWebShellMoveTo(webShellPtr, x, y);
}
}
}
public static void webShellSetFocus (int webShellPtr) throws Exception
{
synchronized(lock) {
if (initialized) {
instance.nativeWebShellSetFocus(webShellPtr);
}
}
}
public static void webShellRemoveFocus (int webShellPtr) throws Exception
{
synchronized(lock) {
if (initialized) {
instance.nativeWebShellRemoveFocus(webShellPtr);
}
}
}
public static void webShellRepaint (int webShellPtr,
boolean forceRepaint) throws Exception
{
synchronized(lock) {
if (initialized) {
instance.nativeWebShellRepaint(webShellPtr, forceRepaint);
}
}
}
public static boolean webShellCanBack (int webShellPtr) throws Exception
{
synchronized(lock) {
if (initialized) {
return instance.nativeWebShellCanBack(webShellPtr);
}
else {
throw new Exception("instance is not initialized.");
}
}
}
public static boolean webShellCanForward (int webShellPtr) throws Exception
{
synchronized(lock) {
if (initialized) {
return instance.nativeWebShellCanForward(webShellPtr);
}
else {
throw new Exception("instance is not initialized.");
}
}
}
public static boolean webShellBack (int webShellPtr) throws Exception
{
synchronized(lock) {
if (initialized) {
return instance.nativeWebShellBack(webShellPtr);
}
else {
throw new Exception("instance is not initialized.");
}
}
}
public static boolean webShellForward (int webShellPtr) throws Exception
{
synchronized(lock) {
if (initialized) {
return instance.nativeWebShellForward(webShellPtr);
}
else {
throw new Exception("instance is not initialized.");
}
}
}
public static boolean webShellGoTo (int webShellPtr,
int historyIndex) throws Exception
{
synchronized(lock) {
if (initialized) {
return instance.nativeWebShellGoTo(webShellPtr, historyIndex);
}
else {
throw new Exception("instance is not initialized.");
}
}
}
public static int webShellGetHistoryLength (int webShellPtr) throws Exception
{
synchronized(lock) {
if (initialized) {
return instance.nativeWebShellGetHistoryLength(webShellPtr);
}
else {
throw new Exception("instance is not initialized.");
}
}
}
public static int webShellGetHistoryIndex (int webShellPtr) throws Exception
{
synchronized(lock) {
if (initialized) {
return instance.nativeWebShellGetHistoryIndex(webShellPtr);
}
else {
throw new Exception("instance is not initialized.");
}
}
}
public static String webShellGetURL(int webShellPtr,
int historyIndex) throws Exception
{
synchronized(lock) {
if (initialized) {
return instance.nativeWebShellGetURL(webShellPtr, historyIndex);
}
else {
throw new Exception("instance is not initialized.");
}
}
}
//
// Native interfaces
//
private native void nativeInitialize () throws Exception;
private native void nativeTerminate () throws Exception;
//
// Event interfaces
//
private native void nativeSendKeyDownEvent(int widgetPtr, char keyChar, int keyCode, int modifiers, int eventTime);
private native void nativeSendKeyUpEvent(int widgetPtr, char keyChar, int keyCode, int modifiers, int eventTime);
private native void nativeSendMouseEvent(int windowPtr, int widgetPtr,
int widgetX, int widgetY,
int windowX, int windowY,
int mouseMessage, int numClicks,
int modifiers, int eventTime);
private native void nativeProcessEvents(int theWebShell);
private native void nativeIdleEvent (int windowPtr, int eventTime);
private native void nativeUpdateEvent (int windowPtr, int eventTime);
//
// Widget interfaces
//
private native int nativeWidgetCreate (int windowPtr, int x, int y, int width, int height) throws Exception;
private native void nativeWidgetDelete (int widgetPtr) throws Exception;
private native void nativeWidgetResize (int widgetPtr, int x, int y, int width, int height, boolean repaint);
/*
private native void nativeWidgetResize (int widgetPtr, int width, int height, boolean repaint);
*/
private native void nativeWidgetEnable (int widgetPtr, boolean enable);
private native void nativeWidgetShow (int widgetPtr, boolean show);
private native void nativeWidgetInvalidate (int widgetPtr, boolean isSynchronous);
private native void nativeWidgetUpdate (int widgetPtr);
//
// WebShell interface
//
private native int nativeWebShellCreate (int windowPtr,
int x, int y, int width, int height) throws Exception;
private native void nativeWebShellDelete (int webShellPtr) throws Exception;
private native void nativeWebShellLoadURL (int webShellPtr, String urlString) throws Exception;
private native void nativeWebShellStop (int webShellPtr) throws Exception;
private native void nativeWebShellShow (int webShellPtr) throws Exception;
private native void nativeWebShellHide (int webShellPtr) throws Exception;
private native void nativeWebShellSetBounds (int webShellPtr, int x, int y, int width, int height) throws Exception;
private native void nativeWebShellMoveTo (int webShellPtr, int x, int y) throws Exception;
private native void nativeWebShellSetFocus (int webShellPtr) throws Exception;
private native void nativeWebShellRemoveFocus (int webShellPtr) throws Exception;
private native void nativeWebShellRepaint (int webShellPtr, boolean forceRepaint) throws Exception;
private native boolean nativeWebShellCanBack (int webShellPtr) throws Exception;
private native boolean nativeWebShellCanForward (int webShellPtr) throws Exception;
private native boolean nativeWebShellBack (int webShellPtr) throws Exception;
private native boolean nativeWebShellForward (int webShellPtr) throws Exception;
private native boolean nativeWebShellGoTo (int webShellPtr, int aHistoryIndex) throws Exception;
private native int nativeWebShellGetHistoryLength (int webShellPtr) throws Exception;
private native int nativeWebShellGetHistoryIndex (int webShellPtr) throws Exception;
private native String nativeWebShellGetURL (int webShellPtr, int aHistoryIndex) throws Exception;
//
// General Methods
//
// ----UNIT_TEST_START
//
// Test methods
//
public static void main(String [] args)
{
Assert.setEnabled(true);
BrowserControlMozillaShim me = new BrowserControlMozillaShim();
Log.setApplicationName("BrowserControlMozillaShim");
Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: BrowserControlMozillaShim.java,v 1.1 1999-07-30 01:03:05 edburns%acm.org Exp $");
}
// ----UNIT_TEST_END
} // end of class BrowserControlMozillaShim

View File

@@ -0,0 +1,60 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The original code is RaptorCanvas
*
* The Initial Developer of the Original Code is Kirk Baker <kbaker@eb.com> and * Ian Wilkinson <iw@ennoble.com
*/
package org.mozilla.webclient;
// Win32BrowserControlCanvas.java
import org.mozilla.util.Assert;
import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;
/**
* Win32RaptorCanvas provides a concrete realization
* of the RaptorCanvas.
* <B>Lifetime And Scope</B> <P>
* There is one instance of the BrowserControlCanvas per top level awt Frame.
* @version $Id: Win32BrowserControlCanvas.java,v 1.1 1999-07-30 01:03:06 edburns%acm.org Exp $
*
* @see org.mozilla.webclient.BrowserControlCanvasFactory
*
*/
import sun.awt.*;
import sun.awt.windows.*;
/**
* Win32BrowserControlCanvas provides a concrete realization
* of the RaptorCanvas.
*/
class Win32BrowserControlCanvas extends BrowserControlCanvas {
/**
* Obtain the native window handle for this
* component's peer.
*
* @returns The native window handle.
*/
protected int getWindow(DrawingSurfaceInfo dsi) {
WDrawingSurfaceInfo ds = (WDrawingSurfaceInfo)dsi;
return ds.getHWnd();
}
}

View File

@@ -0,0 +1,186 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The original code is RaptorCanvas
*
* The Initial Developer of the Original Code is Kirk Baker <kbaker@eb.com> and * Ian Wilkinson <iw@ennoble.com
*/
package org.mozilla.webclient.test;
/*
* EmbeddedMozilla.java
*/
import java.awt.*;
import java.awt.event.*;
import org.mozilla.webclient.*;
/**
*
* This is a test application for using the BrowserControl.
*
* @version $Id: EmbeddedMozilla.java,v 1.1 1999-07-30 01:03:07 edburns%acm.org Exp $
*
* @see org.mozilla.webclient.BrowserControlCanvasFactory
*/
public class EmbeddedMozilla extends Frame implements ActionListener {
static final int defaultWidth = 640;
static final int defaultHeight = 480;
private TextField urlField;
private BrowserControl browserControl;
private Panel controlPanel;
private Panel buttonsPanel;
public static void main (String[] arg) {
String urlArg =(0 < arg.length) ? arg[0] : "http://www.mozilla.org/";
EmbeddedMozilla gecko =
new EmbeddedMozilla("Embedded Mozilla", urlArg);
} // main()
public EmbeddedMozilla (String title, String url) {
super(title);
System.out.println("constructed with " + url);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
dispose();
// should close the BrowserControlCanvas
}
public void windowClosed(WindowEvent e) {
System.exit(0);
}
});
setSize(defaultWidth, defaultHeight);
// Create the URL field
urlField = new TextField("", 30);
urlField.addActionListener(this);
// Create the buttons sub panel
buttonsPanel = new Panel();
buttonsPanel.setLayout(new GridBagLayout());
// Add the buttons
makeItem(buttonsPanel, "Back", 0, 0, 1, 1, 0.0, 0.0);
makeItem(buttonsPanel, "Forward", 1, 0, 1, 1, 0.0, 0.0);
makeItem(buttonsPanel, "Stop", 2, 0, 1, 1, 0.0, 0.0);
// Create the control panel
controlPanel = new Panel();
controlPanel.setLayout(new BorderLayout());
// Add the URL field, and the buttons panel
controlPanel.add(urlField, BorderLayout.CENTER);
controlPanel.add(buttonsPanel, BorderLayout.WEST);
// Create the browser
BrowserControlCanvas browser =
BrowserControlCanvasFactory.newBrowserControlCanvas();
browser.setSize(defaultWidth, defaultHeight);
// Add the control panel and the browser
add(controlPanel, BorderLayout.NORTH);
add(browser, BorderLayout.CENTER);
pack();
show();
toFront();
browserControl = browser.getWebShell();
try {
browserControl.loadURL(url);
urlField.setText(url);
}
catch (Exception e) {
System.out.println(e.toString());
}
} // EmbeddedMozilla() ctor
public void actionPerformed (ActionEvent evt) {
String command = evt.getActionCommand();
try {
if (command.equals("Back")) {
if (browserControl.canBack()) {
browserControl.back();
int index = browserControl.getHistoryIndex();
String newURL = browserControl.getURL(index);
System.out.println(newURL);
urlField.setText(newURL);
}
}
else if (command.equals("Forward")) {
if (browserControl.canForward()) {
browserControl.forward();
int index = browserControl.getHistoryIndex();
String newURL = browserControl.getURL(index);
System.out.println(newURL);
urlField.setText(newURL);
}
}
else if (command.equals("Stop")) {
browserControl.stop();
}
else {
browserControl.loadURL(urlField.getText());
}
}
catch (Exception e) {
System.out.println(e.toString());
}
} // actionPerformed()
private void makeItem (Panel p, Object arg, int x, int y, int w, int h, double weightx, double weighty) {
GridBagLayout gbl = (GridBagLayout) p.getLayout();
GridBagConstraints c = new GridBagConstraints();
Component comp;
c.fill = GridBagConstraints.BOTH;
c.gridx = x;
c.gridy = y;
c.gridwidth = w;
c.gridheight = h;
c.weightx = weightx;
c.weighty = weighty;
if (arg instanceof String) {
Button b;
comp = b = new Button((String) arg);
b.addActionListener(this);
p.add(comp);
gbl.setConstraints(comp, c);
}
} // makeItem()
}
// EOF

View File

@@ -0,0 +1,40 @@
@echo off
rem The contents of this file are subject to the Netscape Public License
rem Version 1.0 (the "NPL"); you may not use this file except in
rem compliance with the NPL. You may obtain a copy of the NPL at
rem http://www.mozilla.org/NPL/
rem
rem Software distributed under the NPL is distributed on an "AS IS" basis,
rem WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
rem for the specific language governing rights and limitations under the
rem NPL.
rem
rem The Initial Developer of this code under the NPL is Netscape
rem Communications Corporation. Portions created by Netscape are
rem Copyright (C) 1998 Netscape Communications Corporation. All Rights
rem Reserved.
@echo on
@echo off
if not exist %2 echo Warning: %2 does not exist! (you may need to check it out)
if not exist %2 exit 1
pushd %2
goto NO_CAFE
if "%MOZ_CAFE%"=="" goto NO_CAFE
mkdir %MOZ_SRC%\mozilla\dist\classes\%2
%MOZ_TOOLS%\bin\sj.exe -classpath %MOZ_SRC%\mozilla\dist\classes;%MOZ_SRC%\mozilla\sun-java\classsrc -d %MOZ_SRC%\mozilla\dist\classes *.java
goto END
:NO_CAFE
perl.exe %MOZ_SRC%\mozilla\config\outofdate.pl -d %MOZ_SRC%\mozilla\dist\classes\%2 -cfg %1 *.java > doit.bat
call doit.bat
del /F /A:A doit.bat
:END
popd

View File

@@ -0,0 +1,4 @@
JAVA=$(JDKHOME)\bin\java
JAVAH=$(JDKHOME)\bin\JAVAH
JAVAHFLAGS=-jni -classpath $(JAVAC_CLASSPATH) -d .

View File

@@ -0,0 +1,130 @@
#!perl
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#
#
#Input: [-d dir] foo1.java foo2.java
#Compares with: foo1.class foo2.class (if -d specified, checks in 'dir',
# otherwise assumes .class files in same directory as .java files)
#Returns: list of input arguments which are newer than corresponding class
#files (non-existant class files are considered to be real old :-)
#
$found = 1;
# GLOBALS
$SEP = 0; # the paltform independent path separator
$CFG = 0; # the value of the -cfg flag
# determine the path separator
$_ = $ENV{"PATH"};
if (m|/|) {
$SEP = "/";
}
else {
$SEP = "\\";
}
if ($ARGV[0] eq '-d') {
$classdir = $ARGV[1];
$classdir .= $SEP;
shift;
shift;
} else {
$classdir = "." . $SEP;
}
# if -cfg is specified, print out the contents of the cfg file to stdout
if ($ARGV[0] eq '-cfg') {
$CFG = $ARGV[1];
shift;
shift;
}
$_ = $ARGV[0];
if (m/\*.java/) {
# Account for the fact that the shell didn't expand *.java by doing it
# manually.
&manuallyExpandArgument("java");
}
$printFile = 0;
foreach $filename (@ARGV) {
$classfilename = $classdir;
$classfilename .= $filename;
$classfilename =~ s/.java$/.class/;
# workaround to only build sun/io/* classes when necessary
# change the pathname of target file to be consistent
# with sun/io subdirectories
#
# sun/io was always getting rebuilt because the java files
# were split into subdirectories, but the package names
# remained the same. This was confusing outofdate.pl
#
$classfilename =~ s/sun\/io\/extended.\//sun\/io\//;
$classfilename =~ s/\.\.\/\.\.\/sun-java\/classsrc\///;
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,
$ctime,$blksize,$blocks) = stat($filename);
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$classmtime,
$ctime,$blksize,$blocks) = stat($classfilename);
# print $filename, " ", $mtime, ", ", $classfilename, " ", $classmtime, "\n";
if ($mtime > $classmtime) {
# Only print the file header if we actually have some files to
# compile.
if (!$printFile) {
$printFile = 1;
&printFile($CFG);
}
print $filename, " ";
$found = 0;
}
}
print "\n";
# push onto $ARG array all filenames with extension $ext
# @param ext the extension of the file
sub manuallyExpandArgument {
local($ext) = @_;
$ext = "\." . $ext; # put it in regexp
$result = opendir(DIR, ".");
@allfiles = grep(/$ext/, readdir(DIR));
$i = 0;
foreach $file (@allfiles) {
#skip emacs save files
$_ = $file;
if (!/~/) {
$ARGV[$i++] = $file;
}
}
}
sub printFile {
local($file) = @_;
$result = open(CFG, $file);
while (<CFG>) {
chop;
print $_;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,81 @@
#!nmake
#
# The contents of this file are subject to the Mozilla Public License
# Version 1.0 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
# the License for the specific language governing rights and limitations
# under the License.
#
# The Initial Developer of the Original Code is Sun Microsystems,
# Inc. Portions created by Sun are Copyright (C) 1999 Sun
# Microsystems, Inc. All Rights Reserved.
DEPTH=..\..\..
IGNORE_MANIFEST=1
MAKE_OBJ_TYPE = DLL
DLLNAME = webclient
DLL=.\$(OBJDIR)\$(DLLNAME).dll
MODULE=webclient
OBJS = \
.\$(OBJDIR)\nsActions.obj \
.\$(OBJDIR)\BrowserControlMozillaShim.obj \
$(NULL)
LINCS = \
$(NULL)
LCFLAGS = \
$(NULL)
LLIBS = \
$(DIST)\lib\raptorweb.lib \
$(DIST)\lib\raptorbasewidget_s.lib \
$(DIST)\lib\raptorwidget.lib \
$(DIST)\lib\xpcom.lib \
$(DIST)\lib\raptorgfxwin.lib \
$(DIST)\lib\nsreg.lib \
$(DIST)\lib\netlib.lib \
$(DIST)\lib\nspr3.lib \
$(DIST)\lib\plds3.lib \
$(DEPTH)\xpfe\bootstrap\WIN32_D.OBJ\nsSetupRegistry.obj \
$(NULL)
# $(DIST)\lib\raptorbase.lib \
# $(DIST)\lib\xpcom32.lib\
# $(DIST)\lib\xpcomds_s.lib\
WIN_LIBS = \
version.lib
include <$(DEPTH)\config\rules.mak>
include <..\config\localdefs.mak>
!CMDSWITCHES -S
# generate the jni header
export:: BrowserControlMozillaShim.h
BrowserControlMozillaShim.h:
@echo Assuming class org.mozilla.webclient.BrowserControlMozillaShim is in $(JAVAH_FLAGS)
$(JAVAH) $(JAVAH_FLAGS) -o $@ org.mozilla.webclient.BrowserControlMozillaShim
install:: $(DLL)
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin
@echo +++ Creating .\$(OBJDIR)\runem.bat. Use this to run the test browser.
@echo $(JAVA) -Djava.library.path=$(MOZ_SRC)\mozilla\dist\WIN32_D.OBJ\bin -classpath $(JAVAC_CLASSPATH) org.mozilla.webclient.test.EmbeddedMozilla %1% > .\$(OBJDIR)\runem.bat
clobber_all:: clobber
clobber::
rm -f $(DIST)\bin\$(DLLNAME).dll
rm -f BrowserControlMozillaShim.h
rm -f .\$(OBJDIR)\runem.bat

View File

@@ -0,0 +1,589 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The original code is RaptorCanvas
*
* The Initial Developer of the Original Code is Kirk Baker <kbaker@eb.com> and * Ian Wilkinson <iw@ennoble.com
*/
/*
* nsActions.cpp
*/
#include "nsActions.h"
void * handleEvent (PLEvent * event);
void destroyEvent (PLEvent * event);
void *
handleEvent (PLEvent * event)
{
nsActionEvent * actionEvent = (nsActionEvent*) event->owner;
void * result = nsnull;
if (actionEvent != NULL) {
actionEvent->setResult(result = actionEvent->handleEvent());
actionEvent->setComplete(PR_TRUE);
}
return result;
} // handleEvent()
void
destroyEvent (PLEvent * event)
{
nsActionEvent * actionEvent = (nsActionEvent*) event->owner;
if (actionEvent != NULL) {
if (!actionEvent->isSynchronous()) {
// Only delete if non-synchronous. Synchronous events are deleted by the event poster.
actionEvent->destroyEvent();
}
}
} // destroyEvent()
/*
* nsActionEvent
*/
nsActionEvent::nsActionEvent (PRBool synchronous)
{
PL_InitEvent(&mEvent, this,
(PLHandleEventProc ) ::handleEvent,
(PLDestroyEventProc) ::destroyEvent);
mSynchronous = synchronous;
mComplete = PR_FALSE;
mResult = nsnull;
}
PRBool
nsActionEvent::isComplete (void)
{
if (mSynchronous) {
return mComplete;
}
else {
return PR_TRUE;
}
} // isComplete()
/*
* wsResizeEvent
*/
wsResizeEvent::wsResizeEvent(nsIWebShell* webShell, PRInt32 x, PRInt32 y, PRInt32 w, PRInt32 h) :
nsActionEvent(PR_FALSE),
mWebShell(webShell),
mLeft(x),
mBottom(y),
mWidth(w),
mHeight(h)
{
}
void *
wsResizeEvent::handleEvent ()
{
if (mWebShell) {
printf("handleEvent(resize) x = %d y = %d w = %d h = %d\n", mLeft, mBottom, mWidth, mHeight);
nsresult rv = mWebShell->SetBounds(mLeft, mBottom, mWidth, mHeight);
printf("result = %lx\n", rv);
return (void *) rv;
}
return NULL;
} // handleEvent()
/*
* wsLoadURLEvent
*/
wsLoadURLEvent::wsLoadURLEvent(nsIWebShell* webShell, PRUnichar * urlString) :
nsActionEvent(PR_FALSE),
mWebShell(webShell),
mURL(nsnull)
{
mURL = new nsString1(urlString);
}
void *
wsLoadURLEvent::handleEvent ()
{
if (mWebShell && mURL) {
printf("handleEvent(loadURL)\n");
nsresult rv = mWebShell->LoadURL(mURL->GetUnicode());
printf("result = %lx\n", rv);
}
return NULL;
} // handleEvent()
wsLoadURLEvent::~wsLoadURLEvent ()
{
if (mURL != nsnull)
delete mURL;
}
/*
* wsStopEvent
*/
wsStopEvent::wsStopEvent(nsIWebShell* webShell) :
nsActionEvent(PR_FALSE),
mWebShell(webShell)
{
}
void *
wsStopEvent::handleEvent ()
{
if (mWebShell) {
printf("handleEvent(Stop)\n");
nsresult rv = mWebShell->Stop();
printf("result = %lx\n", rv);
}
return NULL;
} // handleEvent()
/*
* wsShowEvent
*/
wsShowEvent::wsShowEvent(nsIWebShell* webShell) :
nsActionEvent(PR_FALSE),
mWebShell(webShell)
{
}
void *
wsShowEvent::handleEvent ()
{
if (mWebShell) {
printf("handleEvent(Show)\n");
nsresult rv = mWebShell->Show();
printf("result = %lx\n", rv);
}
return NULL;
} // handleEvent()
/*
* wsHideEvent
*/
wsHideEvent::wsHideEvent(nsIWebShell* webShell) :
nsActionEvent(PR_FALSE),
mWebShell(webShell)
{
}
void *
wsHideEvent::handleEvent ()
{
if (mWebShell) {
printf("handleEvent(Hide)\n");
nsresult rv = mWebShell->Hide();
printf("result = %lx\n", rv);
}
return NULL;
} // handleEvent()
/*
* wsMoveToEvent
*/
wsMoveToEvent::wsMoveToEvent(nsIWebShell* webShell, PRInt32 x, PRInt32 y) :
nsActionEvent(PR_FALSE),
mWebShell(webShell),
mX(x),
mY(y)
{
}
void *
wsMoveToEvent::handleEvent ()
{
if (mWebShell) {
printf("handleEvent(MoveTo(%ld, %ld)\n", mX, mY);
nsresult rv = mWebShell->MoveTo(mX, mY);
printf("result = %lx\n", rv);
}
return NULL;
} // handleEvent()
/*
* wsSetFocusEvent
*/
wsSetFocusEvent::wsSetFocusEvent(nsIWebShell* webShell) :
nsActionEvent(PR_FALSE),
mWebShell(webShell)
{
}
void *
wsSetFocusEvent::handleEvent ()
{
if (mWebShell) {
printf("handleEvent(SetFocus()\n");
nsresult rv = mWebShell->SetFocus();
printf("result = %lx\n", rv);
}
return NULL;
} // handleEvent()
/*
* wsRemoveFocusEvent
*/
wsRemoveFocusEvent::wsRemoveFocusEvent(nsIWebShell* webShell) :
nsActionEvent(PR_FALSE),
mWebShell(webShell)
{
}
void *
wsRemoveFocusEvent::handleEvent ()
{
if (mWebShell) {
printf("handleEvent(RemoveFocus()\n");
nsresult rv = mWebShell->RemoveFocus();
printf("result = %lx\n", rv);
}
return NULL;
} // handleEvent()
/*
* wsRepaintEvent
*/
wsRepaintEvent::wsRepaintEvent(nsIWebShell* webShell, PRBool forceRepaint) :
nsActionEvent(PR_FALSE),
mWebShell(webShell),
mForceRepaint(forceRepaint)
{
}
void *
wsRepaintEvent::handleEvent ()
{
if (mWebShell) {
printf("handleEvent(Repaint(%d)\n", mForceRepaint);
nsresult rv = mWebShell->Repaint(mForceRepaint);
printf("result = %lx\n", rv);
}
return NULL;
} // handleEvent()
/*
* wsCanBackEvent
*/
wsCanBackEvent::wsCanBackEvent(nsIWebShell* webShell) :
nsActionEvent(PR_TRUE),
mWebShell(webShell)
{
}
void *
wsCanBackEvent::handleEvent ()
{
if (mWebShell) {
printf("handleEvent(CanBack()\n");
nsresult rv = mWebShell->CanBack();
printf("result = %lx\n", rv);
return (void *) rv;
}
return NULL;
} // handleEvent()
/*
* wsCanForwardEvent
*/
wsCanForwardEvent::wsCanForwardEvent(nsIWebShell* webShell) :
nsActionEvent(PR_TRUE),
mWebShell(webShell)
{
}
void *
wsCanForwardEvent::handleEvent ()
{
if (mWebShell) {
printf("handleEvent(CanForward()\n");
nsresult rv = mWebShell->CanForward();
printf("result = %lx\n", rv);
return (void *) rv;
}
return NULL;
} // handleEvent()
/*
* wsBackEvent
*/
wsBackEvent::wsBackEvent(nsIWebShell* webShell) :
nsActionEvent(PR_TRUE),
mWebShell(webShell)
{
}
void *
wsBackEvent::handleEvent ()
{
if (mWebShell) {
printf("handleEvent(Back()\n");
nsresult rv = mWebShell->Back();
printf("result = %lx\n", rv);
return (void *) rv;
}
return NULL;
} // handleEvent()
/*
* wsForwardEvent
*/
wsForwardEvent::wsForwardEvent(nsIWebShell* webShell) :
nsActionEvent(PR_TRUE),
mWebShell(webShell)
{
}
void *
wsForwardEvent::handleEvent ()
{
if (mWebShell) {
printf("handleEvent(Forward()\n");
nsresult rv = mWebShell->Forward();
printf("result = %lx\n", rv);
return (void *) rv;
}
return NULL;
} // handleEvent()
/*
* wsGoToEvent
*/
wsGoToEvent::wsGoToEvent(nsIWebShell* webShell, PRInt32 historyIndex) :
nsActionEvent(PR_TRUE),
mWebShell(webShell),
mHistoryIndex(historyIndex)
{
}
void *
wsGoToEvent::handleEvent ()
{
if (mWebShell) {
printf("handleEvent(GoTo(%ld)\n", mHistoryIndex);
nsresult rv = mWebShell->GoTo(mHistoryIndex);
printf("result = %lx\n", rv);
return (void *) rv;
}
return NULL;
} // handleEvent()
/*
* wsGetHistoryLengthEvent
*/
wsGetHistoryLengthEvent::wsGetHistoryLengthEvent(nsIWebShell* webShell) :
nsActionEvent(PR_TRUE),
mWebShell(webShell)
{
}
void *
wsGetHistoryLengthEvent::handleEvent ()
{
if (mWebShell) {
printf("handleEvent(wsGetHistoryLengthEvent()\n");
PRInt32 historyLength = 0;
nsresult rv = mWebShell->GetHistoryLength(historyLength);
printf("result = %lx\n", rv);
return (void *) historyLength;
}
return NULL;
} // handleEvent()
/*
* wsGetHistoryIndexEvent
*/
wsGetHistoryIndexEvent::wsGetHistoryIndexEvent(nsIWebShell* webShell) :
nsActionEvent(PR_TRUE),
mWebShell(webShell)
{
}
void *
wsGetHistoryIndexEvent::handleEvent ()
{
if (mWebShell) {
printf("handleEvent(wsGetHistoryIndexEvent()\n");
PRInt32 historyIndex = 0;
nsresult rv = mWebShell->GetHistoryIndex(historyIndex);
printf("result = %lx\n", rv);
return (void *) historyIndex;
}
return NULL;
} // handleEvent()
/*
* wsGetURLEvent
*/
wsGetURLEvent::wsGetURLEvent(nsIWebShell* webShell, PRInt32 historyIndex) :
nsActionEvent(PR_TRUE),
mWebShell(webShell),
mHistoryIndex(historyIndex)
{
}
void *
wsGetURLEvent::handleEvent ()
{
if (mWebShell) {
printf("handleEvent(wsGetURLEvent(%ld)\n", mHistoryIndex);
const PRUnichar * url = nsnull;
// returns PRUninchar * URL in <url>. No need to delete. References internal buffer of an nsString
nsresult rv = mWebShell->GetURL(mHistoryIndex, &url);
printf("result = %lx, url = %lx\n", rv, url);
return (void *) url;
}
return NULL;
} // handleEvent()
// EOF

View File

@@ -0,0 +1,251 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The original code is RaptorCanvas
*
* The Initial Developer of the Original Code is Kirk Baker <kbaker@eb.com> and * Ian Wilkinson <iw@ennoble.com
*/
/*
* nsActions.h
*/
#ifndef nsActions_h___
#define nsActions_h___
#include <windows.h>
#include "nsIWebShell.h"
#include "nsString.h"
#include "plevent.h"
class nsActionEvent {
public:
nsActionEvent (PRBool synchronous);
virtual ~nsActionEvent () {};
virtual void * handleEvent (void) { return NULL;};
void destroyEvent (void) { delete this; };
operator PLEvent* () { return &mEvent; };
PRBool isSynchronous (void) { return mSynchronous; };
PRBool isComplete (void);
void setComplete (PRBool complete) { mComplete = complete; };
void * getResult (void) { return mResult; };
void setResult (void * result) { mResult = result; };
protected:
PLEvent mEvent;
void * mResult;
PRBool mSynchronous;
PRBool mComplete;
};
class wsResizeEvent : public nsActionEvent {
public:
wsResizeEvent (nsIWebShell* webShell, PRInt32 x, PRInt32 y, PRInt32 w, PRInt32 h);
void * handleEvent (void);
protected:
nsIWebShell * mWebShell;
PRInt32 mLeft;
PRInt32 mBottom;
PRInt32 mWidth;
PRInt32 mHeight;
};
class wsLoadURLEvent : public nsActionEvent {
public:
wsLoadURLEvent (nsIWebShell* webShell, PRUnichar * urlString);
~wsLoadURLEvent ();
void * handleEvent (void);
protected:
nsIWebShell * mWebShell;
nsString1 * mURL;
};
class wsStopEvent : public nsActionEvent {
public:
wsStopEvent (nsIWebShell* webShell);
void * handleEvent (void);
protected:
nsIWebShell * mWebShell;
};
class wsShowEvent : public nsActionEvent {
public:
wsShowEvent (nsIWebShell* webShell);
void * handleEvent (void);
protected:
nsIWebShell * mWebShell;
};
class wsHideEvent : public nsActionEvent {
public:
wsHideEvent (nsIWebShell* webShell);
void * handleEvent (void);
protected:
nsIWebShell * mWebShell;
};
class wsMoveToEvent : public nsActionEvent {
public:
wsMoveToEvent (nsIWebShell* webShell, PRInt32 x, PRInt32 y);
void * handleEvent (void);
protected:
nsIWebShell * mWebShell;
PRInt32 mX;
PRInt32 mY;
};
class wsSetFocusEvent : public nsActionEvent {
public:
wsSetFocusEvent (nsIWebShell* webShell);
void * handleEvent (void);
protected:
nsIWebShell * mWebShell;
};
class wsRemoveFocusEvent : public nsActionEvent {
public:
wsRemoveFocusEvent (nsIWebShell* webShell);
void * handleEvent (void);
protected:
nsIWebShell * mWebShell;
};
class wsRepaintEvent : public nsActionEvent {
public:
wsRepaintEvent (nsIWebShell* webShell, PRBool forceRepaint);
void * handleEvent (void);
protected:
nsIWebShell * mWebShell;
PRBool mForceRepaint;
};
class wsCanBackEvent : public nsActionEvent {
public:
wsCanBackEvent (nsIWebShell* webShell);
void * handleEvent (void);
protected:
nsIWebShell * mWebShell;
};
class wsCanForwardEvent : public nsActionEvent {
public:
wsCanForwardEvent (nsIWebShell* webShell);
void * handleEvent (void);
protected:
nsIWebShell * mWebShell;
};
class wsBackEvent : public nsActionEvent {
public:
wsBackEvent (nsIWebShell* webShell);
void * handleEvent (void);
protected:
nsIWebShell * mWebShell;
};
class wsForwardEvent : public nsActionEvent {
public:
wsForwardEvent (nsIWebShell* webShell);
void * handleEvent (void);
protected:
nsIWebShell * mWebShell;
};
class wsGoToEvent : public nsActionEvent {
public:
wsGoToEvent (nsIWebShell* webShell, PRInt32 historyIndex);
void * handleEvent (void);
protected:
nsIWebShell * mWebShell;
PRInt32 mHistoryIndex;
};
class wsGetHistoryLengthEvent : public nsActionEvent {
public:
wsGetHistoryLengthEvent
(nsIWebShell* webShell);
void * handleEvent (void);
protected:
nsIWebShell * mWebShell;
};
class wsGetHistoryIndexEvent : public nsActionEvent {
public:
wsGetHistoryIndexEvent
(nsIWebShell* webShell);
void * handleEvent (void);
protected:
nsIWebShell * mWebShell;
};
class wsGetURLEvent : public nsActionEvent {
public:
wsGetURLEvent (nsIWebShell* webShell, PRInt32 historyIndex);
void * handleEvent (void);
protected:
nsIWebShell * mWebShell;
PRInt32 mHistoryIndex;
};
#endif /* nsActions_h___ */
// EOF