Mercurial > projects > dwt2
comparison org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/browser/PromptService2.d @ 54:70388b0e6dad
[swt lin] compiles
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Fri, 27 Mar 2009 23:31:11 +0100 |
parents | 7e78af7adab5 |
children |
comparison
equal
deleted
inserted
replaced
53:7e78af7adab5 | 54:70388b0e6dad |
---|---|
11 * John Reimer <terminal.node@gmail.com> | 11 * John Reimer <terminal.node@gmail.com> |
12 *******************************************************************************/ | 12 *******************************************************************************/ |
13 module org.eclipse.swt.browser.PromptService2; | 13 module org.eclipse.swt.browser.PromptService2; |
14 | 14 |
15 version(Tango){ | 15 version(Tango){ |
16 import tango.stdc.stdlib; | 16 static import tango.stdc.stdlib; |
17 } else { // Phobos | 17 } else { // Phobos |
18 static import std.c.stdlib; | |
18 } | 19 } |
19 | 20 |
20 import java.lang.all; | 21 import java.lang.all; |
21 | 22 |
22 import org.eclipse.swt.SWT; | 23 import org.eclipse.swt.SWT; |
62 refCount++; | 63 refCount++; |
63 return refCount; | 64 return refCount; |
64 } | 65 } |
65 | 66 |
66 extern(System) | 67 extern(System) |
67 nsresult QueryInterface (cnsID* riid, void** ppvObject) { | 68 nsresult QueryInterface (in cnsID* riid, void** ppvObject) { |
68 if (riid is null || ppvObject is null) return XPCOM.NS_ERROR_NO_INTERFACE; | 69 if (riid is null || ppvObject is null) return XPCOM.NS_ERROR_NO_INTERFACE; |
69 | 70 |
70 if (*riid == nsISupports.IID) { | 71 if (*riid == nsISupports.IID) { |
71 *ppvObject = cast(void*)cast(nsISupports)this; | 72 *ppvObject = cast(void*)cast(nsISupports)this; |
72 AddRef (); | 73 AddRef (); |
161 case nsIPromptService.BUTTON_TITLE_YES : label = "Yes"; break; //$NON-NLS-1$ | 162 case nsIPromptService.BUTTON_TITLE_YES : label = "Yes"; break; //$NON-NLS-1$ |
162 case nsIPromptService.BUTTON_TITLE_IS_STRING : { | 163 case nsIPromptService.BUTTON_TITLE_IS_STRING : { |
163 auto span = XPCOM.strlen_PRUnichar (buttonTitle); | 164 auto span = XPCOM.strlen_PRUnichar (buttonTitle); |
164 //char[] dest = new char[length]; | 165 //char[] dest = new char[length]; |
165 //XPCOM.memmove (dest, buttonTitle, length * 2); | 166 //XPCOM.memmove (dest, buttonTitle, length * 2); |
166 label = Utf.toString (buttonTitle[0 .. span]); | 167 label = String_valueOf (buttonTitle[0 .. span]); |
167 } | 168 } |
168 } | 169 } |
169 return label; | 170 return label; |
170 } | 171 } |
171 | 172 |
176 Browser browser = getBrowser (aParent); | 177 Browser browser = getBrowser (aParent); |
177 | 178 |
178 int span = XPCOM.strlen_PRUnichar (aDialogTitle); | 179 int span = XPCOM.strlen_PRUnichar (aDialogTitle); |
179 //char[] dest = new char[length]; | 180 //char[] dest = new char[length]; |
180 //XPCOM.memmove (dest, aDialogTitle, length * 2); | 181 //XPCOM.memmove (dest, aDialogTitle, length * 2); |
181 String titleLabel = Utf.toString (aDialogTitle[0 .. span]); | 182 String titleLabel = String_valueOf (aDialogTitle[0 .. span]); |
182 | 183 |
183 span = XPCOM.strlen_PRUnichar (aText); | 184 span = XPCOM.strlen_PRUnichar (aText); |
184 //dest = new char[length]; | 185 //dest = new char[length]; |
185 //XPCOM.memmove (dest, aText, length * 2); | 186 //XPCOM.memmove (dest, aText, length * 2); |
186 String textLabel = Utf.toString (aText[0 .. span]); | 187 String textLabel = String_valueOf (aText[0 .. span]); |
187 | 188 |
188 Shell shell = browser is null ? new Shell () : browser.getShell (); | 189 Shell shell = browser is null ? new Shell () : browser.getShell (); |
189 MessageBox messageBox = new MessageBox (shell, SWT.OK | SWT.ICON_WARNING); | 190 MessageBox messageBox = new MessageBox (shell, SWT.OK | SWT.ICON_WARNING); |
190 messageBox.setText (titleLabel); | 191 messageBox.setText (titleLabel); |
191 messageBox.setMessage (textLabel); | 192 messageBox.setMessage (textLabel); |
198 Browser browser = getBrowser (aParent); | 199 Browser browser = getBrowser (aParent); |
199 | 200 |
200 int span = XPCOM.strlen_PRUnichar (aDialogTitle); | 201 int span = XPCOM.strlen_PRUnichar (aDialogTitle); |
201 //char[] dest = new char[length]; | 202 //char[] dest = new char[length]; |
202 //XPCOM.memmove (dest, aDialogTitle, length * 2); | 203 //XPCOM.memmove (dest, aDialogTitle, length * 2); |
203 String titleLabel = Utf.toString (aDialogTitle[0 .. span]); | 204 String titleLabel = String_valueOf (aDialogTitle[0 .. span]); |
204 | 205 |
205 span = XPCOM.strlen_PRUnichar (aText); | 206 span = XPCOM.strlen_PRUnichar (aText); |
206 //dest = new char[length]; | 207 //dest = new char[length]; |
207 //XPCOM.memmove (dest, aText, length * 2); | 208 //XPCOM.memmove (dest, aText, length * 2); |
208 String textLabel = Utf.toString (aText[0 .. span]); | 209 String textLabel = String_valueOf (aText[0 .. span]); |
209 | 210 |
210 span = XPCOM.strlen_PRUnichar (aCheckMsg); | 211 span = XPCOM.strlen_PRUnichar (aCheckMsg); |
211 //dest = new char[length]; | 212 //dest = new char[length]; |
212 //XPCOM.memmove (dest, aCheckMsg, length * 2); | 213 //XPCOM.memmove (dest, aCheckMsg, length * 2); |
213 String checkLabel = Utf.toString (aCheckMsg[0..span]); | 214 String checkLabel = String_valueOf (aCheckMsg[0..span]); |
214 | 215 |
215 Shell shell = browser is null ? new Shell () : browser.getShell (); | 216 Shell shell = browser is null ? new Shell () : browser.getShell (); |
216 PromptDialog dialog = new PromptDialog (shell); | 217 PromptDialog dialog = new PromptDialog (shell); |
217 int check; | 218 int check; |
218 if (aCheckState !is null) check = *aCheckState; /* PRBool */ | 219 if (aCheckState !is null) check = *aCheckState; /* PRBool */ |
231 Browser browser = getBrowser (aParent); | 232 Browser browser = getBrowser (aParent); |
232 | 233 |
233 int span = XPCOM.strlen_PRUnichar (aDialogTitle); | 234 int span = XPCOM.strlen_PRUnichar (aDialogTitle); |
234 //char[] dest = new char[length]; | 235 //char[] dest = new char[length]; |
235 //XPCOM.memmove (dest, aDialogTitle, length * 2); | 236 //XPCOM.memmove (dest, aDialogTitle, length * 2); |
236 String titleLabel = Utf.toString (aDialogTitle[0 .. span]); | 237 String titleLabel = String_valueOf (aDialogTitle[0 .. span]); |
237 | 238 |
238 span = XPCOM.strlen_PRUnichar (aText); | 239 span = XPCOM.strlen_PRUnichar (aText); |
239 //dest = new char[length]; | 240 //dest = new char[length]; |
240 //XPCOM.memmove (dest, aText, length * 2); | 241 //XPCOM.memmove (dest, aText, length * 2); |
241 String textLabel = Utf.toString (aText[0 .. span]); | 242 String textLabel = String_valueOf (aText[0 .. span]); |
242 | 243 |
243 Shell shell = browser is null ? new Shell () : browser.getShell (); | 244 Shell shell = browser is null ? new Shell () : browser.getShell (); |
244 MessageBox messageBox = new MessageBox (shell, SWT.OK | SWT.CANCEL | SWT.ICON_QUESTION); | 245 MessageBox messageBox = new MessageBox (shell, SWT.OK | SWT.CANCEL | SWT.ICON_QUESTION); |
245 messageBox.setText (titleLabel); | 246 messageBox.setText (titleLabel); |
246 messageBox.setMessage (textLabel); | 247 messageBox.setMessage (textLabel); |
260 Browser browser = getBrowser (aParent); | 261 Browser browser = getBrowser (aParent); |
261 | 262 |
262 int span = XPCOM.strlen_PRUnichar (aDialogTitle); | 263 int span = XPCOM.strlen_PRUnichar (aDialogTitle); |
263 //char[] dest = new char[length]; | 264 //char[] dest = new char[length]; |
264 //XPCOM.memmove (dest, aDialogTitle, length * 2); | 265 //XPCOM.memmove (dest, aDialogTitle, length * 2); |
265 String titleLabel = Utf.toString (aDialogTitle[0 .. span]); | 266 String titleLabel = String_valueOf (aDialogTitle[0 .. span]); |
266 | 267 |
267 span = XPCOM.strlen_PRUnichar (aText); | 268 span = XPCOM.strlen_PRUnichar (aText); |
268 //dest = new char[length]; | 269 //dest = new char[length]; |
269 //XPCOM.memmove (dest, aText, length * 2); | 270 //XPCOM.memmove (dest, aText, length * 2); |
270 String textLabel = Utf.toString (aText[0 .. span]); | 271 String textLabel = String_valueOf (aText[0 .. span]); |
271 | 272 |
272 String checkLabel = null; | 273 String checkLabel = null; |
273 if (aCheckMsg !is null) { | 274 if (aCheckMsg !is null) { |
274 span = XPCOM.strlen_PRUnichar (aCheckMsg); | 275 span = XPCOM.strlen_PRUnichar (aCheckMsg); |
275 //dest = new char[length]; | 276 //dest = new char[length]; |
276 //XPCOM.memmove (dest, aCheckMsg, length * 2); | 277 //XPCOM.memmove (dest, aCheckMsg, length * 2); |
277 checkLabel = Utf.toString (aCheckMsg[0 .. span]); | 278 checkLabel = String_valueOf (aCheckMsg[0 .. span]); |
278 } | 279 } |
279 | 280 |
280 String button0Label = getLabel (aButtonFlags, nsIPromptService.BUTTON_POS_0, aButton0Title); | 281 String button0Label = getLabel (aButtonFlags, nsIPromptService.BUTTON_POS_0, aButton0Title); |
281 String button1Label = getLabel (aButtonFlags, nsIPromptService.BUTTON_POS_1, aButton1Title); | 282 String button1Label = getLabel (aButtonFlags, nsIPromptService.BUTTON_POS_1, aButton1Title); |
282 String button2Label = getLabel (aButtonFlags, nsIPromptService.BUTTON_POS_2, aButton2Title); | 283 String button2Label = getLabel (aButtonFlags, nsIPromptService.BUTTON_POS_2, aButton2Title); |
308 int span; | 309 int span; |
309 if (aDialogTitle !is null) { | 310 if (aDialogTitle !is null) { |
310 span = XPCOM.strlen_PRUnichar (aDialogTitle); | 311 span = XPCOM.strlen_PRUnichar (aDialogTitle); |
311 //dest = new char[length]; | 312 //dest = new char[length]; |
312 //XPCOM.memmove (dest, aDialogTitle, length * 2); | 313 //XPCOM.memmove (dest, aDialogTitle, length * 2); |
313 titleLabel = Utf.toString (aDialogTitle[0 .. span]); | 314 titleLabel = String_valueOf (aDialogTitle[0 .. span]); |
314 } | 315 } |
315 | 316 |
316 span = XPCOM.strlen_PRUnichar (aText); | 317 span = XPCOM.strlen_PRUnichar (aText); |
317 //dest = new char[length]; | 318 //dest = new char[length]; |
318 //XPCOM.memmove (dest, aText, length * 2); | 319 //XPCOM.memmove (dest, aText, length * 2); |
319 textLabel = Utf.toString (aText[0 .. span]); | 320 textLabel = String_valueOf (aText[0 .. span]); |
320 | 321 |
321 //int /*long*/[] valueAddr = new int /*long*/[1]; | 322 //int /*long*/[] valueAddr = new int /*long*/[1]; |
322 //XPCOM.memmove (valueAddr, aValue, C.PTR_SIZEOF); | 323 //XPCOM.memmove (valueAddr, aValue, C.PTR_SIZEOF); |
323 auto valueAddr = aValue; | 324 auto valueAddr = aValue; |
324 if (valueAddr[0] !is null) { | 325 if (valueAddr[0] !is null) { |
325 span = XPCOM.strlen_PRUnichar (valueAddr[0]); | 326 span = XPCOM.strlen_PRUnichar (valueAddr[0]); |
326 //dest = new char[length]; | 327 //dest = new char[length]; |
327 //XPCOM.memmove (dest, valueAddr[0], length * 2); | 328 //XPCOM.memmove (dest, valueAddr[0], length * 2); |
328 valueLabel = Utf.toString ((valueAddr[0])[0 .. span]); | 329 valueLabel = String_valueOf ((valueAddr[0])[0 .. span]); |
329 } | 330 } |
330 | 331 |
331 if (aCheckMsg !is null) { | 332 if (aCheckMsg !is null) { |
332 span = XPCOM.strlen_PRUnichar (aCheckMsg); | 333 span = XPCOM.strlen_PRUnichar (aCheckMsg); |
333 if (span > 0) { | 334 if (span > 0) { |
334 //dest = new char[length]; | 335 //dest = new char[length]; |
335 //XPCOM.memmove (dest, aCheckMsg, length * 2); | 336 //XPCOM.memmove (dest, aCheckMsg, length * 2); |
336 checkLabel = Utf.toString (aCheckMsg[0 .. span]); | 337 checkLabel = String_valueOf (aCheckMsg[0 .. span]); |
337 } | 338 } |
338 } | 339 } |
339 | 340 |
340 Shell shell = browser is null ? new Shell () : browser.getShell (); | 341 Shell shell = browser is null ? new Shell () : browser.getShell (); |
341 PromptDialog dialog = new PromptDialog (shell); | 342 PromptDialog dialog = new PromptDialog (shell); |
348 * User selected OK. User name and password are returned as PRUnichar values. Any default | 349 * User selected OK. User name and password are returned as PRUnichar values. Any default |
349 * value that we override must be freed using the nsIMemory service. | 350 * value that we override must be freed using the nsIMemory service. |
350 */ | 351 */ |
351 int size; | 352 int size; |
352 void* ptr; | 353 void* ptr; |
353 wchar[] buffer; | 354 String16 buffer; |
354 nsIServiceManager serviceManager; | 355 nsIServiceManager serviceManager; |
355 if (valueLabel !is null) { | 356 if (valueLabel !is null) { |
356 //cnt = valueLabel.length; | 357 //cnt = valueLabel.length; |
357 //buffer = new wchar[cnt + 1]; | 358 //buffer = new wchar[cnt + 1]; |
358 //valueLabel.getChars (0, cnt, buffer, 0); | 359 //valueLabel.getChars (0, cnt, buffer, 0); |
359 buffer = toWCharArray(valueLabel); | 360 buffer = valueLabel.toWCharArray(); |
360 size = buffer.length * 2; | 361 size = buffer.length * 2; |
361 ptr = tango.stdc.stdlib.malloc (size); | 362 version(Tango){ |
363 ptr = tango.stdc.stdlib.malloc (size); | |
364 } else { // Phobos | |
365 ptr = std.c.stdlib.malloc (size); | |
366 } | |
362 (cast(wchar*)ptr)[0 .. buffer.length] = buffer[0 .. $]; | 367 (cast(wchar*)ptr)[0 .. buffer.length] = buffer[0 .. $]; |
363 //XPCOM.memmove (ptr, buffer, size); | 368 //XPCOM.memmove (ptr, buffer, size); |
364 //XPCOM.memmove (aValue, new int /*long*/[] {ptr}, C.PTR_SIZEOF); | 369 //XPCOM.memmove (aValue, new int /*long*/[] {ptr}, C.PTR_SIZEOF); |
365 *aValue = cast(PRUnichar*)ptr; | 370 *aValue = cast(PRUnichar*)ptr; |
366 | 371 |
402 | 407 |
403 if (checkboxLabel !is null && checkboxValue !is null) { | 408 if (checkboxLabel !is null && checkboxValue !is null) { |
404 //int span = XPCOM.strlen_PRUnichar (checkboxLabel); | 409 //int span = XPCOM.strlen_PRUnichar (checkboxLabel); |
405 //char[] dest = new char[length]; | 410 //char[] dest = new char[length]; |
406 //XPCOM.memmove (dest, checkboxLabel, length * 2); | 411 //XPCOM.memmove (dest, checkboxLabel, length * 2); |
407 checkLabel = Utf.toString (fromString16z(checkboxLabel)); | 412 checkLabel = String_valueOf (fromString16z(checkboxLabel)); |
408 checkValue = *checkboxValue; /* PRBool */ | 413 checkValue = *checkboxValue; /* PRBool */ |
409 } | 414 } |
410 | 415 |
411 /* get initial username and password values */ | 416 /* get initial username and password values */ |
412 | 417 |
503 int span; | 508 int span; |
504 if (aDialogTitle !is null) { | 509 if (aDialogTitle !is null) { |
505 //span = XPCOM.strlen_PRUnichar (aDialogTitle); | 510 //span = XPCOM.strlen_PRUnichar (aDialogTitle); |
506 //dest = new char[length]; | 511 //dest = new char[length]; |
507 //XPCOM.memmove (dest, aDialogTitle, length * 2); | 512 //XPCOM.memmove (dest, aDialogTitle, length * 2); |
508 titleLabel = Utf.toString (fromString16z(aDialogTitle)); | 513 titleLabel = String_valueOf (fromString16z(aDialogTitle)); |
509 } else { | 514 } else { |
510 //titleLabel = SWT.getMessage ("SWT_Authentication_Required"); //$NON-NLS-1$ | 515 //titleLabel = SWT.getMessage ("SWT_Authentication_Required"); //$NON-NLS-1$ |
511 titleLabel = "Authentication Required"; | 516 titleLabel = "Authentication Required"; |
512 } | 517 } |
513 | 518 |
514 //span = XPCOM.strlen_PRUnichar (aText); | 519 //span = XPCOM.strlen_PRUnichar (aText); |
515 //dest = new char[length]; | 520 //dest = new char[length]; |
516 //XPCOM.memmove (dest, aText, length * 2); | 521 //XPCOM.memmove (dest, aText, length * 2); |
517 textLabel = Utf.toString (fromString16z(aText)); | 522 textLabel = String_valueOf (fromString16z(aText)); |
518 | 523 |
519 //int /*long*/[] userAddr = new int /*long*/[1]; | 524 //int /*long*/[] userAddr = new int /*long*/[1]; |
520 //XPCOM.memmove (userAddr, aUsername, C.PTR_SIZEOF); | 525 //XPCOM.memmove (userAddr, aUsername, C.PTR_SIZEOF); |
521 auto userAddr = *aUsername; | 526 auto userAddr = *aUsername; |
522 if (*aUsername !is null) { | 527 if (*aUsername !is null) { |
523 //span = XPCOM.strlen_PRUnichar (userAddr[0]); | 528 //span = XPCOM.strlen_PRUnichar (userAddr[0]); |
524 //dest = new char[length]; | 529 //dest = new char[length]; |
525 //XPCOM.memmove (dest, userAddr[0], length * 2); | 530 //XPCOM.memmove (dest, userAddr[0], length * 2); |
526 userLabel = Utf.toString(fromString16z(*aUsername)); | 531 userLabel = String_valueOf(fromString16z(*aUsername)); |
527 } | 532 } |
528 | 533 |
529 //int /*long*/[] passAddr = new int /*long*/[1]; | 534 //int /*long*/[] passAddr = new int /*long*/[1]; |
530 //XPCOM.memmove (passAddr, aPassword, C.PTR_SIZEOF); | 535 //XPCOM.memmove (passAddr, aPassword, C.PTR_SIZEOF); |
531 auto passAddr = *aPassword; | 536 auto passAddr = *aPassword; |
532 if (*aPassword !is null) { | 537 if (*aPassword !is null) { |
533 //span = XPCOM.strlen_PRUnichar (passAddr[0]); | 538 //span = XPCOM.strlen_PRUnichar (passAddr[0]); |
534 //dest = new char[length]; | 539 //dest = new char[length]; |
535 //XPCOM.memmove (dest, passAddr[0], length * 2); | 540 //XPCOM.memmove (dest, passAddr[0], length * 2); |
536 passLabel = Utf.toString(fromString16z(*aPassword)); | 541 passLabel = String_valueOf(fromString16z(*aPassword)); |
537 } | 542 } |
538 | 543 |
539 if (aCheckMsg !is null) { | 544 if (aCheckMsg !is null) { |
540 //span = XPCOM.strlen_PRUnichar (aCheckMsg); | 545 //span = XPCOM.strlen_PRUnichar (aCheckMsg); |
541 //if (span > 0) { | 546 //if (span > 0) { |
542 //dest = new char[length]; | 547 //dest = new char[length]; |
543 //XPCOM.memmove (dest, aCheckMsg, length * 2); | 548 //XPCOM.memmove (dest, aCheckMsg, length * 2); |
544 checkLabel = Utf.toString (fromString16z(aCheckMsg)); | 549 checkLabel = String_valueOf (fromString16z(aCheckMsg)); |
545 //} | 550 //} |
546 } | 551 } |
547 | 552 |
548 Shell shell = browser is null ? new Shell () : browser.getShell (); | 553 Shell shell = browser is null ? new Shell () : browser.getShell (); |
549 PromptDialog dialog = new PromptDialog (shell); | 554 PromptDialog dialog = new PromptDialog (shell); |