annotate dwt/browser/PromptService2.d @ 364:2bcb17ebe0be default tip

fix: thx torhu
author Frank Benoit <benoit@tionex.de>
date Sun, 08 Nov 2009 20:57:46 +0100
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, 2008 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.PromptService2;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
14
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
15 import tango.stdc.stdlib;
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
16 import tango.text.convert.Format;
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
17
341
942da4b6558a Ongoing fixup for compile
John Reimer <terminal.node@gmail.com>
parents: 303
diff changeset
18 import dwt.dwthelper.utils;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
19
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
20 import dwt.DWT;
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
21
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
22 import dwt.internal.Compatibility;
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
23
341
942da4b6558a Ongoing fixup for compile
John Reimer <terminal.node@gmail.com>
parents: 303
diff changeset
24 import XPCOM = dwt.internal.mozilla.XPCOM;
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
25
341
942da4b6558a Ongoing fixup for compile
John Reimer <terminal.node@gmail.com>
parents: 303
diff changeset
26 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
27 import dwt.internal.mozilla.nsEmbedString;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
28 import dwt.internal.mozilla.nsIAuthInformation;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
29 import dwt.internal.mozilla.nsIChannel;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
30 import dwt.internal.mozilla.nsID;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
31 import dwt.internal.mozilla.nsIDOMWindow;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
32 import dwt.internal.mozilla.nsIEmbeddingSiteWindow;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
33 import dwt.internal.mozilla.nsIMemory;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
34 import dwt.internal.mozilla.nsIPromptService;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
35 import dwt.internal.mozilla.nsIPromptService2;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
36 import dwt.internal.mozilla.nsIServiceManager;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
37 import dwt.internal.mozilla.nsISupports;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
38 import dwt.internal.mozilla.nsIURI;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
39 import dwt.internal.mozilla.nsIWebBrowserChrome;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
40 import dwt.internal.mozilla.nsIWindowWatcher;
341
942da4b6558a Ongoing fixup for compile
John Reimer <terminal.node@gmail.com>
parents: 303
diff changeset
41 import dwt.internal.mozilla.nsIAuthPromptCallback;
942da4b6558a Ongoing fixup for compile
John Reimer <terminal.node@gmail.com>
parents: 303
diff changeset
42 import dwt.internal.mozilla.nsICancelable;
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
43 import dwt.internal.mozilla.nsStringAPI;
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
44
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
45 import dwt.widgets.MessageBox;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
46 import dwt.widgets.Shell;
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
47
341
942da4b6558a Ongoing fixup for compile
John Reimer <terminal.node@gmail.com>
parents: 303
diff changeset
48 import dwt.browser.Browser;
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
49 import dwt.browser.Mozilla;
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
50 import dwt.browser.PromptDialog;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
51
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
52 class PromptService2 : nsIPromptService2 {
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
53 int refCount = 0;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
54
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
55 this () {
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
56 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
57
348
9a4d7706df52 Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents: 346
diff changeset
58 extern(System)
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
59 nsrefcnt AddRef () {
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
60 refCount++;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
61 return refCount;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
62 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
63
348
9a4d7706df52 Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents: 346
diff changeset
64 extern(System)
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
65 nsresult QueryInterface (nsID* riid, void** ppvObject) {
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
66 if (riid is null || ppvObject is null) return XPCOM.NS_ERROR_NO_INTERFACE;
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
67
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
68 if (*riid == nsISupports.IID) {
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
69 *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
70 AddRef ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
71 return XPCOM.NS_OK;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
72 }
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
73 if (*riid == nsIPromptService.IID) {
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
74 *ppvObject = cast(void*)cast(nsIPromptService)this;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
75 AddRef ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
76 return XPCOM.NS_OK;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
77 }
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
78 if (*riid == nsIPromptService2.IID) {
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
79 *ppvObject = cast(void*)cast(nsIPromptService2)this;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
80 AddRef ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
81 return XPCOM.NS_OK;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
82 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
83
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
84 *ppvObject = null;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
85 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
86 }
348
9a4d7706df52 Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents: 346
diff changeset
87
9a4d7706df52 Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents: 346
diff changeset
88 extern(System)
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
89 nsrefcnt Release () {
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
90 refCount--;
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
91 //if (refCount is 0) disposeCOMInterfaces ();
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
92 return refCount;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
93 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
94
348
9a4d7706df52 Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents: 346
diff changeset
95 extern(D)
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
96 Browser getBrowser (nsIDOMWindow aDOMWindow) {
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
97 if (aDOMWindow is null) return null;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
98
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
99 //int /*long*/[] result = new int /*long*/[1];
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
100 nsIServiceManager serviceManager;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
101 auto rc = XPCOM.NS_GetServiceManager (&serviceManager);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
102 if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
103 if (serviceManager is null) Mozilla.error (XPCOM.NS_NOINTERFACE);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
104
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
105 //nsIServiceManager serviceManager = new nsIServiceManager (result[0]);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
106 //result[0] = 0;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
107 //byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_WINDOWWATCHER_CONTRACTID, true);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
108 nsIWindowWatcher windowWatcher;
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
109 rc = serviceManager.GetServiceByContractID (XPCOM.NS_WINDOWWATCHER_CONTRACTID.ptr, &nsIWindowWatcher.IID, cast(void**)&windowWatcher);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
110 if (rc !is XPCOM.NS_OK) Mozilla.error(rc);
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
111 if (windowWatcher is null) Mozilla.error (XPCOM.NS_NOINTERFACE);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
112 serviceManager.Release ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
113
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
114 //nsIWindowWatcher windowWatcher = new nsIWindowWatcher (result[0]);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
115 //result[0] = 0;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
116 /* the chrome will only be answered for the top-level nsIDOMWindow */
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
117 //nsIDOMWindow window = new nsIDOMWindow (aDOMWindow);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
118 nsIDOMWindow top;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
119 rc = aDOMWindow.GetTop (&top);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
120 if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
121 if (top is null) Mozilla.error (XPCOM.NS_NOINTERFACE);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
122 //aDOMWindow = result[0];
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
123 //result[0] = 0;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
124 nsIWebBrowserChrome webBrowserChrome;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
125 rc = windowWatcher.GetChromeForWindow (top, &webBrowserChrome);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
126 if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
127 if (webBrowserChrome is null) Mozilla.error (XPCOM.NS_NOINTERFACE);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
128 windowWatcher.Release ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
129
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
130 //nsIWebBrowserChrome webBrowserChrome = new nsIWebBrowserChrome (result[0]);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
131 //result[0] = 0;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
132 nsIEmbeddingSiteWindow embeddingSiteWindow;
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
133 rc = webBrowserChrome.QueryInterface (&nsIEmbeddingSiteWindow.IID, cast(void**)&embeddingSiteWindow);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
134 if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
135 if (embeddingSiteWindow is null) Mozilla.error (XPCOM.NS_NOINTERFACE);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
136 webBrowserChrome.Release ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
137
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
138 //nsIEmbeddingSiteWindow embeddingSiteWindow = new nsIEmbeddingSiteWindow (result[0]);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
139 //result[0] = 0;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
140
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
141 void* result;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
142 rc = embeddingSiteWindow.GetSiteWindow (&result);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
143 if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
144 if (result is null) Mozilla.error (XPCOM.NS_NOINTERFACE);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
145 embeddingSiteWindow.Release ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
146
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
147 return Mozilla.findBrowser (result);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
148 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
149
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
150 String getLabel (int buttonFlag, int index, PRUnichar* buttonTitle) {
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
151 String label = null;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
152 int flag = (buttonFlag & (0xff * index)) / index;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
153 switch (flag) {
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
154 // TODO: implement with DWT.getMessage - JJR
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
155 case nsIPromptService.BUTTON_TITLE_CANCEL : label = "Cancel"; break; //$NON-NLS-1$
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
156 case nsIPromptService.BUTTON_TITLE_NO : label = "No"; break; //$NON-NLS-1$
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
157 case nsIPromptService.BUTTON_TITLE_OK : label = "OK"; break; //$NON-NLS-1$
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
158 case nsIPromptService.BUTTON_TITLE_SAVE : label = "Save"; break; //$NON-NLS-1$
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
159 case nsIPromptService.BUTTON_TITLE_YES : label = "Yes"; break; //$NON-NLS-1$
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
160 case nsIPromptService.BUTTON_TITLE_IS_STRING : {
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
161 auto span = XPCOM.strlen_PRUnichar (buttonTitle);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
162 //char[] dest = new char[length];
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
163 //XPCOM.memmove (dest, buttonTitle, length * 2);
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
164 label = Utf.toString (buttonTitle[0 .. span]);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
165 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
166 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
167 return label;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
168 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
169
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
170 /* nsIPromptService */
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
171
348
9a4d7706df52 Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents: 346
diff changeset
172 extern(System)
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
173 nsresult Alert (nsIDOMWindow aParent, PRUnichar* aDialogTitle, PRUnichar* aText) {
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
174 Browser browser = getBrowser (aParent);
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
175
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
176 int span = XPCOM.strlen_PRUnichar (aDialogTitle);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
177 //char[] dest = new char[length];
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
178 //XPCOM.memmove (dest, aDialogTitle, length * 2);
341
942da4b6558a Ongoing fixup for compile
John Reimer <terminal.node@gmail.com>
parents: 303
diff changeset
179 String titleLabel = Utf.toString (aDialogTitle[0 .. span]);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
180
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
181 span = XPCOM.strlen_PRUnichar (aText);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
182 //dest = new char[length];
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
183 //XPCOM.memmove (dest, aText, length * 2);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
184 String textLabel = Utf.toString (aText[0 .. span]);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
185
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
186 Shell shell = browser is null ? new Shell () : browser.getShell ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
187 MessageBox messageBox = new MessageBox (shell, DWT.OK | DWT.ICON_WARNING);
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
188 messageBox.setText (titleLabel);
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
189 messageBox.setMessage (textLabel);
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
190 messageBox.open ();
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
348
9a4d7706df52 Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents: 346
diff changeset
194 extern(System)
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
195 nsresult AlertCheck (nsIDOMWindow aParent, PRUnichar* aDialogTitle, PRUnichar* aText, PRUnichar* aCheckMsg, PRBool* aCheckState) {
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
196 Browser browser = getBrowser (aParent);
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
197
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
198 int span = XPCOM.strlen_PRUnichar (aDialogTitle);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
199 //char[] dest = new char[length];
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
200 //XPCOM.memmove (dest, aDialogTitle, length * 2);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
201 String titleLabel = Utf.toString (aDialogTitle[0 .. span]);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
202
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
203 span = XPCOM.strlen_PRUnichar (aText);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
204 //dest = new char[length];
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
205 //XPCOM.memmove (dest, aText, length * 2);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
206 String textLabel = Utf.toString (aText[0 .. span]);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
207
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
208 span = XPCOM.strlen_PRUnichar (aCheckMsg);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
209 //dest = new char[length];
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
210 //XPCOM.memmove (dest, aCheckMsg, length * 2);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
211 String checkLabel = Utf.toString (aCheckMsg[0..span]);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
212
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
213 Shell shell = browser is null ? new Shell () : browser.getShell ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
214 PromptDialog dialog = new PromptDialog (shell);
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
215 int check;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
216 if (aCheckState !is null) check = *aCheckState; /* PRBool */
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
217 dialog.alertCheck (titleLabel, textLabel, checkLabel, /*ref*/ check);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
218 if (aCheckState !is null) *aCheckState = check; /* PRBool */
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
219 return XPCOM.NS_OK;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
220 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
221
348
9a4d7706df52 Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents: 346
diff changeset
222 extern(System)
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
223 nsresult AsyncPromptAuth(nsIDOMWindow aParent, nsIChannel aChannel, nsIAuthPromptCallback aCallback, nsISupports aContext, PRUint32 level, nsIAuthInformation authInfo, PRUnichar* checkboxLabel, PRBool* checkValue, nsICancelable* _retval) {
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
224 return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
225 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
226
348
9a4d7706df52 Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents: 346
diff changeset
227 extern(System)
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
228 nsresult Confirm (nsIDOMWindow aParent, PRUnichar* aDialogTitle, PRUnichar* aText, PRBool* _retval) {
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
229 Browser browser = getBrowser (aParent);
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
230
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
231 int span = XPCOM.strlen_PRUnichar (aDialogTitle);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
232 //char[] dest = new char[length];
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
233 //XPCOM.memmove (dest, aDialogTitle, length * 2);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
234 String titleLabel = Utf.toString (aDialogTitle[0 .. span]);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
235
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
236 span = XPCOM.strlen_PRUnichar (aText);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
237 //dest = new char[length];
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
238 //XPCOM.memmove (dest, aText, length * 2);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
239 String textLabel = Utf.toString (aText[0 .. span]);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
240
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
241 Shell shell = browser is null ? new Shell () : browser.getShell ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
242 MessageBox messageBox = new MessageBox (shell, DWT.OK | DWT.CANCEL | DWT.ICON_QUESTION);
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
243 messageBox.setText (titleLabel);
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
244 messageBox.setMessage (textLabel);
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
245 int id = messageBox.open ();
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
246 int result = id is DWT.OK ? 1 : 0;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
247 *_retval = result;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
248 return XPCOM.NS_OK;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
249 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
250
348
9a4d7706df52 Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents: 346
diff changeset
251 extern(System)
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
252 nsresult ConfirmCheck (nsIDOMWindow aParent, PRUnichar* aDialogTitle, PRUnichar* aText, PRUnichar* aCheckMsg, PRBool* aCheckState, PRBool* _retval) {
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
253 return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
254 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
255
348
9a4d7706df52 Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents: 346
diff changeset
256 extern(System)
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
257 nsresult ConfirmEx (nsIDOMWindow aParent, PRUnichar* aDialogTitle, PRUnichar* aText, PRUint32 aButtonFlags, PRUnichar* aButton0Title, PRUnichar* aButton1Title, PRUnichar* aButton2Title, PRUnichar* aCheckMsg, PRBool* aCheckState, PRInt32* _retval) {
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
258 Browser browser = getBrowser (aParent);
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
259
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
260 int span = XPCOM.strlen_PRUnichar (aDialogTitle);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
261 //char[] dest = new char[length];
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
262 //XPCOM.memmove (dest, aDialogTitle, length * 2);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
263 String titleLabel = Utf.toString (aDialogTitle[0 .. span]);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
264
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
265 span = XPCOM.strlen_PRUnichar (aText);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
266 //dest = new char[length];
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
267 //XPCOM.memmove (dest, aText, length * 2);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
268 String textLabel = Utf.toString (aText[0 .. span]);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
269
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
270 String checkLabel = null;
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
271 if (aCheckMsg !is null) {
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
272 span = XPCOM.strlen_PRUnichar (aCheckMsg);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
273 //dest = new char[length];
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
274 //XPCOM.memmove (dest, aCheckMsg, length * 2);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
275 checkLabel = Utf.toString (aCheckMsg[0 .. span]);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
276 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
277
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
278 String button0Label = getLabel (aButtonFlags, nsIPromptService.BUTTON_POS_0, aButton0Title);
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
279 String button1Label = getLabel (aButtonFlags, nsIPromptService.BUTTON_POS_1, aButton1Title);
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
280 String button2Label = getLabel (aButtonFlags, nsIPromptService.BUTTON_POS_2, aButton2Title);
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
281
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
282 int defaultIndex = 0;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
283 if ((aButtonFlags & nsIPromptService.BUTTON_POS_1_DEFAULT) !is 0) {
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
284 defaultIndex = 1;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
285 } else if ((aButtonFlags & nsIPromptService.BUTTON_POS_2_DEFAULT) !is 0) {
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
286 defaultIndex = 2;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
287 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
288
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
289 Shell shell = browser is null ? new Shell () : browser.getShell ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
290 PromptDialog dialog = new PromptDialog (shell);
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
291 int check, result;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
292 if (aCheckState !is null) check = *aCheckState;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
293 dialog.confirmEx (titleLabel, textLabel, checkLabel, button0Label, button1Label, button2Label, defaultIndex, /*ref*/check, /*ref*/result);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
294 if (aCheckState !is null) *aCheckState = check;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
295 *_retval = result;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
296 return XPCOM.NS_OK;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
297 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
298
348
9a4d7706df52 Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents: 346
diff changeset
299 extern(System)
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
300 nsresult Prompt (nsIDOMWindow aParent, PRUnichar* aDialogTitle, PRUnichar* aText, PRUnichar** aValue, PRUnichar* aCheckMsg, PRBool* aCheckState, PRBool* _retval) {
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
301 Browser browser = getBrowser (aParent);
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
302 String titleLabel = null;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
303 String textLabel = null, checkLabel = null;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
304 String valueLabel;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
305 //char[] dest;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
306 int span;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
307 if (aDialogTitle !is null) {
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
308 span = XPCOM.strlen_PRUnichar (aDialogTitle);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
309 //dest = new char[length];
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
310 //XPCOM.memmove (dest, aDialogTitle, length * 2);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
311 titleLabel = Utf.toString (aDialogTitle[0 .. span]);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
312 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
313
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
314 span = XPCOM.strlen_PRUnichar (aText);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
315 //dest = new char[length];
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
316 //XPCOM.memmove (dest, aText, length * 2);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
317 textLabel = Utf.toString (aText[0 .. span]);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
318
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
319 //int /*long*/[] valueAddr = new int /*long*/[1];
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
320 //XPCOM.memmove (valueAddr, aValue, C.PTR_SIZEOF);
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
321 auto valueAddr = aValue;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
322 if (valueAddr[0] !is null) {
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
323 span = XPCOM.strlen_PRUnichar (valueAddr[0]);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
324 //dest = new char[length];
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
325 //XPCOM.memmove (dest, valueAddr[0], length * 2);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
326 valueLabel = Utf.toString ((valueAddr[0])[0 .. span]);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
327 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
328
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
329 if (aCheckMsg !is null) {
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
330 span = XPCOM.strlen_PRUnichar (aCheckMsg);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
331 if (span > 0) {
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
332 //dest = new char[length];
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
333 //XPCOM.memmove (dest, aCheckMsg, length * 2);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
334 checkLabel = Utf.toString (aCheckMsg[0 .. span]);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
335 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
336 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
337
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
338 Shell shell = browser is null ? new Shell () : browser.getShell ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
339 PromptDialog dialog = new PromptDialog (shell);
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
340 int check, result;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
341 if (aCheckState !is null) check = *aCheckState;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
342 dialog.prompt (titleLabel, textLabel, checkLabel, /*ref*/valueLabel,/*ref*/ check,/*ref*/ result);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
343 *_retval = result;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
344 if (result is 1) {
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
345 /*
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
346 * User selected OK. User name and password are returned as PRUnichar values. Any default
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
347 * value that we override must be freed using the nsIMemory service.
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
348 */
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
349 int size;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
350 void* ptr;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
351 wchar[] buffer;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
352 nsIServiceManager serviceManager;
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
353 if (valueLabel !is null) {
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
354 //cnt = valueLabel.length;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
355 //buffer = new wchar[cnt + 1];
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
356 //valueLabel.getChars (0, cnt, buffer, 0);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
357 buffer = Utf.toString16(valueLabel);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
358 size = buffer.length * 2;
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
359 ptr = tango.stdc.stdlib.malloc (size);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
360 (cast(wchar*)ptr)[0 .. buffer.length] = buffer[0 .. $];
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
361 //XPCOM.memmove (ptr, buffer, size);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
362 //XPCOM.memmove (aValue, new int /*long*/[] {ptr}, C.PTR_SIZEOF);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
363 *aValue = cast(PRUnichar*)ptr;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
364
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
365 if (valueAddr[0] !is null) {
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
366 int rc = XPCOM.NS_GetServiceManager (&serviceManager);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
367 if (rc !is XPCOM.NS_OK) DWT.error (rc);
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
368 if (serviceManager is null) DWT.error (XPCOM.NS_NOINTERFACE);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
369
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
370 //nsIServiceManager serviceManager = new nsIServiceManager (result2[0]);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
371 //result2[0] = 0;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
372 nsIMemory memory;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
373 //byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_MEMORY_CONTRACTID, true);
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
374 rc = serviceManager.GetServiceByContractID (XPCOM.NS_MEMORY_CONTRACTID.ptr, &nsIMemory.IID, cast(void**)&memory);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
375 if (rc !is XPCOM.NS_OK) DWT.error (rc);
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
376 if (memory is null) DWT.error (XPCOM.NS_NOINTERFACE);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
377 serviceManager.Release ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
378
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
379 //nsIMemory memory = new nsIMemory (result2[0]);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
380 //result2[0] = 0;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
381 memory.Free (valueAddr[0]);
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
382 memory.Release ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
383 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
384 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
385 }
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
386 if (aCheckState !is null) *aCheckState = check;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
387 return XPCOM.NS_OK;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
388 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
389
348
9a4d7706df52 Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents: 346
diff changeset
390 extern(System)
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
391 nsresult PromptAuth(nsIDOMWindow aParent, nsIChannel aChannel, PRUint32 level, nsIAuthInformation authInfo, PRUnichar* checkboxLabel, PRBool* checkboxValue, PRBool* _retval) {
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
392 Browser browser = getBrowser (aParent);
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
393 String checkLabel = null;
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
394 //int[] checkValue = new int[1];
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
395 //String[] userLabel = new String[1], passLabel = new String[1];
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
396 int checkValue;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
397 String userLabel, passLabel;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
398 //String title = DWT.getMessage ("SWT_Authentication_Required"); //$NON-NLS-1$
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
399 String title = "Authentication Required";
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
400
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
401 if (checkboxLabel !is null && checkboxValue !is null) {
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
402 //int span = XPCOM.strlen_PRUnichar (checkboxLabel);
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
403 //char[] dest = new char[length];
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
404 //XPCOM.memmove (dest, checkboxLabel, length * 2);
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
405 checkLabel = Utf.toString (fromString16z(checkboxLabel));
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
406 checkValue = *checkboxValue; /* PRBool */
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
407 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
408
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
409 /* get initial username and password values */
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
410
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
411 //nsIAuthInformation auth = new nsIAuthInformation (authInfo);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
412
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
413 scope auto ptr1 = new nsEmbedString;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
414 int rc = authInfo.GetUsername (cast(nsAString*)ptr1);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
415 if (rc !is XPCOM.NS_OK) DWT.error (rc);
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
416 //int length = XPCOM.nsEmbedString_Length (ptr);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
417 //int /*long*/ buffer = XPCOM.nsEmbedString_get (ptr);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
418 //char[] chars = new char[length];
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
419 //XPCOM.memmove (chars, buffer, length * 2);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
420 userLabel = ptr1.toString;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
421 //XPCOM.nsEmbedString_delete (ptr);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
422
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
423 scope auto ptr2 = new nsEmbedString;
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
424 rc = authInfo.GetPassword (cast(nsAString*)ptr2);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
425 if (rc !is XPCOM.NS_OK) DWT.error (rc);
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
426 //length = XPCOM.nsEmbedString_Length (ptr);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
427 //buffer = XPCOM.nsEmbedString_get (ptr);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
428 //chars = new char[length];
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
429 //XPCOM.memmove (chars, buffer, length * 2);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
430 passLabel = ptr2.toString;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
431 //XPCOM.nsEmbedString_delete (ptr);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
432
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
433 /* compute the message text */
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
434
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
435 scope auto ptr3 = new nsEmbedString;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
436 rc = authInfo.GetRealm (cast(nsAString*)ptr3);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
437 if (rc !is XPCOM.NS_OK) DWT.error (rc);
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
438 //length = XPCOM.nsEmbedString_Length (ptr);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
439 //buffer = XPCOM.nsEmbedString_get (ptr);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
440 //chars = new char[length];
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
441 //XPCOM.memmove (chars, buffer, length * 2);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
442 String realm = ptr3.toString;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
443 //XPCOM.nsEmbedString_delete (ptr);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
444
341
942da4b6558a Ongoing fixup for compile
John Reimer <terminal.node@gmail.com>
parents: 303
diff changeset
445 //nsIChannel channel = new nsIChannel (aChannel);
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
446 nsIURI uri;
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
447 rc = aChannel.GetURI (&uri);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
448 if (rc !is XPCOM.NS_OK) DWT.error (rc);
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
449 if (uri is null) Mozilla.error (XPCOM.NS_NOINTERFACE);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
450
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
451 //nsIURI nsURI = new nsIURI (uri[0]);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
452 scope auto aSpec = new nsEmbedCString;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
453 rc = uri.GetHost (cast(nsACString*)aSpec);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
454 if (rc !is XPCOM.NS_OK) DWT.error (rc);
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
455 //length = XPCOM.nsEmbedCString_Length (aSpec);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
456 //buffer = XPCOM.nsEmbedCString_get (aSpec);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
457 //byte[] bytes = new byte[length];
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
458 //XPCOM.memmove (bytes, buffer, length);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
459 //XPCOM.nsEmbedCString_delete (aSpec);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
460 String host = aSpec.toString;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
461 uri.Release ();
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
462
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
463 String message;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
464 if (realm.length () > 0 && host.length () > 0) {
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
465 //message = Compatibility.getMessage ("SWT_Enter_Username_and_Password", new String[] {realm, host}); //$NON-NLS-1$
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
466 message = Format("Enter user name and password for {0} at {1}",realm, host);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
467 } else {
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
468 message = ""; //$NON-NLS-1$
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
469 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
470
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
471 /* open the prompter */
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
472 Shell shell = browser is null ? new Shell () : browser.getShell ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
473 PromptDialog dialog = new PromptDialog (shell);
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
474 int result;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
475 dialog.promptUsernameAndPassword (title, message, checkLabel, userLabel, passLabel, checkValue, result);
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
476
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
477 //XPCOM.memmove (_retval, result, 4); /* PRBool */
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
478 *_retval = result;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
479 if (result is 1) { /* User selected OK */
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
480 scope auto string1 = new nsEmbedString (toString16(userLabel));
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
481 rc = authInfo.SetUsername(cast(nsAString*)string1);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
482 if (rc !is XPCOM.NS_OK) DWT.error (rc);
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
483 //string.dispose ();
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
484
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
485 scope auto string2 = new nsEmbedString (toString16(passLabel));
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
486 rc = authInfo.SetPassword(cast(nsAString*)string2);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
487 if (rc !is XPCOM.NS_OK) DWT.error (rc);
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
488 //string.dispose ();
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
489 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
490
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
491 if (checkboxValue !is null) *checkboxValue = checkValue; /* PRBool */
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
492 return XPCOM.NS_OK;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
493 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
494
348
9a4d7706df52 Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents: 346
diff changeset
495 extern(System)
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
496 nsresult PromptUsernameAndPassword (nsIDOMWindow aParent, PRUnichar* aDialogTitle, PRUnichar* aText, PRUnichar** aUsername, PRUnichar** aPassword, PRUnichar* aCheckMsg, PRBool* aCheckState, PRBool* _retval) {
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
497 Browser browser = getBrowser (aParent);
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
498 String titleLabel, textLabel, checkLabel = null;
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
499 String userLabel, passLabel;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
500 char[] dest;
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
501 int span;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
502 if (aDialogTitle !is null) {
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
503 //span = XPCOM.strlen_PRUnichar (aDialogTitle);
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
504 //dest = new char[length];
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
505 //XPCOM.memmove (dest, aDialogTitle, length * 2);
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
506 titleLabel = Utf.toString (fromString16z(aDialogTitle));
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
507 } else {
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
508 //titleLabel = DWT.getMessage ("SWT_Authentication_Required"); //$NON-NLS-1$
341
942da4b6558a Ongoing fixup for compile
John Reimer <terminal.node@gmail.com>
parents: 303
diff changeset
509 titleLabel = "Authentication Required";
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
510 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
511
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
512 //span = XPCOM.strlen_PRUnichar (aText);
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
513 //dest = new char[length];
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
514 //XPCOM.memmove (dest, aText, length * 2);
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
515 textLabel = Utf.toString (fromString16z(aText));
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
516
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
517 //int /*long*/[] userAddr = new int /*long*/[1];
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
518 //XPCOM.memmove (userAddr, aUsername, C.PTR_SIZEOF);
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
519 auto userAddr = *aUsername;
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
520 if (*aUsername !is null) {
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
521 //span = XPCOM.strlen_PRUnichar (userAddr[0]);
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
522 //dest = new char[length];
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
523 //XPCOM.memmove (dest, userAddr[0], length * 2);
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
524 userLabel = Utf.toString(fromString16z(*aUsername));
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
525 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
526
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
527 //int /*long*/[] passAddr = new int /*long*/[1];
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
528 //XPCOM.memmove (passAddr, aPassword, C.PTR_SIZEOF);
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
529 auto passAddr = *aPassword;
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
530 if (*aPassword !is null) {
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
531 //span = XPCOM.strlen_PRUnichar (passAddr[0]);
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
532 //dest = new char[length];
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
533 //XPCOM.memmove (dest, passAddr[0], length * 2);
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
534 passLabel = Utf.toString(fromString16z(*aPassword));
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
535 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
536
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
537 if (aCheckMsg !is null) {
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
538 //span = XPCOM.strlen_PRUnichar (aCheckMsg);
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
539 //if (span > 0) {
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
540 //dest = new char[length];
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
541 //XPCOM.memmove (dest, aCheckMsg, length * 2);
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
542 checkLabel = Utf.toString (fromString16z(aCheckMsg));
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
543 //}
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
544 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
545
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
546 Shell shell = browser is null ? new Shell () : browser.getShell ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
547 PromptDialog dialog = new PromptDialog (shell);
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
548 int check, result;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
549 if (aCheckState !is null) check = *aCheckState; /* PRBool */
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
550 dialog.promptUsernameAndPassword (titleLabel, textLabel, checkLabel, /*ref*/ userLabel, /*ref*/ passLabel, check, result);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
551
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
552 *_retval = result; /* PRBool */
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
553 if (result is 1) {
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
554 /*
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
555 * User selected OK. User name and password are returned as PRUnichar values. Any default
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
556 * value that we override must be freed using the nsIMemory service.
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
557 */
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
558 int cnt, size;
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
559 void* ptr;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
560 wchar[] buffer;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
561 int /*long*/[] result2 = new int /*long*/[1];
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
562 if (userLabel !is null) {
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
563 //cnt = userLabel[0].length ();
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
564 //buffer = new char[cnt + 1];
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
565 //buffer = Utf.toString16(userLabel);
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
566 //userLabel[0].getChars (0, cnt, buffer, 0);
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
567 //size = buffer.length * 2;
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
568 //ptr = tango.stdc.stdlib.malloc (size);
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
569 //(cast(wchar*)ptr)[0 .. buffer.length] = buffer[0 .. $];
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
570 //XPCOM.memmove (ptr, buffer, size);
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
571 *aUsername = toString16z(Utf.toString16(userLabel));
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
572 //XPCOM.memmove (aUsername, new int /*long*/[] {ptr}, C.PTR_SIZEOF);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
573 nsIServiceManager serviceManager;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
574
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
575 if (userAddr !is null) {
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
576 int rc = XPCOM.NS_GetServiceManager (&serviceManager);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
577 if (rc !is XPCOM.NS_OK) DWT.error (rc);
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
578 if (serviceManager is null) DWT.error (XPCOM.NS_NOINTERFACE);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
579
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
580 //nsIServiceManager serviceManager = new nsIServiceManager (result2[0]);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
581 //result2[0] = 0;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
582 //byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_MEMORY_CONTRACTID, true);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
583 nsIMemory memory;
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
584 rc = serviceManager.GetServiceByContractID (XPCOM.NS_MEMORY_CONTRACTID.ptr, &nsIMemory.IID, cast(void**)&memory);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
585 if (rc !is XPCOM.NS_OK) DWT.error (rc);
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
586 if (memory is null) DWT.error (XPCOM.NS_NOINTERFACE);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
587 serviceManager.Release ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
588
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
589 //nsIMemory memory = new nsIMemory (result2[0]);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
590 //result2[0] = 0;
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
591 memory.Free (userAddr);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
592 memory.Release ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
593 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
594 }
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
595 if (passLabel !is null) {
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
596 //cnt = passLabel[0].length ();
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
597 //buffer = new char[cnt + 1];
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
598 //buffer = Utf.toString16( passLabel );
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
599 //passLabel[0].getChars (0, cnt, buffer, 0);
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
600 //size = buffer.length * 2;
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
601 //ptr = tango.stdc.stdlib.malloc (size);
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
602 //(cast(wchar*)ptr)[0 .. buffer.length] = buffer[0 .. $];
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
603 //XPCOM.memmove (ptr, buffer, size);
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
604 *aPassword = toString16z(Utf.toString16(passLabel));
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
605 //XPCOM.memmove (aPassword, new int /*long*/[] {ptr}, C.PTR_SIZEOF);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
606
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
607 nsIServiceManager serviceManager;
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
608 if (passAddr !is null) {
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
609 int rc = XPCOM.NS_GetServiceManager (&serviceManager);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
610 if (rc !is XPCOM.NS_OK) DWT.error (rc);
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
611 if (serviceManager is null) DWT.error (XPCOM.NS_NOINTERFACE);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
612
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
613 //nsIServiceManager serviceManager = new nsIServiceManager (result2[0]);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
614 //result2[0] = 0;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
615 //byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_MEMORY_CONTRACTID, true);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
616 nsIMemory memory;
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
617 rc = serviceManager.GetServiceByContractID (XPCOM.NS_MEMORY_CONTRACTID.ptr, &nsIMemory.IID, cast(void**)&memory);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
618 if (rc !is XPCOM.NS_OK) DWT.error (rc);
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
619 if (memory is null) DWT.error (XPCOM.NS_NOINTERFACE);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
620 serviceManager.Release ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
621
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
622 //nsIMemory memory = new nsIMemory (result2[0]);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
623 //result2[0] = 0;
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
624 memory.Free (passAddr);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
625 memory.Release ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
626 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
627 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
628 }
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
629 if (aCheckState !is null) *aCheckState = check; /* PRBool */
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
630 return XPCOM.NS_OK;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
631 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
632
348
9a4d7706df52 Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents: 346
diff changeset
633 extern(System)
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
634 nsresult PromptPassword (nsIDOMWindow aParent, PRUnichar* aDialogTitle, PRUnichar* aText, PRUnichar** aPassword, PRUnichar* aCheckMsg, PRBool* aCheckState, PRBool* _retval) {
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
635 return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
636 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
637
348
9a4d7706df52 Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents: 346
diff changeset
638 extern(System)
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
639 nsresult Select (nsIDOMWindow aParent, PRUnichar* aDialogTitle, PRUnichar* aText, PRUint32 aCount, PRUnichar** aSelectList, PRInt32* aOutSelection, PRBool* _retval) {
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
640 return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
641 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
642
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
643 }