annotate dwt/browser/HelperAppLauncherDialog.d @ 352:a3c5f744d03f

Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
author John Reimer <terminal.node@gmail.com>
date Tue, 04 Nov 2008 21:20:45 -0800
parents 9a4d7706df52
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
1 /*******************************************************************************
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
2 * Copyright (c) 2003, 2007 IBM Corporation and others.
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
3 * All rights reserved. This program and the accompanying materials
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
4 * are made available under the terms of the Eclipse Public License v1.0
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
5 * which accompanies this distribution, and is available at
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
6 * http://www.eclipse.org/legal/epl-v10.html
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
7 *
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
8 * Contributors:
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
9 * IBM Corporation - initial API and implementation
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
10 * Port to the D programming language:
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
11 * John Reimer <terminal.node@gmail.com>
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
12 *******************************************************************************/
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
13 module dwt.browser.HelperAppLauncherDialog;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
14
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
15 import dwt.dwthelper.utils;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
16
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
17 import Utf = tango.text.convert.Utf;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
18
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
19 import dwt.DWT;
345
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
20
341
942da4b6558a Ongoing fixup for compile
John Reimer <terminal.node@gmail.com>
parents: 298
diff changeset
21 import XPCOM = dwt.internal.mozilla.XPCOM;
345
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
22
341
942da4b6558a Ongoing fixup for compile
John Reimer <terminal.node@gmail.com>
parents: 298
diff changeset
23 import dwt.internal.mozilla.Common;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
24 import dwt.internal.mozilla.nsEmbedString;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
25 import dwt.internal.mozilla.nsID;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
26 import dwt.internal.mozilla.nsIHelperAppLauncher;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
27 import dwt.internal.mozilla.nsIHelperAppLauncherDialog;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
28 import dwt.internal.mozilla.nsIHelperAppLauncher_1_8;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
29 import dwt.internal.mozilla.nsISupports;
341
942da4b6558a Ongoing fixup for compile
John Reimer <terminal.node@gmail.com>
parents: 298
diff changeset
30 import dwt.internal.mozilla.nsILocalFile;
345
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
31 import dwt.internal.mozilla.nsStringAPI;
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
32
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
33 import dwt.browser.Mozilla;
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
34
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
35 import dwt.widgets.FileDialog;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
36 import dwt.widgets.Shell;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
37
352
a3c5f744d03f Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
John Reimer <terminal.node@gmail.com>
parents: 348
diff changeset
38 /**
a3c5f744d03f Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
John Reimer <terminal.node@gmail.com>
parents: 348
diff changeset
39 * This class implements the HelperAppLauncherDialog interface for mozilla
a3c5f744d03f Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
John Reimer <terminal.node@gmail.com>
parents: 348
diff changeset
40 * versions 1.4 - 1.8.x. For mozilla versions >= 1.9 this interface is
a3c5f744d03f Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
John Reimer <terminal.node@gmail.com>
parents: 348
diff changeset
41 * implemented by class HelperAppLauncherDialog_1_9. HelperAppLauncherDialogFactory
a3c5f744d03f Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
John Reimer <terminal.node@gmail.com>
parents: 348
diff changeset
42 * determines at runtime which of these classes to instantiate.
a3c5f744d03f Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
John Reimer <terminal.node@gmail.com>
parents: 348
diff changeset
43 */
a3c5f744d03f Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
John Reimer <terminal.node@gmail.com>
parents: 348
diff changeset
44
341
942da4b6558a Ongoing fixup for compile
John Reimer <terminal.node@gmail.com>
parents: 298
diff changeset
45 class HelperAppLauncherDialog : nsIHelperAppLauncherDialog {
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
46 int refCount = 0;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
47
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
48 this() {
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
49 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
50
348
9a4d7706df52 Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents: 346
diff changeset
51 extern(System)
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
52 nsrefcnt AddRef () {
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
53 refCount++;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
54 return refCount;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
55 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
56
348
9a4d7706df52 Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents: 346
diff changeset
57 extern(System)
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
58 nsresult QueryInterface (nsID* riid, void** ppvObject) {
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
59 if (riid is null || ppvObject is null) return XPCOM.NS_ERROR_NO_INTERFACE;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
60
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
61 if (*riid == nsISupports.IID) {
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
62 *ppvObject = cast(void*)cast(nsISupports)this;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
63 AddRef ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
64 return XPCOM.NS_OK;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
65 }
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
66 if (*riid == nsIHelperAppLauncherDialog.IID) {
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
67 *ppvObject = cast(void*)cast(nsIHelperAppLauncherDialog)this;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
68 AddRef ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
69 return XPCOM.NS_OK;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
70 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
71
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
72 *ppvObject = null;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
73 return XPCOM.NS_ERROR_NO_INTERFACE;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
74 }
348
9a4d7706df52 Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents: 346
diff changeset
75
9a4d7706df52 Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents: 346
diff changeset
76 extern(System)
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
77 nsrefcnt Release () {
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
78 refCount--;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
79 /*
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
80 * Note. This instance lives as long as the download it is binded to.
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
81 * Its reference count is expected to go down to 0 when the download
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
82 * has completed or when it has been cancelled. E.g. when the user
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
83 * cancels the File Dialog, cancels or closes the Download Dialog
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
84 * and when the Download Dialog goes away after the download is completed.
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
85 */
352
a3c5f744d03f Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
John Reimer <terminal.node@gmail.com>
parents: 348
diff changeset
86 if (refCount is 0) return 0;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
87 return refCount;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
88 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
89
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
90 /* nsIHelperAppLauncherDialog */
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
91
348
9a4d7706df52 Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents: 346
diff changeset
92 extern(System)
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 345
diff changeset
93 nsresult Show(nsIHelperAppLauncher aLauncher, nsISupports aContext, PRUint32 aReason) {
352
a3c5f744d03f Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
John Reimer <terminal.node@gmail.com>
parents: 348
diff changeset
94 /*
a3c5f744d03f Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
John Reimer <terminal.node@gmail.com>
parents: 348
diff changeset
95 * The interface for nsIHelperAppLauncher changed as of mozilla 1.8. Query the received
a3c5f744d03f Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
John Reimer <terminal.node@gmail.com>
parents: 348
diff changeset
96 * nsIHelperAppLauncher for the new interface, and if it is not found then fall back to
a3c5f744d03f Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
John Reimer <terminal.node@gmail.com>
parents: 348
diff changeset
97 * the old interface.
a3c5f744d03f Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
John Reimer <terminal.node@gmail.com>
parents: 348
diff changeset
98 */
a3c5f744d03f Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
John Reimer <terminal.node@gmail.com>
parents: 348
diff changeset
99
a3c5f744d03f Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
John Reimer <terminal.node@gmail.com>
parents: 348
diff changeset
100 nsISupports supports = cast(nsISupports)aLauncher;
a3c5f744d03f Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
John Reimer <terminal.node@gmail.com>
parents: 348
diff changeset
101 nsIHelperAppLauncher_1_8 helperAppLauncher;
a3c5f744d03f Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
John Reimer <terminal.node@gmail.com>
parents: 348
diff changeset
102 nsresult rc = supports.QueryInterface (&nsIHelperAppLauncher_1_8.IID, cast(void**)&helperAppLauncher);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
103 if (rc is 0) {
352
a3c5f744d03f Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
John Reimer <terminal.node@gmail.com>
parents: 348
diff changeset
104 rc = helperAppLauncher.SaveToDisk (null, 0);
a3c5f744d03f Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
John Reimer <terminal.node@gmail.com>
parents: 348
diff changeset
105 helperAppLauncher.Release ();
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
106 return rc;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
107 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
108
352
a3c5f744d03f Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
John Reimer <terminal.node@gmail.com>
parents: 348
diff changeset
109 /* < 1.8 */
345
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
110 return aLauncher.SaveToDisk (null, 0);
352
a3c5f744d03f Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
John Reimer <terminal.node@gmail.com>
parents: 348
diff changeset
111 // no Release for this? -JJR
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
112 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
113
348
9a4d7706df52 Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents: 346
diff changeset
114 extern(System)
345
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
115 nsresult PromptForSaveToFile (nsIHelperAppLauncher aLauncher, nsISupports aWindowContext, PRUnichar* aDefaultFile, PRUnichar* aSuggestedFileExtension, nsILocalFile* _retval) {
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
116 bool hasLauncher = false;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
117
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
118 /*
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
119 * The interface for nsIHelperAppLauncherDialog changed as of mozilla 1.5 when an
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
120 * extra argument was added to the PromptForSaveToFile method (this resulted in all
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
121 * subsequent arguments shifting right). The workaround is to provide an XPCOMObject
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
122 * that fits the newer API, and to use the first argument's type to infer whether
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
123 * the old or new nsIHelperAppLauncherDialog interface is being used (and by extension
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
124 * the ordering of the arguments). In mozilla >= 1.5 the first argument is an
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
125 * nsIHelperAppLauncher.
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
126 */
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
127 /*
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
128 * The interface for nsIHelperAppLauncher changed as of mozilla 1.8, so the first
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
129 * argument must be queried for both the old and new nsIHelperAppLauncher interfaces.
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
130 */
352
a3c5f744d03f Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
John Reimer <terminal.node@gmail.com>
parents: 348
diff changeset
131 bool using_1_8 = false;
a3c5f744d03f Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
John Reimer <terminal.node@gmail.com>
parents: 348
diff changeset
132 nsISupports support = cast(nsISupports)aLauncher;
a3c5f744d03f Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
John Reimer <terminal.node@gmail.com>
parents: 348
diff changeset
133
345
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
134 if (aLauncher is null)
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
135 assert(0);
345
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
136
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
137 nsIHelperAppLauncher_1_8 helperAppLauncher1;
352
a3c5f744d03f Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
John Reimer <terminal.node@gmail.com>
parents: 348
diff changeset
138 int rc = support.QueryInterface (&nsIHelperAppLauncher_1_8.IID, cast(void**)&helperAppLauncher1);
a3c5f744d03f Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
John Reimer <terminal.node@gmail.com>
parents: 348
diff changeset
139 if (rc is XPCOM.NS_OK) {
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
140 using_1_8 = true;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
141 hasLauncher = true;
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
142 helperAppLauncher1.Release ();
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
143 } else {
352
a3c5f744d03f Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
John Reimer <terminal.node@gmail.com>
parents: 348
diff changeset
144 nsIHelperAppLauncher helperAppLauncher;
a3c5f744d03f Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
John Reimer <terminal.node@gmail.com>
parents: 348
diff changeset
145 rc = support.QueryInterface (&nsIHelperAppLauncher.IID, cast(void**)&helperAppLauncher);
a3c5f744d03f Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
John Reimer <terminal.node@gmail.com>
parents: 348
diff changeset
146 if (rc is XPCOM.NS_OK) {
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
147 hasLauncher = true;
352
a3c5f744d03f Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
John Reimer <terminal.node@gmail.com>
parents: 348
diff changeset
148 helperAppLauncher.Release;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
149 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
150 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
151
345
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
152 /+
352
a3c5f744d03f Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
John Reimer <terminal.node@gmail.com>
parents: 348
diff changeset
153 // In D port, no suppport for version >1.4 yet
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
154 if (hasLauncher) { /* >= 1.5 */
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
155 aDefaultFile = arg2;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
156 aSuggestedFileExtension = arg3;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
157 _retval = arg4;
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
158 } else { /* 1.4 */
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
159 // This call conversion probablywon't work for non-Java
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
160 // and shouldn't get called; fix it later. -JJR
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
161 aDefaultFile = arg1;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
162 aSuggestedFileExtension = arg2;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
163 _retval = arg3;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
164 }
345
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
165 +/
341
942da4b6558a Ongoing fixup for compile
John Reimer <terminal.node@gmail.com>
parents: 298
diff changeset
166 //int span = XPCOM.strlen_PRUnichar (aDefaultFile);
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
167 // XPCOM.memmove (dest, aDefaultFile, length * 2);
345
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
168 String defaultFile = Utf.toString(fromString16z(aDefaultFile));
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
169
341
942da4b6558a Ongoing fixup for compile
John Reimer <terminal.node@gmail.com>
parents: 298
diff changeset
170 //span = XPCOM.strlen_PRUnichar (aSuggestedFileExtension);
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
171 //dest = new char[length];
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
172 //XPCOM.memmove (dest, aSuggestedFileExtension, length * 2);
345
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
173 String suggestedFileExtension = Utf.toString(fromString16z(aSuggestedFileExtension));
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
174
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
175 Shell shell = new Shell ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
176 FileDialog fileDialog = new FileDialog (shell, DWT.SAVE);
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
177 fileDialog.setFileName (defaultFile);
341
942da4b6558a Ongoing fixup for compile
John Reimer <terminal.node@gmail.com>
parents: 298
diff changeset
178 String[] tmp;
942da4b6558a Ongoing fixup for compile
John Reimer <terminal.node@gmail.com>
parents: 298
diff changeset
179 tmp ~= suggestedFileExtension;
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
180 fileDialog.setFilterExtensions (tmp);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
181 String name = fileDialog.open ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
182 shell.close ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
183 if (name is null) {
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
184 if (hasLauncher) {
352
a3c5f744d03f Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
John Reimer <terminal.node@gmail.com>
parents: 348
diff changeset
185 if (using_1_8) {
a3c5f744d03f Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
John Reimer <terminal.node@gmail.com>
parents: 348
diff changeset
186 rc = (cast(nsIHelperAppLauncher_1_8)aLauncher).Cancel (XPCOM.NS_BINDING_ABORTED);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
187 } else {
345
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
188 rc = aLauncher.Cancel ();
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
189 }
352
a3c5f744d03f Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
John Reimer <terminal.node@gmail.com>
parents: 348
diff changeset
190 if (rc !is XPCOM.NS_OK) Mozilla.error (rc,__FILE__,__LINE__);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
191 return XPCOM.NS_OK;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
192 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
193 return XPCOM.NS_ERROR_FAILURE;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
194 }
345
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
195 scope auto path = new nsEmbedString (name.toString16());
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
196 nsILocalFile localFile;
345
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
197 rc = XPCOM.NS_NewLocalFile (cast(nsAString*)path, 1, &localFile);
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
198 //path.dispose ();
352
a3c5f744d03f Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
John Reimer <terminal.node@gmail.com>
parents: 348
diff changeset
199 if (rc !is XPCOM.NS_OK) Mozilla.error (rc,__FILE__,__LINE__);
a3c5f744d03f Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
John Reimer <terminal.node@gmail.com>
parents: 348
diff changeset
200 if (localFile is null) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER,__FILE__,__LINE__);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
201 /* Our own nsIDownload has been registered during the Browser initialization. It will be invoked by Mozilla. */
345
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
202 *_retval = localFile;
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
203 //XPCOM.memmove (_retval, result, C.PTR_SIZEOF);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
204 return XPCOM.NS_OK;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
205 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
206 }