Bug 573616 - [GTK] BrowserFunction only work in first browser instance
(Part 1)
Remove existing BrowserFunction implementation.
To provide synchronous BrowserFunction calls from JavaScript to Java,
SWT loads a native browser extension and communicates with it via
a private D-Bus. Existing implementation assumes a single instance of
the browser extension, but newer WebKitGTK versions create a separate
process per view, resulting in multiple extension instances.
The follow-up patch will provide an alternative BrowserFunction
implementation based on the XMLHttpRequest.
Change-Id: I74ce4ba944833ef205c409f197c5d22d2cae51fe
Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/191031
Reviewed-by: Alexander Kurtakov <akurtako@redhat.com>
Tested-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/common/org/eclipse/swt/internal/Library.java b/bundles/org.eclipse.swt/Eclipse SWT PI/common/org/eclipse/swt/internal/Library.java
index ef966e8..f861b48 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/common/org/eclipse/swt/internal/Library.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/common/org/eclipse/swt/internal/Library.java
@@ -14,10 +14,8 @@
package org.eclipse.swt.internal;
import java.io.*;
-import java.lang.reflect.*;
import java.net.*;
import java.nio.file.*;
-import java.util.function.*;
import java.util.jar.*;
public class Library {
@@ -382,105 +380,4 @@
return version;
}
-public static File findResource(String subDir, String resourceName, boolean mapResourceName){
- return findResource(subDir, resourceName, mapResourceName, true, true);
-}
-/**
- * Locates a resource located either in java library path, swt library path, or attempts to extract it from inside swt.jar file.
- * This function supports a single level subfolder, e.g SubFolder/resource.
- *
- * Dev note: (17/12/07) This has been developed and throughly tested on GTK. Designed to work on Cocoa/Win as well, but not tested.
- *
- * @param subDir 'null' or a folder name without slashes. E.g Correct: 'mysubdir', incorrect: '/subdir/'.
- * Platform specific Slashes will be added automatically.
- * @param resourceName e.g swt-webkitgtk
- * @param mapResourceName true if you like platform specific mapping applied to resource name. e.g MyLib -> libMyLib-gtk-4826.so
- */
-public static File findResource(String subDir, String resourceName, boolean mapResourceName, boolean replaceDylib, boolean searchInOsgi){
-
- //We construct a 'maybe' subdirectory path. 'Maybe' because if no subDir given, then it's an empty string "".
- // subdir e.g: subdir
- String maybeSubDirPath = subDir != null ? subDir + SEPARATOR : ""; // e.g: subdir/ or ""
- String maybeSubDirPathWithPrefix = subDir != null ? SEPARATOR + maybeSubDirPath : ""; // e.g: /subdir/ or ""
- final String finalResourceName = mapResourceName ?
- mapLibraryName(resourceName + "-" + Platform.PLATFORM + "-" + getVersionString (), replaceDylib) // e.g libMyLib-gtk-3826.so
- : resourceName;
-
- // 1) Look for the resource in the java/swt library path(s)
- // This code commonly finds the resource if the swt project is a required project and the swt binary (for your platform)
- // project is open in your workplace (found in the JAVA_LIBRARY_PATH) or if you're explicitly specified SWT_LIBRARY_PATH.
- {
- Function<String, File> lookForFileInPath = searchPath -> {
- String classpath = System.getProperty(searchPath);
- if (classpath != null){
- String[] paths = classpath.split(File.pathSeparator);
- for (String path : paths) {
- File file = new File(path + SEPARATOR + maybeSubDirPath + finalResourceName);
- if (file.exists()){
- return file;
- }
- }
- }
- return null;
- };
- File result = null;
- for (String path : new String[] {JAVA_LIB_PATH,SWT_LIB_PATH}) {
- result = lookForFileInPath.apply(path);
- if (result != null)
- return result;
- }
- }
-
- // 2) If SWT is ran as OSGI bundle (e.g inside Eclipse), then local resources are extracted to
- // eclipse/configuration/org.eclipse.osgi/NN/N/.cp/<resource> and we're given a pointer to the file.
- if (searchInOsgi) {
- // If this is an OSGI bundle look for the resource using getResource
- URL url = Library.class.getClassLoader().getResource(maybeSubDirPathWithPrefix + finalResourceName);
- URLConnection connection;
- try {
- connection = url.openConnection();
- Method getFileURLMethod = connection.getClass().getMethod("getFileURL");
- if (getFileURLMethod != null){
- // This method does the actual extraction of file to: ../eclipse/configuration/org.eclipse.osgi/NN/N/.cp/<SubDir>/resource.ext
- URL result = (URL) getFileURLMethod.invoke(connection);
- return new File(result.toURI());
- }
- } catch (Exception e) {
- // If any exceptions are thrown the resource cannot be located this way.
- }
- }
-
- // 3) Need to try to pull the resource out of the swt.jar.
- // Look for the resource in the user's home directory, (if already extracted in the temp swt folder. (~/.swt/lib...)
- // Extract from the swt.jar if not there already.
- {
- // Developer note:
- // To test this piece of code, you need to compile SWT into a jar and use it in a test project. E.g
- // cd ~/git/eclipse.platform.swt.binaries/bundles/org.eclipse.swt.gtk.linux.x86_64/
- // mvn clean verify -Pbuild-individual-bundles -Dnative=gtk.linux.x86_64
- // then ./target/ will contain org.eclipse.swt.gtk.linux.x86_64-3.106.100-SNAPSHOT.jar (and it's source),
- // you can copy those into your test swt project and test that your resource is extracted into something like ~/.swt/...
- // Lastly, if using subDir, you need to edit the build.properties and specify the folder you wish to have included in your jar in the includes.
- File file = new File (USER_HOME + SEPARATOR + SWT_LIB_DIR + maybeSubDirPathWithPrefix, finalResourceName);
- if (file.exists()){
- return file;
- } else { // Try to extract file from jar if not found.
-
- // Create temp directory if it doesn't exist
- File tempDir = new File (USER_HOME, SWT_LIB_DIR + maybeSubDirPathWithPrefix);
- if ((!tempDir.exists () || tempDir.isDirectory ())) {
- tempDir.mkdirs ();
- }
-
- if (extract(file.getPath(), maybeSubDirPath + finalResourceName)) {
- if (file.exists()) {
- return file;
- }
- }
- }
- }
- throw new UnsatisfiedLinkError("Could not find resource " + resourceName + (subDir != null ? " (in subdirectory: " + subDir + " )" : ""));
-}
-
-
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/build.sh b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/build.sh
index 6b42239..d1694a9 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/build.sh
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/build.sh
@@ -265,14 +265,6 @@
func_build_gtk4 () {
export GTK_VERSION=4.0
- # Dictate Webkit2 Extension only if pkg-config flags exist
- pkg-config --exists webkit2gtk-web-extension-4.0
- if [ $? = 0 ]; then
- export BUILD_WEBKIT2EXTENSION="yes";
- else
- func_echo_error "Warning: Cannot compile Webkit2 Extension because 'pkg-config --exists webkit2gtk-web-extension-4.0' check failed. Please install webkitgtk4-devel.ARCH on your system."
- fi
-
func_echo_plus "Building GTK4 bindings:"
${MAKE_TYPE} -f $MAKEFILE all $MAKE_CAIRO $MAKE_AWT "${@}"
RETURN_VALUE=$? #make can return 1 or 2 if it fails. Thus need to cache it in case it's used programmatically somewhere.
@@ -287,14 +279,6 @@
func_build_gtk3 () {
export GTK_VERSION=3.0
- # Dictate Webkit2 Extension only if pkg-config flags exist
- pkg-config --exists webkit2gtk-web-extension-4.0
- if [ $? = 0 ]; then
- export BUILD_WEBKIT2EXTENSION="yes";
- else
- func_echo_error "Warning: Cannot compile Webkit2 Extension because 'pkg-config --exists webkit2gtk-web-extension-4.0' check failed. Please install webkitgtk4-devel.ARCH on your system."
- fi
-
func_echo_plus "Building GTK3 bindings:"
${MAKE_TYPE} -f $MAKEFILE all $MAKE_CAIRO $MAKE_AWT "${@}"
RETURN_VALUE=$? #make can return 1 or 2 if it fails. Thus need to cache it in case it's used programmatically somewhere.
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/make_linux.mak b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/make_linux.mak
index 749a6d0..65c168f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/make_linux.mak
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/make_linux.mak
@@ -41,7 +41,6 @@
CAIRO_PREFIX = swt-cairo
ATK_PREFIX = swt-atk
WEBKIT_PREFIX = swt-webkit
-WEBKIT_EXTENSION_PREFIX=swt-webkit2extension
GLX_PREFIX = swt-glx
SWT_LIB = lib$(SWT_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so
@@ -53,11 +52,6 @@
WEBKIT_LIB = lib$(WEBKIT_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so
ALL_SWT_LIBS = $(SWT_LIB) $(AWT_LIB) $(SWTPI_LIB) $(CAIRO_LIB) $(ATK_LIB) $(GLX_LIB) $(WEBKIT_LIB)
-# Webkit extension lib has to be put into a separate folder and is treated differently from the other libraries.
-WEBKIT_EXTENSION_LIB = lib$(WEBKIT_EXTENSION_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so
-WEBEXTENSION_BASE_DIR = webkitextensions
-WEBEXTENSION_DIR = $(WEBEXTENSION_BASE_DIR)$(maj_ver)$(min_ver)r$(rev)
-
CAIROCFLAGS = `pkg-config --cflags cairo`
CAIROLIBS = `pkg-config --libs-only-L cairo` -lcairo
@@ -85,9 +79,6 @@
WEBKITLIBS = `pkg-config --libs-only-l gio-2.0`
WEBKITCFLAGS = `pkg-config --cflags gio-2.0`
-WEBKIT_EXTENSION_CFLAGS=`pkg-config --cflags gtk+-3.0 webkit2gtk-web-extension-4.0`
-WEBKIT_EXTENSION_LFLAGS=`pkg-config --libs gtk+-3.0 webkit2gtk-web-extension-4.0`
-
ifdef SWT_WEBKIT_DEBUG
# don't use 'webkit2gtk-4.0' in production, as some systems might not have those libs and we get crashes.
WEBKITLIBS += `pkg-config --libs-only-l webkit2gtk-4.0`
@@ -215,11 +206,7 @@
#
# WebKit lib
#
-ifeq ($(BUILD_WEBKIT2EXTENSION),yes)
-make_webkit: $(WEBKIT_LIB) make_webkit2extension
-else
make_webkit: $(WEBKIT_LIB)
-endif
$(WEBKIT_LIB): $(WEBKIT_OBJECTS)
$(CC) $(LFLAGS) -o $(WEBKIT_LIB) $(WEBKIT_OBJECTS) $(WEBKITLIBS)
@@ -236,16 +223,6 @@
webkitgtk_custom.o: webkitgtk_custom.c
$(CC) $(CFLAGS) $(WEBKITCFLAGS) -c webkitgtk_custom.c
-
-# Webkit2 extension is a seperate .so lib.
-make_webkit2extension: $(WEBKIT_EXTENSION_LIB)
-
-$(WEBKIT_EXTENSION_LIB) : webkitgtk_extension.o
- $(CC) $(LFLAGS) -o $@ $^ $(WEBKIT_EXTENSION_LFLAGS)
-
-webkitgtk_extension.o : webkitgtk_extension.c
- $(CC) $(CFLAGS) $(WEBKIT_EXTENSION_CFLAGS) ${SWT_PTR_CFLAGS} -fPIC -c $^
-
#
# GLX lib
#
@@ -275,16 +252,6 @@
# I hope there are no spaces in the path :-).
install: all
cp $(ALL_SWT_LIBS) $(OUTPUT_DIR)
-ifeq ($(BUILD_WEBKIT2EXTENSION),yes)
- @# Copy webextension into it's own folder, but create folder first.
- @# CAREFULLY delete '.so' files inside webextension*. Then carefully remove the directories. 'rm -rf' seemed too risky of an approach.
- @-[ "$$(ls -d $(OUTPUT_DIR)/$(WEBEXTENSION_BASE_DIR)*/*.so)" ] && rm -v `ls -d $(OUTPUT_DIR)/$(WEBEXTENSION_BASE_DIR)*/*.so`
- @-[ "$$(ls -d $(OUTPUT_DIR)/$(WEBEXTENSION_BASE_DIR)*)" ] && rmdir -v `ls -d $(OUTPUT_DIR)/$(WEBEXTENSION_BASE_DIR)*`
-
- @# Copying webextension is not critical for build to succeed, thus we use '-'. SWT can still function without a webextension.
- @-[ -d $(OUTPUT_DIR)/$(WEBEXTENSION_DIR) ] || mkdir -v $(OUTPUT_DIR)/$(WEBEXTENSION_DIR) # If folder does not exist, make it.
- -cp $(WEBKIT_EXTENSION_LIB) $(OUTPUT_DIR)/$(WEBEXTENSION_DIR)/
-endif
#
# Clean
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
index b981a04..6765f62 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
@@ -11172,34 +11172,6 @@
}
#endif
-#ifndef NO_g_1credentials_1is_1same_1user
-JNIEXPORT jboolean JNICALL OS_NATIVE(g_1credentials_1is_1same_1user)
- (JNIEnv *env, jclass that, jlong arg0, jlong arg1, jlongArray arg2)
-{
- jlong *lparg2=NULL;
- jboolean rc = 0;
- OS_NATIVE_ENTER(env, that, g_1credentials_1is_1same_1user_FUNC);
- if (arg2) if ((lparg2 = (*env)->GetLongArrayElements(env, arg2, NULL)) == NULL) goto fail;
- rc = (jboolean)g_credentials_is_same_user((GCredentials *)arg0, (GCredentials *)arg1, (GError **)lparg2);
-fail:
- if (arg2 && lparg2) (*env)->ReleaseLongArrayElements(env, arg2, lparg2, 0);
- OS_NATIVE_EXIT(env, that, g_1credentials_1is_1same_1user_FUNC);
- return rc;
-}
-#endif
-
-#ifndef NO_g_1credentials_1new
-JNIEXPORT jlong JNICALL OS_NATIVE(g_1credentials_1new)
- (JNIEnv *env, jclass that)
-{
- jlong rc = 0;
- OS_NATIVE_ENTER(env, that, g_1credentials_1new_FUNC);
- rc = (jlong)g_credentials_new();
- OS_NATIVE_EXIT(env, that, g_1credentials_1new_FUNC);
- return rc;
-}
-#endif
-
#ifndef NO_g_1date_1time_1get_1ymd
JNIEXPORT void JNICALL OS_NATIVE(g_1date_1time_1get_1ymd)
(JNIEnv *env, jclass that, jlong arg0, jintArray arg1, jintArray arg2, jintArray arg3)
@@ -11242,143 +11214,6 @@
}
#endif
-#ifndef NO_g_1dbus_1auth_1observer_1new
-JNIEXPORT jlong JNICALL OS_NATIVE(g_1dbus_1auth_1observer_1new)
- (JNIEnv *env, jclass that)
-{
- jlong rc = 0;
- OS_NATIVE_ENTER(env, that, g_1dbus_1auth_1observer_1new_FUNC);
- rc = (jlong)g_dbus_auth_observer_new();
- OS_NATIVE_EXIT(env, that, g_1dbus_1auth_1observer_1new_FUNC);
- return rc;
-}
-#endif
-
-#ifndef NO_g_1dbus_1connection_1call
-JNIEXPORT void JNICALL OS_NATIVE(g_1dbus_1connection_1call)
- (JNIEnv *env, jclass that, jlong arg0, jbyteArray arg1, jbyteArray arg2, jbyteArray arg3, jbyteArray arg4, jlong arg5, jlong arg6, jint arg7, jint arg8, jlong arg9, jlong arg10, jlong arg11)
-{
- jbyte *lparg1=NULL;
- jbyte *lparg2=NULL;
- jbyte *lparg3=NULL;
- jbyte *lparg4=NULL;
- OS_NATIVE_ENTER(env, that, g_1dbus_1connection_1call_FUNC);
- if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
- if (arg2) if ((lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL)) == NULL) goto fail;
- if (arg3) if ((lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL)) == NULL) goto fail;
- if (arg4) if ((lparg4 = (*env)->GetByteArrayElements(env, arg4, NULL)) == NULL) goto fail;
- g_dbus_connection_call((GDBusConnection *)arg0, (const gchar *)lparg1, (const gchar *)lparg2, (const gchar *)lparg3, (const gchar *)lparg4, (GVariant *)arg5, (const GVariantType *)arg6, arg7, arg8, (GCancellable *)arg9, (GAsyncReadyCallback)arg10, (gpointer)arg11);
-fail:
- if (arg4 && lparg4) (*env)->ReleaseByteArrayElements(env, arg4, lparg4, 0);
- if (arg3 && lparg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0);
- if (arg2 && lparg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
- if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
- OS_NATIVE_EXIT(env, that, g_1dbus_1connection_1call_FUNC);
-}
-#endif
-
-#ifndef NO_g_1dbus_1connection_1call_1finish
-JNIEXPORT jlong JNICALL OS_NATIVE(g_1dbus_1connection_1call_1finish)
- (JNIEnv *env, jclass that, jlong arg0, jlong arg1, jlongArray arg2)
-{
- jlong *lparg2=NULL;
- jlong rc = 0;
- OS_NATIVE_ENTER(env, that, g_1dbus_1connection_1call_1finish_FUNC);
- if (arg2) if ((lparg2 = (*env)->GetLongArrayElements(env, arg2, NULL)) == NULL) goto fail;
- rc = (jlong)g_dbus_connection_call_finish((GDBusConnection *)arg0, (GAsyncResult *)arg1, (GError **)lparg2);
-fail:
- if (arg2 && lparg2) (*env)->ReleaseLongArrayElements(env, arg2, lparg2, 0);
- OS_NATIVE_EXIT(env, that, g_1dbus_1connection_1call_1finish_FUNC);
- return rc;
-}
-#endif
-
-#ifndef NO_g_1dbus_1connection_1call_1sync
-JNIEXPORT jlong JNICALL OS_NATIVE(g_1dbus_1connection_1call_1sync)
- (JNIEnv *env, jclass that, jlong arg0, jbyteArray arg1, jbyteArray arg2, jbyteArray arg3, jbyteArray arg4, jlong arg5, jlong arg6, jint arg7, jint arg8, jlong arg9, jlongArray arg10)
-{
- jbyte *lparg1=NULL;
- jbyte *lparg2=NULL;
- jbyte *lparg3=NULL;
- jbyte *lparg4=NULL;
- jlong *lparg10=NULL;
- jlong rc = 0;
- OS_NATIVE_ENTER(env, that, g_1dbus_1connection_1call_1sync_FUNC);
- if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
- if (arg2) if ((lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL)) == NULL) goto fail;
- if (arg3) if ((lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL)) == NULL) goto fail;
- if (arg4) if ((lparg4 = (*env)->GetByteArrayElements(env, arg4, NULL)) == NULL) goto fail;
- if (arg10) if ((lparg10 = (*env)->GetLongArrayElements(env, arg10, NULL)) == NULL) goto fail;
- rc = (jlong)g_dbus_connection_call_sync((GDBusConnection *)arg0, (const gchar *)lparg1, (const gchar *)lparg2, (const gchar *)lparg3, (const gchar *)lparg4, (GVariant *)arg5, (const GVariantType *)arg6, arg7, arg8, (GCancellable *)arg9, (GError **)lparg10);
-fail:
- if (arg10 && lparg10) (*env)->ReleaseLongArrayElements(env, arg10, lparg10, 0);
- if (arg4 && lparg4) (*env)->ReleaseByteArrayElements(env, arg4, lparg4, 0);
- if (arg3 && lparg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0);
- if (arg2 && lparg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
- if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
- OS_NATIVE_EXIT(env, that, g_1dbus_1connection_1call_1sync_FUNC);
- return rc;
-}
-#endif
-
-#ifndef NO_g_1dbus_1connection_1close_1sync
-JNIEXPORT jboolean JNICALL OS_NATIVE(g_1dbus_1connection_1close_1sync)
- (JNIEnv *env, jclass that, jlong arg0, jlong arg1, jlongArray arg2)
-{
- jlong *lparg2=NULL;
- jboolean rc = 0;
- OS_NATIVE_ENTER(env, that, g_1dbus_1connection_1close_1sync_FUNC);
- if (arg2) if ((lparg2 = (*env)->GetLongArrayElements(env, arg2, NULL)) == NULL) goto fail;
- rc = (jboolean)g_dbus_connection_close_sync((GDBusConnection *)arg0, (GCancellable *)arg1, (GError **)lparg2);
-fail:
- if (arg2 && lparg2) (*env)->ReleaseLongArrayElements(env, arg2, lparg2, 0);
- OS_NATIVE_EXIT(env, that, g_1dbus_1connection_1close_1sync_FUNC);
- return rc;
-}
-#endif
-
-#ifndef NO_g_1dbus_1connection_1is_1closed
-JNIEXPORT jboolean JNICALL OS_NATIVE(g_1dbus_1connection_1is_1closed)
- (JNIEnv *env, jclass that, jlong arg0)
-{
- jboolean rc = 0;
- OS_NATIVE_ENTER(env, that, g_1dbus_1connection_1is_1closed_FUNC);
- rc = (jboolean)g_dbus_connection_is_closed((GDBusConnection *)arg0);
- OS_NATIVE_EXIT(env, that, g_1dbus_1connection_1is_1closed_FUNC);
- return rc;
-}
-#endif
-
-#ifndef NO_g_1dbus_1connection_1new_1for_1address
-JNIEXPORT void JNICALL OS_NATIVE(g_1dbus_1connection_1new_1for_1address)
- (JNIEnv *env, jclass that, jbyteArray arg0, jint arg1, jlong arg2, jlong arg3, jlong arg4, jlong arg5)
-{
- jbyte *lparg0=NULL;
- OS_NATIVE_ENTER(env, that, g_1dbus_1connection_1new_1for_1address_FUNC);
- if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
- g_dbus_connection_new_for_address((const gchar *)lparg0, arg1, (GDBusAuthObserver *)arg2, (GCancellable *)arg3, (GAsyncReadyCallback)arg4, (gpointer)arg5);
-fail:
- if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
- OS_NATIVE_EXIT(env, that, g_1dbus_1connection_1new_1for_1address_FUNC);
-}
-#endif
-
-#ifndef NO_g_1dbus_1connection_1new_1for_1address_1finish
-JNIEXPORT jlong JNICALL OS_NATIVE(g_1dbus_1connection_1new_1for_1address_1finish)
- (JNIEnv *env, jclass that, jlong arg0, jlongArray arg1)
-{
- jlong *lparg1=NULL;
- jlong rc = 0;
- OS_NATIVE_ENTER(env, that, g_1dbus_1connection_1new_1for_1address_1finish_FUNC);
- if (arg1) if ((lparg1 = (*env)->GetLongArrayElements(env, arg1, NULL)) == NULL) goto fail;
- rc = (jlong)g_dbus_connection_new_for_address_finish((GAsyncResult *)arg0, (GError **)lparg1);
-fail:
- if (arg1 && lparg1) (*env)->ReleaseLongArrayElements(env, arg1, lparg1, 0);
- OS_NATIVE_EXIT(env, that, g_1dbus_1connection_1new_1for_1address_1finish_FUNC);
- return rc;
-}
-#endif
-
#ifndef NO_g_1dbus_1connection_1register_1object
JNIEXPORT jint JNICALL OS_NATIVE(g_1dbus_1connection_1register_1object)
(JNIEnv *env, jclass that, jlong arg0, jbyteArray arg1, jlong arg2, jlongArray arg3, jlong arg4, jlong arg5, jlongArray arg6)
@@ -11401,18 +11236,6 @@
}
#endif
-#ifndef NO_g_1dbus_1generate_1guid
-JNIEXPORT jlong JNICALL OS_NATIVE(g_1dbus_1generate_1guid)
- (JNIEnv *env, jclass that)
-{
- jlong rc = 0;
- OS_NATIVE_ENTER(env, that, g_1dbus_1generate_1guid_FUNC);
- rc = (jlong)g_dbus_generate_guid();
- OS_NATIVE_EXIT(env, that, g_1dbus_1generate_1guid_FUNC);
- return rc;
-}
-#endif
-
#ifndef NO_g_1dbus_1method_1invocation_1return_1value
JNIEXPORT void JNICALL OS_NATIVE(g_1dbus_1method_1invocation_1return_1value)
(JNIEnv *env, jclass that, jlong arg0, jlong arg1)
@@ -11531,54 +11354,6 @@
}
#endif
-#ifndef NO_g_1dbus_1server_1get_1client_1address
-JNIEXPORT jlong JNICALL OS_NATIVE(g_1dbus_1server_1get_1client_1address)
- (JNIEnv *env, jclass that, jlong arg0)
-{
- jlong rc = 0;
- OS_NATIVE_ENTER(env, that, g_1dbus_1server_1get_1client_1address_FUNC);
- rc = (jlong)g_dbus_server_get_client_address((GDBusServer *)arg0);
- OS_NATIVE_EXIT(env, that, g_1dbus_1server_1get_1client_1address_FUNC);
- return rc;
-}
-#endif
-
-#ifndef NO_g_1dbus_1server_1new_1sync
-JNIEXPORT jlong JNICALL OS_NATIVE(g_1dbus_1server_1new_1sync)
- (JNIEnv *env, jclass that, jlong arg0, jint arg1, jlong arg2, jlong arg3, jlong arg4, jlongArray arg5)
-{
- jlong *lparg5=NULL;
- jlong rc = 0;
- OS_NATIVE_ENTER(env, that, g_1dbus_1server_1new_1sync_FUNC);
- if (arg5) if ((lparg5 = (*env)->GetLongArrayElements(env, arg5, NULL)) == NULL) goto fail;
- rc = (jlong)g_dbus_server_new_sync((const gchar *)arg0, (GDBusServerFlags)arg1, (const gchar *)arg2, (GDBusAuthObserver *)arg3, (GCancellable *)arg4, (GError **)lparg5);
-fail:
- if (arg5 && lparg5) (*env)->ReleaseLongArrayElements(env, arg5, lparg5, 0);
- OS_NATIVE_EXIT(env, that, g_1dbus_1server_1new_1sync_FUNC);
- return rc;
-}
-#endif
-
-#ifndef NO_g_1dbus_1server_1start
-JNIEXPORT void JNICALL OS_NATIVE(g_1dbus_1server_1start)
- (JNIEnv *env, jclass that, jlong arg0)
-{
- OS_NATIVE_ENTER(env, that, g_1dbus_1server_1start_FUNC);
- g_dbus_server_start((GDBusServer *)arg0);
- OS_NATIVE_EXIT(env, that, g_1dbus_1server_1start_FUNC);
-}
-#endif
-
-#ifndef NO_g_1dbus_1server_1stop
-JNIEXPORT void JNICALL OS_NATIVE(g_1dbus_1server_1stop)
- (JNIEnv *env, jclass that, jlong arg0)
-{
- OS_NATIVE_ENTER(env, that, g_1dbus_1server_1stop_FUNC);
- g_dbus_server_stop((GDBusServer *)arg0);
- OS_NATIVE_EXIT(env, that, g_1dbus_1server_1stop_FUNC);
-}
-#endif
-
#ifndef NO_g_1dir_1make_1tmp
JNIEXPORT jlong JNICALL OS_NATIVE(g_1dir_1make_1tmp)
(JNIEnv *env, jclass that, jlong arg0, jlongArray arg1)
@@ -11870,18 +11645,6 @@
G_GNUC_END_IGNORE_DEPRECATIONS
#endif
-#ifndef NO_g_1get_1user_1name
-JNIEXPORT jlong JNICALL OS_NATIVE(g_1get_1user_1name)
- (JNIEnv *env, jclass that)
-{
- jlong rc = 0;
- OS_NATIVE_ENTER(env, that, g_1get_1user_1name_FUNC);
- rc = (jlong)g_get_user_name();
- OS_NATIVE_EXIT(env, that, g_1get_1user_1name_FUNC);
- return rc;
-}
-#endif
-
#ifndef NO_g_1getenv
JNIEXPORT jlong JNICALL OS_NATIVE(g_1getenv)
(JNIEnv *env, jclass that, jbyteArray arg0)
@@ -12923,30 +12686,6 @@
}
#endif
-#ifndef NO_g_1strconcat__JJJ
-JNIEXPORT jlong JNICALL OS_NATIVE(g_1strconcat__JJJ)
- (JNIEnv *env, jclass that, jlong arg0, jlong arg1, jlong arg2)
-{
- jlong rc = 0;
- OS_NATIVE_ENTER(env, that, g_1strconcat__JJJ_FUNC);
- rc = (jlong)g_strconcat((const gchar *)arg0, (const gchar *)arg1, (const gchar *)NULL);
- OS_NATIVE_EXIT(env, that, g_1strconcat__JJJ_FUNC);
- return rc;
-}
-#endif
-
-#ifndef NO_g_1strconcat__JJJJ
-JNIEXPORT jlong JNICALL OS_NATIVE(g_1strconcat__JJJJ)
- (JNIEnv *env, jclass that, jlong arg0, jlong arg1, jlong arg2, jlong arg3)
-{
- jlong rc = 0;
- OS_NATIVE_ENTER(env, that, g_1strconcat__JJJJ_FUNC);
- rc = (jlong)g_strconcat((const gchar *)arg0, (const gchar *)arg1, (const gchar *)arg2, (const gchar *)NULL);
- OS_NATIVE_EXIT(env, that, g_1strconcat__JJJJ_FUNC);
- return rc;
-}
-#endif
-
#ifndef NO_g_1strdup
JNIEXPORT jlong JNICALL OS_NATIVE(g_1strdup)
(JNIEnv *env, jclass that, jlong arg0)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
index 87bb360..bd377ce 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
@@ -961,21 +961,10 @@
"g_1closure_1unref",
"g_1content_1type_1equals",
"g_1content_1type_1is_1a",
- "g_1credentials_1is_1same_1user",
- "g_1credentials_1new",
"g_1date_1time_1get_1ymd",
"g_1date_1time_1new_1local",
"g_1date_1time_1unref",
- "g_1dbus_1auth_1observer_1new",
- "g_1dbus_1connection_1call",
- "g_1dbus_1connection_1call_1finish",
- "g_1dbus_1connection_1call_1sync",
- "g_1dbus_1connection_1close_1sync",
- "g_1dbus_1connection_1is_1closed",
- "g_1dbus_1connection_1new_1for_1address",
- "g_1dbus_1connection_1new_1for_1address_1finish",
"g_1dbus_1connection_1register_1object",
- "g_1dbus_1generate_1guid",
"g_1dbus_1method_1invocation_1return_1value",
"g_1dbus_1node_1info_1lookup_1interface",
"g_1dbus_1node_1info_1new_1for_1xml",
@@ -983,10 +972,6 @@
"g_1dbus_1proxy_1call_1sync",
"g_1dbus_1proxy_1get_1name_1owner",
"g_1dbus_1proxy_1new_1for_1bus_1sync",
- "g_1dbus_1server_1get_1client_1address",
- "g_1dbus_1server_1new_1sync",
- "g_1dbus_1server_1start",
- "g_1dbus_1server_1stop",
"g_1dir_1make_1tmp",
"g_1error_1free",
"g_1error_1get_1message",
@@ -1007,7 +992,6 @@
"g_1filename_1to_1utf8",
"g_1free",
"g_1get_1current_1time",
- "g_1get_1user_1name",
"g_1getenv",
"g_1icon_1new_1for_1string",
"g_1icon_1to_1string",
@@ -1087,8 +1071,6 @@
"g_1slist_1length",
"g_1slist_1next",
"g_1source_1remove",
- "g_1strconcat__JJJ",
- "g_1strconcat__JJJJ",
"g_1strdup",
"g_1strfreev",
"g_1strtod",
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
index 8df6dbe..d48b327 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
@@ -935,21 +935,10 @@
g_1closure_1unref_FUNC,
g_1content_1type_1equals_FUNC,
g_1content_1type_1is_1a_FUNC,
- g_1credentials_1is_1same_1user_FUNC,
- g_1credentials_1new_FUNC,
g_1date_1time_1get_1ymd_FUNC,
g_1date_1time_1new_1local_FUNC,
g_1date_1time_1unref_FUNC,
- g_1dbus_1auth_1observer_1new_FUNC,
- g_1dbus_1connection_1call_FUNC,
- g_1dbus_1connection_1call_1finish_FUNC,
- g_1dbus_1connection_1call_1sync_FUNC,
- g_1dbus_1connection_1close_1sync_FUNC,
- g_1dbus_1connection_1is_1closed_FUNC,
- g_1dbus_1connection_1new_1for_1address_FUNC,
- g_1dbus_1connection_1new_1for_1address_1finish_FUNC,
g_1dbus_1connection_1register_1object_FUNC,
- g_1dbus_1generate_1guid_FUNC,
g_1dbus_1method_1invocation_1return_1value_FUNC,
g_1dbus_1node_1info_1lookup_1interface_FUNC,
g_1dbus_1node_1info_1new_1for_1xml_FUNC,
@@ -957,10 +946,6 @@
g_1dbus_1proxy_1call_1sync_FUNC,
g_1dbus_1proxy_1get_1name_1owner_FUNC,
g_1dbus_1proxy_1new_1for_1bus_1sync_FUNC,
- g_1dbus_1server_1get_1client_1address_FUNC,
- g_1dbus_1server_1new_1sync_FUNC,
- g_1dbus_1server_1start_FUNC,
- g_1dbus_1server_1stop_FUNC,
g_1dir_1make_1tmp_FUNC,
g_1error_1free_FUNC,
g_1error_1get_1message_FUNC,
@@ -981,7 +966,6 @@
g_1filename_1to_1utf8_FUNC,
g_1free_FUNC,
g_1get_1current_1time_FUNC,
- g_1get_1user_1name_FUNC,
g_1getenv_FUNC,
g_1icon_1new_1for_1string_FUNC,
g_1icon_1to_1string_FUNC,
@@ -1061,8 +1045,6 @@
g_1slist_1length_FUNC,
g_1slist_1next_FUNC,
g_1source_1remove_FUNC,
- g_1strconcat__JJJ_FUNC,
- g_1strconcat__JJJJ_FUNC,
g_1strdup_FUNC,
g_1strfreev_FUNC,
g_1strtod_FUNC,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
index a234d7d..ca9b6b1 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
@@ -211,11 +211,6 @@
public static final int G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START = 3;
public static final int G_DBUS_CALL_FLAGS_NONE = 0;
- public static final int G_DBUS_CALL_FLAGS_NO_AUTO_START = (1<<0);
-
- public static final int G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT = 1;
-
- public static final int G_DBUS_SERVER_FLAGS_NONE = 0;
/**
* DBus Data types as defined by:
@@ -274,7 +269,6 @@
public static final byte[] accel_closures_changed = ascii("accel-closures-changed"); // Gtk3,4
public static final byte[] activate = ascii("activate"); // ?
public static final byte[] angle_changed = ascii("angle_changed"); // Gtk3/4, Guesture related.
- public static final byte[] authorize_authenticated_peer = ascii("authorize-authenticated-peer");
public static final byte[] backspace = ascii("backspace");
public static final byte[] begin = ascii("begin");
public static final byte[] button_press_event = ascii("button-press-event");
@@ -340,7 +334,6 @@
public static final byte[] motion = ascii("motion");
public static final byte[] move_cursor = ascii("move-cursor");
public static final byte[] move_focus = ascii("move-focus");
- public static final byte[] new_connection = ascii("new-connection");
public static final byte[] output = ascii("output");
public static final byte[] paste_clipboard = ascii("paste-clipboard");
public static final byte[] pressed = ascii("pressed");
@@ -923,13 +916,6 @@
* @param supertype cast=(gchar *)
*/
public static final native boolean g_content_type_is_a(long type, byte[] supertype);
-public static final native long g_credentials_new();
-/**
- * @param credentials cast=(GCredentials *)
- * @param other_credentials cast=(GCredentials *)
- * @param error cast=(GError **)
- */
-public static final native boolean g_credentials_is_same_user(long credentials, long other_credentials, long [] error);
public static final native int g_file_error_quark();
/**
* @param info cast=(GFileInfo *)
@@ -1060,7 +1046,6 @@
* @param result cast=(GTimeVal *)
*/
public static final native void g_get_current_time(long result);
-public static final native long g_get_user_name();
/**
* @method flags=ignore_deprecations
* @param result cast=(GTimeVal *)
@@ -1309,19 +1294,6 @@
* @param endptr cast=(gchar **)
*/
public static final native double g_strtod(long str, long [] endptr);
-/**
- * @param str cast=(const gchar *)
- * @param str2 cast=(const gchar *)
- * @param str3 cast=(const gchar *)
- * @param terminator cast=(const gchar *),flags=sentinel
- */
-public static final native long g_strconcat(long str, long str2, long str3, long terminator);
-/**
- * @param str cast=(const gchar *)
- * @param str2 cast=(const gchar *)
- * @param terminator cast=(const gchar *),flags=sentinel
- */
-public static final native long g_strconcat(long str, long str2, long terminator);
/** @param str cast=(char *) */
public static final native long g_strdup (long str);
/** @param g_class cast=(GType) */
@@ -1902,7 +1874,7 @@
* On GTK, behavior may be different as the boolean flag doesn't force dark
* theme instead it specify that dark theme is preferred.
* </p>
- *
+ *
* @param isDarkTheme <code>true</code> for dark theme
*/
public static final void setTheme(boolean isDarkTheme) {
@@ -1976,74 +1948,6 @@
/**
* @param connection cast=(GDBusConnection *)
- * @param bus_name cast=(const gchar *)
- * @param object_path cast=(const gchar *)
- * @param interface_name cast=(const gchar *)
- * @param method_name cast=(const gchar *)
- * @param param cast=(GVariant *)
- * @param reply_type cast=(const GVariantType *)
- * @param cancellable cast=(GCancellable *)
- * @param callback cast=(GAsyncReadyCallback)
- * @param user_data cast=(gpointer)
- * @category gdbus
- */
-public static final native void g_dbus_connection_call(long connection, byte [] bus_name, byte [] object_path, byte [] interface_name, byte [] method_name, long param, long reply_type, int flag, int timeout, long cancellable, long callback, long user_data);
-
-/**
- * @param proxy cast=(GDBusConnection *)
- * @param res cast=(GAsyncResult *)
- * @param error cast=(GError **)
- * @category gdbus
- */
-public static final native long g_dbus_connection_call_finish(long proxy, long res, long [] error);
-
-/**
- * @param connection cast=(GDBusConnection *)
- * @param bus_name cast=(const gchar *)
- * @param object_path cast=(const gchar *)
- * @param interface_name cast=(const gchar *)
- * @param method_name cast=(const gchar *)
- * @param param cast=(GVariant *)
- * @param reply_type cast=(const GVariantType *)
- * @param cancellable cast=(GCancellable *)
- * @param error cast=(GError **)
- * @category gdbus
- */
-public static final native long g_dbus_connection_call_sync(long connection, byte [] bus_name, byte [] object_path, byte [] interface_name, byte [] method_name, long param, long reply_type, int flag, int timeout, long cancellable, long [] error);
-
-/**
- * @param connection cast=(GDBusConnection *)
- * @param cancellable cast=(GCancellable *)
- * @param error cast=(GError **)
- * @category gdbus
- */
-public static final native boolean g_dbus_connection_close_sync(long connection, long cancellable, long [] error);
-
-/**
- * @param connection cast=(GDBusConnection *)
- * @category gdbus
- */
-public static final native boolean g_dbus_connection_is_closed(long connection);
-
-/**
- * @param address cast=(const gchar *)
- * @param observer cast=(GDBusAuthObserver *)
- * @param cancellable cast=(GCancellable *)
- * @param callback cast=(GAsyncReadyCallback)
- * @param user_data cast=(gpointer)
- * @category gdbus
- */
-public static final native void g_dbus_connection_new_for_address(byte[] address, int flags, long observer, long cancellable, long callback, long user_data);
-
-/**
- * @param result cast=(GAsyncResult *)
- * @param error cast=(GError **)
- * @category gdbus
- */
-public static final native long g_dbus_connection_new_for_address_finish(long result, long [] error);
-
-/**
- * @param connection cast=(GDBusConnection *)
* @param object_path cast=(const gchar *)
* @param interface_info cast=(GDBusInterfaceInfo *)
* @param vtable cast=(const GDBusInterfaceVTable *)
@@ -2069,45 +1973,6 @@
public static final native void g_dbus_method_invocation_return_value(long invocation, long parameters);
/**
- * @param address cast=(const gchar *)
- * @param flags cast=(GDBusServerFlags)
- * @param guid cast=(const gchar *)
- * @param observer cast=(GDBusAuthObserver *)
- * @param cancellable cast=(GCancellable *)
- * @param error cast=(GError **)
- * @category gdbus
- */
-public static final native long g_dbus_server_new_sync(long address, int flags, long guid, long observer, long cancellable, long [] error);
-
-/**
- * @param server cast=(GDBusServer *)
- * @category gdbus
- */
-public static final native void g_dbus_server_start(long server);
-
-/**
- * @param server cast=(GDBusServer *)
- * @category gdbus
- */
-public static final native void g_dbus_server_stop(long server);
-
-/**
- * @param server cast=(GDBusServer *)
- * @category gdbus
- */
-public static final native long g_dbus_server_get_client_address(long server);
-
-/**
- * @category gdbus
- */
-public static final native long g_dbus_auth_observer_new();
-
-/**
- * @category gdbus
- */
-public static final native long g_dbus_generate_guid();
-
-/**
* @param type cast=(const GVariantType *)
* @category gdbus
*/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk.c b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk.c
index 386a903..f8782de 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2021 IBM Corporation and others. All rights reserved.
+ * Copyright (c) 2009, 2022 IBM Corporation and others. All rights reserved.
* The contents of this file are made available under the terms
* of the GNU Lesser General Public License (LGPL) Version 2.1 that
* accompanies this distribution (lgpl-v21.txt). The LGPL is also
@@ -84,33 +84,6 @@
}
#endif
-#ifndef NO_JSObjectMakeArray
-JNIEXPORT jlong JNICALL WebKitGTK_NATIVE(JSObjectMakeArray)
- (JNIEnv *env, jclass that, jlong arg0, jlong arg1, jlongArray arg2, jlongArray arg3)
-{
- jlong *lparg2=NULL;
- jlong *lparg3=NULL;
- jlong rc = 0;
- WebKitGTK_NATIVE_ENTER(env, that, JSObjectMakeArray_FUNC);
- if (arg2) if ((lparg2 = (*env)->GetLongArrayElements(env, arg2, NULL)) == NULL) goto fail;
- if (arg3) if ((lparg3 = (*env)->GetLongArrayElements(env, arg3, NULL)) == NULL) goto fail;
-/*
- rc = (jlong)JSObjectMakeArray(arg0, arg1, lparg2, lparg3);
-*/
- {
- WebKitGTK_LOAD_FUNCTION(fp, JSObjectMakeArray)
- if (fp) {
- rc = (jlong)((jlong (CALLING_CONVENTION*)(jlong, jlong, jlong *, jlong *))fp)(arg0, arg1, lparg2, lparg3);
- }
- }
-fail:
- if (arg3 && lparg3) (*env)->ReleaseLongArrayElements(env, arg3, lparg3, 0);
- if (arg2 && lparg2) (*env)->ReleaseLongArrayElements(env, arg2, lparg2, 0);
- WebKitGTK_NATIVE_EXIT(env, that, JSObjectMakeArray_FUNC);
- return rc;
-}
-#endif
-
#ifndef NO_JSStringCreateWithUTF8CString
JNIEXPORT jlong JNICALL WebKitGTK_NATIVE(JSStringCreateWithUTF8CString)
(JNIEnv *env, jclass that, jbyteArray arg0)
@@ -217,86 +190,6 @@
}
#endif
-#ifndef NO_JSValueMakeBoolean
-JNIEXPORT jlong JNICALL WebKitGTK_NATIVE(JSValueMakeBoolean)
- (JNIEnv *env, jclass that, jlong arg0, jint arg1)
-{
- jlong rc = 0;
- WebKitGTK_NATIVE_ENTER(env, that, JSValueMakeBoolean_FUNC);
-/*
- rc = (jlong)JSValueMakeBoolean(arg0, arg1);
-*/
- {
- WebKitGTK_LOAD_FUNCTION(fp, JSValueMakeBoolean)
- if (fp) {
- rc = (jlong)((jlong (CALLING_CONVENTION*)(jlong, jint))fp)(arg0, arg1);
- }
- }
- WebKitGTK_NATIVE_EXIT(env, that, JSValueMakeBoolean_FUNC);
- return rc;
-}
-#endif
-
-#ifndef NO_JSValueMakeNumber
-JNIEXPORT jlong JNICALL WebKitGTK_NATIVE(JSValueMakeNumber)
- (JNIEnv *env, jclass that, jlong arg0, jdouble arg1)
-{
- jlong rc = 0;
- WebKitGTK_NATIVE_ENTER(env, that, JSValueMakeNumber_FUNC);
-/*
- rc = (jlong)JSValueMakeNumber(arg0, arg1);
-*/
- {
- WebKitGTK_LOAD_FUNCTION(fp, JSValueMakeNumber)
- if (fp) {
- rc = (jlong)((jlong (CALLING_CONVENTION*)(jlong, jdouble))fp)(arg0, arg1);
- }
- }
- WebKitGTK_NATIVE_EXIT(env, that, JSValueMakeNumber_FUNC);
- return rc;
-}
-#endif
-
-#ifndef NO_JSValueMakeString
-JNIEXPORT jlong JNICALL WebKitGTK_NATIVE(JSValueMakeString)
- (JNIEnv *env, jclass that, jlong arg0, jlong arg1)
-{
- jlong rc = 0;
- WebKitGTK_NATIVE_ENTER(env, that, JSValueMakeString_FUNC);
-/*
- rc = (jlong)JSValueMakeString(arg0, arg1);
-*/
- {
- WebKitGTK_LOAD_FUNCTION(fp, JSValueMakeString)
- if (fp) {
- rc = (jlong)((jlong (CALLING_CONVENTION*)(jlong, jlong))fp)(arg0, arg1);
- }
- }
- WebKitGTK_NATIVE_EXIT(env, that, JSValueMakeString_FUNC);
- return rc;
-}
-#endif
-
-#ifndef NO_JSValueMakeUndefined
-JNIEXPORT jlong JNICALL WebKitGTK_NATIVE(JSValueMakeUndefined)
- (JNIEnv *env, jclass that, jlong arg0)
-{
- jlong rc = 0;
- WebKitGTK_NATIVE_ENTER(env, that, JSValueMakeUndefined_FUNC);
-/*
- rc = (jlong)JSValueMakeUndefined(arg0);
-*/
- {
- WebKitGTK_LOAD_FUNCTION(fp, JSValueMakeUndefined)
- if (fp) {
- rc = (jlong)((jlong (CALLING_CONVENTION*)(jlong))fp)(arg0);
- }
- }
- WebKitGTK_NATIVE_EXIT(env, that, JSValueMakeUndefined_FUNC);
- return rc;
-}
-#endif
-
#ifndef NO_JSValueToNumber
JNIEXPORT jdouble JNICALL WebKitGTK_NATIVE(JSValueToNumber)
(JNIEnv *env, jclass that, jlong arg0, jlong arg1, jlongArray arg2)
@@ -1547,46 +1440,6 @@
}
#endif
-#ifndef NO_webkit_1web_1context_1set_1web_1extensions_1directory
-JNIEXPORT void JNICALL WebKitGTK_NATIVE(webkit_1web_1context_1set_1web_1extensions_1directory)
- (JNIEnv *env, jclass that, jlong arg0, jbyteArray arg1)
-{
- jbyte *lparg1=NULL;
- WebKitGTK_NATIVE_ENTER(env, that, webkit_1web_1context_1set_1web_1extensions_1directory_FUNC);
- if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
-/*
- webkit_web_context_set_web_extensions_directory(arg0, lparg1);
-*/
- {
- WebKitGTK_LOAD_FUNCTION(fp, webkit_web_context_set_web_extensions_directory)
- if (fp) {
- ((void (CALLING_CONVENTION*)(jlong, jbyte *))fp)(arg0, lparg1);
- }
- }
-fail:
- if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
- WebKitGTK_NATIVE_EXIT(env, that, webkit_1web_1context_1set_1web_1extensions_1directory_FUNC);
-}
-#endif
-
-#ifndef NO_webkit_1web_1context_1set_1web_1extensions_1initialization_1user_1data
-JNIEXPORT void JNICALL WebKitGTK_NATIVE(webkit_1web_1context_1set_1web_1extensions_1initialization_1user_1data)
- (JNIEnv *env, jclass that, jlong arg0, jlong arg1)
-{
- WebKitGTK_NATIVE_ENTER(env, that, webkit_1web_1context_1set_1web_1extensions_1initialization_1user_1data_FUNC);
-/*
- webkit_web_context_set_web_extensions_initialization_user_data(arg0, arg1);
-*/
- {
- WebKitGTK_LOAD_FUNCTION(fp, webkit_web_context_set_web_extensions_initialization_user_data)
- if (fp) {
- ((void (CALLING_CONVENTION*)(jlong, jlong))fp)(arg0, arg1);
- }
- }
- WebKitGTK_NATIVE_EXIT(env, that, webkit_1web_1context_1set_1web_1extensions_1initialization_1user_1data_FUNC);
-}
-#endif
-
#ifndef NO_webkit_1web_1resource_1get_1data
JNIEXPORT void JNICALL WebKitGTK_NATIVE(webkit_1web_1resource_1get_1data)
(JNIEnv *env, jclass that, jlong arg0, jlong arg1, jlong arg2, jlong arg3)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk_extension.c b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk_extension.c
deleted file mode 100644
index cd9a5e1..0000000
--- a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk_extension.c
+++ /dev/null
@@ -1,616 +0,0 @@
-#include "webkitgtk_extension.h"
-
-/*
- * To debug this extension:
- * -ensure this is built with debug flags (look for '-g*' in make_linux, or 'SWT_LIB_DEBUG' macro)
- * -connect to the WebKitWebProcess with the PID of this extension. It can be found as follows:
- g_print("Extension PID: %d\n", getpid());
- */
-
-// Client address of the main process GDBusServer -- the extension connects to this
-const gchar *swt_main_proc_client_address = NULL;
-
-// Client address of the extension's GDBusServer -- SWT main process connects to this
-const gchar *extension_server_address = NULL;
-
-// See: WebKitGTK.java's 'TYPE NOTES'
-guchar SWT_DBUS_MAGIC_NUMBER_EMPTY_ARRAY = 101;
-guchar SWT_DBUS_MAGIC_NUMBER_NULL = 48;
-
-// This struct represents a BrowserFunction
-typedef struct {
- guint64 page_id; // page ID
- gchar *function; // JS function
- gchar *url; // URL the function belongs to
-} BrowserFunction;
-
-// The list of BrowserFunctions registered to this extension
-GSList *function_list = NULL;
-
-// GDBusConnection to the SWT main process
-GDBusConnection *connection_to_main_proc = NULL;
-
-// This extension's GDBusServer and related resources
-GDBusServer *server = NULL;
-GDBusAuthObserver *auth_observer = NULL;
-gchar *guid = NULL;
-
-// GDBusConnection from SWT main process
-GDBusConnection *connection_from_main_proc = NULL;
-
-/**
- * Caller should free the returned GVariant
- */
-GVariant *call_main_proc_sync(char * method_name, GVariant *parameters) {
- GError *error = NULL; // Some functions return errors through params
- GVariant *result; // The value result from a call
-
- // Send a message
- result = g_dbus_connection_call_sync(connection_to_main_proc, WEBKIT_MAIN_PROCESS_DBUS_NAME,
- WEBKIT_MAIN_PROCESS_OBJECT_PATH, WEBKIT_MAIN_PROCESS_INTERFACE_NAME, method_name, parameters,
- NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
- // Error checking.
- if (result == NULL) {
- if (error != NULL) {
- g_error("call_main_proc_sync failed because '%s.'\n", error->message);
- } else {
- g_error("call_main_proc_sync failed for an unknown reason.\n");
- }
- return NULL;
- }
-
- return result;
-}
-
-// +--------------------------------------------------+
-// | JavaScriptCore to/from conversion GVariant logic |
-// +--------------------------------------------------+
-
-/** Return true if the given JSValueRef is one we can push over gdbus. False otherwise.
- * We support basic types, nulls and arrays of basic types.*/
-gboolean is_js_valid(JSContextRef context, JSValueRef value) {
- JSType type = JSValueGetType(context, value);
- if (type == kJSTypeBoolean
- || type == kJSTypeNumber
- || type == kJSTypeString
- || type == kJSTypeNull
- || type == kJSTypeUndefined) {
- return true;
- }
- if (type == kJSTypeObject && JSValueIsArray(context, value)) {
- JSStringRef propertyName = JSStringCreateWithUTF8CString("length");
- JSObjectRef object = JSValueToObject(context, value, NULL);
- JSValueRef valuePtr = JSObjectGetProperty(context, object, propertyName, NULL);
- JSStringRelease(propertyName);
- int length = (int) JSValueToNumber(context, valuePtr, NULL);
- int i;
- for (i = 0; i < length; i++) {
- const JSValueRef child = JSObjectGetPropertyAtIndex(context, object, i, NULL);
- if (!is_js_valid(context, child)) {
- return false;
- }
- }
- return true;
- }
- return false;
-}
-
-/*
- * Developer note:
- * JavaScriptCore defines a "Number" to be a double in general. It doesn't seem to be using "Int".
- */
-static GVariant * convert_js_to_gvariant (JSContextRef context, JSValueRef value){
- g_assert(context != NULL);
- g_assert(value != NULL);
- JSType type = JSValueGetType(context, value);
-
- if (type == kJSTypeBoolean) {
- gboolean result = JSValueToNumber(context, value, NULL) != 0;
- return g_variant_new_boolean(result);
- }
-
- if (type == kJSTypeNumber) {
- double result = JSValueToNumber(context, value, NULL);
- return g_variant_new_double(result);
- }
-
- if (type == kJSTypeString) {
- JSStringRef stringRef = JSValueToStringCopy(context, value, NULL);
- size_t length = JSStringGetMaximumUTF8CStringSize(stringRef);
- char* string = (char*) malloc(length);
- JSStringGetUTF8CString(stringRef, string, length);
- GVariant *variant = g_variant_new_string(string);
- free(string);
- return variant;
- }
-
- if (type == kJSTypeNull || type == kJSTypeUndefined) {
- return g_variant_new_byte(SWT_DBUS_MAGIC_NUMBER_NULL);
- }
-
- if (type == kJSTypeObject) {
- JSStringRef propertyName = JSStringCreateWithUTF8CString("length");
- JSObjectRef object = JSValueToObject(context, value, NULL);
- JSValueRef valuePtr = JSObjectGetProperty(context, object, propertyName, NULL);
- JSStringRelease(propertyName);
-
- if (JSValueGetType(context, valuePtr) == kJSTypeNumber) {
- int length = (int) JSValueToNumber(context, valuePtr, NULL);
-
- if (length == 0) {
- return g_variant_new_byte(SWT_DBUS_MAGIC_NUMBER_EMPTY_ARRAY);
- }
- GVariant **children = g_new(GVariant *, length);
- int i = 0;
- for (i = 0; i < length; i++) {
- const JSValueRef child = JSObjectGetPropertyAtIndex(context, object, i, NULL);
- children[i] = convert_js_to_gvariant(context, child);
- }
- GVariant* variant = g_variant_new_tuple(children, length);
- g_free(children);
- return variant;
- }
- }
-
- // Get type value string
- JSStringRef valueIString = JSValueToStringCopy(context, value, NULL);
- size_t valueUTF8Size = JSStringGetMaximumUTF8CStringSize(valueIString);
- char* valueUTF8 = (char*) malloc(valueUTF8Size);
- JSStringGetUTF8CString(valueIString, valueUTF8, valueUTF8Size);
-
- g_warning("Unhandled type %d value: %s \n", type, valueUTF8);
- free(valueUTF8);
- JSStringRelease(valueIString);
-
- return NULL;
-}
-
-
-static JSValueRef convert_gvariant_to_js (JSContextRef context, GVariant * value){
- g_assert(context != NULL);
- g_assert(value != NULL);
-
- if (g_variant_is_of_type(value, G_VARIANT_TYPE_BYTE)) { // see: WebKitGTK.java 'TYPE NOTES'
- guchar magic_number = g_variant_get_byte(value);
- if (magic_number == SWT_DBUS_MAGIC_NUMBER_NULL) {
- // 'JSValueMakeUndefined' is used as oppose to 'JSValueMakeNull' (from what I gather) for legacy reasons.
- // I.e webkit1 used it, so we shall use it in webkit2 also.
- return JSValueMakeUndefined(context);
- } else if (magic_number == SWT_DBUS_MAGIC_NUMBER_EMPTY_ARRAY) {
- return JSObjectMakeArray(context, 0, NULL, NULL); // The empty array with no children.
- } else {
- g_error("Java sent an unknown magic number: '%d' , this should never happen. \n", magic_number);
- }
- }
-
- if (g_variant_is_of_type(value, G_VARIANT_TYPE_BOOLEAN)) {
- return JSValueMakeBoolean(context, g_variant_get_boolean(value));
- }
-
- if (g_variant_is_of_type(value, G_VARIANT_TYPE_DOUBLE)) {
- return JSValueMakeNumber(context, g_variant_get_double(value));
- }
-
- if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
- JSStringRef stringRef = JSStringCreateWithUTF8CString(g_variant_get_string(value, NULL));
- JSValueRef result = JSValueMakeString(context, stringRef);
- JSStringRelease(stringRef);
- return result;
- }
-
- if (g_variant_is_of_type(value, G_VARIANT_TYPE_TUPLE)) {
- gsize length = g_variant_n_children(value);
- JSValueRef *children = g_new(JSValueRef, length);
-
- gsize i = 0;
- for (i = 0; i < length; i++) {
- children[i] = convert_gvariant_to_js(context, g_variant_get_child_value(value, i));
- }
- JSValueRef result = JSObjectMakeArray(context, length, children, NULL);
- g_free(children);
- return result;
- }
- g_error("Unhandled type %s \n", g_variant_get_type_string(value));
- return NULL;
-}
-
-// +--------------------+---------------------------------------------------------
-// | WebExtension Logic |
-// +--------------------+
-
-// Reached by calling "webkit2callJava();" in javascript console.
-// Some basic c function to be exposed to the javascript environment
-static JSValueRef webkit2callJava (JSContextRef context,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[], // [String webview, double index, String Token, Object[] args]
- JSValueRef *exception) {
- g_assert (argumentCount == 4);
- GVariant *g_var_params; // The parameters to a function call
-
- // Need to ensure user arguments won't break gdbus.
- if (!is_js_valid(context, arguments[3])) {
- g_warning("Arguments contain an invalid type (object). Only Number,Boolean,null,String and (mixed) arrays of basic types are supported");
- return 0;
- }
-
- g_var_params = g_variant_new ("(@s@d@s@*)", // pointer to String, pointer to double, pointer to string, pointer to any type.
- convert_js_to_gvariant(context, arguments[0]), // String webView
- convert_js_to_gvariant(context, arguments[1]), // int index
- convert_js_to_gvariant(context, arguments[2]), // String Token
- convert_js_to_gvariant(context, arguments[3]) // js args
- );
-
- GVariant *g_var_result = call_main_proc_sync("webkit2callJava", g_var_params);
- if (g_var_result == NULL) {
- g_error("Java call returned NULL. This should never happpen\n");
- return 0;
- }
-
- // gdbus dynamic call always returns an array(tuple) with return types.
- // In our case, we return a single type or an array.
- // E.g java:int -> gdbus:(i) (array containing one int)
- // E.g java [int,str] -> gdbus:((is)) (array with array of (int+str).
- // So we always extract the first child, convert and pass to js.
- JSValueRef retVal = 0;
- if (g_variant_is_of_type(g_var_result, G_VARIANT_TYPE_TUPLE)) {
- if (g_variant_n_children(g_var_result) != 1) {
- g_error("Should only receive a single item in the tuple, but length is: %ud\n", (unsigned int) g_variant_n_children(g_var_result));
- }
- retVal = convert_gvariant_to_js(context, g_variant_get_child_value(g_var_result, 0));
- } else {
- g_error("Unsupported return type. Should be an array, but received a single type.\n");
- }
-
- g_variant_unref(g_var_result);
- return retVal;
-}
-
-static void web_page_created_callback(WebKitWebExtension *extension, WebKitWebPage *web_page, gpointer user_data) {
- // Observation. This seems to be called only once.
-}
-
-/**
- * Returns the main frame of the WebPage with the given ID
- */
-static WebKitFrame *webkitgtk_extension_get_main_frame (const guint64 id) {
- WebKitWebPage *web_page = webkit_web_extension_get_page (this_extension, id);
- return webkit_web_page_get_main_frame (web_page);
-}
-
-/*
- * Execute the Javascript for the given page and URL.
- */
-static gboolean webkitgtk_extension_execute_script (const guint64 page_id, gchar* script, gchar* url) {
- WebKitFrame *main_frame = webkitgtk_extension_get_main_frame (page_id);
-
- JSStringRef url_string = JSStringCreateWithUTF8CString (url);
- JSStringRef script_string = JSStringCreateWithUTF8CString (script);
-
- /*
- * TODO Bug 570285: Replace with webkit_frame_get_js_context()
- * when minimal WebKitGTK version is 2.22+
- */
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- JSGlobalContextRef context = webkit_frame_get_javascript_global_context (main_frame);
- G_GNUC_END_IGNORE_DEPRECATIONS
-
- JSValueRef exception;
- JSValueRef result = JSEvaluateScript(context, script_string, NULL, url_string, 0, &exception);
- if (!result) {
- JSStringRef exceptionIString = JSValueToStringCopy(context, exception, NULL);
- size_t exceptionUTF8Size = JSStringGetMaximumUTF8CStringSize(exceptionIString);
- char* exceptionUTF8 = (char*)malloc(exceptionUTF8Size);
- JSStringGetUTF8CString(exceptionIString, exceptionUTF8, exceptionUTF8Size);
- g_error("Failed to execute script exception: %s\n", exceptionUTF8);
- free(exceptionUTF8);
- JSStringRelease(exceptionIString);
- }
-
- JSStringRelease (url_string);
- JSStringRelease (script_string);
-
- return result != NULL;
-}
-
-void execute_browser_functions(gconstpointer item, gpointer page) {
- BrowserFunction *function = (BrowserFunction *) item;
- if (function != NULL && function->page_id == GPOINTER_TO_UINT(page)) {
- webkitgtk_extension_execute_script(function->page_id, function->function, function->url);
- }
- return;
-}
-
-gint find_browser_function (gconstpointer item, gconstpointer target) {
- BrowserFunction *element = (BrowserFunction *) item;
- BrowserFunction *remove = (BrowserFunction *) target;
- if (element->page_id == remove->page_id && g_strcmp0(element->function, remove->function) == 0 &&
- g_strcmp0(element->url, remove->url) == 0) {
- return 0;
- }
- return 1;
-}
-
-void add_browser_function(guint64 page_id, const gchar *function, const gchar *url) {
- BrowserFunction *func = g_slice_new0(BrowserFunction);
- func->page_id = page_id;
- func->function = g_strdup(function);
- func->url = g_strdup(url);
- function_list = g_slist_append(function_list, func);
-}
-
-void remove_browser_function(guint64 page_id, const gchar *function, const gchar *url) {
- BrowserFunction *func = g_slice_new0(BrowserFunction);
- func->page_id = page_id;
- func->function = g_strdup(function);
- func->url = g_strdup(url);
- GSList *to_remove = g_slist_find_custom(function_list, func, find_browser_function);
- if (to_remove != NULL) {
- BrowserFunction *delete_func = to_remove->data;
- g_free(delete_func->function);
- g_free(delete_func->url);
- function_list = g_slist_delete_link(function_list, to_remove);
- }
- g_free(func->function);
- g_free(func->url);
- g_slice_free(BrowserFunction, func);
-}
-
-void unpack_browser_function_array(GVariant *array) {
- GVariantIter iter;
- GVariant *child;
-
- g_variant_iter_init (&iter, array);
- while ((child = g_variant_iter_next_value (&iter))) {
- gsize length = (int)g_variant_n_children (child);
- if (length > 3) {
- // If the length is longer than three, something went wrong and this tuple should be skipped
- g_warning("There was an error unpacking the GVariant tuple for a BrowserFunction in the web extension.\n");
- continue;
- }
- guint64 page = g_variant_get_uint64(g_variant_get_child_value(child, 0));
- if (page == -1UL) {
- // Empty or malformed BrowserFunction, skip this one
- continue;
- } else {
- const gchar *function = g_variant_get_string(g_variant_get_child_value(child, 1), NULL);
- const gchar *url = g_variant_get_string(g_variant_get_child_value(child, 2), NULL);
- if (function != NULL && url != NULL) {
- add_browser_function(page, function, url);
- } else {
- g_warning("There was an error unpacking the function string or URL.\n");
- }
- }
- g_variant_unref (child);
- }
-}
-
-/*
- * Every time a webpage is loaded, we should re-register the 'webkit2callJava' function.
- * Additionally, we re-register all BrowserFunctions that are stored in the function_list
- * GSList.
- */
-static void window_object_cleared_callback (WebKitScriptWorld *world, WebKitWebPage *web_page,
- WebKitFrame *frame,
- gpointer user_data) {
- // Observation: This is called every time a webpage is loaded.
- JSGlobalContextRef jsContext;
- JSObjectRef globalObject;
- JSValueRef exception = 0;
-
- /*
- * TODO Bug 570285: Replace with webkit_frame_get_js_context_for_script_world()
- * when minimal WebKitGTK version is 2.22+
- */
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- jsContext = webkit_frame_get_javascript_context_for_script_world (frame, world);
- G_GNUC_END_IGNORE_DEPRECATIONS
- globalObject = JSContextGetGlobalObject (jsContext);
-
- JSStringRef function_name = JSStringCreateWithUTF8CString("webkit2callJava"); // Func reference by javascript
- JSObjectRef jsFunction = JSObjectMakeFunctionWithCallback(jsContext, function_name, webkit2callJava); // C reference to func
- JSObjectSetProperty(jsContext, globalObject, function_name, jsFunction,
- kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly, &exception);
-
- if (exception) {
- g_print("OJSObjectSetProperty exception occurred");
- }
-
- /*
- * Iterate over the list of BrowserFunctions and execute each one of them for the current page.
- * This ensures that BrowserFunctions are not lost on page reloads. See bug 536141.
- */
- if (function_list != NULL) {
- guint64 page_id = webkit_web_page_get_id (web_page);
- if (page_id != -1UL) {
- g_slist_foreach(function_list, (GFunc)execute_browser_functions, GUINT_TO_POINTER(page_id));
- } else {
- g_warning("There was an error fetching the page ID in the object_cleared callback.\n");
- }
- }
-}
-
-static void
-webkitgtk_extension_handle_method_call (GDBusConnection *connection, const gchar *sender,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *method_name,
- GVariant *parameters,
- GDBusMethodInvocation *invocation,
- gpointer user_data) {
- gboolean result = FALSE;
- const gchar *script;
- const gchar *url;
- guint64 page_id;
- // Check method names
- if (g_strcmp0(method_name, "webkitgtk_extension_register_function") == 0) {
- g_variant_get(parameters, "(t&s&s)", &page_id, &script, &url);
- if (page_id != -1UL) {
- result = TRUE;
- // Return before processing the linked list, to prevent DBus from hanging
- g_dbus_method_invocation_return_value(invocation, g_variant_new("(b)", result));
- add_browser_function(page_id, script, url);
- return;
- }
- g_dbus_method_invocation_return_value(invocation, g_variant_new("(b)", result));
- return;
- }
- if (g_strcmp0(method_name, "webkitgtk_extension_deregister_function") == 0) {
- g_variant_get(parameters, "(t&s&s)", &page_id, &script, &url);
- if (page_id != -1UL) {
- result = TRUE;
- // Return before processing the linked list, to prevent DBus from hanging
- g_dbus_method_invocation_return_value(invocation, g_variant_new("(b)", result));
- remove_browser_function(page_id, script, url);
- return;
- }
- g_dbus_method_invocation_return_value(invocation, g_variant_new("(b)", result));
- return;
- }
- g_error ("Unknown method %s\n", method_name);
-}
-
-static const GDBusInterfaceVTable interface_vtable = {.method_call = webkitgtk_extension_handle_method_call};
-
-static void connection_closed_cb (GDBusConnection *connection, gboolean remote_peer_vanished, GError *error,
- gpointer user_data) {
- /*
- * If this connection is closed we can shut the server down. NOTE: all connections are freed in the main
- * SWT process, including connections created here in this extension. This is done for the sake of
- * consistency to avoid double frees.
- */
- if (connection == connection_from_main_proc) {
- // Free server and its objects
- g_dbus_server_stop(server);
- g_object_unref(auth_observer);
- g_object_unref(server);
- g_free(guid);
- }
-}
-
-static gboolean new_connection_cb (GDBusServer *server, GDBusConnection *connection, gpointer user_data) {
- // Create introspection XML
- dbus_introspection_xml = g_new (gchar, strlen(dbus_introspection_xml_template) +
- strlen(WEBKITGTK_EXTENSION_INTERFACE_NAME) + 1);
- g_sprintf (dbus_introspection_xml, dbus_introspection_xml_template, WEBKITGTK_EXTENSION_INTERFACE_NAME);
-
- // Create DBus node
- dbus_node = g_dbus_node_info_new_for_xml (dbus_introspection_xml, NULL);
- g_assert (dbus_node != NULL);
-
- // Register node on the connection that was just created
- dbus_interface = g_dbus_node_info_lookup_interface(dbus_node, WEBKITGTK_EXTENSION_INTERFACE_NAME);
- guint registration_id = g_dbus_connection_register_object(connection, WEBKITGTK_EXTENSION_OBJECT_PATH,
- dbus_interface,
- &interface_vtable, NULL, /* user_data */
- NULL, /* user_data_free_func */
- NULL); /* GError** */
- g_assert(registration_id > 0);
-
- // This connection will be the one from the main SWT process
- connection_from_main_proc = g_object_ref(connection);
-
- // Listen to the "close" signal on this connection so we can free resources in the extension when
- // the time comes.
- g_signal_connect(connection_from_main_proc, "closed", G_CALLBACK (connection_closed_cb), NULL);
-
- return 1;
-}
-
-static gboolean extension_authorize_peer (GDBusAuthObserver *observer, GIOStream *stream, GCredentials *credentials,
- gpointer user_data) {
- g_autoptr (GError) error = NULL;
- gboolean authorized = FALSE;
- if (credentials != NULL) {
- GCredentials *own_credentials;
- own_credentials = g_credentials_new ();
- if (g_credentials_is_same_user (credentials, own_credentials, &error)) {
- authorized = TRUE;
- }
- g_object_unref (own_credentials);
- }
- if (error) {
- g_warning ("Error authenticating client connection: %s", error->message);
- }
- return authorized;
-}
-
-// Returns a valid GDBusServer address -- this will be the address used to connect to the extension's
-// GDBusServer. On Linux, the address required is used for as an abstract path. If abstract path is not supported
-// one must create & manage temporary directories. See Bug562443.
-gchar *construct_server_address () {
- gchar *tmp_address = g_strdup("unix:tmpdir=/tmp/SWT-WebExtensionGDBusServer");
-
- return tmp_address;
-}
-
-// Creates the GDBusServer for this web extension
-static void create_server () {
- g_autoptr (GError) error = NULL;
- extension_server_address = construct_server_address();
- auth_observer = g_dbus_auth_observer_new();
-
- guid = g_dbus_generate_guid();
- server = g_dbus_server_new_sync(extension_server_address, G_DBUS_SERVER_FLAGS_NONE, guid,
- auth_observer, NULL, &error);
-
- if (error) {
- g_error ("Failed to create server: %s", error->message);
- }
-
- if (server) {
- g_signal_connect(server, "new-connection", G_CALLBACK(new_connection_cb), NULL);
- g_dbus_server_start(server);
- g_signal_connect (auth_observer, "authorize-authenticated-peer", G_CALLBACK(extension_authorize_peer), NULL);
- }
-}
-
-// Identifies this web extension to the main SWT process by sending its
-// server address over DBus.
-static void identify_extension_to_main_proc () {
- const gchar *client_address_for_extension_server = g_dbus_server_get_client_address(server);
- GVariant *result = call_main_proc_sync("webkitWebExtensionIdentifier", g_variant_new ("(s)",
- client_address_for_extension_server));
-
- // Process and register any pending BrowserFunctions from the main SWT process
- if (g_variant_is_of_type(result, G_VARIANT_TYPE_TUPLE)) {
- unpack_browser_function_array(g_variant_get_child_value(result, 0));
- } else {
- g_warning("webkitWebExtensionIdentifier return value from SWT was an unexpected type""(not a tuple).\n");
- }
-}
-
-// Creates a GDBusConnection to the main SWT process
-static void connect_to_main_proc (GVariant *user_data) {
- swt_main_proc_client_address = g_variant_get_string(user_data, NULL);
-
- g_autoptr (GError) error = NULL;
- connection_to_main_proc = g_dbus_connection_new_for_address_sync (swt_main_proc_client_address,
- G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT, NULL, NULL, &error);
-
- if (error) {
- g_error ("Failed to create connection: %s", error->message);
- }
-
- if (connection_to_main_proc && g_dbus_connection_is_closed(connection_to_main_proc)) {
- g_error ("Failed to created connection: connection is closed");
- }
-}
-
-G_MODULE_EXPORT void webkit_web_extension_initialize_with_user_data(WebKitWebExtension *extension, GVariant *user_data) {
- this_extension = extension;
-
- // Connect to the main SWT process
- connect_to_main_proc(user_data);
-
- // Create this extension's GDBusServer
- create_server();
-
- // Identify this extension's server address to the main process
- identify_extension_to_main_proc();
-
- // WebKit callbacks
- g_signal_connect(extension, "page-created", G_CALLBACK(web_page_created_callback), NULL);
- g_signal_connect (webkit_script_world_get_default (), "window-object-cleared", G_CALLBACK (window_object_cleared_callback), NULL);
-}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk_extension.h b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk_extension.h
deleted file mode 100644
index 3edca55..0000000
--- a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk_extension.h
+++ /dev/null
@@ -1,74 +0,0 @@
- /*******************************************************************************
- * Copyright (c) 2017 Red Hat and others. All rights reserved.
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- *
- * Contributors:
- * Red Hat - initial API and implementation
- *******************************************************************************/
-#ifndef INC_webkit_extension_H
-#define INC_webkit_extension_H
-
-#include <string.h>
-
-#include <glib.h>
-#include <glib/gprintf.h>
-
-#include <gio/gio.h>
-#include <stdlib.h>
-
-#include <unistd.h>
-#include <stdio.h>
-
-// These 2 are only for getpid();
-#include <sys/types.h>
-#include <unistd.h>
-
-#include <webkit2/webkit-web-extension.h>
-
-#include <JavaScriptCore/JavaScript.h>
-#include <JavaScriptCore/JSContextRef.h>
-#include <JavaScriptCore/JSObjectRef.h>
-#include <JavaScriptCore/JSStringRef.h>
-
-#define WEBKITGTK_EXTENSION_DBUS_NAME "org.eclipse.swt.webkitgtk_extension"
-#define WEBKITGTK_EXTENSION_OBJECT_PATH "/org/eclipse/swt/webkitgtk_extension/gdbus"
-#define WEBKITGTK_EXTENSION_INTERFACE_NAME "org.eclipse.swt.webkitgtk_extension.gdbusInterface"
-
-#define WEBKIT_MAIN_PROCESS_DBUS_NAME "org.eclipse.swt"
-#define WEBKIT_MAIN_PROCESS_OBJECT_PATH "/org/eclipse/swt/gdbus"
-#define WEBKIT_MAIN_PROCESS_INTERFACE_NAME "org.eclipse.swt.gdbusInterface"
-
-static WebKitWebExtension *this_extension;
-
-static GDBusNodeInfo *dbus_node;
-static GDBusInterfaceInfo *dbus_interface;
-static gchar* dbus_introspection_xml;
-static gchar* dbus_introspection_xml_template =
-"<node>"
- "<interface name='%s'>"
-
- "<method name='webkitgtk_extension_register_function'>"
- "<arg type='t' name='page_id' direction='in'/>"
- "<arg type='s' name='script' direction='in'/>"
- "<arg type='s' name='url' direction='in'/>"
- "<arg type='b' name='result' direction='out'/>"
- "</method>"
-
- "<method name='webkitgtk_extension_deregister_function'>"
- "<arg type='t' name='page_id' direction='in'/>"
- "<arg type='s' name='script' direction='in'/>"
- "<arg type='s' name='url' direction='in'/>"
- "<arg type='b' name='result' direction='out'/>"
- "</method>"
-
- "</interface>"
-"</node>";
-
-#endif /*INC_webkit_extension_H*/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk_stats.c b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk_stats.c
index 9a18355..774b722 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk_stats.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2021 IBM Corporation and others. All rights reserved.
+ * Copyright (c) 2009, 2022 IBM Corporation and others. All rights reserved.
* The contents of this file are made available under the terms
* of the GNU Lesser General Public License (LGPL) Version 2.1 that
* accompanies this distribution (lgpl-v21.txt). The LGPL is also
@@ -25,16 +25,11 @@
"GdkRectangle_1sizeof",
"JSObjectGetProperty",
"JSObjectGetPropertyAtIndex",
- "JSObjectMakeArray",
"JSStringCreateWithUTF8CString",
"JSStringGetMaximumUTF8CStringSize",
"JSStringGetUTF8CString",
"JSStringRelease",
"JSValueGetType",
- "JSValueMakeBoolean",
- "JSValueMakeNumber",
- "JSValueMakeString",
- "JSValueMakeUndefined",
"JSValueToNumber",
"JSValueToStringCopy",
"soup_1cookie_1get_1name",
@@ -96,8 +91,6 @@
"webkit_1web_1context_1get_1type",
"webkit_1web_1context_1get_1website_1data_1manager",
"webkit_1web_1context_1set_1tls_1errors_1policy",
- "webkit_1web_1context_1set_1web_1extensions_1directory",
- "webkit_1web_1context_1set_1web_1extensions_1initialization_1user_1data",
"webkit_1web_1resource_1get_1data",
"webkit_1web_1resource_1get_1data_1finish",
"webkit_1web_1view_1can_1go_1back",
diff --git a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk_stats.h b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk_stats.h
index a94d3e7..9ce6e0c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk_stats.h
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2021 IBM Corporation and others. All rights reserved.
+ * Copyright (c) 2009, 2022 IBM Corporation and others. All rights reserved.
* The contents of this file are made available under the terms
* of the GNU Lesser General Public License (LGPL) Version 2.1 that
* accompanies this distribution (lgpl-v21.txt). The LGPL is also
@@ -35,16 +35,11 @@
GdkRectangle_1sizeof_FUNC,
JSObjectGetProperty_FUNC,
JSObjectGetPropertyAtIndex_FUNC,
- JSObjectMakeArray_FUNC,
JSStringCreateWithUTF8CString_FUNC,
JSStringGetMaximumUTF8CStringSize_FUNC,
JSStringGetUTF8CString_FUNC,
JSStringRelease_FUNC,
JSValueGetType_FUNC,
- JSValueMakeBoolean_FUNC,
- JSValueMakeNumber_FUNC,
- JSValueMakeString_FUNC,
- JSValueMakeUndefined_FUNC,
JSValueToNumber_FUNC,
JSValueToStringCopy_FUNC,
soup_1cookie_1get_1name_FUNC,
@@ -106,8 +101,6 @@
webkit_1web_1context_1get_1type_FUNC,
webkit_1web_1context_1get_1website_1data_1manager_FUNC,
webkit_1web_1context_1set_1tls_1errors_1policy_FUNC,
- webkit_1web_1context_1set_1web_1extensions_1directory_FUNC,
- webkit_1web_1context_1set_1web_1extensions_1initialization_1user_1data_FUNC,
webkit_1web_1resource_1get_1data_FUNC,
webkit_1web_1resource_1get_1data_1finish_FUNC,
webkit_1web_1view_1can_1go_1back_FUNC,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java
index b42cc30..b12ec6f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java
@@ -52,20 +52,7 @@
* (the exception is the webextension, because it runs as a separate process and is only loaded dynamically).
* - Try to keep all of your logic in Java and avoid writing custom C-code. (I went down this pit). Because if you
* use native code, then you have to write dynamic native code (get function pointers, cast types etc.. big pain in the ass).
- * (Webextension is again an exception).
* - Don't try to add webkit2 include flags to pkg-config, as this will tie the swt-glue code to specific webkit versions. Thou shall not do this.
- * (webextension is an exception).
- *
- * Webextension:
- * - On Webkit2, a webextension is used to provide browserfunction/javascript callback functionality. (See the whole WebkitGDBus.java business).
- * - I've initially implemented javascript execution by running javascript and then waiting in a display-loop until webkit makes a return call.
- * I then added a whole bunch of logic to avoid deadlocks.
- * In retrospec, the better approach would be to send things off via GDBus and let the webextension run the javascript synchronously.
- * But this would take another 1-2 months of implementation time and wouldn't guarantee dead-lock free behaviour as callbacks could potentailly still
- * cause deadlocks. It's an interesting thought however..
- * - Note, most GDBus tutorials talk about compiling GDBus bindings. But using them dynamically I found is much easier. See this guide:
- * http://www.cs.grinnell.edu/~rebelsky/Courses/CSC195/2013S/Outlines/
- *
*
* EVENT_HANDLING_DOC:
* - On webkit2, signals are implemented via regular gtk mechanism, hook events and pass them along as we receive them.
@@ -219,8 +206,6 @@
Proc5 = new Callback (WebKit.class, "Proc", 5); //$NON-NLS-1$
new Webkit2AsyncToSync();
- WebKitExtension.init();
-
JSDOMEventProc = new Callback (WebKit.class, "JSDOMEventProc", 3); //$NON-NLS-1$
NativeClearSessions = () -> {
@@ -264,48 +249,11 @@
@Override
public void createFunction(BrowserFunction function) {
- if (!WebkitGDBus.initialized) {
- System.err.println("SWT webkit: WebkitGDBus and/or Webkit2Extension not loaded, BrowserFunction will not work." +
- "Tried to create "+ function.name);
- return;
- }
super.createFunction(function);
- String url = this.getUrl().isEmpty() ? "nullURL" : this.getUrl();
- /*
- * If the proxy to the extension has not yet been loaded, store the BrowserFunction page ID,
- * function string, and URL in a HashMap. Once the proxy to the extension is loaded, these
- * functions will be sent to and registered in the extension.
- */
- if (!WebkitGDBus.connectionToExtensionCreated) {
- WebkitGDBus.functionsPending = true;
- ArrayList<ArrayList<String>> list = new ArrayList<>();
- ArrayList<String> functionAndUrl = new ArrayList<>();
- functionAndUrl.add(0, function.functionString);
- functionAndUrl.add(1, url);
- list.add(functionAndUrl);
- ArrayList<ArrayList<String>> existing = WebkitGDBus.pendingBrowserFunctions.putIfAbsent(this.pageId, list);
- if (existing != null) {
- existing.add(functionAndUrl);
- }
- } else {
- // If the proxy to the extension is already loaded, register the function in the extension via DBus
- boolean successful = webkit_extension_modify_function(this.pageId, function.functionString, url, "register");
- if (!successful) {
- System.err.println("SWT webkit: failure registering BrowserFunction " + function.name);
- }
- }
}
@Override
public void destroyFunction (BrowserFunction function) {
- // Only deregister functions if the proxy to the extension has been loaded
- if (WebkitGDBus.connectionToExtensionCreated) {
- String url = this.getUrl().isEmpty() ? "nullURL" : this.getUrl();
- boolean successful = webkit_extension_modify_function(this.pageId, function.functionString, url, "deregister");
- if (!successful) {
- System.err.println("SWT webkit: failure deregistering BrowserFunction from extension " + function.name);
- }
- }
super.destroyFunction(function);
}
@@ -330,170 +278,9 @@
return sw.toString();
}
- /**
- * This class deals with the WebKit extension.
- *
- * Extension is separately loaded and deals Javascript callbacks to Java.
- * Extension is needed so that Javascript can receive a return value from Java
- * (for which currently there is no api in WebkitGtk 2.18)
- */
- static class WebKitExtension {
- /** Note, if updating this, you need to change it also in webkitgtk_extension.c */
- private static final String javaScriptFunctionName = "webkit2callJava"; // $NON-NLS-1$
- private static final String webkitWebExtensionIdentifier = "webkitWebExtensionIdentifier"; // $NON-NLS-1$
- private static Callback initializeWebExtensions_callback;
-
- /** GDBusServer returned by WebkitGDBus */
- private static long dBusServer = 0;
-
- /**
- * Don't continue initialization if something failed. This allows Browser to carryout some functionality
- * even if the webextension failed to load.
- */
- private static boolean loadFailed;
-
- static String getJavaScriptFunctionName() {
- return javaScriptFunctionName;
- }
- static String getWebExtensionIdentifier() {
- return webkitWebExtensionIdentifier;
- }
- static String getJavaScriptFunctionDeclaration(long webView) {
- return "if (!window.callJava) {\n"
- + " window.callJava = function callJava(index, token, args) {\n"
- + " return " + javaScriptFunctionName + "('" + String.valueOf(webView) + "', index, token, args);\n"
- + " }\n"
- + "};\n";
- }
-
- static void init() {
- /*
- * Initialize GDBus before the extension, as the extension initialization callback at the C level
- * sends data back to SWT via GDBus. Failure to load GDBus here will result in crashes.
- * See bug 536141.
- */
- dBusServer = gdbus_init();
- if (dBusServer == 0) {
- System.err.println("SWT WebKit: error initializing DBus server, dBusServer == 0");
- }
- initializeWebExtensions_callback = new Callback(WebKitExtension.class, "initializeWebExtensions_callback", void.class, new Type [] {long.class, long.class});
- if (WebKitGTK.webkit_get_minor_version() >= 4) { // Callback exists only since 2.04
- OS.g_signal_connect (WebKitGTK.webkit_web_context_get_default(), WebKitGTK.initialize_web_extensions, initializeWebExtensions_callback.getAddress(), 0);
- }
- }
-
- /**
- * GDbus initialization can cause performance slow downs. So we int GDBus in lazy way.
- * It can be initialized upon first use of BrowserFunction.
- */
- static long gdbus_init() {
- if (WebKitGTK.webkit_get_minor_version() < 4) {
- System.err.println("SWT Webkit: Warning, You are using an old version of webkitgtk. (pre 2.4)"
- + " BrowserFunction functionality will not be available");
- return 0;
- }
-
-
- if (!loadFailed) {
- return WebkitGDBus.init();
- } else {
- return 0;
- }
- }
-
- /**
- * This callback is called to initialize webextension.
- * It is the optimum place to set extension directory and set initialization user data.
- *
- * I've experimented with loading webextension later (to see if we can get performance gains),
- * but found breakage. Webkitgtk doc says it should be loaded as early as possible and specifically best
- * to do it in this calllback.
- *
- * See documenation: WebKitWebExtension (Description)
- */
- @SuppressWarnings("unused") // Only called directly from C
- private static void initializeWebExtensions_callback (long WebKitWebContext, long user_data) {
- // 1) GDBus:
- // Normally we'd first initialize gdbus channel. But gdbus makes Browser slower and isn't always needed.
- // So WebkitGDBus is lazy-initialized, although it can be initialized here if gdbus is ever needed
- // for more than BrowserFunction, like:
- // WebkitGDBus.init(String.valueOf(uniqueID));
- // Also consider only loading gdbus if the extension initialized properly.
-
- // 2) Load Webkit Extension:
- // Webkit extensions should be in their own directory.
- String swtVersion = Library.getVersionString();
- File extension;
- try {
- extension = Library.findResource("webkitextensions" + swtVersion ,"swt-webkit2extension", true);
- if (extension == null){
- throw new UnsatisfiedLinkError("SWT Webkit could not find it's webextension");
- }
- } catch (UnsatisfiedLinkError e) {
- System.err.println("SWT Webkit.java Error: Could not find webkit extension. BrowserFunction functionality will not be available. \n"
- + "(swt version: " + swtVersion + ")" + WebKitGTK.swtWebkitGlueCodeVersion + WebKitGTK.swtWebkitGlueCodeVersionInfo);
- int [] vers = internalGetWebkitVersion();
- System.err.println(String.format("WebKit2Gtk version %s.%s.%s", vers[0], vers[1], vers[2]));
- System.err.println(getInternalErrorMsg());
- loadFailed = true;
- return;
- }
-
- String extensionsFolder = extension.getParent();
- /* Dev note:
- * As per
- * - WebkitSrc: WebKitExtensionManager.cpp,
- * - IRC discussion with annulen
- * you cannot load the webextension GModule directly, (webkitgtk 2.18). You can only specify directory and user data.
- * So we need to treat this '.so' in a special way.
- * (as a note, the webprocess would have to load the gmodule).
- */
- WebKitGTK.webkit_web_context_set_web_extensions_directory(WebKitGTK.webkit_web_context_get_default(), Converter.wcsToMbcs (extensionsFolder, true));
- long clientAddress = OS.g_dbus_server_get_client_address(dBusServer);
- String clientAddressJava = Converter.cCharPtrToJavaString(clientAddress, false);
- long gvariantUserData = OS.g_variant_new_string(clientAddress);
- WebKitGTK.webkit_web_context_set_web_extensions_initialization_user_data(WebKitGTK.webkit_web_context_get_default(), gvariantUserData);
- }
-
- /**
- * @param cb_args Raw callback arguments by function.
- */
- static Object webkit2callJavaCallback(Object [] cb_args) {
- assert cb_args.length == 4;
- Object returnValue = null;
- Long webViewLocal = (Double.valueOf((String) cb_args[0])).longValue();
- Browser browser = FindBrowser((long ) webViewLocal.longValue());
- Integer functionIndex = ((Double) cb_args[1]).intValue();
- String token = (String) cb_args[2];
-
- BrowserFunction function = browser.webBrowser.functions.get(functionIndex);
- if (function == null) {
- System.err.println("SWT Webkit Error: Failed to find function with index: " + functionIndex);
- return null;
- }
- if (!function.token.equals(token)) {
- System.err.println("SWT Webkit Error: token mismatch for function with index: " + functionIndex);
- return null;
- }
- try {
- // Call user code. Exceptions can occur.
- nonBlockingEvaluate++;
- Object [] user_args = (Object []) cb_args[3];
- returnValue = function.function(user_args);
- } catch (Exception e ) {
- // - Something went wrong in user code.
- System.err.println("SWT Webkit: Exception occured in user code of function: " + function.name);
- returnValue = WebBrowser.CreateErrorString (e.getLocalizedMessage ());
- } finally {
- nonBlockingEvaluate--;
- }
- return returnValue;
- }
- }
-
@Override
String getJavaCallDeclaration() {
- return WebKitExtension.getJavaScriptFunctionDeclaration(webView);
+ return super.getJavaCallDeclaration();
}
/**
@@ -1005,46 +792,6 @@
}
}
-/**
- * Modifies a BrowserFunction in the web extension. This method can be used to register/deregister BrowserFunctions
- * in the web extension, so that those BrowserFunctions are executed upon triggering of the object_cleared callback (in
- * the extension, not in Java).
- *
- * This function will return true if: the operation succeeds synchronously, or if the synchronous call timed out and an
- * asynchronous call was performed instead. All other cases will return false.
- *
- * Supported actions: "register" and "deregister"
- *
- * @param pageId the page ID of the WebKit instance/web page
- * @param function the function string
- * @param url the URL
- * @param action the action being performed on the function, which will be used to form the DBus method name.
- * @return true if the action succeeded (or was performed asynchronously), false if it failed
- */
-private boolean webkit_extension_modify_function (long pageId, String function, String url, String action){
- long[] args = { OS.g_variant_new_uint64(pageId),
- OS.g_variant_new_string (Converter.javaStringToCString(function)),
- OS.g_variant_new_string (Converter.javaStringToCString(url))};
- final long argsTuple = OS.g_variant_new_tuple(args, args.length);
- if (argsTuple == 0) return false;
- String dbusMethodName = "webkitgtk_extension_" + action + "_function";
- Object returnVal = WebkitGDBus.callExtensionSync(argsTuple, dbusMethodName);
- if (returnVal instanceof Boolean) {
- return (Boolean) returnVal;
- } else if (returnVal instanceof String) {
- String returnString = (String) returnVal;
- /*
- * Call the extension asynchronously if a synchronous call times out.
- * Note: this is a pretty rare case, and usually only happens when running test cases.
- * See bug 536141.
- */
- if ("timeout".equals(returnString)) {
- return WebkitGDBus.callExtensionAsync(argsTuple, dbusMethodName);
- }
- }
- return false;
-}
-
@Override
public boolean execute (String script) {
if (!isJavascriptEnabled()) {
@@ -1174,27 +921,6 @@
* SWT implementation.
*
* If in doubt, you should use nonBlockingExecute() where possible :-).
- *
- * TODO_SOMEDAY:
- * - Instead of async js execution and waiting for return value, it might be
- * better to use gdbus, connect to webextension and execute JS synchronously.
- * See: https://blogs.igalia.com/carlosgc/2013/09/10/webkit2gtk-web-process-extensions/
- * 'Extending JavaScript'
- * Pros:
- * - less likely deadlocks would occur due to developer error/not being careful.
- * - js execution can work in synchronous callbacks from webkit.
- * Cons:
- * - High implementation cost/complexity.
- * - Unexpected errors/behaviour due to GDBus timeouts.
- * Proof of concept:
- * https://git.eclipse.org/r/#/c/23416/16/bundles/org.eclipse.swt/Eclipse+SWT+WebKit/gtk/library/webkit_extension.c
- * > 'webkit_extension_execute_script'
- * Tennative structure:
- * - Webextension should create gdbus server, make & communicate UniqueID (pid) to main proc
- * - main proc should make a note of webextension's name+uniqueID
- * - implement mechanism for packaging Java objects into gvariants, (see WebkitGDBus.java),
- * - call webextension over gdbus, parse return value.
- *
*/
static Object runjavascript(String script, Browser browser, long webView) {
if (nonBlockingEvaluate > 0) {
@@ -1373,7 +1099,7 @@
* triggers.
*/
Consumer<Integer> asyncFunc = (callbackID) -> WebKitGTK.webkit_cookie_manager_get_cookies(cookieManager, uri, 0,
- getCookie_callback.getAddress(), WebkitGDBus.convertJavaToGVariant(new Object [] {cookieName, callbackID}));
+ getCookie_callback.getAddress(), GDBus.convertJavaToGVariant(new Object [] {cookieName, callbackID}));
Webkit2AsyncReturnObj retObj = execAsyncAndWaitForReturn(cookieBrowser, asyncFunc, " getCookie() was called");
if (retObj.swtAsyncTimeout) {
@@ -1385,7 +1111,7 @@
@SuppressWarnings("unused") // Callback only called only by C directly
private static void getCookie_callback(long cookieManager, long result, long user_data) {
- Object resultObject = WebkitGDBus.convertGVariantToJava(user_data);
+ Object resultObject = GDBus.convertGVariantToJava(user_data);
// We are expecting a GVariant tuple, anything else means something went wrong
if (resultObject instanceof Object []) {
@@ -2814,38 +2540,6 @@
OS.g_object_set(settings, property, value, 0);
}
-long convertToJS (long ctx, Object value) {
- if (value == null) {
- return WebKitGTK.JSValueMakeUndefined (ctx);
- }
- if (value instanceof String) {
- byte[] bytes = ((String)value + '\0').getBytes (StandardCharsets.UTF_8); //$NON-NLS-1$
- long stringRef = WebKitGTK.JSStringCreateWithUTF8CString (bytes);
- long result = WebKitGTK.JSValueMakeString (ctx, stringRef);
- WebKitGTK.JSStringRelease (stringRef);
- return result;
- }
- if (value instanceof Boolean) {
- return WebKitGTK.JSValueMakeBoolean (ctx, ((Boolean)value).booleanValue () ? 1 : 0);
- }
- if (value instanceof Number) {
- return WebKitGTK.JSValueMakeNumber (ctx, ((Number)value).doubleValue ());
- }
- if (value instanceof Object[]) {
- Object[] arrayValue = (Object[]) value;
- int length = arrayValue.length;
- long [] arguments = new long [length];
- for (int i = 0; i < length; i++) {
- Object javaObject = arrayValue[i];
- long jsObject = convertToJS (ctx, javaObject);
- arguments[i] = jsObject;
- }
- return WebKitGTK.JSObjectMakeArray (ctx, length, arguments, null);
- }
- SWT.error (SWT.ERROR_INVALID_RETURN_VALUE);
- return 0;
-}
-
static Object convertToJava (long ctx, long value) {
int type = WebKitGTK.JSValueGetType (ctx, value);
switch (type) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebkitGDBus.java b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebkitGDBus.java
deleted file mode 100644
index 89f0732..0000000
--- a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebkitGDBus.java
+++ /dev/null
@@ -1,666 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2017, 2022 Red Hat and others. All rights reserved.
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- *
- * Contributors:
- * Red Hat - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.swt.browser;
-
-import java.util.*;
-import java.util.Map.*;
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.widgets.*;
-
-/**
- * Logic for Webkit to interact with it's Webkit extension via GDBus.
- *
- * While this class supports quite a bit of GDBus and gvariant support, it is by no means a complete
- * implementation and it's tailored to support Java to Javascript conversion. (E.g all Numbers are converted to Double).
- * If this is ever to be used outside of Webkit, then care must be taken to deal with
- * cases that are not currently implemented/used. See: WebKitGTK.java 'TYPE NOTES'
- *
- * For hygiene purposes, GVariant types should not be leaving this class. Convert on the way in/out.
- *
- * @category gdbus
- */
-class WebkitGDBus {
- /*
- * If any of the GDBus names/paths/interfaces need to be changed, then they also need to be changed
- * in the extension (webkitgtk_extension.c).
- */
-
- /* WEBKITGDBUS_DBUS_NAME isn't actually used but is here for informative purposes */
- @SuppressWarnings("unused")
- private static final String WEBKITGDBUS_DBUS_NAME = "org.eclipse.swt";
- private static final byte [] WEBKITGDBUS_OBJECT_PATH = Converter.javaStringToCString("/org/eclipse/swt/gdbus");
- private static final String WEBKITGDBUS_INTERFACE_NAME_JAVA = "org.eclipse.swt.gdbusInterface";
- private static final byte [] WEBKITGDBUS_INTERFACE_NAME = Converter.javaStringToCString("org.eclipse.swt.gdbusInterface");
-
- /* Extension connection details, in byte [] form */
- private static final byte [] EXTENSION_DBUS_NAME = Converter.javaStringToCString("org.eclipse.swt.webkitgtk_extension");
- private static final byte [] EXTENSION_OBJECT_PATH = Converter.javaStringToCString("/org/eclipse/swt/webkitgtk_extension/gdbus");
- private static final byte [] EXTENSION_INTERFACE_NAME = Converter.javaStringToCString("org.eclipse.swt.webkitgtk_extension.gdbusInterface");
-
- /** Extension GDBusServer client address */
- private static String EXTENSION_DBUS_SERVER_CLIENT_ADDRESS;
-
- /* Accepted GDBus methods */
- private static final String webkit2callJava = WebKit.WebKitExtension.getJavaScriptFunctionName();
- private static final String webkitWebExtensionIdentifier = WebKit.WebKitExtension.getWebExtensionIdentifier();
-
- /* Connections */
- /** GDBusConnection from the web extension */
- static long connectionFromExtension;
- /** GDBusConnection to the web extension */
- static long connectionToExtension;
- /** A field that is set to true if the proxy connection has been established, false otherwise. */
- static boolean connectionToExtensionCreated;
-
- /* Server related objects */
- /** GDBusServer for the main SWT process */
- private static long gDBusServer = 0;
- /** GDBusAuthObserver for the server */
- private static long authObserver = 0;
- /** GUID of the GDBusServer */
- private static long guid = 0;
-
- /** Display this GDBus class is "attached" to */
- static Display display;
-
-
- // BrowserFunction logic
- /** Set to true if there are <code>BrowserFunction</code> objects waiting to be registered with the web extension.*/
- static boolean functionsPending;
- /**
- * HashMap that stores any BrowserFunctions which have been created but not yet registered with the web extension.
- * These functions will be registered with the web extension as soon as the proxy to the extension is set up.
- *
- * The format of the HashMap is (page ID, list of function string and URL).
- */
- static HashMap<Long, ArrayList<ArrayList<String>>> pendingBrowserFunctions = new HashMap<>();
-
-
- /**
- * Interface is read/parsed at run time. No compilation with gdbus-code-gen necessary.
- *
- * Note,
- * - When calling a method via g_dbus_proxy_call_sync(..g_variant params..),
- * the g_variant that describes parameters should only mirror incoming parameters.
- * Each type is a separate argument.
- * e.g:
- * g_variant xml:
- * "(si)", "string", 42 .. arg type='s'
- * .. arg type='i'
- *
- * - Nested parameters need to have a 2nd bracket around them.
- * e.g:
- * g_variant xml:
- * "((r)i)", *gvariant, 42 .. arg type='r'
- * .. arg type='i'
- *
- * - '@' is a pointer to a gvariant. so '@r' is a pointer to nested type, i.e *gvariant
- *
- * To understand the mappings, it's good to understand DBus and GVariant's syntax:
- * https://dbus.freedesktop.org/doc/dbus-specification.html#idm423
- * https://developer.gnome.org/glib/stable/glib-GVariantType.html
- *
- * Be mindful about only using supported DBUS_TYPE_* , as convert* methods might fail otherwise.
- * Alternatively, modify convert* methods.
- */
- private static final byte [] WEBKITGDBUS_INTROSPECTION_XML = Converter.javaStringToCString(
- "<node>"
- + " <interface name='" + WEBKITGDBUS_INTERFACE_NAME_JAVA + "'>"
- + " <method name='" + webkit2callJava + "'>"
- + " <arg type='"+ OS.DBUS_TYPE_STRING + "' name='webViewPtr' direction='in'/>"
- + " <arg type='"+ OS.DBUS_TYPE_DOUBLE + "' name='index' direction='in'/>"
- + " <arg type='"+ OS.DBUS_TYPE_STRING + "' name='token' direction='in'/>"
- + " <arg type='" + OS.DBUS_TYPE_SINGLE_COMPLETE + "' name='arguments' direction='in'/>"
- + " <arg type='" + OS.DBUS_TYPE_SINGLE_COMPLETE + "' name='result' direction='out'/>"
- + " </method>"
- + " <method name='" + webkitWebExtensionIdentifier + "'>"
- + " <arg type='"+ OS.DBUS_TYPE_STRING + "' name='webExtensionServerAddress' direction='in'/>"
- + " <arg type='"+ OS.DBUS_TYPE_STRUCT_ARRAY_BROWSER_FUNCS + "' name='result' direction='out'/>"
- + " </method>"
- + " </interface>"
- + "</node>");
-
- /**
- * GDBus/DBus doesn't have a notion of Null.
- * To get around this, we use magic numbers to represent special cases.
- * Currently this is specific to Webkit to deal with Javascript data type conversions.
- * @category gdbus */
- private static final byte SWT_DBUS_MAGIC_NUMBER_EMPTY_ARRAY = 101;
- /** @category gdbus */
- private static final byte SWT_DBUS_MAGIC_NUMBER_NULL = 48;
-
-
- /** Callback for GDBus method handling */
- private static Callback handleMethodCB;
- /** Callback for incoming connections to WebkitGDBus' server */
- private static Callback newConnectionCB;
- /** Callback for creating a new connection to the web extension */
- private static Callback newConnectionToExtensionCB;
- /** Callback for authenticating connections to WebkitGDBus' server */
- private static Callback authenticatePeerCB;
- /** Callback for asynchronous proxy calls to the extension */
- private static Callback callExtensionAsyncCB;
-
- static {
- handleMethodCB = new Callback (WebkitGDBus.class, "handleMethodCB", 8); //$NON-NLS-1$
- callExtensionAsyncCB = new Callback (WebkitGDBus.class, "callExtensionAsyncCB", 3); //$NON-NLS-1$
- newConnectionCB = new Callback (WebkitGDBus.class, "newConnectionCB", 3); //$NON-NLS-1$
- newConnectionToExtensionCB = new Callback (WebkitGDBus.class, "newConnectionToExtensionCB", 3); //$NON-NLS-1$
- authenticatePeerCB = new Callback (WebkitGDBus.class, "authenticatePeerCB", 4); //$NON-NLS-1$
- }
-
- /** True iff the GDBusServer has been initialized */
- static boolean initialized;
- /** True iff this class has been attached to a Display */
- static boolean attachedToDisplay;
-
- /** This method is in an internal class and is not intended to be referenced by clients. */
- static long init () {
- if (initialized) {
- return gDBusServer;
- }
- initialized = true;
-
- // Generate address and GUID
- long address = construct_server_address();
- authObserver = OS.g_dbus_auth_observer_new();
- guid = OS.g_dbus_generate_guid();
-
- // Create server
- long [] error = new long [1];
- gDBusServer = OS.g_dbus_server_new_sync(address, OS.G_DBUS_SERVER_FLAGS_NONE, guid, authObserver, 0, error);
-
- // Connect authentication and incoming connections signals to the newly created server, and start it
- if (gDBusServer != 0) {
- OS.g_signal_connect(gDBusServer, OS.new_connection, newConnectionCB.getAddress(), 0);
- OS.g_signal_connect(authObserver, OS.authorize_authenticated_peer, authenticatePeerCB.getAddress(), 0);
- OS.g_dbus_server_start(gDBusServer);
- } else {
- System.err.println("SWT WebKitGDBus: error creating DBus server " + Display.extractFreeGError(error[0]));
- }
- return gDBusServer;
- }
-
- /**
- * Sets the Display for this class. This allows WebkitGDBus to attach its servers and related objects
- * to the provided Display. When the Display is disposed, it will will release the GDBus related
- * resources.
- *
- * @param displayToSet the Display to set
- */
- static void setDisplay (Display displayToSet) {
- if (!attachedToDisplay) {
- display = displayToSet;
-
- /*
- * Add the GDBusServer, GDBusAuthObserver, and GUID to the Display.
- * Note that we don't add the connections yet, because they likely
- * don't exist. Those are added in callbacks as they come in.
- */
- if (gDBusServer != 0) display.dBusServers.add(gDBusServer);
- if (authObserver != 0) display.dBusAuthObservers.add(authObserver);
- if (guid != 0) display.dBusGUIDS.add(guid);
- attachedToDisplay = true;
- }
- }
-
- /**
- * Constructs an address at which the GDBus server for the SWT main process
- * can be reached.
- *
- * @return a pointer to the address
- */
- private static long construct_server_address () {
- // On Linux, the address required is used for as an abstract path. If abstract path is not supported
- // one must create & manage temporary directories. See Bug562443.
- byte [] address = Converter.wcsToMbcs("unix:tmpdir=/tmp/SWT-GDBusServer", true);
- long addressPtr = OS.g_malloc(address.length);
- C.memmove(addressPtr, address, address.length);
-
- return addressPtr;
- }
-
- /**
- * This is called when a client call one of the GDBus methods.
- *
- * Developer note:
- * This method can be reached directly from GDBus cmd utility:
- * gdbus call --session --dest org.eclipse.swt<UNIQUE_ID> --object-path /org/eclipse/swt/gdbus --method org.eclipse.swt.gdbusInterface.HelloWorld
- * where as you tab complete, you append the UNIQUE_ID.
- *
- * @param connection GDBusConnection
- * @param sender const gchar
- * @param object_path const gchar
- * @param interface_name const gchar
- * @param method_name const gchar
- * @param gvar_parameters GVariant
- * @param invocation GDBusMethodInvocation
- * @param user_data gpointer
- * @return
- */
- @SuppressWarnings("unused") // callback not directly called by SWT
- private static long handleMethodCB (
- long connection, long sender,
- long object_path, long interface_name,
- long method_name, long gvar_parameters,
- long invocation, long user_data) {
-
- String java_method_name = Converter.cCharPtrToJavaString(method_name, false);
- Object result = null;
- if (java_method_name != null) {
- if (java_method_name.equals(webkit2callJava)) {
- try {
- Object [] java_parameters = (Object []) convertGVariantToJava(gvar_parameters);
- result = WebKit.WebKitExtension.webkit2callJavaCallback(java_parameters);
- } catch (Exception e) {
- // gdbus should always return to prevent extension from hanging.
- result = WebBrowser.CreateErrorString (e.getLocalizedMessage ());
- System.err.println("SWT WebkitGDBus: Exception occured in Webkit2 callback logic.");
- }
- } else if (java_method_name.equals(webkitWebExtensionIdentifier)) {
- Object [] serverAddress = (Object []) convertGVariantToJava(gvar_parameters);
- if (serverAddress[0] instanceof String) {
- EXTENSION_DBUS_SERVER_CLIENT_ADDRESS = (String) serverAddress[0];
- // Connect to the extension's server by creating a connection asynchronously
- createConnectionToExtension();
- /*
- * Return any pending BrowserFunctions that were created before WebkitGDBus
- * was initialized.
- */
- invokeReturnValueExtensionIdentifier(pendingBrowserFunctions, invocation);
- } else {
- System.err.println("SWT WebkitGDBus: error in web extension identification process."
- + " BrowserFunction may not work.");
- }
- return 0;
- }
- } else {
- result = "SWT WebkitGDBus: GDBus called an unknown method?";
- System.err.println("SWT WebkitGDBus: Received a call from an unknown method: " + java_method_name);
- }
- invokeReturnValue(result, invocation);
- return 0;
- }
-
- @SuppressWarnings("unused") // callback not directly called by SWT
- private static long callExtensionAsyncCB (long source_object, long result, long user_data) {
- long [] error = new long [1];
- long gVariantResult = OS.g_dbus_connection_call_finish (connectionToExtension, result, error);
- if (error[0] != 0) {
- String msg = Display.extractFreeGError(error[0]);
- System.err.println("SWT WebkitGDBus: there was an error executing something asynchronously with the extension (Java callback).");
- System.err.println("SWT WebkitGDBus: the error message provided is " + msg);
- }
- OS.g_variant_unref(gVariantResult);
- return 0;
- }
-
- @SuppressWarnings("unused") // callback not directly called by SWT
- private static long authenticatePeerCB (long observer, long stream, long credentials, long user_data) {
- boolean authorized = false;
- if (credentials != 0) {
- long[] error = new long [1];
- long ownCredentials = OS.g_credentials_new();
- authorized = OS.g_credentials_is_same_user(credentials, ownCredentials, error);
- if (error[0] != 0) {
- String msg = Display.extractFreeGError(error[0]);
- System.err.println("SWT WebkitGDBus: error authenticating client connection to server " + msg);
- }
- OS.g_object_unref(ownCredentials);
- }
- return authorized ? 1 : 0;
- }
-
- @SuppressWarnings("unused") // callback not directly called by SWT
- private static long newConnectionCB (long server, long connection, long user_data) {
- long gdBusNodeInfo;
- long [] error = new long [1];
- gdBusNodeInfo = OS.g_dbus_node_info_new_for_xml(WEBKITGDBUS_INTROSPECTION_XML, error);
- if (gdBusNodeInfo == 0 || error[0] != 0) {
- System.err.println("SWT WebkitGDBus: failed to get introspection data");
- }
- assert gdBusNodeInfo != 0 : "SWT WebKitGDBus: introspection data should not be 0";
-
- long interface_info = OS.g_dbus_node_info_lookup_interface(gdBusNodeInfo, WEBKITGDBUS_INTERFACE_NAME);
- long[] vtable = { handleMethodCB.getAddress(), 0, 0 };
-
- OS.g_dbus_connection_register_object(
- connection,
- WEBKITGDBUS_OBJECT_PATH,
- interface_info,
- vtable,
- 0, // user_data
- 0, // user_data_free_func
- error);
-
- if (error[0] != 0) {
- System.err.println("SWT WebKitGDBus: failed to register object: " + WEBKITGDBUS_OBJECT_PATH);
- return 0;
- }
-
- // Ref the connection and add it to the Display's list of connections
- connectionFromExtension = OS.g_object_ref(connection);
- if (attachedToDisplay && display != null) {
- if (!display.dBusConnections.contains(connection)) display.dBusConnections.add(connectionFromExtension);
- }
- return 1;
- }
-
- @SuppressWarnings("unused") // callback not directly called by SWT
- private static long newConnectionToExtensionCB (long sourceObject, long result, long user_data) {
- long [] error = new long [1];
- connectionToExtension = OS.g_dbus_connection_new_for_address_finish(result, error);
- if (error[0] != 0) {
- System.err.println("SWT WebKitGDBus: error finishing connection: " + Display.extractFreeGError(error[0]));
- return 0;
- } else {
- connectionToExtensionCreated = true;
- }
-
- // Add the connections to the Display's list of connections
- if (attachedToDisplay && display != null) {
- if (!display.dBusConnections.contains(connectionToExtension)) display.dBusConnections.add(connectionToExtension);
- }
- return 0;
- }
-
- /**
- * Returns a GVariant to the DBus invocation of the extension identifier method. When the extension
- * is initialized it sends a DBus message to the SWT webkit instance. As a return value, the SWT webkit
- * instance sends any BrowserFunctions that have been registered. If no functions have been registered,
- * an "empty" function with a page ID of -1 is sent.
- *
- * @param map the HashMap of BrowserFunctions waiting to be registered in the extension, or null
- * if you'd like to explicitly send an empty function signature
- * @param invocation the GDBus invocation to return the value on
- */
- private static void invokeReturnValueExtensionIdentifier (HashMap<Long, ArrayList<ArrayList<String>>> map,
- long invocation) {
- long resultGVariant;
- long builder;
- long type = OS.g_variant_type_new(OS.G_VARIANT_TYPE_ARRAY_BROWSER_FUNCS);
- builder = OS.g_variant_builder_new(type);
- if (builder == 0) return;
- Object [] tupleArray = new Object[3];
- boolean sendEmptyFunction;
- if (map == null) {
- sendEmptyFunction = true;
- } else {
- sendEmptyFunction = map.isEmpty() && !functionsPending;
- }
- /*
- * No functions to register, send a page ID of -1 and empty strings.
- */
- if (sendEmptyFunction) {
- tupleArray[0] = (long)-1;
- tupleArray[1] = "";
- tupleArray[2] = "";
- long tupleGVariant = convertJavaToGVariant(tupleArray);
- if (tupleGVariant != 0) {
- OS.g_variant_builder_add_value(builder, tupleGVariant);
- } else {
- System.err.println("SWT WebKitGDBus: error creating empty BrowserFunction GVariant tuple, skipping.");
- }
- } else {
- for (Entry<Long, ArrayList<ArrayList<String>>> entry : map.entrySet()) {
- ArrayList<ArrayList<String>> list = entry.getValue();
- if (list != null) {
- for (ArrayList<String> stringList : list) {
- Object [] stringArray = stringList.toArray();
- if (stringArray.length > 2) {
- System.err.println("SWT WebKitGDBus: String array with BrowserFunction and URL should never have"
- + "more than 2 Strings");
- }
- tupleArray[0] = entry.getKey();
- System.arraycopy(stringArray, 0, tupleArray, 1, 2);
- long tupleGVariant = convertJavaToGVariant(tupleArray);
- if (tupleGVariant != 0) {
- OS.g_variant_builder_add_value(builder, tupleGVariant);
- } else {
- System.err.println("SWT WebKitGDBus: error creating BrowserFunction GVariant tuple, skipping.");
- }
- }
- }
- }
- }
- resultGVariant = OS.g_variant_builder_end(builder);
- String typeString = Converter.cCharPtrToJavaString(OS.g_variant_get_type_string(resultGVariant), false);
- if (!OS.DBUS_TYPE_STRUCT_ARRAY_BROWSER_FUNCS.equals(typeString)) {
- System.err.println("SWT WebKitGDBus: an error packaging the GVariant occurred: type mismatch.");
- }
- long [] variants = {resultGVariant};
- long finalGVariant = OS.g_variant_new_tuple(variants, 1);
- OS.g_dbus_method_invocation_return_value(invocation, finalGVariant);
- OS.g_variant_builder_unref(builder);
- OS.g_variant_type_free(type);
- }
-
- private static void invokeReturnValue (Object result, long invocation) {
- long resultGVariant = 0;
- try {
- resultGVariant = convertJavaToGVariant(new Object [] {result}); // Result has to be a tuple.
- } catch (SWTException e) {
- // gdbus should always return to prevent extension from hanging.
- String errMsg = WebBrowser.CreateErrorString (e.getLocalizedMessage ());
- resultGVariant = convertJavaToGVariant(new Object [] {errMsg});
- }
- OS.g_dbus_method_invocation_return_value(invocation, resultGVariant);
- }
-
- /**
- * Asynchronously initializes a GDBusConnection to the web extension. Connection process
- * will be confirmed when the newConnectionToExtension callback is called.
- */
- private static void createConnectionToExtension() {
- byte [] address = Converter.javaStringToCString(EXTENSION_DBUS_SERVER_CLIENT_ADDRESS);
- long [] error = new long [1];
- // Create connection asynchronously to avoid deadlock issues
- OS.g_dbus_connection_new_for_address (address, OS.G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT,
- 0, 0, newConnectionToExtensionCB.getAddress(), 0);
-
- if (error[0] != 0) {
- System.err.println("SWT WebkitGDBus: error creating connection to the extension "
- + Display.extractFreeGError(error[0]));
- }
- }
-
- /**
- * Calls the web extension synchronously. Returns true if the operation succeeded, and false
- * otherwise (or if the operation times out).
- *
- * @param params a pointer to the GVariant containing the parameters
- * @param methodName a String representing the DBus method name in the extension
- * @return an Object representing the return value from DBus in boolean form
- */
- static Object callExtensionSync (long params, String methodName) {
- long [] error = new long [1]; // GError **
- long gVariant = OS.g_dbus_connection_call_sync(connectionToExtension, EXTENSION_DBUS_NAME, EXTENSION_OBJECT_PATH,
- EXTENSION_INTERFACE_NAME, Converter.javaStringToCString(methodName), params,
- 0, OS.G_DBUS_CALL_FLAGS_NO_AUTO_START, 1000, 0, error);
- if (error[0] != 0) {
- String msg = Display.extractFreeGError(error[0]);
- /*
- * Don't print console warnings for timeout errors, as we can handle these ourselves.
- * Note, most timeout errors happen only when running test cases, not during "normal" use.
- */
- if (msg != null && (!msg.contains("Timeout") && !msg.contains("timeout"))) {
- System.err.println("SWT WebKitGDBus: there was an error executing something synchronously with the extension.");
- System.err.println("SWT WebKitGDBus: the error message is: " + msg);
- return false;
- }
- return "timeout";
- }
- Object resultObject = gVariant != 0 ? convertGVariantToJava(gVariant) : (Object) false;
- // Sometimes we get back tuples from GDBus, which get converted into Object arrays. In this case
- // we only care about the first value, since the extension never returns anything more than that.
- if (resultObject instanceof Object[]) {
- return ((Object []) resultObject)[0];
- }
- return resultObject;
- }
-
- /**
- * Calls the web extension asynchronously. Note, this method returning true does not
- * guarantee the operation's success, it only means no errors occurred.
- *
- * @param params a pointer to the GVariant containing the parameters
- * @param methodName a String representing the DBus method name in the extension
- * @return true if the extension was called without errors, false otherwise
- */
- static boolean callExtensionAsync (long params, String methodName) {
- long [] error = new long [1]; // GError **
- OS.g_dbus_connection_call(connectionToExtension, EXTENSION_DBUS_NAME, EXTENSION_OBJECT_PATH,
- EXTENSION_INTERFACE_NAME, Converter.javaStringToCString(methodName), params,
- 0, OS.G_DBUS_CALL_FLAGS_NO_AUTO_START, 1000, 0, callExtensionAsyncCB.getAddress(), 0);
- if (error[0] != 0) {
- String msg = Display.extractFreeGError(error[0]);
- System.err.println("SWT WebKitGDBus: there was an error executing something asynchronously "
- + "with the extension.");
- System.err.println("SWT WebKitGDBus: the error message is: " + msg);
- return false;
- }
- return true;
- }
-
- /* TYPE NOTES
- *
- * GDBus doesn't support all the types that we need. I used encoded 'byte' to translate some types.
- *
- * - 'null' is not supported. I thought to potentially use 'maybe' types, but they imply a possible NULL of a certain type, but not null itself.
- * so I use 'byte=48' (meaning '0' in ASCII) to denote null.
- *
- * - Empty arrays/structs are not supported by gdbus.
- * "Container types ... Empty structures are not allowed; there must be at least one type code between the parentheses"
- * src: https://dbus.freedesktop.org/doc/dbus-specification.html
- * I used byte=101 (meaning 'e' in ASCII) to denote empty array.
- *
- * In Javascript all Number types seem to be 'double', (int/float/double/short -> Double). So we convert everything into double accordingly.
- *
- * DBus Type info: https://dbus.freedesktop.org/doc/dbus-specification.html#idm423
- * GDBus Type info: https://developer.gnome.org/glib/stable/glib-GVariantType.html
- */
-
- /**
- * Converts the given GVariant to a Java object.
- * (Only subset of types is currently supported).
- *
- * We assume that the given gvariant does not contain errors. (checked by webextension first).
- *
- * @param gVariant a pointer to the native GVariant
- */
- static Object convertGVariantToJava(long gVariant){
-
- if (OS.g_variant_is_of_type(gVariant, OS.G_VARIANT_TYPE_BOOLEAN)){
- return OS.g_variant_get_boolean(gVariant);
- }
-
- // see: WebKitGTK.java 'TYPE NOTES'
- if (OS.g_variant_is_of_type(gVariant, OS.G_VARIANT_TYPE_BYTE)) {
- byte byteVal = OS.g_variant_get_byte(gVariant);
-
- switch (byteVal) {
- case WebkitGDBus.SWT_DBUS_MAGIC_NUMBER_NULL:
- return null;
- case WebkitGDBus.SWT_DBUS_MAGIC_NUMBER_EMPTY_ARRAY:
- return new Object [0];
- default:
- System.err.println("SWT WebKitGDBus: received an unsupported byte type via GDBus: " + byteVal);
- break;
- }
- }
-
- if (OS.g_variant_is_of_type(gVariant, OS.G_VARIANT_TYPE_DOUBLE)){
- return OS.g_variant_get_double(gVariant);
- }
-
- if (OS.g_variant_is_of_type(gVariant, OS.G_VARIANT_TYPE_UINT64)){
- return OS.g_variant_get_uint64(gVariant);
- }
-
- if (OS.g_variant_is_of_type(gVariant, OS.G_VARIANT_TYPE_STRING)){
- return Converter.cCharPtrToJavaString(OS.g_variant_get_string(gVariant, null), false);
- }
-
- if (OS.g_variant_is_of_type(gVariant, OS.G_VARIANT_TYPE_TUPLE)){
- int length = (int)OS.g_variant_n_children (gVariant);
- Object[] result = new Object[length];
- for (int i = 0; i < length; i++) {
- result[i] = convertGVariantToJava (OS.g_variant_get_child_value(gVariant, i));
- }
- return result;
- }
-
- String typeString = Converter.cCharPtrToJavaString(OS.g_variant_get_type_string(gVariant), false);
- SWT.error (SWT.ERROR_INVALID_ARGUMENT, new Throwable("Unhandled variant type " + typeString ));
- return null;
- }
-
- /**
- * Converts the given Java Object to a GVariant * representation.
- * (Only subset of types is currently supported).
- *
- * We assume that input Object may contain invalid types.
- *
- * @return pointer GVariant *
- */
- static long convertJavaToGVariant(Object javaObject) throws SWTException {
-
- if (javaObject == null) {
- return OS.g_variant_new_byte(WebkitGDBus.SWT_DBUS_MAGIC_NUMBER_NULL); // see: WebKitGTK.java 'TYPE NOTES'
- }
-
- if (javaObject instanceof Long) {
- return OS.g_variant_new_uint64((Long) javaObject);
- }
-
- if (javaObject instanceof String) {
- return OS.g_variant_new_string (Converter.javaStringToCString((String) javaObject));
- }
-
- if (javaObject instanceof Boolean) {
- return OS.g_variant_new_boolean((Boolean) javaObject);
- }
-
- // We treat Integer, Long, Double, Short as a 'double' because in Javascript these are all 'double'.
- // Note, they all extend 'Number' java type, so they are an instance of it.
- if (javaObject instanceof Number) { // see: WebKitGTK.java 'TYPE NOTES'
- return OS.g_variant_new_double (((Number) javaObject).doubleValue());
- }
-
- if (javaObject instanceof Object[]) {
- Object[] arrayValue = (Object[]) javaObject;
- int length = arrayValue.length;
-
- if (length == 0) {
- return OS.g_variant_new_byte(WebkitGDBus.SWT_DBUS_MAGIC_NUMBER_EMPTY_ARRAY); // see: WebKitGTK.java 'TYPE NOTES'
- }
-
- long[] variants = new long [length];
-
- for (int i = 0; i < length; i++) {
- variants[i] = convertJavaToGVariant(arrayValue[i]);
- }
-
- return OS.g_variant_new_tuple(variants, length);
- }
- System.err.println("SWT WebKitGDBus: invalid object being returned to JavaScript: " + javaObject.toString() + "\n"
- + "Only the following are supported: null, String, Boolean, Number(Long,Integer,Double...), Object[] of basic types");
- throw new SWTException(SWT.ERROR_INVALID_ARGUMENT, "Given object is not valid: " + javaObject.toString());
- }
-}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/internal/webkit/WebKitGTK.java b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/internal/webkit/WebKitGTK.java
index d02d7f9..b87c383 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/internal/webkit/WebKitGTK.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/internal/webkit/WebKitGTK.java
@@ -114,9 +114,6 @@
public static final byte[] failed = ascii ("failed"); // $NON-NLS-1$
public static final byte[] finished = ascii ("finished"); // $NON-NLS-1$
- // Webkit2 extension
- public static final byte[] initialize_web_extensions = ascii ("initialize-web-extensions");
-
// Status text signals
public static final byte[] mouse_target_changed = ascii ("mouse-target-changed"); // $NON-NLS-1$
@@ -180,9 +177,6 @@
public static final native long JSObjectGetPropertyAtIndex(long ctx, long object, int propertyIndex, long [] exception);
/** @method flags=dynamic */
-public static final native long JSObjectMakeArray(long ctx, long argumentCount, long [] arguments, long [] exception);
-
-/** @method flags=dynamic */
public static final native long JSStringCreateWithUTF8CString(byte[] string);
/** @method flags=dynamic */
@@ -203,18 +197,6 @@
public static final native int JSValueGetType(long ctx, long value);
/** @method flags=dynamic */
-public static final native long JSValueMakeBoolean(long ctx, int bool);
-
-/** @method flags=dynamic */
-public static final native long JSValueMakeNumber(long ctx, double number);
-
-/** @method flags=dynamic */
-public static final native long JSValueMakeString(long ctx, long string);
-
-/** @method flags=dynamic */
-public static final native long JSValueMakeUndefined(long ctx);
-
-/** @method flags=dynamic */
public static final native double JSValueToNumber(long ctx, long value, long [] exception);
/** @method flags=dynamic */
@@ -444,14 +426,6 @@
/** @method flags=dynamic */
public static final native long webkit_web_view_new_with_related_view(long web_view);
-
-/** @method flags=dynamic */ // @param context cast=(WebKitWebContext*) @param directory cast=(const gchar *)
-public static final native void webkit_web_context_set_web_extensions_directory(long context, byte[] directory);
-
-/** @method flags=dynamic */
-public static final native void webkit_web_context_set_web_extensions_initialization_user_data(long /* int */ context, long /* int */ user_data);
-
-
/**
* @method flags=dynamic
* @param js_result cast=(gpointer)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/GDBus.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/GDBus.java
index 8bda62b..78def99 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/GDBus.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/GDBus.java
@@ -335,7 +335,7 @@
*
* @param gVariant a pointer to the native GVariant
*/
- private static Object[] convertGVariantToJava(long gVariant) {
+ public static Object[] convertGVariantToJava(long gVariant) {
Object retVal = convertGVariantToJavaHelper(gVariant);
if (retVal instanceof Object[]) {
return (Object[]) retVal;
@@ -405,7 +405,7 @@
*
* @return pointer GVariant *
*/
- private static long convertJavaToGVariant(Object javaObject) throws SWTException {
+ public static long convertJavaToGVariant(Object javaObject) throws SWTException {
if (javaObject == null) {
return 0;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
index f59a441..4eaa9e6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
@@ -222,19 +222,6 @@
SessionManagerListener sessionManagerListener;
Runnable [] disposeList;
- /*
- * DBus objects to be freed upong Display release. Only public for use in
- * other areas of SWT (i.e. WebKit). See bug 540060.
- */
- /** @noreference */
- public java.util.List<Long> dBusServers = new ArrayList<>();
- /** @noreference */
- public java.util.List<Long> dBusAuthObservers = new ArrayList<>();
- /** @noreference */
- public java.util.List<Long> dBusGUIDS = new ArrayList<>();
- /** @noreference */
- public java.util.List<Long> dBusConnections = new ArrayList<>();
-
/* Deferred Layout list */
Composite[] layoutDeferred;
int layoutDeferredCount;
@@ -3853,44 +3840,6 @@
}
/**
- * Some parts of SWT (like WebKit) use GDBus for IPC. Some of these objects
- * cannot be disposed of in their own classes due to design challenges.
- * In these instances we release them along with this Display. This ensures
- * no Browser will be using them at disposal time.
- */
-void releaseDBusServices() {
- releaseSessionManager();
- for (long connection : dBusConnections) {
- if (OS.g_dbus_connection_is_closed(connection)) continue;
- long [] error = new long [1];
- boolean closed = OS.g_dbus_connection_close_sync(connection, 0, error);
- if (error[0] != 0) {
- String msg = extractFreeGError(error[0]);
- System.err.println("SWT Display: error closing connection: " + msg);
- }
- if (closed) {
- // Free this as we added a reference to it
- OS.g_object_unref(connection);
- }
- }
- for (long server : dBusServers) {
- OS.g_dbus_server_stop(server);
- OS.g_object_unref(server);
- }
- for (long authObserver : dBusAuthObservers) {
- OS.g_object_unref(authObserver);
- }
- for (long guid : dBusGUIDS) {
- OS.g_free(guid);
- }
- dBusConnections.clear();
- dBusServers.clear();
- dBusAuthObservers.clear();
- dBusGUIDS.clear();
- dBusServers = dBusAuthObservers = dBusGUIDS = dBusConnections = null;
-}
-
-/**
* Helper method to extract GError messages. Only call if the pointer is valid (i.e. non-zero).
*
* @param errorPtr pointer to the GError
@@ -4673,7 +4622,6 @@
synchronizer.releaseSynchronizer ();
synchronizer = null;
- releaseDBusServices ();
releaseSessionManager ();
releaseDisplay ();
super.release ();
diff --git a/bundles/org.eclipse.swt/buildFragment.xml b/bundles/org.eclipse.swt/buildFragment.xml
index 549a4c0..5a12f3e 100644
--- a/bundles/org.eclipse.swt/buildFragment.xml
+++ b/bundles/org.eclipse.swt/buildFragment.xml
@@ -258,9 +258,9 @@
<fileset dir="${build.result.folder}/@dot" includes="**" />
</copy>
<copy todir="${destination.temp.folder}/${full.name}">
- <fileset dir="${fragmentdir}" includes="fragment.properties,about.html,about_files/,swt*.dll,libswt*.so,libswt*.sl,libswt*.a,libswt*.jnilib,libXm.so.2,webkitextensions*/libswt*.so,META-INF/,WebView2Loader.dll" />
+ <fileset dir="${fragmentdir}" includes="fragment.properties,about.html,about_files/,swt*.dll,libswt*.so,libswt*.sl,libswt*.a,libswt*.jnilib,libXm.so.2,META-INF/,WebView2Loader.dll" />
</copy>
- <chmod perm="755" dir="${destination.temp.folder}/${full.name}" includes="swt*.dll,libswt*.so,libswt*.sl,libswt*.a,libswt*.jnilib,libXm.so.2,webkitextensions*/libswt*.so,WebView2Loader.dll" />
+ <chmod perm="755" dir="${destination.temp.folder}/${full.name}" includes="swt*.dll,libswt*.so,libswt*.sl,libswt*.a,libswt*.jnilib,libXm.so.2,WebView2Loader.dll" />
<eclipse.versionReplacer path="${destination.temp.folder}/${full.name}" version="${version.suffix}" />
</target>
@@ -271,7 +271,7 @@
<property name="includetranslationfiles" value="true" />
<property name="swtbasename" value="swt" />
<antcall target="build.jars" />
- <jar jarfile="${build.result.folder}/${swtbasename}.jar" basedir="${fragmentdir}" update="true" includes="swt*.dll,libswt*.so,libswt*.sl,libswt*.a,libswt*.jnilib,libXm.so.2,webkitextensions*/libswt*.so,WebView2Loader.dll" />
+ <jar jarfile="${build.result.folder}/${swtbasename}.jar" basedir="${fragmentdir}" update="true" includes="swt*.dll,libswt*.so,libswt*.sl,libswt*.a,libswt*.jnilib,libXm.so.2,WebView2Loader.dll" />
<move file="${build.result.folder}/${swtbasename}.jar" todir="${temp.folder}/swtdownload" />
<delete dir="${build.result.folder}/@dot" />
<antcall target="build.sources" />
diff --git a/bundles/org.eclipse.swt/buildSWT.xml b/bundles/org.eclipse.swt/buildSWT.xml
index 70d0831..fca937f 100644
--- a/bundles/org.eclipse.swt/buildSWT.xml
+++ b/bundles/org.eclipse.swt/buildSWT.xml
@@ -66,15 +66,15 @@
<param name="fragment" value="org.eclipse.swt.cocoa.macosx.x86_64"/>
</antcall>
<antcall target="check_fragment_libraries">
- <param name="library_count" value="8"/>
+ <param name="library_count" value="7"/>
<param name="fragment" value="org.eclipse.swt.gtk.linux.aarch64"/>
</antcall>
<antcall target="check_fragment_libraries">
- <param name="library_count" value="8"/>
+ <param name="library_count" value="7"/>
<param name="fragment" value="org.eclipse.swt.gtk.linux.ppc64le"/>
</antcall>
<antcall target="check_fragment_libraries">
- <param name="library_count" value="8"/>
+ <param name="library_count" value="7"/>
<param name="fragment" value="org.eclipse.swt.gtk.linux.x86_64"/>
</antcall>
<antcall target="check_fragment_libraries">
@@ -615,7 +615,6 @@
<!-- Get list of files to commit -->
<fileset id="addid" dir="${repo.bin}">
<include name="bundles/*/*${swt_version}*"/>
- <include name="bundles/*/webkitextensions${swt_version}/*${swt_version}*"/>
<include name="bundles/*/build.sha1"/>
<exclude name="**/.git/**"/>
<exclude name="**/tmpdir/**"/>
@@ -788,12 +787,6 @@
port="${port}"
keyfile="${keyfile}"
trust="true"/>
- <scp file="swtbuild@${build_machine}:${lib_output}/webkitextensions${swt_version}/*"
- todir="${output_dir}/webkitextensions${swt_version}/"
- port="${port}"
- keyfile="${keyfile}"
- trust="true"
- failonerror="false"/>
<sshexec host="${build_machine}"
username="swtbuild"
port="${port}"
@@ -804,10 +797,6 @@
<target name="build_local">
<property name="gtk_version" value="3.0" />
- <exec executable="mkdir">
- <arg value="-p"/>
- <arg value="${output_dir}/webkitextensions${swt_version}/"/>
- </exec>
<exec dir="${build_dir}" executable="sh" failonerror="true">
<arg line="build.sh"/>
<env key="GTK_VERSION" value="${gtk_version}"/>