diff options
15 files changed, 873 insertions, 202 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/mozilla/org/eclipse/swt/browser/Download.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/mozilla/org/eclipse/swt/browser/Download.java index 600111ea3c..6434e73193 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Browser/mozilla/org/eclipse/swt/browser/Download.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/mozilla/org/eclipse/swt/browser/Download.java @@ -165,7 +165,8 @@ int Release() { public int /*long*/ Init(int /*long*/ aSource, int /*long*/ aTarget, int /*long*/ aDisplayName, int /*long*/ aMIMEInfo, int /*long*/ startTime1, int /*long*/ startTime2, int /*long*/ aPersist) { nsIURI source = new nsIURI(aSource); int /*long*/ aSpec = XPCOM.nsEmbedCString_new(); - source.GetHost(aSpec); + int rc = source.GetHost(aSpec); + if (rc != XPCOM.NS_OK) Browser.error(rc); int length = XPCOM.nsEmbedCString_Length(aSpec); int /*long*/ buffer = XPCOM.nsEmbedCString_get(aSpec); byte[] dest = new byte[length]; @@ -173,16 +174,43 @@ public int /*long*/ Init(int /*long*/ aSource, int /*long*/ aTarget, int /*long* XPCOM.nsEmbedCString_delete(aSpec); String url = new String(dest); - nsILocalFile target = new nsILocalFile(aTarget); - int /*long*/ aNativeTarget = XPCOM.nsEmbedCString_new(); - target.GetNativeLeafName(aNativeTarget); - length = XPCOM.nsEmbedCString_Length(aNativeTarget); - buffer = XPCOM.nsEmbedCString_get(aNativeTarget); - dest = new byte[length]; - XPCOM.memmove(dest, buffer, length); - XPCOM.nsEmbedCString_delete(aNativeTarget); - String file = new String(dest); - + /* + * As of mozilla 1.7 the second argument of the nsIDownload interface's + * Init function changed from nsILocalFile to nsIURI. Detect which of + * these interfaces the second argument implements and act accordingly. + */ + String filename = null; + nsISupports supports = new nsISupports(aTarget); + int /*long*/[] result = new int /*long*/[1]; + rc = supports.QueryInterface(nsIURI.NS_IURI_IID, result); + if (rc == 0) { /* >= 1.7 */ + nsIURI target = new nsIURI(result[0]); + result[0] = 0; + int /*long*/ aPath = XPCOM.nsEmbedCString_new(); + rc = target.GetPath(aPath); + if (rc != XPCOM.NS_OK) Browser.error(rc); + length = XPCOM.nsEmbedCString_Length(aPath); + buffer = XPCOM.nsEmbedCString_get(aPath); + dest = new byte[length]; + XPCOM.memmove(dest, buffer, length); + XPCOM.nsEmbedCString_delete(aPath); + filename = new String(dest); + int separator = filename.lastIndexOf(System.getProperty("file.separator")); //$NON-NLS-1$ + filename = filename.substring(separator + 1); + target.Release(); + } else { /* < 1.7 */ + nsILocalFile target = new nsILocalFile(aTarget); + int /*long*/ aNativeTarget = XPCOM.nsEmbedCString_new(); + rc = target.GetNativeLeafName(aNativeTarget); + if (rc != XPCOM.NS_OK) Browser.error(rc); + length = XPCOM.nsEmbedCString_Length(aNativeTarget); + buffer = XPCOM.nsEmbedCString_get(aNativeTarget); + dest = new byte[length]; + XPCOM.memmove(dest, buffer, length); + XPCOM.nsEmbedCString_delete(aNativeTarget); + filename = new String(dest); + } + Listener listener = new Listener() { public void handleEvent(Event event) { if (event.widget == cancel) { @@ -197,17 +225,17 @@ public int /*long*/ Init(int /*long*/ aSource, int /*long*/ aTarget, int /*long* } }; shell = new Shell(SWT.DIALOG_TRIM); - String msg = Compatibility.getMessage("SWT_Download_File", new Object[] {file}); + String msg = Compatibility.getMessage("SWT_Download_File", new Object[] {filename}); //$NON-NLS-1$ shell.setText(msg); GridLayout gridLayout = new GridLayout(); gridLayout.marginHeight = 15; gridLayout.marginWidth = 15; gridLayout.verticalSpacing = 20; shell.setLayout(gridLayout); - msg = Compatibility.getMessage("SWT_Download_Location", new Object[] {file, url}); + msg = Compatibility.getMessage("SWT_Download_Location", new Object[] {filename, url}); //$NON-NLS-1$ new Label(shell, SWT.SIMPLE).setText(msg); status = new Label(shell, SWT.SIMPLE); - msg = Compatibility.getMessage("SWT_Download_Started"); + msg = Compatibility.getMessage("SWT_Download_Started"); //$NON-NLS-1$ status.setText(msg); GridData data = new GridData (); data.grabExcessHorizontalSpace = true; @@ -215,7 +243,7 @@ public int /*long*/ Init(int /*long*/ aSource, int /*long*/ aTarget, int /*long* status.setLayoutData (data); cancel = new Button(shell, SWT.PUSH); - cancel.setText(SWT.getMessage("SWT_Cancel")); + cancel.setText(SWT.getMessage("SWT_Cancel")); //$NON-NLS-1$ data = new GridData (); data.horizontalAlignment = GridData.CENTER; cancel.setLayoutData (data); @@ -276,8 +304,7 @@ public int /*long*/ SetObserver(int /*long*/ aObserver) { int /*long*/[] result = new int /*long*/[1]; int rc = supports.QueryInterface(nsIHelperAppLauncher.NS_IHELPERAPPLAUNCHER_IID, result); if (rc != XPCOM.NS_OK) Browser.error(rc); - if (result[0] == 0) Browser.error(XPCOM.NS_ERROR_NO_INTERFACE); - + if (result[0] == 0) Browser.error(XPCOM.NS_ERROR_NO_INTERFACE); helperAppLauncher = new nsIHelperAppLauncher(result[0]); } return XPCOM.NS_OK; @@ -314,21 +341,20 @@ int /*long*/ OnStateChange(int /*long*/ aWebProgress, int /*long*/ aRequest, int shell = null; } return XPCOM.NS_OK; -} +} int /*long*/ OnProgressChange(int /*long*/ aWebProgress, int /*long*/ aRequest, int /*long*/ aCurSelfProgress, int /*long*/ aMaxSelfProgress, int /*long*/ aCurTotalProgress, int /*long*/ aMaxTotalProgress) { - int currentBytes = (int)/*64*/aCurTotalProgress / 1024; - int totalBytes = (int)/*64*/aMaxTotalProgress / 1024; + int currentKBytes = (int)/*64*/aCurTotalProgress / 1024; + int totalKBytes = (int)/*64*/aMaxTotalProgress / 1024; if (shell != null & !shell.isDisposed()) { - Object[] arguments = {new Integer(currentBytes), new Integer(totalBytes)}; - String statusMsg = Compatibility.getMessage("SWT_Download_Status", arguments); + Object[] arguments = {new Integer(currentKBytes), new Integer(totalKBytes)}; + String statusMsg = Compatibility.getMessage("SWT_Download_Status", arguments); //$NON-NLS-1$ status.setText(statusMsg); - shell.layout(true); shell.getDisplay().update(); } return XPCOM.NS_OK; -} +} int /*long*/ OnLocationChange(int /*long*/ aWebProgress, int /*long*/ aRequest, int /*long*/ aLocation) { return XPCOM.NS_OK; diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/mozilla/org/eclipse/swt/browser/DownloadFactory_1_8.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/mozilla/org/eclipse/swt/browser/DownloadFactory_1_8.java new file mode 100644 index 0000000000..711145c28c --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/mozilla/org/eclipse/swt/browser/DownloadFactory_1_8.java @@ -0,0 +1,100 @@ +/******************************************************************************* + * Copyright (c) 2003, 2005 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.internal.mozilla.*; +import org.eclipse.swt.internal.gtk.OS; + +class DownloadFactory_1_8 { + XPCOMObject supports; + XPCOMObject factory; + int refCount = 0; + +public DownloadFactory_1_8() { + 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();} + }; + + factory = new XPCOMObject(new int[]{2, 0, 0, 3, 1}){ + 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 CreateInstance(args[0], args[1], args[2]);} + public int /*long*/ method4(int /*long*/[] args) {return LockFactory(args[0]);} + }; +} + +void disposeCOMInterfaces() { + if (supports != null) { + supports.dispose(); + supports = null; + } + if (factory != null) { + factory.dispose(); + factory = null; + } +} + +int /*long*/ getAddress() { + return factory.getAddress(); +} + +int /*long*/ 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()}, OS.PTR_SIZEOF); + AddRef(); + return XPCOM.NS_OK; + } + if (guid.Equals(nsIFactory.NS_IFACTORY_IID)) { + XPCOM.memmove(ppvObject, new int /*long*/[] {factory.getAddress()}, OS.PTR_SIZEOF); + AddRef(); + return XPCOM.NS_OK; + } + + XPCOM.memmove(ppvObject, new int /*long*/[] {0}, OS.PTR_SIZEOF); + return XPCOM.NS_ERROR_NO_INTERFACE; +} + +int Release() { + refCount--; + if (refCount == 0) disposeCOMInterfaces(); + return refCount; +} + +/* nsIFactory */ + +public int /*long*/ CreateInstance(int /*long*/ aOuter, int /*long*/ iid, int /*long*/ result) { + Download_1_8 download = new Download_1_8(); + download.AddRef(); + XPCOM.memmove(result, new int /*long*/[] {download.getAddress()}, OS.PTR_SIZEOF); + return XPCOM.NS_OK; +} + +public int /*long*/ LockFactory(int /*long*/ lock) { + return XPCOM.NS_OK; +} +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/mozilla/org/eclipse/swt/browser/Download_1_8.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/mozilla/org/eclipse/swt/browser/Download_1_8.java new file mode 100644 index 0000000000..99fa8a4a89 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/mozilla/org/eclipse/swt/browser/Download_1_8.java @@ -0,0 +1,382 @@ +/******************************************************************************* + * Copyright (c) 2003, 2005 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.SWT; +import org.eclipse.swt.internal.*; +import org.eclipse.swt.internal.mozilla.*; +import org.eclipse.swt.internal.gtk.OS; +import org.eclipse.swt.layout.*; +import org.eclipse.swt.widgets.*; + +class Download_1_8 { + XPCOMObject supports; + XPCOMObject download; + XPCOMObject progressDialog; + XPCOMObject webProgressListener; + nsICancelable cancelable; + int refCount = 0; + + Shell shell; + Label status; + Button cancel; + + static final boolean is32 = OS.PTR_SIZEOF == 4; + +public Download_1_8() { + 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();} + }; + + download = new XPCOMObject(new int[]{2, 0, 0, 4, 6, 3, 4, 3, is32 ? 10 : 6, is32 ? 8 : 7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}){ + 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 OnStateChange(args[0], args[1], args[2], args[3]);} + public int /*long*/ method4(int /*long*/[] args) {return OnProgressChange(args[0], args[1], args[2], args[3], args[4], args[5]);} + public int /*long*/ method5(int /*long*/[] args) {return OnLocationChange(args[0], args[1], args[2]);} + public int /*long*/ method6(int /*long*/[] args) {return OnStatusChange(args[0], args[1], args[2], args[3]);} + public int /*long*/ method7(int /*long*/[] args) {return OnSecurityChange(args[0], args[1], args[2]);} + public int /*long*/ method8(int /*long*/[] args) { + if (args.length == 10) { + return OnProgressChange64_32(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9]); + } else { + return OnProgressChange64(args[0], args[1], args[2], args[3], args[4], args[5]); + } + } + public int /*long*/ method9(int /*long*/[] args) { + if (args.length == 8) { + return Init_32(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]); + } else { + return Init(args[0], args[1], args[2], args[3], args[4], args[5], args[6]); + } + } + public int /*long*/ method10(int /*long*/[] args) {return GetTargetFile(args[0]);} + public int /*long*/ method11(int /*long*/[] args) {return GetPercentComplete(args[0]);} + public int /*long*/ method12(int /*long*/[] args) {return GetAmountTransferred(args[0]);} + public int /*long*/ method13(int /*long*/[] args) {return GetSize(args[0]);} + public int /*long*/ method14(int /*long*/[] args) {return GetSource(args[0]);} + public int /*long*/ method15(int /*long*/[] args) {return GetTarget(args[0]);} + public int /*long*/ method16(int /*long*/[] args) {return GetCancelable(args[0]);} + public int /*long*/ method17(int /*long*/[] args) {return GetDisplayName(args[0]);} + public int /*long*/ method18(int /*long*/[] args) {return GetStartTime(args[0]);} + public int /*long*/ method19(int /*long*/[] args) {return GetMIMEInfo(args[0]);} + }; + + progressDialog = new XPCOMObject(new int[]{2, 0, 0, 4, 6, 3, 4, 3, is32 ? 10 : 6, is32 ? 8 : 7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}){ + 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 OnStateChange(args[0], args[1], args[2], args[3]);} + public int /*long*/ method4(int /*long*/[] args) {return OnProgressChange(args[0], args[1], args[2], args[3], args[4], args[5]);} + public int /*long*/ method5(int /*long*/[] args) {return OnLocationChange(args[0], args[1], args[2]);} + public int /*long*/ method6(int /*long*/[] args) {return OnStatusChange(args[0], args[1], args[2], args[3]);} + public int /*long*/ method7(int /*long*/[] args) {return OnSecurityChange(args[0], args[1], args[2]);} + public int /*long*/ method8(int /*long*/[] args) { + if (args.length == 10) { + return OnProgressChange64_32(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9]); + } else { + return OnProgressChange64(args[0], args[1], args[2], args[3], args[4], args[5]); + } + } + public int /*long*/ method9(int /*long*/[] args) { + if (args.length == 8) { + return Init_32(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]); + } else { + return Init(args[0], args[1], args[2], args[3], args[4], args[5], args[6]); + } + } + public int /*long*/ method10(int /*long*/[] args) {return GetTargetFile(args[0]);} + public int /*long*/ method11(int /*long*/[] args) {return GetPercentComplete(args[0]);} + public int /*long*/ method12(int /*long*/[] args) {return GetAmountTransferred(args[0]);} + public int /*long*/ method13(int /*long*/[] args) {return GetSize(args[0]);} + public int /*long*/ method14(int /*long*/[] args) {return GetSource(args[0]);} + public int /*long*/ method15(int /*long*/[] args) {return GetTarget(args[0]);} + public int /*long*/ method16(int /*long*/[] args) {return GetCancelable(args[0]);} + public int /*long*/ method17(int /*long*/[] args) {return GetDisplayName(args[0]);} + public int /*long*/ method18(int /*long*/[] args) {return GetStartTime(args[0]);} + public int /*long*/ method19(int /*long*/[] args) {return GetMIMEInfo(args[0]);} + public int /*long*/ method20(int /*long*/[] args) {return Open(args[0]);} + public int /*long*/ method21(int /*long*/[] args) {return GetCancelDownloadOnClose(args[0]);} + public int /*long*/ method22(int /*long*/[] args) {return SetCancelDownloadOnClose(args[0]);} + public int /*long*/ method23(int /*long*/[] args) {return GetDialog(args[0]);} + public int /*long*/ method24(int /*long*/[] args) {return SetDialog(args[0]);} + }; + + webProgressListener = new XPCOMObject(new int[]{2, 0, 0, 4, 6, 3, 4, 3}){ + 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 OnStateChange(args[0], args[1], args[2],args[3]);} + public int /*long*/ method4(int /*long*/[] args) {return OnProgressChange(args[0], args[1], args[2],args[3],args[4],args[5]);} + public int /*long*/ method5(int /*long*/[] args) {return OnLocationChange(args[0], args[1], args[2]);} + public int /*long*/ method6(int /*long*/[] args) {return OnStatusChange(args[0], args[1], args[2],args[3]);} + public int /*long*/ method7(int /*long*/[] args) {return OnSecurityChange(args[0], args[1], args[2]);} + }; +} + +void disposeCOMInterfaces() { + if (supports != null) { + supports.dispose(); + supports = null; + } + if (download != null) { + download.dispose(); + download = null; + } + if (progressDialog != null) { + progressDialog.dispose(); + progressDialog = null; + } + if (webProgressListener != null) { + webProgressListener.dispose(); + webProgressListener = null; + } +} + +int /*long*/ getAddress() { + return progressDialog.getAddress(); +} + +int /*long*/ 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()}, OS.PTR_SIZEOF); + AddRef(); + return XPCOM.NS_OK; + } + if (guid.Equals(nsIDownload.NS_IDOWNLOAD_IID)) { + XPCOM.memmove(ppvObject, new int /*long*/[] {download.getAddress()}, OS.PTR_SIZEOF); + AddRef(); + return XPCOM.NS_OK; + } + if (guid.Equals(nsIProgressDialog.NS_IPROGRESSDIALOG_IID)) { + XPCOM.memmove(ppvObject, new int /*long*/[] {progressDialog.getAddress()}, OS.PTR_SIZEOF); + AddRef(); + return XPCOM.NS_OK; + } + if (guid.Equals(nsIWebProgressListener.NS_IWEBPROGRESSLISTENER_IID)) { + XPCOM.memmove(ppvObject, new int /*long*/[] {webProgressListener.getAddress()}, OS.PTR_SIZEOF); + AddRef(); + return XPCOM.NS_OK; + } + XPCOM.memmove(ppvObject, new int /*long*/[] {0}, OS.PTR_SIZEOF); + return XPCOM.NS_ERROR_NO_INTERFACE; +} + +int Release() { + refCount--; + if (refCount == 0) disposeCOMInterfaces(); + return refCount; +} + +/* nsIDownload */ + +/* Note. The argument startTime is defined as a PRInt64. This translates into two java ints. */ +public int Init_32(int /*long*/ aSource, int /*long*/ aTarget, int /*long*/ aDisplayName, int /*long*/ aMIMEInfo, int /*long*/ startTime1, int /*long*/ startTime2, int /*long*/ aTempFile, int /*long*/ aCancelable) { + long startTime = (startTime2 << 32) + startTime1; + return Init (aSource, aTarget, aDisplayName, aMIMEInfo, startTime, aTempFile, aCancelable); +} + +public int Init(int /*long*/ aSource, int /*long*/ aTarget, int /*long*/ aDisplayName, int /*long*/ aMIMEInfo, long startTime, int /*long*/ aTempFile, int /*long*/ aCancelable) { + cancelable = new nsICancelable(aCancelable); + nsIURI source = new nsIURI(aSource); + int /*long*/ aSpec = XPCOM.nsEmbedCString_new(); + int rc = source.GetHost(aSpec); + if (rc != XPCOM.NS_OK) Browser.error(rc); + int length = XPCOM.nsEmbedCString_Length(aSpec); + int /*long*/ buffer = XPCOM.nsEmbedCString_get(aSpec); + byte[] dest = new byte[length]; + XPCOM.memmove(dest, buffer, length); + XPCOM.nsEmbedCString_delete(aSpec); + String url = new String(dest); + + nsIURI target = new nsIURI(aTarget); + int /*long*/ aPath = XPCOM.nsEmbedCString_new(); + rc = target.GetPath(aPath); + if (rc != XPCOM.NS_OK) Browser.error(rc); + length = XPCOM.nsEmbedCString_Length(aPath); + buffer = XPCOM.nsEmbedCString_get(aPath); + dest = new byte[length]; + XPCOM.memmove(dest, buffer, length); + XPCOM.nsEmbedCString_delete(aPath); + String filename = new String(dest); + int separator = filename.lastIndexOf(System.getProperty("file.separator")); //$NON-NLS-1$ + filename = filename.substring(separator + 1); + + Listener listener = new Listener() { + public void handleEvent(Event event) { + if (event.widget == cancel) { + shell.close(); + } + if (cancelable != null) { + int rc = cancelable.Cancel(XPCOM.NS_BINDING_ABORTED); + if (rc != XPCOM.NS_OK) Browser.error(rc); + } + shell = null; + cancelable = null; + } + }; + shell = new Shell(SWT.DIALOG_TRIM); + String msg = Compatibility.getMessage("SWT_Download_File", new Object[] {filename}); //$NON-NLS-1$ + shell.setText(msg); + GridLayout gridLayout = new GridLayout(); + gridLayout.marginHeight = 15; + gridLayout.marginWidth = 15; + gridLayout.verticalSpacing = 20; + shell.setLayout(gridLayout); + msg = Compatibility.getMessage("SWT_Download_Location", new Object[] {filename, url}); //$NON-NLS-1$ + new Label(shell, SWT.SIMPLE).setText(msg); + status = new Label(shell, SWT.SIMPLE); + msg = Compatibility.getMessage("SWT_Download_Started"); //$NON-NLS-1$ + status.setText(msg); + GridData data = new GridData (); + data.grabExcessHorizontalSpace = true; + data.grabExcessVerticalSpace = true; + status.setLayoutData (data); + + cancel = new Button(shell, SWT.PUSH); + cancel.setText(SWT.getMessage("SWT_Cancel")); //$NON-NLS-1$ + data = new GridData (); + data.horizontalAlignment = GridData.CENTER; + cancel.setLayoutData (data); + cancel.addListener(SWT.Selection, listener); + shell.addListener(SWT.Close, listener); + shell.pack(); + shell.open(); + return XPCOM.NS_OK; +} + +int /*long*/ GetAmountTransferred(int /*long*/ arg0) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +int /*long*/ GetCancelable(int /*long*/ arg0) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +public int /*long*/ GetDisplayName(int /*long*/ aDisplayName) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +public int /*long*/ GetMIMEInfo(int /*long*/ aMIMEInfo) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +public int /*long*/ GetPercentComplete(int /*long*/ aPercentComplete) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +int /*long*/ GetSize(int /*long*/ arg0) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +public int /*long*/ GetSource(int /*long*/ aSource) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +public int /*long*/ GetStartTime(int /*long*/ aStartTime) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +public int /*long*/ GetTarget(int /*long*/ aTarget) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +int /*long*/ GetTargetFile(int /*long*/ arg0) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +/* nsIProgressDialog */ +public int /*long*/ GetCancelDownloadOnClose(int /*long*/ aCancelDownloadOnClose) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +public int /*long*/ GetDialog(int /*long*/ aDialog) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +public int /*long*/ Open(int /*long*/ aParent) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +public int /*long*/ SetCancelDownloadOnClose(int /*long*/ aCancelDownloadOnClose) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +public int /*long*/ SetDialog(int /*long*/ aDialog) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +/* nsIWebProgressListener */ + +int /*long*/ OnLocationChange(int /*long*/ aWebProgress, int /*long*/ aRequest, int /*long*/ aLocation) { + return XPCOM.NS_OK; +} + +int /*long*/ OnProgressChange(int /*long*/ aWebProgress, int /*long*/ aRequest, int /*long*/ aCurSelfProgress, int /*long*/ aMaxSelfProgress, int /*long*/ aCurTotalProgress, int /*long*/ aMaxTotalProgress) { + return OnProgressChange64(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress); +} + +/* Note. The last 4 args in the original interface are defined as PRInt64. These each translate into two java ints. */ +int /*long*/ OnProgressChange64_32(int /*long*/ aWebProgress, int /*long*/ aRequest, int /*long*/ aCurSelfProgress1, int /*long*/ aCurSelfProgress2, int /*long*/ aMaxSelfProgress1, int /*long*/ aMaxSelfProgress2, int /*long*/ aCurTotalProgress1, int /*long*/ aCurTotalProgress2, int /*long*/ aMaxTotalProgress1, int /*long*/ aMaxTotalProgress2) { + long aCurSelfProgress = (aCurSelfProgress2 << 32) + aCurSelfProgress1; + long aMaxSelfProgress = (aMaxSelfProgress2 << 32) + aMaxSelfProgress1; + long aCurTotalProgress = (aCurTotalProgress2 << 32) + aCurTotalProgress1; + long aMaxTotalProgress = (aMaxTotalProgress2 << 32) + aMaxTotalProgress1; + return OnProgressChange64(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress); +} + +int /*long*/ OnProgressChange64(int /*long*/ aWebProgress, int /*long*/ aRequest, long aCurSelfProgress, long aMaxSelfProgress, long aCurTotalProgress, long aMaxTotalProgress) { + long currentKBytes = aCurSelfProgress / 1024; + long totalKBytes = aMaxTotalProgress / 1024; + if (shell != null & !shell.isDisposed()) { + Object[] arguments = {new Long(currentKBytes), new Long(totalKBytes)}; + String statusMsg = Compatibility.getMessage("SWT_Download_Status", arguments); //$NON-NLS-1$ + status.setText(statusMsg); + shell.layout(true); + shell.getDisplay().update(); + } + return XPCOM.NS_OK; +} + +int /*long*/ OnSecurityChange(int /*long*/ aWebProgress, int /*long*/ aRequest, int /*long*/ state) { + return XPCOM.NS_OK; +} + +int /*long*/ OnStateChange(int /*long*/ aWebProgress, int /*long*/ aRequest, int /*long*/ aStateFlags, int /*long*/ aStatus) { + if ((aStateFlags & nsIWebProgressListener.STATE_STOP) != 0) { + cancelable = null; + if (shell != null && !shell.isDisposed()) shell.dispose(); + shell = null; + } + return XPCOM.NS_OK; +} + +int /*long*/ OnStatusChange(int /*long*/ aWebProgress, int /*long*/ aRequest, int /*long*/ aStatus, int /*long*/ aMessage) { + return XPCOM.NS_OK; +} +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/mozilla/org/eclipse/swt/browser/HelperAppLauncherDialog.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/mozilla/org/eclipse/swt/browser/HelperAppLauncherDialog.java index 72e10d4f48..f0eabffbf2 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Browser/mozilla/org/eclipse/swt/browser/HelperAppLauncherDialog.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/mozilla/org/eclipse/swt/browser/HelperAppLauncherDialog.java @@ -97,38 +97,70 @@ int Release() { /* nsIHelperAppLauncherDialog */ public int /*long*/ Show(int /*long*/ aLauncher, int /*long*/ aContext, int /*long*/ aForced) { - nsIHelperAppLauncher helperAppLauncher = new nsIHelperAppLauncher(aLauncher); + /* + * 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_8.NS_IHELPERAPPLAUNCHER_IID, result); + if (rc == 0) { /* >= 1.8 */ + nsIHelperAppLauncher_1_8 helperAppLauncher = new nsIHelperAppLauncher_1_8(aLauncher); + rc = helperAppLauncher.SaveToDisk(0, false); + helperAppLauncher.Release(); + return rc; + } + nsIHelperAppLauncher helperAppLauncher = new nsIHelperAppLauncher(aLauncher); /* < 1.8 */ return helperAppLauncher.SaveToDisk(0, false); } public int /*long*/ PromptForSaveToFile(int /*long*/ arg0, int /*long*/ arg1, int /*long*/ arg2, int /*long*/ arg3, int /*long*/ arg4) { - nsIHelperAppLauncher helperAppLauncher = null; int /*long*/ aDefaultFile, aSuggestedFileExtension, _retval; + boolean hasLauncher = false; + /* - * Feature in Mozilla. The nsIHelperAppLauncherDialog interface is not frozen - * despite being the only way to download files when embedding Mozilla. Starting - * with Mozilla 1.5, the method PromptForSaveToFile takes an extra argument and - * previous arguments are shifted by one position. The workaround is to provide - * an XPCOMObject that fits the newer API. In all cases the first argument is a - * nsISupports reference. In the newer versions, that argument is nsIHelperAppLauncher, - * a subclass of nsISupports. The ordering of the arguments is inferred from the - * type of the first argument. + * The interface for nsIHelperAppLauncherDialog changed as of mozilla 1.5 when an + * extra argument was added to the PromptForSaveToFile method (this resulted in all + * subsequent arguments shifting right). The workaround is to provide an XPCOMObject + * that fits the newer API, and to use the first argument's type to infer whether + * the old or new nsIHelperAppLauncherDialog interface is being used (and by extension + * the ordering of the arguments). In mozilla >= 1.5 the first argument is an + * nsIHelperAppLauncher. */ + /* + * 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. + */ nsISupports support = new nsISupports(arg0); int /*long*/[] result = new int /*long*/[1]; - int rc = support.QueryInterface(nsIHelperAppLauncher.NS_IHELPERAPPLAUNCHER_IID, result); - if (rc != XPCOM.NS_OK || result[0] != arg0) { - aDefaultFile = arg1; - aSuggestedFileExtension = arg2; - _retval = arg3; + int rc = support.QueryInterface(nsIHelperAppLauncher_1_8.NS_IHELPERAPPLAUNCHER_IID, result); + boolean usingMozilla18 = rc == 0; + if (usingMozilla18) { + hasLauncher = true; + nsISupports supports = new nsISupports(result[0]); + supports.Release(); + } else { + result[0] = 0; + rc = support.QueryInterface(nsIHelperAppLauncher.NS_IHELPERAPPLAUNCHER_IID, result); + if (rc == 0) { + hasLauncher = true; + nsISupports supports = new nsISupports(result[0]); + supports.Release(); + } } - else { - helperAppLauncher = new nsIHelperAppLauncher(arg0); + result[0] = 0; + + if (hasLauncher) { /* >= 1.5 */ aDefaultFile = arg2; aSuggestedFileExtension = arg3; _retval = arg4; + } else { /* 1.4 */ + aDefaultFile = arg1; + aSuggestedFileExtension = arg2; + _retval = arg3; } - result[0] = 0; + int length = XPCOM.strlen_PRUnichar(aDefaultFile); char[] dest = new char[length]; XPCOM.memmove(dest, aDefaultFile, length * 2); @@ -138,7 +170,7 @@ public int /*long*/ PromptForSaveToFile(int /*long*/ arg0, int /*long*/ arg1, in 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); @@ -146,8 +178,14 @@ public int /*long*/ PromptForSaveToFile(int /*long*/ arg0, int /*long*/ arg1, in String name = fileDialog.open(); shell.close(); if (name == null) { - if (helperAppLauncher != null) { - rc = helperAppLauncher.Cancel(); + if (hasLauncher) { + if (usingMozilla18) { + nsIHelperAppLauncher_1_8 launcher = new nsIHelperAppLauncher_1_8(arg0); + rc = launcher.Cancel(XPCOM.NS_BINDING_ABORTED); + } else { + nsIHelperAppLauncher launcher = new nsIHelperAppLauncher(arg0); + rc = launcher.Cancel(); + } if (rc != XPCOM.NS_OK) Browser.error(rc); return XPCOM.NS_OK; } @@ -162,5 +200,4 @@ public int /*long*/ PromptForSaveToFile(int /*long*/ arg0, int /*long*/ arg1, in XPCOM.memmove(_retval, result, OS.PTR_SIZEOF); return XPCOM.NS_OK; } - } 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 b4e21d445b..ff2563847d 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 @@ -243,6 +243,18 @@ JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIIIIIII) } #endif +#ifndef NO_VtblCall__IIIIIIJII +JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIIIIIJII) + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jlong arg6, jint arg7, jint arg8) +{ + jint rc = 0; + XPCOM_NATIVE_ENTER(env, that, VtblCall__IIIIIIJII_FUNC); + rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jint, jint, jint, jlong, jint, jint))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); + XPCOM_NATIVE_EXIT(env, that, VtblCall__IIIIIIJII_FUNC); + return rc; +} +#endif + #ifndef NO_VtblCall__IIIIIIZ JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIIIIIZ) (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jboolean arg6) @@ -321,6 +333,18 @@ fail: } #endif +#ifndef NO_VtblCall__IIIIJJJJ +JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIIIJJJJ) + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jlong arg4, jlong arg5, jlong arg6, jlong arg7) +{ + jint rc = 0; + XPCOM_NATIVE_ENTER(env, that, VtblCall__IIIIJJJJ_FUNC); + rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jint, jlong, jlong, jlong, jlong))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, arg4, arg5, arg6, arg7); + XPCOM_NATIVE_EXIT(env, that, VtblCall__IIIIJJJJ_FUNC); + return rc; +} +#endif + #ifndef NO_VtblCall__IIIIJZ JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIIIJZ) (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jlong arg4, jboolean arg5) @@ -1570,28 +1594,6 @@ fail: } #endif -#ifndef NO_VtblCall__II_3B_3Z_3I -JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3B_3Z_3I) - (JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jbooleanArray arg3, jintArray arg4) -{ - jbyte *lparg2=NULL; - jboolean *lparg3=NULL; - jint *lparg4=NULL; - jint rc = 0; - XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3B_3Z_3I_FUNC); - if (arg2) if ((lparg2 = env->GetByteArrayElements(arg2, NULL)) == NULL) goto fail; - if (arg3) if ((lparg3 = env->GetBooleanArrayElements(arg3, NULL)) == NULL) goto fail; - if (arg4) if ((lparg4 = env->GetIntArrayElements(arg4, NULL)) == NULL) goto fail; - rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jbyte *, jboolean *, jint *))(*(jint **)arg1)[arg0])(arg1, lparg2, lparg3, lparg4); -fail: - if (arg4 && lparg4) env->ReleaseIntArrayElements(arg4, lparg4, 0); - if (arg3 && lparg3) env->ReleaseBooleanArrayElements(arg3, lparg3, 0); - if (arg2 && lparg2) env->ReleaseByteArrayElements(arg2, lparg2, 0); - XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3B_3Z_3I_FUNC); - return rc; -} -#endif - #ifndef NO_VtblCall__II_3C JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3C) (JNIEnv *env, jclass that, jint arg0, jint arg1, jcharArray arg2) 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 1d79c1ec9d..d43639b523 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 @@ -31,8 +31,8 @@ #ifdef NATIVE_STATS -int XPCOM_nativeFunctionCount = 132; -int XPCOM_nativeFunctionCallCount[132]; +int XPCOM_nativeFunctionCount = 133; +int XPCOM_nativeFunctionCallCount[133]; char * XPCOM_nativeFunctionNames[] = { "Call", "NS_1GetComponentManager", @@ -50,11 +50,13 @@ char * XPCOM_nativeFunctionNames[] = { "VtblCall__IIIIII", "VtblCall__IIIIIII", "VtblCall__IIIIIIII", + "VtblCall__IIIIIIJII", "VtblCall__IIIIIIZ", "VtblCall__IIIIIZ", "VtblCall__IIIIIZ_3CIIIIZ_3I_3I", "VtblCall__IIIII_3C", "VtblCall__IIIII_3I", + "VtblCall__IIIIJJJJ", "VtblCall__IIIIJZ", "VtblCall__IIIIZ", "VtblCall__IIII_3C", @@ -121,7 +123,6 @@ char * XPCOM_nativeFunctionNames[] = { "VtblCall__II_3B_3I_3Z", "VtblCall__II_3B_3J", "VtblCall__II_3B_3Z", - "VtblCall__II_3B_3Z_3I", "VtblCall__II_3C", "VtblCall__II_3CIIII", "VtblCall__II_3CI_3I", 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 3443a510fd..0e84a615ee 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 @@ -54,11 +54,13 @@ typedef enum { VtblCall__IIIIII_FUNC, VtblCall__IIIIIII_FUNC, VtblCall__IIIIIIII_FUNC, + VtblCall__IIIIIIJII_FUNC, VtblCall__IIIIIIZ_FUNC, VtblCall__IIIIIZ_FUNC, VtblCall__IIIIIZ_3CIIIIZ_3I_3I_FUNC, VtblCall__IIIII_3C_FUNC, VtblCall__IIIII_3I_FUNC, + VtblCall__IIIIJJJJ_FUNC, VtblCall__IIIIJZ_FUNC, VtblCall__IIIIZ_FUNC, VtblCall__IIII_3C_FUNC, @@ -125,7 +127,6 @@ typedef enum { VtblCall__II_3B_3I_3Z_FUNC, VtblCall__II_3B_3J_FUNC, VtblCall__II_3B_3Z_FUNC, - VtblCall__II_3B_3Z_3I_FUNC, VtblCall__II_3C_FUNC, VtblCall__II_3CIIII_FUNC, VtblCall__II_3CI_3I_FUNC, 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 095f5d98ce..1b04f2a6ed 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 @@ -58,13 +58,14 @@ public class XPCOM extends Platform { public static final String NS_PREFLOCALIZEDSTRING_CONTRACTID = "@mozilla.org/pref-localizedstring;1"; //$NON-NLS-1$ public static final String NS_PREFSERVICE_CONTRACTID = "@mozilla.org/preferences-service;1"; //$NON-NLS-1$ public static final String NS_PROMPTSERVICE_CONTRACTID = "@mozilla.org/embedcomp/prompt-service;1"; //$NON-NLS-1$ + public static final String NS_TRANSFER_CONTRACTID = "@mozilla.org/transfer;1"; //$NON-NLS-1$ public static final String NS_WINDOWWATCHER_CONTRACTID = "@mozilla.org/embedcomp/window-watcher;1"; //$NON-NLS-1$ public static final String NS_COOKIEMANAGER_CONTRACTID = "@mozilla.org/cookiemanager;1"; //$NON-NLS-1$ /* XPCOM constants */ public static final int NS_OK = 0; public static final int NS_COMFALSE = 1; - public static final int NS_BINDING_ABORTED = 2; + public static final int NS_BINDING_ABORTED = 0x804B0002; public static final int NS_ERROR_BASE = 0xc1f30000; public static final int NS_ERROR_NOT_INITIALIZED = NS_ERROR_BASE + 1; public static final int NS_ERROR_ALREADY_INITIALIZED = NS_ERROR_BASE + 2; @@ -223,5 +224,6 @@ 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); static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, byte[] arg0, int[] arg1, int /*long*/[] arg2); static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, byte[] arg0, nsID arg1, int /*long*/ arg2); -static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, byte[] arg0, boolean[] arg1, int /*long*/[] arg2); +static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int /*long*/ arg0, int /*long*/ arg1, long arg2, long arg3, long arg4, long arg5); +static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int /*long*/ arg0, int /*long*/ arg1, int /*long*/ arg2, int /*long*/ arg3, long arg4, int /*long*/ arg5, int /*long*/ arg6); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIDirectoryServiceProvider.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsICancelable.java index 97c34c96f1..e20f203922 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIDirectoryServiceProvider.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsICancelable.java @@ -27,21 +27,21 @@ * ***** END LICENSE BLOCK ***** */ package org.eclipse.swt.internal.mozilla; -public class nsIDirectoryServiceProvider extends nsISupports { +public class nsICancelable extends nsISupports { static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 1; - public static final String NS_IDIRECTORYSERVICEPROVIDER_IID_STR = - "bbf8cab0-d43a-11d3-8cc2-00609792278c"; + public static final String NS_ICANCELABLE_IID_STR = + "d94ac0a0-bb18-46b8-844e-84159064b0bd"; - public static final nsID NS_IDIRECTORYSERVICEPROVIDER_IID = - new nsID(NS_IDIRECTORYSERVICEPROVIDER_IID_STR); + public static final nsID NS_ICANCELABLE_IID = + new nsID(NS_ICANCELABLE_IID_STR); - public nsIDirectoryServiceProvider(int /*long*/ address) { + public nsICancelable(int /*long*/ address) { super(address); } - public int GetFile(byte[] prop, boolean[] persistent, int /*long*/[] _retval) { - return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), prop, persistent, _retval); + public int Cancel(int aReason) { + return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), aReason); } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIDownload_1_8.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIDownload_1_8.java new file mode 100644 index 0000000000..aeeb02446e --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIDownload_1_8.java @@ -0,0 +1,83 @@ +/* ***** 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 IBM Corp. All Rights Reserved. + * + * ***** END LICENSE BLOCK ***** */ +package org.eclipse.swt.internal.mozilla; + +public class nsIDownload_1_8 extends nsITransfer { + + static final int LAST_METHOD_ID = nsITransfer.LAST_METHOD_ID + 10; + + public static final String NS_IDOWNLOAD_IID_STR = + "9e1fd9f2-9727-4926-85cd-f16c375bba6d"; + + public static final nsID NS_IDOWNLOAD_IID = + new nsID(NS_IDOWNLOAD_IID_STR); + + public nsIDownload_1_8(int /*long*/ address) { + super(address); + } + + public int GetTargetFile(int /*long*/[] aTargetFile) { + return XPCOM.VtblCall(nsITransfer.LAST_METHOD_ID + 1, getAddress(), aTargetFile); + } + + public int GetPercentComplete(int[] aPercentComplete) { + return XPCOM.VtblCall(nsITransfer.LAST_METHOD_ID + 2, getAddress(), aPercentComplete); + } + + public int GetAmountTransferred(int /*long*/ aAmountTransferred) { + return XPCOM.VtblCall(nsITransfer.LAST_METHOD_ID + 3, getAddress(), aAmountTransferred); + } + + public int GetSize(int /*long*/ aSize) { + return XPCOM.VtblCall(nsITransfer.LAST_METHOD_ID + 4, getAddress(), aSize); + } + + public int GetSource(int /*long*/[] aSource) { + return XPCOM.VtblCall(nsITransfer.LAST_METHOD_ID + 5, getAddress(), aSource); + } + + public int GetTarget(int /*long*/[] aTarget) { + return XPCOM.VtblCall(nsITransfer.LAST_METHOD_ID + 6, getAddress(), aTarget); + } + + public int GetCancelable(int /*long*/[] aCancelable) { + return XPCOM.VtblCall(nsITransfer.LAST_METHOD_ID + 7, getAddress(), aCancelable); + } + + public int GetDisplayName(int /*long*/[] aDisplayName) { + return XPCOM.VtblCall(nsITransfer.LAST_METHOD_ID + 8, getAddress(), aDisplayName); + } + + public int GetStartTime(long[] aStartTime) { + return XPCOM.VtblCall(nsITransfer.LAST_METHOD_ID + 9, getAddress(), aStartTime); + } + + public int GetMIMEInfo(int /*long*/[] aMIMEInfo) { + return XPCOM.VtblCall(nsITransfer.LAST_METHOD_ID + 10, getAddress(), aMIMEInfo); + } +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIHelperAppLauncher_1_8.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIHelperAppLauncher_1_8.java new file mode 100644 index 0000000000..8d3a337e78 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIHelperAppLauncher_1_8.java @@ -0,0 +1,79 @@ +/* ***** 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 IBM Corp. All Rights Reserved. + * + * ***** END LICENSE BLOCK ***** */ +package org.eclipse.swt.internal.mozilla; + +public class nsIHelperAppLauncher_1_8 extends nsICancelable { + + static final int LAST_METHOD_ID = nsICancelable.LAST_METHOD_ID + 9; + + public static final String NS_IHELPERAPPLAUNCHER_IID_STR = + "99a0882d-2ff9-4659-9952-9ac531ba5592"; + + public static final nsID NS_IHELPERAPPLAUNCHER_IID = + new nsID(NS_IHELPERAPPLAUNCHER_IID_STR); + + public nsIHelperAppLauncher_1_8(int /*long*/ address) { + super(address); + } + + public int GetMIMEInfo(int /*long*/[] aMIMEInfo) { + return XPCOM.VtblCall(nsICancelable.LAST_METHOD_ID + 1, getAddress(), aMIMEInfo); + } + + public int GetSource(int /*long*/[] aSource) { + return XPCOM.VtblCall(nsICancelable.LAST_METHOD_ID + 2, getAddress(), aSource); + } + + public int GetSuggestedFileName(int /*long*/ aSuggestedFileName) { + return XPCOM.VtblCall(nsICancelable.LAST_METHOD_ID + 3, getAddress(), aSuggestedFileName); + } + + public int SaveToDisk(int /*long*/ aNewFileLocation, boolean aRememberThisPreference) { + return XPCOM.VtblCall(nsICancelable.LAST_METHOD_ID + 4, getAddress(), aNewFileLocation, aRememberThisPreference); + } + + public int LaunchWithApplication(int /*long*/ aApplication, boolean aRememberThisPreference) { + return XPCOM.VtblCall(nsICancelable.LAST_METHOD_ID + 5, getAddress(), aApplication, aRememberThisPreference); + } + + public int SetWebProgressListener(int /*long*/ aWebProgressListener) { + return XPCOM.VtblCall(nsICancelable.LAST_METHOD_ID + 6, getAddress(), aWebProgressListener); + } + + public int CloseProgressWindow() { + return XPCOM.VtblCall(nsICancelable.LAST_METHOD_ID + 7, getAddress()); + } + + public int GetTargetFile(int /*long*/[] aTargetFile) { + return XPCOM.VtblCall(nsICancelable.LAST_METHOD_ID + 8, getAddress(), aTargetFile); + } + + public int GetTimeDownloadStarted(int /*long*/ aTimeDownloadStarted) { + return XPCOM.VtblCall(nsICancelable.LAST_METHOD_ID + 9, getAddress(), aTimeDownloadStarted); + } +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIProfile.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIProfile.java deleted file mode 100644 index 8691ca3d05..0000000000 --- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIProfile.java +++ /dev/null @@ -1,87 +0,0 @@ -/* ***** 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, 2005 IBM Corp. All Rights Reserved. - * - * ***** END LICENSE BLOCK ***** */ -package org.eclipse.swt.internal.mozilla; - -public class nsIProfile extends nsISupports { - - static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 10; - - public static final String NS_IPROFILE_IID_STR = - "02b0625a-e7f3-11d2-9f5a-006008a6efe9"; - - public static final nsID NS_IPROFILE_IID = - new nsID(NS_IPROFILE_IID_STR); - - public nsIProfile(int /*long*/ address) { - super(address); - } - - public int GetProfileCount(int[] aProfileCount) { - return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), aProfileCount); - } - - public int GetProfileList(int[] length, int /*long*/[] profileNames) { - return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), length, profileNames); - } - - public int ProfileExists(char[] profileName, boolean[] _retval) { - return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), profileName, _retval); - } - - public int GetCurrentProfile(int /*long*/[] aCurrentProfile) { - return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), aCurrentProfile); - } - - public int SetCurrentProfile(char[] aCurrentProfile) { - return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 5, getAddress(), aCurrentProfile); - } - - public static final int SHUTDOWN_PERSIST = 1; - - public static final int SHUTDOWN_CLEANSE = 2; - - public int ShutDownCurrentProfile(int shutDownType) { - return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 6, getAddress(), shutDownType); - } - - public int CreateNewProfile(char[] profileName, char[] nativeProfileDir, char[] langcode, boolean useExistingDir) { - return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 7, getAddress(), profileName, nativeProfileDir, langcode, useExistingDir); - } - - public int RenameProfile(char[] oldName, char[] newName) { - return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 8, getAddress(), oldName, newName); - } - - public int DeleteProfile(char[] name, boolean canDeleteFiles) { - return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 9, getAddress(), name, canDeleteFiles); - } - - public int CloneProfile(char[] profileName) { - return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 10, getAddress(), profileName); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIDirectoryServiceProvider2.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsITransfer.java index b1cf5c4443..c9f0ba686d 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIDirectoryServiceProvider2.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsITransfer.java @@ -27,21 +27,21 @@ * ***** END LICENSE BLOCK ***** */ package org.eclipse.swt.internal.mozilla; -public class nsIDirectoryServiceProvider2 extends nsIDirectoryServiceProvider { +public class nsITransfer extends nsIWebProgressListener2 { - static final int LAST_METHOD_ID = nsIDirectoryServiceProvider.LAST_METHOD_ID + 1; + static final int LAST_METHOD_ID = nsIWebProgressListener2.LAST_METHOD_ID + 1; - public static final String NS_IDIRECTORYSERVICEPROVIDER2_IID_STR = - "2f977d4b-5485-11d4-87e2-0010a4e75ef2"; + public static final String NS_ITRANSFER_IID_STR = + "23c51569-e9a1-4a92-adeb-3723db82ef7c"; - public static final nsID NS_IDIRECTORYSERVICEPROVIDER2_IID = - new nsID(NS_IDIRECTORYSERVICEPROVIDER2_IID_STR); + public static final nsID NS_ITRANSFER_IID = + new nsID(NS_ITRANSFER_IID_STR); - public nsIDirectoryServiceProvider2(int /*long*/ address) { + public nsITransfer(int /*long*/ address) { super(address); } - public int GetFiles(byte[] prop, int /*long*/[] _retval) { - return XPCOM.VtblCall(nsIDirectoryServiceProvider.LAST_METHOD_ID + 1, getAddress(), prop, _retval); + public int Init(int /*long*/ aSource, int /*long*/ aTarget, int /*long*/ aDisplayName, int /*long*/ aMIMEInfo, long startTime, int /*long*/ aTempFile, int /*long*/ aCancelable) { + return XPCOM.VtblCall(nsIWebProgressListener2.LAST_METHOD_ID + 1, getAddress(), aSource, aTarget, aDisplayName, aMIMEInfo, startTime, aTempFile, aCancelable); } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIWebProgressListener2.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIWebProgressListener2.java new file mode 100644 index 0000000000..d27f4863ff --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIWebProgressListener2.java @@ -0,0 +1,47 @@ +/* ***** 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 IBM Corp. All Rights Reserved. + * + * ***** END LICENSE BLOCK ***** */ +package org.eclipse.swt.internal.mozilla; + +public class nsIWebProgressListener2 extends nsIWebProgressListener { + + static final int LAST_METHOD_ID = nsIWebProgressListener.LAST_METHOD_ID + 1; + + public static final String NS_IWEBPROGRESSLISTENER2_IID_STR = + "3f24610d-1e1f-4151-9d2e-239884742324"; + + public static final nsID NS_IWEBPROGRESSLISTENER2_IID = + new nsID(NS_IWEBPROGRESSLISTENER2_IID_STR); + + public nsIWebProgressListener2(int /*long*/ address) { + super(address); + } + + public int OnProgressChange64(int /*long*/ aWebProgress, int /*long*/ aRequest, long aCurSelfProgress, long aMaxSelfProgress, long aCurTotalProgress, long aMaxTotalProgress) { + return XPCOM.VtblCall(nsIWebProgressListener.LAST_METHOD_ID + 1, getAddress(), aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress); + } +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/gtk/org/eclipse/swt/browser/Browser.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/gtk/org/eclipse/swt/browser/Browser.java index 4412cb5daa..2b49482242 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/gtk/org/eclipse/swt/browser/Browser.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/gtk/org/eclipse/swt/browser/Browser.java @@ -577,7 +577,6 @@ public Browser(Composite parent, int style) { HelperAppLauncherDialogFactory dialogFactory = new HelperAppLauncherDialogFactory(); dialogFactory.AddRef(); - buffer = XPCOM.NS_HELPERAPPLAUNCHERDIALOG_CONTRACTID.getBytes(); aContractID = new byte[buffer.length + 1]; System.arraycopy(buffer, 0, aContractID, 0, buffer.length); @@ -590,10 +589,9 @@ public Browser(Composite parent, int style) { error(rc); } dialogFactory.Release(); - + DownloadFactory downloadFactory = new DownloadFactory(); downloadFactory.AddRef(); - buffer = XPCOM.NS_DOWNLOAD_CONTRACTID.getBytes(); aContractID = new byte[buffer.length + 1]; System.arraycopy(buffer, 0, aContractID, 0, buffer.length); @@ -606,10 +604,24 @@ public Browser(Composite parent, int style) { error(rc); } downloadFactory.Release(); - + + DownloadFactory_1_8 downloadFactory_1_8 = new DownloadFactory_1_8(); + downloadFactory_1_8.AddRef(); + buffer = XPCOM.NS_TRANSFER_CONTRACTID.getBytes(); + aContractID = new byte[buffer.length + 1]; + System.arraycopy(buffer, 0, aContractID, 0, buffer.length); + buffer = "Transfer".getBytes(); //$NON-NLS-1$ + aClassName = new byte[buffer.length + 1]; + System.arraycopy(buffer, 0, aClassName, 0, buffer.length); + rc = componentRegistrar.RegisterFactory(XPCOM.NS_DOWNLOAD_CID, aClassName, aContractID, downloadFactory_1_8.getAddress()); + if (rc != XPCOM.NS_OK) { + dispose(); + error(rc); + } + downloadFactory_1_8.Release(); + FilePickerFactory pickerFactory = new FilePickerFactory(); pickerFactory.AddRef(); - buffer = XPCOM.NS_FILEPICKER_CONTRACTID.getBytes(); aContractID = new byte[buffer.length + 1]; System.arraycopy(buffer, 0, aContractID, 0, buffer.length); @@ -1539,18 +1551,6 @@ void Deactivate() { webBrowserFocus.Release(); } -void SetFocusAtFirstElement() { - int /*long*/[] result = new int /*long*/[1]; - int rc = webBrowser.QueryInterface(nsIWebBrowserFocus.NS_IWEBBROWSERFOCUS_IID, result); - if (rc != XPCOM.NS_OK) error(rc); - if (result[0] == 0) error(XPCOM.NS_ERROR_NO_INTERFACE); - - nsIWebBrowserFocus webBrowserFocus = new nsIWebBrowserFocus(result[0]); - rc = webBrowserFocus.SetFocusAtFirstElement(); - if (rc != XPCOM.NS_OK) error(rc); - webBrowserFocus.Release(); -} - void onResize() { Rectangle rect = getClientArea(); int /*long*/[] result = new int /*long*/[1]; @@ -2219,18 +2219,16 @@ int /*long*/ OnStateChange(int /*long*/ aWebProgress, int /*long*/ aRequest, int int /*long*/ OnProgressChange(int /*long*/ aWebProgress, int /*long*/ aRequest, int /*long*/ aCurSelfProgress, int /*long*/ aMaxSelfProgress, int /*long*/ aCurTotalProgress, int /*long*/ aMaxTotalProgress) { if (progressListeners.length == 0) return XPCOM.NS_OK; - - int /*long*/ total = aMaxTotalProgress; - if (total <= 0) total = Integer.MAX_VALUE; ProgressEvent event = new ProgressEvent(this); event.display = getDisplay(); event.widget = this; event.current = (int)/*64*/aCurTotalProgress; event.total = (int)/*64*/aMaxTotalProgress; - for (int i = 0; i < progressListeners.length; i++) - progressListeners[i].changed(event); + for (int i = 0; i < progressListeners.length; i++) { + progressListeners[i].changed(event); + } return XPCOM.NS_OK; -} +} int /*long*/ OnLocationChange(int /*long*/ aWebProgress, int /*long*/ aRequest, int /*long*/ aLocation) { /* @@ -2288,7 +2286,7 @@ int /*long*/ OnLocationChange(int /*long*/ aWebProgress, int /*long*/ aRequest, locationListeners[i].changed(event); return XPCOM.NS_OK; } - + int /*long*/ OnStatusChange(int /*long*/ aWebProgress, int /*long*/ aRequest, int /*long*/ aStatus, int /*long*/ aMessage) { /* * Feature in Mozilla. Navigating to an HTTPS link without a user profile |