зеркало из https://github.com/mozilla/pjs.git
This is a checkpoint milestone for webclient 2.0. Webclient currently
doesn't run, but several unit tests for webclient do. I'll be proceeding through the rest of the webclient interfaces, building junit tests as I go, in the coming months. I hope to flesh out the basic framework, then publish build instructions, and hopefully I can get some contributions from the community. M util/classes/org/mozilla/util/Utilities.java new method: getImplFromServices: + * + * <p>This method tries to load the resource + * <code>META-INF/services/>interfaceClassName></code>, where + * <code>>interfaceClassName<</code> is the argument to this + * method. If the resource is found, interpret it as a + * <code>Properties</code> file and read out its first line. + * Interpret the first line as the fully qualified class name of a + * class that implements <code></code>. The named class must have a + * public no-arg constructor.</p> M webclient/build-tests.xml - junit testcases for Webclient APIs, developed using test-first. M webclient/build.xml - changes for new package name structure: packages org.mozilla.webclient.{wrapper_native, wrapper_non_native} have gone away. Replaced with org.mozilla.webclient.impl.{wrapper_native, wrapper_non_native} - changes to accomodate "Services" based approach for pluggable webclient implementation. - don't bother re-naming the javah generated files, just let javah pick the names. - pass debugging args from build.properties - changed name of junit test target to "test". M webclient/classes_spec/org/mozilla/webclient/BrowserControl.java - got rid of BROWSER_TYPE. No longer necessary due to the new pluggability mechanism. M webclient/classes_spec/org/mozilla/webclient/BrowserControlFactory.java - Leverage the org.mozilla.util.Utilities.getImplFromServices() mechanism to allow a vendor-pluggable webclient implementation of the new "WebclientFactory" interface, which is method for method compatible with BrowserControlFactory. Make all BrowserControlFactory methods call through to methods on the vendor provided WebclientFactory implementation. R webclient/classes_spec/org/mozilla/webclient/BrowserControlFactoryInterface.java A webclient/classes_spec/org/mozilla/webclient/BrowserControlICE.java R webclient/classes_spec/org/mozilla/webclient/BrowserControlImpl.java R webclient/classes_spec/org/mozilla/webclient/BrowserType.java - move all implementation specific classe to the impl package. M webclient/classes_spec/org/mozilla/webclient/ImplObject.java - ImplObject shouldn't depend on vendor private classes. M webclient/classes_spec/org/mozilla/webclient/Preferences.java - new method + public void unregisterPrefChangedCallback(PrefChangedCallback cb, + String prefName, Object closure); M webclient/classes_spec/org/mozilla/webclient/ProfileManager.java - properly specify this interface. A webclient/classes_spec/org/mozilla/webclient/WebclientFactory.java * <p>This interface allows a pluggable webclient API implementation. * The static methods in {@link BrowserControlFactory} call through to * methods on this interface. Please see {@link BrowserControlFactory} * for information on how to hook up your <code>WebclientFactory</code> * implementation to the <code>BrowserControlFactory</code></p> R webclient/classes_spec/org/mozilla/webclient/WrapperFactory.java R webclient/classes_spec/org/mozilla/webclient/impl/BrowserControlFactoryImpl.java - moved these to the impl class A webclient/classes_spec/org/mozilla/webclient/impl/BrowserControlImpl.java A webclient/classes_spec/org/mozilla/webclient/impl/Service.java A webclient/classes_spec/org/mozilla/webclient/impl/WebclientFactoryImpl.java A webclient/classes_spec/org/mozilla/webclient/impl/WrapperFactory.java A webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/BookmarkEntryImpl.java A webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/BookmarksImpl.java A webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/CurrentPageImpl.java A webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/EventRegistrationImpl.java A webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/HistoryImpl.java A webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/ISupportsPeer.java A webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/ImplObjectNative.java A webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/NativeEventThread.java A webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/NavigationImpl.java A webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/PreferencesImpl.java A webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/ProfileManagerImpl.java A webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/RDFEnumeration.java A webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/RDFTreeNode.java A webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/SelectionImpl.java A webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/WCEventListenerWrapper.java A webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/WCMouseListenerImpl.java A webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/WindowControlImpl.java A webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/WrapperFactoryImpl.java A webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/gtk/GtkBrowserControlCanvas.java A webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/win32/Win32BrowserControlCanvas.java - copied from old package naming scheme. - lots and lots of cleanup. R webclient/classes_spec/org/mozilla/webclient/wrapper_native/BookmarkEntryImpl.java R webclient/classes_spec/org/mozilla/webclient/wrapper_native/BookmarksImpl.java R webclient/classes_spec/org/mozilla/webclient/wrapper_native/CurrentPageImpl.java R webclient/classes_spec/org/mozilla/webclient/wrapper_native/EventRegistrationImpl.java R webclient/classes_spec/org/mozilla/webclient/wrapper_native/HistoryImpl.java R webclient/classes_spec/org/mozilla/webclient/wrapper_native/ISupportsPeer.java R webclient/classes_spec/org/mozilla/webclient/wrapper_native/ImplObjectNative.java R webclient/classes_spec/org/mozilla/webclient/wrapper_native/NativeEventThread.java R webclient/classes_spec/org/mozilla/webclient/wrapper_native/NavigationImpl.java R webclient/classes_spec/org/mozilla/webclient/wrapper_native/PreferencesImpl.java R webclient/classes_spec/org/mozilla/webclient/wrapper_native/ProfileManagerImpl.java R webclient/classes_spec/org/mozilla/webclient/wrapper_native/RDFEnumeration.java R webclient/classes_spec/org/mozilla/webclient/wrapper_native/RDFTreeNode.java A webclient/classes_spec/org/mozilla/webclient/wrapper_native/README R webclient/classes_spec/org/mozilla/webclient/wrapper_native/SelectionImpl.java R webclient/classes_spec/org/mozilla/webclient/wrapper_native/WCEventListenerWrapper.java R webclient/classes_spec/org/mozilla/webclient/wrapper_native/WCMouseListenerImpl.java R webclient/classes_spec/org/mozilla/webclient/wrapper_native/WindowControlImpl.java R webclient/classes_spec/org/mozilla/webclient/wrapper_native/WrapperFactoryImpl.java R webclient/classes_spec/org/mozilla/webclient/wrapper_native/gtk/GtkBrowserControlCanvas.java R webclient/classes_spec/org/mozilla/webclient/wrapper_native/win32/Win32BrowserControlCanvas.java - removed from old package naming scheme M webclient/src_moz/BookmarksImpl.cpp - remove dependency on RDFActionEvents by inlining all the code that formerly was in the events. - package name change - JNI include file name change M webclient/src_moz/CurrentPageImpl.cpp M webclient/src_moz/HistoryImpl.cpp M webclient/src_moz/ISupportsPeer.cpp - package name change - JNI include file name change M webclient/src_moz/Makefile.in - get rid of PreferencesActionEvents.cpp and RDFActionEvents.cpp - add ProfileManagerImpl.cpp M webclient/src_moz/NativeEventThread.cpp - this file is not done yet. I've been pulling misplaced initialization stuff out of here and putting it into WrapperFactoryImpl.cpp. - got rid of gComponentManager, since we can use do_CreateInstance instead. - package name change - JNI include file name change M webclient/src_moz/NativeEventThreadActionEvents.h - JNI include file name change M webclient/src_moz/NavigationImpl.cpp - package name change - JNI include file name change R webclient/src_moz/PreferencesActionEvents.cpp R webclient/src_moz/PreferencesActionEvents.h - don't need these anymore! woohoo! M webclient/src_moz/PreferencesImpl.cpp - remove dependency on PreferencesActionEvents by inlining code into the methods that used to use the events. A webclient/src_moz/ProfileManagerImpl.cpp - new class, implementation of the ProfileManager interface. M webclient/src_moz/PromptActionEvents.cpp - change erroneous comment so my grep performed correctly. R webclient/src_moz/RDFActionEvents.cpp R webclient/src_moz/RDFActionEvents.h - don't need these anymore! woohoo! M webclient/src_moz/RDFEnumeration.cpp M webclient/src_moz/RDFTreeNode.cpp - remove dependency on RDFActionEvents by inlining code into the methods that used to use the events. M webclient/src_moz/WindowControlActionEvents.cpp - deallocate shareInitiContext. M webclient/src_moz/WindowControlImpl.cpp - package name change - JNI include file name change - remove the "sleep so I can attach gdb" code. Moved to WrapperFactoryImpl.cpp. M webclient/src_moz/WrapperFactoryImpl.cpp - lots of changes. This is now where the app initialization and shutdown happens, M webclient/src_moz/dom_util.cpp - comment change M webclient/src_moz/ns_globals.h - get rid of inappropriate global usage. M webclient/src_moz/ns_util.h - new struct WebclientContext for singletons. M webclient/src_moz/rdf_util.cpp - new methods, rdf_startup and rdf_shutdown. - replace calls to nsComponentManager::CreateInstance() with do_CreateInstance(). M webclient/src_moz/rdf_util.h - new methods, rdf_startup and rdf_shutdown. M webclient/src_moz/gtk/GtkBrowserControlCanvas.cpp - package name change - JNI include file name change M webclient/src_moz/gtk/GtkBrowserControlCanvasStub.cpp - package name change - JNI include file name change - this file isn't needed anymore, thankfully! I'll remove it soon. M webclient/src_moz/gtk/StubFunctions.h - package name change - JNI include file name change - this file isn't needed anymore, thankfully! I'll remove it soon. M webclient/src_moz/motif/BrowserControlNativeShimStub.cpp M webclient/src_moz/motif/MotifBrowserControlCanvas.cpp M webclient/src_moz/motif/MotifBrowserControlCanvasStub.cpp M webclient/src_moz/motif/NativeLoaderStub.cpp M webclient/src_moz/win32/Win32BrowserControlCanvas.cpp - package name change - JNI include file name change M webclient/src_share/jni_util.cpp M webclient/src_share/jni_util.h - util_InitializeShareInitContext() takes a JNIEnv *. - new methods +void util_DeleteGlobalRef(JNIEnv *env, jobject toDeleteRef); +void util_DeleteLocalRef(JNIEnv *env, jobject toDeleteRef); +void util_getSystemProperty(JNIEnv *env, + const char *propName, + char *propValue, + jint propValueLen); M webclient/src_share/jni_util_export.cpp M webclient/src_share/jni_util_export.h +JNIEXPORT jobjectArray util_GetJstringArrayFromJcharArray(JNIEnv *env, + jint len, + jchar **strings, + jint *stringLengths) A webclient/test/automated/src/classes/org/mozilla/webclient/BookmarksTest.java R webclient/test/automated/src/classes/org/mozilla/webclient/BrowserControlFactoryTest.java A webclient/test/automated/src/classes/org/mozilla/webclient/PreferencesTest.java A webclient/test/automated/src/classes/org/mozilla/webclient/ProfileManagerTest.java A webclient/test/automated/src/classes/org/mozilla/webclient/impl/WebclientFactoryImplTest.java A webclient/test/automated/src/classes/org/mozilla/webclient/impl/wrapper_native/WrapperFactoryImplTest.java A webclient/test/automated/src/classes/org/mozilla/webclient/impl/wrapper_native/gtk/TestGtkBrowserControlCanvas.java R webclient/test/automated/src/classes/org/mozilla/webclient/wrapper_native/gtk/TestGtkBrowserControlCanvas.java A webclient/test/automated/src/test/BrowserControlFactoryTest_correct - junit tests! TEST FIRST!
This commit is contained in:
Родитель
228afa0530
Коммит
f93e3b0d01
|
@ -33,6 +33,11 @@ import java.util.MissingResourceException;
|
|||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
public class Utilities extends Object {
|
||||
// PENDING(kbern) NOTE: These Vector methods should eventually move into a file
|
||||
|
@ -284,5 +289,81 @@ public class Utilities extends Object {
|
|||
return aString.regionMatches(true, aString.length() - endingLength,
|
||||
possibleEnding, 0, endingLength);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* <p>This method tries to load the resource
|
||||
* <code>META-INF/services/>interfaceClassName></code>, where
|
||||
* <code>>interfaceClassName<</code> is the argument to this
|
||||
* method. If the resource is found, interpret it as a
|
||||
* <code>Properties</code> file and read out its first line.
|
||||
* Interpret the first line as the fully qualified class name of a
|
||||
* class that implements <code></code>. The named class must have a
|
||||
* public no-arg constructor.</p>
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
public static Object getImplFromServices(String interfaceClassName) {
|
||||
Object instance = null;
|
||||
|
||||
ClassLoader classLoader =
|
||||
Thread.currentThread().getContextClassLoader();
|
||||
if (classLoader == null) {
|
||||
throw new RuntimeException("Context ClassLoader");
|
||||
}
|
||||
|
||||
BufferedReader reader = null;
|
||||
InputStream stream = null;
|
||||
String
|
||||
className = null,
|
||||
resourceName = "META-INF/services/" + interfaceClassName;
|
||||
try {
|
||||
stream = classLoader.getResourceAsStream(resourceName);
|
||||
if (stream != null) {
|
||||
// Deal with systems whose native encoding is possibly
|
||||
// different from the way that the services entry was created
|
||||
try {
|
||||
reader =
|
||||
new BufferedReader(new InputStreamReader(stream,
|
||||
"UTF-8"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
reader = new BufferedReader(new InputStreamReader(stream));
|
||||
}
|
||||
className = reader.readLine();
|
||||
reader.close();
|
||||
reader = null;
|
||||
stream = null;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
} catch (SecurityException e) {
|
||||
} finally {
|
||||
if (reader != null) {
|
||||
try {
|
||||
reader.close();
|
||||
} catch (Throwable t) {
|
||||
;
|
||||
}
|
||||
reader = null;
|
||||
stream = null;
|
||||
}
|
||||
if (stream != null) {
|
||||
try {
|
||||
stream.close();
|
||||
} catch (Throwable t) {
|
||||
;
|
||||
}
|
||||
stream = null;
|
||||
}
|
||||
}
|
||||
if (null != className) {
|
||||
try {
|
||||
Class clazz = classLoader.loadClass(className);
|
||||
instance = clazz.newInstance();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -72,6 +72,7 @@
|
|||
<!-- Output directory for test data files -->
|
||||
<property name="build.test" value="${basedir}/build.test"/>
|
||||
|
||||
<property name="native.waitForDebugger" value=""/>
|
||||
|
||||
<path id="test.classpath">
|
||||
<pathelement location="${junit.jar}"/>
|
||||
|
@ -128,14 +129,20 @@
|
|||
<jvmarg value="-DNSPR_LOG_MODULES=${myenv.NSPR_LOG_MODULES}"/>
|
||||
<jvmarg value="-DNSPR_LOG_FILE=${myenv.NSPR_LOG_FILE}"/>
|
||||
<jvmarg value="-DBROWSER_BIN_DIR=${myenv.MOZILLA_FIVE_HOME}"/>
|
||||
<sysproperty key="native.waitForDebugger"
|
||||
value="${native.waitForDebugger}"/>
|
||||
<jvmarg line="${debug.jvm.args}"/>
|
||||
|
||||
|
||||
<classpath refid="test.classpath"/>
|
||||
|
||||
<formatter type="plain" usefile="false"/>
|
||||
|
||||
<test name="org.mozilla.webclient.BrowserControlFactoryTest"/>
|
||||
<test name="org.mozilla.webclient.ProfileManagerTest"/>
|
||||
<test name="org.mozilla.webclient.PreferencesTest"/>
|
||||
<test name="org.mozilla.webclient.BookmarksTest"/>
|
||||
<test name="org.mozilla.webclient.impl.WebclientFactoryImplTest"/>
|
||||
<test name="org.mozilla.webclient.impl.wrapper_native.WrapperFactoryImplTest"/>
|
||||
|
||||
<!-- non-running tests
|
||||
|
||||
<test name="org.mozilla.webclient.wrapper_native.gtk.TestGtkBrowserControlCanvas"/>
|
||||
|
|
|
@ -72,11 +72,12 @@
|
|||
<classpath refid="compile.classpath"/>
|
||||
<src path="${source.home}"/>
|
||||
<patternset>
|
||||
<include name="org/mozilla/webclient/wrapper_native/gtk/*"
|
||||
<include name="org/mozilla/webclient/impl/wrapper_native/gtk/*"
|
||||
if="build.unix.classes"/>
|
||||
</patternset>
|
||||
|
||||
<patternset>
|
||||
<include name="org/mozilla/webclient/wrapper_native/win32/*"
|
||||
<include name="org/mozilla/webclient/impl/wrapper_native/win32/*"
|
||||
if="build.win32.classes"/>
|
||||
</patternset>
|
||||
|
||||
|
@ -84,13 +85,14 @@
|
|||
HotJava, etc -->
|
||||
|
||||
<include name="org/mozilla/webclient/*"/>
|
||||
<include name="org/mozilla/webclient/wrapper_native/*"/>
|
||||
<include name="org/mozilla/webclient/impl/**"/>
|
||||
<include name="org/mozilla/webclient/impl/wrapper_native/*"/>
|
||||
<include name="org/mozilla/webclient/impl/*"/>
|
||||
<include name="org/mozilla/webclient/test/*"/>
|
||||
</javac>
|
||||
|
||||
<mkdir dir="${build.home}/META-INF/services"/>
|
||||
<echo file="${build.home}/META-INF/services/org.mozilla.webclient.BrowserControlFactoryInterface">org.mozilla.webclient.impl.BrowserControlFactoryImpl</echo>
|
||||
<echo file="${build.home}/META-INF/services/org.mozilla.webclient.WebclientFactory">org.mozilla.webclient.impl.WebclientFactoryImpl</echo>
|
||||
<echo file="${build.home}/META-INF/services/org.mozilla.webclient.impl.WrapperFactory">org.mozilla.webclient.impl.wrapper_native.WrapperFactoryImpl</echo>
|
||||
|
||||
</target>
|
||||
|
||||
|
@ -105,50 +107,10 @@
|
|||
|
||||
</target>
|
||||
|
||||
<target name="compile.javah.headers" depends="compile.javah.canvas.headers">
|
||||
<target name="compile.javah.headers" depends="compile.classes_spec,compile.javah.canvas.headers">
|
||||
|
||||
<javah outputFile="${basedir}/src_share/BookmarksImpl.h"
|
||||
class="org.mozilla.webclient.wrapper_native.BookmarksImpl">
|
||||
<classpath refid="compile.classpath"/>
|
||||
</javah>
|
||||
<javah outputFile="${basedir}/src_share/PreferencesImpl.h"
|
||||
class="org.mozilla.webclient.wrapper_native.PreferencesImpl">
|
||||
<classpath refid="compile.classpath"/>
|
||||
</javah>
|
||||
<javah outputFile="${basedir}/src_share/CurrentPageImpl.h"
|
||||
class="org.mozilla.webclient.wrapper_native.CurrentPageImpl">
|
||||
<classpath refid="compile.classpath"/>
|
||||
</javah>
|
||||
<javah outputFile="${basedir}/src_share/HistoryImpl.h"
|
||||
class="org.mozilla.webclient.wrapper_native.HistoryImpl">
|
||||
<classpath refid="compile.classpath"/>
|
||||
</javah>
|
||||
<javah outputFile="${basedir}/src_share/WrapperFactoryImpl.h"
|
||||
class="org.mozilla.webclient.wrapper_native.WrapperFactoryImpl">
|
||||
<classpath refid="compile.classpath"/>
|
||||
</javah>
|
||||
<javah outputFile="${basedir}/src_share/NavigationImpl.h"
|
||||
class="org.mozilla.webclient.wrapper_native.NavigationImpl">
|
||||
<classpath refid="compile.classpath"/>
|
||||
</javah>
|
||||
<javah outputFile="${basedir}/src_share/RDFEnumeration.h"
|
||||
class="org.mozilla.webclient.wrapper_native.RDFEnumeration">
|
||||
<classpath refid="compile.classpath"/>
|
||||
</javah>
|
||||
<javah outputFile="${basedir}/src_share/RDFTreeNode.h"
|
||||
class="org.mozilla.webclient.wrapper_native.RDFTreeNode">
|
||||
<classpath refid="compile.classpath"/>
|
||||
</javah>
|
||||
<javah outputFile="${basedir}/src_share/ISupportsPeer.h"
|
||||
class="org.mozilla.webclient.wrapper_native.ISupportsPeer">
|
||||
<classpath refid="compile.classpath"/>
|
||||
</javah>
|
||||
<javah outputFile="${basedir}/src_share/WindowControlImpl.h"
|
||||
class="org.mozilla.webclient.wrapper_native.WindowControlImpl">
|
||||
<classpath refid="compile.classpath"/>
|
||||
</javah>
|
||||
<javah outputFile="${basedir}/src_share/NativeEventThread.h"
|
||||
class="org.mozilla.webclient.wrapper_native.NativeEventThread">
|
||||
<javah destdir="${basedir}/src_share"
|
||||
class="org.mozilla.webclient.impl.wrapper_native.BookmarksImpl,org.mozilla.webclient.impl.wrapper_native.ProfileManagerImpl,org.mozilla.webclient.impl.wrapper_native.PreferencesImpl,org.mozilla.webclient.impl.wrapper_native.CurrentPageImpl,org.mozilla.webclient.impl.wrapper_native.HistoryImpl,org.mozilla.webclient.impl.wrapper_native.WrapperFactoryImpl,org.mozilla.webclient.impl.wrapper_native.NavigationImpl,org.mozilla.webclient.impl.wrapper_native.RDFEnumeration,org.mozilla.webclient.impl.wrapper_native.RDFTreeNode,org.mozilla.webclient.impl.wrapper_native.ISupportsPeer,org.mozilla.webclient.impl.wrapper_native.WindowControlImpl,org.mozilla.webclient.impl.wrapper_native.NativeEventThread">
|
||||
<classpath refid="compile.classpath"/>
|
||||
</javah>
|
||||
</target>
|
||||
|
@ -158,8 +120,8 @@
|
|||
|
||||
<target name="compile.unix.canvas.headers" if="build.unix.classes">
|
||||
|
||||
<javah outputFile="${basedir}/src_moz/gtk/GtkBrowserControlCanvas.h"
|
||||
class="org.mozilla.webclient.wrapper_native.gtk.GtkBrowserControlCanvas">
|
||||
<javah destdir="${basedir}/src_moz/gtk"
|
||||
class="org.mozilla.webclient.impl.wrapper_native.gtk.GtkBrowserControlCanvas">
|
||||
<classpath refid="compile.classpath"/>
|
||||
</javah>
|
||||
|
||||
|
@ -167,8 +129,8 @@
|
|||
|
||||
<target name="compile.win32.canvas.headers" if="build.win32.classes">
|
||||
|
||||
<javah outputFile="${basedir}/src_moz/win32/Win32BrowserControlCanvas.h"
|
||||
class="org.mozilla.webclient.wrapper_native.win32.Win32BrowserControlCanvas">
|
||||
<javah destdir="${basedir}/src_moz/win32"
|
||||
class="org.mozilla.webclient.impl.wrapper_native.win32.Win32BrowserControlCanvas">
|
||||
<classpath refid="compile.classpath"/>
|
||||
</javah>
|
||||
|
||||
|
@ -207,7 +169,7 @@ depends="create.win32.webclient.scripts,create.unix.webclient.scripts"/>
|
|||
<target name="create.win32.webclient.scripts"
|
||||
if="build.win32.classes">
|
||||
|
||||
<condition property="debug.options" value="-Xdebug -Xrunjdwp:transport=dt_shmem,address=jdbconn,server=y,suspend=n">
|
||||
<condition property="debug.options" value="${debug.jvm.args}">
|
||||
<equals arg1="${myenv.MOZ_DEBUG}" arg2="1"/>
|
||||
</condition>
|
||||
<condition property="debug.options" value="">
|
||||
|
@ -225,7 +187,7 @@ ${myenv.MOZ_JDKHOME}/bin/java ${debug.options} org.mozilla.webclient.test.Embedd
|
|||
<target name="create.unix.webclient.scripts"
|
||||
if="build.unix.classes">
|
||||
|
||||
<condition property="debug.options" value="-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n">
|
||||
<condition property="debug.options" value="${debug.jvm.args}">
|
||||
<equals arg1="${myenv.MOZ_DEBUG}" arg2="1"/>
|
||||
</condition>
|
||||
<condition property="debug.options" value="">
|
||||
|
@ -242,9 +204,41 @@ ${myenv.MOZ_JDKHOME}/bin/java ${debug.options} org.mozilla.webclient.test.Embedd
|
|||
|
||||
</target>
|
||||
|
||||
<target name="clean">
|
||||
<target name="clean.classes_spec">
|
||||
<delete dir="${build.home}/org/mozilla/webclient"/>
|
||||
</target>
|
||||
|
||||
<target name="clean" depends="clean.classes_spec">
|
||||
|
||||
<ant antfile="build-tests.xml" target="clean"/>
|
||||
<delete>
|
||||
<fileset dir="${basedir}/src_moz">
|
||||
<include name="**/*BrowserControlCanvas.h"/>
|
||||
<exclude name="motif/MotifBrowserControlCanvas.h"/>
|
||||
</fileset>
|
||||
</delete>
|
||||
|
||||
<delete >
|
||||
<fileset dir="${basedir}/src_share">
|
||||
<include name="*.h"/>
|
||||
<exclude name="bal_util.h"/>
|
||||
<exclude name="jni_util_export.h"/>
|
||||
<exclude name="jni_util.h"/>
|
||||
</fileset>
|
||||
</delete>
|
||||
|
||||
<delete >
|
||||
<fileset dir="${basedir}/src_moz">
|
||||
<include name="*.ilk"/>
|
||||
</fileset>
|
||||
</delete>
|
||||
|
||||
|
||||
<delete >
|
||||
<fileset dir="${basedir}/src_ie">
|
||||
<include name="*.ilk"/>
|
||||
</fileset>
|
||||
</delete>
|
||||
|
||||
<exec os="SunOS" dir="${basedir}/src_moz" executable="gmake"
|
||||
failonerror="yes">
|
||||
|
@ -284,37 +278,9 @@ ${myenv.MOZ_JDKHOME}/bin/java ${debug.options} org.mozilla.webclient.test.Embedd
|
|||
<arg line="clobber_all"/>
|
||||
</exec>
|
||||
|
||||
<delete >
|
||||
<fileset dir="${basedir}/src_share">
|
||||
<include name="*.h"/>
|
||||
<exclude name="bal_util.h"/>
|
||||
<exclude name="jni_util_export.h"/>
|
||||
<exclude name="jni_util.h"/>
|
||||
</fileset>
|
||||
</delete>
|
||||
|
||||
<delete >
|
||||
<fileset dir="${basedir}/src_moz">
|
||||
<include name="*.ilk"/>
|
||||
</fileset>
|
||||
</delete>
|
||||
|
||||
|
||||
<delete file="${basedir}/src_moz/gtk/GtkBrowserControlCanvas.h"/>
|
||||
<delete file="${basedir}/src_moz/win32/Win32BrowserControlCanvas.h"/>
|
||||
|
||||
|
||||
<delete dir="${build.home}/org/mozilla/webclient"/>
|
||||
|
||||
<delete >
|
||||
<fileset dir="${basedir}/src_ie">
|
||||
<include name="*.ilk"/>
|
||||
</fileset>
|
||||
</delete>
|
||||
|
||||
</target>
|
||||
|
||||
<target name="run.test" depends="main" description="Run unit tests">
|
||||
<target name="test" depends="main" description="Run unit tests">
|
||||
|
||||
<ant antfile="build-tests.xml" target="run.test"/>
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ package org.mozilla.webclient;
|
|||
|
||||
|
||||
*
|
||||
* @version $Id: BrowserControl.java,v 1.3 2001-07-27 20:57:51 ashuk%eng.sun.com Exp $
|
||||
* @version $Id: BrowserControl.java,v 1.4 2003-09-28 06:29:04 edburns%acm.org Exp $
|
||||
*
|
||||
* @see org.mozilla.webclient.BrowserControlFactory
|
||||
* */
|
||||
|
@ -44,7 +44,6 @@ package org.mozilla.webclient;
|
|||
public interface BrowserControl
|
||||
{
|
||||
|
||||
public static String BROWSER_TYPE_NAME = "webclient.BrowserType";
|
||||
public static String BOOKMARKS_NAME = "webclient.Bookmarks";
|
||||
public static String BROWSER_CONTROL_CANVAS_NAME = "webclient.BrowserControlCanvas";
|
||||
public static String CURRENT_PAGE_NAME = "webclient.CurrentPage";
|
||||
|
@ -58,8 +57,16 @@ public static String PRINT_NAME = "webclient.Print";
|
|||
public static String WINDOW_CONTROL_NAME = "webclient.WindowControl";
|
||||
public static String PROFILE_MANAGER_NAME = "webclient.ProfileManager";
|
||||
|
||||
public static String BROWSER_TYPE_NATIVE = "native";
|
||||
public static String BROWSER_TYPE_NON_NATIVE = "nonnative";
|
||||
/**
|
||||
* @deprecated the type of browser implementation is derived using a
|
||||
* services definition loaded from {@link
|
||||
* org.mozilla.util.Utilities#getImplFromServices}
|
||||
*
|
||||
*/
|
||||
|
||||
public static String BROWSER_TYPE_NATIVE = null;
|
||||
public static String BROWSER_TYPE_NON_NATIVE = null;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
|
|
|
@ -31,37 +31,20 @@ package org.mozilla.webclient;
|
|||
import org.mozilla.util.Assert;
|
||||
import org.mozilla.util.Log;
|
||||
import org.mozilla.util.ParameterCheck;
|
||||
import org.mozilla.util.Utilities;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Properties;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* <p><B>BrowserControlFactory</B> uses a discovery algorithm to find
|
||||
* an implementation of {@link BrowserControlFactoryInterface}. All of
|
||||
* the public static methods in this class simply call through to this
|
||||
* <p><B>BrowserControlFactory</B> uses the discovery algorithm below
|
||||
* to find an implementation of {@link WebclientFactory}. All of the
|
||||
* public static methods in this class simply call through to this
|
||||
* implemenatation instance.</p>
|
||||
*
|
||||
* <p>The discovery mechanism used is to look try to load a resource
|
||||
* called
|
||||
* <code>META-INF/services/org.mozilla.webclient.BrowserControlFactoryInterface</code>.
|
||||
* If the resource is found, interpret it as a <code>Properties</code>
|
||||
* file and read out its first line. Interpret the first line as the
|
||||
* fully qualified class name of a class that implements {@link
|
||||
* BrowserControlFactoryInterface}. The named class must have a public
|
||||
* no-arg constructor.</p>
|
||||
*
|
||||
*
|
||||
* @version $Id: BrowserControlFactory.java,v 1.8 2003-09-06 06:26:45 edburns%acm.org Exp $
|
||||
* @version $Id: BrowserControlFactory.java,v 1.9 2003-09-28 06:29:04 edburns%acm.org Exp $
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
@ -76,7 +59,7 @@ public class BrowserControlFactory extends Object
|
|||
// Class Variables
|
||||
//
|
||||
|
||||
private static BrowserControlFactoryInterface instance = null;
|
||||
private static WebclientFactory instance = null;
|
||||
|
||||
//
|
||||
// Constructors and Initializers
|
||||
|
@ -91,14 +74,35 @@ private BrowserControlFactory()
|
|||
// Class methods
|
||||
//
|
||||
|
||||
/**
|
||||
*
|
||||
* <p>Initialize the webclient API passing in the path to the browser
|
||||
* binary, if necessary. This must be the first method called in the
|
||||
* Webclient API.</p>
|
||||
*
|
||||
* <p>If we are embedding a native browser, calling this method will
|
||||
* cause the native libraries to be loaded into the JVM.</p>
|
||||
*
|
||||
* @param absolutePathToNativeBrowserBinDir if non-<code>null</code>
|
||||
* this must be the path to the bin dir of the native browser, including
|
||||
* the bin. ie: "D:\\Projects\\mozilla\\dist\\win32_d.obj\\bin". When
|
||||
* embedding a non-native browser, this may be null.
|
||||
*
|
||||
*/
|
||||
|
||||
public static void setAppData(String absolutePathToNativeBrowserBinDir) throws FileNotFoundException, ClassNotFoundException
|
||||
{
|
||||
getInstance().setAppData(BrowserControl.BROWSER_TYPE_NATIVE, absolutePathToNativeBrowserBinDir);
|
||||
getInstance().setAppData(absolutePathToNativeBrowserBinDir);
|
||||
}
|
||||
|
||||
public static void setAppData(String myBrowserType, String absolutePathToNativeBrowserBinDir) throws FileNotFoundException, ClassNotFoundException
|
||||
/**
|
||||
*
|
||||
* @deprecated Use {@link #setAppData(java.lang.String)} instead.
|
||||
*/
|
||||
|
||||
public static void setAppData(String notUsed, String absolutePathToNativeBrowserBinDir) throws FileNotFoundException, ClassNotFoundException
|
||||
{
|
||||
getInstance().setAppData(myBrowserType, absolutePathToNativeBrowserBinDir);
|
||||
getInstance().setAppData(absolutePathToNativeBrowserBinDir);
|
||||
}
|
||||
|
||||
public static void appTerminate() throws Exception
|
||||
|
@ -122,67 +126,14 @@ public static void deleteBrowserControl(BrowserControl toDelete)
|
|||
// helper methods
|
||||
//
|
||||
|
||||
protected static BrowserControlFactoryInterface getInstance()
|
||||
protected static WebclientFactory getInstance()
|
||||
{
|
||||
if (null != instance) {
|
||||
return instance;
|
||||
}
|
||||
|
||||
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
||||
if (classLoader == null) {
|
||||
throw new RuntimeException("Context ClassLoader");
|
||||
}
|
||||
|
||||
BufferedReader reader = null;
|
||||
InputStream stream = null;
|
||||
String
|
||||
className = null,
|
||||
resourceName = "META-INF/services/org.mozilla.webclient.BrowserControlFactoryInterface";
|
||||
try {
|
||||
stream = classLoader.getResourceAsStream(resourceName);
|
||||
if (stream != null) {
|
||||
// Deal with systems whose native encoding is possibly
|
||||
// different from the way that the services entry was created
|
||||
try {
|
||||
reader =
|
||||
new BufferedReader(new InputStreamReader(stream,
|
||||
"UTF-8"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
reader = new BufferedReader(new InputStreamReader(stream));
|
||||
}
|
||||
className = reader.readLine();
|
||||
reader.close();
|
||||
reader = null;
|
||||
stream = null;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
} catch (SecurityException e) {
|
||||
} finally {
|
||||
if (reader != null) {
|
||||
try {
|
||||
reader.close();
|
||||
} catch (Throwable t) {
|
||||
;
|
||||
}
|
||||
reader = null;
|
||||
stream = null;
|
||||
}
|
||||
if (stream != null) {
|
||||
try {
|
||||
stream.close();
|
||||
} catch (Throwable t) {
|
||||
;
|
||||
}
|
||||
stream = null;
|
||||
}
|
||||
}
|
||||
if (null != className) {
|
||||
try {
|
||||
Class clazz = classLoader.loadClass(className);
|
||||
instance = (BrowserControlFactoryInterface) (clazz.newInstance());
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
instance = (WebclientFactory)
|
||||
Utilities.getImplFromServices("org.mozilla.webclient.WebclientFactory");
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Ashutosh Kulkarni <ashuk@eng.sun.com>
|
||||
* Ed Burns <edburns@acm.org>
|
||||
*
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient;
|
||||
|
||||
/**
|
||||
|
||||
* This interface contains methods that pertain to the specific
|
||||
* underlying browser implemantation type. These methods are the union
|
||||
* of all such methods for underlying browser implementations. For
|
||||
* example, the ICE browser needs methods setICEProps(), getStormBase,
|
||||
* getViewPort(). In the mozilla implementation, these methods do
|
||||
* nothing.
|
||||
|
||||
*/
|
||||
|
||||
public interface BrowserControlICE extends BrowserControl
|
||||
{
|
||||
|
||||
/**
|
||||
* These 3 methods, setICEProps, getStormBase and getViewPort
|
||||
* are for Webclient embedding the ICE browser. For Gecko or
|
||||
* IE, these methods are to be ignored
|
||||
*
|
||||
*/
|
||||
|
||||
public abstract void setICEProps(Object base, Object viewport);
|
||||
|
||||
public abstract Object getStormBase();
|
||||
|
||||
public abstract Object getViewPort();
|
||||
|
||||
} // end of interface BrowserControlICE
|
|
@ -66,26 +66,6 @@ public abstract class ImplObject extends Object
|
|||
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
* The factory that created me. It's true that the WrapperFactory
|
||||
* instance is stored as a static member of BrowserControlImpl, and thus
|
||||
* you might say we don't need to keep it as an ivar here. BUT, we
|
||||
* don't want to introduce the notion of WrapperFactory to the webclient
|
||||
* user, AND we don't want to have webclient interface implementation
|
||||
* classes depend on BrowserControlImpl, SO we keep it as ivar. That
|
||||
* is, given that we don't want to talk to myBrowserControl as anything
|
||||
* but a BrowserControl (and not a BrowserControlImpl), we would have to
|
||||
* add an accessor to the public BrowserControl interface in order to
|
||||
* avoid having this myFactory ivar. But we can't do that, because we
|
||||
* don't want to expose the WrapperFactory concept to the webclient API
|
||||
* end user. Got it?
|
||||
|
||||
*/
|
||||
|
||||
public WrapperFactory myFactory = null;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* The BrowserControl to which I'm attached, used for locking and communication.
|
||||
|
@ -99,14 +79,10 @@ public BrowserControl myBrowserControl = null;
|
|||
// Constructors and Initializers
|
||||
//
|
||||
|
||||
public ImplObject(WrapperFactory yourFactory,
|
||||
BrowserControl yourBrowserControl)
|
||||
public ImplObject(BrowserControl yourBrowserControl)
|
||||
{
|
||||
super();
|
||||
ParameterCheck.nonNull(yourFactory);
|
||||
ParameterCheck.nonNull(yourBrowserControl);
|
||||
|
||||
myFactory = yourFactory;
|
||||
myBrowserControl = yourBrowserControl;
|
||||
}
|
||||
|
||||
|
@ -124,7 +100,6 @@ public ImplObject(WrapperFactory yourFactory,
|
|||
|
||||
public void delete()
|
||||
{
|
||||
myFactory = null;
|
||||
myBrowserControl = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,8 @@ public interface Preferences
|
|||
public Properties getPrefs();
|
||||
public void registerPrefChangedCallback(PrefChangedCallback cb,
|
||||
String prefName, Object closure);
|
||||
public void unregisterPrefChangedCallback(PrefChangedCallback cb,
|
||||
String prefName, Object closure);
|
||||
}
|
||||
// end of interface Preferences
|
||||
|
||||
|
|
|
@ -24,21 +24,25 @@ package org.mozilla.webclient;
|
|||
|
||||
public interface ProfileManager
|
||||
{
|
||||
public int GetProfileCount();
|
||||
|
||||
public String [] GetProfileList(int [] length);
|
||||
public int getProfileCount();
|
||||
|
||||
public boolean ProfileExists(String profileName);
|
||||
public String [] getProfileList();
|
||||
|
||||
public String GetCurrentProfile();
|
||||
public boolean profileExists(String profileName);
|
||||
|
||||
public void SetCurrentProfile(String profileName);
|
||||
public String getCurrentProfile();
|
||||
|
||||
public void CreateNewProfile(String profileName, String nativeProfileDir, String langcode, boolean useExistingDir);
|
||||
public void setCurrentProfile(String profileName);
|
||||
|
||||
public void RenameProfile(String currName, String newName);
|
||||
public void createNewProfile(String profileName,
|
||||
String nativeProfileDir,
|
||||
String langcode,
|
||||
boolean useExistingDir);
|
||||
|
||||
public void DeleteProfile(String profileName, boolean canDeleteFiles);
|
||||
public void renameProfile(String currName, String newName);
|
||||
|
||||
public void CloneProfile(String currName);
|
||||
public void deleteProfile(String profileName, boolean canDeleteFiles);
|
||||
|
||||
public void cloneProfile(String currName);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
/* -*- 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.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Kirk Baker <kbaker@eb.com>
|
||||
* Ian Wilkinson <iw@ennoble.com>
|
||||
* Mark Lin <mark.lin@eng.sun.com>
|
||||
* Ed Burns <edburns@acm.org>
|
||||
* Ashutosh Kulkarni <ashuk@eng.sun.com>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
/**
|
||||
* <p>This interface allows a pluggable webclient API implementation.
|
||||
* The static methods in {@link BrowserControlFactory} call through to
|
||||
* methods on this interface. Please see {@link BrowserControlFactory}
|
||||
* for information on how to hook up your <code>WebclientFactory</code>
|
||||
* implementation to the <code>BrowserControlFactory</code></p>
|
||||
*/
|
||||
|
||||
public interface WebclientFactory {
|
||||
|
||||
//
|
||||
// Public API
|
||||
//
|
||||
|
||||
/**
|
||||
*
|
||||
* <p>See {@link
|
||||
* BrowserControlFactory#setAppData(java.lang.String)}.</p>
|
||||
*
|
||||
*/
|
||||
|
||||
public void setAppData(String absolutePathToNativeBrowserBinDir)
|
||||
throws FileNotFoundException, ClassNotFoundException;
|
||||
|
||||
public void appTerminate() throws Exception;
|
||||
|
||||
public BrowserControl newBrowserControl()
|
||||
throws InstantiationException, IllegalAccessException,
|
||||
IllegalStateException;
|
||||
|
||||
/**
|
||||
|
||||
* BrowserControlFactory.deleteBrowserControl is called with a
|
||||
* BrowserControl instance obtained from
|
||||
* BrowserControlFactory.newBrowserControl. This method renders the
|
||||
* argument instance completely un-usable. It should be called when the
|
||||
* BrowserControl instance is no longer needed. This method simply
|
||||
* calls through to the non-public BrowserControlImpl.delete() method.
|
||||
|
||||
* @see org.mozilla.webclient.ImplObject#delete
|
||||
|
||||
*/
|
||||
|
||||
public void deleteBrowserControl(BrowserControl toDelete);
|
||||
|
||||
}
|
|
@ -20,7 +20,7 @@
|
|||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient;
|
||||
package org.mozilla.webclient.impl;
|
||||
|
||||
// BrowserControlImpl
|
||||
|
||||
|
@ -29,8 +29,19 @@ import org.mozilla.util.Log;
|
|||
import org.mozilla.util.ParameterCheck;
|
||||
import org.mozilla.util.Utilities;
|
||||
|
||||
import org.mozilla.webclient.BrowserControl;
|
||||
import org.mozilla.webclient.BrowserControlCanvas;
|
||||
import org.mozilla.webclient.CurrentPage;
|
||||
import org.mozilla.webclient.EventRegistration;
|
||||
import org.mozilla.webclient.WindowControl;
|
||||
import org.mozilla.webclient.Navigation;
|
||||
import org.mozilla.webclient.Bookmarks;
|
||||
import org.mozilla.webclient.Preferences;
|
||||
import org.mozilla.webclient.ProfileManager;
|
||||
import org.mozilla.webclient.History;
|
||||
import org.mozilla.webclient.ImplObject;
|
||||
|
||||
|
||||
// PENDING(edburns); move this inside impl package
|
||||
public class BrowserControlImpl extends Object implements BrowserControl
|
||||
{
|
||||
//
|
||||
|
@ -67,7 +78,6 @@ private static WrapperFactory wrapperFactory = null;
|
|||
|
||||
|
||||
private BrowserControlCanvas myCanvas = null;
|
||||
private BrowserType myType = null;
|
||||
private CurrentPage currentPage = null;
|
||||
private EventRegistration eventRegistration = null;
|
||||
private WindowControl windowControl = null;
|
||||
|
@ -76,20 +86,18 @@ private History history = null;
|
|||
private static Bookmarks bookmarks = null;
|
||||
private static Preferences prefs = null;
|
||||
private static ProfileManager profileManager = null;
|
||||
private static String browserType = null;
|
||||
|
||||
|
||||
//
|
||||
// Constructors and Initializers
|
||||
//
|
||||
|
||||
public BrowserControlImpl(String myBrowserType, BrowserControlCanvas yourCanvas)
|
||||
public BrowserControlImpl(WrapperFactory yourWrapper)
|
||||
{
|
||||
super();
|
||||
if (browserType.equals(BrowserControl.BROWSER_TYPE_NATIVE)) {
|
||||
ParameterCheck.nonNull(yourCanvas);
|
||||
myCanvas = yourCanvas;
|
||||
}
|
||||
ParameterCheck.nonNull(yourWrapper);
|
||||
|
||||
wrapperFactory = yourWrapper;
|
||||
}
|
||||
|
||||
|
||||
|
@ -105,13 +113,13 @@ public BrowserControlImpl(String myBrowserType, BrowserControlCanvas yourCanvas)
|
|||
|
||||
void delete()
|
||||
{
|
||||
Assert.assert_it(null != myCanvas);
|
||||
|
||||
if (null != myCanvas) {
|
||||
// Make sure we're not showing.
|
||||
if (myCanvas.isShowing()) {
|
||||
throw new IllegalStateException("Can't delete a browser control while its canvas is showing");
|
||||
if (myCanvas.isShowing()) {
|
||||
throw new IllegalStateException("Can't delete a browser control while its canvas is showing");
|
||||
}
|
||||
myCanvas = null;
|
||||
}
|
||||
myCanvas = null;
|
||||
|
||||
if (null != eventRegistration) {
|
||||
((ImplObject)eventRegistration).delete();
|
||||
|
@ -133,103 +141,19 @@ void delete()
|
|||
currentPage = null;
|
||||
}
|
||||
|
||||
Assert.assert_it(null != windowControl);
|
||||
((ImplObject)windowControl).delete();
|
||||
windowControl = null;
|
||||
if (null != windowControl) {
|
||||
((ImplObject)windowControl).delete();
|
||||
windowControl = null;
|
||||
}
|
||||
|
||||
// since bookmarks and prefs are static, we must not deallocate them
|
||||
// here. That is done in the static method appTerminate
|
||||
// here. That is done in WrapperFactoryImpl.terminate()
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Class methods
|
||||
//
|
||||
// PENDING(edburns): make this package private again
|
||||
public static void appInitialize(String myBrowserType, String verifiedBinDirAbsolutePath) throws Exception
|
||||
{
|
||||
browserType = myBrowserType;
|
||||
if (null == wrapperFactory) {
|
||||
System.out.println("\n+++ In appInitialize - before createWrapperFactory +++ \n");
|
||||
wrapperFactory = createWrapperFactory();
|
||||
System.out.println("\n+++ In appInitialize - after createWrapperFactory +++ \n");
|
||||
}
|
||||
wrapperFactory.initialize(verifiedBinDirAbsolutePath);
|
||||
}
|
||||
|
||||
// PENDING(edburns): make this package private again
|
||||
public static void appTerminate() throws Exception
|
||||
{
|
||||
Assert.assert_it(null != wrapperFactory);
|
||||
|
||||
if (null != bookmarks) {
|
||||
((ImplObject)bookmarks).delete();
|
||||
bookmarks = null;
|
||||
}
|
||||
if (null != prefs) {
|
||||
((ImplObject)prefs).delete();
|
||||
prefs = null;
|
||||
}
|
||||
if (null != profileManager) {
|
||||
((ImplObject)profileManager).delete();
|
||||
profileManager = null;
|
||||
}
|
||||
|
||||
wrapperFactory.terminate();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* Creates an instance of the appropriate wrapper factory, based on the
|
||||
* current package name and a parameterized string value. This method
|
||||
* uses reflection to obtain the right WrapperFactory concrete subclass,
|
||||
* either native or nonnative. This method should only be called once.
|
||||
|
||||
*/
|
||||
|
||||
private static WrapperFactory createWrapperFactory() throws ClassNotFoundException
|
||||
{
|
||||
String wrapperFactoryClassName = null;
|
||||
Class wrapperFactoryClass = null;
|
||||
WrapperFactory result = null;
|
||||
|
||||
// get the current package name
|
||||
if (null == (wrapperFactoryClassName =
|
||||
Utilities.getPackageName(BrowserControlImpl.class))){
|
||||
throw new ClassNotFoundException("Can't determine current class name");
|
||||
}
|
||||
|
||||
// PENDING(edburns): when we have a java implementation, this is
|
||||
// where you'll replace the string "native" with either "native" or
|
||||
// "nonnative".
|
||||
String PARAMETERIZED_VALUE = "";
|
||||
|
||||
System.out.println("\n+++ browserType is - " + browserType + " +++\n");
|
||||
if (browserType.equals(BrowserControl.BROWSER_TYPE_NATIVE)) {
|
||||
PARAMETERIZED_VALUE = "native";
|
||||
}
|
||||
else {
|
||||
PARAMETERIZED_VALUE = "nonnative";
|
||||
}
|
||||
|
||||
System.out.println("\n+++ PARAMETERIZED_VALUE is " + PARAMETERIZED_VALUE + " +++\n");
|
||||
// tack on the appropriate stuff
|
||||
wrapperFactoryClassName = wrapperFactoryClassName + "wrapper_" +
|
||||
PARAMETERIZED_VALUE + "." + WrapperFactory.IMPL_NAME;
|
||||
|
||||
System.out.println("\n+++ WrapperFactory classname is " + wrapperFactoryClassName + " +++\n");
|
||||
|
||||
wrapperFactoryClass = Class.forName(wrapperFactoryClassName);
|
||||
|
||||
try {
|
||||
result = (WrapperFactory) wrapperFactoryClass.newInstance();
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new ClassNotFoundException(e.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// General Methods
|
||||
|
@ -268,13 +192,6 @@ public Object queryInterface(String interfaceName) throws ClassNotFoundException
|
|||
Assert.assert_it(null != myCanvas);
|
||||
return myCanvas;
|
||||
}
|
||||
if (BROWSER_TYPE_NAME.equals(interfaceName)) {
|
||||
if (null == myType) {
|
||||
myType = (BrowserType) wrapperFactory.newImpl(BROWSER_TYPE_NAME,
|
||||
this);
|
||||
}
|
||||
return myType;
|
||||
}
|
||||
if (CURRENT_PAGE_NAME.equals(interfaceName)) {
|
||||
if (null == currentPage) {
|
||||
currentPage =
|
||||
|
@ -335,7 +252,7 @@ public static void main(String [] args)
|
|||
Assert.setEnabled(true);
|
||||
Log.setApplicationName("BrowserControlImpl");
|
||||
Log.setApplicationVersion("0.0");
|
||||
Log.setApplicationVersionDate("$Id: BrowserControlImpl.java,v 1.8 2003-09-06 06:26:45 edburns%acm.org Exp $");
|
||||
Log.setApplicationVersionDate("$Id: BrowserControlImpl.java,v 1.1 2003-09-28 06:29:05 edburns%acm.org Exp $");
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
/* -*- 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.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Kirk Baker <kbaker@eb.com>
|
||||
* Ian Wilkinson <iw@ennoble.com>
|
||||
* Mark Lin <mark.lin@eng.sun.com>
|
||||
* Ed Burns <edburns@acm.org>
|
||||
* Ashutosh Kulkarni <ashuk@eng.sun.com>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.impl;
|
||||
|
||||
/**
|
||||
* <p>This interface is for classes that provide startup and shutdown
|
||||
* behavior.</p>
|
||||
*
|
||||
*/
|
||||
|
||||
public interface Service {
|
||||
public void startup();
|
||||
public void shutdown();
|
||||
}
|
|
@ -0,0 +1,193 @@
|
|||
/* -*- 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.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Kirk Baker <kbaker@eb.com>
|
||||
* Ian Wilkinson <iw@ennoble.com>
|
||||
* Mark Lin <mark.lin@eng.sun.com>
|
||||
* Ed Burns <edburns@acm.org>
|
||||
* Ashutosh Kulkarni <ashuk@eng.sun.com>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.impl;
|
||||
|
||||
// WebclientFactoryImpl.java
|
||||
|
||||
import org.mozilla.util.Assert;
|
||||
import org.mozilla.util.Log;
|
||||
import org.mozilla.util.ParameterCheck;
|
||||
import org.mozilla.util.Utilities;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
import org.mozilla.webclient.WebclientFactory;
|
||||
import org.mozilla.webclient.BrowserControl;
|
||||
|
||||
import org.mozilla.webclient.BrowserControlCanvas; // PENDING(edburns): remove this dependency
|
||||
|
||||
public class WebclientFactoryImpl extends Object implements WebclientFactory
|
||||
{
|
||||
//
|
||||
// Protected Constants
|
||||
//
|
||||
|
||||
//
|
||||
// Class Variables
|
||||
//
|
||||
|
||||
private Class browserControlCanvasClass = null;
|
||||
private String platformCanvasClassName = null;
|
||||
|
||||
/**
|
||||
* <p>Owns the responsibility of loading the native language
|
||||
* libraries, if necessary.</p>
|
||||
*
|
||||
* <p>Knows how to create instances of the webclient API
|
||||
* interfaces.</p>
|
||||
*/
|
||||
|
||||
protected WrapperFactory wrapperFactory = null;
|
||||
|
||||
protected int browserControlCount = 0;
|
||||
|
||||
|
||||
//
|
||||
// Instance Variables
|
||||
//
|
||||
|
||||
// Attribute Instance Variables
|
||||
|
||||
// Relationship Instance Variables
|
||||
|
||||
//
|
||||
// Constructors and Initializers
|
||||
//
|
||||
|
||||
public WebclientFactoryImpl()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Public methods
|
||||
//
|
||||
|
||||
|
||||
public void setAppData(String absolutePathToNativeBrowserBinDir) throws FileNotFoundException, ClassNotFoundException
|
||||
{
|
||||
try {
|
||||
getWrapperFactory().initialize(absolutePathToNativeBrowserBinDir);
|
||||
}
|
||||
catch (SecurityException se) {
|
||||
throw new ClassNotFoundException(se.getMessage(), se);
|
||||
}
|
||||
catch (UnsatisfiedLinkError ule) {
|
||||
throw new ClassNotFoundException(ule.getMessage(), ule);
|
||||
}
|
||||
}
|
||||
/******
|
||||
// figure out the correct value for platformCanvasClassName
|
||||
if (browserType.equals(BrowserControl.BROWSER_TYPE_NON_NATIVE)) {
|
||||
platformCanvasClassName = "org.mozilla.webclient.wrapper_nonnative.JavaBrowserControlCanvas";
|
||||
}
|
||||
else {
|
||||
ParameterCheck.nonNull(absolutePathToNativeBrowserBinDir);
|
||||
|
||||
// verify that the directory exists:
|
||||
File binDir = new File(absolutePathToNativeBrowserBinDir);
|
||||
if (!binDir.exists()) {
|
||||
throw new FileNotFoundException("Directory " + absolutePathToNativeBrowserBinDir + " is not found.");
|
||||
}
|
||||
|
||||
// This hack is necessary for Sun Bug #4303996
|
||||
java.awt.Canvas c = new java.awt.Canvas();
|
||||
platformCanvasClassName = determinePlatformCanvasClassName();
|
||||
}
|
||||
// end of figuring out the correct value for platformCanvasClassName
|
||||
if (platformCanvasClassName != null) {
|
||||
browserControlCanvasClass = Class.forName(platformCanvasClassName);
|
||||
}
|
||||
else {
|
||||
throw new ClassNotFoundException("Could not determine BrowserControlCanvas class to load\n");
|
||||
}
|
||||
|
||||
try {
|
||||
BrowserControlImpl.appInitialize(absolutePathToNativeBrowserBinDir);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new ClassNotFoundException("Can't initialize native browser: " +
|
||||
e.getMessage());
|
||||
}
|
||||
********************/
|
||||
|
||||
public void appTerminate() throws Exception
|
||||
{
|
||||
if (0 == browserControlCount) {
|
||||
getWrapperFactory().terminate();
|
||||
}
|
||||
}
|
||||
|
||||
public BrowserControl newBrowserControl() throws InstantiationException, IllegalAccessException, IllegalStateException
|
||||
{
|
||||
getWrapperFactory().verifyInitialized();
|
||||
browserControlCount++;
|
||||
|
||||
BrowserControl result = null;
|
||||
result = new BrowserControlImpl(getWrapperFactory());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* BrowserControlFactory.deleteBrowserControl is called with a
|
||||
* BrowserControl instance obtained from
|
||||
* BrowserControlFactory.newBrowserControl. This method renders the
|
||||
* argument instance completely un-usable. It should be called when the
|
||||
* BrowserControl instance is no longer needed. This method simply
|
||||
* calls through to the non-public BrowserControlImpl.delete() method.
|
||||
|
||||
* @see org.mozilla.webclient.ImplObject#delete
|
||||
|
||||
*/
|
||||
|
||||
public void deleteBrowserControl(BrowserControl toDelete)
|
||||
{
|
||||
ParameterCheck.nonNull(toDelete);
|
||||
((BrowserControlImpl)toDelete).delete();
|
||||
browserControlCount--;
|
||||
}
|
||||
|
||||
//
|
||||
// Helper Methods
|
||||
//
|
||||
|
||||
WrapperFactory getWrapperFactory()
|
||||
{
|
||||
if (null != wrapperFactory) {
|
||||
return wrapperFactory;
|
||||
}
|
||||
|
||||
wrapperFactory = (WrapperFactory)
|
||||
Utilities.
|
||||
getImplFromServices("org.mozilla.webclient.impl.WrapperFactory");
|
||||
|
||||
return wrapperFactory;
|
||||
}
|
||||
|
||||
} // end of class WebclientFactoryImpl
|
|
@ -0,0 +1,58 @@
|
|||
/* -*- 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.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Kirk Baker <kbaker@eb.com>
|
||||
* Ian Wilkinson <iw@ennoble.com>
|
||||
* Mark Lin <mark.lin@eng.sun.com>
|
||||
* Ed Burns <edburns@acm.org>
|
||||
* Ashutosh Kulkarni <ashuk@eng.sun.com>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.impl;
|
||||
|
||||
import org.mozilla.webclient.BrowserControl;
|
||||
|
||||
public interface WrapperFactory {
|
||||
|
||||
public static String IMPL_NAME = "WrapperFactoryImpl";
|
||||
|
||||
public Object newImpl(String interfaceName,
|
||||
BrowserControl browserControl) throws ClassNotFoundException;
|
||||
|
||||
/**
|
||||
*
|
||||
* <p>Cause the native library to be loaded, if necessary.</p>
|
||||
*
|
||||
* <p>Cause the underlying browser embedding API to be ready to
|
||||
* use.</p>
|
||||
*
|
||||
* <p>POSTCONDITION: The API is ready to accomodate the creation of
|
||||
* a {@link BrowserControl} instance.</p>
|
||||
*
|
||||
*/
|
||||
|
||||
public void initialize(String verifiedBinDirAbsolutePath) throws SecurityException, UnsatisfiedLinkError;
|
||||
|
||||
public void verifyInitialized() throws IllegalStateException;
|
||||
|
||||
public void terminate() throws Exception;
|
||||
|
||||
public int getNativeContext();
|
||||
|
||||
}
|
|
@ -20,7 +20,7 @@
|
|||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.wrapper_native;
|
||||
package org.mozilla.webclient.impl.wrapper_native;
|
||||
|
||||
import org.mozilla.util.Assert;
|
||||
import org.mozilla.util.Log;
|
||||
|
@ -55,10 +55,10 @@ public class BookmarkEntryImpl extends RDFTreeNode implements BookmarkEntry
|
|||
// Constructors and Initializers
|
||||
//
|
||||
|
||||
protected BookmarkEntryImpl(int nativeWebShell, int nativeNode,
|
||||
protected BookmarkEntryImpl(int nativeContext, int nativeNode,
|
||||
RDFTreeNode yourParent)
|
||||
{
|
||||
super(nativeWebShell, nativeNode, yourParent);
|
||||
super(nativeContext, nativeNode, yourParent);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -73,10 +73,10 @@ protected BookmarkEntryImpl(int nativeWebShell, int nativeNode,
|
|||
// Abstract Method Implementations
|
||||
//
|
||||
|
||||
protected RDFTreeNode newRDFTreeNode(int nativeWebShell, int nativeNode,
|
||||
protected RDFTreeNode newRDFTreeNode(int nativeContext, int nativeNode,
|
||||
RDFTreeNode yourParent)
|
||||
{
|
||||
return new BookmarkEntryImpl(nativeWebShell, nativeNode, yourParent);
|
||||
return new BookmarkEntryImpl(nativeContext, nativeNode, yourParent);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -118,22 +118,4 @@ public boolean isFolder()
|
|||
return super.isFolder();
|
||||
}
|
||||
|
||||
// ----VERTIGO_TEST_START
|
||||
|
||||
//
|
||||
// Test methods
|
||||
//
|
||||
|
||||
public static void main(String [] args)
|
||||
{
|
||||
Assert.setEnabled(true);
|
||||
|
||||
Log.setApplicationName("BookmarkEntryImpl");
|
||||
Log.setApplicationVersion("0.0");
|
||||
Log.setApplicationVersionDate("$Id: BookmarkEntryImpl.java,v 1.4 2001-04-02 21:13:56 ashuk%eng.sun.com Exp $");
|
||||
|
||||
}
|
||||
|
||||
// ----VERTIGO_TEST_END
|
||||
|
||||
} // end of class BookmarksImpl
|
|
@ -22,16 +22,16 @@
|
|||
* Louis-Philippe Gagnon <louisphilippe@macadamian.com>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.wrapper_native;
|
||||
package org.mozilla.webclient.impl.wrapper_native;
|
||||
|
||||
import org.mozilla.util.Assert;
|
||||
import org.mozilla.util.Log;
|
||||
import org.mozilla.util.ParameterCheck;
|
||||
|
||||
import org.mozilla.webclient.BrowserControl;
|
||||
import org.mozilla.webclient.Bookmarks;
|
||||
import org.mozilla.webclient.BookmarkEntry;
|
||||
import org.mozilla.webclient.WrapperFactory;
|
||||
import org.mozilla.webclient.impl.WrapperFactory;
|
||||
import org.mozilla.webclient.impl.Service;
|
||||
|
||||
import javax.swing.tree.TreeModel;
|
||||
import javax.swing.tree.TreeNode;
|
||||
|
@ -39,7 +39,7 @@ import javax.swing.tree.DefaultTreeModel;
|
|||
|
||||
import org.mozilla.webclient.UnimplementedException;
|
||||
|
||||
public class BookmarksImpl extends ImplObjectNative implements Bookmarks
|
||||
public class BookmarksImpl extends ImplObjectNative implements Bookmarks, Service
|
||||
{
|
||||
//
|
||||
// Constants
|
||||
|
@ -71,10 +71,17 @@ private TreeModel bookmarksTree = null;
|
|||
// Constructors and Initializers
|
||||
//
|
||||
|
||||
public BookmarksImpl(WrapperFactory yourFactory,
|
||||
BrowserControl yourBrowserControl)
|
||||
public BookmarksImpl(WrapperFactory yourFactory)
|
||||
{
|
||||
super(yourFactory, yourBrowserControl);
|
||||
super(yourFactory, null);
|
||||
}
|
||||
|
||||
public void startup() {
|
||||
nativeStartup(getWrapperFactory().getNativeContext());
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
nativeShutdown(getWrapperFactory().getNativeContext());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -113,7 +120,7 @@ public void addBookmark(BookmarkEntry mayBeNullParent,
|
|||
BookmarkEntry bookmark)
|
||||
{
|
||||
ParameterCheck.nonNull(bookmark);
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
|
||||
if (!(bookmark instanceof BookmarkEntryImpl)) {
|
||||
throw new IllegalArgumentException("Can't add bookmark unless BookmarkEntry obtained from Bookmarks.newBookmarkEntry()");
|
||||
|
@ -142,18 +149,19 @@ public void addBookmark(BookmarkEntry mayBeNullParent,
|
|||
|
||||
public TreeModel getBookmarks() throws IllegalStateException
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
myFactory.verifyInitialized();
|
||||
|
||||
if (null == bookmarksTree) {
|
||||
int nativeBookmarks;
|
||||
TreeNode root;
|
||||
if (-1 == (nativeBookmarks = nativeGetBookmarks(nativeWebShell))) {
|
||||
if (-1 ==
|
||||
(nativeBookmarks =
|
||||
nativeGetBookmarks(getWrapperFactory().getNativeContext()))) {
|
||||
throw new IllegalStateException("BookmarksImpl.getBookmarks(): Can't get bookmarks from native browser.");
|
||||
}
|
||||
// if we can't create a root, or we can't create a tree
|
||||
if ((null == (root = new BookmarkEntryImpl(nativeWebShell,
|
||||
nativeBookmarks, null))) ||
|
||||
if ((null == (root = new BookmarkEntryImpl(getWrapperFactory().getNativeContext(),
|
||||
nativeBookmarks, null))) ||
|
||||
(null == (bookmarksTree = new DefaultTreeModel(root)))) {
|
||||
throw new IllegalStateException("BookmarksImpl.getBookmarks(): Can't create RDFTreeModel.");
|
||||
}
|
||||
|
@ -165,7 +173,7 @@ public TreeModel getBookmarks() throws IllegalStateException
|
|||
public void removeBookmark(BookmarkEntry bookmark)
|
||||
{
|
||||
ParameterCheck.nonNull(bookmark);
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
|
||||
throw new UnimplementedException("\nUnimplementedException -----\n API Function CurrentPage::getPageInfo has not yet been implemented.\n");
|
||||
|
@ -219,6 +227,10 @@ public BookmarkEntry newBookmarkFolder(String name)
|
|||
// native methods
|
||||
//
|
||||
|
||||
private native void nativeStartup(int nativeContext);
|
||||
|
||||
private native void nativeShutdown(int nativeContext);
|
||||
|
||||
private native int nativeGetBookmarks(int webShellPtr);
|
||||
|
||||
/**
|
||||
|
@ -230,35 +242,4 @@ private native int nativeGetBookmarks(int webShellPtr);
|
|||
private native int nativeNewRDFNode(int webShellPtr, String url,
|
||||
boolean isFolder);
|
||||
|
||||
// ----VERTIGO_TEST_START
|
||||
|
||||
//
|
||||
// Test methods
|
||||
//
|
||||
|
||||
public static void main(String [] args)
|
||||
{
|
||||
Assert.setEnabled(true);
|
||||
|
||||
Log.setApplicationName("BookmarksImpl");
|
||||
Log.setApplicationVersion("0.0");
|
||||
Log.setApplicationVersionDate("$Id: BookmarksImpl.java,v 1.9 2001-05-29 18:36:04 ashuk%eng.sun.com Exp $");
|
||||
|
||||
try {
|
||||
org.mozilla.webclient.BrowserControlFactory.setAppData(args[0]);
|
||||
org.mozilla.webclient.BrowserControl control =
|
||||
org.mozilla.webclient.BrowserControlFactory.newBrowserControl();
|
||||
Assert.assert_it(control != null);
|
||||
|
||||
Bookmarks wc = (Bookmarks)
|
||||
control.queryInterface(org.mozilla.webclient.BrowserControl.WINDOW_CONTROL_NAME);
|
||||
Assert.assert_it(wc != null);
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println("got exception: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// ----VERTIGO_TEST_END
|
||||
|
||||
} // end of class BookmarksImpl
|
|
@ -20,7 +20,7 @@
|
|||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.wrapper_native;
|
||||
package org.mozilla.webclient.impl.wrapper_native;
|
||||
|
||||
import org.mozilla.util.Assert;
|
||||
import org.mozilla.util.Log;
|
||||
|
@ -30,7 +30,7 @@ import org.mozilla.webclient.BrowserControl;
|
|||
import org.mozilla.webclient.CurrentPage2;
|
||||
import org.mozilla.webclient.Selection;
|
||||
import org.mozilla.webclient.WindowControl;
|
||||
import org.mozilla.webclient.WrapperFactory;
|
||||
import org.mozilla.webclient.impl.WrapperFactory;
|
||||
|
||||
import java.util.Properties;
|
||||
import java.io.*;
|
||||
|
@ -92,7 +92,7 @@ public CurrentPageImpl(WrapperFactory yourFactory,
|
|||
|
||||
public void copyCurrentSelectionToSystemClipboard()
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
|
@ -103,7 +103,7 @@ public void copyCurrentSelectionToSystemClipboard()
|
|||
public Selection getSelection() {
|
||||
Selection selection = new SelectionImpl();
|
||||
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
synchronized(myBrowserControl) {
|
||||
nativeGetSelection(nativeWebShell, selection);
|
||||
|
@ -119,7 +119,7 @@ public void highlightSelection(Selection selection) {
|
|||
int startOffset = selection.getStartOffset();
|
||||
int endOffset = selection.getEndOffset();
|
||||
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
synchronized(myBrowserControl) {
|
||||
nativeHighlightSelection(nativeWebShell, startContainer, endContainer, startOffset, endOffset);
|
||||
|
@ -128,7 +128,7 @@ public void highlightSelection(Selection selection) {
|
|||
}
|
||||
|
||||
public void clearAllSelections() {
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
synchronized(myBrowserControl) {
|
||||
nativeClearAllSelections(nativeWebShell);
|
||||
|
@ -138,7 +138,7 @@ public void clearAllSelections() {
|
|||
public void findInPage(String stringToFind, boolean forward, boolean matchCase)
|
||||
{
|
||||
ParameterCheck.nonNull(stringToFind);
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeFindInPage(nativeWebShell, stringToFind, forward, matchCase);
|
||||
|
@ -147,7 +147,7 @@ public void findInPage(String stringToFind, boolean forward, boolean matchCase)
|
|||
|
||||
public void findNextInPage()
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeFindNextInPage(nativeWebShell);
|
||||
|
@ -157,7 +157,7 @@ public void findNextInPage()
|
|||
public String getCurrentURL()
|
||||
{
|
||||
String result = null;
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
result = nativeGetCurrentURL(nativeWebShell);
|
||||
|
@ -188,7 +188,7 @@ public Properties getPageInfo()
|
|||
|
||||
public String getSource()
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
String HTMLContent = new String();
|
||||
String currURL = getCurrentURL();
|
||||
System.out.println("\nThe Current URL is -- " + currURL);
|
||||
|
@ -219,7 +219,7 @@ public String getSource()
|
|||
public byte [] getSourceBytes()
|
||||
{
|
||||
byte [] result = null;
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
|
||||
|
||||
String HTMLContent = new String();
|
||||
|
@ -251,7 +251,7 @@ public byte [] getSourceBytes()
|
|||
|
||||
public void resetFind()
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeResetFind(nativeWebShell);
|
||||
|
@ -260,7 +260,7 @@ public void resetFind()
|
|||
|
||||
public void selectAll()
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeSelectAll(nativeWebShell);
|
||||
|
@ -269,7 +269,7 @@ public void selectAll()
|
|||
|
||||
public void print()
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativePrint(nativeWebShell);
|
||||
|
@ -278,7 +278,7 @@ public void print()
|
|||
|
||||
public void printPreview(boolean preview)
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativePrintPreview(nativeWebShell, preview);
|
||||
|
@ -332,7 +332,7 @@ public static void main(String [] args)
|
|||
Assert.setEnabled(true);
|
||||
Log.setApplicationName("CurrentPageImpl");
|
||||
Log.setApplicationVersion("0.0");
|
||||
Log.setApplicationVersionDate("$Id: CurrentPageImpl.java,v 1.20 2003-04-18 01:07:52 kyle.yuan%sun.com Exp $");
|
||||
Log.setApplicationVersionDate("$Id: CurrentPageImpl.java,v 1.1 2003-09-28 06:29:06 edburns%acm.org Exp $");
|
||||
|
||||
}
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.wrapper_native;
|
||||
package org.mozilla.webclient.impl.wrapper_native;
|
||||
|
||||
|
||||
import org.mozilla.util.Assert;
|
||||
|
@ -30,7 +30,7 @@ import org.mozilla.util.ParameterCheck;
|
|||
import org.mozilla.webclient.BrowserControl;
|
||||
import org.mozilla.webclient.EventRegistration2;
|
||||
import org.mozilla.webclient.WindowControl;
|
||||
import org.mozilla.webclient.WrapperFactory;
|
||||
import org.mozilla.webclient.impl.WrapperFactory;
|
||||
import org.mozilla.webclient.DocumentLoadEvent;
|
||||
import org.mozilla.webclient.DocumentLoadListener;
|
||||
import org.mozilla.webclient.NewWindowEvent;
|
||||
|
@ -120,7 +120,7 @@ public void delete()
|
|||
public void addDocumentLoadListener(DocumentLoadListener listener)
|
||||
{
|
||||
ParameterCheck.nonNull(listener);
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
Assert.assert_it(null != nativeEventThread);
|
||||
ParameterCheck.nonNull(listener);
|
||||
|
@ -140,7 +140,7 @@ public void addDocumentLoadListener(DocumentLoadListener listener)
|
|||
public void removeDocumentLoadListener(DocumentLoadListener listener)
|
||||
{
|
||||
ParameterCheck.nonNull(listener);
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
Assert.assert_it(null != nativeEventThread);
|
||||
ParameterCheck.nonNull(listener);
|
||||
|
@ -160,7 +160,7 @@ public void removeDocumentLoadListener(DocumentLoadListener listener)
|
|||
public void addMouseListener(MouseListener listener)
|
||||
{
|
||||
ParameterCheck.nonNull(listener);
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
Assert.assert_it(null != nativeEventThread);
|
||||
ParameterCheck.nonNull(listener);
|
||||
|
@ -193,7 +193,7 @@ public void addMouseListener(MouseListener listener)
|
|||
public void removeMouseListener(MouseListener listener)
|
||||
{
|
||||
ParameterCheck.nonNull(listener);
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
Assert.assert_it(null != nativeEventThread);
|
||||
ParameterCheck.nonNull(listener);
|
||||
|
@ -221,7 +221,7 @@ public void removeMouseListener(MouseListener listener)
|
|||
public void addNewWindowListener(NewWindowListener listener)
|
||||
{
|
||||
ParameterCheck.nonNull(listener);
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
Assert.assert_it(null != nativeEventThread);
|
||||
ParameterCheck.nonNull(listener);
|
||||
|
@ -241,7 +241,7 @@ public void addNewWindowListener(NewWindowListener listener)
|
|||
public void removeNewWindowListener(NewWindowListener listener)
|
||||
{
|
||||
ParameterCheck.nonNull(listener);
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
Assert.assert_it(null != nativeEventThread);
|
||||
ParameterCheck.nonNull(listener);
|
||||
|
@ -271,7 +271,7 @@ public static void main(String [] args)
|
|||
|
||||
Log.setApplicationName("EventRegistrationImpl");
|
||||
Log.setApplicationVersion("0.0");
|
||||
Log.setApplicationVersionDate("$Id: EventRegistrationImpl.java,v 1.11 2003-04-24 05:55:12 kyle.yuan%sun.com Exp $");
|
||||
Log.setApplicationVersionDate("$Id: EventRegistrationImpl.java,v 1.1 2003-09-28 06:29:06 edburns%acm.org Exp $");
|
||||
|
||||
try {
|
||||
org.mozilla.webclient.BrowserControlFactory.setAppData(args[0]);
|
|
@ -20,7 +20,7 @@
|
|||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.wrapper_native;
|
||||
package org.mozilla.webclient.impl.wrapper_native;
|
||||
|
||||
import org.mozilla.util.Assert;
|
||||
import org.mozilla.util.Log;
|
||||
|
@ -30,7 +30,7 @@ import org.mozilla.webclient.BrowserControl;
|
|||
import org.mozilla.webclient.History;
|
||||
import org.mozilla.webclient.HistoryEntry;
|
||||
import org.mozilla.webclient.WindowControl;
|
||||
import org.mozilla.webclient.WrapperFactory;
|
||||
import org.mozilla.webclient.impl.WrapperFactory;
|
||||
|
||||
import org.mozilla.webclient.UnimplementedException;
|
||||
|
||||
|
@ -76,7 +76,7 @@ public HistoryImpl(WrapperFactory yourFactory,
|
|||
|
||||
public void back()
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
|
@ -86,7 +86,7 @@ public void back()
|
|||
|
||||
public boolean canBack()
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
boolean result = false;
|
||||
|
||||
|
@ -98,7 +98,7 @@ public boolean canBack()
|
|||
|
||||
public HistoryEntry [] getBackList()
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
HistoryEntry [] result = null;
|
||||
|
||||
|
@ -113,7 +113,7 @@ public HistoryEntry [] getBackList()
|
|||
|
||||
public void clearHistory()
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
|
||||
/* synchronized(myBrowserControl) {
|
||||
|
@ -128,7 +128,7 @@ public void clearHistory()
|
|||
|
||||
public void forward()
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
|
@ -138,7 +138,7 @@ public void forward()
|
|||
|
||||
public boolean canForward()
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
boolean result = false;
|
||||
|
||||
|
@ -151,7 +151,7 @@ public boolean canForward()
|
|||
public HistoryEntry [] getForwardList()
|
||||
{
|
||||
HistoryEntry [] result = null;
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
|
||||
/* synchronized(myBrowserControl) {
|
||||
|
@ -166,7 +166,7 @@ public HistoryEntry [] getForwardList()
|
|||
public HistoryEntry [] getHistory()
|
||||
{
|
||||
HistoryEntry [] result = null;
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
|
||||
/* synchronized(myBrowserControl) {
|
||||
|
@ -181,7 +181,7 @@ public HistoryEntry [] getHistory()
|
|||
public HistoryEntry getHistoryEntry(int historyIndex)
|
||||
{
|
||||
ParameterCheck.noLessThan(historyIndex, 0);
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
HistoryEntry result = null;
|
||||
|
||||
|
@ -196,7 +196,7 @@ public HistoryEntry getHistoryEntry(int historyIndex)
|
|||
|
||||
public int getCurrentHistoryIndex()
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
int result = -1;
|
||||
|
||||
|
@ -209,7 +209,7 @@ public int getCurrentHistoryIndex()
|
|||
public void setCurrentHistoryIndex(int historyIndex)
|
||||
{
|
||||
ParameterCheck.noLessThan(historyIndex, 0);
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
|
@ -219,7 +219,7 @@ public void setCurrentHistoryIndex(int historyIndex)
|
|||
|
||||
public int getHistoryLength()
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
int result = -1;
|
||||
|
||||
|
@ -232,7 +232,7 @@ public int getHistoryLength()
|
|||
public String getURLForIndex(int historyIndex)
|
||||
{
|
||||
ParameterCheck.noLessThan(historyIndex, 0);
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
String result = null;
|
||||
|
||||
|
@ -283,7 +283,7 @@ public static void main(String [] args)
|
|||
Assert.setEnabled(true);
|
||||
Log.setApplicationName("HistoryImpl");
|
||||
Log.setApplicationVersion("0.0");
|
||||
Log.setApplicationVersionDate("$Id: HistoryImpl.java,v 1.5 2001-05-29 18:36:07 ashuk%eng.sun.com Exp $");
|
||||
Log.setApplicationVersionDate("$Id: HistoryImpl.java,v 1.1 2003-09-28 06:29:06 edburns%acm.org Exp $");
|
||||
|
||||
}
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.wrapper_native;
|
||||
package org.mozilla.webclient.impl.wrapper_native;
|
||||
|
||||
import org.mozilla.util.Assert;
|
||||
import org.mozilla.util.Log;
|
||||
|
@ -87,7 +87,7 @@ public static void main(String [] args)
|
|||
|
||||
Log.setApplicationName("ISupportsPeer");
|
||||
Log.setApplicationVersion("0.0");
|
||||
Log.setApplicationVersionDate("$Id: ISupportsPeer.java,v 1.1 2000-03-04 01:10:55 edburns%acm.org Exp $");
|
||||
Log.setApplicationVersionDate("$Id: ISupportsPeer.java,v 1.1 2003-09-28 06:29:06 edburns%acm.org Exp $");
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,162 @@
|
|||
/* -*- 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.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Kirk Baker <kbaker@eb.com>
|
||||
* Ian Wilkinson <iw@ennoble.com>
|
||||
* Mark Lin <mark.lin@eng.sun.com>
|
||||
* Mark Goddard
|
||||
* Ed Burns <edburns@acm.org>
|
||||
* Ann Sunhachawee
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.impl.wrapper_native;
|
||||
|
||||
// ImplObjectNative.java
|
||||
|
||||
import org.mozilla.util.Assert;
|
||||
import org.mozilla.util.Log;
|
||||
import org.mozilla.util.ParameterCheck;
|
||||
|
||||
import org.mozilla.webclient.ImplObject;
|
||||
import org.mozilla.webclient.impl.WrapperFactory;
|
||||
import org.mozilla.webclient.BrowserControl;
|
||||
import org.mozilla.webclient.WindowControl;
|
||||
|
||||
/**
|
||||
|
||||
* This is the base class for all implementations of the BrowserControl
|
||||
* interfaces in the native browser wrapping code. It simply defines
|
||||
* the common attributes for all native browser wrapping webclient
|
||||
* implementation classes. It extends the ImplObject, which is the base
|
||||
* class for all implementations of BrowserControl interfaces in either
|
||||
* native or non-native code.
|
||||
|
||||
*/
|
||||
|
||||
public abstract class ImplObjectNative extends ImplObject
|
||||
{
|
||||
//
|
||||
// Protected Constants
|
||||
//
|
||||
|
||||
//
|
||||
// Class Variables
|
||||
//
|
||||
|
||||
//
|
||||
// Instance Variables
|
||||
//
|
||||
|
||||
// Attribute Instance Variables
|
||||
|
||||
// Relationship Instance Variables
|
||||
|
||||
/**
|
||||
|
||||
* My ivars are public for fast access from subclasses in the wrapper_*
|
||||
* packages.
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
* a handle to the actual mozilla webShell, owned, allocated, and
|
||||
* released by WindowControl
|
||||
|
||||
*/
|
||||
|
||||
public int nativeWebShell = -1;
|
||||
|
||||
protected WrapperFactory myFactory = null;
|
||||
|
||||
//
|
||||
// Constructors and Initializers
|
||||
//
|
||||
|
||||
public ImplObjectNative(WrapperFactory yourFactory,
|
||||
BrowserControl yourBrowserControl)
|
||||
{
|
||||
super(yourBrowserControl);
|
||||
myFactory = yourFactory;
|
||||
|
||||
// If we're a WindowControlImpl instance, we can't ask ourself for
|
||||
// the nativeWebShell, since it hasn't yet been created!
|
||||
|
||||
if (!(this instanceof WindowControlImpl)) {
|
||||
// save the native webshell ptr
|
||||
try {
|
||||
WindowControl windowControl = (WindowControl)
|
||||
myBrowserControl.queryInterface(BrowserControl.WINDOW_CONTROL_NAME);
|
||||
nativeWebShell = windowControl.getNativeWebShell();
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* This constructor doesn't initialize the nativeWebshell ivar
|
||||
|
||||
*/
|
||||
|
||||
public ImplObjectNative(WrapperFactory yourFactory,
|
||||
BrowserControl yourBrowserControl,
|
||||
boolean notUsed)
|
||||
{
|
||||
super(yourBrowserControl);
|
||||
myFactory = yourFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* Note how we call super.delete() at the end. THIS IS VERY IMPORTANT. <P>
|
||||
|
||||
* Also, note how we don't de-allocate nativeWebShell, that is done in
|
||||
* the class that owns the nativeWebShell reference, WindowControlImpl. <P>
|
||||
|
||||
* ImplObjectNative subclasses that further override delete() are <P>
|
||||
|
||||
<CODE><PRE>
|
||||
BookmarksImpl.java
|
||||
EventRegistrationImpl.java
|
||||
NativeEventThread.java
|
||||
WindowControlImpl.java
|
||||
</PRE><CODE> <P>
|
||||
|
||||
* All other ImplObject subclasses don't have any local Ivars and thus
|
||||
* don't need to override delete().
|
||||
|
||||
*/
|
||||
|
||||
public void delete()
|
||||
{
|
||||
nativeWebShell = -1;
|
||||
System.out.println("ImplObjectNative.delete()");
|
||||
super.delete();
|
||||
}
|
||||
|
||||
protected WrapperFactory getWrapperFactory() {
|
||||
return myFactory;
|
||||
}
|
||||
|
||||
|
||||
} // end of class ImplObject
|
|
@ -0,0 +1,493 @@
|
|||
/* -*- 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.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
* Ashutosh Kulkarni <ashuk@eng.sun.com>
|
||||
* Jason Mawdsley <jason@macadamian.com>
|
||||
* Louis-Philippe Gagnon <louisphilippe@macadamian.com>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.impl.wrapper_native;
|
||||
|
||||
import org.mozilla.util.Assert;
|
||||
import org.mozilla.util.Log;
|
||||
import org.mozilla.util.ParameterCheck;
|
||||
|
||||
import java.util.Vector;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import org.mozilla.webclient.BrowserControl;
|
||||
import org.mozilla.webclient.BrowserControlCanvas;
|
||||
import org.mozilla.webclient.WindowControl;
|
||||
import org.mozilla.webclient.DocumentLoadEvent;
|
||||
import org.mozilla.webclient.DocumentLoadListener;
|
||||
import org.mozilla.webclient.NewWindowEvent;
|
||||
import org.mozilla.webclient.NewWindowListener;
|
||||
import java.awt.event.MouseListener;
|
||||
import org.mozilla.webclient.WebclientEvent;
|
||||
import org.mozilla.webclient.WebclientEventListener;
|
||||
import org.mozilla.webclient.UnimplementedException;
|
||||
|
||||
public class NativeEventThread extends Thread
|
||||
{
|
||||
|
||||
//
|
||||
// Class variables
|
||||
//
|
||||
|
||||
private static Object firstThread = null;
|
||||
|
||||
|
||||
//
|
||||
// Attribute ivars
|
||||
//
|
||||
|
||||
//
|
||||
// Relationship ivars
|
||||
//
|
||||
|
||||
/**
|
||||
|
||||
* Vector of listener objects to add.
|
||||
|
||||
*/
|
||||
|
||||
private Vector listenersToAdd;
|
||||
|
||||
/**
|
||||
|
||||
* Vector of listener objects to remove.
|
||||
|
||||
*/
|
||||
|
||||
private Vector listenersToRemove;
|
||||
|
||||
/**
|
||||
|
||||
* a handle to the actual mozilla webShell, obtained in constructor
|
||||
|
||||
*/
|
||||
|
||||
private int nativeWebShell = -1;
|
||||
|
||||
/**
|
||||
|
||||
* a reference to the WindowControl that created us.
|
||||
|
||||
*/
|
||||
|
||||
private WindowControl windowControl;
|
||||
|
||||
private BrowserControl browserControl;
|
||||
|
||||
private BrowserControlCanvas browserControlCanvas;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* Used in run()
|
||||
|
||||
*/
|
||||
|
||||
private Enumeration tempEnum;
|
||||
|
||||
//
|
||||
// Attribute ivars
|
||||
//
|
||||
|
||||
//
|
||||
// Constructors
|
||||
//
|
||||
|
||||
public NativeEventThread(String threadName, BrowserControl yourBrowserControl)
|
||||
{
|
||||
super(threadName);
|
||||
ParameterCheck.nonNull(yourBrowserControl);
|
||||
|
||||
if (null == firstThread) {
|
||||
firstThread = this;
|
||||
}
|
||||
|
||||
browserControl = yourBrowserControl;
|
||||
|
||||
try {
|
||||
windowControl = (WindowControl)
|
||||
browserControl.queryInterface(BrowserControl.WINDOW_CONTROL_NAME);
|
||||
nativeWebShell = windowControl.getNativeWebShell();
|
||||
|
||||
browserControlCanvas = (BrowserControlCanvas)
|
||||
browserControl.queryInterface(BrowserControl.BROWSER_CONTROL_CANVAS_NAME);
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println("NativeEventThread constructor: Exception: " + e +
|
||||
" " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* This is a very delicate method, and possibly subject to race
|
||||
* condition problems. To combat this, our first step is to set our
|
||||
* browserControlCanvas to null, within a synchronized block which
|
||||
* synchronizes on the same object used in the run() method's event
|
||||
* loop. By setting the browserControlCanvas ivar to null, we cause the
|
||||
* run method to return.
|
||||
|
||||
*/
|
||||
|
||||
public void delete()
|
||||
{
|
||||
// setting this to null causes the run thread to exit
|
||||
synchronized(this) {
|
||||
// this has to be inside the synchronized block!
|
||||
browserControlCanvas = null;
|
||||
synchronized (this) {
|
||||
try {
|
||||
wait();
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println("NativeEventThread.delete: interrupted while waiting\n\t for NativeEventThread to notify() after destruction of initContext: " + e +
|
||||
" " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
// PENDING(ashuk): do any necessary cleanup.
|
||||
listenersToAdd = null;
|
||||
doRemoveListeners();
|
||||
listenersToRemove = null;
|
||||
nativeWebShell = -1;
|
||||
windowControl = null;
|
||||
browserControl = null;
|
||||
tempEnum = null;
|
||||
}
|
||||
|
||||
//
|
||||
// Methods from Thread
|
||||
//
|
||||
|
||||
/**
|
||||
|
||||
* This method is the heart of webclient. It should only be called when
|
||||
* WindowControlImpl.createWindow() is called. It calls
|
||||
* nativeInitialize, which does the per-window initialization, including
|
||||
* creating the native event queue which corresponds to this instance,
|
||||
* then enters into an infinite loop where processes native events, then
|
||||
* checks to see if there are any listeners to add, and adds them if
|
||||
* necessary.
|
||||
|
||||
* @see nativeInitialize
|
||||
|
||||
* @see nativeProcessEvents
|
||||
|
||||
* @see nativeAddListener
|
||||
|
||||
*/
|
||||
|
||||
public void run()
|
||||
{
|
||||
// this.setPriority(Thread.MIN_PRIORITY);
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
Assert.assert_it(null != windowControl);
|
||||
|
||||
nativeInitialize(nativeWebShell);
|
||||
|
||||
// IMPORTANT: tell the windowControl, who is waiting for this
|
||||
// message, that we have initialized successfully.
|
||||
synchronized(windowControl) {
|
||||
try {
|
||||
windowControl.notify();
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println("NativeEventThread.run: Exception: trying to send notify() to windowControl: " + e + " " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
while (true) {
|
||||
try {
|
||||
Thread.sleep(1);
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println("NativeEventThread.run(): Exception: " + e +
|
||||
" while sleeping: " + e.getMessage());
|
||||
}
|
||||
synchronized (this) {
|
||||
|
||||
// this has to be inside the synchronized block!
|
||||
if (null == this.browserControlCanvas) {
|
||||
// if we get here, this Thread is terminating, destroy
|
||||
// the initContext and notify the WindowControl
|
||||
((WindowControlImpl)windowControl).nativeDestroyInitContext(nativeWebShell);
|
||||
try {
|
||||
notify();
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println("NativeEventThread.run: Exception: trying to send notify() to this during delete: " + e + " " + e.getMessage());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (this == firstThread) {
|
||||
nativeProcessEvents(nativeWebShell);
|
||||
}
|
||||
|
||||
if (null != listenersToAdd && !listenersToAdd.isEmpty()) {
|
||||
tempEnum = listenersToAdd.elements();
|
||||
|
||||
while (tempEnum.hasMoreElements()) {
|
||||
WCEventListenerWrapper tempListener =
|
||||
(WCEventListenerWrapper) tempEnum.nextElement();
|
||||
nativeAddListener(nativeWebShell,tempListener.listener,
|
||||
tempListener.listenerClassName);
|
||||
}
|
||||
// use removeAllElements instead of clear for jdk1.1.x
|
||||
// compatibility.
|
||||
listenersToAdd.removeAllElements();
|
||||
}
|
||||
doRemoveListeners();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// private methods
|
||||
//
|
||||
|
||||
/**
|
||||
|
||||
* this was broken out into a separate method due to the complexity of
|
||||
* handling the case where we are to remove all listeners.
|
||||
|
||||
*/
|
||||
|
||||
private void doRemoveListeners()
|
||||
{
|
||||
if (null != listenersToRemove && !listenersToRemove.isEmpty()) {
|
||||
tempEnum = listenersToRemove.elements();
|
||||
while (tempEnum.hasMoreElements()) {
|
||||
Object listenerObj = tempEnum.nextElement();
|
||||
String listenerString;
|
||||
if (listenerObj instanceof String) {
|
||||
listenerString = (String) listenerObj;
|
||||
if (listenerString.equals("all")) {
|
||||
nativeRemoveAllListeners(nativeWebShell);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
throw new UnimplementedException("Webclient doesn't understand how to remove " + ((String)listenerObj) + ".");
|
||||
}
|
||||
}
|
||||
else {
|
||||
WCEventListenerWrapper tempListener =
|
||||
(WCEventListenerWrapper) listenerObj;
|
||||
nativeRemoveListener(nativeWebShell,
|
||||
tempListener.listener,
|
||||
tempListener.listenerClassName);
|
||||
|
||||
}
|
||||
}
|
||||
// use removeAllElements instead of clear for jdk1.1.x
|
||||
// compatibility.
|
||||
listenersToRemove.removeAllElements();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Package methods
|
||||
//
|
||||
|
||||
/**
|
||||
|
||||
* Takes the abstract WebclientEventListener instance and adds it to a
|
||||
* Vector of listeners to be added. This vector is scanned each time
|
||||
* around the event loop in run(). <P>
|
||||
|
||||
* The vector is a vector of WCEventListenerWrapper instances. In run()
|
||||
* these are unpacked and sent to nativeAddListener like this:
|
||||
* nativeAddListener(nativeWebShell,tempListener.listener,
|
||||
* tempListener.listenerClassName); <P>
|
||||
|
||||
* @see run
|
||||
|
||||
*/
|
||||
|
||||
void addListener(WCEventListenerWrapper newListener)
|
||||
{
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
Assert.assert_it(null != windowControl);
|
||||
|
||||
synchronized (this) {
|
||||
if (null == listenersToAdd) {
|
||||
listenersToAdd = new Vector();
|
||||
}
|
||||
// use addElement instead of add for jdk1.1.x
|
||||
// compatibility.
|
||||
listenersToAdd.addElement(newListener);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* remove a listener
|
||||
|
||||
* @param newListener if null, removes all listeners
|
||||
|
||||
*/
|
||||
|
||||
void removeListener(WCEventListenerWrapper newListener)
|
||||
{
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
Assert.assert_it(null != windowControl);
|
||||
|
||||
synchronized (this) {
|
||||
if (null == listenersToRemove) {
|
||||
listenersToRemove = new Vector();
|
||||
}
|
||||
if (null == newListener) {
|
||||
String all = "all";
|
||||
// use addElement instead of add for jdk1.1.x
|
||||
// compatibility.
|
||||
listenersToRemove.addElement(all);
|
||||
}
|
||||
else {
|
||||
// use addElement instead of add for jdk1.1.x
|
||||
// compatibility.
|
||||
listenersToRemove.addElement(newListener);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* This method is called from native code when an event occurrs. This
|
||||
* method relies on the fact that all events types that the client can
|
||||
* observe descend from WebclientEventListener. I use instanceOf to
|
||||
* determine what kind of WebclientEvent subclass to create.
|
||||
|
||||
*/
|
||||
|
||||
void nativeEventOccurred(WebclientEventListener target,
|
||||
String targetClassName, long eventType,
|
||||
Object eventData)
|
||||
{
|
||||
ParameterCheck.nonNull(target);
|
||||
ParameterCheck.nonNull(targetClassName);
|
||||
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
Assert.assert_it(null != windowControl);
|
||||
|
||||
WebclientEvent event = null;
|
||||
|
||||
if (DocumentLoadListener.class.getName().equals(targetClassName)) {
|
||||
event = new DocumentLoadEvent(this, eventType, eventData);
|
||||
}
|
||||
else if (MouseListener.class.getName().equals(targetClassName)) {
|
||||
Assert.assert_it(target instanceof WCMouseListenerImpl);
|
||||
|
||||
// We create a plain vanilla WebclientEvent, which the
|
||||
// WCMouseListenerImpl target knows how to deal with.
|
||||
|
||||
// Also, the source happens to be the browserControlCanvas
|
||||
// to satisfy the java.awt.event.MouseEvent's requirement
|
||||
// that the source be a java.awt.Component subclass.
|
||||
|
||||
event = new WebclientEvent(browserControlCanvas, eventType, eventData);
|
||||
}
|
||||
else if (NewWindowListener.class.getName().equals(targetClassName)) {
|
||||
event = new NewWindowEvent(this, eventType, eventData);
|
||||
}
|
||||
// else...
|
||||
|
||||
// PENDING(edburns): maybe we need to put this in some sort of
|
||||
// event queue?
|
||||
target.eventDispatched(event);
|
||||
}
|
||||
|
||||
//
|
||||
// local methods
|
||||
//
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Native methods
|
||||
//
|
||||
|
||||
/**
|
||||
|
||||
* Takes the int from WindowControlImpl.nativeCreateInitContext, the
|
||||
* meaning of which is left up to the implementation, and does any
|
||||
* per-window creation and initialization tasks. <P>
|
||||
|
||||
* For mozilla, this means creating the nsIWebShell instance, attaching
|
||||
* to the native event queue, creating the nsISessionHistory instance, etc.
|
||||
|
||||
*/
|
||||
|
||||
public native void nativeInitialize(int webShellPtr);
|
||||
|
||||
/**
|
||||
|
||||
* Called from java to allow the native code to process any pending
|
||||
* events, such as: painting the UI, processing mouse and key events,
|
||||
* etc.
|
||||
|
||||
*/
|
||||
|
||||
public native void nativeProcessEvents(int webShellPtr);
|
||||
|
||||
/**
|
||||
|
||||
* Called from Java to allow the native code to add a "listener" to the
|
||||
* underlying browser implementation. The native code should do what's
|
||||
* necessary to add the appropriate listener type. When a listener
|
||||
* event occurrs, the native code should call the nativeEventOccurred
|
||||
* method of this instance, passing the typedListener argument received
|
||||
* from nativeAddListener. See the comments in the native
|
||||
* implementation.
|
||||
|
||||
* @see nativeEventOccurred
|
||||
|
||||
*/
|
||||
|
||||
public native void nativeAddListener(int webShellPtr,
|
||||
WebclientEventListener typedListener,
|
||||
String listenerName);
|
||||
|
||||
/**
|
||||
|
||||
* Called from Java to allow the native code to remove a listener.
|
||||
|
||||
*/
|
||||
|
||||
public native void nativeRemoveListener(int webShellPtr,
|
||||
WebclientEventListener typedListener,
|
||||
String listenerName);
|
||||
|
||||
/**
|
||||
|
||||
* Called from Java to allow the native code to remove all listeners.
|
||||
|
||||
*/
|
||||
|
||||
public native void nativeRemoveAllListeners(int webShellPrt);
|
||||
|
||||
} // end of class NativeEventThread
|
|
@ -22,7 +22,7 @@
|
|||
* Anthony Sizer <sizera@yahoo.com>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.wrapper_native;
|
||||
package org.mozilla.webclient.impl.wrapper_native;
|
||||
|
||||
import org.mozilla.util.Assert;
|
||||
import org.mozilla.util.Log;
|
||||
|
@ -33,7 +33,7 @@ import org.mozilla.webclient.BrowserControl;
|
|||
import org.mozilla.webclient.Navigation;
|
||||
import org.mozilla.webclient.Navigation2;
|
||||
import org.mozilla.webclient.WindowControl;
|
||||
import org.mozilla.webclient.WrapperFactory;
|
||||
import org.mozilla.webclient.impl.WrapperFactory;
|
||||
import org.mozilla.webclient.Prompt;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
@ -82,7 +82,7 @@ public NavigationImpl(WrapperFactory yourFactory,
|
|||
public void loadURL(String absoluteURL)
|
||||
{
|
||||
ParameterCheck.nonNull(absoluteURL);
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
|
@ -102,7 +102,7 @@ public void loadFromStream(InputStream stream, String uri,
|
|||
" is out of range. It is should be either -1 or greater than 0.");
|
||||
}
|
||||
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
|
@ -115,7 +115,7 @@ public void loadFromStream(InputStream stream, String uri,
|
|||
public void refresh(long loadFlags)
|
||||
{
|
||||
ParameterCheck.noLessThan(loadFlags, 0);
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
|
@ -125,7 +125,7 @@ public void refresh(long loadFlags)
|
|||
|
||||
public void stop()
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
|
@ -136,7 +136,7 @@ public void stop()
|
|||
public void setPrompt(Prompt yourPrompt)
|
||||
{
|
||||
ParameterCheck.nonNull(yourPrompt);
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
|
@ -155,7 +155,7 @@ public void post(String absoluteUrl,
|
|||
String postHeaders)
|
||||
{
|
||||
ParameterCheck.nonNull(absoluteUrl);
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
|
||||
int postDataLength = 0;
|
||||
|
@ -224,7 +224,7 @@ public static void main(String [] args)
|
|||
|
||||
Log.setApplicationName("NavigationImpl");
|
||||
Log.setApplicationVersion("0.0");
|
||||
Log.setApplicationVersionDate("$Id: NavigationImpl.java,v 1.6 2001-07-12 23:18:50 edburns%acm.org Exp $");
|
||||
Log.setApplicationVersionDate("$Id: NavigationImpl.java,v 1.1 2003-09-28 06:29:06 edburns%acm.org Exp $");
|
||||
|
||||
try {
|
||||
org.mozilla.webclient.BrowserControlFactory.setAppData(args[0]);
|
|
@ -20,22 +20,23 @@
|
|||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.wrapper_native;
|
||||
package org.mozilla.webclient.impl.wrapper_native;
|
||||
|
||||
import org.mozilla.util.Assert;
|
||||
import org.mozilla.util.Log;
|
||||
import org.mozilla.util.ParameterCheck;
|
||||
|
||||
import org.mozilla.webclient.BrowserControl;
|
||||
import org.mozilla.webclient.WrapperFactory;
|
||||
import org.mozilla.webclient.impl.WrapperFactory;
|
||||
import org.mozilla.webclient.impl.Service;
|
||||
import org.mozilla.webclient.Preferences;
|
||||
import org.mozilla.webclient.PrefChangedCallback;
|
||||
|
||||
import java.util.Properties;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.mozilla.webclient.UnimplementedException;
|
||||
|
||||
public class PreferencesImpl extends ImplObjectNative implements Preferences
|
||||
public class PreferencesImpl extends ImplObjectNative implements Preferences, Service
|
||||
{
|
||||
//
|
||||
// Constants
|
||||
|
@ -59,13 +60,20 @@ private Properties props;
|
|||
// Constructors and Initializers
|
||||
//
|
||||
|
||||
public PreferencesImpl(WrapperFactory yourFactory,
|
||||
BrowserControl yourBrowserControl)
|
||||
public PreferencesImpl(WrapperFactory yourFactory)
|
||||
{
|
||||
super(yourFactory, yourBrowserControl);
|
||||
super(yourFactory, null);
|
||||
props = null;
|
||||
}
|
||||
|
||||
public void startup() {
|
||||
nativeStartup(getWrapperFactory().getNativeContext());
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
nativeShutdown(getWrapperFactory().getNativeContext());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* Since this class is a singleton, we don't expect this method to be
|
||||
|
@ -104,25 +112,28 @@ public void setPref(String prefName, String prefValue)
|
|||
// determine the type of pref value: String, boolean, integer
|
||||
try {
|
||||
Integer intVal = Integer.valueOf(prefValue);
|
||||
nativeSetIntPref(nativeWebShell, prefName, intVal.intValue());
|
||||
nativeSetIntPref(getWrapperFactory().getNativeContext(), prefName, intVal.intValue());
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
// it's not an integer
|
||||
if (prefValue.equals("true") || prefValue.equals("false")) {
|
||||
Boolean boolVal = Boolean.valueOf(prefValue);
|
||||
nativeSetBoolPref(nativeWebShell, prefName,
|
||||
nativeSetBoolPref(getWrapperFactory().getNativeContext(), prefName,
|
||||
boolVal.booleanValue());
|
||||
}
|
||||
else {
|
||||
// it must be a string
|
||||
nativeSetUnicharPref(nativeWebShell, prefName, prefValue);
|
||||
nativeSetUnicharPref(getWrapperFactory().getNativeContext(), prefName, prefValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Properties getPrefs()
|
||||
{
|
||||
props = nativeGetPrefs(nativeWebShell, props);
|
||||
props = nativeGetPrefs(getWrapperFactory().getNativeContext(), props);
|
||||
//Properties result = new Properties();
|
||||
// result.put("webclientpref", "webclient_value");
|
||||
|
||||
return props;
|
||||
}
|
||||
|
||||
|
@ -132,55 +143,42 @@ public void registerPrefChangedCallback(PrefChangedCallback cb,
|
|||
ParameterCheck.nonNull(cb);
|
||||
ParameterCheck.nonNull(prefName);
|
||||
|
||||
nativeRegisterPrefChangedCallback(nativeWebShell, cb, prefName, closure);
|
||||
nativeRegisterPrefChangedCallback(getWrapperFactory().getNativeContext(), cb, prefName, closure);
|
||||
}
|
||||
|
||||
public void unregisterPrefChangedCallback(PrefChangedCallback cb,
|
||||
String prefName, Object closure)
|
||||
{
|
||||
ParameterCheck.nonNull(cb);
|
||||
ParameterCheck.nonNull(prefName);
|
||||
|
||||
nativeUnregisterPrefChangedCallback(getWrapperFactory().getNativeContext(), cb, prefName, closure);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// native methods
|
||||
//
|
||||
|
||||
public native void nativeSetUnicharPref(int nativeWebShell,
|
||||
String prefName, String prefValue);
|
||||
public native void nativeSetIntPref(int nativeWebShell,
|
||||
String prefName, int prefValue);
|
||||
public native void nativeSetBoolPref(int nativeWebShell,
|
||||
String prefName, boolean prefValue);
|
||||
public native Properties nativeGetPrefs(int nativeWebShell, Properties props);
|
||||
public native void nativeRegisterPrefChangedCallback(int nativeWebShell,
|
||||
PrefChangedCallback cb,
|
||||
String prefName,
|
||||
Object closure);
|
||||
native void nativeStartup(int nativeContext);
|
||||
|
||||
// ----VERTIGO_TEST_START
|
||||
native void nativeShutdown(int nativeContext);
|
||||
|
||||
//
|
||||
// Test methods
|
||||
//
|
||||
|
||||
public static void main(String [] args)
|
||||
{
|
||||
Assert.setEnabled(true);
|
||||
|
||||
Log.setApplicationName("PreferencesImpl");
|
||||
Log.setApplicationVersion("0.0");
|
||||
Log.setApplicationVersionDate("$Id: PreferencesImpl.java,v 1.3 2001-05-29 18:36:10 ashuk%eng.sun.com Exp $");
|
||||
|
||||
try {
|
||||
org.mozilla.webclient.BrowserControlFactory.setAppData(args[0]);
|
||||
org.mozilla.webclient.BrowserControl control =
|
||||
org.mozilla.webclient.BrowserControlFactory.newBrowserControl();
|
||||
Assert.assert_it(control != null);
|
||||
|
||||
Preferences wc = (Preferences)
|
||||
control.queryInterface(org.mozilla.webclient.BrowserControl.WINDOW_CONTROL_NAME);
|
||||
Assert.assert_it(wc != null);
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println("got exception: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// ----VERTIGO_TEST_END
|
||||
native void nativeSetUnicharPref(int nativeContext,
|
||||
String prefName, String prefValue);
|
||||
native void nativeSetIntPref(int nativeContext,
|
||||
String prefName, int prefValue);
|
||||
native void nativeSetBoolPref(int nativeContext,
|
||||
String prefName, boolean prefValue);
|
||||
native Properties nativeGetPrefs(int nativeContext, Properties props);
|
||||
native void nativeRegisterPrefChangedCallback(int nativeContext,
|
||||
PrefChangedCallback cb,
|
||||
String prefName,
|
||||
Object closure);
|
||||
native void nativeUnregisterPrefChangedCallback(int nativeContext,
|
||||
PrefChangedCallback cb,
|
||||
String prefName,
|
||||
Object closure);
|
||||
|
||||
} // end of class PreferencesImpl
|
|
@ -0,0 +1,153 @@
|
|||
/* -*- 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.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Ashu Kulkarni <ashuk@eng.sun.com>
|
||||
* Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.impl.wrapper_native;
|
||||
|
||||
import org.mozilla.util.Assert;
|
||||
import org.mozilla.util.Log;
|
||||
import org.mozilla.util.ParameterCheck;
|
||||
|
||||
import org.mozilla.webclient.ProfileManager;
|
||||
import org.mozilla.webclient.impl.WrapperFactory;
|
||||
import org.mozilla.webclient.impl.Service;
|
||||
|
||||
import org.mozilla.webclient.UnimplementedException;
|
||||
|
||||
|
||||
public class ProfileManagerImpl extends ImplObjectNative implements ProfileManager, Service
|
||||
{
|
||||
|
||||
// local variables
|
||||
|
||||
public ProfileManagerImpl(WrapperFactory yourFactory)
|
||||
{
|
||||
super(yourFactory, null);
|
||||
|
||||
}
|
||||
|
||||
public void startup() {
|
||||
nativeStartup(getWrapperFactory().getNativeContext(), null, null);
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
nativeShutdown(getWrapperFactory().getNativeContext());
|
||||
}
|
||||
|
||||
public int getProfileCount()
|
||||
{
|
||||
return nativeGetProfileCount(getWrapperFactory().getNativeContext());
|
||||
}
|
||||
|
||||
public String [] getProfileList()
|
||||
{
|
||||
String [] list = null;
|
||||
list = nativeGetProfileList(getWrapperFactory().getNativeContext());
|
||||
return list;
|
||||
}
|
||||
|
||||
public boolean profileExists(String profileName)
|
||||
{
|
||||
boolean exists = false;
|
||||
exists = nativeProfileExists(getWrapperFactory().getNativeContext(),
|
||||
profileName);
|
||||
return exists;
|
||||
}
|
||||
|
||||
public String getCurrentProfile()
|
||||
{
|
||||
String currProfile = null;
|
||||
currProfile =
|
||||
nativeGetCurrentProfile(getWrapperFactory().getNativeContext());
|
||||
return currProfile;
|
||||
}
|
||||
|
||||
public void setCurrentProfile(String profileName)
|
||||
{
|
||||
nativeSetCurrentProfile(getWrapperFactory().getNativeContext(),
|
||||
profileName);
|
||||
}
|
||||
|
||||
public void createNewProfile(String profileName,
|
||||
String nativeProfileDir,
|
||||
String langcode,
|
||||
boolean useExistingDir)
|
||||
{
|
||||
nativeCreateNewProfile(getWrapperFactory().getNativeContext(),
|
||||
profileName, nativeProfileDir, langcode,
|
||||
useExistingDir);
|
||||
}
|
||||
|
||||
public void renameProfile(String currName, String newName)
|
||||
{
|
||||
nativeRenameProfile(getWrapperFactory().getNativeContext(),
|
||||
currName, newName);
|
||||
}
|
||||
|
||||
public void deleteProfile(String profileName, boolean canDeleteFiles)
|
||||
{
|
||||
nativeDeleteProfile(getWrapperFactory().getNativeContext(),
|
||||
profileName, canDeleteFiles);
|
||||
}
|
||||
|
||||
public void cloneProfile(String currName)
|
||||
{
|
||||
}
|
||||
|
||||
protected void finalize()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Native methods
|
||||
//
|
||||
|
||||
native void nativeStartup(int nativeContext,
|
||||
String profileDir, String profileName);
|
||||
|
||||
native void nativeShutdown(int nativeContext);
|
||||
|
||||
native int nativeGetProfileCount(int nativeContext);
|
||||
|
||||
native boolean nativeProfileExists(int nativeContext, String profileName);
|
||||
|
||||
native void nativeSetCurrentProfile(int nativeContext, String profileName);
|
||||
|
||||
native String nativeGetCurrentProfile(int nativeContext);
|
||||
|
||||
native String [] nativeGetProfileList(int nativeContext);
|
||||
|
||||
native void nativeCreateNewProfile(int nativeContext,
|
||||
String profileName,
|
||||
String nativeProfileDir,
|
||||
String langcode,
|
||||
boolean useExistingDir);
|
||||
|
||||
native void nativeRenameProfile(int nativeContext,
|
||||
String currName, String newName);
|
||||
|
||||
native void nativeDeleteProfile(int nativeContext,
|
||||
String profileName, boolean canDeleteFiles);
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -20,7 +20,7 @@
|
|||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.wrapper_native;
|
||||
package org.mozilla.webclient.impl.wrapper_native;
|
||||
|
||||
import org.mozilla.util.Assert;
|
||||
import org.mozilla.util.Log;
|
||||
|
@ -68,12 +68,12 @@ private int nativeContainer = -1;
|
|||
|
||||
/**
|
||||
|
||||
* a handle to the actual mozilla webShell, owned, allocated, and
|
||||
* released by WindowControl
|
||||
* <p>the nativeContext, owned by WrapperFactory</p>
|
||||
*
|
||||
|
||||
*/
|
||||
|
||||
public int nativeWebShell = -1;
|
||||
public int nativeContext = -1;
|
||||
|
||||
|
||||
|
||||
|
@ -81,9 +81,10 @@ public int nativeWebShell = -1;
|
|||
// Constructors and Initializers
|
||||
//
|
||||
|
||||
public RDFEnumeration(int yourNativeWebShell, RDFTreeNode enumParent)
|
||||
public RDFEnumeration(int yourNativeContext,
|
||||
RDFTreeNode enumParent)
|
||||
{
|
||||
nativeWebShell = yourNativeWebShell;
|
||||
nativeContext = yourNativeContext;
|
||||
parent = enumParent;
|
||||
nativeRDFNode = parent.getNativeRDFNode();
|
||||
}
|
||||
|
@ -102,7 +103,7 @@ public RDFEnumeration(int yourNativeWebShell, RDFTreeNode enumParent)
|
|||
|
||||
protected void finalize() throws Throwable
|
||||
{
|
||||
nativeFinalize(nativeWebShell);
|
||||
nativeFinalize(nativeContext);
|
||||
super.finalize();
|
||||
}
|
||||
|
||||
|
@ -113,7 +114,7 @@ protected void finalize() throws Throwable
|
|||
public boolean hasMoreElements()
|
||||
{
|
||||
Assert.assert_it(-1 != nativeRDFNode);
|
||||
return nativeHasMoreElements(nativeWebShell, nativeRDFNode);
|
||||
return nativeHasMoreElements(nativeContext, nativeRDFNode);
|
||||
}
|
||||
|
||||
public Object nextElement()
|
||||
|
@ -122,9 +123,9 @@ public Object nextElement()
|
|||
Object result = null;
|
||||
int nextNativeRDFNode;
|
||||
|
||||
if (-1 != (nextNativeRDFNode = nativeNextElement(nativeWebShell,
|
||||
if (-1 != (nextNativeRDFNode = nativeNextElement(nativeContext,
|
||||
nativeRDFNode))) {
|
||||
result = parent.newRDFTreeNode(nativeWebShell,
|
||||
result = parent.newRDFTreeNode(nativeContext,
|
||||
nextNativeRDFNode, parent);
|
||||
}
|
||||
|
||||
|
@ -135,7 +136,7 @@ public Object nextElement()
|
|||
// Native Methods
|
||||
//
|
||||
|
||||
private native boolean nativeHasMoreElements(int webShellPtr,
|
||||
private native boolean nativeHasMoreElements(int nativeContext,
|
||||
int nativeRDFNode);
|
||||
|
||||
/**
|
||||
|
@ -144,26 +145,9 @@ private native boolean nativeHasMoreElements(int webShellPtr,
|
|||
|
||||
*/
|
||||
|
||||
private native int nativeNextElement(int webShellPtr,
|
||||
private native int nativeNextElement(int nativeContext,
|
||||
int nativeRDFNode);
|
||||
protected native void nativeFinalize(int webShellPtr);
|
||||
protected native void nativeFinalize(int nativeContext);
|
||||
|
||||
// ----VERTIGO_TEST_START
|
||||
|
||||
//
|
||||
// Test methods
|
||||
//
|
||||
|
||||
public static void main(String [] args)
|
||||
{
|
||||
Assert.setEnabled(true);
|
||||
|
||||
Log.setApplicationName("RDFEnumeration");
|
||||
Log.setApplicationVersion("0.0");
|
||||
Log.setApplicationVersionDate("$Id: RDFEnumeration.java,v 1.3 2001-05-29 18:36:11 ashuk%eng.sun.com Exp $");
|
||||
|
||||
}
|
||||
|
||||
// ----VERTIGO_TEST_END
|
||||
|
||||
} // end of class RDFEnumeration
|
|
@ -20,7 +20,7 @@
|
|||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.wrapper_native;
|
||||
package org.mozilla.webclient.impl.wrapper_native;
|
||||
|
||||
import org.mozilla.util.Assert;
|
||||
import org.mozilla.util.Log;
|
||||
|
@ -60,13 +60,10 @@ private RDFTreeNode parent;
|
|||
Properties properties = null;
|
||||
|
||||
/**
|
||||
|
||||
* a handle to the actual mozilla webShell, owned, allocated, and
|
||||
* released by WindowControl
|
||||
|
||||
* the native pointer from WrapperFactory.
|
||||
*/
|
||||
|
||||
public int nativeWebShell = -1;
|
||||
public int nativeContext = -1;
|
||||
|
||||
|
||||
//
|
||||
|
@ -76,7 +73,7 @@ public int nativeWebShell = -1;
|
|||
protected RDFTreeNode(int yourNativeWebShell,
|
||||
int nativeNode, RDFTreeNode yourParent)
|
||||
{
|
||||
nativeWebShell = yourNativeWebShell;
|
||||
nativeContext = yourNativeWebShell;
|
||||
nativeRDFNode = nativeNode;
|
||||
parent = yourParent;
|
||||
}
|
||||
|
@ -104,7 +101,7 @@ public Properties getProperties()
|
|||
// Abstract Methods
|
||||
//
|
||||
|
||||
protected abstract RDFTreeNode newRDFTreeNode(int nativeWebShell,
|
||||
protected abstract RDFTreeNode newRDFTreeNode(int nativeContext,
|
||||
int nativeNode,
|
||||
RDFTreeNode yourParent);
|
||||
|
||||
|
@ -137,7 +134,7 @@ public String toString()
|
|||
{
|
||||
String result = null;
|
||||
if (-1 != nativeRDFNode) {
|
||||
result = nativeToString(nativeWebShell, nativeRDFNode);
|
||||
result = nativeToString(nativeContext, nativeRDFNode);
|
||||
}
|
||||
else {
|
||||
result = super.toString();
|
||||
|
@ -155,7 +152,7 @@ public Enumeration children()
|
|||
Assert.assert_it(-1 != nativeRDFNode);
|
||||
Enumeration enum = null;
|
||||
|
||||
enum = new RDFEnumeration(nativeWebShell, this);
|
||||
enum = new RDFEnumeration(nativeContext, this);
|
||||
|
||||
return enum;
|
||||
}
|
||||
|
@ -172,9 +169,9 @@ public TreeNode getChildAt(int childIndex)
|
|||
int childNode;
|
||||
|
||||
if (!isLeaf()) {
|
||||
if (-1 != (childNode = nativeGetChildAt(nativeWebShell, nativeRDFNode,
|
||||
if (-1 != (childNode = nativeGetChildAt(nativeContext, nativeRDFNode,
|
||||
childIndex))) {
|
||||
result = newRDFTreeNode(nativeWebShell, childNode, this);
|
||||
result = newRDFTreeNode(nativeContext, childNode, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -186,7 +183,7 @@ public int getChildCount()
|
|||
Assert.assert_it(-1 != nativeRDFNode);
|
||||
int result = -1;
|
||||
|
||||
result = nativeGetChildCount(nativeWebShell, nativeRDFNode);
|
||||
result = nativeGetChildCount(nativeContext, nativeRDFNode);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -196,7 +193,7 @@ public int getIndex(TreeNode node)
|
|||
Assert.assert_it(-1 != nativeRDFNode);
|
||||
int result = -1;
|
||||
if (node instanceof RDFTreeNode) {
|
||||
result = nativeGetIndex(nativeWebShell, nativeRDFNode,
|
||||
result = nativeGetIndex(nativeContext, nativeRDFNode,
|
||||
((RDFTreeNode)node).nativeRDFNode);
|
||||
}
|
||||
|
||||
|
@ -213,7 +210,7 @@ public boolean isLeaf()
|
|||
{
|
||||
Assert.assert_it(-1 != nativeRDFNode);
|
||||
|
||||
return nativeIsLeaf(nativeWebShell, nativeRDFNode);
|
||||
return nativeIsLeaf(nativeContext, nativeRDFNode);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -240,7 +237,7 @@ public void insert(MutableTreeNode child, int index)
|
|||
int childNativeRDFNode;
|
||||
|
||||
// hook up the child to its native peer
|
||||
childNativeRDFNode = nativeNewFolder(nativeWebShell, nativeRDFNode,
|
||||
childNativeRDFNode = nativeNewFolder(nativeContext, nativeRDFNode,
|
||||
childNode.getProperties());
|
||||
|
||||
// hook up the child to its native peer
|
||||
|
@ -251,7 +248,7 @@ public void insert(MutableTreeNode child, int index)
|
|||
int childNativeRDFNode = childNode.getNativeRDFNode();
|
||||
|
||||
// hook up the child to its native peer
|
||||
nativeInsertElementAt(nativeWebShell, nativeRDFNode,
|
||||
nativeInsertElementAt(nativeContext, nativeRDFNode,
|
||||
childNativeRDFNode, childNode.getProperties(),
|
||||
index);
|
||||
}
|
||||
|
@ -300,7 +297,7 @@ public boolean isFolder()
|
|||
}
|
||||
}
|
||||
else {
|
||||
result = nativeIsContainer(nativeWebShell, getNativeRDFNode());
|
||||
result = nativeIsContainer(nativeContext, getNativeRDFNode());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -310,8 +307,8 @@ public boolean isFolder()
|
|||
// Native methods
|
||||
//
|
||||
|
||||
public native boolean nativeIsLeaf(int webShellPtr, int nativeRDFNode);
|
||||
public native boolean nativeIsContainer(int webShellPtr, int nativeRDFNode);
|
||||
public native boolean nativeIsLeaf(int nativeContext, int nativeRDFNode);
|
||||
public native boolean nativeIsContainer(int nativeContext, int nativeRDFNode);
|
||||
|
||||
/**
|
||||
|
||||
|
@ -319,36 +316,17 @@ public native boolean nativeIsContainer(int webShellPtr, int nativeRDFNode);
|
|||
|
||||
*/
|
||||
|
||||
public native int nativeGetChildAt(int webShellPtr, int nativeRDFNode,
|
||||
public native int nativeGetChildAt(int nativeContext, int nativeRDFNode,
|
||||
int childIndex);
|
||||
public native int nativeGetChildCount(int webShellPtr, int nativeRDFNode);
|
||||
public native int nativeGetIndex(int webShellPtr, int nativeRDFNode,
|
||||
public native int nativeGetChildCount(int nativeContext, int nativeRDFNode);
|
||||
public native int nativeGetIndex(int nativeContext, int nativeRDFNode,
|
||||
int childRDFNode);
|
||||
public native String nativeToString(int webShellPtr, int nativeRDFNode);
|
||||
public native void nativeInsertElementAt(int webShellPtr,
|
||||
public native String nativeToString(int nativeContext, int nativeRDFNode);
|
||||
public native void nativeInsertElementAt(int nativeContext,
|
||||
int parentNativeRDFNode,
|
||||
int childNativeRDFNode,
|
||||
Properties childProps, int index);
|
||||
public native int nativeNewFolder(int webShellPtr, int parentRDFNode,
|
||||
public native int nativeNewFolder(int nativeContext, int parentRDFNode,
|
||||
Properties childProps);
|
||||
|
||||
|
||||
// ----VERTIGO_TEST_START
|
||||
|
||||
//
|
||||
// Test methods
|
||||
//
|
||||
|
||||
public static void main(String [] args)
|
||||
{
|
||||
Assert.setEnabled(true);
|
||||
|
||||
Log.setApplicationName("RDFTreeNode");
|
||||
Log.setApplicationVersion("0.0");
|
||||
Log.setApplicationVersionDate("$Id: RDFTreeNode.java,v 1.5 2001-05-29 18:36:11 ashuk%eng.sun.com Exp $");
|
||||
|
||||
}
|
||||
|
||||
// ----VERTIGO_TEST_END
|
||||
|
||||
} // end of class RDFTreeNode
|
|
@ -0,0 +1,100 @@
|
|||
/* -*- 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.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
|
||||
* Contributor(s): Daniel Park <daepark@apmindsf.com>
|
||||
*
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.impl.wrapper_native;
|
||||
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import org.mozilla.webclient.Selection;
|
||||
|
||||
public class SelectionImpl extends Object implements Selection {
|
||||
|
||||
private String _selection = null;
|
||||
private Node _startContainer = null;
|
||||
private Node _endContainer = null;
|
||||
private int _startOffset = -1;
|
||||
private int _endOffset = -1;
|
||||
|
||||
/**
|
||||
* Create an invalid (or uninitialized) Selection object.
|
||||
*/
|
||||
public SelectionImpl() {}
|
||||
|
||||
public void init(String selection,
|
||||
Node startContainer,
|
||||
Node endContainer,
|
||||
int startOffset,
|
||||
int endOffset)
|
||||
{
|
||||
_selection = selection;
|
||||
_startContainer = startContainer;
|
||||
_endContainer = endContainer;
|
||||
_startOffset = startOffset;
|
||||
_endOffset = endOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the text representation of this Selection object.
|
||||
*/
|
||||
public String toString() {
|
||||
return (_selection);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Node that contains the start of this selection.
|
||||
*/
|
||||
public Node getStartContainer() {
|
||||
return (_startContainer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Node that contains the end of this selection.
|
||||
*/
|
||||
public Node getEndContainer() {
|
||||
return (_endContainer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the offset to which the selection starts within the startContainer.
|
||||
*/
|
||||
public int getStartOffset() {
|
||||
return (_startOffset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the offset to which the selection ends within the endContainer.
|
||||
*/
|
||||
public int getEndOffset() {
|
||||
return (_endOffset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if the selection properties have been set.
|
||||
*/
|
||||
public boolean isValid() {
|
||||
if (_selection == null ||
|
||||
_startContainer == null ||
|
||||
_endContainer == null ||
|
||||
_startOffset == -1 ||
|
||||
_endOffset == -1) {
|
||||
return (false);
|
||||
}
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
||||
} // end class "SelectionImpl"
|
|
@ -0,0 +1,80 @@
|
|||
/* -*- 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.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.impl.wrapper_native;
|
||||
|
||||
import org.mozilla.util.ParameterCheck;
|
||||
|
||||
import org.mozilla.webclient.WebclientEventListener;
|
||||
|
||||
/**
|
||||
|
||||
* This class allows the custom app to have one instance that implements
|
||||
* multiple Webclient event listener types. <P>
|
||||
|
||||
* This is simply a "struct" type class that encapsulates a listener
|
||||
* instance with its class name. This is necessary because the class
|
||||
* name is lost when we deal with the listener as a
|
||||
* WebclientEventListener, and not a WebclientEventListener subclass. <P>
|
||||
|
||||
* @see org.mozilla.webclient.wrapper_native.NativeEventThread#addListener
|
||||
* @see org.mozilla.webclient.wrapper_native.NativeEventThread#removeListener
|
||||
|
||||
* note that we use "package protection" here since this class isn't
|
||||
* public.
|
||||
|
||||
*/
|
||||
|
||||
class WCEventListenerWrapper extends Object
|
||||
{
|
||||
//
|
||||
// Instance Variables
|
||||
//
|
||||
|
||||
// Attribute Instance Variables
|
||||
|
||||
// Relationship Instance Variables
|
||||
|
||||
/**
|
||||
|
||||
* These are public for easy access
|
||||
|
||||
*/
|
||||
|
||||
public WebclientEventListener listener;
|
||||
public String listenerClassName;
|
||||
|
||||
//
|
||||
// Constructors and Initializers
|
||||
//
|
||||
|
||||
public WCEventListenerWrapper(WebclientEventListener yourListener,
|
||||
String yourListenerClassName)
|
||||
{
|
||||
ParameterCheck.nonNull(yourListener);
|
||||
ParameterCheck.nonNull(yourListenerClassName);
|
||||
listener = yourListener;
|
||||
listenerClassName = yourListenerClassName;
|
||||
}
|
||||
|
||||
|
||||
} // end of class WCEventListenerWrapper
|
|
@ -0,0 +1,235 @@
|
|||
/* -*- 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.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.impl.wrapper_native;
|
||||
|
||||
import org.mozilla.util.Assert;
|
||||
import org.mozilla.util.Log;
|
||||
import org.mozilla.util.ParameterCheck;
|
||||
|
||||
import java.awt.event.MouseListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.Component;
|
||||
import org.mozilla.webclient.WCMouseEvent;
|
||||
import org.mozilla.webclient.WebclientEvent;
|
||||
import org.mozilla.webclient.WebclientEventListener;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
|
||||
* This class wraps the user provided instance of
|
||||
* java.awt.event.MouseListener so it can be installed as a
|
||||
* WebclientEventListener. Note that we implement MouseListener so we
|
||||
* can be detected by the webclient event system. We don't do anything
|
||||
* with these methods here, though.
|
||||
|
||||
*/
|
||||
|
||||
public class WCMouseListenerImpl extends Object implements WebclientEventListener, MouseListener
|
||||
{
|
||||
//
|
||||
// Protected Constants
|
||||
//
|
||||
|
||||
//
|
||||
// Class Variables
|
||||
//
|
||||
|
||||
//
|
||||
// Instance Variables
|
||||
//
|
||||
|
||||
// Attribute Instance Variables
|
||||
|
||||
// Relationship Instance Variables
|
||||
|
||||
/**
|
||||
|
||||
* The MouseListener for which I proxy.
|
||||
|
||||
*/
|
||||
|
||||
protected MouseListener mouseListener;
|
||||
|
||||
//
|
||||
// Constructors and Initializers
|
||||
//
|
||||
|
||||
WCMouseListenerImpl(MouseListener yourListener)
|
||||
{
|
||||
super();
|
||||
// ParameterCheck.nonNull();
|
||||
mouseListener = yourListener;
|
||||
}
|
||||
|
||||
//
|
||||
// Class methods
|
||||
//
|
||||
|
||||
//
|
||||
// General Methods
|
||||
//
|
||||
|
||||
MouseListener getMouseListener()
|
||||
{
|
||||
return mouseListener;
|
||||
}
|
||||
|
||||
//
|
||||
// Methods from WebclientEventListener
|
||||
//
|
||||
|
||||
/**
|
||||
|
||||
* Here's where we take the WebclientEvent from mozilla, generate an
|
||||
* appropriate WCMouseEvent instance, and call the
|
||||
* appropriate listener event.
|
||||
|
||||
*/
|
||||
|
||||
public void eventDispatched(WebclientEvent event)
|
||||
{
|
||||
ParameterCheck.nonNull(event);
|
||||
WCMouseEvent mouseEvent;
|
||||
Properties props = (Properties) event.getEventData();
|
||||
int modifiers = 0, x = -1, y = -1, clickCount = 0;
|
||||
String str;
|
||||
boolean bool;
|
||||
if (null != props) {
|
||||
if (null != (str = props.getProperty("ClientX"))) {
|
||||
x = Integer.valueOf(str).intValue();
|
||||
}
|
||||
if (null != (str = props.getProperty("ClientY"))) {
|
||||
y = Integer.valueOf(str).intValue();
|
||||
}
|
||||
if (null != (str = props.getProperty("ClickCount"))) {
|
||||
clickCount = Integer.valueOf(str).intValue();
|
||||
}
|
||||
if (null != (str = props.getProperty("Button"))) {
|
||||
int button = Integer.valueOf(str).intValue();
|
||||
if (1 == button) {
|
||||
modifiers += InputEvent.BUTTON1_MASK;
|
||||
}
|
||||
if (2 == button) {
|
||||
modifiers += InputEvent.BUTTON2_MASK;
|
||||
}
|
||||
if (3 == button) {
|
||||
modifiers += InputEvent.BUTTON3_MASK;
|
||||
}
|
||||
}
|
||||
if (null != (str = props.getProperty("Alt"))) {
|
||||
bool = Boolean.valueOf(str).booleanValue();
|
||||
if (bool) {
|
||||
modifiers += InputEvent.ALT_MASK;
|
||||
}
|
||||
}
|
||||
if (null != (str = props.getProperty("Ctrl"))) {
|
||||
bool = Boolean.valueOf(str).booleanValue();
|
||||
if (bool) {
|
||||
modifiers += InputEvent.CTRL_MASK;
|
||||
}
|
||||
}
|
||||
if (null != (str = props.getProperty("Meta"))) {
|
||||
bool = Boolean.valueOf(str).booleanValue();
|
||||
if (bool) {
|
||||
modifiers += InputEvent.META_MASK;
|
||||
}
|
||||
}
|
||||
if (null != (str = props.getProperty("Shift"))) {
|
||||
bool = Boolean.valueOf(str).booleanValue();
|
||||
if (bool) {
|
||||
modifiers += InputEvent.SHIFT_MASK;
|
||||
}
|
||||
}
|
||||
}
|
||||
switch ((int) event.getType()) {
|
||||
case (int) WCMouseEvent.MOUSE_DOWN_EVENT_MASK:
|
||||
mouseEvent =
|
||||
new WCMouseEvent((Component) event.getSource(),
|
||||
MouseEvent.MOUSE_PRESSED, -1,
|
||||
modifiers, x, y, clickCount, false, event);
|
||||
mouseListener.mousePressed(mouseEvent);
|
||||
break;
|
||||
case (int) WCMouseEvent.MOUSE_UP_EVENT_MASK:
|
||||
mouseEvent =
|
||||
new WCMouseEvent((Component) event.getSource(),
|
||||
MouseEvent.MOUSE_RELEASED, -1,
|
||||
modifiers, x, y, clickCount, false, event);
|
||||
mouseListener.mouseReleased(mouseEvent);
|
||||
break;
|
||||
case (int) WCMouseEvent.MOUSE_CLICK_EVENT_MASK:
|
||||
case (int) WCMouseEvent.MOUSE_DOUBLE_CLICK_EVENT_MASK:
|
||||
mouseEvent =
|
||||
new WCMouseEvent((Component) event.getSource(),
|
||||
MouseEvent.MOUSE_CLICKED, -1,
|
||||
modifiers, x, y, clickCount, false, event);
|
||||
mouseListener.mouseClicked(mouseEvent);
|
||||
break;
|
||||
case (int) WCMouseEvent.MOUSE_OVER_EVENT_MASK:
|
||||
mouseEvent =
|
||||
new WCMouseEvent((Component) event.getSource(),
|
||||
MouseEvent.MOUSE_ENTERED, -1,
|
||||
modifiers, x, y, clickCount, false, event);
|
||||
mouseListener.mouseEntered(mouseEvent);
|
||||
break;
|
||||
case (int) WCMouseEvent.MOUSE_OUT_EVENT_MASK:
|
||||
mouseEvent =
|
||||
new WCMouseEvent((Component) event.getSource(),
|
||||
MouseEvent.MOUSE_EXITED, -1,
|
||||
modifiers, x, y, clickCount, false, event);
|
||||
mouseListener.mouseExited(mouseEvent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// From MouseListener
|
||||
//
|
||||
|
||||
public void mouseClicked(MouseEvent e)
|
||||
{
|
||||
Assert.assert_it(false, "This method should not be called.");
|
||||
}
|
||||
|
||||
public void mouseEntered(MouseEvent e)
|
||||
{
|
||||
Assert.assert_it(false, "This method should not be called.");
|
||||
}
|
||||
|
||||
public void mouseExited(MouseEvent e)
|
||||
{
|
||||
Assert.assert_it(false, "This method should not be called.");
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent e)
|
||||
{
|
||||
Assert.assert_it(false, "This method should not be called.");
|
||||
}
|
||||
|
||||
public void mouseReleased(MouseEvent e)
|
||||
{
|
||||
Assert.assert_it(false, "This method should not be called.");
|
||||
}
|
||||
|
||||
} // end of class WCMouseListenerImpl
|
|
@ -20,7 +20,7 @@
|
|||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.wrapper_native;
|
||||
package org.mozilla.webclient.impl.wrapper_native;
|
||||
|
||||
import org.mozilla.util.Assert;
|
||||
import org.mozilla.util.Log;
|
||||
|
@ -28,7 +28,7 @@ import org.mozilla.util.ParameterCheck;
|
|||
|
||||
import org.mozilla.webclient.BrowserControl;
|
||||
import org.mozilla.webclient.WindowControl;
|
||||
import org.mozilla.webclient.WrapperFactory;
|
||||
import org.mozilla.webclient.impl.WrapperFactory;
|
||||
|
||||
import org.mozilla.webclient.UnimplementedException;
|
||||
|
||||
|
@ -106,7 +106,7 @@ NativeEventThread getNativeEventThread()
|
|||
public void setBounds(Rectangle newBounds)
|
||||
{
|
||||
ParameterCheck.nonNull(newBounds);
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
|
@ -119,7 +119,7 @@ public void createWindow(int nativeWindow, Rectangle bounds)
|
|||
{
|
||||
ParameterCheck.greaterThan(nativeWindow, 0);
|
||||
ParameterCheck.nonNull(bounds);
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
synchronized(this) {
|
||||
|
@ -146,14 +146,14 @@ public void createWindow(int nativeWindow, Rectangle bounds)
|
|||
|
||||
public int getNativeWebShell()
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
|
||||
return nativeWebShell;
|
||||
}
|
||||
|
||||
public void moveWindowTo(int x, int y)
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeMoveWindowTo(nativeWebShell, x, y);
|
||||
|
@ -162,7 +162,7 @@ public void moveWindowTo(int x, int y)
|
|||
|
||||
public void removeFocus()
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
|
||||
throw new UnimplementedException("\nUnimplementedException -----\n API Function WindowControl::removeFocus has not yet been implemented.\n");
|
||||
|
||||
|
@ -170,7 +170,7 @@ public void removeFocus()
|
|||
|
||||
public void repaint(boolean forceRepaint)
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeRepaint(nativeWebShell, forceRepaint);
|
||||
|
@ -179,7 +179,7 @@ public void repaint(boolean forceRepaint)
|
|||
|
||||
public void setVisible(boolean newState)
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeSetVisible(nativeWebShell, newState);
|
||||
|
@ -188,7 +188,7 @@ public void setVisible(boolean newState)
|
|||
|
||||
public void setFocus()
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
myFactory.verifyInitialized();
|
||||
|
||||
throw new UnimplementedException("\nUnimplementedException -----\n API Function WindowControl::setFocus has not yet been implemented.\n");
|
||||
}
|
||||
|
@ -244,7 +244,7 @@ public static void main(String [] args)
|
|||
|
||||
Log.setApplicationName("WindowControlImpl");
|
||||
Log.setApplicationVersion("0.0");
|
||||
Log.setApplicationVersionDate("$Id: WindowControlImpl.java,v 1.9 2001-05-29 18:36:13 ashuk%eng.sun.com Exp $");
|
||||
Log.setApplicationVersionDate("$Id: WindowControlImpl.java,v 1.1 2003-09-28 06:29:07 edburns%acm.org Exp $");
|
||||
|
||||
try {
|
||||
org.mozilla.webclient.BrowserControlFactory.setAppData(args[0]);
|
|
@ -20,25 +20,27 @@
|
|||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.wrapper_native;
|
||||
package org.mozilla.webclient.impl.wrapper_native;
|
||||
|
||||
import org.mozilla.util.Assert;
|
||||
import org.mozilla.util.Log;
|
||||
import org.mozilla.util.ParameterCheck;
|
||||
|
||||
import org.mozilla.webclient.BrowserControl;
|
||||
import org.mozilla.webclient.WrapperFactory;
|
||||
import org.mozilla.webclient.Bookmarks;
|
||||
import org.mozilla.webclient.Preferences;
|
||||
import org.mozilla.webclient.ProfileManager;
|
||||
import org.mozilla.webclient.ImplObject;
|
||||
|
||||
public class WrapperFactoryImpl extends WrapperFactory
|
||||
import org.mozilla.webclient.impl.WrapperFactory;
|
||||
import org.mozilla.webclient.impl.Service;
|
||||
|
||||
public class WrapperFactoryImpl extends Object implements WrapperFactory
|
||||
{
|
||||
//
|
||||
// Protected Constants
|
||||
//
|
||||
|
||||
final String [] stubsImplementedInterfaces =
|
||||
{
|
||||
};
|
||||
|
||||
//
|
||||
// Class Variables
|
||||
//
|
||||
|
@ -49,10 +51,32 @@ public class WrapperFactoryImpl extends WrapperFactory
|
|||
|
||||
// Attribute Instance Variables
|
||||
|
||||
boolean initialized = false;
|
||||
protected String platformCanvasClassName = null;
|
||||
protected boolean initialized = false;
|
||||
protected int nativeContext = -1;
|
||||
|
||||
// Relationship Instance Variables
|
||||
|
||||
/**
|
||||
* <p>App singleton. WrapperFactoryImpl is the owner of this reference.
|
||||
* We maintain a reference so we can remove it at shutdown time.</p>
|
||||
*/
|
||||
|
||||
protected Bookmarks bookmarks = null;
|
||||
|
||||
/**
|
||||
* <p>App singleton. WrapperFactoryImpl is the owner of this reference.
|
||||
* We maintain a reference so we can remove it at shutdown time.</p>
|
||||
*/
|
||||
protected Preferences prefs = null;
|
||||
|
||||
/**
|
||||
* <p>App singleton. WrapperFactoryImpl is the owner of this reference.
|
||||
* We maintain a reference so we can remove it at shutdown time.</p>
|
||||
*/
|
||||
|
||||
protected ProfileManager profileManager = null;
|
||||
|
||||
//
|
||||
// Constructors and Initializers
|
||||
//
|
||||
|
@ -108,93 +132,157 @@ public WrapperFactoryImpl()
|
|||
public Object newImpl(String interfaceName,
|
||||
BrowserControl browserControl) throws ClassNotFoundException
|
||||
{
|
||||
throwExceptionIfNotInitialized();
|
||||
|
||||
Object result = null;
|
||||
|
||||
synchronized(this) {
|
||||
if (!stubsDoImplement(interfaceName) && !nativeDoesImplement(interfaceName)) {
|
||||
if (!nativeDoesImplement(interfaceName)) {
|
||||
throw new ClassNotFoundException("Can't instantiate " +
|
||||
interfaceName +
|
||||
": not implemented.");
|
||||
}
|
||||
System.out.println("native library does implement " +
|
||||
interfaceName);
|
||||
if (BrowserControl.WINDOW_CONTROL_NAME == interfaceName) {
|
||||
result = new WindowControlImpl(this, browserControl);
|
||||
return result;
|
||||
}
|
||||
if (BrowserControl.NAVIGATION_NAME == interfaceName) {
|
||||
result = new NavigationImpl(this, browserControl);
|
||||
return result;
|
||||
}
|
||||
if (BrowserControl.HISTORY_NAME == interfaceName) {
|
||||
result = new HistoryImpl(this, browserControl);
|
||||
return result;
|
||||
}
|
||||
if (BrowserControl.CURRENT_PAGE_NAME == interfaceName) {
|
||||
result = new CurrentPageImpl(this, browserControl);
|
||||
return result;
|
||||
}
|
||||
if (BrowserControl.EVENT_REGISTRATION_NAME == interfaceName) {
|
||||
result = new EventRegistrationImpl(this, browserControl);
|
||||
return result;
|
||||
}
|
||||
if (BrowserControl.BOOKMARKS_NAME == interfaceName) {
|
||||
result = new BookmarksImpl(this, browserControl);
|
||||
return result;
|
||||
if (null == bookmarks) {
|
||||
bookmarks = new BookmarksImpl(this);
|
||||
}
|
||||
result = bookmarks;
|
||||
}
|
||||
if (BrowserControl.PREFERENCES_NAME == interfaceName) {
|
||||
result = new PreferencesImpl(this, browserControl);
|
||||
return result;
|
||||
if (null == prefs) {
|
||||
prefs = new PreferencesImpl(this);
|
||||
}
|
||||
result = prefs;
|
||||
}
|
||||
if (BrowserControl.PROFILE_MANAGER_NAME == interfaceName) {
|
||||
result = new ProfileManagerImpl(this, browserControl);
|
||||
return result;
|
||||
if (null == profileManager) {
|
||||
profileManager = new ProfileManagerImpl(this);
|
||||
}
|
||||
result = profileManager;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void initialize(String verifiedBinDirAbsolutePath) throws Exception
|
||||
public void initialize(String verifiedBinDirAbsolutePath) throws SecurityException, UnsatisfiedLinkError
|
||||
{
|
||||
synchronized(this) {
|
||||
if (!hasBeenInitialized()) {
|
||||
nativeAppInitialize(verifiedBinDirAbsolutePath);
|
||||
initialized = true;
|
||||
}
|
||||
if (initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
System.loadLibrary("webclient");
|
||||
|
||||
try {
|
||||
nativeContext = nativeAppInitialize(verifiedBinDirAbsolutePath);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
throw new UnsatisfiedLinkError(e.getMessage());
|
||||
}
|
||||
Assert.assert_it(-1 != nativeContext);
|
||||
|
||||
//
|
||||
// create app singletons
|
||||
//
|
||||
profileManager = new ProfileManagerImpl(this);
|
||||
Assert.assert_it(null != profileManager);
|
||||
((Service)profileManager).startup();
|
||||
|
||||
prefs = new PreferencesImpl(this);
|
||||
Assert.assert_it(null != prefs);
|
||||
((Service)prefs).startup();
|
||||
|
||||
bookmarks = new BookmarksImpl(this);
|
||||
Assert.assert_it(null != bookmarks);
|
||||
((Service)bookmarks).startup();
|
||||
|
||||
try {
|
||||
nativeAppSetup(nativeContext);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
throw new UnsatisfiedLinkError(e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
public void verifyInitialized() throws IllegalStateException
|
||||
{
|
||||
if (!initialized) {
|
||||
throw new IllegalStateException("Webclient has not been initialized.");
|
||||
}
|
||||
}
|
||||
|
||||
public void terminate() throws Exception
|
||||
{
|
||||
throwExceptionIfNotInitialized();
|
||||
Assert.assert_it(null != bookmarks);
|
||||
((Service)bookmarks).shutdown();
|
||||
((ImplObject)bookmarks).delete();
|
||||
bookmarks = null;
|
||||
|
||||
Assert.assert_it(null != prefs);
|
||||
((Service)prefs).shutdown();
|
||||
((ImplObject)prefs).delete();
|
||||
prefs = null;
|
||||
|
||||
Assert.assert_it(null != profileManager);
|
||||
((Service)profileManager).shutdown();
|
||||
((ImplObject)profileManager).delete();
|
||||
profileManager = null;
|
||||
|
||||
synchronized(this) {
|
||||
nativeTerminate();
|
||||
initialized = false;
|
||||
nativeTerminate(nativeContext);
|
||||
}
|
||||
|
||||
public int getNativeContext() {
|
||||
return nativeContext;
|
||||
}
|
||||
|
||||
//
|
||||
// helper methods
|
||||
//
|
||||
|
||||
/**
|
||||
*
|
||||
* <p>Called from {@link #loadNativeLibrary}. This method simply
|
||||
* figures out the proper name for the class that is the
|
||||
* BrowserControlCanvas. Sets the {@link #platformCanvasClassName} ivar
|
||||
* as a side effect.</p>
|
||||
*/
|
||||
|
||||
protected String getPlatformCanvasClassName()
|
||||
{
|
||||
if (null != platformCanvasClassName) {
|
||||
return platformCanvasClassName;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasBeenInitialized()
|
||||
{
|
||||
return initialized;
|
||||
}
|
||||
|
||||
|
||||
private boolean stubsDoImplement(String interfaceName)
|
||||
{
|
||||
boolean foundInterface = false;
|
||||
for (int i=0; i<stubsImplementedInterfaces.length; i++) {
|
||||
if (interfaceName.equals(stubsImplementedInterfaces[i])) {
|
||||
foundInterface = true;
|
||||
String osName = System.getProperty("os.name");
|
||||
|
||||
if (null != osName) {
|
||||
if (-1 != osName.indexOf("indows")) {
|
||||
platformCanvasClassName = "org.mozilla.webclient.impl.wrapper_native.win32.Win32BrowserControlCanvas";
|
||||
}
|
||||
else {
|
||||
platformCanvasClassName = "org.mozilla.webclient.impl.wrapper_native.gtk.GtkBrowserControlCanvas";
|
||||
}
|
||||
}
|
||||
return foundInterface;
|
||||
|
||||
return platformCanvasClassName;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native methods
|
||||
//
|
||||
|
@ -210,7 +298,15 @@ private boolean stubsDoImplement(String interfaceName)
|
|||
|
||||
*/
|
||||
|
||||
private native void nativeAppInitialize (String verifiedBinDirAbsolutePath) throws Exception;
|
||||
native int nativeAppInitialize (String verifiedBinDirAbsolutePath) throws Exception;
|
||||
|
||||
/**
|
||||
*
|
||||
* <p>Place to put any final app setup, after the app singletons have
|
||||
* been started.</p>
|
||||
*/
|
||||
|
||||
native void nativeAppSetup(int nativeContext) throws Exception;
|
||||
|
||||
/**
|
||||
|
||||
|
@ -219,7 +315,7 @@ private native void nativeAppInitialize (String verifiedBinDirAbsolutePath) thro
|
|||
|
||||
*/
|
||||
|
||||
private native void nativeTerminate () throws Exception;
|
||||
native void nativeTerminate(int nativeContext) throws Exception;
|
||||
|
||||
/**
|
||||
|
||||
|
@ -232,26 +328,6 @@ private native void nativeTerminate () throws Exception;
|
|||
|
||||
*/
|
||||
|
||||
private native boolean nativeDoesImplement(String interfaceName);
|
||||
|
||||
|
||||
// ----VERTIGO_TEST_START
|
||||
|
||||
//
|
||||
// Test methods
|
||||
//
|
||||
|
||||
public static void main(String [] args)
|
||||
{
|
||||
Assert.setEnabled(true);
|
||||
WrapperFactory me = new WrapperFactoryImpl();
|
||||
Log.setApplicationName("WrapperFactoryImpl");
|
||||
Log.setApplicationVersion("0.0");
|
||||
Log.setApplicationVersionDate("$Id: WrapperFactoryImpl.java,v 1.6 2002-05-08 21:55:12 edburns%acm.org Exp $");
|
||||
|
||||
|
||||
}
|
||||
|
||||
// ----VERTIGO_TEST_END
|
||||
native boolean nativeDoesImplement(String interfaceName);
|
||||
|
||||
} // end of class WrapperFactoryImpl
|
|
@ -19,7 +19,7 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package org.mozilla.webclient.wrapper_native.gtk;
|
||||
package org.mozilla.webclient.impl.wrapper_native.gtk;
|
||||
|
||||
// GtkBrowserControlCanvas.java
|
||||
|
||||
|
@ -42,7 +42,7 @@ import java.awt.Dimension;
|
|||
|
||||
* There is one instance of GtkBrowserControlCanvas per top level awt Frame.
|
||||
|
||||
* @version $Id: GtkBrowserControlCanvas.java,v 1.3 2003-04-09 01:36:02 kyle.yuan%sun.com Exp $
|
||||
* @version $Id: GtkBrowserControlCanvas.java,v 1.1 2003-09-28 06:29:09 edburns%acm.org Exp $
|
||||
*
|
||||
* @see org.mozilla.webclient.BrowserControlCanvasFactory
|
||||
*
|
||||
|
@ -52,11 +52,6 @@ import java.awt.Dimension;
|
|||
|
||||
public class GtkBrowserControlCanvas extends BrowserControlCanvas /* implements ActionListener*/ {
|
||||
|
||||
static {
|
||||
System.loadLibrary("webclientstub");
|
||||
GtkBrowserControlCanvas.loadMainDll();
|
||||
}
|
||||
|
||||
private boolean firstTime = true;
|
||||
private int gtkWinID;
|
||||
private int gtkTopWindow;
|
||||
|
@ -65,7 +60,6 @@ public class GtkBrowserControlCanvas extends BrowserControlCanvas /* implements
|
|||
// We dont need this, now that we use the JAWT Native Interface
|
||||
// private MDrawingSurfaceInfo drawingSurfaceInfo;
|
||||
|
||||
static private native void loadMainDll();
|
||||
native int createTopLevelWindow();
|
||||
native int createContainerWindow(int parent, int width, int height);
|
||||
native int getGTKWinID(int gtkWinPtr);
|
|
@ -20,7 +20,7 @@
|
|||
* Contributor(s):
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.wrapper_native.win32;
|
||||
package org.mozilla.webclient.impl.wrapper_native.win32;
|
||||
|
||||
// Win32BrowserControlCanvas.java
|
||||
|
||||
|
@ -37,7 +37,7 @@ import org.mozilla.util.ParameterCheck;
|
|||
|
||||
* There is one instance of the BrowserControlCanvas per top level awt Frame.
|
||||
|
||||
* @version $Id: Win32BrowserControlCanvas.java,v 1.2 2001-05-25 23:09:42 ashuk%eng.sun.com Exp $
|
||||
* @version $Id: Win32BrowserControlCanvas.java,v 1.1 2003-09-28 06:29:10 edburns%acm.org Exp $
|
||||
*
|
||||
* @see org.mozilla.webclient.BrowserControlCanvasFactory
|
||||
*
|
||||
|
@ -55,10 +55,6 @@ import org.mozilla.webclient.BrowserControlCanvas;
|
|||
*/
|
||||
public class Win32BrowserControlCanvas extends BrowserControlCanvas {
|
||||
|
||||
static {
|
||||
System.loadLibrary("webclient");
|
||||
}
|
||||
|
||||
//New method for obtaining access to the Native Peer handle
|
||||
private native int getHandleToPeer();
|
||||
|
|
@ -0,0 +1 @@
|
|||
All classes in this directory have been moved to ../impl/wrapper_native.
|
|
@ -20,9 +20,7 @@
|
|||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
#include "BookmarksImpl.h"
|
||||
|
||||
#include "RDFActionEvents.h"
|
||||
#include "org_mozilla_webclient_impl_wrapper_0005fnative_BookmarksImpl.h"
|
||||
|
||||
#include "rdf_util.h"
|
||||
#include "ns_util.h"
|
||||
|
@ -31,73 +29,132 @@
|
|||
#include "nsISimpleEnumerator.h"
|
||||
#include "nsString.h"
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_BookmarksImpl_nativeStartup
|
||||
(JNIEnv *env, jobject obj, jint nativeContext)
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("BookmarksImpl_nativeStartup: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
|
||||
PR_ASSERT(wcContext);
|
||||
nsresult rv;
|
||||
|
||||
rv = rdf_startup();
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Can't initialize bookmarks.");
|
||||
return;
|
||||
}
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("BookmarksImpl_nativeStartup: exiting\n"));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_BookmarksImpl_nativeShutdown
|
||||
(JNIEnv *env, jobject obj, jint nativeContext)
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("BookmarksImpl_nativeShutdown: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
|
||||
PR_ASSERT(wcContext);
|
||||
nsresult rv;
|
||||
|
||||
rv = rdf_shutdown();
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Can't shutdown bookmarks.");
|
||||
return;
|
||||
}
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("BookmarksImpl_nativeShutdown: exiting\n"));
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_BookmarksImpl_nativeAddBookmark
|
||||
Java_org_mozilla_webclient_impl_wrapper_1native_BookmarksImpl_nativeAddBookmark
|
||||
(JNIEnv *, jobject, jint, jobject)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_BookmarksImpl_nativeGetBookmarks
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_BookmarksImpl_nativeGetBookmarks
|
||||
(JNIEnv *env, jobject obj, jint nativeContext)
|
||||
{
|
||||
jint result = -1;
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
void * voidResult = nsnull;
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("BookmarksImpl_nativeGetBookmarks: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeGetBookmarks");
|
||||
return result;
|
||||
}
|
||||
PR_ASSERT(wcContext);
|
||||
PR_ASSERT(kNC_BookmarksRoot);
|
||||
|
||||
result = (jint) kNC_BookmarksRoot.get();
|
||||
|
||||
if (!initContext->initComplete) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: can't initialize RDF Utils");
|
||||
return result;
|
||||
}
|
||||
|
||||
wsInitBookmarksEvent *actionEvent = new wsInitBookmarksEvent(initContext);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
voidResult = ::util_PostSynchronousEvent(initContext, event);
|
||||
result = (jint) voidResult;
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("BookmarksImpl_nativeGetBookmarks: exiting\n"));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_BookmarksImpl_nativeNewRDFNode
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jstring urlString,
|
||||
Java_org_mozilla_webclient_impl_wrapper_1native_BookmarksImpl_nativeNewRDFNode
|
||||
(JNIEnv *env, jobject obj, jint nativeContext, jstring urlString,
|
||||
jboolean isFolder)
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("BookmarksImpl_nativeNewRDFNode: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
|
||||
PR_ASSERT(wcContext);
|
||||
jint result = -1;
|
||||
nsCAutoString uri("NC:BookmarksRoot");
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
void * voidResult = nsnull;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeNewRDFNode");
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!initContext->initComplete) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: can't get new RDFNode");
|
||||
return result;
|
||||
}
|
||||
|
||||
const char *url = ::util_GetStringUTFChars(env, urlString);
|
||||
PRUnichar *url = (PRUnichar *) ::util_GetStringChars(env, urlString);
|
||||
if (!url) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: can't get new RDFNode, can't create url string");
|
||||
return result;
|
||||
}
|
||||
|
||||
wsNewRDFNodeEvent *actionEvent = new wsNewRDFNodeEvent(initContext,
|
||||
url,
|
||||
(PRBool) isFolder);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIRDFResource> newNode;
|
||||
|
||||
voidResult = ::util_PostSynchronousEvent(initContext, event);
|
||||
result = (jint) voidResult;
|
||||
rv = gRDF->GetUnicodeResource(nsDependentString(url),
|
||||
getter_AddRefs(newNode));
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeNewRDFNode: can't create new nsIRDFResource.");
|
||||
return result;
|
||||
}
|
||||
|
||||
if (isFolder) {
|
||||
rv = gRDFCU->MakeSeq(gBookmarksDataSource, newNode, nsnull);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: unable to make new folder as a sequence.");
|
||||
return result;
|
||||
}
|
||||
rv = gBookmarksDataSource->Assert(newNode, kRDF_type,
|
||||
kNC_Folder, PR_TRUE);
|
||||
if (rv != NS_OK) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: unable to mark new folder as folder.");
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
* Do the AddRef here.
|
||||
|
||||
*/
|
||||
|
||||
result = (jint) newNode.get();
|
||||
((nsISupports *)result)->AddRef();
|
||||
|
||||
::util_ReleaseStringChars(env, urlString, url);
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("BookmarksImpl_nativeNewRDFNode: exiting\n"));
|
||||
|
||||
::util_ReleaseStringUTFChars(env, urlString, url);
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
* CurrentPageImpl.cpp
|
||||
*/
|
||||
|
||||
#include "CurrentPageImpl.h"
|
||||
#include "org_mozilla_webclient_impl_wrapper_0005fnative_CurrentPageImpl.h"
|
||||
|
||||
#include "CurrentPageActionEvents.h"
|
||||
|
||||
|
@ -39,7 +39,7 @@
|
|||
|
||||
#include "nsCRT.h"
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeCopyCurrentSelectionToSystemClipboard
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_CurrentPageImpl_nativeCopyCurrentSelectionToSystemClipboard
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
@ -52,7 +52,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImp
|
|||
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeGetSelection
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_CurrentPageImpl_nativeGetSelection
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jobject selection)
|
||||
{
|
||||
WebShellInitContext *initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
@ -76,7 +76,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImp
|
|||
}
|
||||
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeHighlightSelection
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_CurrentPageImpl_nativeHighlightSelection
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jobject startContainer, jobject endContainer, jint startOffset, jint endOffset)
|
||||
{
|
||||
WebShellInitContext *initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
@ -94,7 +94,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImp
|
|||
}
|
||||
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeClearAllSelections
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_CurrentPageImpl_nativeClearAllSelections
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
WebShellInitContext *initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
@ -113,11 +113,11 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImp
|
|||
}
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_webclient_wrapper_0005fnative_CurrentPageImpl
|
||||
* Class: org_mozilla_webclient_impl_wrapper_0005fnative_CurrentPageImpl
|
||||
* Method: nativeFindInPage
|
||||
* Signature: (Ljava/lang/String;ZZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeFindInPage
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_CurrentPageImpl_nativeFindInPage
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jstring searchString, jboolean forward, jboolean matchCase)
|
||||
{
|
||||
|
||||
|
@ -144,11 +144,11 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImp
|
|||
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_webclient_wrapper_0005fnative_CurrentPageImpl
|
||||
* Class: org_mozilla_webclient_impl_wrapper_0005fnative_CurrentPageImpl
|
||||
* Method: nativeFindNextInPage
|
||||
* Signature: (Z)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeFindNextInPage
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_CurrentPageImpl_nativeFindNextInPage
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
|
||||
|
@ -166,11 +166,11 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImp
|
|||
}
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_webclient_wrapper_0005fnative_CurrentPageImpl
|
||||
* Class: org_mozilla_webclient_impl_wrapper_0005fnative_CurrentPageImpl
|
||||
* Method: nativeGetCurrentURL
|
||||
* Signature: ()Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeGetCurrentURL
|
||||
JNIEXPORT jstring JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_CurrentPageImpl_nativeGetCurrentURL
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
JNIEnv * pEnv = env;
|
||||
|
@ -205,7 +205,7 @@ JNIEXPORT jstring JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPage
|
|||
return urlString;
|
||||
}
|
||||
|
||||
JNIEXPORT jobject JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeGetDOM
|
||||
JNIEXPORT jobject JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_CurrentPageImpl_nativeGetDOM
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
@ -244,13 +244,13 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPage
|
|||
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_webclient_wrapper_0005fnative_CurrentPageImpl
|
||||
* Class: org_mozilla_webclient_impl_wrapper_0005fnative_CurrentPageImpl
|
||||
* Method: nativeGetSource
|
||||
* Signature: ()Ljava/lang/String;
|
||||
*/
|
||||
|
||||
/* PENDING(ashuk): remove this from here and in the motif directory
|
||||
JNIEXPORT jstring JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeGetSource
|
||||
JNIEXPORT jstring JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_CurrentPageImpl_nativeGetSource
|
||||
(JNIEnv * env, jobject jobj)
|
||||
{
|
||||
jstring result = nsnull;
|
||||
|
@ -261,13 +261,13 @@ JNIEXPORT jstring JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPage
|
|||
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_webclient_wrapper_0005fnative_CurrentPageImpl
|
||||
* Class: org_mozilla_webclient_impl_wrapper_0005fnative_CurrentPageImpl
|
||||
* Method: nativeGetSourceBytes
|
||||
* Signature: ()[B
|
||||
*/
|
||||
|
||||
/* PENDING(ashuk): remove this from here and in the motif directory
|
||||
JNIEXPORT jbyteArray JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeGetSourceBytes
|
||||
JNIEXPORT jbyteArray JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_CurrentPageImpl_nativeGetSourceBytes
|
||||
(JNIEnv * env, jobject jobj, jint webShellPtr, jboolean viewMode)
|
||||
{
|
||||
|
||||
|
@ -289,11 +289,11 @@ JNIEXPORT jbyteArray JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentP
|
|||
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_webclient_wrapper_0005fnative_CurrentPageImpl
|
||||
* Class: org_mozilla_webclient_impl_wrapper_0005fnative_CurrentPageImpl
|
||||
* Method: nativeResetFind
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeResetFind
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_CurrentPageImpl_nativeResetFind
|
||||
(JNIEnv * env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
@ -303,11 +303,11 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImp
|
|||
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_webclient_wrapper_0005fnative_CurrentPageImpl
|
||||
* Class: org_mozilla_webclient_impl_wrapper_0005fnative_CurrentPageImpl
|
||||
* Method: nativeSelectAll
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeSelectAll
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_CurrentPageImpl_nativeSelectAll
|
||||
(JNIEnv * env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
@ -319,11 +319,11 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImp
|
|||
}
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_webclient_wrapper_0005fnative_CurrentPageImpl
|
||||
* Class: org_mozilla_webclient_impl_wrapper_0005fnative_CurrentPageImpl
|
||||
* Method: nativePrint
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativePrint
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_CurrentPageImpl_nativePrint
|
||||
(JNIEnv * env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
@ -335,11 +335,11 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImp
|
|||
}
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_webclient_wrapper_0005fnative_CurrentPageImpl
|
||||
* Class: org_mozilla_webclient_impl_wrapper_0005fnative_CurrentPageImpl
|
||||
* Method: nativePrintPreview
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativePrintPreview
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_CurrentPageImpl_nativePrintPreview
|
||||
(JNIEnv * env, jobject obj, jint webShellPtr, jboolean preview)
|
||||
{
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
* Ashutosh Kulkarni <ashuk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#include "HistoryImpl.h"
|
||||
#include "org_mozilla_webclient_impl_wrapper_0005fnative_HistoryImpl.h"
|
||||
|
||||
#include "HistoryActionEvents.h"
|
||||
|
||||
|
@ -35,7 +35,7 @@
|
|||
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeBack
|
||||
Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeBack
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
JNIEnv * pEnv = env;
|
||||
|
@ -60,7 +60,7 @@ Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeBack
|
|||
}
|
||||
|
||||
JNIEXPORT jboolean
|
||||
JNICALL Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeCanBack
|
||||
JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeCanBack
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
jboolean result = JNI_FALSE;
|
||||
|
@ -89,7 +89,7 @@ JNICALL Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeCanBack
|
|||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jobjectArray JNICALL Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeGetBackList
|
||||
JNIEXPORT jobjectArray JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeGetBackList
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
jobjectArray result = nsnull;
|
||||
|
@ -98,13 +98,13 @@ JNIEXPORT jobjectArray JNICALL Java_org_mozilla_webclient_wrapper_1native_Histor
|
|||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeClearHistory
|
||||
Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeClearHistory
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeForward
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeForward
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
JNIEnv * pEnv = env;
|
||||
|
@ -128,7 +128,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_na
|
|||
return;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeCanForward
|
||||
JNIEXPORT jboolean JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeCanForward
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
jboolean result = JNI_FALSE;
|
||||
|
@ -156,7 +156,7 @@ JNIEXPORT jboolean JNICALL Java_org_mozilla_webclient_wrapper_1native_HistoryImp
|
|||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jobjectArray JNICALL Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeGetForwardList
|
||||
JNIEXPORT jobjectArray JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeGetForwardList
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
jobjectArray result = nsnull;
|
||||
|
@ -164,7 +164,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_mozilla_webclient_wrapper_1native_Histor
|
|||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jobjectArray JNICALL Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeGetHistory
|
||||
JNIEXPORT jobjectArray JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeGetHistory
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
jobjectArray result = nsnull;
|
||||
|
@ -173,7 +173,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_mozilla_webclient_wrapper_1native_Histor
|
|||
}
|
||||
|
||||
JNIEXPORT jobject JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeGetHistoryEntry
|
||||
Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeGetHistoryEntry
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint historyIndex)
|
||||
{
|
||||
jobject result = nsnull;
|
||||
|
@ -182,7 +182,7 @@ Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeGetHistoryEntry
|
|||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeGetCurrentHistoryIndex
|
||||
Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeGetCurrentHistoryIndex
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
JNIEnv * pEnv = env;
|
||||
|
@ -211,7 +211,7 @@ Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeGetCurrentHistoryIn
|
|||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeSetCurrentHistoryIndex
|
||||
Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeSetCurrentHistoryIndex
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint historyIndex)
|
||||
{
|
||||
JNIEnv * pEnv = env;
|
||||
|
@ -236,7 +236,7 @@ Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeSetCurrentHistoryIn
|
|||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeGetHistoryLength
|
||||
Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeGetHistoryLength
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
JNIEnv * pEnv = env;
|
||||
|
@ -264,7 +264,7 @@ Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeGetHistoryLength
|
|||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeGetURLForIndex
|
||||
JNIEXPORT jstring JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeGetURLForIndex
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint historyIndex)
|
||||
{
|
||||
JNIEnv * pEnv = env;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
#include "ISupportsPeer.h"
|
||||
#include "org_mozilla_webclient_impl_wrapper_0005fnative_ISupportsPeer.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsISupports.h"
|
||||
|
@ -30,7 +30,7 @@
|
|||
//
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_ISupportsPeer_nativeAddRef
|
||||
Java_org_mozilla_webclient_impl_wrapper_1native_ISupportsPeer_nativeAddRef
|
||||
(JNIEnv *env, jobject obj, jint nativeISupportsImpl)
|
||||
{
|
||||
nsCOMPtr<nsISupports> supports = (nsISupports *) nativeISupportsImpl;
|
||||
|
@ -38,7 +38,7 @@ Java_org_mozilla_webclient_wrapper_1native_ISupportsPeer_nativeAddRef
|
|||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_ISupportsPeer_nativeRelease
|
||||
Java_org_mozilla_webclient_impl_wrapper_1native_ISupportsPeer_nativeRelease
|
||||
(JNIEnv *env, jobject obj, jint nativeISupportsImpl)
|
||||
{
|
||||
nsCOMPtr<nsISupports> supports = (nsISupports *) nativeISupportsImpl;
|
||||
|
|
|
@ -106,12 +106,11 @@ CPPSRCS = \
|
|||
InputStreamShim.cpp \
|
||||
RDFEnumeration.cpp \
|
||||
RDFTreeNode.cpp \
|
||||
RDFActionEvents.cpp \
|
||||
wsRDFObserver.cpp \
|
||||
WindowControlImpl.cpp \
|
||||
WindowControlActionEvents.cpp \
|
||||
PreferencesImpl.cpp \
|
||||
PreferencesActionEvents.cpp \
|
||||
ProfileManagerImpl.cpp \
|
||||
WrapperFactoryImpl.cpp \
|
||||
WindowCreator.cpp \
|
||||
$(NULL)
|
||||
|
|
|
@ -27,22 +27,15 @@
|
|||
* Kyle Yuan <kyle.yuan@sun.com>
|
||||
*/
|
||||
|
||||
#include "NativeEventThread.h"
|
||||
#include "org_mozilla_webclient_impl_wrapper_0005fnative_NativeEventThread.h"
|
||||
#include "CBrowserContainer.h"
|
||||
|
||||
#include "ns_util.h"
|
||||
#include "ns_globals.h"
|
||||
|
||||
#include "nsEmbedAPI.h" // for NS_InitEmbedding
|
||||
|
||||
#include "nsIProfile.h" // for the profile manager
|
||||
#include "nsIProfileInternal.h" // for the profile manager
|
||||
#include "nsICmdLineService.h" // for the cmdline service to give to the
|
||||
// profile manager.
|
||||
|
||||
#include "nsCRT.h" // for nsCRT::strcmp
|
||||
#include "prenv.h"
|
||||
#include "nsILocalFile.h"
|
||||
// #include "WrapperFactoryImpl.cpp"
|
||||
|
||||
#ifdef XP_PC
|
||||
|
@ -86,13 +79,10 @@ static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
|
|||
static NS_DEFINE_IID(kISHistoryIID, NS_ISHISTORY_IID);
|
||||
static NS_DEFINE_CID(kSHistoryCID, NS_SHISTORY_CID);
|
||||
|
||||
static NS_DEFINE_CID(kCmdLineServiceCID, NS_COMMANDLINE_SERVICE_CID);
|
||||
|
||||
static const char *NS_DOCSHELL_PROGID = "component://netscape/docshell/html";
|
||||
//static const char *NS_WEBBROWSER_PROGID = "component://netscape/embedding/browser/nsWebBrowser";
|
||||
|
||||
extern const char * gBinDir; // defined in WrapperFactoryImpl.cpp
|
||||
|
||||
#ifdef XP_PC
|
||||
|
||||
// All this stuff is needed to initialize the history
|
||||
|
@ -167,7 +157,6 @@ nsresult InitMozillaStuff (WebShellInitContext * arg);
|
|||
// Local data
|
||||
//
|
||||
|
||||
nsIComponentManager *gComponentManager = nsnull;
|
||||
static PRBool gFirstTime = PR_TRUE;
|
||||
PLEventQueue * gActionQueue = nsnull;
|
||||
PRThread * gEmbeddedThread = nsnull;
|
||||
|
@ -186,7 +175,7 @@ char * errorMessages[] = {
|
|||
// JNI methods
|
||||
//
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NativeEventThread_nativeInitialize
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_NativeEventThread_nativeInitialize
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
@ -197,10 +186,6 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NativeEventThr
|
|||
"NULL webShellPtr passed to nativeInitialize.");
|
||||
return;
|
||||
}
|
||||
if (nsnull == gVm) { // declared in ../src_share/jni_util.h
|
||||
::util_GetJavaVM(env, &gVm); // save this vm reference
|
||||
}
|
||||
|
||||
rv = InitMozillaStuff(initContext);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env,
|
||||
|
@ -219,7 +204,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NativeEventThr
|
|||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NativeEventThread_nativeProcessEvents
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_NativeEventThread_nativeProcessEvents
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
WebShellInitContext * initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
@ -252,7 +237,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NativeEventThr
|
|||
|
||||
*/
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NativeEventThread_nativeAddListener
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_NativeEventThread_nativeAddListener
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jobject typedListener,
|
||||
jstring listenerString)
|
||||
{
|
||||
|
@ -322,7 +307,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NativeEventThr
|
|||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_NativeEventThread_nativeRemoveListener
|
||||
Java_org_mozilla_webclient_impl_wrapper_1native_NativeEventThread_nativeRemoveListener
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jobject typedListener,
|
||||
jstring listenerString)
|
||||
{
|
||||
|
@ -371,7 +356,7 @@ Java_org_mozilla_webclient_wrapper_1native_NativeEventThread_nativeRemoveListene
|
|||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_NativeEventThread_nativeRemoveAllListeners(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
Java_org_mozilla_webclient_impl_wrapper_1native_NativeEventThread_nativeRemoveAllListeners(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
WebShellInitContext *initContext = (WebShellInitContext *)webShellPtr;
|
||||
|
||||
|
@ -498,29 +483,10 @@ nsresult InitializeWindowCreator(WebShellInitContext * initContext)
|
|||
void DoMozInitialization(WebShellInitContext * initContext)
|
||||
{
|
||||
if (gFirstTime) {
|
||||
// PENDING(edburns): We need this for rdf_getChildCount
|
||||
PR_SetEnv("XPCOM_CHECK_THREADSAFE=0");
|
||||
|
||||
nsILocalFile * pathFile = nsnull;
|
||||
nsresult rv = nsnull;
|
||||
JNIEnv * env = initContext->env;
|
||||
nsAutoString BinDir;
|
||||
BinDir.AssignWithConversion(gBinDir);
|
||||
|
||||
rv = NS_NewLocalFile(BinDir, PR_TRUE, &pathFile);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "call to NS_NewLocalFile failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
// It is vitally important to call NS_InitEmbedding before calling
|
||||
// anything else.
|
||||
NS_InitEmbedding(pathFile, nsnull);
|
||||
rv = NS_GetGlobalComponentManager(&gComponentManager);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "NS_GetGlobalComponentManager() failed.");
|
||||
return;
|
||||
}
|
||||
const char *webclientLogFile = PR_GetEnv("WEBCLIENT_LOG_FILE");
|
||||
if (nsnull != webclientLogFile) {
|
||||
PR_SetLogFile(webclientLogFile);
|
||||
|
@ -529,66 +495,6 @@ void DoMozInitialization(WebShellInitContext * initContext)
|
|||
|
||||
InitializeWindowCreator(initContext);
|
||||
|
||||
// handle the profile manager nonsense
|
||||
nsCOMPtr<nsICmdLineService> cmdLine =do_GetService(kCmdLineServiceCID);
|
||||
nsCOMPtr<nsIProfile> profile = do_GetService(NS_PROFILE_CONTRACTID);
|
||||
if (!cmdLine || !profile) {
|
||||
::util_ThrowExceptionToJava(env, "Can't get the profile manager.");
|
||||
return;
|
||||
}
|
||||
PRInt32 numProfiles=0;
|
||||
rv = profile->GetProfileCount(&numProfiles);
|
||||
char *argv[3];
|
||||
int i, argc = 0;
|
||||
argv[0] = strdup(gBinDir);
|
||||
if (numProfiles > 1) {
|
||||
PRUnichar **Names;
|
||||
PRUint32 NamesLen = 0;
|
||||
rv = profile->GetProfileList(&NamesLen, &Names);
|
||||
argv[1] = strdup("-p");
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PR_ASSERT(NamesLen >= 1);
|
||||
// PENDING(edburns): fix for 70656. Really we should have a way
|
||||
// for the embedding app to specify which profile to use.
|
||||
// For now we just get the name of the first profile.
|
||||
char * temp = new char[100]; // de-allocated in following for loop
|
||||
for (i = 0; Names[0][i] != '\0'; i++) {
|
||||
temp[i] = (char) Names[0][i];
|
||||
}
|
||||
nsMemory::Free(Names);
|
||||
temp[i] = '\0';
|
||||
argv[2] = temp;
|
||||
argc = 3;
|
||||
}
|
||||
else {
|
||||
argv[2] = strdup("default");
|
||||
}
|
||||
printf("debug: edburns: argv[1]: %s argv[2]: %s\n", argv[1],
|
||||
argv[2]);
|
||||
}
|
||||
else {
|
||||
argc = 1;
|
||||
}
|
||||
rv = cmdLine->Initialize(argc, argv);
|
||||
for (i = 0; i < argc; i++) {
|
||||
nsCRT::free(argv[i]);
|
||||
}
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Can't initialize nsICmdLineService.");
|
||||
return;
|
||||
}
|
||||
nsCOMPtr<nsIProfileInternal> profileInt = do_QueryInterface(profile);
|
||||
if (profileInt) {
|
||||
rv = profileInt->StartupWithArgs(cmdLine, PR_FALSE);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Can't statrup nsIProfile service.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
::util_ThrowExceptionToJava(env, "Can't statrup nsIProfile service.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -600,8 +506,6 @@ nsresult InitMozillaStuff (WebShellInitContext * initContext)
|
|||
|
||||
DoMozInitialization(initContext);
|
||||
|
||||
PR_ASSERT(gComponentManager);
|
||||
|
||||
if (gFirstTime) {
|
||||
printf ("\n\nCreating Event Queue \n\n");
|
||||
nsCOMPtr<nsIEventQueueService>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#ifndef NativeEventThreadActionEvents_h___
|
||||
#define NativeEventThreadActionEvents_h___
|
||||
|
||||
#include "NativeEventThread.h"
|
||||
#include "org_mozilla_webclient_impl_wrapper_0005fnative_NativeEventThread.h"
|
||||
#include "CBrowserContainer.h"
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
* Anthony Sizer <sizera@yahoo.com>
|
||||
*/
|
||||
|
||||
#include "NavigationImpl.h"
|
||||
#include "org_mozilla_webclient_impl_wrapper_0005fnative_NavigationImpl.h"
|
||||
|
||||
#include "NavigationActionEvents.h"
|
||||
#include "nsIServiceManagerUtils.h"
|
||||
|
@ -38,7 +38,7 @@
|
|||
|
||||
#include "ns_util.h"
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NavigationImpl_nativeLoadURL
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_NavigationImpl_nativeLoadURL
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jstring urlString)
|
||||
{
|
||||
jobject jobj = obj;
|
||||
|
@ -83,7 +83,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NavigationImpl
|
|||
::util_ReleaseStringChars(env, urlString, (const jchar *) urlStringChars);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NavigationImpl_nativeLoadFromStream
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_NavigationImpl_nativeLoadFromStream
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jobject stream, jstring uri,
|
||||
jstring contentType, jint contentLength, jobject loadProperties)
|
||||
{
|
||||
|
@ -150,7 +150,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NavigationImpl
|
|||
// wsLoadFromStreamEvent destructor.
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NavigationImpl_nativePost
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_NavigationImpl_nativePost
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jstring absoluteURL, jstring target, jint postDataLength,
|
||||
jstring postData, jint postHeadersLength, jstring postHeaders)
|
||||
{
|
||||
|
@ -268,7 +268,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NavigationImpl
|
|||
return;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NavigationImpl_nativeRefresh
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_NavigationImpl_nativeRefresh
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jlong loadFlags)
|
||||
{
|
||||
JNIEnv * pEnv = env;
|
||||
|
@ -293,7 +293,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NavigationImpl
|
|||
return;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NavigationImpl_nativeStop
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_NavigationImpl_nativeStop
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
JNIEnv * pEnv = env;
|
||||
|
@ -315,7 +315,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NavigationImpl
|
|||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_NavigationImpl_nativeSetPrompt
|
||||
Java_org_mozilla_webclient_impl_wrapper_1native_NavigationImpl_nativeSetPrompt
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jobject userPrompt)
|
||||
{
|
||||
JNIEnv * pEnv = env;
|
||||
|
|
|
@ -20,100 +20,155 @@
|
|||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
#include "PreferencesImpl.h"
|
||||
#include "PreferencesActionEvents.h"
|
||||
#include "org_mozilla_webclient_impl_wrapper_0005fnative_PreferencesImpl.h"
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_PreferencesImpl_nativeSetUnicharPref
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jstring prefName,
|
||||
jstring prefValue)
|
||||
#include <nsIPref.h>
|
||||
#include <nsIServiceManager.h> // for do_getService
|
||||
#include <nsDataHashtable.h>
|
||||
#include <nsHashKeys.h> // for nsStringHashKey
|
||||
#include "ns_util.h"
|
||||
//
|
||||
// Local Data
|
||||
//
|
||||
|
||||
#include "ns_util.h"
|
||||
|
||||
typedef struct _peStruct {
|
||||
WebclientContext *cx;
|
||||
jobject obj;
|
||||
jobject callback;
|
||||
} peStruct;
|
||||
|
||||
nsDataHashtable<nsCStringHashKey,peStruct *> closures;
|
||||
|
||||
//
|
||||
// Local functions
|
||||
//
|
||||
|
||||
void prefEnumerator(const char *name, void *closure);
|
||||
static int PR_CALLBACK prefChanged(const char *name, void *closure);
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_PreferencesImpl_nativeStartup
|
||||
(JNIEnv *env, jobject obj, jint nativeContext)
|
||||
{
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to netiveSetPref");
|
||||
return;
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("PreferencesImpl_nativeStartup: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
|
||||
PR_ASSERT(wcContext);
|
||||
|
||||
nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID));
|
||||
|
||||
if (!prefs) {
|
||||
::util_ThrowExceptionToJava(env, "Can't get the preferences.");
|
||||
return;
|
||||
}
|
||||
|
||||
const char * prefNameChars = (char *) ::util_GetStringUTFChars(env,
|
||||
prefName);
|
||||
const jchar * prefValueChars = (jchar *) ::util_GetStringChars(env,
|
||||
prefValue);
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
wsSetUnicharPrefEvent *actionEvent = nsnull;
|
||||
void *voidResult = nsnull;
|
||||
wcContext->sPrefs = prefs.get();
|
||||
NS_ADDREF(wcContext->sPrefs);
|
||||
|
||||
closures.Init();
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("PreferencesImpl_nativeStartup: exiting\n"));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_PreferencesImpl_nativeShutdown
|
||||
(JNIEnv *env, jobject obj, jint nativeContext)
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("PreferencesImpl_nativeShutdown: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
|
||||
PR_ASSERT(wcContext);
|
||||
|
||||
closures.Clear();
|
||||
|
||||
NS_RELEASE(wcContext->sPrefs);
|
||||
wcContext->sPrefs = nsnull;
|
||||
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("PreferencesImpl_nativeShutdown: exiting\n"));
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_impl_wrapper_1native_PreferencesImpl_nativeSetUnicharPref
|
||||
(JNIEnv *env, jobject obj, jint nativeContext, jstring prefName,
|
||||
jstring prefValue)
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("PreferencesImpl_nativeSetUnicharPref: entering\n"));
|
||||
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
nsCOMPtr<nsIPref> prefs = nsnull;
|
||||
PR_ASSERT(wcContext);
|
||||
|
||||
prefs = wcContext->sPrefs;
|
||||
PR_ASSERT(prefs);
|
||||
|
||||
const char * prefNameChars = (char *)::util_GetStringUTFChars(env,
|
||||
prefName);
|
||||
const jchar * prefValueChars = (jchar *)::util_GetStringChars(env,
|
||||
prefValue);
|
||||
if (nsnull == prefNameChars) {
|
||||
::util_ThrowExceptionToJava(env, "nativeSetUnicharPref: unable to extract Java string for pref name");
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
goto NSUP_CLEANUP;
|
||||
goto OMWIWNPINSUP_CLEANUP;
|
||||
}
|
||||
if (nsnull == prefValueChars) {
|
||||
::util_ThrowExceptionToJava(env, "nativeSetUnicharPref: unable to extract Java string for pref value");
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
goto NSUP_CLEANUP;
|
||||
goto OMWIWNPINSUP_CLEANUP;
|
||||
}
|
||||
|
||||
if (!(actionEvent = new wsSetUnicharPrefEvent(prefNameChars,
|
||||
prefValueChars))) {
|
||||
::util_ThrowExceptionToJava(env, "nativeSetPref: unable to create actionEvent");
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
goto NSUP_CLEANUP;
|
||||
}
|
||||
|
||||
voidResult = ::util_PostSynchronousEvent(initContext,
|
||||
(PLEvent *) *actionEvent);
|
||||
rv = (nsresult) voidResult;
|
||||
rv = prefs->SetUnicharPref(prefNameChars,
|
||||
(const PRUnichar *) prefValueChars);
|
||||
|
||||
NSUP_CLEANUP:
|
||||
OMWIWNPINSUP_CLEANUP:
|
||||
|
||||
::util_ReleaseStringUTFChars(env, prefName, prefNameChars);
|
||||
::util_ReleaseStringChars(env, prefName, prefValueChars);
|
||||
::util_ReleaseStringChars(env, prefValue, prefValueChars);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
// PENDING(edburns): set a more specific kind of pref
|
||||
::util_ThrowExceptionToJava(env, "nativeSetUnicharPref: can't set pref");
|
||||
}
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("PreferencesImpl_nativeSetUnicharPref: exiting\n"));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_PreferencesImpl_nativeSetIntPref
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jstring prefName,
|
||||
Java_org_mozilla_webclient_impl_wrapper_1native_PreferencesImpl_nativeSetIntPref
|
||||
(JNIEnv *env, jobject obj, jint nativeContext, jstring prefName,
|
||||
jint prefValue)
|
||||
{
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("PreferencesImpl_nativeSetIntPref: entering\n"));
|
||||
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
nsCOMPtr<nsIPref> prefs = nsnull;
|
||||
PR_ASSERT(wcContext);
|
||||
|
||||
prefs = wcContext->sPrefs;
|
||||
PR_ASSERT(prefs);
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to netiveSetPref");
|
||||
return;
|
||||
}
|
||||
const char * prefNameChars = (char *) ::util_GetStringUTFChars(env,
|
||||
prefName);
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
wsSetIntPrefEvent *actionEvent = nsnull;
|
||||
void *voidResult = nsnull;
|
||||
|
||||
if (nsnull == prefNameChars) {
|
||||
::util_ThrowExceptionToJava(env, "nativeSetIntPref: unable to extract Java string");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(actionEvent = new wsSetIntPrefEvent(prefNameChars,
|
||||
(PRInt32) prefValue))) {
|
||||
::util_ThrowExceptionToJava(env, "nativeSetPref: unable to create actionEvent");
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
goto NSIP_CLEANUP;
|
||||
}
|
||||
rv = prefs->SetIntPref(prefNameChars, (PRInt32) prefValue);
|
||||
|
||||
voidResult = ::util_PostSynchronousEvent(initContext,
|
||||
(PLEvent *) *actionEvent);
|
||||
rv = (nsresult) voidResult;
|
||||
|
||||
NSIP_CLEANUP:
|
||||
|
||||
::util_ReleaseStringUTFChars(env, prefName, prefNameChars);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -121,45 +176,36 @@ Java_org_mozilla_webclient_wrapper_1native_PreferencesImpl_nativeSetIntPref
|
|||
::util_ThrowExceptionToJava(env, "nativeSetIntPref: can't set pref");
|
||||
}
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("PreferencesImpl_nativeSetIntPref: exiting\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_PreferencesImpl_nativeSetBoolPref
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jstring prefName,
|
||||
Java_org_mozilla_webclient_impl_wrapper_1native_PreferencesImpl_nativeSetBoolPref
|
||||
(JNIEnv *env, jobject obj, jint nativeContext, jstring prefName,
|
||||
jboolean prefValue)
|
||||
{
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to netiveSetPref");
|
||||
return;
|
||||
}
|
||||
|
||||
const char * prefNameChars = (char *) ::util_GetStringUTFChars(env,
|
||||
prefName);
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("PreferencesImpl_nativeSetIntPref: entering\n"));
|
||||
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
wsSetBoolPrefEvent *actionEvent = nsnull;
|
||||
void *voidResult = nsnull;
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
nsCOMPtr<nsIPref> prefs = nsnull;
|
||||
PR_ASSERT(wcContext);
|
||||
|
||||
prefs = wcContext->sPrefs;
|
||||
PR_ASSERT(prefs);
|
||||
|
||||
const char * prefNameChars = (char *)::util_GetStringUTFChars(env,
|
||||
prefName);
|
||||
if (nsnull == prefNameChars) {
|
||||
::util_ThrowExceptionToJava(env, "nativeSetBoolPref: unable to extract Java string");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(actionEvent = new wsSetBoolPrefEvent(prefNameChars,
|
||||
prefValue))) {
|
||||
::util_ThrowExceptionToJava(env, "nativeSetPref: unable to create actionEvent");
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
goto NSBP_CLEANUP;
|
||||
}
|
||||
|
||||
voidResult = ::util_PostSynchronousEvent(initContext,
|
||||
(PLEvent *) *actionEvent);
|
||||
rv = (nsresult) voidResult;
|
||||
|
||||
NSBP_CLEANUP:
|
||||
rv = prefs->SetBoolPref(prefNameChars, prefValue);
|
||||
|
||||
::util_ReleaseStringUTFChars(env, prefName, prefNameChars);
|
||||
|
||||
|
@ -169,31 +215,34 @@ Java_org_mozilla_webclient_wrapper_1native_PreferencesImpl_nativeSetBoolPref
|
|||
}
|
||||
|
||||
return;
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("PreferencesImpl_nativeSetIntPref: exiting\n"));
|
||||
|
||||
}
|
||||
|
||||
JNIEXPORT jobject JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_PreferencesImpl_nativeGetPrefs
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jobject props)
|
||||
Java_org_mozilla_webclient_impl_wrapper_1native_PreferencesImpl_nativeGetPrefs
|
||||
(JNIEnv *env, jobject obj, jint nativeContext, jobject props)
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("PreferencesImpl_nativeGetIntPref: entering\n"));
|
||||
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
jobject newProps;
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
wsGetPrefsEvent *actionEvent = nsnull;
|
||||
void *voidResult = nsnull;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to netiveGetPrefs");
|
||||
return props;
|
||||
}
|
||||
|
||||
PR_ASSERT(initContext->initComplete);
|
||||
jobject newProps = nsnull;
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
nsCOMPtr<nsIPref> prefs = nsnull;
|
||||
PR_ASSERT(wcContext);
|
||||
|
||||
prefs = wcContext->sPrefs;
|
||||
PR_ASSERT(prefs);
|
||||
|
||||
// step one: create or clear props
|
||||
if (nsnull == props) {
|
||||
if (nsnull ==
|
||||
(newProps =
|
||||
::util_CreatePropertiesObject(env, (jobject)
|
||||
&(initContext->shareContext)))) {
|
||||
&(wcContext->shareContext)))) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeGetPrefs: can't create prefs.");
|
||||
return props;
|
||||
}
|
||||
|
@ -204,7 +253,7 @@ Java_org_mozilla_webclient_wrapper_1native_PreferencesImpl_nativeGetPrefs
|
|||
}
|
||||
else {
|
||||
::util_ClearPropertiesObject(env, props, (jobject)
|
||||
&(initContext->shareContext));
|
||||
&(wcContext->shareContext));
|
||||
|
||||
}
|
||||
PR_ASSERT(props);
|
||||
|
@ -212,64 +261,46 @@ Java_org_mozilla_webclient_wrapper_1native_PreferencesImpl_nativeGetPrefs
|
|||
// step two, call the magic enumeration function, to populate the
|
||||
// properties
|
||||
peStruct pes;
|
||||
pes.cx = initContext;
|
||||
pes.cx = wcContext;
|
||||
pes.obj = props;
|
||||
if (!(actionEvent = new wsGetPrefsEvent(&pes))) {
|
||||
::util_ThrowExceptionToJava(env, "nativeSetPref: unable to create actionEvent");
|
||||
return props;
|
||||
}
|
||||
|
||||
voidResult = ::util_PostSynchronousEvent(initContext,
|
||||
(PLEvent *) *actionEvent);
|
||||
rv = (nsresult) voidResult;
|
||||
|
||||
rv = prefs->EnumerateChildren("", prefEnumerator, &pes);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
// PENDING(edburns): set a more specific kind of pref
|
||||
::util_ThrowExceptionToJava(env, "nativeGetPrefs: can't get prefs");
|
||||
}
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("PreferencesImpl_nativeGetIntPref: exiting\n"));
|
||||
|
||||
return props;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_PreferencesImpl_nativeRegisterPrefChangedCallback
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr,
|
||||
Java_org_mozilla_webclient_impl_wrapper_1native_PreferencesImpl_nativeRegisterPrefChangedCallback
|
||||
(JNIEnv *env, jobject obj, jint nativeContext,
|
||||
jobject callback, jstring prefName, jobject closure)
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("PreferencesImpl_nativeRegisterPrefChangedCallback: entering\n"));
|
||||
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
const char *prefNameChars;
|
||||
wsRegisterPrefCallbackEvent *actionEvent = nsnull;
|
||||
void *voidResult = nsnull;
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
const char *prefNameChars = nsnull;
|
||||
nsCOMPtr<nsIPref> prefs = nsnull;
|
||||
PR_ASSERT(wcContext);
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeRegisterPrefChangedCallback");
|
||||
return;
|
||||
}
|
||||
|
||||
PR_ASSERT(initContext->initComplete);
|
||||
prefs = wcContext->sPrefs;
|
||||
PR_ASSERT(prefs);
|
||||
|
||||
if (nsnull == (callback = ::util_NewGlobalRef(env, callback))) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeRegisterPrefChangedCallback: can't global ref for callback");
|
||||
return;
|
||||
}
|
||||
|
||||
if (nsnull == (closure = ::util_NewGlobalRef(env, closure))) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeRegisterPrefChangedCallback: can't global ref for closure");
|
||||
return;
|
||||
}
|
||||
|
||||
// step one, set up our struct
|
||||
peStruct *pes;
|
||||
peStruct *pes = new peStruct();
|
||||
|
||||
if (nsnull == (pes = new peStruct())) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeRegisterPrefChangedCallback: can't get peStruct");
|
||||
return;
|
||||
}
|
||||
|
||||
pes->cx = initContext;
|
||||
pes->obj = closure;
|
||||
pes->callback = callback;
|
||||
pes->cx = wcContext;
|
||||
pes->obj = ::util_NewGlobalRef(env, closure);
|
||||
pes->callback = ::util_NewGlobalRef(env, callback);
|
||||
closures.Put(nsDependentCString(prefNameChars), pes);
|
||||
|
||||
// step two: create a const char * from the prefName
|
||||
if (nsnull == (prefNameChars = ::util_GetStringUTFChars(env, prefName))) {
|
||||
|
@ -277,15 +308,7 @@ Java_org_mozilla_webclient_wrapper_1native_PreferencesImpl_nativeRegisterPrefCha
|
|||
return;
|
||||
}
|
||||
|
||||
if (!(actionEvent = new wsRegisterPrefCallbackEvent(prefNameChars, pes))) {
|
||||
::util_ThrowExceptionToJava(env, "nativeSetPref: unable to create actionEvent");
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
return;
|
||||
}
|
||||
|
||||
voidResult = ::util_PostSynchronousEvent(initContext,
|
||||
(PLEvent *) *actionEvent);
|
||||
rv = (nsresult) voidResult;
|
||||
rv = prefs->RegisterCallback(prefNameChars, prefChanged, pes);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
// PENDING(edburns): set a more specific kind of pref
|
||||
|
@ -293,6 +316,165 @@ Java_org_mozilla_webclient_wrapper_1native_PreferencesImpl_nativeRegisterPrefCha
|
|||
}
|
||||
|
||||
::util_ReleaseStringUTFChars(env, prefName, prefNameChars);
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_PreferencesImpl_nativeUnregisterPrefChangedCallback
|
||||
(JNIEnv *env, jobject obj, jint nativeContext,
|
||||
jobject callback, jstring prefName, jobject closure)
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("PreferencesImpl_nativeRegisterPrefChangedCallback: entering\n"));
|
||||
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
const char *prefNameChars = nsnull;
|
||||
nsCOMPtr<nsIPref> prefs = nsnull;
|
||||
PR_ASSERT(wcContext);
|
||||
|
||||
prefs = wcContext->sPrefs;
|
||||
PR_ASSERT(prefs);
|
||||
|
||||
// step one, set up our struct
|
||||
peStruct *pes = nsnull;
|
||||
|
||||
|
||||
// step two: create a const char * from the prefName
|
||||
if (nsnull == (prefNameChars = ::util_GetStringUTFChars(env, prefName))) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeRegisterPrefChangedCallback: can't get string for prefName");
|
||||
return;
|
||||
}
|
||||
|
||||
nsDependentCString prefNameCString(prefNameChars);
|
||||
|
||||
if (closures.Get(prefNameCString, &pes)) {
|
||||
closures.Remove(prefNameCString);
|
||||
|
||||
rv = prefs->UnregisterCallback(prefNameChars, prefChanged, pes);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
// PENDING(edburns): set a more specific kind of pref
|
||||
::util_ThrowExceptionToJava(env, "nativeRegisterPrefChangedCallback: can't set callback");
|
||||
}
|
||||
|
||||
::util_DeleteGlobalRef(env, pes->obj);
|
||||
::util_DeleteGlobalRef(env, pes->callback);
|
||||
delete pes;
|
||||
}
|
||||
|
||||
::util_ReleaseStringUTFChars(env, prefName, prefNameChars);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Helper functions
|
||||
//
|
||||
|
||||
void prefEnumerator(const char *name, void *closure)
|
||||
{
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
|
||||
if (nsnull == closure) {
|
||||
return;
|
||||
}
|
||||
peStruct *pes = (peStruct *) closure;
|
||||
WebclientContext *wcContext = pes->cx;
|
||||
jobject props = pes->obj;
|
||||
PRInt32 prefType, intVal;
|
||||
PRBool boolVal;
|
||||
jstring prefName = nsnull;
|
||||
jstring prefValue = nsnull;
|
||||
PRUnichar *prefValueUni = nsnull;
|
||||
nsAutoString prefValueAuto;
|
||||
const PRInt32 bufLen = 20;
|
||||
char buf[bufLen];
|
||||
memset(buf, 0, bufLen);
|
||||
nsCOMPtr<nsIPref> prefs = wcContext->sPrefs;
|
||||
|
||||
if (nsnull == props || !prefs) {
|
||||
return;
|
||||
}
|
||||
if (NS_FAILED(prefs->GetPrefType(name, &prefType))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (nsnull == (prefName = ::util_NewStringUTF(env, name))) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch(prefType) {
|
||||
case nsIPref::ePrefInt:
|
||||
if (NS_SUCCEEDED(prefs->GetIntPref(name, &intVal))) {
|
||||
WC_ITOA(intVal, buf, 10);
|
||||
prefValue = ::util_NewStringUTF(env, buf);
|
||||
}
|
||||
break;
|
||||
case nsIPref::ePrefBool:
|
||||
if (NS_SUCCEEDED(prefs->GetBoolPref(name, &boolVal))) {
|
||||
if (boolVal) {
|
||||
prefValue = ::util_NewStringUTF(env, "true");
|
||||
}
|
||||
else {
|
||||
prefValue = ::util_NewStringUTF(env, "false");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case nsIPref::ePrefString:
|
||||
if (NS_SUCCEEDED(prefs->CopyUnicharPref(name, &prefValueUni))) {
|
||||
prefValueAuto = prefValueUni;
|
||||
prefValue = ::util_NewString(env, (const jchar *) prefValueUni,
|
||||
prefValueAuto.Length());
|
||||
delete [] prefValueUni;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
PR_ASSERT(PR_TRUE);
|
||||
break;
|
||||
}
|
||||
if (nsnull == prefValue) {
|
||||
prefValue = ::util_NewStringUTF(env, "");
|
||||
}
|
||||
::util_StoreIntoPropertiesObject(env, props, prefName, prefValue,
|
||||
(jobject) &(wcContext->shareContext));
|
||||
::util_DeleteLocalRef(env, prefName);
|
||||
::util_DeleteLocalRef(env, prefValue);
|
||||
}
|
||||
|
||||
static int PR_CALLBACK prefChanged(const char *name, void *closure)
|
||||
{
|
||||
if (nsnull == name || nsnull == closure) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsresult rv;
|
||||
int result;
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
|
||||
peStruct *pes = (peStruct *) closure;
|
||||
jstring prefName;
|
||||
|
||||
if (!(prefName = ::util_NewStringUTF(env, name))) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
#ifdef BAL_INTERFACE
|
||||
#else
|
||||
jclass pcClass = nsnull;
|
||||
jmethodID pcMID = nsnull;
|
||||
|
||||
if (!(pcClass = env->GetObjectClass(pes->callback))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (!(pcMID =env->GetMethodID(pcClass, "prefChanged",
|
||||
"(Ljava/lang/String;Ljava/lang/Object;)I"))){
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
result = env->CallIntMethod(pes->callback, pcMID, prefName,
|
||||
pes->obj);
|
||||
|
||||
#endif
|
||||
|
||||
::util_DeleteStringUTF(env, prefName);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,416 @@
|
|||
/* -*- 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.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Kirk Baker <kbaker@eb.com>
|
||||
* Ian Wilkinson <iw@ennoble.com>
|
||||
* Mark Lin <mark.lin@eng.sun.com>
|
||||
* Mark Goddard
|
||||
* Ed Burns <edburns@acm.org>
|
||||
* Ashutosh Kulkarni <ashuk@eng.sun.com>
|
||||
* Ann Sunhachawee
|
||||
*/
|
||||
|
||||
#include "org_mozilla_webclient_impl_wrapper_0005fnative_ProfileManagerImpl.h"
|
||||
|
||||
#include "ns_util.h"
|
||||
|
||||
#include <nsCRT.h> // for nsCRT::strlen
|
||||
|
||||
#include <nsICmdLineService.h> // for the cmdline service to give to the
|
||||
// profile manager.
|
||||
#include <nsIProfile.h> // for the profile manager
|
||||
#include <nsIProfileInternal.h> // for the profile manager
|
||||
#include <nsString.h> // for nsCAutoString
|
||||
|
||||
static NS_DEFINE_CID(kCmdLineServiceCID, NS_COMMANDLINE_SERVICE_CID);
|
||||
|
||||
//
|
||||
// global data
|
||||
//
|
||||
|
||||
//
|
||||
// Local Functions
|
||||
//
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_ProfileManagerImpl_nativeStartup
|
||||
(JNIEnv *env, jobject obj, jint nativeContext,
|
||||
jstring profileDir , jstring profileName)
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("ProfileManagerImpl_nativeStartup: entering\n"));
|
||||
nsresult rv;
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
|
||||
PR_ASSERT(wcContext);
|
||||
|
||||
// handle the profile manager nonsense
|
||||
nsCOMPtr<nsICmdLineService> cmdLine =do_GetService(kCmdLineServiceCID);
|
||||
nsCOMPtr<nsIProfile> profile = do_GetService(NS_PROFILE_CONTRACTID);
|
||||
if (!cmdLine || !profile) {
|
||||
::util_ThrowExceptionToJava(env, "Can't get the profile manager.");
|
||||
return;
|
||||
}
|
||||
PRInt32 numProfiles=0;
|
||||
rv = profile->GetProfileCount(&numProfiles);
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("ProfileManagerImpl_nativeStartup: GetProfileCount rv: %d\n",
|
||||
rv));
|
||||
|
||||
char *argv[3];
|
||||
int i, argc = 0;
|
||||
argv[0] = PL_strdup(nsnull);
|
||||
if (numProfiles > 1) {
|
||||
PRUnichar **Names;
|
||||
PRUint32 NamesLen = 0;
|
||||
rv = profile->GetProfileList(&NamesLen, &Names);
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("ProfileManagerImpl_nativeStartup: GetProfileList rv: %d\n",
|
||||
rv));
|
||||
|
||||
argv[1] = PL_strdup("-p");
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PR_ASSERT(NamesLen >= 1);
|
||||
// PENDING(edburns): fix for 70656. Really we should have a way
|
||||
// for the embedding app to specify which profile to use.
|
||||
// For now we just get the name of the first profile.
|
||||
char * temp = new char[100]; // de-allocated in following for loop
|
||||
for (i = 0; Names[0][i] != '\0'; i++) {
|
||||
temp[i] = (char) Names[0][i];
|
||||
}
|
||||
nsMemory::Free(Names);
|
||||
temp[i] = '\0';
|
||||
argv[2] = temp;
|
||||
argc = 3;
|
||||
}
|
||||
else {
|
||||
argv[2] = PL_strdup("default");
|
||||
}
|
||||
}
|
||||
else {
|
||||
argc = 1;
|
||||
}
|
||||
rv = cmdLine->Initialize(argc, argv);
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("ProfileManagerImpl_nativeStartup: commandLineService initialize rv: %d\n",
|
||||
rv));
|
||||
|
||||
for (i = 0; i < argc; i++) {
|
||||
nsCRT::free(argv[i]);
|
||||
}
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Can't initialize nsICmdLineService.");
|
||||
return;
|
||||
}
|
||||
nsCOMPtr<nsIProfileInternal> profileInt = do_QueryInterface(profile);
|
||||
if (profileInt) {
|
||||
rv = profileInt->StartupWithArgs(cmdLine, PR_FALSE);
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("ProfileManagerImpl_nativeStartup: profileInternal startupWithArgs rv: %d\n",
|
||||
rv));
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Can't statrup nsIProfile service.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
::util_ThrowExceptionToJava(env, "Can't statrup nsIProfile service.");
|
||||
return;
|
||||
}
|
||||
|
||||
wcContext->sProfile = profile.get();
|
||||
NS_ADDREF(wcContext->sProfile);
|
||||
wcContext->sProfileInternal = profileInt.get();
|
||||
NS_ADDREF(wcContext->sProfileInternal);
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("ProfileManagerImpl_nativeStartup: exiting\n"));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_ProfileManagerImpl_nativeShutdown
|
||||
(JNIEnv *env, jobject, jint nativeContext)
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("ProfileManagerImpl_nativeShutdown: entering\n"));
|
||||
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
|
||||
PR_ASSERT(wcContext);
|
||||
|
||||
NS_RELEASE(wcContext->sProfile);
|
||||
wcContext->sProfile = nsnull;
|
||||
NS_RELEASE(wcContext->sProfileInternal);
|
||||
wcContext->sProfileInternal = nsnull;
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("ProfileManagerImpl_nativeShutdown: exiting\n"));
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_ProfileManagerImpl_nativeGetProfileCount
|
||||
(JNIEnv *env, jobject obj, jint nativeContext)
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("ProfileManagerImpl_nativeGetProfileCount: entering\n"));
|
||||
|
||||
nsresult rv;
|
||||
jint result = -1;
|
||||
PRInt32 count = 0;
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
nsCOMPtr<nsIProfile> profile = nsnull;
|
||||
PR_ASSERT(wcContext);
|
||||
|
||||
profile = wcContext->sProfile;
|
||||
PR_ASSERT(profile);
|
||||
|
||||
rv = profile->GetProfileCount(&count);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Can't get profile count.");
|
||||
return result;
|
||||
}
|
||||
result = (jint) count;
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("ProfileManagerImpl_nativeGetProfileCount: exiting\n"));
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_ProfileManagerImpl_nativeProfileExists
|
||||
(JNIEnv *env, jobject obj, jint nativeContext, jstring profileNameJstr)
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("ProfileManagerImpl_nativeProfileExists: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
PR_ASSERT(wcContext);
|
||||
nsCOMPtr<nsIProfile> profile = wcContext->sProfile;
|
||||
PR_ASSERT(profile);
|
||||
nsresult rv;
|
||||
jboolean result;
|
||||
PRBool exists;
|
||||
PRUnichar *profileName =
|
||||
(PRUnichar *) ::util_GetStringChars(env, profileNameJstr);
|
||||
|
||||
rv = profile->ProfileExists(profileName, &exists);
|
||||
::util_ReleaseStringChars(env, profileNameJstr, profileName);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Can't see if profile exists.");
|
||||
return result;
|
||||
}
|
||||
|
||||
result = exists == PR_TRUE ? JNI_TRUE : JNI_FALSE;
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("ProfileManagerImpl_nativeProfileExists: exiting\n"));
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_ProfileManagerImpl_nativeSetCurrentProfile
|
||||
(JNIEnv *env, jobject obj, jint nativeContext, jstring profileNameJstr)
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("ProfileManagerImpl_nativeSetCurrentProfile: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
PR_ASSERT(wcContext);
|
||||
nsCOMPtr<nsIProfile> profile = wcContext->sProfile;
|
||||
PR_ASSERT(profile);
|
||||
nsresult rv;
|
||||
PRUnichar *profileName =
|
||||
(PRUnichar *) ::util_GetStringChars(env, profileNameJstr);
|
||||
|
||||
rv = profile->SetCurrentProfile(profileName);
|
||||
::util_ReleaseStringChars(env, profileNameJstr, profileName);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Can't set current profile.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("ProfileManagerImpl_nativeSetCurrentProfile: exiting\n"));
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_ProfileManagerImpl_nativeGetCurrentProfile
|
||||
(JNIEnv *env, jobject obj, jint nativeContext)
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("ProfileManagerImpl_nativeGetCurrentProfile: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
PR_ASSERT(wcContext);
|
||||
nsCOMPtr<nsIProfile> profile = wcContext->sProfile;
|
||||
PR_ASSERT(profile);
|
||||
nsresult rv;
|
||||
jstring result = nsnull;
|
||||
nsXPIDLString profileName;
|
||||
|
||||
rv = profile->GetCurrentProfile(getter_Copies(profileName));
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Can't get current profile.");
|
||||
return result;
|
||||
}
|
||||
result = (jstring) ::util_NewString(env, profileName.get(),
|
||||
profileName.Length());
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("ProfileManagerImpl_nativeGetCurrentProfile: exiting\n"));
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jobjectArray JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_ProfileManagerImpl_nativeGetProfileList
|
||||
(JNIEnv *env, jobject obj, jint nativeContext)
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("ProfileManagerImpl_nativeGetProfileList: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
PR_ASSERT(wcContext);
|
||||
nsCOMPtr<nsIProfile> profile = wcContext->sProfile;
|
||||
PR_ASSERT(profile);
|
||||
nsresult rv;
|
||||
jobjectArray result = nsnull;
|
||||
PRUint32 length = -1;
|
||||
PRUnichar **profileNames = nsnull;
|
||||
jint *profileNameLengths = nsnull;
|
||||
int i = 0;
|
||||
|
||||
rv = profile->GetProfileList(&length, &profileNames);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Can't get profile list.");
|
||||
return result;
|
||||
}
|
||||
|
||||
profileNameLengths = new jint[length];
|
||||
for (i = 0; i < length; i++) {
|
||||
profileNameLengths[i] =
|
||||
nsCRT::strlen((const PRUnichar*)profileNames[i]);
|
||||
}
|
||||
result = ::util_GetJstringArrayFromJcharArray(env, length, profileNames,
|
||||
profileNameLengths);
|
||||
if (nsnull == result) {
|
||||
::util_ThrowExceptionToJava(env, "Can't get profile list.");
|
||||
return result;
|
||||
}
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("ProfileManagerImpl_nativeGetProfileList: exiting\n"));
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_ProfileManagerImpl_nativeCreateNewProfile
|
||||
(JNIEnv *env, jobject obj, jint nativeContext,
|
||||
jstring profileNameJstr,
|
||||
jstring nativeProfileDirJstr,
|
||||
jstring langCodeJstr,
|
||||
jboolean useExistingDir)
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("ProfileManagerImpl_nativeCreateNewProfile: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
PR_ASSERT(wcContext);
|
||||
nsCOMPtr<nsIProfile> profile = wcContext->sProfile;
|
||||
PR_ASSERT(profile);
|
||||
PR_ASSERT(profileNameJstr);
|
||||
nsresult rv;
|
||||
const PRUnichar
|
||||
*profileName =
|
||||
(PRUnichar *) ::util_GetStringChars(env, profileNameJstr),
|
||||
*nativeProfileDir = (nsnull == nativeProfileDirJstr) ? nsnull :
|
||||
(PRUnichar *) ::util_GetStringChars(env, nativeProfileDirJstr),
|
||||
*langCode = (nsnull == langCodeJstr) ? nsnull :
|
||||
(PRUnichar *) ::util_GetStringChars(env, langCodeJstr);
|
||||
|
||||
rv = profile->CreateNewProfile(profileName, nativeProfileDir, langCode,
|
||||
useExistingDir);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Can't create new profile.");
|
||||
}
|
||||
|
||||
::util_ReleaseStringChars(env, profileNameJstr, profileName);
|
||||
if (nsnull != nativeProfileDir) {
|
||||
::util_ReleaseStringChars(env, nativeProfileDirJstr, nativeProfileDir);
|
||||
}
|
||||
if (nsnull != langCode) {
|
||||
::util_ReleaseStringChars(env, langCodeJstr, langCode);
|
||||
}
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("ProfileManagerImpl_nativeCreateNewProfile: exiting\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_ProfileManagerImpl_nativeRenameProfile
|
||||
(JNIEnv *env, jobject obj, jint nativeContext,
|
||||
jstring oldNameJstr,
|
||||
jstring newNameJstr)
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("ProfileManagerImpl_nativeRenameProfile: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
PR_ASSERT(wcContext);
|
||||
nsCOMPtr<nsIProfile> profile = wcContext->sProfile;
|
||||
PR_ASSERT(profile);
|
||||
PR_ASSERT(oldNameJstr);
|
||||
PR_ASSERT(newNameJstr);
|
||||
nsresult rv;
|
||||
const PRUnichar
|
||||
*oldName =
|
||||
(PRUnichar *) ::util_GetStringChars(env, oldNameJstr),
|
||||
*newName = (nsnull == newNameJstr) ? nsnull :
|
||||
(PRUnichar *) ::util_GetStringChars(env, newNameJstr);
|
||||
|
||||
rv = profile->RenameProfile(oldName, newName);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Can't create new profile.");
|
||||
}
|
||||
|
||||
::util_ReleaseStringChars(env, oldNameJstr, oldName);
|
||||
::util_ReleaseStringChars(env, newNameJstr, newName);
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("ProfileManagerImpl_nativeRenameProfile: exiting\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_ProfileManagerImpl_nativeDeleteProfile
|
||||
(JNIEnv *env, jobject obj, jint nativeContext,
|
||||
jstring profileNameJstr, jboolean canDeleteFiles)
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("ProfileManagerImpl_nativeDeleteProfile: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
PR_ASSERT(wcContext);
|
||||
nsCOMPtr<nsIProfile> profile = wcContext->sProfile;
|
||||
PR_ASSERT(profile);
|
||||
PR_ASSERT(profileNameJstr);
|
||||
nsresult rv;
|
||||
const PRUnichar
|
||||
*profileName =
|
||||
(PRUnichar *) ::util_GetStringChars(env, profileNameJstr);
|
||||
|
||||
rv = profile->DeleteProfile(profileName, canDeleteFiles);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Can't create new profile.");
|
||||
}
|
||||
|
||||
::util_ReleaseStringChars(env, profileNameJstr, profileName);
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("ProfileManagerImpl_nativeDeleteProfile: exiting\n"));
|
||||
return;
|
||||
}
|
|
@ -21,7 +21,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* RDFActionEvents.cpp
|
||||
* PromptActionEvents.cpp
|
||||
*/
|
||||
|
||||
#include "PromptActionEvents.h"
|
||||
|
|
|
@ -20,9 +20,7 @@
|
|||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
#include "RDFEnumeration.h"
|
||||
|
||||
#include "RDFActionEvents.h"
|
||||
#include "org_mozilla_webclient_impl_wrapper_0005fnative_RDFEnumeration.h"
|
||||
|
||||
#include "rdf_util.h"
|
||||
#include "rdf_progids.h"
|
||||
|
@ -37,92 +35,242 @@
|
|||
|
||||
static NS_DEFINE_CID(kRDFContainerCID, NS_RDFCONTAINER_CID);
|
||||
|
||||
//
|
||||
// Local function prototypes
|
||||
//
|
||||
|
||||
/**
|
||||
|
||||
* pull the int for the field nativeEnum from the java object obj.
|
||||
|
||||
*/
|
||||
|
||||
jint getNativeEnumFromJava(JNIEnv *env, jobject obj, jint nativeRDFNode);
|
||||
|
||||
//
|
||||
// JNI methods
|
||||
//
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_RDFEnumeration_nativeHasMoreElements
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint nativeRDFNode)
|
||||
Java_org_mozilla_webclient_impl_wrapper_1native_RDFEnumeration_nativeHasMoreElements
|
||||
(JNIEnv *env, jobject obj, jint nativeContext, jint nativeRDFNode)
|
||||
{
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
void * voidResult = nsnull;
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("RDFEnumeration_nativeHasMoreElements: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
|
||||
PR_ASSERT(wcContext);
|
||||
PR_ASSERT(nativeRDFNode);
|
||||
nsresult rv;
|
||||
jboolean result = JNI_FALSE;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeIsContainer");
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!initContext->initComplete) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: can't see if isContainer");
|
||||
PRBool prResult = PR_FALSE;
|
||||
jint nativeEnum;
|
||||
|
||||
if (-1 == (nativeEnum = getNativeEnumFromJava(env, obj, nativeRDFNode))) {
|
||||
// PENDING(edburns): should this be an exception?
|
||||
return result;
|
||||
}
|
||||
wsRDFHasMoreElementsEvent *actionEvent =
|
||||
new wsRDFHasMoreElementsEvent(initContext,
|
||||
(PRUint32) nativeRDFNode,
|
||||
(void *) obj);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
voidResult = ::util_PostSynchronousEvent(initContext, event);
|
||||
result = (0 != voidResult) ? JNI_TRUE : JNI_FALSE;
|
||||
nsCOMPtr<nsISimpleEnumerator> enumerator = (nsISimpleEnumerator *)nativeEnum;
|
||||
rv = enumerator->HasMoreElements(&prResult);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeHasMoreElements: Can't ask nsISimpleEnumerator->HasMoreElements().");
|
||||
return result;
|
||||
}
|
||||
result = (PR_FALSE == prResult) ? JNI_FALSE : JNI_TRUE;
|
||||
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("RDFEnumeration_nativeHasMoreElements: exiting\n"));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_RDFEnumeration_nativeNextElement
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint nativeRDFNode)
|
||||
Java_org_mozilla_webclient_impl_wrapper_1native_RDFEnumeration_nativeNextElement
|
||||
(JNIEnv *env, jobject obj, jint nativeContext, jint nativeRDFNode)
|
||||
{
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
void * voidResult = nsnull;
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("RDFEnumeration_nativeNextElement: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
|
||||
PR_ASSERT(wcContext);
|
||||
PR_ASSERT(nativeRDFNode);
|
||||
PR_ASSERT(-1 != nativeRDFNode);
|
||||
nsresult rv;
|
||||
jint result = -1;
|
||||
PRBool hasMoreElements = PR_FALSE;
|
||||
jint nativeEnum;
|
||||
nsCOMPtr<nsISupports> supportsResult;
|
||||
nsCOMPtr<nsIRDFNode> nodeResult;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeIsContainer");
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!initContext->initComplete) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: can't see if isContainer");
|
||||
if (-1 == (nativeEnum = getNativeEnumFromJava(env, (jobject) obj,
|
||||
nativeRDFNode))) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeNextElement: Can't get nativeEnum from nativeRDFNode.");
|
||||
return result;
|
||||
}
|
||||
wsRDFNextElementEvent *actionEvent =
|
||||
new wsRDFNextElementEvent(initContext,
|
||||
(PRUint32) nativeRDFNode,
|
||||
(void *) obj);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
voidResult = ::util_PostSynchronousEvent(initContext, event);
|
||||
result = (jint) voidResult;
|
||||
nsCOMPtr<nsISimpleEnumerator> enumerator = (nsISimpleEnumerator *)nativeEnum;
|
||||
rv = enumerator->HasMoreElements(&hasMoreElements);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeNextElement: Can't ask nsISimpleEnumerator->HasMoreElements().");
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!hasMoreElements) {
|
||||
return result;
|
||||
}
|
||||
|
||||
rv = enumerator->GetNext(getter_AddRefs(supportsResult));
|
||||
if (NS_FAILED(rv)) {
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("Exception: nativeNextElement: Can't get next from enumerator.\n"));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// make sure it's an RDFNode
|
||||
rv = supportsResult->QueryInterface(NS_GET_IID(nsIRDFNode),
|
||||
getter_AddRefs(nodeResult));
|
||||
if (NS_FAILED(rv)) {
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("Exception: nativeNextElement: next from enumerator is not an nsIRDFNode.\n"));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
result = (jint)nodeResult.get();
|
||||
((nsISupports *)result)->AddRef();
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("RDFEnumeration_nativeNextElement: exiting\n"));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_RDFEnumeration_nativeFinalize
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
Java_org_mozilla_webclient_impl_wrapper_1native_RDFEnumeration_nativeFinalize
|
||||
(JNIEnv *env, jobject obj, jint nativeContext)
|
||||
{
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
void * voidResult = nsnull;
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("RDFEnumeration_nativeFinalize: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeFinalize");
|
||||
}
|
||||
|
||||
if (!initContext->initComplete) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: can't finalize");
|
||||
PR_ASSERT(wcContext);
|
||||
jint nativeEnum, nativeContainer;
|
||||
|
||||
// release the nsISimpleEnumerator
|
||||
if (-1 == (nativeEnum =
|
||||
::util_GetIntValueFromInstance(env, obj, "nativeEnum"))) {
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("nativeFinalize: Can't get fieldID for nativeEnum.\n"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
wsRDFFinalizeEvent *actionEvent =
|
||||
new wsRDFFinalizeEvent((void *) obj);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
nsCOMPtr<nsISimpleEnumerator> enumerator =
|
||||
(nsISimpleEnumerator *) nativeEnum;
|
||||
((nsISupports *)enumerator.get())->Release();
|
||||
|
||||
voidResult = ::util_PostSynchronousEvent(initContext, event);
|
||||
if (NS_FAILED((nsresult) voidResult)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: Can't Finalize");
|
||||
}
|
||||
// release the nsIRDFContainer
|
||||
if (-1 == (nativeContainer =
|
||||
::util_GetIntValueFromInstance(env, obj, "nativeContainer"))) {
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("nativeFinalize: Can't get fieldID for nativeContainerFieldID.\n"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
nsCOMPtr<nsIRDFContainer> container = (nsIRDFContainer *) nativeContainer;
|
||||
((nsISupports *)container.get())->Release();
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("RDFEnumeration_nativeFinalize: exiting\n"));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
jint getNativeEnumFromJava(JNIEnv *env, jobject obj, jint nativeRDFNode)
|
||||
{
|
||||
nsresult rv;
|
||||
jint result = -1;
|
||||
|
||||
result = ::util_GetIntValueFromInstance(env, obj, "nativeEnum");
|
||||
|
||||
// if the field has been initialized, just return the value
|
||||
if (-1 != result) {
|
||||
// NORMAL EXIT 1
|
||||
return result;
|
||||
}
|
||||
|
||||
// else, we need to create the enum
|
||||
nsCOMPtr<nsIRDFNode> node = (nsIRDFNode *) nativeRDFNode;
|
||||
nsCOMPtr<nsIRDFResource> nodeResource;
|
||||
nsCOMPtr<nsIRDFContainer> container;
|
||||
nsCOMPtr<nsISimpleEnumerator> enumerator;
|
||||
|
||||
rv = node->QueryInterface(NS_GET_IID(nsIRDFResource),
|
||||
getter_AddRefs(nodeResource));
|
||||
if (NS_FAILED(rv)) {
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("getNativeEnumFromJava: Argument nativeRDFNode isn't an nsIRDFResource.\n"));
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// get a container in order to get the enum
|
||||
container = do_CreateInstance(kRDFContainerCID);
|
||||
if (!container) {
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("getNativeEnumFromJava: can't get a new container\n"));
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (prLogModuleInfo) {
|
||||
const char *value = nsnull;
|
||||
nodeResource->GetValueConst(&value);
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("getNativeEnumFromJava: current node: %s\n", value));
|
||||
}
|
||||
|
||||
|
||||
rv = container->Init(gBookmarksDataSource, nodeResource);
|
||||
if (NS_FAILED(rv)) {
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("getNativeEnumFromJava: Can't Init container.\n"));
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
rv = container->GetElements(getter_AddRefs(enumerator));
|
||||
if (NS_FAILED(rv)) {
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("getNativeEnumFromJava: Can't get enumeration from container.\n"));
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// IMPORTANT: Store the enum back into java
|
||||
::util_SetIntValueForInstance(env,obj,"nativeEnum",(jint)enumerator.get());
|
||||
// IMPORTANT: make sure it doesn't get deleted when it goes out of scope
|
||||
((nsISupports *)enumerator.get())->AddRef();
|
||||
|
||||
// PENDING(edburns): I'm not sure if we need to keep the
|
||||
// nsIRDFContainer from being destructed in order to maintain the
|
||||
// validity of the nsISimpleEnumerator that came from the container.
|
||||
// Just to be safe, I'm doing so.
|
||||
::util_SetIntValueForInstance(env, obj, "nativeContainer",
|
||||
(jint) container.get());
|
||||
((nsISupports *)container.get())->AddRef();
|
||||
|
||||
// NORMAL EXIT 2
|
||||
result = (jint)enumerator.get();
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -20,20 +20,23 @@
|
|||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
#include "RDFTreeNode.h"
|
||||
|
||||
#include "RDFActionEvents.h"
|
||||
#include "org_mozilla_webclient_impl_wrapper_0005fnative_RDFTreeNode.h"
|
||||
|
||||
#include "rdf_util.h"
|
||||
#include "rdf_progids.h"
|
||||
#include "ns_util.h"
|
||||
#include "wsRDFObserver.h"
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsString.h" // for nsCAutoString
|
||||
#include <nsIServiceManager.h>
|
||||
#include <nsString.h> // for nsCAutoString
|
||||
|
||||
#include "prlog.h" // for PR_ASSERT
|
||||
#include <prlog.h> // for PR_ASSERT
|
||||
#include <nsRDFCID.h> // for NS_RDFCONTAINER_CID
|
||||
|
||||
|
||||
static NS_DEFINE_CID(kRDFContainerCID, NS_RDFCONTAINER_CID);
|
||||
static NS_DEFINE_CID(kSupportsArrayCID, NS_SUPPORTSARRAY_CID);
|
||||
|
||||
//
|
||||
// Local function prototypes
|
||||
//
|
||||
|
@ -42,26 +45,18 @@
|
|||
// JNI methods
|
||||
//
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeIsLeaf
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint nativeRDFNode)
|
||||
JNIEXPORT jboolean JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_RDFTreeNode_nativeIsLeaf
|
||||
(JNIEnv *env, jobject obj, jint nativeContext, jint nativeRDFNode)
|
||||
{
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
void * voidResult = nsnull;
|
||||
jint childCount = -1;
|
||||
jboolean result = JNI_FALSE;
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeGetChildCount");
|
||||
return result;
|
||||
}
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("RDFTreeNode_nativeIsLeaf: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
|
||||
if (!initContext->initComplete) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: can't getChildAt");
|
||||
return result;
|
||||
}
|
||||
PR_ASSERT(wcContext);
|
||||
jboolean result = JNI_FALSE;
|
||||
|
||||
PRInt32 count;
|
||||
nsresult rv;
|
||||
// PENDING(edburns): assert rdf_InitRDFUtils()
|
||||
nsCOMPtr<nsIRDFResource> parent = (nsIRDFResource *) nativeRDFNode;
|
||||
|
||||
rv = rdf_getChildCount(parent, &count);
|
||||
|
@ -71,88 +66,85 @@ JNIEXPORT jboolean JNICALL Java_org_mozilla_webclient_wrapper_1native_RDFTreeNod
|
|||
}
|
||||
result = (count == 0) ? JNI_TRUE : JNI_FALSE;
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("RDFTreeNode_nativeIsLeaf: exiting\n"));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeIsContainer
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint nativeRDFNode)
|
||||
JNIEXPORT jboolean JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_RDFTreeNode_nativeIsContainer
|
||||
(JNIEnv *env, jobject obj, jint nativeContext, jint nativeRDFNode)
|
||||
{
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
void * voidResult = nsnull;
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("RDFTreeNode_nativeIsContainer: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
|
||||
PR_ASSERT(wcContext);
|
||||
nsCOMPtr<nsIRDFNode> node = (nsIRDFNode *) nativeRDFNode;
|
||||
nsCOMPtr<nsIRDFResource> nodeResource;
|
||||
nsresult rv;
|
||||
jboolean result = JNI_FALSE;
|
||||
PRBool prBool;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeIsContainer");
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!initContext->initComplete) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: can't see if isContainer");
|
||||
return result;
|
||||
rv = node->QueryInterface(NS_GET_IID(nsIRDFResource),
|
||||
getter_AddRefs(nodeResource));
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeIsContainer: nativeRDFNode is not an RDFResource.");
|
||||
return nsnull;
|
||||
}
|
||||
wsRDFIsContainerEvent *actionEvent = new wsRDFIsContainerEvent(initContext,
|
||||
(PRUint32) nativeRDFNode);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
voidResult = ::util_PostSynchronousEvent(initContext, event);
|
||||
result = (0 != voidResult) ? JNI_TRUE : JNI_FALSE;
|
||||
rv = gRDFCU->IsContainer(gBookmarksDataSource, nodeResource,
|
||||
&prBool);
|
||||
result = (prBool == PR_FALSE) ? JNI_FALSE : JNI_TRUE;
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("RDFTreeNode_nativeIsContainer: exiting\n"));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeGetChildAt
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint nativeRDFNode,
|
||||
Java_org_mozilla_webclient_impl_wrapper_1native_RDFTreeNode_nativeGetChildAt
|
||||
(JNIEnv *env, jobject obj, jint nativeContext, jint nativeRDFNode,
|
||||
jint childIndex)
|
||||
{
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
void * voidResult = nsnull;
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("RDFTreeNode_nativeGetChildAt: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
|
||||
PR_ASSERT(wcContext);
|
||||
|
||||
jint result = -1;
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIRDFResource> parent = (nsIRDFResource *) nativeRDFNode;
|
||||
nsCOMPtr<nsIRDFResource> child;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeGetChildAt");
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!initContext->initComplete) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: can't getChildAt");
|
||||
return result;
|
||||
rv = rdf_getChildAt(childIndex, parent, getter_AddRefs(child));
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeGetChildAt: Can't get child.");
|
||||
return nsnull;
|
||||
}
|
||||
wsRDFGetChildAtEvent *actionEvent =
|
||||
new wsRDFGetChildAtEvent(initContext,
|
||||
(PRUint32) nativeRDFNode,
|
||||
(PRUint32) childIndex);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
voidResult = ::util_PostSynchronousEvent(initContext, event);
|
||||
result = (jint) voidResult;
|
||||
result = (jint)child.get();
|
||||
((nsISupports *)result)->AddRef();
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("RDFTreeNode_nativeGetChildAt: exiting\n"));
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeGetChildCount
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint nativeRDFNode)
|
||||
Java_org_mozilla_webclient_impl_wrapper_1native_RDFTreeNode_nativeGetChildCount
|
||||
(JNIEnv *env, jobject obj, jint nativeContext, jint nativeRDFNode)
|
||||
{
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
void * voidResult = nsnull;
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("RDFTreeNode_nativeGetChildCount: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
|
||||
PR_ASSERT(wcContext);
|
||||
jint result = -1;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeGetChildCount");
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!initContext->initComplete) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: can't getChildAt");
|
||||
return result;
|
||||
}
|
||||
PRInt32 count;
|
||||
nsresult rv;
|
||||
// PENDING(edburns): assert rdf_InitRDFUtils()
|
||||
nsCOMPtr<nsIRDFResource> parent = (nsIRDFResource *) nativeRDFNode;
|
||||
|
||||
rv = rdf_getChildCount(parent, &count);
|
||||
|
@ -162,62 +154,53 @@ Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeGetChildCount
|
|||
}
|
||||
result = (jint) count;
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("RDFTreeNode_nativeGetChildCount: exiting\n"));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeGetIndex
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint nativeRDFNode,
|
||||
Java_org_mozilla_webclient_impl_wrapper_1native_RDFTreeNode_nativeGetIndex
|
||||
(JNIEnv *env, jobject obj, jint nativeContext, jint nativeRDFNode,
|
||||
jint childRDFNode)
|
||||
{
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
void * voidResult = nsnull;
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("RDFTreeNode_nativeGetIndex: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
|
||||
PR_ASSERT(wcContext);
|
||||
jint result = -1;
|
||||
PRInt32 index;
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIRDFResource> parent = (nsIRDFResource *) nativeRDFNode;
|
||||
nsCOMPtr<nsIRDFResource> child = (nsIRDFResource *) childRDFNode;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeGetChildIndex");
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!initContext->initComplete) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: can't getChildIndex");
|
||||
return result;
|
||||
}
|
||||
wsRDFGetChildIndexEvent *actionEvent =
|
||||
new wsRDFGetChildIndexEvent(initContext,
|
||||
(PRUint32) nativeRDFNode,
|
||||
(PRUint32) childRDFNode);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
voidResult = ::util_PostSynchronousEvent(initContext, event);
|
||||
result = (jint) voidResult;
|
||||
rv = rdf_getIndexOfChild(parent, child, &index);
|
||||
result = (jint) index;
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("RDFTreeNode_nativeGetIndex: exiting\n"));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeToString
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint nativeRDFNode)
|
||||
Java_org_mozilla_webclient_impl_wrapper_1native_RDFTreeNode_nativeToString
|
||||
(JNIEnv *env, jobject obj, jint nativeContext, jint nativeRDFNode)
|
||||
{
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
void * voidResult = nsnull;
|
||||
jstring result = nsnull;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeToString");
|
||||
return result;
|
||||
}
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("RDFTreeNode_nativeToString: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
|
||||
PR_ASSERT(wcContext);
|
||||
|
||||
if (!initContext->initComplete) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: can't toString");
|
||||
return result;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIRDFResource> currentResource =
|
||||
(nsIRDFResource *) nativeRDFNode;
|
||||
nsCOMPtr<nsIRDFNode> node;
|
||||
nsCOMPtr<nsIRDFLiteral> literal;
|
||||
PRBool isContainer = PR_FALSE;
|
||||
jstring result = nsnull;
|
||||
nsresult rv;
|
||||
const PRUnichar *textForNode = nsnull;
|
||||
|
||||
|
@ -302,77 +285,296 @@ Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeToString
|
|||
result = ::util_NewStringUTF(env, "");
|
||||
}
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("RDFTreeNode_nativeToString: exiting\n"));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeInsertElementAt
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint parentRDFNode,
|
||||
Java_org_mozilla_webclient_impl_wrapper_1native_RDFTreeNode_nativeInsertElementAt
|
||||
(JNIEnv *env, jobject obj, jint nativeContext, jint parentRDFNode,
|
||||
jint childRDFNode, jobject childProps, jint childIndex)
|
||||
{
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
void * voidResult = nsnull;
|
||||
jobject propsGlobalRef;
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("RDFTreeNode_nativeInsertElementAt: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeInsertElementAt");
|
||||
}
|
||||
PR_ASSERT(wcContext);
|
||||
PR_ASSERT(childProps); // PENDING(edburns): do we need to NewGlobalRef this?
|
||||
|
||||
nsCOMPtr<nsIRDFResource> parent = (nsIRDFResource *) parentRDFNode;
|
||||
nsCOMPtr<nsIRDFResource> newChild = (nsIRDFResource *) childRDFNode;
|
||||
nsCOMPtr<nsIRDFContainer> container;
|
||||
nsCOMPtr<nsIRDFLiteral> nameLiteral;
|
||||
nsCOMPtr<nsIRDFLiteral> urlLiteral;
|
||||
|
||||
jstring name;
|
||||
const jchar *nameJchar;
|
||||
|
||||
if (!initContext->initComplete) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: can't InsertElementAt");
|
||||
jstring url;
|
||||
const jchar *urlJchar;
|
||||
|
||||
nsresult rv;
|
||||
PRBool isContainer;
|
||||
|
||||
rv = gRDFCU->IsContainer(gBookmarksDataSource, parent,
|
||||
&isContainer);
|
||||
|
||||
// PENDING(edburns): I don't think we can throw exceptions from
|
||||
// here, no?
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeInsertElementAt: RDFResource is not a container.");
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
goto omwiwnrtnniea_CLEANUP;
|
||||
}
|
||||
|
||||
// get a container in order to create a child
|
||||
container = do_CreateInstance(kRDFContainerCID);
|
||||
|
||||
if (!container) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeInsertElementAt: can't create container.");
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
goto omwiwnrtnniea_CLEANUP;
|
||||
}
|
||||
rv = container->Init(gBookmarksDataSource, parent);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeInsertElementAt: can't create container.");
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
goto omwiwnrtnniea_CLEANUP;
|
||||
}
|
||||
|
||||
// pull the info from the properties object and add it to the new
|
||||
// node.
|
||||
if (nsnull == (name = (jstring) ::util_GetFromPropertiesObject(env,
|
||||
childProps,
|
||||
BM_NAME_VALUE,
|
||||
(jobject) &(wcContext->shareContext)))) {
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
goto omwiwnrtnniea_CLEANUP;
|
||||
}
|
||||
propsGlobalRef = ::util_NewGlobalRef(env, childProps);
|
||||
wsRDFInsertElementAtEvent *actionEvent =
|
||||
new wsRDFInsertElementAtEvent(initContext,
|
||||
(PRUint32) parentRDFNode,
|
||||
(PRUint32) childRDFNode,
|
||||
(void *) propsGlobalRef,
|
||||
(PRUint32) childIndex);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
voidResult = ::util_PostSynchronousEvent(initContext, event);
|
||||
::util_DeleteGlobalRef(env, propsGlobalRef);
|
||||
if (NS_FAILED((nsresult) voidResult)) {
|
||||
if (nsnull == (nameJchar = ::util_GetStringChars(env, name))) {
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
goto omwiwnrtnniea_CLEANUP;
|
||||
}
|
||||
|
||||
if (nsnull == (url = (jstring) ::util_GetFromPropertiesObject(env, childProps,
|
||||
BM_URL_VALUE,
|
||||
(jobject) &(wcContext->shareContext)))) {
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
goto omwiwnrtnniea_CLEANUP;
|
||||
}
|
||||
|
||||
if (nsnull == (urlJchar = ::util_GetStringChars(env, url))) {
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
goto omwiwnrtnniea_CLEANUP;
|
||||
}
|
||||
// if we get here, we have valid nameJchar and urlJchar strings.
|
||||
|
||||
// create literals for the name and url
|
||||
rv = gRDF->GetLiteral((const PRUnichar *) nameJchar,
|
||||
getter_AddRefs(nameLiteral));
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeInsertElementAt: can't arguments nsISupportsArray.");
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
goto omwiwnrtnniea_CLEANUP;
|
||||
}
|
||||
|
||||
rv = gRDF->GetLiteral((const PRUnichar *) urlJchar,
|
||||
getter_AddRefs(urlLiteral));
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeInsertElementAt: can't create arguments nsISupportsArray.");
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
goto omwiwnrtnniea_CLEANUP;
|
||||
}
|
||||
|
||||
// now Assert them to add the to the newChild
|
||||
rv = gBookmarksDataSource->Assert(newChild, kNC_Name, nameLiteral,
|
||||
PR_TRUE);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeInsertElementAt: can't add name literal to new node.");
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
goto omwiwnrtnniea_CLEANUP;
|
||||
}
|
||||
|
||||
// + 1 because for some reason the 1 is the first, not 0.
|
||||
rv = container->InsertElementAt(newChild, childIndex + 1, PR_TRUE);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeInsertElementAt: can't insert element into parent container.");
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
goto omwiwnrtnniea_CLEANUP;
|
||||
}
|
||||
|
||||
omwiwnrtnniea_CLEANUP:
|
||||
::util_ReleaseStringChars(env, name, nameJchar);
|
||||
::util_ReleaseStringChars(env, url, urlJchar);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: Can't InsertElementAt");
|
||||
}
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("RDFTreeNode_nativeInsertElementAt: exiting\n"));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeNewFolder
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint parentRDFNode,
|
||||
Java_org_mozilla_webclient_impl_wrapper_1native_RDFTreeNode_nativeNewFolder
|
||||
(JNIEnv *env, jobject obj, jint nativeContext, jint parentRDFNode,
|
||||
jobject childProps)
|
||||
{
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
void * voidResult = nsnull;
|
||||
jobject propsGlobalRef;
|
||||
jint retVal = 0;
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("RDFTreeNode_nativeNewFolder: entering\n"));
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeNewFolder");
|
||||
}
|
||||
PR_ASSERT(wcContext);
|
||||
|
||||
jint result = -1;
|
||||
nsCOMPtr<nsIRDFResource> parent = (nsIRDFResource *) parentRDFNode;
|
||||
nsCOMPtr<nsIRDFResource> newChildFromObserver;
|
||||
nsCOMPtr<nsISupportsArray> selectionArray;
|
||||
nsCOMPtr<nsISupportsArray> argumentsArray;
|
||||
nsCOMPtr<nsIRDFLiteral> nameLiteral;
|
||||
nsCOMPtr<nsIRDFLiteral> urlLiteral;
|
||||
nsresult rv = NS_ERROR_UNEXPECTED;
|
||||
PRBool isContainer;
|
||||
nsCOMPtr<nsIRDFObserver> observer = new wsRDFObserver();
|
||||
wsRDFObserver *wsO = nsnull;
|
||||
|
||||
if (!initContext->initComplete || !childProps) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: can't NewFolder");
|
||||
}
|
||||
propsGlobalRef = ::util_NewGlobalRef(env, childProps);
|
||||
if (!propsGlobalRef) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: can't NewFolder");
|
||||
jstring name;
|
||||
const jchar *nameJchar;
|
||||
|
||||
jstring url;
|
||||
const jchar *urlJchar;
|
||||
|
||||
rv = gRDFCU->IsContainer(gBookmarksDataSource, parent, &isContainer);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeNewFolder: RDFResource is not a container.");
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
goto RNFEHE_CLEANUP;
|
||||
}
|
||||
|
||||
wsRDFNewFolderEvent *actionEvent =
|
||||
new wsRDFNewFolderEvent(initContext,
|
||||
(PRUint32) parentRDFNode,
|
||||
(void *) propsGlobalRef,
|
||||
(PRUint32 *) &retVal);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
// pull out the necessary keys from the properties table
|
||||
if (nsnull == (name = (jstring) ::util_GetFromPropertiesObject(env,
|
||||
childProps,
|
||||
BM_NAME_VALUE,
|
||||
(jobject) &(wcContext->shareContext)))) {
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
goto RNFEHE_CLEANUP;
|
||||
}
|
||||
|
||||
voidResult = ::util_PostSynchronousEvent(initContext, event);
|
||||
::util_DeleteGlobalRef(env, propsGlobalRef);
|
||||
if (NS_FAILED((nsresult) voidResult)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: Can't do NewFolder");
|
||||
}
|
||||
return retVal;
|
||||
if (nsnull == (nameJchar = ::util_GetStringChars(env, name))) {
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
goto RNFEHE_CLEANUP;
|
||||
}
|
||||
|
||||
if (nsnull == (url = (jstring) ::util_GetFromPropertiesObject(env, childProps,
|
||||
BM_URL_VALUE,
|
||||
(jobject) &(wcContext->shareContext)))) {
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
goto RNFEHE_CLEANUP;
|
||||
}
|
||||
|
||||
if (nsnull == (urlJchar = ::util_GetStringChars(env, url))) {
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
goto RNFEHE_CLEANUP;
|
||||
}
|
||||
// if we get here, we have valid nameJchar and urlJchar strings.
|
||||
|
||||
// use the magic "command interface" as in bookmarks.js
|
||||
// http://lxr.mozilla.org/mozilla/source/xpfe/components/bookmarks/resources/bookmarks.js#1190
|
||||
|
||||
// set up selection nsISupportsArray
|
||||
selectionArray = do_CreateInstance(kSupportsArrayCID);
|
||||
if (!selectionArray) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeNewFolder: can't create selection nsISupportsArray.");
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
goto RNFEHE_CLEANUP;
|
||||
}
|
||||
|
||||
// set up arguments nsISupportsArray
|
||||
argumentsArray = do_CreateInstance(kSupportsArrayCID);
|
||||
if (argumentsArray) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeNewFolder: can't create arguments nsISupportsArray.");
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
goto RNFEHE_CLEANUP;
|
||||
}
|
||||
// get various arguments (parent, name)
|
||||
// kNC_parent
|
||||
// kNC_Name
|
||||
// kNC_URL
|
||||
|
||||
// add parent into selection array
|
||||
selectionArray->AppendElement(parent);
|
||||
|
||||
// add multiple arguments into arguments array
|
||||
argumentsArray->AppendElement(kNC_parent);
|
||||
argumentsArray->AppendElement(parent);
|
||||
|
||||
rv = gRDF->GetLiteral((const PRUnichar *) nameJchar,
|
||||
getter_AddRefs(nameLiteral));
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeNewFolder: can't arguments nsISupportsArray.");
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
goto RNFEHE_CLEANUP;
|
||||
}
|
||||
argumentsArray->AppendElement(kNC_Name);
|
||||
argumentsArray->AppendElement(nameLiteral);
|
||||
|
||||
rv = gRDF->GetLiteral((const PRUnichar *) urlJchar,
|
||||
getter_AddRefs(urlLiteral));
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeNewFolder: can't create arguments nsISupportsArray.");
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
goto RNFEHE_CLEANUP;
|
||||
}
|
||||
argumentsArray->AppendElement(kNC_URL);
|
||||
argumentsArray->AppendElement(urlLiteral);
|
||||
|
||||
// at this point, selectionArray contains the parent
|
||||
// and argumentsArray contains arcs and literals for the name and the
|
||||
// url of the node to be inserted.
|
||||
|
||||
if (observer) {
|
||||
gBookmarksDataSource->AddObserver(observer);
|
||||
}
|
||||
|
||||
// find out if it's a folder
|
||||
if (nsnull != ::util_GetFromPropertiesObject(env, childProps,
|
||||
BM_IS_FOLDER_VALUE, (jobject)
|
||||
(jobject) &(wcContext->shareContext))){
|
||||
// do the command
|
||||
rv = gBookmarksDataSource->DoCommand(selectionArray,
|
||||
kNewFolderCommand,
|
||||
argumentsArray);
|
||||
}
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeInsertElementAt: can't execute bookmarks command to add folder.");
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
goto RNFEHE_CLEANUP;
|
||||
}
|
||||
|
||||
if (observer) {
|
||||
gBookmarksDataSource->RemoveObserver(observer);
|
||||
wsO = (wsRDFObserver *) observer.get();
|
||||
newChildFromObserver = wsO->getFolder();
|
||||
if (newChildFromObserver) {
|
||||
result = (jint) newChildFromObserver.get();
|
||||
((nsISupports *)result)->AddRef();
|
||||
}
|
||||
}
|
||||
|
||||
RNFEHE_CLEANUP:
|
||||
::util_ReleaseStringChars(env, name, nameJchar);
|
||||
::util_ReleaseStringChars(env, url, urlJchar);
|
||||
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("RDFTreeNode_nativeNewFolder: exiting\n"));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -147,7 +147,8 @@ wsDeallocateInitContextEvent::handleEvent ()
|
|||
|
||||
mInitContext->currentDocument = nsnull;
|
||||
mInitContext->browserContainer = nsnull;
|
||||
util_DeallocateShareInitContext(&(mInitContext->shareContext));
|
||||
util_DeallocateShareInitContext((JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION),
|
||||
&(mInitContext->shareContext));
|
||||
|
||||
// delete mInitContext;
|
||||
if (isLastWindow) {
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
* Ann Sunhachawee
|
||||
*/
|
||||
|
||||
#include "WindowControlImpl.h"
|
||||
#include "org_mozilla_webclient_impl_wrapper_0005fnative_WindowControlImpl.h"
|
||||
|
||||
#include "WindowControlActionEvents.h"
|
||||
|
||||
|
@ -37,11 +37,8 @@
|
|||
#include "nsCOMPtr.h" // to get nsIBaseWindow from webshell
|
||||
#include "nsIBaseWindow.h" // to get methods like SetVisibility
|
||||
|
||||
|
||||
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_WindowControlImpl_nativeSetBounds
|
||||
Java_org_mozilla_webclient_impl_wrapper_1native_WindowControlImpl_nativeSetBounds
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint x, jint y, jint w, jint h)
|
||||
{
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
@ -60,7 +57,7 @@ Java_org_mozilla_webclient_wrapper_1native_WindowControlImpl_nativeSetBounds
|
|||
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_WindowControlImpl_nativeCreateInitContext
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_WindowControlImpl_nativeCreateInitContext
|
||||
(JNIEnv *env, jobject obj, jint windowPtr, jint x, jint y,
|
||||
jint width, jint height, jobject aBrowserControlImpl)
|
||||
{
|
||||
|
@ -100,15 +97,9 @@ JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_WindowControlI
|
|||
initContext->h = height;
|
||||
initContext->currentDocument = nsnull;
|
||||
initContext->browserContainer = nsnull;
|
||||
util_InitializeShareInitContext(&(initContext->shareContext));
|
||||
util_InitializeShareInitContext(env, &(initContext->shareContext));
|
||||
|
||||
#ifdef XP_UNIX
|
||||
/***** Uncomment this to debug on unix
|
||||
pid_t pid = getpid();
|
||||
printf("++++++++++++++++debug: edburns: pid is: %d\n", pid);
|
||||
sleep(7);
|
||||
**************/
|
||||
|
||||
initContext->gtkWinPtr =
|
||||
(int)::util_GetGTKWinPtrFromCanvas(env, aBrowserControlImpl);
|
||||
#else
|
||||
|
@ -119,7 +110,7 @@ JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_WindowControlI
|
|||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_WindowControlImpl_nativeDestroyInitContext
|
||||
Java_org_mozilla_webclient_impl_wrapper_1native_WindowControlImpl_nativeDestroyInitContext
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
@ -143,7 +134,7 @@ Java_org_mozilla_webclient_wrapper_1native_WindowControlImpl_nativeDestroyInitCo
|
|||
}
|
||||
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_WindowControlImpl_nativeMoveWindowTo
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_WindowControlImpl_nativeMoveWindowTo
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint x, jint y)
|
||||
{
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
@ -161,7 +152,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_WindowControlI
|
|||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_WindowControlImpl_nativeRemoveFocus
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_WindowControlImpl_nativeRemoveFocus
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
@ -179,7 +170,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_WindowControlI
|
|||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_WindowControlImpl_nativeRepaint
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_WindowControlImpl_nativeRepaint
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jboolean forceRepaint)
|
||||
{
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
@ -198,7 +189,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_WindowControlI
|
|||
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_WindowControlImpl_nativeSetVisible
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_WindowControlImpl_nativeSetVisible
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jboolean newState)
|
||||
{
|
||||
|
||||
|
@ -215,7 +206,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_WindowControlI
|
|||
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_WindowControlImpl_nativeSetFocus
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_WindowControlImpl_nativeSetFocus
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
|
|
@ -26,13 +26,30 @@
|
|||
* Ann Sunhachawee
|
||||
*/
|
||||
|
||||
#include "WrapperFactoryImpl.h"
|
||||
#include "org_mozilla_webclient_impl_wrapper_0005fnative_WrapperFactoryImpl.h"
|
||||
|
||||
#include "ns_util.h"
|
||||
#include "nsCRT.h" // for nsCRT::strcmp
|
||||
|
||||
#include <nsWidgetsCID.h> // for NS_APPSHELL_CID
|
||||
#include <nsIComponentManager.h> // for do_CreateInstance
|
||||
#include <nsILocalFile.h>
|
||||
#include <nsEmbedAPI.h> // for NS_InitEmbedding
|
||||
#include <nsIComponentRegistrar.h>
|
||||
|
||||
const char * gBinDir;
|
||||
#include <prenv.h> // for PR_SetEnv
|
||||
|
||||
#include <nsIAppShell.h>
|
||||
|
||||
#ifdef XP_UNIX
|
||||
#include <unistd.h> // for getpid
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
|
||||
|
||||
//
|
||||
// global data
|
||||
//
|
||||
|
||||
PRLogModuleInfo *prLogModuleInfo = NULL; // declared in ns_globals.h
|
||||
|
||||
|
@ -44,41 +61,210 @@ const char *gImplementedInterfaces[] = {
|
|||
"webclient.EventRegistration",
|
||||
"webclient.Bookmarks",
|
||||
"webclient.Preferences",
|
||||
"webclient.ProfileManager",
|
||||
nsnull
|
||||
};
|
||||
|
||||
//
|
||||
// global data
|
||||
// Local Functions
|
||||
//
|
||||
|
||||
|
||||
//
|
||||
// Functions to hook into mozilla
|
||||
//
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_WrapperFactoryImpl_nativeAppInitialize(
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_mozilla_webclient_impl_wrapper_1native_WrapperFactoryImpl_nativeAppInitialize(
|
||||
JNIEnv *env, jobject obj, jstring verifiedBinDirAbsolutePath)
|
||||
{
|
||||
prLogModuleInfo = PR_NewLogModule("webclient");
|
||||
const char *nativePath = (const char *) ::util_GetStringUTFChars(env,
|
||||
verifiedBinDirAbsolutePath);
|
||||
const char *nativePath = nsnull;
|
||||
WebclientContext *result = new WebclientContext();
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsILocalFile> binDir;
|
||||
|
||||
gBinDir = PL_strdup(nativePath);
|
||||
// PENDING(edburns): We need this for rdf_getChildCount
|
||||
PR_SetEnv("XPCOM_CHECK_THREADSAFE=0");
|
||||
|
||||
//
|
||||
// create an nsILocalFile from our argument
|
||||
//
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("WrapperFactoryImpl_nativeAppInitialize: entering\n"));
|
||||
|
||||
nativePath = (const char *) ::util_GetStringUTFChars(env,
|
||||
verifiedBinDirAbsolutePath);
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("WrapperFactoryImpl_nativeAppInitialize: nativeBinDir: %s\n",
|
||||
nativePath));
|
||||
|
||||
if (nativePath) {
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(nativePath), 1,
|
||||
getter_AddRefs(binDir));
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("WrapperFactoryImpl_nativeAppInitialize: NS_NewNativeLocalFile rv: %d\n",
|
||||
rv));
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env,
|
||||
"Can't get nsILocalFile from bin directory");
|
||||
return (jint) rv;
|
||||
}
|
||||
}
|
||||
::util_ReleaseStringUTFChars(env, verifiedBinDirAbsolutePath, nativePath);
|
||||
|
||||
//
|
||||
// Make the all important NS_InitEmbedding call
|
||||
//
|
||||
|
||||
rv = NS_InitEmbedding(binDir, nsnull);
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("WrapperFactoryImpl_nativeAppInitialize: NS_InitEmbedding rv: %d\n",
|
||||
rv));
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "NS_InitEmbedding() failed.");
|
||||
return (jint) rv;
|
||||
}
|
||||
|
||||
// the rest of the startup tasks are coordinated from the java side.
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("WrapperFactoryImpl_nativeAppInitialize: exiting\n"));
|
||||
|
||||
#ifdef XP_UNIX
|
||||
char propValue[50];
|
||||
::util_getSystemProperty(env, "native.waitForDebugger", propValue, 50);
|
||||
if (nsnull != propValue[0] &&
|
||||
0 < nsCRT::strlen(propValue)) {
|
||||
pid_t pid = getpid();
|
||||
printf("++++++++++++++++debug: pid is: %d\n", pid);
|
||||
fflush(stdout);
|
||||
sleep(7);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Store our pointer to the global vm
|
||||
if (nsnull == gVm) { // declared in ../src_share/jni_util.h
|
||||
::util_GetJavaVM(env, &gVm); // save this vm reference
|
||||
}
|
||||
|
||||
util_InitializeShareInitContext(env, &(result->shareContext));
|
||||
|
||||
return (jint) result;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_WrapperFactoryImpl_nativeTerminate
|
||||
(JNIEnv *env, jobject obj)
|
||||
Java_org_mozilla_webclient_impl_wrapper_1native_WrapperFactoryImpl_nativeAppSetup
|
||||
(JNIEnv *env, jobject obj, jint nativeContext)
|
||||
{
|
||||
gComponentManager = nsnull;
|
||||
nsCRT::free((char *) gBinDir);
|
||||
gBinDir = nsnull;
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("WrapperFactoryImpl_nativeAppSetup: entering\n"));
|
||||
nsresult rv;
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
|
||||
PR_ASSERT(wcContext);
|
||||
|
||||
nsCOMPtr<nsIComponentRegistrar> cr;
|
||||
rv = NS_GetComponentRegistrar(getter_AddRefs(cr));
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env,
|
||||
"Failed to create Component Registrar");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/************* PENDING(edburns): fix this when someone replies to my
|
||||
* 20030915 post to n.p.m.embedding
|
||||
|
||||
// appshell
|
||||
// XXX startup appshell service?
|
||||
// XXX create offscreen window for appshell service?
|
||||
// XXX remove X prop from offscreen window?
|
||||
|
||||
nsCOMPtr<nsIAppShell> appShell;
|
||||
appShell = do_CreateInstance(kAppShellCID);
|
||||
if (!appShell) {
|
||||
::util_ThrowExceptionToJava(env,
|
||||
"Failed to create AppShell");
|
||||
return;
|
||||
}
|
||||
wcContext->sAppShell = appShell.get();
|
||||
NS_ADDREF(wcContext->sAppShell);
|
||||
|
||||
rv = wcContext->sAppShell->Create(0, nsnull);
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("WrapperFactoryImpl_nativeAppSetup: AppShell create rv: %d\n",
|
||||
rv));
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env,
|
||||
"Failed to create AppShell");
|
||||
return;
|
||||
}
|
||||
rv = wcContext->sAppShell->Spinup();
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("WrapperFactoryImpl_nativeAppSetup: AppShell spinup rv: %d\n",
|
||||
rv));
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env,
|
||||
"Failed to Spinup AppShell");
|
||||
return;
|
||||
}
|
||||
****/
|
||||
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("WrapperFactoryImpl_nativeAppSetup: exiting\n"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_impl_wrapper_1native_WrapperFactoryImpl_nativeTerminate
|
||||
(JNIEnv *env, jobject obj, jint nativeContext)
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("WrapperFactoryImpl_nativeTerminate: entering\n"));
|
||||
nsresult rv;
|
||||
WebclientContext *wcContext = (WebclientContext *) nativeContext;
|
||||
|
||||
PR_ASSERT(wcContext);
|
||||
|
||||
/********* PENDING(edburns): fix this when the above appshell logic
|
||||
is fixed
|
||||
|
||||
NS_RELEASE(wcContext->sAppShell);
|
||||
wcContext->sAppShell = nsnull;
|
||||
***/
|
||||
PR_ASSERT(nsnull == wcContext->sProfile);
|
||||
PR_ASSERT(nsnull == wcContext->sProfileInternal);
|
||||
|
||||
util_DeallocateShareInitContext(env, &(wcContext->shareContext));
|
||||
|
||||
delete wcContext;
|
||||
|
||||
// PENDING(edburns): do the rest of the stuff from
|
||||
// mozilla/embedding/browser/gtk/src/EmbedPrivate.cpp::PopStartup(void),
|
||||
// and NativeEventThread.cpp
|
||||
|
||||
// shut down XPCOM/Embedding
|
||||
rv = NS_TermEmbedding();
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("WrapperFactoryImpl_nativeTerminate: NS_TermEmbedding rv: %d\n",
|
||||
rv));
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "NS_TermEmbedding() failed.");
|
||||
return (jint) rv;
|
||||
}
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("WrapperFactoryImpl_nativeTerminate: exiting\n"));
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_WrapperFactoryImpl_nativeDoesImplement
|
||||
Java_org_mozilla_webclient_impl_wrapper_1native_WrapperFactoryImpl_nativeDoesImplement
|
||||
(JNIEnv *env, jobject obj, jstring interfaceName)
|
||||
{
|
||||
const char *iName = (const char *) ::util_GetStringUTFChars(env,
|
||||
|
@ -101,3 +287,4 @@ Java_org_mozilla_webclient_wrapper_1native_WrapperFactoryImpl_nativeDoesImplemen
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include "dom_util.h"
|
||||
|
||||
#include "ns_globals.h" // for prLogModuleInfo and gComponentManager
|
||||
#include "ns_globals.h" // for prLogModuleInfo
|
||||
|
||||
#include "prlog.h" // for PR_ASSERT
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <jni.h>
|
||||
#include <jawt_md.h>
|
||||
#include <jawt.h>
|
||||
#include "GtkBrowserControlCanvas.h"
|
||||
#include "org_mozilla_webclient_impl_wrapper_0005fnative_gtk_GtkBrowserControlCanvas.h"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
|
@ -55,7 +55,7 @@ extern "C" {
|
|||
* Method: createTopLevelWindow
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_gtk_GtkBrowserControlCanvas_createTopLevelWindow
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_gtk_GtkBrowserControlCanvas_createTopLevelWindow
|
||||
(JNIEnv * env, jobject obj) {
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("GtkBrowserControlCanvas_createTopLevelWindow: entering\n"));
|
||||
|
@ -99,7 +99,7 @@ JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_gtk_GtkBrowser
|
|||
* Method: createContainerWindow
|
||||
* Signature: (III)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_gtk_GtkBrowserControlCanvas_createContainerWindow
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_gtk_GtkBrowserControlCanvas_createContainerWindow
|
||||
(JNIEnv * env, jobject obj, jint parent, jint screenWidth, jint screenHeight) {
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
|
@ -136,7 +136,7 @@ int getWinID(GtkWidget * gtkWidgetPtr) {
|
|||
* Method: getGTKWinID
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_gtk_GtkBrowserControlCanvas_getGTKWinID
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_gtk_GtkBrowserControlCanvas_getGTKWinID
|
||||
(JNIEnv * env, jobject obj, jint gtkWinPtr) {
|
||||
GtkWidget * gtkWidgetPtr = (GtkWidget *) gtkWinPtr;
|
||||
|
||||
|
@ -149,7 +149,7 @@ JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_gtk_GtkBrowser
|
|||
* Method: reparentWindow
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_gtk_GtkBrowserControlCanvas_reparentWindow (JNIEnv * env, jobject obj, jint childID, jint parentID) {
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_gtk_GtkBrowserControlCanvas_reparentWindow (JNIEnv * env, jobject obj, jint childID, jint parentID) {
|
||||
XReparentWindow(GDK_DISPLAY(), childID, parentID, 0, 0);
|
||||
}
|
||||
|
||||
|
@ -158,7 +158,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_gtk_GtkBrowser
|
|||
* Method: processEvents
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_gtk_GtkBrowserControlCanvas_processEvents
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_gtk_GtkBrowserControlCanvas_processEvents
|
||||
(JNIEnv * env, jobject obj) {
|
||||
//printf("process events....\n");
|
||||
//processEventLoopIntelligently();
|
||||
|
@ -169,7 +169,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_gtk_GtkBrowser
|
|||
* Method: setGTKWindowSize
|
||||
* Signature: (III)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_gtk_GtkBrowserControlCanvas_setGTKWindowSize
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_gtk_GtkBrowserControlCanvas_setGTKWindowSize
|
||||
(JNIEnv * env, jobject obj, jint gtkWinPtr, jint width, jint height) {
|
||||
if (gtkWinPtr != 0) {
|
||||
GtkWidget * gtkWidgetPtr = (GtkWidget *) gtkWinPtr;
|
||||
|
@ -186,7 +186,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_gtk_GtkBrowser
|
|||
* Method: getHandleToPeer
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_gtk_GtkBrowserControlCanvas_getHandleToPeer
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_gtk_GtkBrowserControlCanvas_getHandleToPeer
|
||||
(JNIEnv *env, jobject canvas) {
|
||||
JAWT awt;
|
||||
JAWT_DrawingSurface* ds;
|
||||
|
@ -278,7 +278,7 @@ JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_gtk_GtkBrowser
|
|||
* Method: loadMainDll
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_gtk_GtkBrowserControlCanvas_loadMainDll
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_gtk_GtkBrowserControlCanvas_loadMainDll
|
||||
(JNIEnv *, jclass)
|
||||
{
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_ERROR,
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -23,19 +23,19 @@
|
|||
|
||||
#include <jni.h>
|
||||
|
||||
#include "BookmarksImpl.h"
|
||||
#include "PreferencesImpl.h"
|
||||
#include "CurrentPageImpl.h"
|
||||
#include "HistoryImpl.h"
|
||||
#include "ISupportsPeer.h"
|
||||
#include "NavigationImpl.h"
|
||||
#include "RDFEnumeration.h"
|
||||
#include "RDFTreeNode.h"
|
||||
#include "WindowControlImpl.h"
|
||||
#include "WrapperFactoryImpl.h"
|
||||
#include "NativeEventThread.h"
|
||||
#include "org_mozilla_webclient_impl_wrapper_0005fnative_BookmarksImpl.h"
|
||||
#include "org_mozilla_webclient_impl_wrapper_0005fnative_PreferencesImpl.h"
|
||||
#include "org_mozilla_webclient_impl_wrapper_0005fnative_CurrentPageImpl.h"
|
||||
#include "org_mozilla_webclient_impl_wrapper_0005fnative_HistoryImpl.h"
|
||||
#include "org_mozilla_webclient_impl_wrapper_0005fnative_ISupportsPeer.h"
|
||||
#include "org_mozilla_webclient_impl_wrapper_0005fnative_NavigationImpl.h"
|
||||
#include "org_mozilla_webclient_impl_wrapper_0005fnative_RDFEnumeration.h"
|
||||
#include "org_mozilla_webclient_impl_wrapper_0005fnative_RDFTreeNode.h"
|
||||
#include "org_mozilla_webclient_impl_wrapper_0005fnative_WindowControlImpl.h"
|
||||
#include "org_mozilla_webclient_impl_wrapper_0005fnative_WrapperFactoryImpl.h"
|
||||
#include "org_mozilla_webclient_impl_wrapper_0005fnative_NativeEventThread.h"
|
||||
|
||||
#include "GtkBrowserControlCanvas.h"
|
||||
#include "org_mozilla_webclient_impl_wrapper_0005fnative_gtk_GtkBrowserControlCanvas.h"
|
||||
|
||||
#define WEBCLIENTSTUB_LOG_MODULE "webclientstub"
|
||||
#define WEBCLIENT_DSO "libwebclient.so"
|
||||
|
@ -64,13 +64,13 @@ void (* processEvents) (JNIEnv *, jobject);
|
|||
void (* setGTKWindowSize) (JNIEnv *, jobject, jint, jint, jint);
|
||||
jint (* getHandleToPeer) (JNIEnv *, jobject);
|
||||
|
||||
// from NativeEventThread.h
|
||||
// from org_mozilla_webclient_impl_wrapper_0005fnative_NativeEventThread.h
|
||||
void (* nativeAddListener) (JNIEnv *, jobject, jint, jobject, jstring);
|
||||
void (* nativeRemoveListener) (JNIEnv *, jobject, jint, jobject, jstring);
|
||||
void (* nativeRemoveAllListeners) (JNIEnv *, jobject, jint);
|
||||
void (* nativeInitialize) (JNIEnv *, jobject, jint);
|
||||
void (* nativeProcessEvents) (JNIEnv *, jobject, jint);
|
||||
// from BookmarksImpl.h
|
||||
// from org_mozilla_webclient_impl_wrapper_0005fnative_BookmarksImpl.h
|
||||
jint (* nativeGetBookmarks) (JNIEnv *, jobject, jint);
|
||||
jint (* nativeNewRDFNode) (JNIEnv *, jobject, jint, jstring, jboolean);
|
||||
// from PreferencesImpl.h
|
||||
|
@ -79,7 +79,7 @@ void (* nativeSetIntPref) (JNIEnv *, jobject, jint, jstring, jint);
|
|||
void (* nativeSetBoolPref) (JNIEnv *, jobject, jint, jstring, jboolean);
|
||||
jobject (* nativeGetPrefs) (JNIEnv *env, jobject obj, jint webShellPtr, jobject props);
|
||||
void (* nativeRegisterPrefChangedCallback) (JNIEnv *env, jobject obj, jint webShellPtr, jobject callback, jstring prefName, jobject closure);
|
||||
// from CurrentPageImpl.h
|
||||
// from org_mozilla_webclient_impl_wrapper_0005fnative_CurrentPageImpl.h
|
||||
void (* nativeCopyCurrentSelectionToSystemClipboard) (JNIEnv *, jobject, jint);
|
||||
void (* nativeGetSelection) (JNIEnv *, jobject, jint, jobject);
|
||||
void (* nativeHighlightSelection) (JNIEnv *, jobject, jint, jobject, jobject, jint, jint);
|
||||
|
@ -90,7 +90,7 @@ jstring (* nativeGetCurrentURL) (JNIEnv *, jobject, jint);
|
|||
void (* nativeResetFind) (JNIEnv *, jobject, jint);
|
||||
void (* nativeSelectAll) (JNIEnv *, jobject, jint);
|
||||
jobject (* nativeGetDOM) (JNIEnv *, jobject, jint);
|
||||
// from HistoryImpl.h
|
||||
// from org_mozilla_webclient_impl_wrapper_0005fnative_HistoryImpl.h
|
||||
void (* nativeBack) (JNIEnv *, jobject, jint);
|
||||
jboolean (* nativeCanBack) (JNIEnv *, jobject, jint);
|
||||
jboolean (* nativeCanForward) (JNIEnv *, jobject, jint);
|
||||
|
@ -104,20 +104,20 @@ jobject (* nativeGetHistoryEntry) (JNIEnv *, jobject, jint, jint);
|
|||
jint (* nativeGetHistoryLength) (JNIEnv *, jobject, jint);
|
||||
jstring (* nativeGetURLForIndex) (JNIEnv *, jobject, jint, jint);
|
||||
void (* nativeSetCurrentHistoryIndex) (JNIEnv *, jobject, jint, jint);
|
||||
// from ISupportsPeer.h
|
||||
// from org_mozilla_webclient_impl_wrapper_0005fnative_ISupportsPeer.h
|
||||
void (* nativeAddRef) (JNIEnv *, jobject, jint);
|
||||
void (* nativeRelease) (JNIEnv *, jobject, jint);
|
||||
// from NavigationImpl.h
|
||||
// from org_mozilla_webclient_impl_wrapper_0005fnative_NavigationImpl.h
|
||||
void (* nativeLoadURL) (JNIEnv *, jobject, jint, jstring);
|
||||
void (* nativeLoadFromStream) (JNIEnv *, jobject, jint, jobject, jstring, jstring, jint, jobject);
|
||||
void (* nativeRefresh) (JNIEnv *, jobject, jint, jlong);
|
||||
void (* nativeStop) (JNIEnv *, jobject, jint);
|
||||
void (* nativeSetPrompt) (JNIEnv *, jobject, jint, jobject);
|
||||
// from RDFEnumeration.h
|
||||
// from org_mozilla_webclient_impl_wrapper_0005fnative_RDFEnumeration.h
|
||||
void (* nativeFinalize) (JNIEnv *, jobject, jint);
|
||||
jboolean (* nativeHasMoreElements) (JNIEnv *, jobject, jint, jint);
|
||||
jint (* nativeNextElement) (JNIEnv *, jobject, jint, jint);
|
||||
// from RDFTreeNode.h
|
||||
// from org_mozilla_webclient_impl_wrapper_0005fnative_RDFTreeNode.h
|
||||
jint (* nativeGetChildAt) (JNIEnv *, jobject, jint, jint, jint);
|
||||
jint (* nativeGetChildCount) (JNIEnv *, jobject, jint, jint);
|
||||
jint (* nativeGetIndex) (JNIEnv *, jobject, jint, jint, jint);
|
||||
|
@ -126,7 +126,7 @@ jint (* nativeNewFolder) (JNIEnv *, jobject, jint, jint, jobject);
|
|||
jboolean (* nativeIsContainer) (JNIEnv *, jobject, jint, jint);
|
||||
jboolean (* nativeIsLeaf) (JNIEnv *, jobject, jint, jint);
|
||||
jstring (* nativeToString) (JNIEnv *, jobject, jint, jint);
|
||||
// from WindowControlImpl.h
|
||||
// from org_mozilla_webclient_impl_wrapper_0005fnative_WindowControlImpl.h
|
||||
jint (* nativeCreateInitContext) (JNIEnv *, jobject, jint, jint, jint, jint, jint, jobject);
|
||||
void (* nativeMoveWindowTo) (JNIEnv *, jobject, jint, jint, jint);
|
||||
void (* nativeRemoveFocus) (JNIEnv *, jobject, jint);
|
||||
|
@ -135,8 +135,8 @@ void (* nativeSetBounds) (JNIEnv *, jobject, jint, jint, jint, jint, jint);
|
|||
void (* nativeSetFocus) (JNIEnv *, jobject, jint);
|
||||
void (* nativeSetVisible) (JNIEnv *, jobject, jint, jboolean);
|
||||
void (* nativeDestroyInitContext) (JNIEnv *, jobject, jint);
|
||||
//from WrapperFactoryImpl.h
|
||||
//from org_mozilla_webclient_impl_wrapper_0005fnative_WrapperFactoryImpl.h
|
||||
jboolean (* nativeDoesImplement) (JNIEnv *, jobject, jstring);
|
||||
void (* nativeAppInitialize) (JNIEnv *, jobject, jstring);
|
||||
void (* nativeTerminate) (JNIEnv *, jobject);
|
||||
jint (* nativeAppInitialize) (JNIEnv *, jobject, jstring);
|
||||
void (* nativeTerminate) (JNIEnv *, jobject, jint);
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
// JNI Header
|
||||
#include "../.h"
|
||||
// JNI Header
|
||||
#include "../NativeEventThread.h"
|
||||
#include "../org_mozilla_webclient_impl_wrapper_0005fnative_NativeEventThread.h"
|
||||
|
||||
// allow code in webclientstub.so to load us
|
||||
#include "BrowserControlNativeShimStub.h"
|
||||
|
|
|
@ -53,7 +53,7 @@ extern "C" {
|
|||
* Method: createTopLevelWindow
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_motif_MotifBrowserControlCanvas_createTopLevelWindow
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_motif_MotifBrowserControlCanvas_createTopLevelWindow
|
||||
(JNIEnv * env, jobject obj) {
|
||||
static GtkWidget *mShell = NULL;
|
||||
|
||||
|
@ -87,7 +87,7 @@ JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_motif_MotifBro
|
|||
* Method: createContainerWindow
|
||||
* Signature: (III)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_motif_MotifBrowserControlCanvas_createContainerWindow
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_motif_MotifBrowserControlCanvas_createContainerWindow
|
||||
(JNIEnv * env, jobject obj, jint parent, jint screenWidth, jint screenHeight) {
|
||||
|
||||
GtkWidget * window = (GtkWidget *) parent;
|
||||
|
@ -113,7 +113,7 @@ int getWinID(GtkWidget * gtkWidgetPtr) {
|
|||
* Method: getGTKWinID
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_motif_MotifBrowserControlCanvas_getGTKWinID
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_motif_MotifBrowserControlCanvas_getGTKWinID
|
||||
(JNIEnv * env, jobject obj, jint gtkWinPtr) {
|
||||
GtkWidget * gtkWidgetPtr = (GtkWidget *) gtkWinPtr;
|
||||
|
||||
|
@ -126,7 +126,7 @@ JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_motif_MotifBro
|
|||
* Method: reparentWindow
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_motif_MotifBrowserControlCanvas_reparentWindow (JNIEnv * env, jobject obj, jint childID, jint parentID) {
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_motif_MotifBrowserControlCanvas_reparentWindow (JNIEnv * env, jobject obj, jint childID, jint parentID) {
|
||||
XReparentWindow(GDK_DISPLAY(), childID, parentID, 0, 0);
|
||||
}
|
||||
|
||||
|
@ -135,7 +135,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_motif_MotifBro
|
|||
* Method: processEvents
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_motif_MotifBrowserControlCanvas_processEvents
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_motif_MotifBrowserControlCanvas_processEvents
|
||||
(JNIEnv * env, jobject obj) {
|
||||
//printf("process events....\n");
|
||||
//processEventLoopIntelligently();
|
||||
|
@ -146,7 +146,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_motif_MotifBro
|
|||
* Method: setGTKWindowSize
|
||||
* Signature: (III)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_motif_MotifBrowserControlCanvas_setGTKWindowSize
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_motif_MotifBrowserControlCanvas_setGTKWindowSize
|
||||
(JNIEnv * env, jobject obj, jint gtkWinPtr, jint width, jint height) {
|
||||
if (gtkWinPtr != 0) {
|
||||
GtkWidget * gtkWidgetPtr = (GtkWidget *) gtkWinPtr;
|
||||
|
@ -163,7 +163,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_motif_MotifBro
|
|||
* Method: getHandleToPeer
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_motif_MotifBrowserControlCanvas_getHandleToPeer
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_motif_MotifBrowserControlCanvas_getHandleToPeer
|
||||
(JNIEnv * env, jobject canvas) {
|
||||
JAWT awt;
|
||||
JAWT_DrawingSurface* ds;
|
||||
|
@ -228,7 +228,7 @@ JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_motif_MotifBro
|
|||
* Method: loadMainDll
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_motif_MotifBrowserControlCanvas_loadMainDll
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_motif_MotifBrowserControlCanvas_loadMainDll
|
||||
(JNIEnv *, jclass)
|
||||
{
|
||||
printf("incorrect loadMainDll called\n\n");
|
||||
|
|
|
@ -46,37 +46,37 @@ void (* setGTKWindowSize) (JNIEnv *, jobject, jint, jint, jint);
|
|||
jint (* getHandleToPeer) (JNIEnv *, jobject);
|
||||
|
||||
void locateMotifBrowserControlStubFunctions(void * dll) {
|
||||
createTopLevelWindow = (jint (*) (JNIEnv *, jobject)) dlsym(dll, "Java_org_mozilla_webclient_wrapper_1native_motif_MotifBrowserControlCanvas_createTopLevelWindow");
|
||||
createTopLevelWindow = (jint (*) (JNIEnv *, jobject)) dlsym(dll, "Java_org_mozilla_webclient_impl_wrapper_1native_motif_MotifBrowserControlCanvas_createTopLevelWindow");
|
||||
if (!createTopLevelWindow) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
|
||||
getHandleToPeer = (jint (*) (JNIEnv *, jobject)) dlsym(dll, "Java_org_mozilla_webclient_wrapper_1native_motif_MotifBrowserControlCanvas_getHandleToPeer");
|
||||
getHandleToPeer = (jint (*) (JNIEnv *, jobject)) dlsym(dll, "Java_org_mozilla_webclient_impl_wrapper_1native_motif_MotifBrowserControlCanvas_getHandleToPeer");
|
||||
if (!getHandleToPeer) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
|
||||
createContainerWindow = (jint (*) (JNIEnv *, jobject, jint, jint, jint)) dlsym(dll, "Java_org_mozilla_webclient_wrapper_1native_motif_MotifBrowserControlCanvas_createContainerWindow");
|
||||
createContainerWindow = (jint (*) (JNIEnv *, jobject, jint, jint, jint)) dlsym(dll, "Java_org_mozilla_webclient_impl_wrapper_1native_motif_MotifBrowserControlCanvas_createContainerWindow");
|
||||
if (!createContainerWindow) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
|
||||
reparentWindow = (void (*) (JNIEnv *, jobject, jint, jint)) dlsym(dll, "Java_org_mozilla_webclient_wrapper_1native_motif_MotifBrowserControlCanvas_reparentWindow");
|
||||
reparentWindow = (void (*) (JNIEnv *, jobject, jint, jint)) dlsym(dll, "Java_org_mozilla_webclient_impl_wrapper_1native_motif_MotifBrowserControlCanvas_reparentWindow");
|
||||
if (!reparentWindow) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
|
||||
processEvents = (void (*) (JNIEnv *, jobject)) dlsym(dll, "Java_org_mozilla_webclient_wrapper_1native_motif_MotifBrowserControlCanvas_processEvents");
|
||||
processEvents = (void (*) (JNIEnv *, jobject)) dlsym(dll, "Java_org_mozilla_webclient_impl_wrapper_1native_motif_MotifBrowserControlCanvas_processEvents");
|
||||
if (!processEvents) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
|
||||
setGTKWindowSize = (void (*) (JNIEnv *, jobject, jint, jint, jint)) dlsym(dll, "Java_org_mozilla_webclient_wrapper_1native_motif_MotifBrowserControlCanvas_setGTKWindowSize");
|
||||
setGTKWindowSize = (void (*) (JNIEnv *, jobject, jint, jint, jint)) dlsym(dll, "Java_org_mozilla_webclient_impl_wrapper_1native_motif_MotifBrowserControlCanvas_setGTKWindowSize");
|
||||
if (!setGTKWindowSize) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
|
||||
getGTKWinID = (jint (*) (JNIEnv *, jobject, jint)) dlsym(dll, "Java_org_mozilla_webclient_wrapper_1native_motif_MotifBrowserControlCanvas_getGTKWinID");
|
||||
getGTKWinID = (jint (*) (JNIEnv *, jobject, jint)) dlsym(dll, "Java_org_mozilla_webclient_impl_wrapper_1native_motif_MotifBrowserControlCanvas_getGTKWinID");
|
||||
if (!getGTKWinID) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ void locateMotifBrowserControlStubFunctions(void * dll) {
|
|||
* Method: createTopLevelWindow
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_motif_MotifBrowserControlCanvas_createTopLevelWindow (JNIEnv * env, jobject obj) {
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_motif_MotifBrowserControlCanvas_createTopLevelWindow (JNIEnv * env, jobject obj) {
|
||||
return (* createTopLevelWindow) (env, obj);
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_motif_MotifBro
|
|||
* Method: getHandleToPeer
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_motif_MotifBrowserControlCanvas_getHandleToPeer (JNIEnv * env, jobject obj) {
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_motif_MotifBrowserControlCanvas_getHandleToPeer (JNIEnv * env, jobject obj) {
|
||||
return (* getHandleToPeer) (env, obj);
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,7 @@ JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_motif_MotifBro
|
|||
* Method: createContainerWindow
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_motif_MotifBrowserControlCanvas_createContainerWindow (JNIEnv * env, jobject obj, jint parent, jint width, jint height) {
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_motif_MotifBrowserControlCanvas_createContainerWindow (JNIEnv * env, jobject obj, jint parent, jint width, jint height) {
|
||||
return (* createContainerWindow) (env, obj, parent, width, height);
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_motif_MotifBro
|
|||
* Method: getGTKWinID
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_motif_MotifBrowserControlCanvas_getGTKWinID
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_motif_MotifBrowserControlCanvas_getGTKWinID
|
||||
(JNIEnv * env, jobject obj, jint gtkWinPtr) {
|
||||
return (* getGTKWinID) (env, obj, gtkWinPtr);
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_motif_MotifBro
|
|||
* Method: reparentWindow
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_motif_MotifBrowserControlCanvas_reparentWindow
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_motif_MotifBrowserControlCanvas_reparentWindow
|
||||
(JNIEnv * env, jobject obj, jint childID, jint parentID) {
|
||||
(* reparentWindow) (env, obj, childID, parentID);
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_motif_MotifBro
|
|||
* Method: processEvents
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_motif_MotifBrowserControlCanvas_processEvents
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_motif_MotifBrowserControlCanvas_processEvents
|
||||
(JNIEnv * env, jobject obj) {
|
||||
(* processEvents) (env, obj);
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_motif_MotifBro
|
|||
* Method: setGTKWindowSize
|
||||
* Signature: (III)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_motif_MotifBrowserControlCanvas_setGTKWindowSize
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_motif_MotifBrowserControlCanvas_setGTKWindowSize
|
||||
(JNIEnv * env, jobject obj, jint xwinID, jint width, jint height) {
|
||||
(* setGTKWindowSize) (env, obj, xwinID, width, height);
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_motif_MotifBro
|
|||
* Method: loadMainDll
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_motif_MotifBrowserControlCanvas_loadMainDll
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_motif_MotifBrowserControlCanvas_loadMainDll
|
||||
(JNIEnv *, jclass)
|
||||
{
|
||||
loadMainDll();
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -39,24 +39,6 @@
|
|||
#include "prlog.h"
|
||||
extern PRLogModuleInfo *prLogModuleInfo; // defined in WrapperFactory.cpp
|
||||
|
||||
/**
|
||||
|
||||
* Lifetime:
|
||||
|
||||
* Created using NS_GetGlobalComponentManager in WrapperFactoryImpl.cpp
|
||||
* nativeAppInitialize().
|
||||
|
||||
* Set to nsnull in WrapperFactoryImpl.cpp nativeTerminate().
|
||||
|
||||
* PENDING(edburns): is it preferable to use nsComponentManager:: static
|
||||
* methods?
|
||||
|
||||
*/
|
||||
|
||||
class nsIComponentManager;
|
||||
extern nsIComponentManager *gComponentManager; // defined in NativeEventThread.cpp
|
||||
extern const char * gBinDir; // defined in WrapperFactoryImpl.cpp
|
||||
|
||||
/**
|
||||
|
||||
* Lifetime:
|
||||
|
|
|
@ -106,6 +106,19 @@ struct WebShellInitContext {
|
|||
ShareInitContext shareContext;
|
||||
};
|
||||
|
||||
class nsIProfile;
|
||||
class nsIProfileInternal;
|
||||
class nsIPref;
|
||||
class nsIAppShell;
|
||||
|
||||
typedef struct WebclientContext {
|
||||
nsIProfile *sProfile;
|
||||
nsIProfileInternal *sProfileInternal;
|
||||
nsIPref *sPrefs;
|
||||
nsIAppShell *sAppShell;
|
||||
ShareInitContext shareContext;
|
||||
};
|
||||
|
||||
enum {
|
||||
kEventQueueError = 1,
|
||||
kCreateWebShellError,
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include "rdf_util.h"
|
||||
|
||||
#include "ns_globals.h" // for prLogModuleInfo and gComponentManager
|
||||
#include "ns_globals.h" // for prLogModuleInfo
|
||||
#include "nsString.h"
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
|
@ -52,7 +52,7 @@ static NS_DEFINE_CID(kRDFContainerCID, NS_RDFCONTAINER_CID);
|
|||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID);
|
||||
|
||||
nsresult rdf_InitRDFUtils()
|
||||
nsresult rdf_startup()
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -173,6 +173,43 @@ nsresult rdf_InitRDFUtils()
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsresult rdf_shutdown()
|
||||
{
|
||||
kNewBookmarkCommand = nsnull;
|
||||
|
||||
kNewFolderCommand = nsnull;
|
||||
|
||||
kRDF_type = nsnull;
|
||||
|
||||
kNC_Folder = nsnull;
|
||||
|
||||
kNC_parent = nsnull;
|
||||
|
||||
kNC_URL = nsnull;
|
||||
|
||||
kNC_Name = nsnull;
|
||||
|
||||
kNC_BookmarksRoot = nsnull;
|
||||
|
||||
gRDFCU = nsnull;
|
||||
|
||||
gRDF = nsnull;
|
||||
|
||||
gBookmarksDataSource = nsnull;
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
nsIBookmarksService *raw = (nsIBookmarksService *) gBookmarks.get();
|
||||
raw->Release();
|
||||
#endif
|
||||
|
||||
gBookmarks = nsnull;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void rdf_recursiveResourceTraversal(nsCOMPtr<nsIRDFResource> currentResource)
|
||||
{
|
||||
nsresult rv;
|
||||
|
@ -223,14 +260,9 @@ void rdf_recursiveResourceTraversal(nsCOMPtr<nsIRDFResource> currentResource)
|
|||
}
|
||||
}
|
||||
|
||||
PR_ASSERT(gComponentManager);
|
||||
// get a container in order to recurr
|
||||
rv = nsComponentManager::
|
||||
CreateInstance(kRDFContainerCID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsIRDFContainer),
|
||||
getter_AddRefs(container));
|
||||
if (NS_FAILED(rv)) {
|
||||
container = do_CreateInstance(kRDFContainerCID);
|
||||
if (!container) {
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("recursiveResourceTraversal: can't get a new container\n"));
|
||||
|
@ -471,13 +503,8 @@ nsresult rdf_getChildAt(int index, nsIRDFResource *theParent,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
PR_ASSERT(gComponentManager);
|
||||
|
||||
rv = nsComponentManager::CreateInstance(kRDFContainerCID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsIRDFContainer),
|
||||
getter_AddRefs(container));
|
||||
if (NS_FAILED(rv)) {
|
||||
container = do_CreateInstance(kRDFContainerCID);
|
||||
if (!container) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -540,12 +567,8 @@ nsresult rdf_getChildCount(nsIRDFResource *theParent, PRInt32 *count)
|
|||
if (PR_FALSE == result) {
|
||||
return NS_OK;
|
||||
}
|
||||
PR_ASSERT(gComponentManager);
|
||||
rv = nsComponentManager::CreateInstance(kRDFContainerCID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsIRDFContainer),
|
||||
getter_AddRefs(container));
|
||||
if (NS_FAILED(rv)) {
|
||||
container = do_CreateInstance(kRDFContainerCID);
|
||||
if (!container) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -585,12 +608,8 @@ nsresult rdf_getIndexOfChild(nsIRDFResource *theParent,
|
|||
if (PR_FALSE == result) {
|
||||
return NS_OK;
|
||||
}
|
||||
PR_ASSERT(gComponentManager);
|
||||
rv = nsComponentManager::CreateInstance(kRDFContainerCID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsIRDFContainer),
|
||||
getter_AddRefs(container));
|
||||
if (NS_FAILED(rv)) {
|
||||
container = do_CreateInstance(kRDFContainerCID);
|
||||
if (container) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,8 @@ extern nsCOMPtr<nsIRDFResource> kRDF_type;
|
|||
extern nsCOMPtr<nsIRDFResource> kNewFolderCommand;
|
||||
extern nsCOMPtr<nsIRDFResource> kNewBookmarkCommand;
|
||||
|
||||
nsresult rdf_InitRDFUtils();
|
||||
nsresult rdf_startup();
|
||||
nsresult rdf_shutdown();
|
||||
void rdf_recursiveResourceTraversal(nsCOMPtr<nsIRDFResource> currentResource);
|
||||
void rdf_printArcLabels(nsCOMPtr<nsIRDFResource> currentResource);
|
||||
|
||||
|
|
|
@ -32,16 +32,16 @@
|
|||
|
||||
typedef jboolean (JNICALL *PJAWT_GETAWT)(JNIEnv*, JAWT*);
|
||||
|
||||
#include "Win32BrowserControlCanvas.h"
|
||||
#include "org_mozilla_webclient_impl_wrapper_0005fnative_win32_Win32BrowserControlCanvas.h"
|
||||
#include "jni_util.h" //for throwing Exceptions to Java
|
||||
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_webclient_wrapper_0005fnative_win32_Win32BrowserControlCanvas
|
||||
* Class: org_mozilla_webclient_impl_wrapper_0005fnative_win32_Win32BrowserControlCanvas
|
||||
* Method: getHandleToPeer
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_win32_Win32BrowserControlCanvas_getHandleToPeer
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_win32_Win32BrowserControlCanvas_getHandleToPeer
|
||||
(JNIEnv *env, jobject canvas) {
|
||||
JAWT awt;
|
||||
JAWT_DrawingSurface* ds;
|
||||
|
|
|
@ -108,13 +108,18 @@ char *DOMMouseListener_maskNames[] = {
|
|||
nsnull
|
||||
};
|
||||
|
||||
void util_InitializeShareInitContext(void *yourInitContext)
|
||||
void util_InitializeShareInitContext(JNIEnv *env,
|
||||
void *yourInitContext)
|
||||
{
|
||||
ShareInitContext *initContext = (ShareInitContext *) yourInitContext;
|
||||
initContext->propertiesClass = nsnull;
|
||||
initContext->propertiesClass =
|
||||
::util_FindClass(env, "java/util/Properties");
|
||||
util_Assert(initContext->propertiesClass);
|
||||
}
|
||||
|
||||
void util_DeallocateShareInitContext(void *yourInitContext)
|
||||
void util_DeallocateShareInitContext(JNIEnv *env,
|
||||
void *yourInitContext)
|
||||
{
|
||||
// right now there is nothing to deallocate
|
||||
}
|
||||
|
@ -441,6 +446,14 @@ void util_DeleteGlobalRef(JNIEnv *env, jobject obj)
|
|||
#endif
|
||||
}
|
||||
|
||||
void util_DeleteLocalRef(JNIEnv *env, jobject obj)
|
||||
{
|
||||
#ifdef BAL_INTERFACE
|
||||
#else
|
||||
env->DeleteLocalRef(obj);
|
||||
#endif
|
||||
}
|
||||
|
||||
jthrowable util_ExceptionOccurred(JNIEnv *env)
|
||||
{
|
||||
jthrowable result = nsnull;
|
||||
|
@ -805,6 +818,44 @@ jint util_GetIntFromPropertiesObject(JNIEnv *env, jobject propertiesObject,
|
|||
return result;
|
||||
}
|
||||
|
||||
void util_getSystemProperty(JNIEnv *env,
|
||||
const char *propName,
|
||||
char *propValue, jint propValueLen)
|
||||
{
|
||||
jstring
|
||||
resultJstr = nsnull,
|
||||
propNameJstr = ::util_NewStringUTF(env, propName);
|
||||
jclass clazz = nsnull;
|
||||
jmethodID getPropertyMethodId;
|
||||
const char * result = nsnull;
|
||||
int i = 0;
|
||||
|
||||
memset(propValue, nsnull, propValueLen);
|
||||
|
||||
if (nsnull == (clazz = ::util_FindClass(env, "java/lang/System"))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (nsnull == (getPropertyMethodId =
|
||||
env->GetStaticMethodID(clazz, "getProperty",
|
||||
"(Ljava/lang/String;)Ljava/lang/String;"))) {
|
||||
return;
|
||||
}
|
||||
if (nsnull ==
|
||||
(resultJstr = (jstring) env->CallStaticObjectMethod(clazz,
|
||||
getPropertyMethodId,
|
||||
propNameJstr))) {
|
||||
return;
|
||||
}
|
||||
::util_DeleteStringUTF(env, propNameJstr);
|
||||
result = ::util_GetStringUTFChars(env, resultJstr);
|
||||
strncpy(propValue, result, propValueLen - 1);
|
||||
::util_ReleaseStringUTFChars(env, resultJstr, result);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jvalue JNICALL
|
||||
JNU_CallMethodByName(JNIEnv *env,
|
||||
jboolean *hasException,
|
||||
|
|
|
@ -218,8 +218,8 @@ extern JavaVM *gVm; // defined in jni_util.cpp
|
|||
#define nsnull 0
|
||||
#endif
|
||||
|
||||
void util_InitializeShareInitContext(void *initContext);
|
||||
void util_DeallocateShareInitContext(void *initContext);
|
||||
void util_InitializeShareInitContext(JNIEnv *env, void *initContext);
|
||||
void util_DeallocateShareInitContext(JNIEnv *env, void *initContext);
|
||||
|
||||
/**
|
||||
|
||||
|
@ -258,7 +258,9 @@ void util_DumpJavaStack(JNIEnv *env);
|
|||
|
||||
jobject util_NewGlobalRef(JNIEnv *env, jobject toAddRef);
|
||||
|
||||
void util_DeleteGlobalRef(JNIEnv *env, jobject toAddRef);
|
||||
void util_DeleteGlobalRef(JNIEnv *env, jobject toDeleteRef);
|
||||
|
||||
void util_DeleteLocalRef(JNIEnv *env, jobject toDeleteRef);
|
||||
|
||||
jthrowable util_ExceptionOccurred(JNIEnv *env);
|
||||
|
||||
|
@ -351,6 +353,11 @@ jboolean util_GetBoolFromPropertiesObject(JNIEnv *, jobject propertiesObject,
|
|||
jint util_GetIntFromPropertiesObject(JNIEnv *, jobject propertiesObject,
|
||||
jobject name, jobject reserved);
|
||||
|
||||
void util_getSystemProperty(JNIEnv *env,
|
||||
const char *propName,
|
||||
char *propValue,
|
||||
jint propValueLen);
|
||||
|
||||
//
|
||||
// Functions provided by the browser specific native code
|
||||
//
|
||||
|
|
|
@ -113,6 +113,30 @@ JNIEXPORT jsize JNICALL util_GetStringLength(JNIEnv *env,
|
|||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jobjectArray util_GetJstringArrayFromJcharArray(JNIEnv *env,
|
||||
jint len,
|
||||
jchar **strings,
|
||||
jint *stringLengths)
|
||||
{
|
||||
jobjectArray result = nsnull;
|
||||
jclass clazz = nsnull;
|
||||
jstring curString = nsnull;
|
||||
jint i = 0;
|
||||
#ifdef BAL_INTERFACE
|
||||
#else
|
||||
clazz = ::util_FindClass(env, "java/lang/String");
|
||||
result = env->NewObjectArray(len, clazz, nsnull);
|
||||
for (i = 0; i < len; i++) {
|
||||
curString = ::util_NewString(env, strings[i],
|
||||
stringLengths[i]);
|
||||
env->SetObjectArrayElement(result, i, curString);
|
||||
::util_DeleteLocalRef(env, curString);
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jstring JNICALL util_NewStringUTF(JNIEnv *env, const char *inString)
|
||||
{
|
||||
jstring result = nsnull;
|
||||
|
|
|
@ -54,6 +54,11 @@ JNIEXPORT void JNICALL util_ReleaseStringChars(JNIEnv *env, jstring inString,
|
|||
JNIEXPORT jsize JNICALL util_GetStringLength(JNIEnv *env,
|
||||
jstring inString);
|
||||
|
||||
JNIEXPORT jobjectArray util_GetJstringArrayFromJcharArray(JNIEnv *env,
|
||||
jint len,
|
||||
jchar **strings,
|
||||
jint *stringLengths);
|
||||
|
||||
JNIEXPORT jstring JNICALL util_NewStringUTF(JNIEnv *env,
|
||||
const char * inString);
|
||||
|
||||
|
|
|
@ -0,0 +1,107 @@
|
|||
/*
|
||||
* $Id: BookmarksTest.java,v 1.1 2003-09-28 06:29:18 edburns%acm.org Exp $
|
||||
*/
|
||||
|
||||
/* -*- 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.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun
|
||||
* Microsystems, Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
import junit.framework.Test;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import javax.swing.tree.TreeModel;
|
||||
import javax.swing.tree.TreeNode;
|
||||
|
||||
// BookmarksTest.java
|
||||
|
||||
public class BookmarksTest extends WebclientTestCase {
|
||||
|
||||
public BookmarksTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return (new TestSuite(BookmarksTest.class));
|
||||
}
|
||||
|
||||
//
|
||||
// Constants
|
||||
//
|
||||
|
||||
//
|
||||
// Testcases
|
||||
//
|
||||
|
||||
public void testBookmarks() throws Exception {
|
||||
BrowserControl firstBrowserControl = null;
|
||||
BrowserControlFactory.setAppData(getBrowserBinDir());
|
||||
firstBrowserControl = BrowserControlFactory.newBrowserControl();
|
||||
assertNotNull(firstBrowserControl);
|
||||
|
||||
// test we can get the bookmarks
|
||||
TreeModel tree = null;
|
||||
TreePrinter printer = new TreePrinter();
|
||||
Bookmarks bookmarks = (Bookmarks)
|
||||
firstBrowserControl.queryInterface(BrowserControl.BOOKMARKS_NAME);
|
||||
assertNotNull(bookmarks);
|
||||
|
||||
// test that we can get the bookmarks tree
|
||||
tree = bookmarks.getBookmarks();
|
||||
assertNotNull(bookmarks);
|
||||
|
||||
walkTree((TreeNode) tree.getRoot(), printer, null);
|
||||
|
||||
BrowserControlFactory.deleteBrowserControl(firstBrowserControl);
|
||||
BrowserControlFactory.appTerminate();
|
||||
}
|
||||
|
||||
interface NodeCallback {
|
||||
public void takeActionOnNode(TreeNode node, int depth, Object closure);
|
||||
}
|
||||
|
||||
class TreePrinter extends Object implements NodeCallback {
|
||||
public void takeActionOnNode(TreeNode node, int depth, Object closure){
|
||||
for (int i = 0; i < depth; i++) {
|
||||
System.out.print(" ");
|
||||
}
|
||||
System.out.println(node.toString());
|
||||
}
|
||||
}
|
||||
|
||||
protected int depth = 0;
|
||||
|
||||
protected void walkTree(TreeNode root, NodeCallback cb, Object closure) {
|
||||
|
||||
Enumeration children = root.children();
|
||||
TreeNode child = null;
|
||||
|
||||
cb.takeActionOnNode(root, depth, closure);
|
||||
while (children.hasMoreElements()) {
|
||||
depth++;
|
||||
walkTree((TreeNode) children.nextElement(), cb, closure);
|
||||
depth--;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
* $Id: PreferencesTest.java,v 1.1 2003-09-28 06:29:18 edburns%acm.org Exp $
|
||||
*/
|
||||
|
||||
/* -*- 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.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun
|
||||
* Microsystems, Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
import junit.framework.Test;
|
||||
|
||||
import java.util.Properties;
|
||||
import java.util.Iterator;
|
||||
|
||||
// PreferencesTest.java
|
||||
|
||||
public class PreferencesTest extends WebclientTestCase {
|
||||
|
||||
public PreferencesTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return (new TestSuite(PreferencesTest.class));
|
||||
}
|
||||
|
||||
//
|
||||
// Constants
|
||||
//
|
||||
|
||||
public static final String CLOSURE = "closure";
|
||||
public static final String PREFNAME = "webclient.pref";
|
||||
public static final String PREFVALUE = "webclient.value";
|
||||
|
||||
//
|
||||
// Testcases
|
||||
//
|
||||
|
||||
public void testPreferences() throws Exception {
|
||||
Properties prefProperties = null;
|
||||
BrowserControl firstBrowserControl = null;
|
||||
PrefChangedCallback callback = new TestPrefChangedCallback();
|
||||
BrowserControlFactory.setAppData(getBrowserBinDir());
|
||||
firstBrowserControl = BrowserControlFactory.newBrowserControl();
|
||||
assertNotNull(firstBrowserControl);
|
||||
|
||||
// test we can get the prefs
|
||||
Preferences prefs = (Preferences)
|
||||
firstBrowserControl.queryInterface(BrowserControl.PREFERENCES_NAME);
|
||||
assertNotNull(prefs);
|
||||
|
||||
// make sure we don't have the pref already
|
||||
prefProperties = prefs.getPrefs();
|
||||
assertNotNull(prefProperties);
|
||||
assertTrue(null == prefProperties.getProperty(PREFNAME));
|
||||
|
||||
// test that we can set a preference
|
||||
prefs.setPref(PREFNAME, PREFVALUE);
|
||||
|
||||
// test that the set value is actually there
|
||||
prefProperties = prefs.getPrefs();
|
||||
assertNotNull(prefProperties);
|
||||
|
||||
// test that the set value is as expected
|
||||
assertTrue(prefProperties.getProperty(PREFNAME).equals(PREFVALUE));
|
||||
|
||||
// test that we can register a prefChangedCallback
|
||||
System.setProperty(PREFNAME, "");
|
||||
prefs.registerPrefChangedCallback(callback, PREFNAME, CLOSURE);
|
||||
|
||||
// change the value of the preference
|
||||
prefs.setPref(PREFNAME, "newValue");
|
||||
|
||||
// test that our pref-change callback has been called.
|
||||
assertTrue(System.getProperty(PREFNAME).equals(CLOSURE));
|
||||
|
||||
// test that we can successfully unregister our callback
|
||||
prefs.unregisterPrefChangedCallback(callback, PREFNAME, CLOSURE);
|
||||
|
||||
// verify that it is no longer called
|
||||
System.setProperty(PREFNAME, "");
|
||||
prefs.setPref(PREFNAME, "newValue");
|
||||
|
||||
// test that our pref-change callback has not been called.
|
||||
assertFalse(System.getProperty(PREFNAME).equals(CLOSURE));
|
||||
|
||||
|
||||
BrowserControlFactory.deleteBrowserControl(firstBrowserControl);
|
||||
BrowserControlFactory.appTerminate();
|
||||
}
|
||||
|
||||
class TestPrefChangedCallback extends Object implements PrefChangedCallback {
|
||||
public int prefChanged(String prefName, Object closure) {
|
||||
System.setProperty(prefName, closure.toString());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,141 @@
|
|||
/*
|
||||
* $Id: ProfileManagerTest.java,v 1.1 2003-09-28 06:29:18 edburns%acm.org Exp $
|
||||
*/
|
||||
|
||||
/* -*- 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.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun
|
||||
* Microsystems, Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
import junit.framework.Test;
|
||||
|
||||
// ProfileManagerTest.java
|
||||
|
||||
public class ProfileManagerTest extends WebclientTestCase {
|
||||
|
||||
public ProfileManagerTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return (new TestSuite(ProfileManagerTest.class));
|
||||
}
|
||||
|
||||
//
|
||||
// Testcases
|
||||
//
|
||||
|
||||
public void testProfile() throws Exception {
|
||||
int
|
||||
i = 0,
|
||||
len = 0;
|
||||
final String
|
||||
name = "testProfile",
|
||||
newName = "testProfile2";
|
||||
BrowserControl firstBrowserControl = null;
|
||||
BrowserControlFactory.setAppData(getBrowserBinDir());
|
||||
firstBrowserControl = BrowserControlFactory.newBrowserControl();
|
||||
assertNotNull(firstBrowserControl);
|
||||
|
||||
// test we can get the profileManager
|
||||
ProfileManager profileManager = (ProfileManager)
|
||||
firstBrowserControl.queryInterface(BrowserControl.PROFILE_MANAGER_NAME);
|
||||
assertNotNull(profileManager);
|
||||
|
||||
// create a new profile
|
||||
profileManager.createNewProfile(name, null, null, false);
|
||||
|
||||
// test that we have at least one profile
|
||||
int profileCount = profileManager.getProfileCount();
|
||||
assertTrue(1 <= profileCount);
|
||||
|
||||
// test that the new profile exists
|
||||
assertTrue(profileManager.profileExists(name));
|
||||
|
||||
// test that we can set the current profile to the new profile
|
||||
profileManager.setCurrentProfile(name);
|
||||
|
||||
// test that the current profile is the new profile
|
||||
String currentProfile = profileManager.getCurrentProfile();
|
||||
assertTrue(currentProfile.equals(name));
|
||||
|
||||
// test that the list of profiles contains the new profile
|
||||
String [] profiles = profileManager.getProfileList();
|
||||
assertNotNull(profiles);
|
||||
boolean hasExpectedProfile = false;
|
||||
for (i = 0, len = profiles.length; i < len; i++) {
|
||||
if (profiles[i].equals(name)) {
|
||||
hasExpectedProfile = true;
|
||||
}
|
||||
}
|
||||
assertTrue(hasExpectedProfile);
|
||||
|
||||
// test that you can rename the newly created profile
|
||||
profileManager.renameProfile(name, newName);
|
||||
|
||||
// test that the new profile exists
|
||||
assertTrue(profileManager.profileExists(newName));
|
||||
profiles = profileManager.getProfileList();
|
||||
assertNotNull(profiles);
|
||||
hasExpectedProfile = false;
|
||||
for (i = 0, len = profiles.length; i < len; i++) {
|
||||
if (profiles[i].equals(newName)) {
|
||||
hasExpectedProfile = true;
|
||||
}
|
||||
}
|
||||
assertTrue(hasExpectedProfile);
|
||||
|
||||
// test that the old name doesn't exist
|
||||
assertTrue(!profileManager.profileExists(name));
|
||||
profiles = profileManager.getProfileList();
|
||||
assertNotNull(profiles);
|
||||
hasExpectedProfile = false;
|
||||
for (i = 0, len = profiles.length; i < len; i++) {
|
||||
if (profiles[i].equals(name)) {
|
||||
hasExpectedProfile = true;
|
||||
}
|
||||
}
|
||||
assertTrue(!hasExpectedProfile);
|
||||
|
||||
// test that we can delete the new profile
|
||||
profileManager.deleteProfile(newName, true);
|
||||
|
||||
// test that the new name doesn't exist
|
||||
assertTrue(!profileManager.profileExists(newName));
|
||||
profiles = profileManager.getProfileList();
|
||||
assertNotNull(profiles);
|
||||
hasExpectedProfile = false;
|
||||
for (i = 0, len = profiles.length; i < len; i++) {
|
||||
if (profiles[i].equals(newName)) {
|
||||
hasExpectedProfile = true;
|
||||
}
|
||||
}
|
||||
assertTrue(!hasExpectedProfile);
|
||||
|
||||
|
||||
BrowserControlFactory.deleteBrowserControl(firstBrowserControl);
|
||||
BrowserControlFactory.appTerminate();
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Id: BrowserControlFactoryTest.java,v 1.1 2003-09-06 06:26:50 edburns%acm.org Exp $
|
||||
* $Id: WebclientFactoryImplTest.java,v 1.1 2003-09-28 06:29:19 edburns%acm.org Exp $
|
||||
*/
|
||||
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
|
@ -24,33 +24,33 @@
|
|||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient;
|
||||
package org.mozilla.webclient.impl;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
import junit.framework.Test;
|
||||
|
||||
// BrowserControlFactoryTest.java
|
||||
import org.mozilla.webclient.WebclientTestCase;
|
||||
|
||||
public class BrowserControlFactoryTest extends WebclientTestCase {
|
||||
// WebclientFactoryImplTest.java
|
||||
|
||||
public BrowserControlFactoryTest(String name) {
|
||||
public class WebclientFactoryImplTest extends WebclientTestCase {
|
||||
|
||||
public WebclientFactoryImplTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return (new TestSuite(BrowserControlFactoryTest.class));
|
||||
return (new TestSuite(WebclientFactoryImplTest.class));
|
||||
}
|
||||
|
||||
//
|
||||
// Testcases
|
||||
//
|
||||
|
||||
public void testFactoryLocator() {
|
||||
try {
|
||||
BrowserControlFactory.setAppData(getBrowserBinDir());
|
||||
}
|
||||
catch (Throwable e) {
|
||||
assertTrue(e.getMessage() + " " + e, false);
|
||||
}
|
||||
public void testWrapperFactoryLocator() throws Exception {
|
||||
WebclientFactoryImpl impl = new WebclientFactoryImpl();
|
||||
WrapperFactory wrapper = impl.getWrapperFactory();
|
||||
assertNotNull(wrapper);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* $Id: WrapperFactoryImplTest.java,v 1.1 2003-09-28 06:29:20 edburns%acm.org Exp $
|
||||
*/
|
||||
|
||||
/* -*- 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.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun
|
||||
* Microsystems, Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.impl.wrapper_native;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
import junit.framework.Test;
|
||||
|
||||
import org.mozilla.webclient.BrowserControl;
|
||||
import org.mozilla.webclient.WebclientTestCase;
|
||||
|
||||
// WrapperFactoryImplTest.java
|
||||
|
||||
public class WrapperFactoryImplTest extends WebclientTestCase {
|
||||
|
||||
public WrapperFactoryImplTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return (new TestSuite(WrapperFactoryImplTest.class));
|
||||
}
|
||||
|
||||
//
|
||||
// Testcases
|
||||
//
|
||||
|
||||
protected String [] expectedInterfaces = {
|
||||
BrowserControl.WINDOW_CONTROL_NAME,
|
||||
BrowserControl.NAVIGATION_NAME,
|
||||
BrowserControl.HISTORY_NAME,
|
||||
BrowserControl.EVENT_REGISTRATION_NAME,
|
||||
BrowserControl.BOOKMARKS_NAME
|
||||
};
|
||||
|
||||
|
||||
public void testNativeDoesImplement() throws Exception {
|
||||
WrapperFactoryImpl wrapper = new WrapperFactoryImpl();
|
||||
wrapper.initialize(getBrowserBinDir());
|
||||
for (int i = 0, len = expectedInterfaces.length; i < len; i++) {
|
||||
assertTrue(wrapper.nativeDoesImplement(expectedInterfaces[i]));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Id: TestGtkBrowserControlCanvas.java,v 1.1 2002-10-01 00:39:30 edburns%acm.org Exp $
|
||||
* $Id: TestGtkBrowserControlCanvas.java,v 1.1 2003-09-28 06:29:21 edburns%acm.org Exp $
|
||||
*/
|
||||
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
|
@ -24,7 +24,7 @@
|
|||
* Contributor(s):
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.wrapper_native.gtk;
|
||||
package org.mozilla.webclient.impl.wrapper_native.gtk;
|
||||
|
||||
// TestGtkBrowserControlCanvas.java
|
||||
|
||||
|
@ -39,7 +39,7 @@ import org.mozilla.webclient.WebclientTestCase;
|
|||
*
|
||||
* <B>Lifetime And Scope</B> <P>
|
||||
*
|
||||
* @version $Id: TestGtkBrowserControlCanvas.java,v 1.1 2002-10-01 00:39:30 edburns%acm.org Exp $
|
||||
* @version $Id: TestGtkBrowserControlCanvas.java,v 1.1 2003-09-28 06:29:21 edburns%acm.org Exp $
|
||||
*
|
||||
* @see Blah
|
||||
* @see Bloo
|
|
@ -0,0 +1,28 @@
|
|||
1024[80fc498]: WrapperFactoryImpl_nativeAppInitialize: entering
|
||||
1024[80fc498]: WrapperFactoryImpl_nativeAppInitialize: nativeBinDir: /home/edburns/Projects/mozilla/MOZILLA_1_4/mozilla/dist/bin
|
||||
1024[80fc498]: WrapperFactoryImpl_nativeAppInitialize: NS_NewNativeLocalFile rv: 0
|
||||
1024[80fc498]: WrapperFactoryImpl_nativeAppInitialize: NS_InitEmbedding rv: 0
|
||||
1024[80fc498]: WrapperFactoryImpl_nativeAppInitialize: exiting
|
||||
1024[80fc498]: ProfileManagerImpl_nativeStartup: entering
|
||||
1024[80fc498]: ProfileManagerImpl_nativeStartup: GetProfileCount rv: 0
|
||||
1024[80fc498]: ProfileManagerImpl_nativeStartup: GetProfileList rv: 0
|
||||
1024[80fc498]: ProfileManagerImpl_nativeStartup: commandLineService initialize rv: 0
|
||||
1024[80fc498]: ProfileManagerImpl_nativeStartup: profileInternal startupWithArgs rv: 0
|
||||
1024[80fc498]: ProfileManagerImpl_nativeStartup: exiting
|
||||
1024[80fc498]: PreferencesImpl_nativeStartup: entering
|
||||
1024[80fc498]: PreferencesImpl_nativeStartup: exiting
|
||||
1024[80fc498]: BookmarksImpl_nativeStartup: entering
|
||||
1024[80fc498]: WARNING: NS_ENSURE_TRUE(NS_SUCCEEDED(rv)) failed, file nsChromeRegistry.cpp, line 3188
|
||||
1024[80fc498]: WARNING: NS_ENSURE_TRUE(NS_SUCCEEDED(rv)) failed, file nsChromeRegistry.cpp, line 3188
|
||||
1024[80fc498]: BookmarksImpl_nativeStartup: exiting
|
||||
1024[80fc498]: WrapperFactoryImpl_nativeAppSetup: entering
|
||||
1024[80fc498]: WrapperFactoryImpl_nativeAppSetup: exiting
|
||||
1024[80fc498]: BookmarksImpl_nativeShutdown: entering
|
||||
1024[80fc498]: BookmarksImpl_nativeShutdown: exiting
|
||||
1024[80fc498]: PreferencesImpl_nativeShutdown: entering
|
||||
1024[80fc498]: PreferencesImpl_nativeShutdown: exiting
|
||||
1024[80fc498]: ProfileManagerImpl_nativeShutdown: entering
|
||||
1024[80fc498]: ProfileManagerImpl_nativeShutdown: exiting
|
||||
1024[80fc498]: WrapperFactoryImpl_nativeTerminate: entering
|
||||
1024[80fc498]: WrapperFactoryImpl_nativeTerminate: NS_TermEmbedding rv: 0
|
||||
1024[80fc498]: WrapperFactoryImpl_nativeTerminate: exiting
|
Загрузка…
Ссылка в новой задаче