annotate dwt/browser/PromptService2.d @ 346:2e591eb01162

Browser Package now compiles (phase 2 complete)
author John Reimer <terminal.node@gmail.com>
date Wed, 29 Oct 2008 20:06:08 -0700
parents 942da4b6558a
children 9a4d7706df52
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
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
58 nsrefcnt AddRef () {
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
59 refCount++;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
60 return refCount;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
61 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
62
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
63 nsresult QueryInterface (nsID* riid, void** ppvObject) {
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
64 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
65
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
66 if (*riid == nsISupports.IID) {
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
67 *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
68 AddRef ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
69 return XPCOM.NS_OK;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
70 }
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
71 if (*riid == nsIPromptService.IID) {
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
72 *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
73 AddRef ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
74 return XPCOM.NS_OK;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
75 }
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
76 if (*riid == nsIPromptService2.IID) {
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
77 *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
78 AddRef ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
79 return XPCOM.NS_OK;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
80 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
81
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
82 *ppvObject = null;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
83 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
84 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
85
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
86 nsrefcnt Release () {
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
87 refCount--;
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
88 //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
89 return refCount;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
90 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
91
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
92 Browser getBrowser (nsIDOMWindow aDOMWindow) {
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
93 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
94
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
95 //int /*long*/[] result = new int /*long*/[1];
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
96 nsIServiceManager serviceManager;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
97 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
98 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
99 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
100
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
101 //nsIServiceManager serviceManager = new nsIServiceManager (result[0]);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
102 //result[0] = 0;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
103 //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
104 nsIWindowWatcher windowWatcher;
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
105 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
106 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
107 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
108 serviceManager.Release ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
109
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
110 //nsIWindowWatcher windowWatcher = new nsIWindowWatcher (result[0]);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
111 //result[0] = 0;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
112 /* 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
113 //nsIDOMWindow window = new nsIDOMWindow (aDOMWindow);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
114 nsIDOMWindow top;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
115 rc = aDOMWindow.GetTop (&top);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
116 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
117 if (top is null) Mozilla.error (XPCOM.NS_NOINTERFACE);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
118 //aDOMWindow = result[0];
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
119 //result[0] = 0;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
120 nsIWebBrowserChrome webBrowserChrome;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
121 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
122 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
123 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
124 windowWatcher.Release ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
125
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
126 //nsIWebBrowserChrome webBrowserChrome = new nsIWebBrowserChrome (result[0]);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
127 //result[0] = 0;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
128 nsIEmbeddingSiteWindow embeddingSiteWindow;
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
129 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
130 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
131 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
132 webBrowserChrome.Release ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
133
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
134 //nsIEmbeddingSiteWindow embeddingSiteWindow = new nsIEmbeddingSiteWindow (result[0]);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
135 //result[0] = 0;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
136
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
137 void* result;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
138 rc = embeddingSiteWindow.GetSiteWindow (&result);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
139 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
140 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
141 embeddingSiteWindow.Release ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
142
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
143 return Mozilla.findBrowser (result);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
144 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
145
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
146 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
147 String label = null;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
148 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
149 switch (flag) {
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
150 // TODO: implement with DWT.getMessage - JJR
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
151 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
152 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
153 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
154 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
155 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
156 case nsIPromptService.BUTTON_TITLE_IS_STRING : {
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
157 auto span = XPCOM.strlen_PRUnichar (buttonTitle);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
158 //char[] dest = new char[length];
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
159 //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
160 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
161 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
162 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
163 return label;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
164 }
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 /* nsIPromptService */
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
167
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
168 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
169 Browser browser = getBrowser (aParent);
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
170
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
171 int span = XPCOM.strlen_PRUnichar (aDialogTitle);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
172 //char[] dest = new char[length];
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
173 //XPCOM.memmove (dest, aDialogTitle, length * 2);
341
942da4b6558a Ongoing fixup for compile
John Reimer <terminal.node@gmail.com>
parents: 303
diff changeset
174 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
175
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
176 span = XPCOM.strlen_PRUnichar (aText);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
177 //dest = new char[length];
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
178 //XPCOM.memmove (dest, aText, length * 2);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
179 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
180
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
181 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
182 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
183 messageBox.setText (titleLabel);
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
184 messageBox.setMessage (textLabel);
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
185 messageBox.open ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
186 return XPCOM.NS_OK;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
187 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
188
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
189 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
190 Browser browser = getBrowser (aParent);
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
191
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
192 int span = XPCOM.strlen_PRUnichar (aDialogTitle);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
193 //char[] dest = new char[length];
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
194 //XPCOM.memmove (dest, aDialogTitle, length * 2);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
195 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
196
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
197 span = XPCOM.strlen_PRUnichar (aText);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
198 //dest = new char[length];
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
199 //XPCOM.memmove (dest, aText, length * 2);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
200 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
201
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
202 span = XPCOM.strlen_PRUnichar (aCheckMsg);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
203 //dest = new char[length];
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
204 //XPCOM.memmove (dest, aCheckMsg, length * 2);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
205 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
206
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
207 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
208 PromptDialog dialog = new PromptDialog (shell);
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
209 int check;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
210 if (aCheckState !is null) check = *aCheckState; /* PRBool */
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
211 dialog.alertCheck (titleLabel, textLabel, checkLabel, /*ref*/ check);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
212 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
213 return XPCOM.NS_OK;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
214 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
215
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
216 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
217 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
218 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
219
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
220 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
221 Browser browser = getBrowser (aParent);
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
222
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
223 int span = XPCOM.strlen_PRUnichar (aDialogTitle);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
224 //char[] dest = new char[length];
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
225 //XPCOM.memmove (dest, aDialogTitle, length * 2);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
226 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
227
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
228 span = XPCOM.strlen_PRUnichar (aText);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
229 //dest = new char[length];
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
230 //XPCOM.memmove (dest, aText, length * 2);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
231 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
232
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
233 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
234 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
235 messageBox.setText (titleLabel);
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
236 messageBox.setMessage (textLabel);
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
237 int id = messageBox.open ();
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
238 int result = id is DWT.OK ? 1 : 0;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
239 *_retval = result;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
240 return XPCOM.NS_OK;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
241 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
242
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
243 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
244 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
245 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
246
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
247 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
248 Browser browser = getBrowser (aParent);
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
249
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
250 int span = XPCOM.strlen_PRUnichar (aDialogTitle);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
251 //char[] dest = new char[length];
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
252 //XPCOM.memmove (dest, aDialogTitle, length * 2);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
253 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
254
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
255 span = XPCOM.strlen_PRUnichar (aText);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
256 //dest = new char[length];
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
257 //XPCOM.memmove (dest, aText, length * 2);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
258 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
259
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
260 String checkLabel = null;
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
261 if (aCheckMsg !is null) {
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
262 span = XPCOM.strlen_PRUnichar (aCheckMsg);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
263 //dest = new char[length];
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
264 //XPCOM.memmove (dest, aCheckMsg, length * 2);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
265 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
266 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
267
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
268 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
269 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
270 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
271
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
272 int defaultIndex = 0;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
273 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
274 defaultIndex = 1;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
275 } 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
276 defaultIndex = 2;
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
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
279 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
280 PromptDialog dialog = new PromptDialog (shell);
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
281 int check, result;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
282 if (aCheckState !is null) check = *aCheckState;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
283 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
284 if (aCheckState !is null) *aCheckState = check;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
285 *_retval = result;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
286 return XPCOM.NS_OK;
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
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
289 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
290 Browser browser = getBrowser (aParent);
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
291 String titleLabel = null;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
292 String textLabel = null, checkLabel = null;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
293 String valueLabel;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
294 //char[] dest;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
295 int span;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
296 if (aDialogTitle !is null) {
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
297 span = XPCOM.strlen_PRUnichar (aDialogTitle);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
298 //dest = new char[length];
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
299 //XPCOM.memmove (dest, aDialogTitle, length * 2);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
300 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
301 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
302
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
303 span = XPCOM.strlen_PRUnichar (aText);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
304 //dest = new char[length];
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
305 //XPCOM.memmove (dest, aText, length * 2);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
306 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
307
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
308 //int /*long*/[] valueAddr = new int /*long*/[1];
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
309 //XPCOM.memmove (valueAddr, aValue, C.PTR_SIZEOF);
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
310 auto valueAddr = aValue;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
311 if (valueAddr[0] !is null) {
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
312 span = XPCOM.strlen_PRUnichar (valueAddr[0]);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
313 //dest = new char[length];
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
314 //XPCOM.memmove (dest, valueAddr[0], length * 2);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
315 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
316 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
317
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
318 if (aCheckMsg !is null) {
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
319 span = XPCOM.strlen_PRUnichar (aCheckMsg);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
320 if (span > 0) {
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
321 //dest = new char[length];
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
322 //XPCOM.memmove (dest, aCheckMsg, length * 2);
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
323 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
324 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
325 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
326
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
327 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
328 PromptDialog dialog = new PromptDialog (shell);
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
329 int check, result;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
330 if (aCheckState !is null) check = *aCheckState;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
331 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
332 *_retval = result;
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
333 if (result is 1) {
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
334 /*
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
335 * 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
336 * 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
337 */
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
338 int size;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
339 void* ptr;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
340 wchar[] buffer;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
341 nsIServiceManager serviceManager;
298
eec6ddb07873 More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
342 if (valueLabel !is null) {
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
343 //cnt = valueLabel.length;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
344 //buffer = new wchar[cnt + 1];
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
345 //valueLabel.getChars (0, cnt, buffer, 0);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
346 buffer = Utf.toString16(valueLabel);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
347 size = buffer.length * 2;
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
348 ptr = tango.stdc.stdlib.malloc (size);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
349 (cast(wchar*)ptr)[0 .. buffer.length] = buffer[0 .. $];
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
350 //XPCOM.memmove (ptr, buffer, size);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
351 //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
352 *aValue = cast(PRUnichar*)ptr;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
353
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
354 if (valueAddr[0] !is null) {
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
355 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
356 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
357 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
358
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
359 //nsIServiceManager serviceManager = new nsIServiceManager (result2[0]);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
360 //result2[0] = 0;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
361 nsIMemory memory;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
362 //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
363 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
364 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
365 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
366 serviceManager.Release ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
367
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
368 //nsIMemory memory = new nsIMemory (result2[0]);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
369 //result2[0] = 0;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
370 memory.Free (valueAddr[0]);
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
371 memory.Release ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
372 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
373 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
374 }
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
375 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
376 return XPCOM.NS_OK;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
377 }
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 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
380 Browser browser = getBrowser (aParent);
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
381 String checkLabel = null;
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
382 //int[] checkValue = new int[1];
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
383 //String[] userLabel = new String[1], passLabel = new String[1];
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
384 int checkValue;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
385 String userLabel, passLabel;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
386 //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
387 String title = "Authentication Required";
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
388
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
389 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
390 //int span = XPCOM.strlen_PRUnichar (checkboxLabel);
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
391 //char[] dest = new char[length];
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
392 //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
393 checkLabel = Utf.toString (fromString16z(checkboxLabel));
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
394 checkValue = *checkboxValue; /* PRBool */
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
395 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
396
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
397 /* 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
398
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
399 //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
400
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
401 scope auto ptr1 = new nsEmbedString;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
402 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
403 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
404 //int length = XPCOM.nsEmbedString_Length (ptr);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
405 //int /*long*/ buffer = XPCOM.nsEmbedString_get (ptr);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
406 //char[] chars = new char[length];
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
407 //XPCOM.memmove (chars, buffer, length * 2);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
408 userLabel = ptr1.toString;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
409 //XPCOM.nsEmbedString_delete (ptr);
278
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 scope auto ptr2 = new nsEmbedString;
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
412 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
413 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
414 //length = XPCOM.nsEmbedString_Length (ptr);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
415 //buffer = XPCOM.nsEmbedString_get (ptr);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
416 //chars = new char[length];
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
417 //XPCOM.memmove (chars, buffer, length * 2);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
418 passLabel = ptr2.toString;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
419 //XPCOM.nsEmbedString_delete (ptr);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
420
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
421 /* compute the message text */
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 ptr3 = new nsEmbedString;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
424 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
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 String realm = ptr3.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
341
942da4b6558a Ongoing fixup for compile
John Reimer <terminal.node@gmail.com>
parents: 303
diff changeset
433 //nsIChannel channel = new nsIChannel (aChannel);
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
434 nsIURI uri;
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
435 rc = aChannel.GetURI (&uri);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
436 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
437 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
438
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
439 //nsIURI nsURI = new nsIURI (uri[0]);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
440 scope auto aSpec = new nsEmbedCString;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
441 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
442 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
443 //length = XPCOM.nsEmbedCString_Length (aSpec);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
444 //buffer = XPCOM.nsEmbedCString_get (aSpec);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
445 //byte[] bytes = new byte[length];
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
446 //XPCOM.memmove (bytes, buffer, length);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
447 //XPCOM.nsEmbedCString_delete (aSpec);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
448 String host = aSpec.toString;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
449 uri.Release ();
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
450
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
451 String message;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
452 if (realm.length () > 0 && host.length () > 0) {
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
453 //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
454 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
455 } else {
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
456 message = ""; //$NON-NLS-1$
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
457 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
458
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
459 /* open the prompter */
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
460 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
461 PromptDialog dialog = new PromptDialog (shell);
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
462 int result;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
463 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
464
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
465 //XPCOM.memmove (_retval, result, 4); /* PRBool */
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
466 *_retval = result;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
467 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
468 scope auto string1 = new nsEmbedString (toString16(userLabel));
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
469 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
470 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
471 //string.dispose ();
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
472
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
473 scope auto string2 = new nsEmbedString (toString16(passLabel));
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
474 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
475 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
476 //string.dispose ();
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
477 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
478
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
479 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
480 return XPCOM.NS_OK;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
481 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
482
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
483 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
484 Browser browser = getBrowser (aParent);
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
485 String titleLabel, textLabel, checkLabel = null;
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
486 String userLabel, passLabel;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
487 char[] dest;
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
488 int span;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
489 if (aDialogTitle !is null) {
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
490 //span = XPCOM.strlen_PRUnichar (aDialogTitle);
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
491 //dest = new char[length];
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
492 //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
493 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
494 } else {
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
495 //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
496 titleLabel = "Authentication Required";
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
497 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
498
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
499 //span = XPCOM.strlen_PRUnichar (aText);
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
500 //dest = new char[length];
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
501 //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
502 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
503
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
504 //int /*long*/[] userAddr = new int /*long*/[1];
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
505 //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
506 auto userAddr = *aUsername;
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
507 if (*aUsername !is null) {
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
508 //span = XPCOM.strlen_PRUnichar (userAddr[0]);
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
509 //dest = new char[length];
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
510 //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
511 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
512 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
513
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
514 //int /*long*/[] passAddr = new int /*long*/[1];
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
515 //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
516 auto passAddr = *aPassword;
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
517 if (*aPassword !is null) {
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
518 //span = XPCOM.strlen_PRUnichar (passAddr[0]);
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
519 //dest = new char[length];
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
520 //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
521 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
522 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
523
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
524 if (aCheckMsg !is null) {
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
525 //span = XPCOM.strlen_PRUnichar (aCheckMsg);
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
526 //if (span > 0) {
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
527 //dest = new char[length];
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
528 //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
529 checkLabel = Utf.toString (fromString16z(aCheckMsg));
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
530 //}
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
531 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
532
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
533 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
534 PromptDialog dialog = new PromptDialog (shell);
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
535 int check, result;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
536 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
537 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
538
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
539 *_retval = result; /* PRBool */
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
540 if (result is 1) {
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
541 /*
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
542 * 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
543 * 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
544 */
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
545 int cnt, size;
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
546 void* ptr;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
547 wchar[] buffer;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
548 int /*long*/[] result2 = new int /*long*/[1];
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
549 if (userLabel !is null) {
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
550 //cnt = userLabel[0].length ();
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
551 //buffer = new char[cnt + 1];
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
552 //buffer = Utf.toString16(userLabel);
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
553 //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
554 //size = buffer.length * 2;
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
555 //ptr = tango.stdc.stdlib.malloc (size);
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
556 //(cast(wchar*)ptr)[0 .. buffer.length] = buffer[0 .. $];
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
557 //XPCOM.memmove (ptr, buffer, size);
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
558 *aUsername = toString16z(Utf.toString16(userLabel));
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
559 //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
560 nsIServiceManager serviceManager;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
561
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
562 if (userAddr !is null) {
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
563 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
564 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
565 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
566
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
567 //nsIServiceManager serviceManager = new nsIServiceManager (result2[0]);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
568 //result2[0] = 0;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
569 //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
570 nsIMemory memory;
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
571 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
572 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
573 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
574 serviceManager.Release ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
575
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
576 //nsIMemory memory = new nsIMemory (result2[0]);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
577 //result2[0] = 0;
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
578 memory.Free (userAddr);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
579 memory.Release ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
580 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
581 }
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
582 if (passLabel !is null) {
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
583 //cnt = passLabel[0].length ();
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
584 //buffer = new char[cnt + 1];
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
585 //buffer = Utf.toString16( passLabel );
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
586 //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
587 //size = buffer.length * 2;
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
588 //ptr = tango.stdc.stdlib.malloc (size);
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
589 //(cast(wchar*)ptr)[0 .. buffer.length] = buffer[0 .. $];
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
590 //XPCOM.memmove (ptr, buffer, size);
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
591 *aPassword = toString16z(Utf.toString16(passLabel));
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
592 //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
593
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
594 nsIServiceManager serviceManager;
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
595 if (passAddr !is null) {
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
596 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
597 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
598 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
599
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
600 //nsIServiceManager serviceManager = new nsIServiceManager (result2[0]);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
601 //result2[0] = 0;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
602 //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
603 nsIMemory memory;
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
604 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
605 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
606 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
607 serviceManager.Release ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
608
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
609 //nsIMemory memory = new nsIMemory (result2[0]);
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
610 //result2[0] = 0;
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 341
diff changeset
611 memory.Free (passAddr);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
612 memory.Release ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
613 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
614 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
615 }
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
616 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
617 return XPCOM.NS_OK;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
618 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
619
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
620 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
621 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
622 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
623
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 298
diff changeset
624 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
625 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
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 }