diff --git a/mozilla/java/makefiles b/mozilla/java/makefiles index d4936b9bca1..b5931109489 100644 --- a/mozilla/java/makefiles +++ b/mozilla/java/makefiles @@ -3,5 +3,6 @@ java/util/Makefile java/util/classes/Makefile java/webclient/Makefile java/webclient/classes_spec/Makefile +java/webclient/src_share/Makefile java/webclient/src_moz/Makefile java/webclient/src_moz/motif/Makefile diff --git a/mozilla/java/webclient/Makefile.in b/mozilla/java/webclient/Makefile.in index 6ae5e959bcd..a55fdc0a01f 100644 --- a/mozilla/java/webclient/Makefile.in +++ b/mozilla/java/webclient/Makefile.in @@ -25,7 +25,7 @@ include $(DEPTH)/config/autoconf.mk #// DIRS - There are subdirectories to process #// #//------------------------------------------------------------------------ -DIRS= classes_spec src_moz +DIRS= classes_spec src_share src_moz #//------------------------------------------------------------------------ #// diff --git a/mozilla/java/webclient/Makefile.win b/mozilla/java/webclient/Makefile.win index de510f4ac1b..e486ee498e4 100644 --- a/mozilla/java/webclient/Makefile.win +++ b/mozilla/java/webclient/Makefile.win @@ -36,11 +36,13 @@ IGNORE_MANIFEST=1 DEPTH = ..\.. DIRS = classes_spec \ + src_share \ src_moz \ $(NULL) !if defined(BAL_INTERFACE) DIRS = classes_spec \ + src_share \ src_moz \ bal_test \ $(NULL) diff --git a/mozilla/java/webclient/src_moz/BookmarksImpl.cpp b/mozilla/java/webclient/src_moz/BookmarksImpl.cpp index 85b45efdd9e..a8a6b37cba9 100644 --- a/mozilla/java/webclient/src_moz/BookmarksImpl.cpp +++ b/mozilla/java/webclient/src_moz/BookmarksImpl.cpp @@ -23,7 +23,7 @@ #include "BookmarksImpl.h" #include "rdf_util.h" -#include "jni_util.h" +#include "ns_util.h" #include "nsCOMPtr.h" diff --git a/mozilla/java/webclient/src_moz/CBrowserContainer.cpp b/mozilla/java/webclient/src_moz/CBrowserContainer.cpp index 3df1d28e142..0a4cc886b57 100644 --- a/mozilla/java/webclient/src_moz/CBrowserContainer.cpp +++ b/mozilla/java/webclient/src_moz/CBrowserContainer.cpp @@ -100,7 +100,7 @@ CBrowserContainer::CBrowserContainer(nsIWebBrowser *pOwner, JNIEnv *env, inverseDepth(-1), properties(nsnull), currentDOMEvent(nsnull) { NS_INIT_REFCNT(); - if (nsnull == gVm) { // declared in jni_util.h + if (nsnull == gVm) { // declared in ../src_share/jni_util.h ::util_GetJavaVM(env, &gVm); // save this vm reference away for the callback! } } @@ -700,8 +700,6 @@ CBrowserContainer::OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURI* aURL, ::Recycle(urlStr); } } - - util_SendEventToJava(mInitContext->env, mInitContext->nativeEventThread, mDocTarget, DocumentLoader_maskValues[START_DOCUMENT_LOAD_EVENT_MASK], @@ -778,7 +776,6 @@ CBrowserContainer::OnStartURLLoad(nsIDocumentLoader* loader, nsIChannel* aChanne DocumentLoader_maskValues[START_URL_LOAD_EVENT_MASK], nsnull); - return NS_OK; } @@ -796,7 +793,6 @@ CBrowserContainer::OnProgressURLLoad(nsIDocumentLoader* loader, nsIChannel* aCha } #endif - util_SendEventToJava(mInitContext->env, mInitContext->nativeEventThread, mDocTarget, DocumentLoader_maskValues[PROGRESS_URL_LOAD_EVENT_MASK], @@ -830,13 +826,12 @@ CBrowserContainer::OnStatusURLLoad(nsIDocumentLoader* loader, JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION_1_2); jstring statusMessage = ::util_NewString(env, (const jchar *) aMsg.GetUnicode(), length); - + util_SendEventToJava(mInitContext->env, mInitContext->nativeEventThread, mDocTarget, DocumentLoader_maskValues[STATUS_URL_LOAD_EVENT_MASK], (jobject) statusMessage); - if (statusMessage) { ::util_DeleteString(mInitContext->env, statusMessage); } @@ -863,7 +858,6 @@ CBrowserContainer::OnEndURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, mInitContext->nativeEventThread, mDocTarget, DocumentLoader_maskValues[END_URL_LOAD_EVENT_MASK], nsnull); - return NS_OK; } @@ -884,14 +878,11 @@ CBrowserContainer::MouseDown(nsIDOMEvent* aMouseEvent) PR_ASSERT(nsnull != aMouseEvent); getPropertiesFromEvent(aMouseEvent); - util_SendEventToJava(mInitContext->env, mInitContext->nativeEventThread, mMouseTarget, DOMMouseListener_maskValues[MOUSE_DOWN_EVENT_MASK], properties); - - return NS_OK; } @@ -905,14 +896,11 @@ CBrowserContainer::MouseUp(nsIDOMEvent* aMouseEvent) PR_ASSERT(nsnull != aMouseEvent); getPropertiesFromEvent(aMouseEvent); - util_SendEventToJava(mInitContext->env, mInitContext->nativeEventThread, mMouseTarget, DOMMouseListener_maskValues[MOUSE_UP_EVENT_MASK], properties); - - return NS_OK; } @@ -928,15 +916,14 @@ CBrowserContainer::MouseClick(nsIDOMEvent* aMouseEvent) JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION_1_2); ::util_StoreIntoPropertiesObject(env, properties, CLICK_COUNT_KEY, - ONE_VALUE, (jobject) mInitContext); + ONE_VALUE, (jobject) + &(mInitContext->shareContext)); util_SendEventToJava(mInitContext->env, mInitContext->nativeEventThread, mMouseTarget, DOMMouseListener_maskValues[MOUSE_CLICK_EVENT_MASK], properties); - - return NS_OK; } @@ -953,15 +940,14 @@ CBrowserContainer::MouseDblClick(nsIDOMEvent* aMouseEvent) JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION_1_2); ::util_StoreIntoPropertiesObject(env, properties, CLICK_COUNT_KEY, - TWO_VALUE, (jobject) mInitContext); + TWO_VALUE, (jobject) + &(mInitContext->shareContext)); util_SendEventToJava(mInitContext->env, mInitContext->nativeEventThread, mMouseTarget, DOMMouseListener_maskValues[MOUSE_DOUBLE_CLICK_EVENT_MASK], properties); - - return NS_OK; } @@ -975,14 +961,11 @@ CBrowserContainer::MouseOver(nsIDOMEvent* aMouseEvent) PR_ASSERT(nsnull != aMouseEvent); getPropertiesFromEvent(aMouseEvent); - util_SendEventToJava(mInitContext->env, mInitContext->nativeEventThread, mMouseTarget, DOMMouseListener_maskValues[MOUSE_OVER_EVENT_MASK], properties); - - return NS_OK; } @@ -996,14 +979,11 @@ CBrowserContainer::MouseOut(nsIDOMEvent* aMouseEvent) PR_ASSERT(nsnull != aMouseEvent); getPropertiesFromEvent(aMouseEvent); - util_SendEventToJava(mInitContext->env, mInitContext->nativeEventThread, mMouseTarget, DOMMouseListener_maskValues[MOUSE_OUT_EVENT_MASK], properties); - - return NS_OK; } @@ -1024,7 +1004,6 @@ NS_IMETHODIMP CBrowserContainer::AddMouseListener(jobject target) DOMMouseListener_maskNames, DOMMouseListener_maskValues); } - mMouseTarget = target; return rv; @@ -1042,7 +1021,6 @@ NS_IMETHODIMP CBrowserContainer::AddDocumentLoadListener(jobject target) DocumentLoader_maskNames, DocumentLoader_maskValues); } - mDocTarget = target; return rv; @@ -1138,11 +1116,13 @@ jobject JNICALL CBrowserContainer::getPropertiesFromEvent(nsIDOMEvent *event) JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION_1_2); if (properties) { - util_ClearPropertiesObject(env, properties, (jobject) mInitContext); + util_ClearPropertiesObject(env, properties, (jobject) + &(mInitContext->shareContext)); } else { if (!(properties = - util_CreatePropertiesObject(env, (jobject)mInitContext))) { + util_CreatePropertiesObject(env, (jobject) + &(mInitContext->shareContext)))) { return properties; } } @@ -1189,7 +1169,8 @@ void JNICALL CBrowserContainer::addMouseEventDataToProperties(nsIDOMEvent *aMous strVal = ::util_NewStringUTF(env, buf); ::util_StoreIntoPropertiesObject(env, properties, SCREEN_X_KEY, (jobject) strVal, - (jobject) mInitContext); + (jobject) + &(mInitContext->shareContext)); } rv = mouseEvent->GetScreenY(&intVal); @@ -1198,7 +1179,8 @@ void JNICALL CBrowserContainer::addMouseEventDataToProperties(nsIDOMEvent *aMous strVal = ::util_NewStringUTF(env, buf); ::util_StoreIntoPropertiesObject(env, properties, SCREEN_Y_KEY, (jobject) strVal, - (jobject) mInitContext); + (jobject) + &(mInitContext->shareContext)); } rv = mouseEvent->GetClientX(&intVal); @@ -1207,7 +1189,8 @@ void JNICALL CBrowserContainer::addMouseEventDataToProperties(nsIDOMEvent *aMous strVal = ::util_NewStringUTF(env, buf); ::util_StoreIntoPropertiesObject(env, properties, CLIENT_X_KEY, (jobject) strVal, - (jobject) mInitContext); + (jobject) + &(mInitContext->shareContext)); } rv = mouseEvent->GetClientY(&intVal); @@ -1216,7 +1199,8 @@ void JNICALL CBrowserContainer::addMouseEventDataToProperties(nsIDOMEvent *aMous strVal = ::util_NewStringUTF(env, buf); ::util_StoreIntoPropertiesObject(env, properties, CLIENT_Y_KEY, (jobject) strVal, - (jobject) mInitContext); + (jobject) + &(mInitContext->shareContext)); } int16Val = 0; @@ -1226,7 +1210,8 @@ void JNICALL CBrowserContainer::addMouseEventDataToProperties(nsIDOMEvent *aMous strVal = ::util_NewStringUTF(env, buf); ::util_StoreIntoPropertiesObject(env, properties, BUTTON_KEY, (jobject) strVal, - (jobject) mInitContext); + (jobject) + &(mInitContext->shareContext)); } rv = mouseEvent->GetAltKey(&boolVal); @@ -1234,7 +1219,8 @@ void JNICALL CBrowserContainer::addMouseEventDataToProperties(nsIDOMEvent *aMous strVal = boolVal ? (jstring) TRUE_VALUE : (jstring) FALSE_VALUE; ::util_StoreIntoPropertiesObject(env, properties, ALT_KEY, (jobject) strVal, - (jobject) mInitContext); + (jobject) + &(mInitContext->shareContext)); } rv = mouseEvent->GetCtrlKey(&boolVal); @@ -1242,7 +1228,8 @@ void JNICALL CBrowserContainer::addMouseEventDataToProperties(nsIDOMEvent *aMous strVal = boolVal ? (jstring) TRUE_VALUE : (jstring) FALSE_VALUE; ::util_StoreIntoPropertiesObject(env, properties, CTRL_KEY, (jobject) strVal, - (jobject) mInitContext); + (jobject) + &(mInitContext->shareContext)); } rv = mouseEvent->GetShiftKey(&boolVal); @@ -1250,7 +1237,8 @@ void JNICALL CBrowserContainer::addMouseEventDataToProperties(nsIDOMEvent *aMous strVal = boolVal ? (jstring) TRUE_VALUE : (jstring) FALSE_VALUE; ::util_StoreIntoPropertiesObject(env, properties, SHIFT_KEY, (jobject) strVal, - (jobject) mInitContext); + (jobject) + &(mInitContext->shareContext)); } rv = mouseEvent->GetMetaKey(&boolVal); @@ -1258,7 +1246,8 @@ void JNICALL CBrowserContainer::addMouseEventDataToProperties(nsIDOMEvent *aMous strVal = boolVal ? (jstring) TRUE_VALUE : (jstring) FALSE_VALUE; ::util_StoreIntoPropertiesObject(env, properties, META_KEY, (jobject) strVal, - (jobject) mInitContext); + (jobject) + &(mInitContext->shareContext)); } } @@ -1323,7 +1312,8 @@ nsresult JNICALL CBrowserContainer::takeActionOnNode(nsCOMPtr curren util_StoreIntoPropertiesObject(env, (jobject) curThis->properties, (jobject) jNodeName, (jobject) jNodeValue, - (jobject) curThis->mInitContext); + (jobject) + &(curThis->mInitContext->shareContext)); if (jNodeName) { ::util_DeleteString(env, jNodeName); } @@ -1386,7 +1376,8 @@ nsresult JNICALL CBrowserContainer::takeActionOnNode(nsCOMPtr curren util_StoreIntoPropertiesObject(env, (jobject) curThis->properties, (jobject) jNodeName, (jobject) jNodeValue, - (jobject) curThis->mInitContext); + (jobject) + &(curThis->mInitContext->shareContext)); if (jNodeName) { ::util_DeleteString(env, jNodeName); } diff --git a/mozilla/java/webclient/src_moz/CBrowserContainer.h b/mozilla/java/webclient/src_moz/CBrowserContainer.h index e836cf8b7a8..6ade2795a38 100644 --- a/mozilla/java/webclient/src_moz/CBrowserContainer.h +++ b/mozilla/java/webclient/src_moz/CBrowserContainer.h @@ -46,7 +46,7 @@ #include "wcIBrowserContainer.h" -#include "jni_util.h" +#include "ns_util.h" class nsIURI; diff --git a/mozilla/java/webclient/src_moz/CurrentPageImpl.cpp b/mozilla/java/webclient/src_moz/CurrentPageImpl.cpp index 1212163691b..efd2d72e833 100644 --- a/mozilla/java/webclient/src_moz/CurrentPageImpl.cpp +++ b/mozilla/java/webclient/src_moz/CurrentPageImpl.cpp @@ -31,8 +31,7 @@ #include "CurrentPageImpl.h" -#include "jni_util.h" -#include "jni_util_export.h" +#include "ns_util.h" #include "rdf_util.h" #include "nsActions.h" diff --git a/mozilla/java/webclient/src_moz/HistoryImpl.cpp b/mozilla/java/webclient/src_moz/HistoryImpl.cpp index 99fced2fef3..124ab337726 100644 --- a/mozilla/java/webclient/src_moz/HistoryImpl.cpp +++ b/mozilla/java/webclient/src_moz/HistoryImpl.cpp @@ -27,7 +27,7 @@ #include "HistoryImpl.h" -#include "jni_util.h" +#include "ns_util.h" #include "nsActions.h" diff --git a/mozilla/java/webclient/src_moz/Makefile.in b/mozilla/java/webclient/src_moz/Makefile.in index 70df7bc9230..1d1eb51fc72 100644 --- a/mozilla/java/webclient/src_moz/Makefile.in +++ b/mozilla/java/webclient/src_moz/Makefile.in @@ -31,8 +31,8 @@ include $(DEPTH)/config/autoconf.mk LIBRARY_NAME = webclient CPPSRCS = \ - jni_util.cpp \ - jni_util_export.cpp \ + ns_util.cpp \ + ns_util_export.cpp \ dom_util.cpp \ nsActions.cpp \ rdf_util.cpp \ @@ -52,10 +52,6 @@ CPPSRCS = \ motif/gtkmozilla.cpp \ $(NULL) -ifneq ($(BAL_INTERFACE),) - CPPSRCS += bal_util.cpp -endif - include $(topsrcdir)/config/rules.mk ifdef MOZ_ENABLE_GTK @@ -70,10 +66,10 @@ EXTRA_DSO_LDOPTS += -lgtkxtbin -lgtksuperwin -L/usr/X11R6/lib -lXt endif endif -EXTRA_DSO_LDOPTS += -L$(DEPTH)/dist/bin/components -lwidget_gtk +EXTRA_DSO_LDOPTS += -L$(DEPTH)/dist/bin/components -lwidget_gtk -lwc_share INCLUDES := -I$(JDKHOME)/include -I$(JDKHOME)/include/solaris $(INCLUDES) \ - -I$(DEPTH)/widget/src/gtk + -I$(DEPTH)/widget/src/gtk -I../src_share JAVAH_CLS= \ "-o BookmarksImpl.h org.mozilla.webclient.wrapper_native.BookmarksImpl" \ diff --git a/mozilla/java/webclient/src_moz/Makefile.solaris b/mozilla/java/webclient/src_moz/Makefile.solaris deleted file mode 100755 index 029d939c6df..00000000000 --- a/mozilla/java/webclient/src_moz/Makefile.solaris +++ /dev/null @@ -1,139 +0,0 @@ -# -# PENDING(mark): I need to use gtk-config to find the libraries and -# include files -# For JDK1.2 -JAVADIR = ${JDKHOME} -DLLNAME = libwebclient.so -DLLNAMESTUB = libwebclientstub.so -MOZILLA_TOP = ../../.. -DIST = ${MOZILLA_TOP}/dist -LIBDIR = ${DIST}/lib - -# FOR GCC UNCOMMENT THESE LINES -CC = gcc -g -fno-rtti -fno-exceptions -pedantic -Wno-long-long -MKSHLIB = c++ -G - -# FOR SUN WORKSHOP UNCOMMENT THESE LINES -#CC = CC -pic -#MKSHLIB = CC -G - - -# WARNING: YOU NEED TO RUN 'gtk-config --cflags' and stick it in here -GTKINCLUDES = -I/usr/openwin/include -I/opt/local/lib/glib/include -I/opt/local/include -I/Blackwood/gtk/include -I/Blackwood/glib/lib/glib/include -I/Blackwood/glib/include -# WARNING: YOU NEED TO RUN 'gtk-config --libs' and stick it in here -GTKLIBS = -L/opt/local/lib -L/usr/openwin/lib -R/usr/openwin/lib -lgtk -lgdk -lgmodule -lglib -ldl -lintl -lXext -lX11 -lsocket -lnsl -lm -L/usr/dt/lib -L/Blackwood/gtk/lib -L/Blackwood/glib/lib -JAVAINCLUDE = -I${JAVADIR}/include -I${JAVADIR}/include/solaris -# For JDK1.2 -# For Solaris -JAVALIBS = -L${JAVADIR}/jre/lib/sparc -ljava -INCLUDE = ${JAVAINCLUDE} -I${DIST}/include -I${MOZILLA_TOP}/widget/src/gtk ${GTKINCLUDES} ${GTKMOZILLAINCLUDE} -DEFINES = -D_REENTRANT -DNECKO -DXP_UNIX -DNS_DEBUG -DDEBUG_RAPTOR_CANVAS -DMOZ_DLL_SUFFIX=\".so\" -STUBDEFINES = -D_REENTRANT -STUBINCLUDE = ${JAVAINCLUDE} -STUBLIBS = ${JAVALIBS} /usr/lib/libC.so.5 -# For the latest mozilla build -LIBS = ${GTKLIBS} ${JAVALIBS} \ --L${DIST}/bin -L${LIBDIR} -lraptorgfx -lexpat_s -lxmltok_s -lmozjs -lmozutil_s -lnspr3 -ljpeg -lpng -lzlib -lpthread -lXm -lXt -L${DIST}/lib -lxpcom -limg_s -lplds3 -lgfx_gtk -lraptorwebwidget -lraptorplugin -lgtksuperwin -lwidget_gtk -lplds3 -lplc3 -ljsdom -L${DIST}/lib -ltimer_s /usr/lib/libC.so.5 - -#-L${DIST}/bin -L${LIBDIR} -lraptorgfx -lexpat_s -lxmltok_s -ljsurl -lmozdbm -lmozjs -lmozutil_s -lnspr3 -lxp -ljpeg -lpng -lz -lpthread -lXm -lXt -L${DIST}/lib -lxpcom -limg -lplds3 -lgfx_gtk -lgkwebwidget -lgkhtmlpars -lgkplugin -lpref -lplds3 -lplc3 -ljsdom -L${DIST}/lib -ltimer_gtk_s /usr/lib/libC.so.5 -LN = ln -f -s - -all: libwebclientstub.so libwebclient.so copy - -copy: - cp libwebclient*.so ${DIST}/bin - -# component.reg components - -component.reg: - ${LN} ${DIST}/bin/component.reg - -components: - ${LN} ${DIST}/bin/components - -libwebclientstub.so: NativeLoaderStub.o MotifBrowserControlCanvasStub.o - ${MKSHLIB} -o ${DLLNAMESTUB} NativeLoaderStub.o MotifBrowserControlCanvasStub.o ${STUBLIBS} - -libwebclient.so: jni_util.o jni_util_export.o rdf_util.o NativeEventThread.o BookmarksImpl.o CurrentPageImpl.o HistoryImpl.o ISupportsPeer.o NavigationImpl.o RDFEnumeration.o RDFTreeNode.o WindowControlImpl.o WrapperFactoryImpl.o MotifBrowserControlCanvas.o gtkmozilla.o nsActions.o nsSetupRegistry.o DocumentLoaderObserverImpl.o EventRegistration.o dom_util.o DOMMouseListenerImpl.o - ${MKSHLIB} -o ${DLLNAME} jni_util.o jni_util_export.o rdf_util.o NativeEventThread.o BookmarksImpl.o CurrentPageImpl.o HistoryImpl.o ISupportsPeer.o NavigationImpl.o RDFEnumeration.o RDFTreeNode.o WindowControlImpl.o WrapperFactoryImpl.o MotifBrowserControlCanvas.o gtkmozilla.o nsActions.o nsSetupRegistry.o DocumentLoaderObserverImpl.o EventRegistration.o dom_util.o DOMMouseListenerImpl.o ${LIBS} - -gtkmozilla.o: motif/gtkmozilla.cpp - ${CC} ${DEFINES} ${INCLUDE} -c motif/gtkmozilla.cpp - -MotifBrowserControlCanvasStub.o: motif/MotifBrowserControlCanvasStub.cpp - ${CC} ${STUBDEFINES} ${STUBINCLUDE} -c motif/MotifBrowserControlCanvasStub.cpp - -MotifBrowserControlCanvas.o: motif/MotifBrowserControlCanvas.cpp - ${CC} ${DEFINES} ${INCLUDE} -c motif/MotifBrowserControlCanvas.cpp - -NativeLoaderStub.o: motif/NativeLoaderStub.cpp - ${CC} ${STUBDEFINES} ${STUBINCLUDE} -c motif/NativeLoaderStub.cpp - -NativeEventThread.o: NativeEventThread.cpp - ${CC} ${DEFINES} ${INCLUDE} -c NativeEventThread.cpp - -BookmarksImpl.o: BookmarksImpl.cpp - ${CC} ${DEFINES} ${INCLUDE} -c BookmarksImpl.cpp - -CurrentPageImpl.o: CurrentPageImpl.cpp - ${CC} ${DEFINES} ${INCLUDE} -c CurrentPageImpl.cpp - -HistoryImpl.o: HistoryImpl.cpp - ${CC} ${DEFINES} ${INCLUDE} -c HistoryImpl.cpp - -ISupportsPeer.o: ISupportsPeer.cpp - ${CC} ${DEFINES} ${INCLUDE} -c ISupportsPeer.cpp - -NavigationImpl.o: NavigationImpl.cpp - ${CC} ${DEFINES} ${INCLUDE} -c NavigationImpl.cpp - -RDFEnumeration.o: RDFEnumeration.cpp - ${CC} ${DEFINES} ${INCLUDE} -c RDFEnumeration.cpp - -RDFTreeNode.o: RDFTreeNode.cpp - ${CC} ${DEFINES} ${INCLUDE} -c RDFTreeNode.cpp - -WindowControlImpl.o: WindowControlImpl.cpp - ${CC} ${DEFINES} ${INCLUDE} -c WindowControlImpl.cpp - -WrapperFactoryImpl.o: WrapperFactoryImpl.cpp - ${CC} ${DEFINES} ${INCLUDE} -c WrapperFactoryImpl.cpp - -motif/nsSetupRegistry.cpp: - cd motif - ${LN} ${MOZILLA_TOP}/../xpfe/bootstrap/nsSetupRegistry.cpp motif/nsSetupRegistry.cpp - cd .. - -#PENDING(mark): I think we should use this for the Win32 version as well... -nsSetupRegistry.o: motif/nsSetupRegistry.cpp - ${CC} ${DEFINES} ${INCLUDE} -c motif/nsSetupRegistry.cpp - -nsActions.o: nsActions.cpp - ${CC} ${DEFINES} ${INCLUDE} -c nsActions.cpp - -dom_util.o: dom_util.cpp - ${CC} ${DEFINES} ${INCLUDE} -c dom_util.cpp - -DOMMouseListenerImpl.o: DOMMouseListenerImpl.cpp - ${CC} ${DEFINES} ${INCLUDE} -c DOMMouseListenerImpl.cpp - -DocumentLoaderObserverImpl.o: DocumentLoaderObserverImpl.cpp - ${CC} ${DEFINES} ${INCLUDE} -c DocumentLoaderObserverImpl.cpp - -EventRegistration.o: EventRegistration.cpp - ${CC} ${DEFINES} ${INCLUDE} -c EventRegistration.cpp - -jni_util.o: jni_util.cpp - ${CC} ${DEFINES} ${INCLUDE} -c jni_util.cpp - -jni_util_export.o: jni_util_export.cpp - ${CC} ${DEFINES} ${INCLUDE} -c jni_util_export.cpp - -bal_util.o: bal_util.cpp - ${CC} ${DEFINES} ${INCLUDE} -c bal_util.cpp - -rdf_util.o: rdf_util.cpp - ${CC} ${DEFINES} ${INCLUDE} -c rdf_util.cpp - -clean: - rm -f component.reg components *.o *.so *~ motif/*~ motif/nsSetupRegistry.cpp diff --git a/mozilla/java/webclient/src_moz/Makefile.win b/mozilla/java/webclient/src_moz/Makefile.win index 0a70fcf062d..5503cd9d8b3 100644 --- a/mozilla/java/webclient/src_moz/Makefile.win +++ b/mozilla/java/webclient/src_moz/Makefile.win @@ -28,8 +28,8 @@ MODULE=webclient OBJS = \ - .\$(OBJDIR)\jni_util.obj \ - .\$(OBJDIR)\jni_util_export.obj \ + .\$(OBJDIR)\ns_util.obj \ + .\$(OBJDIR)\ns_util_export.obj \ .\$(OBJDIR)\rdf_util.obj \ .\$(OBJDIR)\dom_util.obj \ .\$(OBJDIR)\nsActions.obj \ @@ -47,13 +47,6 @@ OBJS = \ .\$(OBJDIR)\nsSetupRegistry.obj \ $(NULL) -!ifdef BAL_INTERFACE -OBJS = \ - .\$(OBJDIR)\bal_util.obj \ - $(OBJS) \ - $(NULL) -!endif - LCFLAGS = \ -DDEBUG_RAPTOR_CANVAS \ @@ -82,6 +75,7 @@ LLIBS = \ $(DIST)\lib\nspr4.lib \ $(DIST)\lib\plc4.lib \ $(DIST)\lib\plds4.lib \ + $(DIST)\lib\wc_share.lib \ # $(DEPTH)\xpfe\bootstrap\$(OBJDIR)\nsSetupRegistry.obj \ $(NULL) @@ -110,6 +104,10 @@ INCS = \ $(NULL) !endif +INCS = \ + -I..\src_share \ + $(INCS) \ + $(NULL) !CMDSWITCHES -S diff --git a/mozilla/java/webclient/src_moz/NativeEventThread.cpp b/mozilla/java/webclient/src_moz/NativeEventThread.cpp index a25058c4fa8..db7aaf1043d 100644 --- a/mozilla/java/webclient/src_moz/NativeEventThread.cpp +++ b/mozilla/java/webclient/src_moz/NativeEventThread.cpp @@ -29,7 +29,7 @@ #include "NativeEventThread.h" #include "CBrowserContainer.h" -#include "jni_util.h" +#include "ns_util.h" #include "ns_globals.h" #include "nsIServiceManager.h" // for NS_InitXPCOM @@ -49,7 +49,7 @@ #include "nsAppShellCIDs.h" // for NS_SESSIONHISTORY_CID #include "nsCOMPtr.h" // to get nsIBaseWindow from webshell -//nsIDocShell is included in jni_util.h +//nsIDocShell is included in ns_util.h #include "nsIEventQueueService.h" // for PLEventQueue #include "nsRepository.h" #include "nsIServiceManager.h" // for do_GetService @@ -61,7 +61,7 @@ #include "nsCWebBrowser.h" #include "nsIEventQueueService.h" #include "nsIThread.h" -//nsIWebShell is included in jni_util.h +//nsIWebShell is included in ns_util.h #include "prlog.h" // for PR_ASSERT @@ -196,7 +196,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NativeEventThr "NULL webShellPtr passed to nativeInitialize."); return; } - if (nsnull == gVm) { // declared in jni_util.h + if (nsnull == gVm) { // declared in ../src_share/jni_util.h ::util_GetJavaVM(env, &gVm); // save this vm reference } @@ -310,7 +310,6 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NativeEventThr return; } - JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NativeEventThread_nativeRemoveListener (JNIEnv *env, jobject obj, jint webShellPtr, jobject typedListener) diff --git a/mozilla/java/webclient/src_moz/NavigationImpl.cpp b/mozilla/java/webclient/src_moz/NavigationImpl.cpp index 1b9c1d535c5..4abe6b6e276 100644 --- a/mozilla/java/webclient/src_moz/NavigationImpl.cpp +++ b/mozilla/java/webclient/src_moz/NavigationImpl.cpp @@ -28,7 +28,7 @@ #include "NavigationImpl.h" -#include "jni_util.h" +#include "ns_util.h" #include "nsActions.h" diff --git a/mozilla/java/webclient/src_moz/RDFEnumeration.cpp b/mozilla/java/webclient/src_moz/RDFEnumeration.cpp index 9ad7a920d4c..3f88ec593e3 100644 --- a/mozilla/java/webclient/src_moz/RDFEnumeration.cpp +++ b/mozilla/java/webclient/src_moz/RDFEnumeration.cpp @@ -24,7 +24,7 @@ #include "rdf_util.h" #include "rdf_progids.h" -#include "jni_util.h" +#include "ns_util.h" #include "nsIRDFContainer.h" #include "nsIServiceManager.h" diff --git a/mozilla/java/webclient/src_moz/RDFTreeNode.cpp b/mozilla/java/webclient/src_moz/RDFTreeNode.cpp index 728de927911..3fb29d7de0b 100644 --- a/mozilla/java/webclient/src_moz/RDFTreeNode.cpp +++ b/mozilla/java/webclient/src_moz/RDFTreeNode.cpp @@ -24,7 +24,7 @@ #include "rdf_util.h" #include "rdf_progids.h" -#include "jni_util.h" +#include "ns_util.h" #include "nsIServiceManager.h" diff --git a/mozilla/java/webclient/src_moz/WindowControlImpl.cpp b/mozilla/java/webclient/src_moz/WindowControlImpl.cpp index 1256bdda1c7..8c5b5a238c5 100644 --- a/mozilla/java/webclient/src_moz/WindowControlImpl.cpp +++ b/mozilla/java/webclient/src_moz/WindowControlImpl.cpp @@ -27,8 +27,7 @@ */ #include "WindowControlImpl.h" -#include -#include "jni_util.h" +#include "ns_util.h" #include "nsActions.h" #include "nsIThread.h" // for PRThread @@ -100,8 +99,8 @@ JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_WindowControlI initContext->h = height; initContext->searchContext = nsnull; initContext->currentDocument = nsnull; - initContext->propertiesClass = nsnull; initContext->browserContainer = nsnull; + util_InitializeShareInitContext(&(initContext->shareContext)); #ifdef XP_UNIX initContext->gtkWinPtr = diff --git a/mozilla/java/webclient/src_moz/WrapperFactoryImpl.cpp b/mozilla/java/webclient/src_moz/WrapperFactoryImpl.cpp index 564e2c07f56..7ab62795c6b 100644 --- a/mozilla/java/webclient/src_moz/WrapperFactoryImpl.cpp +++ b/mozilla/java/webclient/src_moz/WrapperFactoryImpl.cpp @@ -28,13 +28,13 @@ #include "WrapperFactoryImpl.h" -#include "jni_util.h" +#include "ns_util.h" #include "nsCRT.h" // for nsCRT::strcmp const char * gBinDir; -PRLogModuleInfo *prLogModuleInfo = NULL; // declared in jni_util.h +PRLogModuleInfo *prLogModuleInfo = NULL; // declared in ns_globals.h const char *gImplementedInterfaces[] = { "webclient.WindowControl", diff --git a/mozilla/java/webclient/src_moz/nsActions.cpp b/mozilla/java/webclient/src_moz/nsActions.cpp index c05221e46ab..116257f7ed1 100644 --- a/mozilla/java/webclient/src_moz/nsActions.cpp +++ b/mozilla/java/webclient/src_moz/nsActions.cpp @@ -37,7 +37,7 @@ #include "nsIURI.h" #include "nsIDocShellTreeItem.h" -#include "jni_util.h" +#include "ns_util.h" void * handleEvent (PLEvent * event); void destroyEvent (PLEvent * event); @@ -737,8 +737,8 @@ wsDeallocateInitContextEvent::handleEvent () mInitContext->browserContainer->RemoveAllListeners(); mInitContext->currentDocument = nsnull; - mInitContext->propertiesClass = nsnull; mInitContext->browserContainer = nsnull; + util_DeallocateShareInitContext(&(mInitContext->shareContext)); // delete mInitContext; diff --git a/mozilla/java/webclient/src_moz/nsActions.h b/mozilla/java/webclient/src_moz/nsActions.h index 954ba9cc143..1849047a25c 100644 --- a/mozilla/java/webclient/src_moz/nsActions.h +++ b/mozilla/java/webclient/src_moz/nsActions.h @@ -69,7 +69,7 @@ * The nsActionEvent subclass is then cast to a PLEvent struct, and * passed into either util_PostEvent() or util_PostSynchronous event, - * declared in jni_util.h. See the comments for those functions for + * declared in ns_util.h. See the comments for those functions for * information on how they deal with the nsActionEvent, cast as a * PLEvent. diff --git a/mozilla/java/webclient/src_moz/ns_util.cpp b/mozilla/java/webclient/src_moz/ns_util.cpp new file mode 100644 index 00000000000..30e6900a0e7 --- /dev/null +++ b/mozilla/java/webclient/src_moz/ns_util.cpp @@ -0,0 +1,111 @@ +/* -*- 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 + * Ian Wilkinson + * Mark Lin + * Mark Goddard + * Ed Burns + * Ashutosh Kulkarni + * Ann Sunhachawee + */ + +#include "prlog.h" // for PR_ASSERT + +#include "ns_util.h" + +void util_PostEvent(WebShellInitContext * initContext, PLEvent * event) +{ + PL_ENTER_EVENT_QUEUE_MONITOR(initContext->actionQueue); + + ::PL_PostEvent(initContext->actionQueue, event); + + PL_EXIT_EVENT_QUEUE_MONITOR(initContext->actionQueue); +} // PostEvent() + + +void *util_PostSynchronousEvent(WebShellInitContext * initContext, PLEvent * event) +{ + void * voidResult = nsnull; + + PL_ENTER_EVENT_QUEUE_MONITOR(initContext->actionQueue); + + voidResult = ::PL_PostSynchronousEvent(initContext->actionQueue, event); + + PL_EXIT_EVENT_QUEUE_MONITOR(initContext->actionQueue); + + return voidResult; +} // PostSynchronousEvent() + +#ifdef XP_UNIX +jint util_GetGTKWinPtrFromCanvas(JNIEnv *env, jobject browserControlCanvas) +{ + jint result = -1; +#ifdef BAL_INTERFACE +#else + jclass cls = env->GetObjectClass(browserControlCanvas); // Get Class for BrowserControlImpl object + jclass clz = env->FindClass("org/mozilla/webclient/BrowserControlImpl"); + if (nsnull == clz) { + ::util_ThrowExceptionToJava(env, "Exception: Could not find class for BrowserControlImpl"); + return (jint) 0; + } + jboolean ans = env->IsInstanceOf(browserControlCanvas, clz); + if (JNI_FALSE == ans) { + ::util_ThrowExceptionToJava(env, "Exception: We have a problem"); + return (jint) 0; + } + // Get myCanvas IVar + jfieldID fid = env->GetFieldID(cls, "myCanvas", "Lorg/mozilla/webclient/BrowserControlCanvas;"); + if (nsnull == fid) { + ::util_ThrowExceptionToJava(env, "Exception: field myCanvas not found in the jobject for BrowserControlImpl"); + return (jint) 0; + } + jobject canvasObj = env->GetObjectField(browserControlCanvas, fid); + jclass canvasCls = env->GetObjectClass(canvasObj); + if (nsnull == canvasCls) { + ::util_ThrowExceptionToJava(env, "Exception: Could Not find Class for CanvasObj"); + return (jint) 0; + } + jfieldID gtkfid = env->GetFieldID(canvasCls, "gtkWinPtr", "I"); + if (nsnull == gtkfid) { + ::util_ThrowExceptionToJava(env, "Exception: field gtkWinPtr not found in the jobject for BrowserControlCanvas"); + return (jint) 0; + } + result = env->GetIntField(canvasObj, gtkfid); +#endif + return result; +} +#endif + +// +// Implementations for functions defined in ../src_share/jni_util.h, but not +// implemented there. +// + +void util_LogMessage(int level, const char *fmt) +{ + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, level, (fmt)); + } +} + +void util_Assert(void *test) +{ + PR_ASSERT(test); +} diff --git a/mozilla/java/webclient/src_moz/jni_util.h b/mozilla/java/webclient/src_moz/ns_util.h similarity index 58% rename from mozilla/java/webclient/src_moz/jni_util.h rename to mozilla/java/webclient/src_moz/ns_util.h index 54be82dae71..9f9aebd529c 100644 --- a/mozilla/java/webclient/src_moz/jni_util.h +++ b/mozilla/java/webclient/src_moz/ns_util.h @@ -33,10 +33,11 @@ */ -#ifndef jni_util_h -#define jni_util_h +#ifndef ns_util_h +#define ns_util_h -#include +#include "jni_util.h" // located in ../src_share, + // pulls in ../src_share/jni_util_export.h #include "nsCOMPtr.h" // so we can save the docShell #include "nsIWebBrowser.h" @@ -97,8 +98,9 @@ struct WebShellInitContext { int gtkWinPtr; nsCOMPtr searchContext; nsCOMPtr currentDocument; - jclass propertiesClass; nsCOMPtr browserContainer; + // This struct contains all per-window information not specific to mozilla + ShareInitContext shareContext; }; enum { @@ -116,11 +118,6 @@ enum { kGetDOMWindowError }; - -extern JavaVM *gVm; // defined in jni_util.cpp - -void util_ThrowExceptionToJava (JNIEnv * env, const char * message); - /** * This method calls PL_PostEvent(), @@ -154,118 +151,9 @@ void util_PostEvent (WebShellInitContext * initContext, PLEvent * event); void * util_PostSynchronousEvent (WebShellInitContext * initContext, PLEvent * event); -/** - - * simply call the java method nativeEventOccurred on - * eventRegistrationImpl, passing webclientEventListener and eventType - * as arguments. - - */ - -void util_SendEventToJava(JNIEnv *env, jobject eventRegistrationImpl, - jobject webclientEventListener, - jlong eventType, - jobject eventData); - -char *util_GetCurrentThreadName(JNIEnv *env); - -void util_DumpJavaStack(JNIEnv *env); - -// -// Functions to wrap JNIEnv functions. -// - -#include "jni_util_export.h" - -jobject util_NewGlobalRef(JNIEnv *env, jobject toAddRef); - -void util_DeleteGlobalRef(JNIEnv *env, jobject toAddRef); - -jthrowable util_ExceptionOccurred(JNIEnv *env); - -jint util_GetJavaVM(JNIEnv *env, JavaVM **vm); - -jclass util_FindClass(JNIEnv *env, const char *fullyQualifiedClassName); - -jfieldID util_GetStaticFieldID(JNIEnv *env, jclass clazz, - const char *fieldName, - const char *signature); - -jlong util_GetStaticLongField(JNIEnv *env, jclass clazz, jfieldID id); - -jboolean util_IsInstanceOf(JNIEnv *env, jobject obj, jclass clazz); - -jint util_GetIntValueFromInstance(JNIEnv *env, jobject instance, - const char *fieldName); - -void util_SetIntValueForInstance(JNIEnv *env, jobject instance, - const char *fieldName, jint newValue); - -/** - - * A JNI wrapper to create a java.util.Properties object, or the - * equivalent object in the BAL case. - - */ - -jobject util_CreatePropertiesObject(JNIEnv *env, jobject reserved_NotUsed); - -/** - - * A JNI wrapper to destroy the object from CreatePropertiesObject - - */ - -void util_DestroyPropertiesObject(JNIEnv *env, jobject propertiesObject, - jobject reserved_NotUsed); - -/** - - * A JNI wrapper to clear the object from CreatePropertiesObject - - */ - -void util_ClearPropertiesObject(JNIEnv *env, jobject propertiesObject, - jobject reserved_NotUsed); - -/** - - * A JNI wrapper for storing a name/value pair into the Properties - * object created by CreatePropertiesObject - - */ - -void util_StoreIntoPropertiesObject(JNIEnv *env, jobject propertiesObject, - jobject name, jobject value, - jobject reserved); - - -// -// Functions from secret JDK files -// - -JNIEXPORT jvalue JNICALL -JNU_CallMethodByName(JNIEnv *env, - jboolean *hasException, - jobject obj, - const char *name, - const char *signature, - ...); - -JNIEXPORT jvalue JNICALL -JNU_CallMethodByNameV(JNIEnv *env, - jboolean *hasException, - jobject obj, - const char *name, - const char *signature, - va_list args); - -JNIEXPORT void * JNICALL -JNU_GetEnv(JavaVM *vm, jint version); - // hack functions to get around mozilla oddities #ifdef XP_UNIX jint util_GetGTKWinPtrFromCanvas(JNIEnv *env, jobject browserControlCanvas); #endif -#endif // jni_util_h +#endif // ns_util_h diff --git a/mozilla/java/webclient/src_moz/ns_util_export.cpp b/mozilla/java/webclient/src_moz/ns_util_export.cpp new file mode 100644 index 00000000000..69bc1e07809 --- /dev/null +++ b/mozilla/java/webclient/src_moz/ns_util_export.cpp @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Mozilla Public + * License Version 1.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 + * + */ + +#include "jni_util_export.h" // from ../src_share + +#include "nsHashtable.h" // PENDING(edburns): size optimization? + +static nsHashtable *gClassMappingTable = nsnull; + +// +// Implementations for functions defined in ../src_share/jni_util.h, but not +// implemented there. +// + +JNIEXPORT jint JNICALL util_StoreClassMapping(const char* jniClassName, + jclass yourClassType) +{ + if (nsnull == gClassMappingTable) { + if (nsnull == (gClassMappingTable = new nsHashtable(20, PR_TRUE))) { + return -1; + } + } + + nsStringKey key(jniClassName); + gClassMappingTable->Put(&key, yourClassType); + + return 0; +} + +JNIEXPORT jclass JNICALL util_GetClassMapping(const char* jniClassName) +{ + jclass result = nsnull; + + if (nsnull == gClassMappingTable) { + return nsnull; + } + + nsStringKey key(jniClassName); + result = (jclass) gClassMappingTable->Get(&key); + + return result; +} diff --git a/mozilla/java/webclient/src_share/Makefile.in b/mozilla/java/webclient/src_share/Makefile.in new file mode 100644 index 00000000000..89eb3571a28 --- /dev/null +++ b/mozilla/java/webclient/src_share/Makefile.in @@ -0,0 +1,46 @@ +# 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): + +DEPTH = ../../.. +topsrcdir = $(DEPTH) +srcdir = $(topsrcdir)/java/webclient/src_share +VPATH = $(topsrcdir)/java/webclient/src_share + +JAVAHOME = $(JDKHOME) + +include $(DEPTH)/config/autoconf.mk + +MODULE = webclient +LIBRARY_NAME = wc_share + +CPPSRCS = \ + jni_util.cpp \ + jni_util_export.cpp \ + $(NULL) + +ifneq ($(BAL_INTERFACE),) + CPPSRCS += bal_util.cpp +endif + +override NO_SHARED_LIB=1 +override NO_STATIC_LIB= + +include $(topsrcdir)/config/rules.mk + +INCLUDES := -I$(JDKHOME)/include -I$(JDKHOME)/include/solaris $(INCLUDES) diff --git a/mozilla/java/webclient/src_share/Makefile.win b/mozilla/java/webclient/src_share/Makefile.win new file mode 100644 index 00000000000..bdad70d17c4 --- /dev/null +++ b/mozilla/java/webclient/src_share/Makefile.win @@ -0,0 +1,85 @@ +#!nmake +# +# 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): + +DEPTH=..\..\.. +MODULE=wc_share +include <$(DEPTH)/config/config.mak> + +OBJS = \ + .\$(OBJDIR)\jni_util.obj \ + .\$(OBJDIR)\jni_util_export.obj \ + $(NULL) + +!ifdef BAL_INTERFACE +OBJS = \ + .\$(OBJDIR)\bal_util.obj \ + $(OBJS) \ + $(NULL) +!endif + + +LCFLAGS = \ + -DDEBUG_RAPTOR_CANVAS \ + $(NULL) + +!ifdef BAL_INTERFACE +LCFLAGS = \ + $(LCFLAGS) \ + -DBAL_INTERFACE \ + $(NULL) + +LIBRARY_NAME = wc_share_bal +!else +LIBRARY_NAME = wc_share +!endif + +LLIBS = \ + $(NULL) + +WIN_LIBS = \ + version.lib + +include <$(DEPTH)\config\rules.mak> + +!ifdef BAL_INTERFACE +INCS = \ + -I..\bal\ \ + -I..\bal\win32 \ + $(INCS) \ + $(NULL) +!else +INCS = \ + -I$(JDKHOME)\include \ + -I$(JDKHOME)\include\win32 \ + $(INCS) \ + $(NULL) +!endif + +!CMDSWITCHES -S + +install:: $(LIBRARY) + $(MAKE_INSTALL) .\$(OBJDIR)\$(LIBRARY_NAME).lib $(DIST)\lib + +clobber_all:: clobber + +clobber:: + rm -f $(DIST)\lib\$(LIBRARY_NAME).lib + diff --git a/mozilla/java/webclient/src_moz/bal_util.cpp b/mozilla/java/webclient/src_share/bal_util.cpp similarity index 100% rename from mozilla/java/webclient/src_moz/bal_util.cpp rename to mozilla/java/webclient/src_share/bal_util.cpp diff --git a/mozilla/java/webclient/src_moz/bal_util.h b/mozilla/java/webclient/src_share/bal_util.h similarity index 100% rename from mozilla/java/webclient/src_moz/bal_util.h rename to mozilla/java/webclient/src_share/bal_util.h diff --git a/mozilla/java/webclient/src_moz/jni_util.cpp b/mozilla/java/webclient/src_share/jni_util.cpp similarity index 77% rename from mozilla/java/webclient/src_moz/jni_util.cpp rename to mozilla/java/webclient/src_share/jni_util.cpp index 547030624b9..badc3016af8 100644 --- a/mozilla/java/webclient/src_moz/jni_util.cpp +++ b/mozilla/java/webclient/src_share/jni_util.cpp @@ -26,10 +26,10 @@ * Ann Sunhachawee */ -#include "prlog.h" // for PR_ASSERT - #include "jni_util.h" +#include + JavaVM *gVm = nsnull; // declared in ns_globals.h, which is included in // jni_util.h @@ -41,6 +41,17 @@ static jmethodID gPropertiesInitMethodID = nsnull; static jmethodID gPropertiesSetPropertyMethodID = nsnull; static jmethodID gPropertiesClearMethodID = nsnull; +void util_InitializeShareInitContext(void *yourInitContext) +{ + ShareInitContext *initContext = (ShareInitContext *) yourInitContext; + initContext->propertiesClass = nsnull; +} + +void util_DeallocateShareInitContext(void *yourInitContext) +{ + // right now there is nothing to deallocate +} + void util_ThrowExceptionToJava (JNIEnv * env, const char * message) { if (env->ExceptionOccurred()) { @@ -74,30 +85,6 @@ void util_ThrowExceptionToJava (JNIEnv * env, const char * message) } } // ThrowExceptionToJava() -void util_PostEvent(WebShellInitContext * initContext, PLEvent * event) -{ - PL_ENTER_EVENT_QUEUE_MONITOR(initContext->actionQueue); - - ::PL_PostEvent(initContext->actionQueue, event); - - PL_EXIT_EVENT_QUEUE_MONITOR(initContext->actionQueue); -} // PostEvent() - - -void *util_PostSynchronousEvent(WebShellInitContext * initContext, PLEvent * event) -{ - void * voidResult = nsnull; - - PL_ENTER_EVENT_QUEUE_MONITOR(initContext->actionQueue); - - voidResult = ::PL_PostSynchronousEvent(initContext->actionQueue, event); - - PL_EXIT_EVENT_QUEUE_MONITOR(initContext->actionQueue); - - return voidResult; -} // PostSynchronousEvent() - - void util_SendEventToJava(JNIEnv *yourEnv, jobject nativeEventThread, jobject webclientEventListener, jlong eventType, jobject eventData) @@ -131,10 +118,7 @@ void util_SendEventToJava(JNIEnv *yourEnv, jobject nativeEventThread, env->CallVoidMethod(nativeEventThread, mid, webclientEventListener, eventType, eventData); } else { - if (prLogModuleInfo) { - PR_LOG(prLogModuleInfo, 3, - ("cannot call the Java Method!\n")); - } + util_LogMessage(3, "cannot call the Java Method!\n"); } #endif } @@ -273,46 +257,6 @@ jboolean util_IsInstanceOf(JNIEnv *env, jobject obj, jclass clazz) return result; } -#ifdef XP_UNIX -jint util_GetGTKWinPtrFromCanvas(JNIEnv *env, jobject browserControlCanvas) -{ - jint result = -1; -#ifdef BAL_INTERFACE -#else - jclass cls = env->GetObjectClass(browserControlCanvas); // Get Class for BrowserControlImpl object - jclass clz = env->FindClass("org/mozilla/webclient/BrowserControlImpl"); - if (nsnull == clz) { - ::util_ThrowExceptionToJava(env, "Exception: Could not find class for BrowserControlImpl"); - return (jint) 0; - } - jboolean ans = env->IsInstanceOf(browserControlCanvas, clz); - if (JNI_FALSE == ans) { - ::util_ThrowExceptionToJava(env, "Exception: We have a problem"); - return (jint) 0; - } - // Get myCanvas IVar - jfieldID fid = env->GetFieldID(cls, "myCanvas", "Lorg/mozilla/webclient/BrowserControlCanvas;"); - if (nsnull == fid) { - ::util_ThrowExceptionToJava(env, "Exception: field myCanvas not found in the jobject for BrowserControlImpl"); - return (jint) 0; - } - jobject canvasObj = env->GetObjectField(browserControlCanvas, fid); - jclass canvasCls = env->GetObjectClass(canvasObj); - if (nsnull == canvasCls) { - ::util_ThrowExceptionToJava(env, "Exception: Could Not find Class for CanvasObj"); - return (jint) 0; - } - jfieldID gtkfid = env->GetFieldID(canvasCls, "gtkWinPtr", "I"); - if (nsnull == gtkfid) { - ::util_ThrowExceptionToJava(env, "Exception: field gtkWinPtr not found in the jobject for BrowserControlCanvas"); - return (jint) 0; - } - result = env->GetIntField(canvasObj, gtkfid); -#endif - return result; -} -#endif - jint util_GetIntValueFromInstance(JNIEnv *env, jobject obj, const char *fieldName) { @@ -321,19 +265,15 @@ jint util_GetIntValueFromInstance(JNIEnv *env, jobject obj, #else jclass objClass = env->GetObjectClass(obj); if (nsnull == objClass) { - if (prLogModuleInfo) { - PR_LOG(prLogModuleInfo, 3, - ("util_GetIntValueFromInstance: Can't get object class from instance.\n")); - } + util_LogMessage(3, + "util_GetIntValueFromInstance: Can't get object class from instance.\n"); return result; } jfieldID theFieldID = env->GetFieldID(objClass, fieldName, "I"); if (nsnull == theFieldID) { - if (prLogModuleInfo) { - PR_LOG(prLogModuleInfo, 3, - ("util_GetIntValueFromInstance: Can't get fieldID for fieldName.\n")); - } + util_LogMessage(3, + "util_GetIntValueFromInstance: Can't get fieldID for fieldName.\n"); return result; } @@ -349,19 +289,15 @@ void util_SetIntValueForInstance(JNIEnv *env, jobject obj, #else jclass objClass = env->GetObjectClass(obj); if (nsnull == objClass) { - if (prLogModuleInfo) { - PR_LOG(prLogModuleInfo, 3, - ("util_SetIntValueForInstance: Can't get object class from instance.\n")); - } + util_LogMessage(3, + "util_SetIntValueForInstance: Can't get object class from instance.\n"); return; } jfieldID fieldID = env->GetFieldID(objClass, fieldName, "I"); if (nsnull == fieldID) { - if (prLogModuleInfo) { - PR_LOG(prLogModuleInfo, 3, - ("util_SetIntValueForInstance: Can't get fieldID for fieldName.\n")); - } + util_LogMessage(3, + "util_SetIntValueForInstance: Can't get fieldID for fieldName.\n"); return; } @@ -377,8 +313,8 @@ jobject util_CreatePropertiesObject(JNIEnv *env, jobject initContextObj) result = externalCreatePropertiesObject(env, initContextObj); } #else - PR_ASSERT(initContextObj); - WebShellInitContext *initContext = (WebShellInitContext *) initContextObj; + util_Assert(initContextObj); + ShareInitContext *initContext = (ShareInitContext *) initContextObj; if (nsnull == initContext->propertiesClass) { if (nsnull == (initContext->propertiesClass = @@ -388,14 +324,14 @@ jobject util_CreatePropertiesObject(JNIEnv *env, jobject initContextObj) } if (nsnull == gPropertiesInitMethodID) { - PR_ASSERT(initContext->propertiesClass); + util_Assert(initContext->propertiesClass); if (nsnull == (gPropertiesInitMethodID = env->GetMethodID(initContext->propertiesClass, "", "()V"))) { return result; } } - PR_ASSERT(gPropertiesInitMethodID); + util_Assert(gPropertiesInitMethodID); result = ::util_NewGlobalRef(env, env->NewObject(initContext->propertiesClass, @@ -426,17 +362,17 @@ void util_ClearPropertiesObject(JNIEnv *env, jobject propertiesObject, externalClearPropertiesObject(env, propertiesObject, initContextObj); } #else - PR_ASSERT(initContextObj); - WebShellInitContext *initContext = (WebShellInitContext *) initContextObj; + util_Assert(initContextObj); + ShareInitContext *initContext = (ShareInitContext *) initContextObj; if (nsnull == gPropertiesClearMethodID) { - PR_ASSERT(initContext->propertiesClass); + util_Assert(initContext->propertiesClass); if (nsnull == (gPropertiesClearMethodID = env->GetMethodID(initContext->propertiesClass, "clear", "()V"))) { return; } } - PR_ASSERT(gPropertiesClearMethodID); + util_Assert(gPropertiesClearMethodID); env->CallVoidMethod(propertiesObject, gPropertiesClearMethodID); return; @@ -453,11 +389,11 @@ void util_StoreIntoPropertiesObject(JNIEnv *env, jobject propertiesObject, initContextObj); } #else - PR_ASSERT(initContextObj); - WebShellInitContext *initContext = (WebShellInitContext *) initContextObj; + util_Assert(initContextObj); + ShareInitContext *initContext = (ShareInitContext *) initContextObj; if (nsnull == gPropertiesSetPropertyMethodID) { - PR_ASSERT(initContext->propertiesClass); + util_Assert(initContext->propertiesClass); if (nsnull == (gPropertiesSetPropertyMethodID = env->GetMethodID(initContext->propertiesClass, "setProperty", @@ -465,7 +401,7 @@ void util_StoreIntoPropertiesObject(JNIEnv *env, jobject propertiesObject, return; } } - PR_ASSERT(gPropertiesSetPropertyMethodID); + util_Assert(gPropertiesSetPropertyMethodID); env->CallObjectMethod(propertiesObject, gPropertiesSetPropertyMethodID, name, value); diff --git a/mozilla/java/webclient/src_share/jni_util.h b/mozilla/java/webclient/src_share/jni_util.h new file mode 100644 index 00000000000..d8ebaed617b --- /dev/null +++ b/mozilla/java/webclient/src_share/jni_util.h @@ -0,0 +1,185 @@ +/* -*- 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 + * Ian Wilkinson + * Mark Lin + * Mark Goddard + * Ed Burns + * Ashutosh Kulkarni + * Ann Sunhachawee + */ + + +/** + + * Util methods + + */ + +#ifndef jni_util_h +#define jni_util_h + +#include + +// +// Local classes +// + +/** + + * This struct contains all non browser specific per-window data. The + * WebShellInitContext struct, in the src_moz and src_ie directories + * contains a pointer to a ShareInitContext struct. + + */ + +struct ShareInitContext { + jclass propertiesClass; +}; + +extern JavaVM *gVm; // defined in jni_util.cpp + +#ifndef nsnull +#define nsnull 0 +#endif + +void util_InitializeShareInitContext(void *initContext); +void util_DeallocateShareInitContext(void *initContext); + +void util_ThrowExceptionToJava (JNIEnv * env, const char * message); + +/** + + * simply call the java method nativeEventOccurred on + * eventRegistrationImpl, passing webclientEventListener and eventType + * as arguments. + + */ + +void util_SendEventToJava(JNIEnv *env, jobject eventRegistrationImpl, + jobject webclientEventListener, + jlong eventType, + jobject eventData); + +char *util_GetCurrentThreadName(JNIEnv *env); + +void util_DumpJavaStack(JNIEnv *env); + +// +// Functions to wrap JNIEnv functions. +// + +#include "jni_util_export.h" + +jobject util_NewGlobalRef(JNIEnv *env, jobject toAddRef); + +void util_DeleteGlobalRef(JNIEnv *env, jobject toAddRef); + +jthrowable util_ExceptionOccurred(JNIEnv *env); + +jint util_GetJavaVM(JNIEnv *env, JavaVM **vm); + +jclass util_FindClass(JNIEnv *env, const char *fullyQualifiedClassName); + +jfieldID util_GetStaticFieldID(JNIEnv *env, jclass clazz, + const char *fieldName, + const char *signature); + +jlong util_GetStaticLongField(JNIEnv *env, jclass clazz, jfieldID id); + +jboolean util_IsInstanceOf(JNIEnv *env, jobject obj, jclass clazz); + +jint util_GetIntValueFromInstance(JNIEnv *env, jobject instance, + const char *fieldName); + +void util_SetIntValueForInstance(JNIEnv *env, jobject instance, + const char *fieldName, jint newValue); + +/** + + * A JNI wrapper to create a java.util.Properties object, or the + * equivalent object in the BAL case. + + */ + +jobject util_CreatePropertiesObject(JNIEnv *env, jobject reserved_NotUsed); + +/** + + * A JNI wrapper to destroy the object from CreatePropertiesObject + + */ + +void util_DestroyPropertiesObject(JNIEnv *env, jobject propertiesObject, + jobject reserved_NotUsed); + +/** + + * A JNI wrapper to clear the object from CreatePropertiesObject + + */ + +void util_ClearPropertiesObject(JNIEnv *env, jobject propertiesObject, + jobject reserved_NotUsed); + +/** + + * A JNI wrapper for storing a name/value pair into the Properties + * object created by CreatePropertiesObject + + */ + +void util_StoreIntoPropertiesObject(JNIEnv *env, jobject propertiesObject, + jobject name, jobject value, + jobject reserved); + + +// +// Functions provided by the browser specific native code +// + +void util_LogMessage(int level, const char *fmt); + +void util_Assert(void *test); + +// +// Functions from secret JDK files +// + +JNIEXPORT jvalue JNICALL +JNU_CallMethodByName(JNIEnv *env, + jboolean *hasException, + jobject obj, + const char *name, + const char *signature, + ...); + +JNIEXPORT jvalue JNICALL +JNU_CallMethodByNameV(JNIEnv *env, + jboolean *hasException, + jobject obj, + const char *name, + const char *signature, + va_list args); + +JNIEXPORT void * JNICALL +JNU_GetEnv(JavaVM *vm, jint version); + +#endif // jni_util_h diff --git a/mozilla/java/webclient/src_moz/jni_util_export.cpp b/mozilla/java/webclient/src_share/jni_util_export.cpp similarity index 87% rename from mozilla/java/webclient/src_moz/jni_util_export.cpp rename to mozilla/java/webclient/src_share/jni_util_export.cpp index 4a918ecc3f3..dea48b602cc 100644 --- a/mozilla/java/webclient/src_moz/jni_util_export.cpp +++ b/mozilla/java/webclient/src_share/jni_util_export.cpp @@ -26,14 +26,6 @@ #include "bal_util.h" -#include "nscore.h" // for nsnull - -#include "ns_globals.h" // for prLogModuleInfo - -#include "nsHashtable.h" // PENDING(edburns): size optimization? - -static nsHashtable *gClassMappingTable = nsnull; - fpEventOccurredType externalEventOccurred = nsnull; // jni_util_export.h fpInstanceOfType externalInstanceOf = nsnull; // jni_util_export.h @@ -150,36 +142,6 @@ JNIEXPORT void JNICALL util_DeleteString(JNIEnv *env, jstring toDelete) } -JNIEXPORT jint JNICALL util_StoreClassMapping(const char* jniClassName, - jclass yourClassType) -{ - if (nsnull == gClassMappingTable) { - if (nsnull == (gClassMappingTable = new nsHashtable(20, PR_TRUE))) { - return -1; - } - } - - nsStringKey key(jniClassName); - gClassMappingTable->Put(&key, yourClassType); - - return 0; -} - -JNIEXPORT jclass JNICALL util_GetClassMapping(const char* jniClassName) -{ - jclass result = nsnull; - - if (nsnull == gClassMappingTable) { - return nsnull; - } - - nsStringKey key(jniClassName); - result = (jclass) gClassMappingTable->Get(&key); - - return result; -} - - JNIEXPORT void JNICALL util_SetEventOccurredFunction(fpEventOccurredType fp) { externalEventOccurred = fp; diff --git a/mozilla/java/webclient/src_moz/jni_util_export.h b/mozilla/java/webclient/src_share/jni_util_export.h similarity index 99% rename from mozilla/java/webclient/src_moz/jni_util_export.h rename to mozilla/java/webclient/src_share/jni_util_export.h index 41eb2bb109d..8a24dddabc1 100644 --- a/mozilla/java/webclient/src_moz/jni_util_export.h +++ b/mozilla/java/webclient/src_share/jni_util_export.h @@ -72,26 +72,6 @@ JNIEXPORT void JNICALL util_DeleteString(JNIEnv *env, jstring toDelete); */ -/** - - * This method is used to store a mapping from a jniClass Name, such as - * "org/mozilla/webclient/DocumentLoadListener" to some external class - * type, such as - * org::mozilla::webclient::wrapper_native::uno::DocumentLoadListener. - - * This table is used in util_IsInstanceOf. - - * @see util_SetInstanceOfFunction - - * @ret 0 on success - - */ - -JNIEXPORT jint JNICALL util_StoreClassMapping(const char* jniClassName, - jclass yourClassType); - -JNIEXPORT jclass JNICALL util_GetClassMapping(const char* jniClassName); - /** @@ -359,6 +339,32 @@ util_InitializeEventMaskValuesFromClass(const char *className, char *maskNames[], jlong maskValues[]); +// +// Functions provided by browser-specific native code +// + +/** + + * This method is used to store a mapping from a jniClass Name, such as + * "org/mozilla/webclient/DocumentLoadListener" to some external class + * type, such as + * org::mozilla::webclient::wrapper_native::uno::DocumentLoadListener. + + * This table is used in util_IsInstanceOf. + + * @see util_SetInstanceOfFunction + + * @ret 0 on success + + */ + +JNIEXPORT jint JNICALL util_StoreClassMapping(const char* jniClassName, + jclass yourClassType); + +JNIEXPORT jclass JNICALL util_GetClassMapping(const char* jniClassName); + + + #ifdef __cplusplus } /* extern "C" */ #endif /* __cplusplus */