annotate dwt/browser/PromptService2.d @ 302:bfe1c57259e3

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