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