diff options
author | Grant Gayed <ggayed> | 2008-08-21 16:05:06 +0000 |
---|---|---|
committer | Grant Gayed <ggayed> | 2008-08-21 16:05:06 +0000 |
commit | e5c54f94dba0a9129c87c68372b565b8971079dd (patch) | |
tree | b2205cf86a5a477417c000266d90e9f9b8ef6adb | |
parent | 193008c7f69b4eacf5f30227fd1a6e79da404ef9 (diff) | |
download | eclipse.platform.swt-e5c54f94dba0a9129c87c68372b565b8971079dd.tar.gz eclipse.platform.swt-e5c54f94dba0a9129c87c68372b565b8971079dd.tar.xz eclipse.platform.swt-e5c54f94dba0a9129c87c68372b565b8971079dd.zip |
242644 - eclipse crashes when downloading a file in the internal browser
10 files changed, 326 insertions, 61 deletions
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.mozilla.XPCOM.properties b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.mozilla.XPCOM.properties index 6330601471..d0ebcb280b 100644 --- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.mozilla.XPCOM.properties +++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.mozilla.XPCOM.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2000, 2007 IBM Corporation and others. +# Copyright (c) 2000, 2008 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at @@ -265,6 +265,16 @@ XPCOM_VtblCall__IIII_3CJJJ_5= XPCOM_VtblCall__IIII_3CJJJ_6= XPCOM_VtblCall__IIII_3CJJJ_7= +XPCOM_VtblCall__IIII_3C_3CI_3I= +XPCOM_VtblCall__IIII_3C_3CI_3I_0= +XPCOM_VtblCall__IIII_3C_3CI_3I_1= +XPCOM_VtblCall__IIII_3C_3CI_3I_2= +XPCOM_VtblCall__IIII_3C_3CI_3I_3= +XPCOM_VtblCall__IIII_3C_3CI_3I_4= +XPCOM_VtblCall__IIII_3C_3CI_3I_5= +XPCOM_VtblCall__IIII_3C_3CI_3I_6= +XPCOM_VtblCall__IIII_3C_3CI_3I_7= + XPCOM_VtblCall__IIII_3I= XPCOM_VtblCall__IIII_3I_0= XPCOM_VtblCall__IIII_3I_1= @@ -691,6 +701,16 @@ XPCOM_VtblCall__IIJJ_3CJJJ_5= XPCOM_VtblCall__IIJJ_3CJJJ_6= XPCOM_VtblCall__IIJJ_3CJJJ_7= +XPCOM_VtblCall__IIJJ_3C_3CI_3J= +XPCOM_VtblCall__IIJJ_3C_3CI_3J_0= +XPCOM_VtblCall__IIJJ_3C_3CI_3J_1= +XPCOM_VtblCall__IIJJ_3C_3CI_3J_2= +XPCOM_VtblCall__IIJJ_3C_3CI_3J_3= +XPCOM_VtblCall__IIJJ_3C_3CI_3J_4= +XPCOM_VtblCall__IIJJ_3C_3CI_3J_5= +XPCOM_VtblCall__IIJJ_3C_3CI_3J_6= +XPCOM_VtblCall__IIJJ_3C_3CI_3J_7= + XPCOM_VtblCall__IIJJ_3I= XPCOM_VtblCall__IIJJ_3I_0= XPCOM_VtblCall__IIJJ_3I_1= @@ -1399,6 +1419,8 @@ org_eclipse_swt_internal_mozilla_nsIHelperAppLauncher= org_eclipse_swt_internal_mozilla_nsIHelperAppLauncherDialog= +org_eclipse_swt_internal_mozilla_nsIHelperAppLauncherDialog_11_19= + org_eclipse_swt_internal_mozilla_nsIHelperAppLauncher_11_18= org_eclipse_swt_internal_mozilla_nsIHelperAppLauncher_11_19= diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom.cpp b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom.cpp index 1903027c5f..07b9dce31f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom.cpp +++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom.cpp @@ -472,6 +472,29 @@ fail: } #endif +#ifndef NO_VtblCall__IIII_3C_3CI_3I +extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIII_3C_3CI_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jcharArray arg4, jcharArray arg5, jint arg6, jintArray arg7); +JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIII_3C_3CI_3I) + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jcharArray arg4, jcharArray arg5, jint arg6, jintArray arg7) +{ + jchar *lparg4=NULL; + jchar *lparg5=NULL; + jint *lparg7=NULL; + jint rc = 0; + XPCOM_NATIVE_ENTER(env, that, VtblCall__IIII_3C_3CI_3I_FUNC); + if (arg4) if ((lparg4 = env->GetCharArrayElements(arg4, NULL)) == NULL) goto fail; + if (arg5) if ((lparg5 = env->GetCharArrayElements(arg5, NULL)) == NULL) goto fail; + if (arg7) if ((lparg7 = env->GetIntArrayElements(arg7, NULL)) == NULL) goto fail; + rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jint, jchar *, jchar *, jint, jint *))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, lparg4, lparg5, arg6, lparg7); +fail: + if (arg7 && lparg7) env->ReleaseIntArrayElements(arg7, lparg7, 0); + if (arg5 && lparg5) env->ReleaseCharArrayElements(arg5, lparg5, 0); + if (arg4 && lparg4) env->ReleaseCharArrayElements(arg4, lparg4, 0); + XPCOM_NATIVE_EXIT(env, that, VtblCall__IIII_3C_3CI_3I_FUNC); + return rc; +} +#endif + #ifndef NO_VtblCall__IIII_3I extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIII_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jintArray arg4); JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIII_3I) @@ -1371,6 +1394,29 @@ fail: } #endif +#ifndef NO_VtblCall__IIJJ_3C_3CI_3J +extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJ_3C_3CI_3J)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jcharArray arg4, jcharArray arg5, jint arg6, jlongArray arg7); +JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJ_3C_3CI_3J) + (JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jcharArray arg4, jcharArray arg5, jint arg6, jlongArray arg7) +{ + jchar *lparg4=NULL; + jchar *lparg5=NULL; + jlong *lparg7=NULL; + jint rc = 0; + XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJJ_3C_3CI_3J_FUNC); + if (arg4) if ((lparg4 = env->GetCharArrayElements(arg4, NULL)) == NULL) goto fail; + if (arg5) if ((lparg5 = env->GetCharArrayElements(arg5, NULL)) == NULL) goto fail; + if (arg7) if ((lparg7 = env->GetLongArrayElements(arg7, NULL)) == NULL) goto fail; + rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jlong, jchar *, jchar *, jint, jlong *))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, lparg4, lparg5, arg6, lparg7); +fail: + if (arg7 && lparg7) env->ReleaseLongArrayElements(arg7, lparg7, 0); + if (arg5 && lparg5) env->ReleaseCharArrayElements(arg5, lparg5, 0); + if (arg4 && lparg4) env->ReleaseCharArrayElements(arg4, lparg4, 0); + XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJJ_3C_3CI_3J_FUNC); + return rc; +} +#endif + #ifndef NO_VtblCall__IIJJ_3I extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJ_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jintArray arg4); JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJ_3I) diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom_stats.cpp b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom_stats.cpp index ad2aad3aa4..b276290c48 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom_stats.cpp +++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom_stats.cpp @@ -14,8 +14,8 @@ #ifdef NATIVE_STATS -int XPCOM_nativeFunctionCount = 168; -int XPCOM_nativeFunctionCallCount[168]; +int XPCOM_nativeFunctionCount = 170; +int XPCOM_nativeFunctionCallCount[170]; char * XPCOM_nativeFunctionNames[] = { "Call", "NS_1GetComponentManager", @@ -45,6 +45,7 @@ char * XPCOM_nativeFunctionNames[] = { "VtblCall__IIII_3C", "VtblCall__IIII_3CIJI", "VtblCall__IIII_3CJJJ", + "VtblCall__IIII_3C_3CI_3I", "VtblCall__IIII_3I", "VtblCall__IIII_3J", "VtblCall__IIIJJ", @@ -92,6 +93,7 @@ char * XPCOM_nativeFunctionNames[] = { "VtblCall__IIJJ_3B", "VtblCall__IIJJ_3CIJI", "VtblCall__IIJJ_3CJJJ", + "VtblCall__IIJJ_3C_3CI_3J", "VtblCall__IIJJ_3I", "VtblCall__IIJLorg_eclipse_swt_internal_mozilla_nsID_2", "VtblCall__IIJLorg_eclipse_swt_internal_mozilla_nsID_2_3J", diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom_stats.h b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom_stats.h index 0bdefb5e64..11990c6ae7 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom_stats.h +++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom_stats.h @@ -53,6 +53,7 @@ typedef enum { VtblCall__IIII_3C_FUNC, VtblCall__IIII_3CIJI_FUNC, VtblCall__IIII_3CJJJ_FUNC, + VtblCall__IIII_3C_3CI_3I_FUNC, VtblCall__IIII_3I_FUNC, VtblCall__IIII_3J_FUNC, VtblCall__IIIJJ_FUNC, @@ -100,6 +101,7 @@ typedef enum { VtblCall__IIJJ_3B_FUNC, VtblCall__IIJJ_3CIJI_FUNC, VtblCall__IIJJ_3CJJJ_FUNC, + VtblCall__IIJJ_3C_3CI_3J_FUNC, VtblCall__IIJJ_3I_FUNC, VtblCall__IIJLorg_eclipse_swt_internal_mozilla_nsID_2_FUNC, VtblCall__IIJLorg_eclipse_swt_internal_mozilla_nsID_2_3J_FUNC, diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/HelperAppLauncherDialog.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/HelperAppLauncherDialog.java index 5457c6a767..76747047fe 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/HelperAppLauncherDialog.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/HelperAppLauncherDialog.java @@ -15,6 +15,12 @@ import org.eclipse.swt.internal.C; import org.eclipse.swt.internal.mozilla.*; import org.eclipse.swt.widgets.*; +/** + * This class implements the HelperAppLauncherDialog interface for mozilla + * versions 1.4 - 1.8.x. For mozilla versions >= 1.9 this interface is + * implemented by class HelperAppLauncherDialog_1_9. HelperAppLauncherDialogFactory + * determines at runtime which of these classes to instantiate. + */ class HelperAppLauncherDialog { XPCOMObject supports; XPCOMObject helperAppLauncherDialog; @@ -98,28 +104,19 @@ int Release () { int Show (int /*long*/ aLauncher, int /*long*/ aContext, int aReason) { /* - * The interface for nsIHelperAppLauncher changed in GRE versions 1.8 and 1.9. Query for - * each of these interfaces in turn until one is found. - */ + * The interface for nsIHelperAppLauncher changed as of mozilla 1.8. Query the received + * nsIHelperAppLauncher for the new interface, and if it is not found then fall back to + * the old interface. + */ nsISupports supports = new nsISupports (aLauncher); int /*long*/[] result = new int /*long*/[1]; - int rc = supports.QueryInterface (nsIHelperAppLauncher_1_9.NS_IHELPERAPPLAUNCHER_IID, result); - if (rc == 0) { - nsIHelperAppLauncher_1_9 helperAppLauncher = new nsIHelperAppLauncher_1_9 (aLauncher); - rc = helperAppLauncher.SaveToDisk (0, 0); - helperAppLauncher.Release (); - return rc; - } - - result[0] = 0; - rc = supports.QueryInterface (nsIHelperAppLauncher_1_8.NS_IHELPERAPPLAUNCHER_IID, result); - if (rc == 0) { + int rc = supports.QueryInterface (nsIHelperAppLauncher_1_8.NS_IHELPERAPPLAUNCHER_IID, result); + if (rc == XPCOM.NS_OK) { /* >= 1.8 */ nsIHelperAppLauncher_1_8 helperAppLauncher = new nsIHelperAppLauncher_1_8 (aLauncher); rc = helperAppLauncher.SaveToDisk (0, 0); helperAppLauncher.Release (); return rc; } - nsIHelperAppLauncher helperAppLauncher = new nsIHelperAppLauncher (aLauncher); /* < 1.8 */ return helperAppLauncher.SaveToDisk (0, 0); } @@ -141,28 +138,20 @@ int PromptForSaveToFile (int /*long*/ arg0, int /*long*/ arg1, int /*long*/ arg2 * The interface for nsIHelperAppLauncher changed as of mozilla 1.8, so the first * argument must be queried for both the old and new nsIHelperAppLauncher interfaces. */ - boolean using_1_8 = false, using_1_9 = false; + boolean using_1_8 = false; nsISupports support = new nsISupports (arg0); int /*long*/[] result = new int /*long*/[1]; int rc = support.QueryInterface (nsIHelperAppLauncher_1_8.NS_IHELPERAPPLAUNCHER_IID, result); - if (rc == 0) { + if (rc == XPCOM.NS_OK) { using_1_8 = true; hasLauncher = true; new nsISupports (result[0]).Release (); } else { result[0] = 0; - rc = support.QueryInterface (nsIHelperAppLauncher_1_9.NS_IHELPERAPPLAUNCHER_IID, result); - if (rc == 0) { - using_1_9 = true; + rc = support.QueryInterface (nsIHelperAppLauncher.NS_IHELPERAPPLAUNCHER_IID, result); + if (rc == XPCOM.NS_OK) { hasLauncher = true; new nsISupports (result[0]).Release (); - } else { - result[0] = 0; - rc = support.QueryInterface (nsIHelperAppLauncher.NS_IHELPERAPPLAUNCHER_IID, result); - if (rc == 0) { - hasLauncher = true; - new nsISupports (result[0]).Release (); - } } } result[0] = 0; @@ -198,9 +187,6 @@ int PromptForSaveToFile (int /*long*/ arg0, int /*long*/ arg1, int /*long*/ arg2 if (using_1_8) { nsIHelperAppLauncher_1_8 launcher = new nsIHelperAppLauncher_1_8 (arg0); rc = launcher.Cancel (XPCOM.NS_BINDING_ABORTED); - } else if (using_1_9) { - nsIHelperAppLauncher_1_9 launcher = new nsIHelperAppLauncher_1_9 (arg0); - rc = launcher.Cancel (XPCOM.NS_BINDING_ABORTED); } else { nsIHelperAppLauncher launcher = new nsIHelperAppLauncher (arg0); rc = launcher.Cancel (); diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/HelperAppLauncherDialogFactory.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/HelperAppLauncherDialogFactory.java index 11bf0d3bf9..574bc03d14 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/HelperAppLauncherDialogFactory.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/HelperAppLauncherDialogFactory.java @@ -17,6 +17,7 @@ class HelperAppLauncherDialogFactory { XPCOMObject supports; XPCOMObject factory; int refCount = 0; + boolean isPre_1_9 = true; HelperAppLauncherDialogFactory () { createCOMInterfaces (); @@ -88,9 +89,15 @@ int Release () { /* nsIFactory */ int CreateInstance (int /*long*/ aOuter, int /*long*/ iid, int /*long*/ result) { - HelperAppLauncherDialog helperAppLauncherDialog = new HelperAppLauncherDialog (); - helperAppLauncherDialog.AddRef (); - XPCOM.memmove (result, new int /*long*/[] {helperAppLauncherDialog.getAddress ()}, C.PTR_SIZEOF); + if (isPre_1_9) { + HelperAppLauncherDialog helperAppLauncherDialog = new HelperAppLauncherDialog (); + helperAppLauncherDialog.AddRef (); + XPCOM.memmove (result, new int /*long*/[] {helperAppLauncherDialog.getAddress ()}, C.PTR_SIZEOF); + } else { + HelperAppLauncherDialog_1_9 helperAppLauncherDialog = new HelperAppLauncherDialog_1_9 (); + helperAppLauncherDialog.AddRef (); + XPCOM.memmove (result, new int /*long*/[] {helperAppLauncherDialog.getAddress ()}, C.PTR_SIZEOF); + } return XPCOM.NS_OK; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/HelperAppLauncherDialog_1_9.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/HelperAppLauncherDialog_1_9.java new file mode 100644 index 0000000000..25aec5211a --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/HelperAppLauncherDialog_1_9.java @@ -0,0 +1,137 @@ +/******************************************************************************* + * Copyright (c) 2003, 2008 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.swt.browser; + +import org.eclipse.swt.*; +import org.eclipse.swt.internal.C; +import org.eclipse.swt.internal.mozilla.*; +import org.eclipse.swt.widgets.*; + +class HelperAppLauncherDialog_1_9 { + XPCOMObject supports; + XPCOMObject helperAppLauncherDialog; + int refCount = 0; + +HelperAppLauncherDialog_1_9 () { + createCOMInterfaces (); +} + +int AddRef () { + refCount++; + return refCount; +} + +void createCOMInterfaces () { + /* Create each of the interfaces that this object implements */ + supports = new XPCOMObject (new int[] {2, 0, 0}) { + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + }; + + helperAppLauncherDialog = new XPCOMObject (new int[] {2, 0, 0, 3, 6}) { + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + public int /*long*/ method3 (int /*long*/[] args) {return Show (args[0], args[1], (int)/*64*/args[2]);} + public int /*long*/ method4 (int /*long*/[] args) {return PromptForSaveToFile (args[0], args[1], args[2], args[3], (int)/*64*/args[4], args[5]);} + }; +} + +void disposeCOMInterfaces () { + if (supports != null) { + supports.dispose (); + supports = null; + } + if (helperAppLauncherDialog != null) { + helperAppLauncherDialog.dispose (); + helperAppLauncherDialog = null; + } +} + +int /*long*/ getAddress () { + return helperAppLauncherDialog.getAddress (); +} + +int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) { + if (riid == 0 || ppvObject == 0) return XPCOM.NS_ERROR_NO_INTERFACE; + nsID guid = new nsID (); + XPCOM.memmove (guid, riid, nsID.sizeof); + + if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF); + AddRef (); + return XPCOM.NS_OK; + } + if (guid.Equals (nsIHelperAppLauncherDialog_1_9.NS_IHELPERAPPLAUNCHERDIALOG_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {helperAppLauncherDialog.getAddress ()}, C.PTR_SIZEOF); + AddRef (); + return XPCOM.NS_OK; + } + + XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF); + return XPCOM.NS_ERROR_NO_INTERFACE; +} + +int Release () { + refCount--; + /* + * Note. This instance lives as long as the download it is bound to. + * Its reference count is expected to go down to 0 when the download + * has completed or when it has been cancelled. E.g. when the user + * cancels the File Dialog, cancels or closes the Download Dialog + * and when the Download Dialog goes away after the download is completed. + */ + if (refCount == 0) disposeCOMInterfaces (); + return refCount; +} + +/* nsIHelperAppLauncherDialog */ + +int Show (int /*long*/ aLauncher, int /*long*/ aContext, int aReason) { + nsIHelperAppLauncher_1_9 helperAppLauncher = new nsIHelperAppLauncher_1_9 (aLauncher); + return helperAppLauncher.SaveToDisk (0, 0); +} + +int PromptForSaveToFile (int /*long*/ aLauncher, int /*long*/ aWindowContext, int /*long*/ aDefaultFileName, int /*long*/ aSuggestedFileExtension, int aForcePrompt, int /*long*/ _retval) { + int length = XPCOM.strlen_PRUnichar (aDefaultFileName); + char[] dest = new char[length]; + XPCOM.memmove (dest, aDefaultFileName, length * 2); + String defaultFile = new String (dest); + + length = XPCOM.strlen_PRUnichar (aSuggestedFileExtension); + dest = new char[length]; + XPCOM.memmove (dest, aSuggestedFileExtension, length * 2); + String suggestedFileExtension = new String (dest); + + Shell shell = new Shell (); + FileDialog fileDialog = new FileDialog (shell, SWT.SAVE); + fileDialog.setFileName (defaultFile); + fileDialog.setFilterExtensions (new String[] {suggestedFileExtension}); + String name = fileDialog.open (); + shell.close (); + if (name == null) { + nsIHelperAppLauncher_1_9 launcher = new nsIHelperAppLauncher_1_9 (aLauncher); + int rc = launcher.Cancel (XPCOM.NS_BINDING_ABORTED); + if (rc != XPCOM.NS_OK) Mozilla.error (rc); + return XPCOM.NS_ERROR_FAILURE; + } + nsEmbedString path = new nsEmbedString (name); + int /*long*/[] result = new int /*long*/[1]; + int rc = XPCOM.NS_NewLocalFile (path.getAddress (), 1, result); + path.dispose (); + if (rc != XPCOM.NS_OK) Mozilla.error (rc); + if (result[0] == 0) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER); + /* Our own nsIDownload has been registered during the Browser initialization. It will be invoked by Mozilla. */ + XPCOM.memmove (_retval, result, C.PTR_SIZEOF); + return XPCOM.NS_OK; +} +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java index 580a0e20cb..0f9f7b82ce 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java @@ -895,17 +895,6 @@ public void create (Composite parent, int style) { } factory.Release (); - HelperAppLauncherDialogFactory dialogFactory = new HelperAppLauncherDialogFactory (); - dialogFactory.AddRef (); - aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_HELPERAPPLAUNCHERDIALOG_CONTRACTID, true); - aClassName = MozillaDelegate.wcsToMbcs (null, "Helper App Launcher Dialog", true); //$NON-NLS-1$ - rc = componentRegistrar.RegisterFactory (XPCOM.NS_HELPERAPPLAUNCHERDIALOG_CID, aClassName, aContractID, dialogFactory.getAddress ()); - if (rc != XPCOM.NS_OK) { - browser.dispose (); - error (rc); - } - dialogFactory.Release (); - /* * This Download factory will be used if the GRE version is < 1.8. * If the GRE version is 1.8.x then the Download factory that is registered later for @@ -1099,6 +1088,29 @@ public void create (Composite parent, int style) { if (!PerformedVersionCheck) { PerformedVersionCheck = true; + rc = componentManager.QueryInterface (nsIComponentRegistrar.NS_ICOMPONENTREGISTRAR_IID, result); + if (rc != XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + if (result[0] == 0) { + browser.dispose (); + error (XPCOM.NS_NOINTERFACE); + } + nsIComponentRegistrar componentRegistrar = new nsIComponentRegistrar (result[0]); + result[0] = 0; + + HelperAppLauncherDialogFactory dialogFactory = new HelperAppLauncherDialogFactory (); + dialogFactory.AddRef (); + byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_HELPERAPPLAUNCHERDIALOG_CONTRACTID, true); + byte[] aClassName = MozillaDelegate.wcsToMbcs (null, "Helper App Launcher Dialog", true); //$NON-NLS-1$ + rc = componentRegistrar.RegisterFactory (XPCOM.NS_HELPERAPPLAUNCHERDIALOG_CID, aClassName, aContractID, dialogFactory.getAddress ()); + if (rc != XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + dialogFactory.Release (); + /* * Check for the availability of the pre-1.8 implementation of nsIDocShell * to determine if the GRE's version is < 1.8. @@ -1136,28 +1148,17 @@ public void create (Composite parent, int style) { if (rc == XPCOM.NS_OK && result[0] != 0) { /* 1.8 */ new nsISupports (result[0]).Release (); result[0] = 0; - rc = componentManager.QueryInterface (nsIComponentRegistrar.NS_ICOMPONENTREGISTRAR_IID, result); - if (rc != XPCOM.NS_OK) { - browser.dispose (); - error (rc); - } - if (result[0] == 0) { - browser.dispose (); - error (XPCOM.NS_NOINTERFACE); - } - nsIComponentRegistrar componentRegistrar = new nsIComponentRegistrar (result[0]); DownloadFactory_1_8 downloadFactory_1_8 = new DownloadFactory_1_8 (); downloadFactory_1_8.AddRef (); - byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_TRANSFER_CONTRACTID, true); - byte[] aClassName = MozillaDelegate.wcsToMbcs (null, "Transfer", true); //$NON-NLS-1$ + aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_TRANSFER_CONTRACTID, true); + aClassName = MozillaDelegate.wcsToMbcs (null, "Transfer", true); //$NON-NLS-1$ rc = componentRegistrar.RegisterFactory (XPCOM.NS_DOWNLOAD_CID, aClassName, aContractID, downloadFactory_1_8.getAddress ()); if (rc != XPCOM.NS_OK) { browser.dispose (); error (rc); } downloadFactory_1_8.Release (); - componentRegistrar.Release (); } else { /* >= 1.9 */ /* * Bug in XULRunner 1.9. Mozilla no longer clears its background before initial content has @@ -1182,10 +1183,13 @@ public void create (Composite parent, int style) { ABOUT_BLANK.getChars (0, ABOUT_BLANK.length (), uri, 0); rc = webNavigation.LoadURI (uri, nsIWebNavigation.LOAD_FLAGS_NONE, 0, 0, 0); webNavigation.Release (); + + dialogFactory.isPre_1_9 = false; } } result[0] = 0; interfaceRequestor.Release (); + componentRegistrar.Release (); } componentManager.Release (); @@ -2768,7 +2772,7 @@ int IsPreferred (int /*long*/ aContentType, int /*long*/ aDesiredContentType, in /* First try to use the nsIWebNavigationInfo if it's available (>= mozilla 1.8) */ byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_WEBNAVIGATIONINFO_CONTRACTID, true); rc = serviceManager.GetServiceByContractID (aContractID, nsIWebNavigationInfo.NS_IWEBNAVIGATIONINFO_IID, result); - if (rc == 0) { + if (rc == XPCOM.NS_OK) { byte[] bytes = MozillaDelegate.wcsToMbcs (null, contentType, true); int /*long*/ typePtr = XPCOM.nsEmbedCString_new (bytes, bytes.length); nsIWebNavigationInfo info = new nsIWebNavigationInfo (result[0]); diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/XPCOM.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/XPCOM.java index 1539ef5d44..a2f889c443 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/XPCOM.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/XPCOM.java @@ -277,6 +277,8 @@ static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, byte[] arg0, static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, byte[] arg0, byte[] arg1, byte[] arg2, int arg3, int arg4, long[] arg5); static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, int arg1, int arg2, int arg3, int[] arg4, int[] arg5); static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, int arg1, int arg2, long arg3, int[] arg4, long [] arg5); +static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, int arg1, char[] arg2, char[] arg3, int arg4, int [] arg5); +static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, long arg1, char[] arg2, char[] arg3, int arg4, long[] arg5); static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, char[] arg1, char[] arg2, int arg3, int[] arg4, int[] arg5, int[] arg6); static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, char[] arg1, char[] arg2, int arg3, long[] arg4, int[] arg5, int[] arg6); diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIHelperAppLauncherDialog_1_9.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIHelperAppLauncherDialog_1_9.java new file mode 100644 index 0000000000..104e14303f --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIHelperAppLauncherDialog_1_9.java @@ -0,0 +1,57 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by Netscape are Copyright (C) 1998-1999 + * Netscape Communications Corporation. All Rights Reserved. + * + * Contributor(s): + * + * IBM + * - Binding to permit interfacing between Mozilla and SWT + * - Copyright (C) 2003, 2008 IBM Corp. All Rights Reserved. + * + * ***** END LICENSE BLOCK ***** */ +package org.eclipse.swt.internal.mozilla; + +public class nsIHelperAppLauncherDialog_1_9 extends nsISupports { + + static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 2; + + public static final String NS_IHELPERAPPLAUNCHERDIALOG_IID_STR = + "f3704fdc-8ae6-4eba-a3c3-f02958ac0649"; + + public static final nsID NS_IHELPERAPPLAUNCHERDIALOG_IID = + new nsID(NS_IHELPERAPPLAUNCHERDIALOG_IID_STR); + + public nsIHelperAppLauncherDialog_1_9(int /*long*/ address) { + super(address); + } + + public static final int REASON_CANTHANDLE = 0; + + public static final int REASON_SERVERREQUEST = 1; + + public static final int REASON_TYPESNIFFED = 2; + + public int Show(int /*long*/ aLauncher, int /*long*/ aWindowContext, int aReason) { + return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), aLauncher, aWindowContext, aReason); + } + + public int PromptForSaveToFile(int /*long*/ aLauncher, int /*long*/ aWindowContext, char[] aDefaultFileName, char[] aSuggestedFileExtension, int aForcePrompt, int /*long*/[] _retval) { + return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), aLauncher, aWindowContext, aDefaultFileName, aSuggestedFileExtension, aForcePrompt, _retval); + } +} |