Mercurial > projects > dwt-mac
diff dwt/browser/HelperAppLauncherDialog.d @ 45:d8635bb48c7c
Merge with SWT 3.5
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Mon, 01 Dec 2008 17:07:00 +0100 |
parents | e831403a80a9 |
children | 5583f8eeee6c |
line wrap: on
line diff
--- a/dwt/browser/HelperAppLauncherDialog.d Tue Oct 21 15:20:04 2008 +0200 +++ b/dwt/browser/HelperAppLauncherDialog.d Mon Dec 01 17:07:00 2008 +0100 @@ -1,5 +1,5 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. +/******************************************************************************* + * 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 @@ -21,11 +21,16 @@ import dwt.internal.mozilla.nsIHelperAppLauncher; import dwt.internal.mozilla.nsIHelperAppLauncherDialog; import dwt.internal.mozilla.nsIHelperAppLauncher_1_8; -import dwt.internal.mozilla.nsIHelperAppLauncher_1_9; import dwt.internal.mozilla.nsISupports; import dwt.widgets.FileDialog; import dwt.widgets.Shell; +/** + * This class implements the nsIHelperAppLauncherDialog 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; @@ -109,28 +114,19 @@ 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 is 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 is 0) { + int rc = supports.QueryInterface (nsIHelperAppLauncher_1_8.NS_IHELPERAPPLAUNCHER_IID, result); + if (rc is 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); } @@ -152,28 +148,20 @@ * 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. */ - bool using_1_8 = false, using_1_9 = false; + bool 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 is 0) { + if (rc is 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 is 0) { - using_1_9 = true; + rc = support.QueryInterface (nsIHelperAppLauncher.NS_IHELPERAPPLAUNCHER_IID, result); + if (rc is XPCOM.NS_OK) { hasLauncher = true; new nsISupports (result[0]).Release (); - } else { - result[0] = 0; - rc = support.QueryInterface (nsIHelperAppLauncher.NS_IHELPERAPPLAUNCHER_IID, result); - if (rc is 0) { - hasLauncher = true; - new nsISupports (result[0]).Release (); - } } } result[0] = 0; @@ -209,9 +197,6 @@ 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 ();