KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > swt > browser > PromptService


1 /*******************************************************************************
2  * Copyright (c) 2003, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.swt.browser;
12
13 import org.eclipse.swt.*;
14 import org.eclipse.swt.internal.*;
15 import org.eclipse.swt.internal.mozilla.*;
16 import org.eclipse.swt.widgets.*;
17
18 class PromptService {
19     XPCOMObject supports;
20     XPCOMObject promptService;
21     int refCount = 0;
22
23 public PromptService () {
24     createCOMInterfaces ();
25 }
26
27 int AddRef () {
28     refCount++;
29     return refCount;
30 }
31
32 void createCOMInterfaces () {
33     /* Create each of the interfaces that this object implements */
34     supports = new XPCOMObject (new int[] {2, 0, 0}) {
35         public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
36         public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
37         public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
38     };
39     
40     promptService = new XPCOMObject (new int[] {2, 0, 0, 3, 5, 4, 6, 10, 7, 8, 7, 7}) {
41         public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
42         public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
43         public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
44         public int /*long*/ method3 (int /*long*/[] args) {return Alert (args[0], args[1], args[2]);}
45         public int /*long*/ method4 (int /*long*/[] args) {return AlertCheck (args[0], args[1], args[2], args[3], args[4]);}
46         public int /*long*/ method5 (int /*long*/[] args) {return Confirm (args[0], args[1], args[2], args[3]);}
47         public int /*long*/ method6 (int /*long*/[] args) {return ConfirmCheck (args[0], args[1], args[2], args[3], args[4], args[5]);}
48         public int /*long*/ method7 (int /*long*/[] args) {return ConfirmEx (args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9]);}
49         public int /*long*/ method8 (int /*long*/[] args) {return Prompt (args[0], args[1], args[2], args[3], args[4], args[5], args[6]);}
50         public int /*long*/ method9 (int /*long*/[] args) {return PromptUsernameAndPassword (args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);}
51         public int /*long*/ method10 (int /*long*/[] args) {return PromptPassword (args[0], args[1], args[2], args[3], args[4], args[5], args[6]);}
52         public int /*long*/ method11 (int /*long*/[] args) {return Select (args[0], args[1], args[2], args[3], args[4], args[5], args[6]);}
53     };
54 }
55
56 void disposeCOMInterfaces () {
57     if (supports != null) {
58         supports.dispose ();
59         supports = null;
60     }
61     if (promptService != null) {
62         promptService.dispose ();
63         promptService = null;
64     }
65 }
66
67 int /*long*/ getAddress () {
68     return promptService.getAddress ();
69 }
70
71 int /*long*/ QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) {
72     if (riid == 0 || ppvObject == 0) return XPCOM.NS_ERROR_NO_INTERFACE;
73     nsID guid = new nsID ();
74     XPCOM.memmove (guid, riid, nsID.sizeof);
75     
76     if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) {
77         XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF);
78         AddRef ();
79         return XPCOM.NS_OK;
80     }
81     if (guid.Equals (nsIPromptService.NS_IPROMPTSERVICE_IID)) {
82         XPCOM.memmove (ppvObject, new int /*long*/[] {promptService.getAddress ()}, C.PTR_SIZEOF);
83         AddRef ();
84         return XPCOM.NS_OK;
85     }
86     
87     XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF);
88     return XPCOM.NS_ERROR_NO_INTERFACE;
89 }
90             
91 int Release () {
92     refCount--;
93     if (refCount == 0) disposeCOMInterfaces ();
94     return refCount;
95 }
96
97 Browser getBrowser (int /*long*/ aDOMWindow) {
98     if (aDOMWindow == 0) return null;
99
100     int /*long*/[] result = new int /*long*/[1];
101     int rc = XPCOM.NS_GetServiceManager (result);
102     if (rc != XPCOM.NS_OK) Mozilla.error (rc);
103     if (result[0] == 0) Mozilla.error (XPCOM.NS_NOINTERFACE);
104     
105     nsIServiceManager serviceManager = new nsIServiceManager (result[0]);
106     result[0] = 0;
107     byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_WINDOWWATCHER_CONTRACTID, true);
108     rc = serviceManager.GetServiceByContractID (aContractID, nsIWindowWatcher.NS_IWINDOWWATCHER_IID, result);
109     if (rc != XPCOM.NS_OK) Mozilla.error(rc);
110     if (result[0] == 0) Mozilla.error (XPCOM.NS_NOINTERFACE);
111     serviceManager.Release ();
112     
113     nsIWindowWatcher windowWatcher = new nsIWindowWatcher (result[0]);
114     result[0] = 0;
115     /* the chrome will only be answered for the top-level nsIDOMWindow */
116     nsIDOMWindow window = new nsIDOMWindow (aDOMWindow);
117     rc = window.GetTop (result);
118     if (rc != XPCOM.NS_OK) Mozilla.error (rc);
119     if (result[0] == 0) Mozilla.error (XPCOM.NS_NOINTERFACE);
120     aDOMWindow = result[0];
121     result[0] = 0;
122     rc = windowWatcher.GetChromeForWindow (aDOMWindow, result);
123     if (rc != XPCOM.NS_OK) Mozilla.error (rc);
124     if (result[0] == 0) Mozilla.error (XPCOM.NS_NOINTERFACE);
125     windowWatcher.Release ();
126     
127     nsIWebBrowserChrome webBrowserChrome = new nsIWebBrowserChrome (result[0]);
128     result[0] = 0;
129     rc = webBrowserChrome.QueryInterface (nsIEmbeddingSiteWindow.NS_IEMBEDDINGSITEWINDOW_IID, result);
130     if (rc != XPCOM.NS_OK) Mozilla.error (rc);
131     if (result[0] == 0) Mozilla.error (XPCOM.NS_NOINTERFACE);
132     webBrowserChrome.Release ();
133     
134     nsIEmbeddingSiteWindow embeddingSiteWindow = new nsIEmbeddingSiteWindow (result[0]);
135     result[0] = 0;
136     rc = embeddingSiteWindow.GetSiteWindow (result);
137     if (rc != XPCOM.NS_OK) Mozilla.error (rc);
138     if (result[0] == 0) Mozilla.error (XPCOM.NS_NOINTERFACE);
139     embeddingSiteWindow.Release ();
140     
141     return Mozilla.findBrowser (result[0]);
142 }
143
144 String JavaDoc getLabel (int buttonFlag, int index, int /*long*/ buttonTitle) {
145     String JavaDoc label = null;
146     int flag = (buttonFlag & (0xff * index)) / index;
147     switch (flag) {
148         case nsIPromptService.BUTTON_TITLE_CANCEL : label = SWT.getMessage ("SWT_Cancel"); break; //$NON-NLS-1$
149
case nsIPromptService.BUTTON_TITLE_NO : label = SWT.getMessage ("SWT_No"); break; //$NON-NLS-1$
150
case nsIPromptService.BUTTON_TITLE_OK : label = SWT.getMessage ("SWT_OK"); break; //$NON-NLS-1$
151
case nsIPromptService.BUTTON_TITLE_SAVE : label = SWT.getMessage ("SWT_Save"); break; //$NON-NLS-1$
152
case nsIPromptService.BUTTON_TITLE_YES : label = SWT.getMessage ("SWT_Yes"); break; //$NON-NLS-1$
153
case nsIPromptService.BUTTON_TITLE_IS_STRING : {
154             int length = XPCOM.strlen_PRUnichar (buttonTitle);
155             char[] dest = new char[length];
156             XPCOM.memmove (dest, buttonTitle, length * 2);
157             label = new String JavaDoc (dest);
158         }
159     }
160     return label;
161 }
162
163 /* nsIPromptService */
164
165 public int /*long*/ Alert (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText) {
166     Browser browser = getBrowser (aParent);
167     
168     int length = XPCOM.strlen_PRUnichar (aDialogTitle);
169     char[] dest = new char[length];
170     XPCOM.memmove (dest, aDialogTitle, length * 2);
171     String JavaDoc titleLabel = new String JavaDoc (dest);
172
173     length = XPCOM.strlen_PRUnichar (aText);
174     dest = new char[length];
175     XPCOM.memmove (dest, aText, length * 2);
176     String JavaDoc textLabel = new String JavaDoc (dest);
177
178     Shell shell = browser == null ? new Shell () : browser.getShell ();
179     MessageBox messageBox = new MessageBox (shell, SWT.OK | SWT.ICON_WARNING);
180     messageBox.setText (titleLabel);
181     messageBox.setMessage (textLabel);
182     messageBox.open ();
183     return XPCOM.NS_OK;
184 }
185
186 public int /*long*/ AlertCheck (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int /*long*/ aCheckMsg, int /*long*/ aCheckState) {
187     Browser browser = getBrowser (aParent);
188     
189     int length = XPCOM.strlen_PRUnichar (aDialogTitle);
190     char[] dest = new char[length];
191     XPCOM.memmove (dest, aDialogTitle, length * 2);
192     String JavaDoc titleLabel = new String JavaDoc (dest);
193
194     length = XPCOM.strlen_PRUnichar (aText);
195     dest = new char[length];
196     XPCOM.memmove (dest, aText, length * 2);
197     String JavaDoc textLabel = new String JavaDoc (dest);
198
199     length = XPCOM.strlen_PRUnichar (aCheckMsg);
200     dest = new char[length];
201     XPCOM.memmove (dest, aCheckMsg, length * 2);
202     String JavaDoc checkLabel = new String JavaDoc (dest);
203
204     Shell shell = browser == null ? new Shell () : browser.getShell ();
205     PromptDialog dialog = new PromptDialog (shell);
206     int[] check = new int[1];
207     if (aCheckState != 0) XPCOM.memmove (check, aCheckState, 4); /* PRBool */
208     dialog.alertCheck (titleLabel, textLabel, checkLabel, check);
209     if (aCheckState != 0) XPCOM.memmove (aCheckState, check, 4); /* PRBool */
210     return XPCOM.NS_OK;
211 }
212
213 public int /*long*/ Confirm (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int /*long*/ _retval) {
214     Browser browser = getBrowser (aParent);
215     
216     int length = XPCOM.strlen_PRUnichar (aDialogTitle);
217     char[] dest = new char[length];
218     XPCOM.memmove (dest, aDialogTitle, length * 2);
219     String JavaDoc titleLabel = new String JavaDoc (dest);
220
221     length = XPCOM.strlen_PRUnichar (aText);
222     dest = new char[length];
223     XPCOM.memmove (dest, aText, length * 2);
224     String JavaDoc textLabel = new String JavaDoc (dest);
225
226     Shell shell = browser == null ? new Shell () : browser.getShell ();
227     MessageBox messageBox = new MessageBox (shell, SWT.OK | SWT.CANCEL | SWT.ICON_QUESTION);
228     messageBox.setText (titleLabel);
229     messageBox.setMessage (textLabel);
230     int id = messageBox.open ();
231     int[] result = {id == SWT.OK ? 1 : 0};
232     XPCOM.memmove (_retval, result, 4);
233     return XPCOM.NS_OK;
234 }
235
236 public int /*long*/ ConfirmCheck (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int /*long*/ aCheckMsg, int /*long*/ aCheckState, int /*long*/ _retval) {
237     return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
238 }
239
240 public int /*long*/ ConfirmEx (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int /*long*/ aButtonFlags, int /*long*/ aButton0Title, int /*long*/ aButton1Title, int /*long*/ aButton2Title, int /*long*/ aCheckMsg, int /*long*/ aCheckState, int /*long*/ _retval) {
241     Browser browser = getBrowser (aParent);
242     
243     int length = XPCOM.strlen_PRUnichar (aDialogTitle);
244     char[] dest = new char[length];
245     XPCOM.memmove (dest, aDialogTitle, length * 2);
246     String JavaDoc titleLabel = new String JavaDoc (dest);
247
248     length = XPCOM.strlen_PRUnichar (aText);
249     dest = new char[length];
250     XPCOM.memmove (dest, aText, length * 2);
251     String JavaDoc textLabel = new String JavaDoc (dest);
252     
253     String JavaDoc checkLabel = null;
254     if (aCheckMsg != 0) {
255         length = XPCOM.strlen_PRUnichar (aCheckMsg);
256         dest = new char[length];
257         XPCOM.memmove (dest, aCheckMsg, length * 2);
258         checkLabel = new String JavaDoc (dest);
259     }
260     
261     String JavaDoc button0Label = getLabel ((int)/*64*/aButtonFlags, nsIPromptService.BUTTON_POS_0, aButton0Title);
262     String JavaDoc button1Label = getLabel ((int)/*64*/aButtonFlags, nsIPromptService.BUTTON_POS_1, aButton1Title);
263     String JavaDoc button2Label = getLabel ((int)/*64*/aButtonFlags, nsIPromptService.BUTTON_POS_2, aButton2Title);
264     
265     int defaultIndex = 0;
266     if ((aButtonFlags & nsIPromptService.BUTTON_POS_1_DEFAULT) != 0) {
267         defaultIndex = 1;
268     } else if ((aButtonFlags & nsIPromptService.BUTTON_POS_2_DEFAULT) != 0) {
269         defaultIndex = 2;
270     }
271     
272     Shell shell = browser == null ? new Shell () : browser.getShell ();
273     PromptDialog dialog = new PromptDialog (shell);
274     int[] check = new int[1], result = new int[1];
275     if (aCheckState != 0) XPCOM.memmove (check, aCheckState, 4);
276     dialog.confirmEx (titleLabel, textLabel, checkLabel, button0Label, button1Label, button2Label, defaultIndex, check, result);
277     if (aCheckState != 0) XPCOM.memmove (aCheckState, check, 4);
278     XPCOM.memmove (_retval, result, 4);
279     return XPCOM.NS_OK;
280 }
281
282 public int /*long*/ Prompt (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int /*long*/ aValue, int /*long*/ aCheckMsg, int /*long*/ aCheckState, int /*long*/ _retval) {
283     Browser browser = getBrowser (aParent);
284     String JavaDoc titleLabel = null, textLabel, checkLabel = null;
285     String JavaDoc[] valueLabel = new String JavaDoc[1];
286     char[] dest;
287     int length;
288     if (aDialogTitle != 0) {
289         length = XPCOM.strlen_PRUnichar (aDialogTitle);
290         dest = new char[length];
291         XPCOM.memmove (dest, aDialogTitle, length * 2);
292         titleLabel = new String JavaDoc (dest);
293     }
294     
295     length = XPCOM.strlen_PRUnichar (aText);
296     dest = new char[length];
297     XPCOM.memmove (dest, aText, length * 2);
298     textLabel = new String JavaDoc (dest);
299     
300     int /*long*/[] valueAddr = new int /*long*/[1];
301     XPCOM.memmove (valueAddr, aValue, C.PTR_SIZEOF);
302     if (valueAddr[0] != 0) {
303         length = XPCOM.strlen_PRUnichar (valueAddr[0]);
304         dest = new char[length];
305         XPCOM.memmove (dest, valueAddr[0], length * 2);
306         valueLabel[0] = new String JavaDoc (dest);
307     }
308     
309     if (aCheckMsg != 0) {
310         length = XPCOM.strlen_PRUnichar (aCheckMsg);
311         if (length > 0) {
312             dest = new char[length];
313             XPCOM.memmove (dest, aCheckMsg, length * 2);
314             checkLabel = new String JavaDoc (dest);
315         }
316     }
317
318     Shell shell = browser == null ? new Shell () : browser.getShell ();
319     PromptDialog dialog = new PromptDialog (shell);
320     int[] check = new int[1], result = new int[1];
321     if (aCheckState != 0) XPCOM.memmove (check, aCheckState, 4);
322     dialog.prompt (titleLabel, textLabel, checkLabel, valueLabel, check, result);
323
324     XPCOM.memmove (_retval, result, 4);
325     if (result[0] == 1) {
326         /*
327         * User selected OK. User name and password are returned as PRUnichar values. Any default
328         * value that we override must be freed using the nsIMemory service.
329         */

330         int cnt, size;
331         int /*long*/ ptr;
332         char[] buffer;
333         int /*long*/[] result2 = new int /*long*/[1];
334         if (valueLabel[0] != null) {
335             cnt = valueLabel[0].length ();
336             buffer = new char[cnt + 1];
337             valueLabel[0].getChars (0, cnt, buffer, 0);
338             size = buffer.length * 2;
339             ptr = C.malloc (size);
340             XPCOM.memmove (ptr, buffer, size);
341             XPCOM.memmove (aValue, new int /*long*/[] {ptr}, C.PTR_SIZEOF);
342
343             if (valueAddr[0] != 0) {
344                 int rc = XPCOM.NS_GetServiceManager (result2);
345                 if (rc != XPCOM.NS_OK) SWT.error (rc);
346                 if (result2[0] == 0) SWT.error (XPCOM.NS_NOINTERFACE);
347             
348                 nsIServiceManager serviceManager = new nsIServiceManager (result2[0]);
349                 result2[0] = 0;
350                 byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_MEMORY_CONTRACTID, true);
351                 rc = serviceManager.GetServiceByContractID (aContractID, nsIMemory.NS_IMEMORY_IID, result2);
352                 if (rc != XPCOM.NS_OK) SWT.error (rc);
353                 if (result2[0] == 0) SWT.error (XPCOM.NS_NOINTERFACE);
354                 serviceManager.Release ();
355                 
356                 nsIMemory memory = new nsIMemory (result2[0]);
357                 result2[0] = 0;
358                 memory.Free (valueAddr[0]);
359                 memory.Release ();
360             }
361         }
362     }
363     if (aCheckState != 0) XPCOM.memmove (aCheckState, check, 4);
364     return XPCOM.NS_OK;
365 }
366
367 public int /*long*/ 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) {
368     Browser browser = getBrowser (aParent);
369     String JavaDoc titleLabel, textLabel, checkLabel = null;
370     String JavaDoc[] userLabel = new String JavaDoc[1], passLabel = new String JavaDoc[1];
371     char[] dest;
372     int length;
373     if (aDialogTitle != 0) {
374         length = XPCOM.strlen_PRUnichar (aDialogTitle);
375         dest = new char[length];
376         XPCOM.memmove (dest, aDialogTitle, length * 2);
377         titleLabel = new String JavaDoc (dest);
378     } else {
379         titleLabel = ""; //$NON-NLS-1$
380
}
381     
382     length = XPCOM.strlen_PRUnichar (aText);
383     dest = new char[length];
384     XPCOM.memmove (dest, aText, length * 2);
385     textLabel = new String JavaDoc (dest);
386     
387     int /*long*/[] userAddr = new int /*long*/[1];
388     XPCOM.memmove (userAddr, aUsername, C.PTR_SIZEOF);
389     if (userAddr[0] != 0) {
390         length = XPCOM.strlen_PRUnichar (userAddr[0]);
391         dest = new char[length];
392         XPCOM.memmove (dest, userAddr[0], length * 2);
393         userLabel[0] = new String JavaDoc (dest);
394     }
395     
396     int /*long*/[] passAddr = new int /*long*/[1];
397     XPCOM.memmove (passAddr, aPassword, C.PTR_SIZEOF);
398     if (passAddr[0] != 0) {
399         length = XPCOM.strlen_PRUnichar (passAddr[0]);
400         dest = new char[length];
401         XPCOM.memmove (dest, passAddr[0], length * 2);
402         passLabel[0] = new String JavaDoc (dest);
403     }
404     
405     if (aCheckMsg != 0) {
406         length = XPCOM.strlen_PRUnichar (aCheckMsg);
407         if (length > 0) {
408             dest = new char[length];
409             XPCOM.memmove (dest, aCheckMsg, length * 2);
410             checkLabel = new String JavaDoc (dest);
411         }
412     }
413
414     Shell shell = browser == null ? new Shell () : browser.getShell ();
415     PromptDialog dialog = new PromptDialog (shell);
416     int[] check = new int[1], result = new int[1];
417     if (aCheckState != 0) XPCOM.memmove (check, aCheckState, 4);
418     dialog.promptUsernameAndPassword (titleLabel, textLabel, checkLabel, userLabel, passLabel, check, result);
419
420     XPCOM.memmove (_retval, result, 4);
421     if (result[0] == 1) {
422         /*
423         * User selected OK. User name and password are returned as PRUnichar values. Any default
424         * value that we override must be freed using the nsIMemory service.
425         */

426         int cnt, size;
427         int /*long*/ ptr;
428         char[] buffer;
429         int /*long*/[] result2 = new int /*long*/[1];
430         if (userLabel[0] != null) {
431             cnt = userLabel[0].length ();
432             buffer = new char[cnt + 1];
433             userLabel[0].getChars (0, cnt, buffer, 0);
434             size = buffer.length * 2;
435             ptr = C.malloc (size);
436             XPCOM.memmove (ptr, buffer, size);
437             XPCOM.memmove (aUsername, new int /*long*/[] {ptr}, C.PTR_SIZEOF);
438
439             if (userAddr[0] != 0) {
440                 int rc = XPCOM.NS_GetServiceManager (result2);
441                 if (rc != XPCOM.NS_OK) SWT.error (rc);
442                 if (result2[0] == 0) SWT.error (XPCOM.NS_NOINTERFACE);
443             
444                 nsIServiceManager serviceManager = new nsIServiceManager (result2[0]);
445                 result2[0] = 0;
446                 byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_MEMORY_CONTRACTID, true);
447                 rc = serviceManager.GetServiceByContractID (aContractID, nsIMemory.NS_IMEMORY_IID, result2);
448                 if (rc != XPCOM.NS_OK) SWT.error (rc);
449                 if (result[0] == 0) SWT.error (XPCOM.NS_NOINTERFACE);
450                 serviceManager.Release ();
451                 
452                 nsIMemory memory = new nsIMemory (result2[0]);
453                 result2[0] = 0;
454                 memory.Free (userAddr[0]);
455                 memory.Release ();
456             }
457         }
458         if (passLabel[0] != null) {
459             cnt = passLabel[0].length ();
460             buffer = new char[cnt + 1];
461             passLabel[0].getChars (0, cnt, buffer, 0);
462             size = buffer.length * 2;
463             ptr = C.malloc (size);
464             XPCOM.memmove (ptr, buffer, size);
465             XPCOM.memmove (aPassword, new int /*long*/[] {ptr}, C.PTR_SIZEOF);
466             
467             if (passAddr[0] != 0) {
468                 int rc = XPCOM.NS_GetServiceManager (result2);
469                 if (rc != XPCOM.NS_OK) SWT.error (rc);
470                 if (result2[0] == 0) SWT.error (XPCOM.NS_NOINTERFACE);
471
472                 nsIServiceManager serviceManager = new nsIServiceManager (result2[0]);
473                 result2[0] = 0;
474                 byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_MEMORY_CONTRACTID, true);
475                 rc = serviceManager.GetServiceByContractID (aContractID, nsIMemory.NS_IMEMORY_IID, result2);
476                 if (rc != XPCOM.NS_OK) SWT.error (rc);
477                 if (result2[0] == 0) SWT.error (XPCOM.NS_NOINTERFACE);
478                 serviceManager.Release ();
479
480                 nsIMemory memory = new nsIMemory (result2[0]);
481                 result2[0] = 0;
482                 memory.Free (passAddr[0]);
483                 memory.Release ();
484             }
485         }
486     }
487     if (aCheckState != 0) XPCOM.memmove (aCheckState, check, 4);
488     return XPCOM.NS_OK;
489 }
490
491 public int /*long*/ PromptPassword (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int /*long*/ aPassword, int /*long*/ aCheckMsg, int /*long*/ aCheckState, int /*long*/ _retval) {
492     return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
493 }
494
495 public int /*long*/ Select (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int /*long*/ aCount, int /*long*/ aSelectList, int /*long*/ aOutSelection, int /*long*/ _retval) {
496     return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
497 }
498 }
499
Popular Tags