comparison dwt/browser/Mozilla.d @ 341:942da4b6558a

Ongoing fixup for compile
author John Reimer <terminal.node@gmail.com>
date Sun, 26 Oct 2008 21:19:51 -0700
parents 3f4a5c7d138f
children 96243e3ebcf0
comparison
equal deleted inserted replaced
340:3f4a5c7d138f 341:942da4b6558a
21 //import java.util.Enumeration; 21 //import java.util.Enumeration;
22 //import java.util.Locale; 22 //import java.util.Locale;
23 //import java.util.Vector; 23 //import java.util.Vector;
24 24
25 import tango.text.locale.Core; // Necessary for Region/Culture/Locale code 25 import tango.text.locale.Core; // Necessary for Region/Culture/Locale code
26 import tango.text.convert.Format;
27 import tango.io.Console;
28 import tango.sys.Environment;
29
26 import dwt.internal.c.gtk; 30 import dwt.internal.c.gtk;
27 31
28 import dwt.DWT; 32 import dwt.DWT;
29 import dwt.DWTError; 33 import dwt.DWTError;
30 import dwt.graphics.Device; 34 import dwt.graphics.Device;
31 import dwt.graphics.Point; 35 import dwt.graphics.Point;
32 import dwt.graphics.Rectangle; 36 import dwt.graphics.Rectangle;
33 37
38 import dwt.browser.Browser;
39 import dwt.browser.WebBrowser;
34 import dwt.browser.MozillaDelegate; 40 import dwt.browser.MozillaDelegate;
35 import dwt.browser.AppFileLocProvider; 41 import dwt.browser.AppFileLocProvider;
36 import dwt.browser.WindowCreator2; 42 import dwt.browser.WindowCreator2;
43 import dwt.browser.PromptService2Factory;
44 import dwt.browser.HelperAppLauncherDialogFactory;
45 import dwt.browser.DownloadFactory;
46 import dwt.browser.DownloadFactory_1_8;
47 import dwt.browser.FilePickerFactory;
48 import dwt.browser.FilePickerFactory_1_8;
37 49
38 import dwt.internal.Compatibility; 50 import dwt.internal.Compatibility;
39 import dwt.internal.LONG; 51 import dwt.internal.LONG;
40 import dwt.internal.Library; 52 import dwt.internal.Library;
41 53
42 import dwt.internal.mozilla.XPCOM; 54 import XPCOM = dwt.internal.mozilla.XPCOM;
43 import dwt.internal.mozilla.XPCOMInit; 55 import XPCOMInit = dwt.internal.mozilla.XPCOMInit;
56
44 import dwt.internal.mozilla.Common; 57 import dwt.internal.mozilla.Common;
45
46 import dwt.internal.mozilla.nsEmbedString; 58 import dwt.internal.mozilla.nsEmbedString;
47 import dwt.internal.mozilla.nsIAppShell; 59 import dwt.internal.mozilla.nsIAppShell;
48 import dwt.internal.mozilla.nsIBaseWindow; 60 import dwt.internal.mozilla.nsIBaseWindow;
49 import dwt.internal.mozilla.nsICategoryManager; 61 import dwt.internal.mozilla.nsICategoryManager;
50 import dwt.internal.mozilla.nsIComponentManager; 62 import dwt.internal.mozilla.nsIComponentManager;
51 import dwt.internal.mozilla.nsIComponentRegistrar; 63 import dwt.internal.mozilla.nsIComponentRegistrar;
52 import dwt.internal.mozilla.nsIContextMenuListener; 64 import dwt.internal.mozilla.nsIContextMenuListener;
53 import dwt.internal.mozilla.nsICookie; 65 import dwt.internal.mozilla.nsICookie;
54 import dwt.internal.mozilla.nsICookieManager; 66 import dwt.internal.mozilla.nsICookieManager;
55 import dwt.internal.mozilla.nsID; 67 import dwt.internal.mozilla.nsID;
68 import dwt.internal.mozilla.nsIDOMNode;
56 import dwt.internal.mozilla.nsIDOMEvent; 69 import dwt.internal.mozilla.nsIDOMEvent;
57 import dwt.internal.mozilla.nsIDOMEventListener; 70 import dwt.internal.mozilla.nsIDOMEventListener;
58 import dwt.internal.mozilla.nsIDOMEventTarget; 71 import dwt.internal.mozilla.nsIDOMEventTarget;
59 import dwt.internal.mozilla.nsIDOMKeyEvent; 72 import dwt.internal.mozilla.nsIDOMKeyEvent;
60 import dwt.internal.mozilla.nsIDOMMouseEvent; 73 import dwt.internal.mozilla.nsIDOMMouseEvent;
61 import dwt.internal.mozilla.nsIDOMSerializer; 74 import dwt.internal.mozilla.nsIDOMSerializer;
62 import dwt.internal.mozilla.nsIDOMSerializer_1_7; 75 import dwt.internal.mozilla.nsIDOMSerializer_1_7;
63 import dwt.internal.mozilla.nsIDOMWindow; 76 import dwt.internal.mozilla.nsIDOMWindow;
64 import dwt.internal.mozilla.nsIDOMWindowCollection; 77 import dwt.internal.mozilla.nsIDOMWindowCollection;
78 import dwt.internal.mozilla.nsIDOMDocument;
65 import dwt.internal.mozilla.nsIDirectoryService; 79 import dwt.internal.mozilla.nsIDirectoryService;
66 import dwt.internal.mozilla.nsIDocShell; 80 import dwt.internal.mozilla.nsIDocShell;
67 //import dwt.internal.mozilla.nsIDocShell_1_8; 81 //import dwt.internal.mozilla.nsIDocShell_1_8;
68 //import dwt.internal.mozilla.nsIDocShell_1_9; 82 //import dwt.internal.mozilla.nsIDocShell_1_9;
69 import dwt.internal.mozilla.nsIEmbeddingSiteWindow; 83 import dwt.internal.mozilla.nsIEmbeddingSiteWindow;
70 import dwt.internal.mozilla.nsIFile; 84 import dwt.internal.mozilla.nsIFile;
85 import dwt.internal.mozilla.nsIFactory;
71 import dwt.internal.mozilla.nsIIOService; 86 import dwt.internal.mozilla.nsIIOService;
72 import dwt.internal.mozilla.nsIInterfaceRequestor; 87 import dwt.internal.mozilla.nsIInterfaceRequestor;
73 import dwt.internal.mozilla.nsIJSContextStack; 88 import dwt.internal.mozilla.nsIJSContextStack;
74 import dwt.internal.mozilla.nsILocalFile; 89 import dwt.internal.mozilla.nsILocalFile;
75 import dwt.internal.mozilla.nsIObserverService; 90 import dwt.internal.mozilla.nsIObserverService;
78 import dwt.internal.mozilla.nsIPrefService; 93 import dwt.internal.mozilla.nsIPrefService;
79 import dwt.internal.mozilla.nsIProperties; 94 import dwt.internal.mozilla.nsIProperties;
80 import dwt.internal.mozilla.nsIRequest; 95 import dwt.internal.mozilla.nsIRequest;
81 import dwt.internal.mozilla.nsIServiceManager; 96 import dwt.internal.mozilla.nsIServiceManager;
82 import dwt.internal.mozilla.nsISimpleEnumerator; 97 import dwt.internal.mozilla.nsISimpleEnumerator;
98 import dwt.internal.mozilla.nsIStreamListener;
83 import dwt.internal.mozilla.nsISupports; 99 import dwt.internal.mozilla.nsISupports;
84 //import dwt.internal.mozilla.nsISupportsWeakReference; 100 //import dwt.internal.mozilla.nsISupportsWeakReference;
85 import dwt.internal.mozilla.nsITooltipListener; 101 import dwt.internal.mozilla.nsITooltipListener;
86 import dwt.internal.mozilla.nsIURI; 102 import dwt.internal.mozilla.nsIURI;
87 import dwt.internal.mozilla.nsIURIContentListener; 103 import dwt.internal.mozilla.nsIURIContentListener;
93 import dwt.internal.mozilla.nsIWebNavigation; 109 import dwt.internal.mozilla.nsIWebNavigation;
94 import dwt.internal.mozilla.nsIWebNavigationInfo; 110 import dwt.internal.mozilla.nsIWebNavigationInfo;
95 import dwt.internal.mozilla.nsIWebProgress; 111 import dwt.internal.mozilla.nsIWebProgress;
96 import dwt.internal.mozilla.nsIWebProgressListener; 112 import dwt.internal.mozilla.nsIWebProgressListener;
97 import dwt.internal.mozilla.nsIWindowWatcher; 113 import dwt.internal.mozilla.nsIWindowWatcher;
114 import dwt.internal.mozilla.nsIWindowCreator;
115 import dwt.internal.mozilla.nsStringAPI;
116
98 import dwt.layout.FillLayout; 117 import dwt.layout.FillLayout;
99 import dwt.widgets.Composite; 118 import dwt.widgets.Composite;
100 import dwt.widgets.Display; 119 import dwt.widgets.Display;
101 import dwt.widgets.Event; 120 import dwt.widgets.Event;
102 import dwt.widgets.Label; 121 import dwt.widgets.Label;
103 import dwt.widgets.Listener; 122 import dwt.widgets.Listener;
104 import dwt.widgets.Menu; 123 import dwt.widgets.Menu;
105 import dwt.widgets.Shell; 124 import dwt.widgets.Shell;
106 import dwt.browser.WebBrowser; 125 import dwt.widgets.Control;
107 126
108 class Mozilla : WebBrowser, 127 class Mozilla : WebBrowser,
109 nsIWeakReference, 128 nsIWeakReference,
110 nsIWebProgressListener, 129 nsIWebProgressListener,
111 nsIWebBrowserChrome, 130 nsIWebBrowserChrome,
112 nsIWebBrowserFocus, 131 nsIWebBrowserChromeFocus,
113 nsIEmbeddingSiteWindow, 132 nsIEmbeddingSiteWindow,
114 nsIInterfaceRequestor, 133 nsIInterfaceRequestor,
115 nsISupportsWeakReference, 134 nsISupportsWeakReference,
116 nsIContextMenuListener, 135 nsIContextMenuListener,
117 nsIURIContentListener, 136 nsIURIContentListener,
219 rc = enumerator.HasMoreElements (&moreElements); 238 rc = enumerator.HasMoreElements (&moreElements);
220 if (rc !is XPCOM.NS_OK) error (rc); 239 if (rc !is XPCOM.NS_OK) error (rc);
221 while (moreElements !is 0) { 240 while (moreElements !is 0) {
222 //result[0] = 0; 241 //result[0] = 0;
223 nsICookie cookie; 242 nsICookie cookie;
224 rc = enumerator.GetNext (cast(nsISupports)cookie); 243 rc = enumerator.GetNext (cast(nsISupports*)&cookie);
225 if (rc !is XPCOM.NS_OK) error (rc); 244 if (rc !is XPCOM.NS_OK) error (rc);
226 //nsICookie cookie = new nsICookie (result[0]); 245 //nsICookie cookie = new nsICookie (result[0]);
227 PRUint64 expires; 246 PRUint64 expires;
228 rc = cookie.GetExpires (&expires); 247 rc = cookie.GetExpires (&expires);
229 if (expires is 0) { 248 if (expires is 0) {
266 */ 285 */
267 Initialized = true; 286 Initialized = true;
268 } 287 }
269 String mozillaPath = System.getProperty (XULRUNNER_PATH); 288 String mozillaPath = System.getProperty (XULRUNNER_PATH);
270 if (mozillaPath is null) { 289 if (mozillaPath is null) {
271 // we don't have to load an initial library in DWT, so set to "true" 290 // we don't need to load an initial library in DWT, so set to "true"
272 initLoaded = true; 291 initLoaded = true;
273 /+ 292 /+
274 if (mozillaPath is null) { 293 if (mozillaPath is null) {
275 try { 294 try {
276 String libName = mozDelegate.getSWTInitLibraryName (); 295 String libName = mozDelegate.getSWTInitLibraryName ();
289 IsXULRunner = true; 308 IsXULRunner = true;
290 } 309 }
291 310
292 if (initLoaded) { 311 if (initLoaded) {
293 /* attempt to discover a XULRunner to use as the GRE */ 312 /* attempt to discover a XULRunner to use as the GRE */
294 GREVersionRange range; 313 XPCOMInit.GREVersionRange range;
295 //byte[] bytes = MozillaDelegate.wcsToMbcs (null, GRERANGE_LOWER, true); 314 //byte[] bytes = MozillaDelegate.wcsToMbcs (null, GRERANGE_LOWER, true);
296 //int /*long*/ lower = C.malloc (bytes.length); 315 //int /*long*/ lower = C.malloc (bytes.length);
297 //C.memmove (lower, bytes, bytes.length); 316 //C.memmove (lower, bytes, bytes.length);
298 range.lower = GRERANGE_LOWER; 317 range.lower = GRERANGE_LOWER.ptr;
299 range.lowerInclusive = LowerRangeInclusive; 318 range.lowerInclusive = LowerRangeInclusive;
300 319
301 //bytes = MozillaDelegate.wcsToMbcs (null, GRERANGE_UPPER, true); 320 //bytes = MozillaDelegate.wcsToMbcs (null, GRERANGE_UPPER, true);
302 //int /*long*/ upper = C.malloc (bytes.length); 321 //int /*long*/ upper = C.malloc (bytes.length);
303 //C.memmove (upper, bytes, bytes.length); 322 //C.memmove (upper, bytes, bytes.length);
304 range.upper = GRERANGE_UPPER; 323 range.upper = GRERANGE_UPPER.ptr;
305 range.upperInclusive = UpperRangeInclusive; 324 range.upperInclusive = UpperRangeInclusive;
306 325
307 //int length = XPCOMInit.PATH_MAX; 326 //int length = XPCOMInit.PATH_MAX;
308 //int /*long*/ greBuffer = C.malloc (length); 327 //int /*long*/ greBuffer = C.malloc (length);
309 char[] greBuffer = new char[XPCOMInit.PATH_MAX]; 328 char[] greBuffer = new char[XPCOMInit.PATH_MAX];
317 if (rc !is XPCOM.NS_OK) { 336 if (rc !is XPCOM.NS_OK) {
318 //C.free (lower); 337 //C.free (lower);
319 //bytes = MozillaDelegate.wcsToMbcs (null, GRERANGE_LOWER_FALLBACK, true); 338 //bytes = MozillaDelegate.wcsToMbcs (null, GRERANGE_LOWER_FALLBACK, true);
320 //lower = C.malloc (bytes.length); 339 //lower = C.malloc (bytes.length);
321 //C.memmove (lower, bytes, bytes.length); 340 //C.memmove (lower, bytes, bytes.length);
322 range.lower = GRERANGE_LOWER_FALLBACK; 341 range.lower = GRERANGE_LOWER_FALLBACK.ptr;
323 rc = XPCOMInit.GRE_GetGREPathWithProperties (&range, 1, null, 0, greBuffer.ptr, greBuffer.length); 342 rc = XPCOMInit.GRE_GetGREPathWithProperties (&range, 1, null, 0, greBuffer.ptr, greBuffer.length);
324 } 343 }
325 344
326 //C.free (lower); 345 //C.free (lower);
327 //C.free (upper); 346 //C.free (upper);
346 if (IsXULRunner) { 365 if (IsXULRunner) {
347 // byte[] path = MozillaDelegate.wcsToMbcs (null, mozillaPath, true); 366 // byte[] path = MozillaDelegate.wcsToMbcs (null, mozillaPath, true);
348 rc = XPCOMInit.XPCOMGlueStartup (mozillaPath.ptr); 367 rc = XPCOMInit.XPCOMGlueStartup (mozillaPath.ptr);
349 if (rc !is XPCOM.NS_OK) { 368 if (rc !is XPCOM.NS_OK) {
350 IsXULRunner = false; /* failed */ 369 IsXULRunner = false; /* failed */
351 mozillaPath = mozillaPath[0 .. locatePrior( mozillaPath, SEPARATOR_OS )]; 370 //mozillaPath = mozillaPath[0 .. locatePrior( mozillaPath, SEPARATOR_OS )];
352 //mozillaPath = mozillaPath.substring (0, mozillaPath.lastIndexOf (SEPARATOR_OS)); 371 mozillaPath = mozillaPath.substring (0, mozillaPath.lastIndexOf (SEPARATOR_OS));
353 if (Device.DEBUG) Stdout ("cannot use detected XULRunner: ") (mozillaPath).newline; //$NON-NLS-1$ 372 if (Device.DEBUG) Cerr ("cannot use detected XULRunner: ") (mozillaPath).newline; //$NON-NLS-1$
354 } else { 373 } else {
355 XPCOMInitWasGlued = true; 374 XPCOMInitWasGlued = true;
356 } 375 }
357 } 376 }
358 } 377 }
359 //C.free (greBuffer); 378 //C.free (greBuffer);
360 } 379 }
361 380
362 if (IsXULRunner) { 381 if (IsXULRunner) {
363 if (Device.DEBUG) Stdout ("XULRunner path: ") (mozillaPath).newline; //$NON-NLS-1$ 382 if (Device.DEBUG) Cerr ("XULRunner path: ") (mozillaPath).newline; //$NON-NLS-1$
364 /+ 383 /+
365 try { 384 try {
366 Library.loadLibrary ("swt-xulrunner"); //$NON-NLS-1$ 385 Library.loadLibrary ("swt-xulrunner"); //$NON-NLS-1$
367 } catch (UnsatisfiedLinkError e) { 386 } catch (UnsatisfiedLinkError e) {
368 DWT.error (DWT.ERROR_NO_HANDLES, e); 387 DWT.error (DWT.ERROR_NO_HANDLES, e);
373 392
374 if (rc !is XPCOM.NS_OK) { 393 if (rc !is XPCOM.NS_OK) {
375 browser.dispose (); 394 browser.dispose ();
376 error (rc); 395 error (rc);
377 } 396 }
378 +/ // No need for double layer initialization in DWT; glue is initialized -JJR 397 +/ // No need for double layer initialization in DWT; XPCOMInit was glued
398 // At this stage we know that XULRunner is available, but we don't know
399 // TODO: determine if
379 XPCOMWasGlued = true; 400 XPCOMWasGlued = true;
380 401
381 /* 402 /*
382 * Remove the trailing xpcom lib name from mozillaPath because the 403 * Remove the trailing xpcom lib name from mozillaPath because the
383 * Mozilla.initialize and NS_InitXPCOM2 invocations require a directory name only. 404 * Mozilla.initialize and NS_InitXPCOM2 invocations require a directory name only.
384 */ 405 */
385 mozillaPath = mozillaPath[0 .. locatePrior( mozillaPath, SEPARATOR_OS )]; 406 mozillaPath = mozillaPath.substring (0, mozillaPath.lastIndexOf (SEPARATOR_OS));
386 //mozillaPath = mozillaPath.substring (0, mozillaPath.lastIndexOf (SEPARATOR_OS));
387 } else { 407 } else {
388 if ((style & DWT.MOZILLA) !is 0) { 408 if ((style & DWT.MOZILLA) !is 0) {
389 browser.dispose (); 409 browser.dispose ();
390 String errorString = (mozillaPath !is null && mozillaPath.length > 0) ? 410 String errorString = (mozillaPath !is null && mozillaPath.length > 0) ?
391 " [Failed to use detected XULRunner: " ~ mozillaPath ~ "]" : 411 " [Failed to use detected XULRunner: " ~ mozillaPath ~ "]" :
392 " [Could not detect registered XULRunner to use]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 412 " [Could not detect registered XULRunner to use]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
393 DWT.error (DWT.ERROR_NO_HANDLES, null, errorString); 413 DWT.error (DWT.ERROR_NO_HANDLES, null, errorString);
394 } 414 }
395 415
396 /* attempt to use the GRE pointed at by MOZILLA_FIVE_HOME */ 416 /* attempt to use the GRE pointed at by MOZILLA_FIVE_HOME */
397 auto mozFiveHome = tango.sys.Environment.get(XPCOM.MOZILLA_FIVE_HOME); 417 auto mozFiveHome = Environment.get(XPCOM.MOZILLA_FIVE_HOME);
398 if (mozFiveHome !is null) { 418 if (mozFiveHome !is null) {
399 //int length = C.strlen (ptr); 419 //int length = C.strlen (ptr);
400 //byte[] buffer = new byte[length]; 420 //byte[] buffer = new byte[length];
401 //C.memmove (buffer, ptr, length); 421 //C.memmove (buffer, ptr, length);
402 mozillaPath = mozFiveHome; 422 mozillaPath = mozFiveHome;
403 } else { 423 } else {
404 browser.dispose (); 424 browser.dispose ();
405 DWT.error (DWT.ERROR_NO_HANDLES, null, " [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)]"); //$NON-NLS-1$ 425 DWT.error (DWT.ERROR_NO_HANDLES, null, " [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)]"); //$NON-NLS-1$
406 } 426 }
407 if (Device.DEBUG) Stdout ("Mozilla path: ") (mozillaPath).newline; //$NON-NLS-1$ 427 if (Device.DEBUG) Cerr ("Mozilla path: ") (mozillaPath).newline; //$NON-NLS-1$
408 428
409 /* 429 /*
410 * Note. Embedding a Mozilla GTK1.2 causes a crash. The workaround 430 * Note. Embedding a Mozilla GTK1.2 causes a crash. The workaround
411 * is to check the version of GTK used by Mozilla by looking for 431 * is to check the version of GTK used by Mozilla by looking for
412 * the libwidget_gtk.so library used by Mozilla GTK1.2. Mozilla GTK2 432 * the libwidget_gtk.so library used by Mozilla GTK1.2. Mozilla GTK2
438 } 458 }
439 +/ 459 +/
440 } 460 }
441 461
442 if (!Initialized) { 462 if (!Initialized) {
443 nsILocalFile file; 463 nsILocalFile localFile;
444 scope auto pathString = new nsEmbedString (mozillaPath); 464 scope auto pathString = new nsEmbedString (mozillaPath.toString16());
445 nsresult rc = XPCOM.NS_NewLocalFile (cast(nsAString*)pathString, 1, &localFile); 465 nsresult rc = XPCOM.NS_NewLocalFile (cast(nsAString*)pathString, 1, &localFile);
446 //pathString.dispose (); 466 //pathString.dispose ();
447 if (rc !is XPCOM.NS_OK) { 467 if (rc !is XPCOM.NS_OK) {
448 browser.dispose (); 468 browser.dispose ();
449 error (rc); 469 error (rc);
461 rc = LocationProvider.QueryInterface( &nsIDirectoryServiceProvider.IID, cast(void**)&directoryServiceProvider); 481 rc = LocationProvider.QueryInterface( &nsIDirectoryServiceProvider.IID, cast(void**)&directoryServiceProvider);
462 if (rc !is XPCOM.NS_OK) { 482 if (rc !is XPCOM.NS_OK) {
463 browser.dispose(); 483 browser.dispose();
464 error(rc); 484 error(rc);
465 } 485 }
466 rc = XPCOM.NS_InitXPCOM2 (null, cast(IFile*)&localFile, &directoryServiceProvider); 486 rc = XPCOM.NS_InitXPCOM2 (null, cast(nsIFile)localFile, directoryServiceProvider);
467 localFile.Release (); 487 localFile.Release ();
468 LocationProvider.Release(); 488 LocationProvider.Release();
469 if (rc !is XPCOM.NS_OK) { 489 if (rc !is XPCOM.NS_OK) {
470 browser.dispose (); 490 browser.dispose ();
471 DWT.error (DWT.ERROR_NO_HANDLES, null, Format(" [MOZILLA_FIVE_HOME may not point at an embeddable GRE] [NS_InitEmbedding {0} error {1} ] ", mozillaPath, rc ) ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 491 DWT.error (DWT.ERROR_NO_HANDLES, null, Format(" [MOZILLA_FIVE_HOME may not point at an embeddable GRE] [NS_InitEmbedding {0} error {1} ] ", mozillaPath, rc ) ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
517 537
518 //nsIComponentManager componentManager = new nsIComponentManager (result[0]); 538 //nsIComponentManager componentManager = new nsIComponentManager (result[0]);
519 //result[0] = 0; 539 //result[0] = 0;
520 if (mozDelegate.needsSpinup ()) { 540 if (mozDelegate.needsSpinup ()) {
521 /* nsIAppShell is discontinued as of xulrunner 1.9, so do not fail if it is not found */ 541 /* nsIAppShell is discontinued as of xulrunner 1.9, so do not fail if it is not found */
522 rc = componentManager.CreateInstance (XPCOM.NS_APPSHELL_CID.ptr, 0, &nsIAppShell.IID, cast(void**)&AppShell); 542 rc = componentManager.CreateInstance (&XPCOM.NS_APPSHELL_CID, null, &nsIAppShell.IID, cast(void**)&AppShell);
523 if (rc !is XPCOM.NS_ERROR_NO_INTERFACE) { 543 if (rc !is XPCOM.NS_ERROR_NO_INTERFACE) {
524 if (rc !is XPCOM.NS_OK) { 544 if (rc !is XPCOM.NS_OK) {
525 browser.dispose (); 545 browser.dispose ();
526 error (rc); 546 error (rc);
527 } 547 }
529 browser.dispose (); 549 browser.dispose ();
530 error (XPCOM.NS_NOINTERFACE); 550 error (XPCOM.NS_NOINTERFACE);
531 } 551 }
532 552
533 //AppShell = new nsIAppShell (result[0]); 553 //AppShell = new nsIAppShell (result[0]);
534 rc = AppShell.Create (0, null); 554 rc = AppShell.Create (null, null);
535 if (rc !is XPCOM.NS_OK) { 555 if (rc !is XPCOM.NS_OK) {
536 browser.dispose (); 556 browser.dispose ();
537 error (rc); 557 error (rc);
538 } 558 }
539 rc = AppShell.Spinup (); 559 rc = AppShell.Spinup ();
573 error (XPCOM.NS_NOINTERFACE); 593 error (XPCOM.NS_NOINTERFACE);
574 } 594 }
575 595
576 //nsIWindowWatcher windowWatcher = new nsIWindowWatcher (result[0]); 596 //nsIWindowWatcher windowWatcher = new nsIWindowWatcher (result[0]);
577 //result[0] = 0; 597 //result[0] = 0;
578 rc = windowWatcher.SetWindowCreator (&WindowCreator); 598 rc = windowWatcher.SetWindowCreator (cast(nsIWindowCreator)WindowCreator);
579 if (rc !is XPCOM.NS_OK) { 599 if (rc !is XPCOM.NS_OK) {
580 browser.dispose (); 600 browser.dispose ();
581 error (rc); 601 error (rc);
582 } 602 }
583 windowWatcher.Release (); 603 windowWatcher.Release ();
660 //result[0] = 0; 680 //result[0] = 0;
661 //buffer = MozillaDelegate.wcsToMbcs (null, PROFILE_DO_CHANGE, true); 681 //buffer = MozillaDelegate.wcsToMbcs (null, PROFILE_DO_CHANGE, true);
662 //length = STARTUP.length (); 682 //length = STARTUP.length ();
663 //char[] chars = new char [length + 1]; 683 //char[] chars = new char [length + 1];
664 //STARTUP.getChars (0, length, chars, 0); 684 //STARTUP.getChars (0, length, chars, 0);
665 wchar[] chars = Utf.toString16(STARTUP).toString16z; 685 wchar* chars = STARTUP.toString16().toString16z();
666 rc = observerService.NotifyObservers (null, PROFILE_DO_CHANGE.ptr, chars); 686 rc = observerService.NotifyObservers (null, PROFILE_DO_CHANGE.ptr, chars);
667 if (rc !is XPCOM.NS_OK) { 687 if (rc !is XPCOM.NS_OK) {
668 browser.dispose (); 688 browser.dispose ();
669 error (rc); 689 error (rc);
670 } 690 }
671 //buffer = MozillaDelegate.wcsToMbcs (null, PROFILE_AFTER_CHANGE, true); 691 //buffer = MozillaDelegate.wcsToMbcs (null, PROFILE_AFTER_CHANGE, true);
672 rc = observerService.NotifyObservers (null, PROFILE_AFTER_CHANGE.ptr, chars.ptr); 692 rc = observerService.NotifyObservers (null, PROFILE_AFTER_CHANGE.ptr, chars);
673 if (rc !is XPCOM.NS_OK) { 693 if (rc !is XPCOM.NS_OK) {
674 browser.dispose (); 694 browser.dispose ();
675 error (rc); 695 error (rc);
676 } 696 }
677 observerService.Release (); 697 observerService.Release ();
682 * and charset. The fix for this is to set mozilla's locale and charset 702 * and charset. The fix for this is to set mozilla's locale and charset
683 * preference values according to the user's current locale and charset. 703 * preference values according to the user's current locale and charset.
684 */ 704 */
685 //aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_PREFSERVICE_CONTRACTID, true); 705 //aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_PREFSERVICE_CONTRACTID, true);
686 nsIPrefService prefService; 706 nsIPrefService prefService;
687 rc = serviceManager.GetServiceByContractID (XPCOM.NS_PREFSERVICE_CONTRACTID, &nsIPrefService.IID, cast(void**)&prefService); 707 rc = serviceManager.GetServiceByContractID (XPCOM.NS_PREFSERVICE_CONTRACTID.ptr, &nsIPrefService.IID, cast(void**)&prefService);
688 serviceManager.Release (); 708 serviceManager.Release ();
689 if (rc !is XPCOM.NS_OK) { 709 if (rc !is XPCOM.NS_OK) {
690 browser.dispose (); 710 browser.dispose ();
691 error (rc); 711 error (rc);
692 } 712 }
792 //int span = newLocales.length (); 812 //int span = newLocales.length ();
793 //char[] charBuffer = new char[span + 1]; 813 //char[] charBuffer = new char[span + 1];
794 //newLocales.getChars (0, span, charBuffer, 0); 814 //newLocales.getChars (0, span, charBuffer, 0);
795 if (localizedString is null) { 815 if (localizedString is null) {
796 //byte[] contractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_PREFLOCALIZEDSTRING_CONTRACTID, true); 816 //byte[] contractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_PREFLOCALIZEDSTRING_CONTRACTID, true);
797 rc = componentManager.CreateInstanceByContractID (XPCOM.NS_PREFLOCALIZEDSTRING, null, &nsIPrefLocalizedString.IID, cast(void**)&localizedString); 817 rc = componentManager.CreateInstanceByContractID (XPCOM.NS_PREFLOCALIZEDSTRING_CONTRACTID.ptr, null, &nsIPrefLocalizedString.IID, cast(void**)&localizedString);
798 if (rc !is XPCOM.NS_OK) { 818 if (rc !is XPCOM.NS_OK) {
799 browser.dispose (); 819 browser.dispose ();
800 error (rc); 820 error (rc);
801 } 821 }
802 if (localizedString is null) { 822 if (localizedString is null) {
804 error (XPCOM.NS_NOINTERFACE); 824 error (XPCOM.NS_NOINTERFACE);
805 } 825 }
806 //localizedString = new nsIPrefLocalizedString (result[0]); 826 //localizedString = new nsIPrefLocalizedString (result[0]);
807 //result[0] = 0; 827 //result[0] = 0;
808 } 828 }
809 localizedString.SetDataWithLength (newLocales.length, Utf.toString16(newLocales).toString16z); 829 localizedString.SetDataWithLength (newLocales.length, newLocales.toString16().toString16z());
810 rc = prefBranch.SetComplexValue (PREFERENCES_LANGUAGES.ptr, nsIPrefLocalizedString.IID, cast(nsISupports)localizedString); 830 rc = prefBranch.SetComplexValue (PREFERENCE_LANGUAGES.ptr, &nsIPrefLocalizedString.IID, cast(nsISupports)localizedString);
811 } 831 }
812 if (localizedString !is null) { 832 if (localizedString !is null) {
813 localizedString.Release (); 833 localizedString.Release ();
814 localizedString = null; 834 localizedString = null;
815 } 835 }
816 836
817 /* get Mozilla's current charset preference value */ 837 /* get Mozilla's current charset preference value */
818 String prefCharset = null; 838 String prefCharset = null;
819 //buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_CHARSET, true); 839 //buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_CHARSET, true);
820 rc = prefBranch.GetComplexValue (PREFERENCE_CHARSET.ptr, nsIPrefLocalizedString.IID, cast(void**)&localizedString); 840 rc = prefBranch.GetComplexValue (PREFERENCE_CHARSET.ptr, &nsIPrefLocalizedString.IID, cast(void**)&localizedString);
821 /* 841 /*
822 * Feature of Debian. For some reason attempting to query for the current charset 842 * Feature of Debian. For some reason attempting to query for the current charset
823 * preference fails on Debian. The workaround for this is to assume a value of 843 * preference fails on Debian. The workaround for this is to assume a value of
824 * "ISO-8859-1" since this is typically the default value when mozilla is used 844 * "ISO-8859-1" since this is typically the default value when mozilla is used
825 * without a profile. 845 * without a profile.
856 //int length = newCharset.length (); 876 //int length = newCharset.length ();
857 //char[] charBuffer = new char[length + 1]; 877 //char[] charBuffer = new char[length + 1];
858 //newCharset.getChars (0, length, charBuffer, 0); 878 //newCharset.getChars (0, length, charBuffer, 0);
859 if (localizedString is null) { 879 if (localizedString is null) {
860 //byte[] contractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_PREFLOCALIZEDSTRING_CONTRACTID, true); 880 //byte[] contractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_PREFLOCALIZEDSTRING_CONTRACTID, true);
861 rc = componentManager.CreateInstanceByContractID (XPCOM.NS_PREFLOCALIZEDSTRING_CONTRACTID, null, &nsIPrefLocalizedString.IID, cast(void**)&localizedString); 881 rc = componentManager.CreateInstanceByContractID (XPCOM.NS_PREFLOCALIZEDSTRING_CONTRACTID.ptr, null, &nsIPrefLocalizedString.IID, cast(void**)&localizedString);
862 if (rc !is XPCOM.NS_OK) { 882 if (rc !is XPCOM.NS_OK) {
863 browser.dispose (); 883 browser.dispose ();
864 error (rc); 884 error (rc);
865 } 885 }
866 if (localizedString is null) { 886 if (localizedString is null) {
868 error (XPCOM.NS_NOINTERFACE); 888 error (XPCOM.NS_NOINTERFACE);
869 } 889 }
870 //localizedString = new nsIPrefLocalizedString (result[0]); 890 //localizedString = new nsIPrefLocalizedString (result[0]);
871 //result[0] = 0; 891 //result[0] = 0;
872 } 892 }
873 localizedString.SetDataWithLength (newCharset.length, Utf.toString16(newCharset).toString16z); 893 localizedString.SetDataWithLength (newCharset.length, newCharset.toString16().toString16z());
874 rc = prefBranch.SetComplexValue (PREFERENCE_CHARSET.ptr, &nsIPrefLocalizedString.IID, cast(nsISupports)localizedString); 894 rc = prefBranch.SetComplexValue (PREFERENCE_CHARSET.ptr, &nsIPrefLocalizedString.IID, cast(nsISupports)localizedString);
875 } 895 }
876 if (localizedString !is null) localizedString.Release (); 896 if (localizedString !is null) localizedString.Release ();
877 897
878 /* 898 /*
892 } 912 }
893 } 913 }
894 914
895 if (proxyHost !is null) { 915 if (proxyHost !is null) {
896 //byte[] contractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_PREFLOCALIZEDSTRING_CONTRACTID, true); 916 //byte[] contractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_PREFLOCALIZEDSTRING_CONTRACTID, true);
897 rc = componentManager.CreateInstanceByContractID (XPCOM.NS_PREFLOCALIZEDSTRING_CONTRACTID, null, &nsIPrefLocalizedString.IID, cast(void**)&localizedString); 917 rc = componentManager.CreateInstanceByContractID (XPCOM.NS_PREFLOCALIZEDSTRING_CONTRACTID.ptr, null, &nsIPrefLocalizedString.IID, cast(void**)&localizedString);
898 if (rc !is XPCOM.NS_OK) error (rc); 918 if (rc !is XPCOM.NS_OK) error (rc);
899 if (localizedString is null) error (XPCOM.NS_NOINTERFACE); 919 if (localizedString is null) error (XPCOM.NS_NOINTERFACE);
900 920
901 //localizedString = new nsIPrefLocalizedString (result[0]); 921 //localizedString = new nsIPrefLocalizedString (result[0]);
902 //result[0] = 0; 922 //result[0] = 0;
903 //int length = proxyHost.length (); 923 //int length = proxyHost.length ();
904 //char[] charBuffer = new char[length + 1]; 924 //char[] charBuffer = new char[length + 1];
905 //proxyHost.getChars (0, length, charBuffer, 0); 925 //proxyHost.getChars (0, length, charBuffer, 0);
906 rc = localizedString.SetDataWithLength (proxyHost.length, Utf.toString16(proxyHost).toString16z); 926 rc = localizedString.SetDataWithLength (proxyHost.length, proxyHost.toString16().toString16z());
907 if (rc !is XPCOM.NS_OK) error (rc); 927 if (rc !is XPCOM.NS_OK) error (rc);
908 //buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_PROXYHOST_FTP, true); 928 //buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_PROXYHOST_FTP, true);
909 rc = prefBranch.SetComplexValue (PREFERENCE_PROXYHOST_FTP.ptr, &nsIPrefLocalizedString.IID, cast(nsISupports)localizedString); 929 rc = prefBranch.SetComplexValue (PREFERENCE_PROXYHOST_FTP.ptr, &nsIPrefLocalizedString.IID, cast(nsISupports)localizedString);
910 if (rc !is XPCOM.NS_OK) error (rc); 930 if (rc !is XPCOM.NS_OK) error (rc);
911 //buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_PROXYHOST_HTTP, true); 931 //buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_PROXYHOST_HTTP, true);
977 //result[0] = 0; 997 //result[0] = 0;
978 //aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_PROMPTSERVICE_CONTRACTID, true); 998 //aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_PROMPTSERVICE_CONTRACTID, true);
979 String aClassName = "Prompt Service"; 999 String aClassName = "Prompt Service";
980 //byte[] aClassName = MozillaDelegate.wcsToMbcs (null, "Prompt Service", true); //$NON-NLS-1$ 1000 //byte[] aClassName = MozillaDelegate.wcsToMbcs (null, "Prompt Service", true); //$NON-NLS-1$
981 1001
982 rc = componentRegistrar.RegisterFactory (XPCOM.NS_PROMPTSERVICE_CID, aClassName.ptr, XPCOM.NS_PROMPTSERVICE_CONTRACTID, cast(nsIFactory)factory); 1002 rc = componentRegistrar.RegisterFactory (&XPCOM.NS_PROMPTSERVICE_CID, aClassName.ptr, XPCOM.NS_PROMPTSERVICE_CONTRACTID.ptr, cast(nsIFactory)factory);
983 1003
984 if (rc !is XPCOM.NS_OK) { 1004 if (rc !is XPCOM.NS_OK) {
985 browser.dispose (); 1005 browser.dispose ();
986 error (rc); 1006 error (rc);
987 } 1007 }
990 HelperAppLauncherDialogFactory dialogFactory = new HelperAppLauncherDialogFactory (); 1010 HelperAppLauncherDialogFactory dialogFactory = new HelperAppLauncherDialogFactory ();
991 dialogFactory.AddRef (); 1011 dialogFactory.AddRef ();
992 //aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_HELPERAPPLAUNCHERDIALOG_CONTRACTID, true); 1012 //aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_HELPERAPPLAUNCHERDIALOG_CONTRACTID, true);
993 aClassName = "Helper App Launcher Dialog"; 1013 aClassName = "Helper App Launcher Dialog";
994 //aClassName = MozillaDelegate.wcsToMbcs (null, "Helper App Launcher Dialog", true); //$NON-NLS-1$ 1014 //aClassName = MozillaDelegate.wcsToMbcs (null, "Helper App Launcher Dialog", true); //$NON-NLS-1$
995 rc = componentRegistrar.RegisterFactory (XPCOM.NS_HELPERAPPLAUNCHERDIALOG_CID, aClassName.ptr, XPCOM.NS_HELPERAPPLAUNCHERDIALOG_CONTRACTID, cast(nsIFactory)dialogFactory); 1015 rc = componentRegistrar.RegisterFactory (&XPCOM.NS_HELPERAPPLAUNCHERDIALOG_CID, aClassName.ptr, XPCOM.NS_HELPERAPPLAUNCHERDIALOG_CONTRACTID.ptr, cast(nsIFactory)dialogFactory);
996 if (rc !is XPCOM.NS_OK) { 1016 if (rc !is XPCOM.NS_OK) {
997 browser.dispose (); 1017 browser.dispose ();
998 error (rc); 1018 error (rc);
999 } 1019 }
1000 dialogFactory.Release (); 1020 dialogFactory.Release ();
1009 DownloadFactory downloadFactory = new DownloadFactory (); 1029 DownloadFactory downloadFactory = new DownloadFactory ();
1010 downloadFactory.AddRef (); 1030 downloadFactory.AddRef ();
1011 //aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_DOWNLOAD_CONTRACTID, true); 1031 //aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_DOWNLOAD_CONTRACTID, true);
1012 aClassName = "Download"; 1032 aClassName = "Download";
1013 //aClassName = MozillaDelegate.wcsToMbcs (null, "Download", true); //$NON-NLS-1$ 1033 //aClassName = MozillaDelegate.wcsToMbcs (null, "Download", true); //$NON-NLS-1$
1014 rc = componentRegistrar.RegisterFactory (XPCOM.NS_DOWNLOAD_CID, aClassName.ptr, XPCOM.NS_DOWNLOAD_CONTRACTID, cast(nsIFactory)downloadFactory); 1034 rc = componentRegistrar.RegisterFactory (&XPCOM.NS_DOWNLOAD_CID, aClassName.ptr, XPCOM.NS_DOWNLOAD_CONTRACTID.ptr, cast(nsIFactory)downloadFactory);
1015 if (rc !is XPCOM.NS_OK) { 1035 if (rc !is XPCOM.NS_OK) {
1016 browser.dispose (); 1036 browser.dispose ();
1017 error (rc); 1037 error (rc);
1018 } 1038 }
1019 downloadFactory.Release (); 1039 downloadFactory.Release ();
1021 FilePickerFactory pickerFactory = IsXULRunner ? new FilePickerFactory_1_8 () : new FilePickerFactory (); 1041 FilePickerFactory pickerFactory = IsXULRunner ? new FilePickerFactory_1_8 () : new FilePickerFactory ();
1022 pickerFactory.AddRef (); 1042 pickerFactory.AddRef ();
1023 //aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_FILEPICKER_CONTRACTID, true); 1043 //aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_FILEPICKER_CONTRACTID, true);
1024 aClassName = "FilePicker"; 1044 aClassName = "FilePicker";
1025 //aClassName = MozillaDelegate.wcsToMbcs (null, "FilePicker", true); //$NON-NLS-1$ 1045 //aClassName = MozillaDelegate.wcsToMbcs (null, "FilePicker", true); //$NON-NLS-1$
1026 rc = componentRegistrar.RegisterFactory (XPCOM.NS_FILEPICKER_CID, aClassName.ptr, XPCOM.NS_FILEPICKER_CONTRACTID, cast(nsIFactory)pickerFactory); 1046 rc = componentRegistrar.RegisterFactory (&XPCOM.NS_FILEPICKER_CID, aClassName.ptr, XPCOM.NS_FILEPICKER_CONTRACTID.ptr, cast(nsIFactory)pickerFactory);
1027 if (rc !is XPCOM.NS_OK) { 1047 if (rc !is XPCOM.NS_OK) {
1028 browser.dispose (); 1048 browser.dispose ();
1029 error (rc); 1049 error (rc);
1030 } 1050 }
1031 pickerFactory.Release (); 1051 pickerFactory.Release ();
1035 1055
1036 Initialized = true; 1056 Initialized = true;
1037 } 1057 }
1038 1058
1039 if (display.getData (DISPOSE_LISTENER_HOOKED) is null) { 1059 if (display.getData (DISPOSE_LISTENER_HOOKED) is null) {
1040 display.setData (DISPOSE_LISTENER_HOOKED, DISPOSE_LISTENER_HOOKED); 1060 display.setData (DISPOSE_LISTENER_HOOKED, stringcast(DISPOSE_LISTENER_HOOKED));
1041 display.addListener (DWT.Dispose, new class() Listener { 1061 display.addListener (DWT.Dispose, new class() Listener {
1042 public void handleEvent (Event event) { 1062 public void handleEvent (Event event) {
1043 if (BrowserCount > 0) return; /* another display is still active */ 1063 if (BrowserCount > 0) return; /* another display is still active */
1044 1064
1045 nsIServiceManager serviceManager; 1065 nsIServiceManager serviceManager;
1046 //int /*long*/[] result = new int /*long*/[1]; 1066 //int /*long*/[] result = new int /*long*/[1];
1047 int rc = XPCOM.NS_GetServiceManager (&serviceManager); 1067 int rc = XPCOM.NS_GetServiceManager (&serviceManager);
1048 if (rc !is XPCOM.NS_OK) error (rc); 1068 if (rc !is XPCOM.NS_OK) error (rc);
1049 if (serviceManager is null) error (XPCOM.NS_NOINTERFACE); 1069 if (serviceManager is null) error (XPCOM.NS_NOINTERFACE);
1050 1070
1051 //nsIServiceManager serviceManager = new nsIServiceManager (result[0]); 1071 //nsIServiceManager serviceManager = new nsIServiceManager (result[0]);
1052 //result[0] = 0; 1072 //result[0] = 0;
1053 //byte[] buffer = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_OBSERVER_CONTRACTID, true); 1073 //byte[] buffer = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_OBSERVER_CONTRACTID, true);
1054 nsIObserverService observerService; 1074 nsIObserverService observerService;
1055 rc = serviceManager.GetServiceByContractID (XPCOM.NS_OBSERVER_CONTRACTID, &nsIObserverService.IID, cast(void**)&observerService); 1075 rc = serviceManager.GetServiceByContractID (XPCOM.NS_OBSERVER_CONTRACTID.ptr, &nsIObserverService.IID, cast(void**)&observerService);
1056 if (rc !is XPCOM.NS_OK) error (rc); 1076 if (rc !is XPCOM.NS_OK) error (rc);
1057 if (observerService is null) error (XPCOM.NS_NOINTERFACE); 1077 if (observerService is null) error (XPCOM.NS_NOINTERFACE);
1058 1078
1059 //nsIObserverService observerService = new nsIObserverService (result[0]); 1079 //nsIObserverService observerService = new nsIObserverService (result[0]);
1060 //result[0] = 0; 1080 //result[0] = 0;
1061 //buffer = MozillaDelegate.wcsToMbcs (null, PROFILE_BEFORE_CHANGE, true); 1081 //buffer = MozillaDelegate.wcsToMbcs (null, PROFILE_BEFORE_CHANGE, true);
1062 //int length = SHUTDOWN_PERSIST.length (); 1082 //int length = SHUTDOWN_PERSIST.length ();
1063 //char[] chars = new char [length + 1]; 1083 //char[] chars = new char [length + 1];
1064 //SHUTDOWN_PERSIST.getChars (0, length, chars, 0); 1084 //SHUTDOWN_PERSIST.getChars (0, length, chars, 0);
1065 rc = observerService.NotifyObservers (null, PROFILE_BEFORE_CHANGE.ptr, Utf.toString16(SHUTDOWN_PERSIST).toString16z); 1085 rc = observerService.NotifyObservers (null, PROFILE_BEFORE_CHANGE.ptr, SHUTDOWN_PERSIST.toString16().toString16z());
1066 if (rc !is XPCOM.NS_OK) error (rc); 1086 if (rc !is XPCOM.NS_OK) error (rc);
1067 observerService.Release (); 1087 observerService.Release ();
1068 1088
1069 if (LocationProvider !is null) { 1089 if (LocationProvider !is null) {
1070 String prefsLocation = LocationProvider.profilePath ~ AppFileLocProvider.PREFERENCES_FILE; 1090 String prefsLocation = LocationProvider.profilePath ~ AppFileLocProvider.PREFERENCES_FILE;
1071 scope auto pathString = new nsEmbedString (prefsLocation); 1091 scope auto pathString = new nsEmbedString (prefsLocation.toString16());
1072 nsILocalFile localFile; 1092 nsILocalFile localFile;
1073 rc = XPCOM.NS_NewLocalFile (cast(nsAString*)pathString, 1, &localFile); 1093 rc = XPCOM.NS_NewLocalFile (cast(nsAString*)pathString, 1, &localFile);
1074 if (rc !is XPCOM.NS_OK) Mozilla.error (rc); 1094 if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
1075 if (localFile is null) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER); 1095 if (localFile is null) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER);
1076 //pathString.dispose (); 1096 //pathString.dispose ();
1077 1097
1078 //nsILocalFile localFile = new nsILocalFile (result [0]); 1098 //nsILocalFile localFile = new nsILocalFile (result [0]);
1079 //result[0] = 0; 1099 //result[0] = 0;
1080 nsIFile prefFile; 1100 nsIFile prefFile;
1081 rc = localFile.QueryInterface (&nsIFile.IID, &prefFile); 1101 rc = localFile.QueryInterface (&nsIFile.IID, cast(void**)&prefFile);
1082 if (rc !is XPCOM.NS_OK) Mozilla.error (rc); 1102 if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
1083 if (prefFile is null) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE); 1103 if (prefFile is null) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE);
1084 localFile.Release (); 1104 localFile.Release ();
1085 1105
1086 //nsIFile prefFile = new nsIFile (result[0]); 1106 //nsIFile prefFile = new nsIFile (result[0]);
1087 //result[0] = 0; 1107 //result[0] = 0;
1088 nsIPrefService prefService; 1108 nsIPrefService prefService;
1089 //buffer = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_PREFSERVICE_CONTRACTID, true); 1109 //buffer = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_PREFSERVICE_CONTRACTID, true);
1090 rc = serviceManager.GetServiceByContractID (XPCOM.NS_PREFSERVICE_CONTRACTID, &nsIPrefService.IID, &prefService); 1110 rc = serviceManager.GetServiceByContractID (XPCOM.NS_PREFSERVICE_CONTRACTID.ptr, &nsIPrefService.IID, cast(void**)&prefService);
1091 if (rc !is XPCOM.NS_OK) error (rc); 1111 if (rc !is XPCOM.NS_OK) error (rc);
1092 if (prefService is null) error (XPCOM.NS_NOINTERFACE); 1112 if (prefService is null) error (XPCOM.NS_NOINTERFACE);
1093 1113
1094 //nsIPrefService prefService = new nsIPrefService (result[0]); 1114 //nsIPrefService prefService = new nsIPrefService (result[0]);
1095 //result[0] = 0; 1115 //result[0] = 0;
1098 prefFile.Release (); 1118 prefFile.Release ();
1099 } 1119 }
1100 serviceManager.Release (); 1120 serviceManager.Release ();
1101 1121
1102 if (XPCOMWasGlued) { 1122 if (XPCOMWasGlued) {
1103 XPCOM.XPCOMGlueShutdown (); 1123 // TODO: is there a difference between two startup methhods? Glue functions are same.
1124 XPCOMInit.XPCOMGlueShutdown ();
1104 XPCOMWasGlued = false; 1125 XPCOMWasGlued = false;
1105 } 1126 }
1106 if (XPCOMInitWasGlued) { 1127 if (XPCOMInitWasGlued) {
1107 XPCOMInit.XPCOMGlueShutdown (); 1128 XPCOMInit.XPCOMGlueShutdown ();
1108 XPCOMInitWasGlued = false; 1129 XPCOMInitWasGlued = false;
1160 browser.dispose (); 1181 browser.dispose ();
1161 error (rc); 1182 error (rc);
1162 } 1183 }
1163 1184
1164 nsIBaseWindow baseWindow; 1185 nsIBaseWindow baseWindow;
1165 rc = webBrowser.QueryInterface (nsIBaseWindow.IID, cast(void**)&baseWindow); 1186 rc = webBrowser.QueryInterface (&nsIBaseWindow.IID, cast(void**)&baseWindow);
1166 if (rc !is XPCOM.NS_OK) { 1187 if (rc !is XPCOM.NS_OK) {
1167 browser.dispose (); 1188 browser.dispose ();
1168 error (rc); 1189 error (rc);
1169 } 1190 }
1170 if (baseWindow is null) { 1191 if (baseWindow is null) {
1180 rect.height = 1; 1201 rect.height = 1;
1181 } 1202 }
1182 1203
1183 embedHandle = mozDelegate.getHandle (); 1204 embedHandle = mozDelegate.getHandle ();
1184 1205
1185 rc = baseWindow.InitWindow (embedHandle, 0, 0, 0, rect.width, rect.height); 1206 rc = baseWindow.InitWindow (cast(void*)embedHandle, null, 0, 0, rect.width, rect.height);
1186 if (rc !is XPCOM.NS_OK) { 1207 if (rc !is XPCOM.NS_OK) {
1187 browser.dispose (); 1208 browser.dispose ();
1188 error (XPCOM.NS_ERROR_FAILURE); 1209 error (XPCOM.NS_ERROR_FAILURE);
1189 } 1210 }
1190 rc = baseWindow.Create (); 1211 rc = baseWindow.Create ();
1256 // nsIComponentRegistrar componentRegistrar = new nsIComponentRegistrar (result[0]); 1277 // nsIComponentRegistrar componentRegistrar = new nsIComponentRegistrar (result[0]);
1257 DownloadFactory_1_8 downloadFactory_1_8 = new DownloadFactory_1_8 (); 1278 DownloadFactory_1_8 downloadFactory_1_8 = new DownloadFactory_1_8 ();
1258 downloadFactory_1_8.AddRef (); 1279 downloadFactory_1_8.AddRef ();
1259 // byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_TRANSFER_CONTRACTID, true); 1280 // byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_TRANSFER_CONTRACTID, true);
1260 1281
1261 // byte[] aClassName = MozillaDelegate.wcsToMbcs (null, "Transfer", true); //$NON-NLS-1$ 1282 String aClassName = "Transfer"; //$NON-NLS-1$
1262 rc = componentRegistrar.RegisterFactory (XPCOM.NS_DOWNLOAD_CID, aClassName.ptr, XPCOM.NS_TRANSFER_CONTRACTID, cast(nsIFactory)downloadFactory_1_8); 1283 rc = componentRegistrar.RegisterFactory (&XPCOM.NS_DOWNLOAD_CID, aClassName.ptr, XPCOM.NS_TRANSFER_CONTRACTID.ptr, cast(nsIFactory)downloadFactory_1_8);
1263 if (rc !is XPCOM.NS_OK) { 1284 if (rc !is XPCOM.NS_OK) {
1264 browser.dispose (); 1285 browser.dispose ();
1265 error (rc); 1286 error (rc);
1266 } 1287 }
1267 downloadFactory_1_8.Release (); 1288 downloadFactory_1_8.Release ();
1287 error (XPCOM.NS_ERROR_NO_INTERFACE); 1308 error (XPCOM.NS_ERROR_NO_INTERFACE);
1288 } 1309 }
1289 //nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]); 1310 //nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]);
1290 //char[] uri = new char[ABOUT_BLANK.length () + 1]; 1311 //char[] uri = new char[ABOUT_BLANK.length () + 1];
1291 //ABOUT_BLANK.getChars (0, ABOUT_BLANK.length (), uri, 0); 1312 //ABOUT_BLANK.getChars (0, ABOUT_BLANK.length (), uri, 0);
1292 rc = webNavigation.LoadURI (Utf.toString16(ABOUT_BLANK).toString16z, nsIWebNavigation.LOAD_FLAGS_NONE, null, null, null); 1313 rc = webNavigation.LoadURI (ABOUT_BLANK.toString16().toString16z(), nsIWebNavigation.LOAD_FLAGS_NONE, null, null, null);
1293 webNavigation.Release (); 1314 webNavigation.Release ();
1294 } 1315 }
1295 } 1316 }
1296 //result[0] = 0; 1317 //result[0] = 0;
1297 interfaceRequestor.Release (); 1318 interfaceRequestor.Release ();
1298 } 1319 }
1299 componentManager.Release (); 1320 componentManager.Release ();
1300 1321 /*
1322 // REMOVE: not necessary
1301 nsIWeakReference weakReference; 1323 nsIWeakReference weakReference;
1324
1302 rc = this.QueryInterface(&nsIWeakReference.IID, cast(void**)&weakReference); 1325 rc = this.QueryInterface(&nsIWeakReference.IID, cast(void**)&weakReference);
1303 if (rc !is XPCOM.NS_OK) { 1326 if (rc !is XPCOM.NS_OK) {
1304 browser.dispose(); 1327 browser.dispose();
1305 error(rc); 1328 error(rc);
1306 } 1329 }
1307 if (weakReference is null) { 1330 if (weakReference is null) {
1308 browser.dispose(); 1331 browser.dispose();
1309 error(XPCOM.NS_ERROR_NO_INTERFACE); 1332 error(XPCOM.NS_ERROR_NO_INTERFACE);
1310 } 1333 }
1311 1334 */
1312 // TODO: Find appropriate place to "Release" weakReference -JJR 1335 rc = webBrowser.AddWebBrowserListener (cast(nsIWeakReference)this, &nsIWebProgressListener.IID);
1313 rc = webBrowser.AddWebBrowserListener (weakReference, &nsIWebProgressListener.IID);
1314 if (rc !is XPCOM.NS_OK) { 1336 if (rc !is XPCOM.NS_OK) {
1315 browser.dispose (); 1337 browser.dispose ();
1316 error (rc); 1338 error (rc);
1317 } 1339 }
1318 1340
1319 // TODO: Find appropriate place to "Release" uriContentListener -JJR 1341 // TODO: Find appropriate place to "Release" uriContentListener -JJR
1320 nsIUriContentListener uriContentListener; 1342 nsIURIContentListener uriContentListener;
1321 this.QueryInterface(&nsIUriContentListener.IID, cast(void**)&uriContentListener); 1343 this.QueryInterface(&nsIURIContentListener.IID, cast(void**)&uriContentListener);
1322 if (rc !is XPCOM.NS_OK) { 1344 if (rc !is XPCOM.NS_OK) {
1323 browser.dispose(); 1345 browser.dispose();
1324 error(rc); 1346 error(rc);
1325 } 1347 }
1326 if (uriContentListener is null) { 1348 if (uriContentListener is null) {
1336 1358
1337 mozDelegate.init (); 1359 mozDelegate.init ();
1338 1360
1339 listener = new class () Listener { 1361 listener = new class () Listener {
1340 public void handleEvent (Event event) { 1362 public void handleEvent (Event event) {
1363 Control control = cast(Control)this.outer.browser;
1341 switch (event.type) { 1364 switch (event.type) {
1342 case DWT.Dispose: { 1365 case DWT.Dispose: {
1343 /* make this handler run after other dispose listeners */ 1366 /* make this handler run after other dispose listeners */
1344 if (ignoreDispose) { 1367 if (ignoreDispose) {
1345 ignoreDispose = false; 1368 ignoreDispose = false;
1354 case DWT.Resize: onResize (); break; 1377 case DWT.Resize: onResize (); break;
1355 case DWT.FocusIn: Activate (); break; 1378 case DWT.FocusIn: Activate (); break;
1356 case DWT.Activate: Activate (); break; 1379 case DWT.Activate: Activate (); break;
1357 case DWT.Deactivate: { 1380 case DWT.Deactivate: {
1358 Display display = event.display; 1381 Display display = event.display;
1359 if (this.browser is display.getFocusControl ()) Deactivate (); 1382 if (control is display.getFocusControl ()) Deactivate ();
1360 break; 1383 break;
1361 } 1384 }
1362 case DWT.Show: { 1385 case DWT.Show: {
1363 /* 1386 /*
1364 * Feature in GTK Mozilla. Mozilla does not show up when 1387 * Feature in GTK Mozilla. Mozilla does not show up when
1419 1442
1420 //nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]); 1443 //nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]);
1421 //char[] arg = url.toCharArray (); 1444 //char[] arg = url.toCharArray ();
1422 //char[] c = new char[arg.length+1]; 1445 //char[] c = new char[arg.length+1];
1423 //System.arraycopy (arg, 0, c, 0, arg.length); 1446 //System.arraycopy (arg, 0, c, 0, arg.length);
1424 rc = webNavigation.LoadURI (Utf.toString16(url).toString16z, nsIWebNavigation.LOAD_FLAGS_NONE, null, null, null); 1447 rc = webNavigation.LoadURI (url.toString16().toString16z(), nsIWebNavigation.LOAD_FLAGS_NONE, null, null, null);
1425 webNavigation.Release (); 1448 webNavigation.Release ();
1426 return rc is XPCOM.NS_OK; 1449 return rc is XPCOM.NS_OK;
1427 } 1450 }
1428 1451
1429 static Browser findBrowser (void* handle) { 1452 static Browser findBrowser (void* handle) {
1448 1471
1449 public String getText () { 1472 public String getText () {
1450 if (awaitingNavigate) return ""; //$NON-NLS-1$ 1473 if (awaitingNavigate) return ""; //$NON-NLS-1$
1451 1474
1452 //int /*long*/[] result = new int /*long*/[1]; 1475 //int /*long*/[] result = new int /*long*/[1];
1453 nsIDOMWIndow window; 1476 nsIDOMWindow window;
1454 int rc = webBrowser.GetContentDOMWindow (&window); 1477 int rc = webBrowser.GetContentDOMWindow (&window);
1455 if (rc !is XPCOM.NS_OK) error (rc); 1478 if (rc !is XPCOM.NS_OK) error (rc);
1456 if (window is null) error (XPCOM.NS_NOINTERFACE); 1479 if (window is null) error (XPCOM.NS_NOINTERFACE);
1457 1480
1458 //nsIDOMWindow window = new nsIDOMWindow (result[0]); 1481 //nsIDOMWindow window = new nsIDOMWindow (result[0]);
1473 //nsIComponentManager componentManager = new nsIComponentManager (result[0]); 1496 //nsIComponentManager componentManager = new nsIComponentManager (result[0]);
1474 //result[0] = 0; 1497 //result[0] = 0;
1475 //byte[] contractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_DOMSERIALIZER_CONTRACTID, true); 1498 //byte[] contractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_DOMSERIALIZER_CONTRACTID, true);
1476 String chars = null; 1499 String chars = null;
1477 nsIDOMSerializer_1_7 serializer_1_7; 1500 nsIDOMSerializer_1_7 serializer_1_7;
1478 rc = componentManager.CreateInstanceByContractID (XPCOM.NS_DOMSERIALIZER_CONTRACTID, null, &nsIDOMSerializer_1_7.IID, cast(void**)&serializer_1_7); 1501 rc = componentManager.CreateInstanceByContractID (XPCOM.NS_DOMSERIALIZER_CONTRACTID.ptr, null, &nsIDOMSerializer_1_7.IID, cast(void**)&serializer_1_7);
1479 if (rc is XPCOM.NS_OK) { /* mozilla >= 1.7 */ 1502 if (rc is XPCOM.NS_OK) { /* mozilla >= 1.7 */
1480 if (serializer_1_7 is null) error (XPCOM.NS_NOINTERFACE); 1503 if (serializer_1_7 is null) error (XPCOM.NS_NOINTERFACE);
1481 1504
1482 //nsIDOMSerializer_1_7 serializer = new nsIDOMSerializer_1_7 (result[0]); 1505 //nsIDOMSerializer_1_7 serializer = new nsIDOMSerializer_1_7 (result[0]);
1483 //result[0] = 0; 1506 //result[0] = 0;
1488 //int length = XPCOM.nsEmbedString_Length (string); 1511 //int length = XPCOM.nsEmbedString_Length (string);
1489 //int /*long*/ buffer = XPCOM.nsEmbedString_get (string); 1512 //int /*long*/ buffer = XPCOM.nsEmbedString_get (string);
1490 //chars = new char[length]; 1513 //chars = new char[length];
1491 //XPCOM.memmove (chars, buffer, length * 2); 1514 //XPCOM.memmove (chars, buffer, length * 2);
1492 //XPCOM.nsEmbedString_delete (string); 1515 //XPCOM.nsEmbedString_delete (string);
1493 chars = string.toString; 1516 chars = string.toString();
1494 } else { /* mozilla < 1.7 */ 1517 } else { /* mozilla < 1.7 */
1495 nsIDOMSerializer serializer; 1518 nsIDOMSerializer serializer;
1496 rc = componentManager.CreateInstanceByContractID (XPCOM.NS_DOMSERIALIZER_CONTRACTID, null, &nsIDOMSerializer.IID, cast(void**)&serializer); 1519 rc = componentManager.CreateInstanceByContractID (XPCOM.NS_DOMSERIALIZER_CONTRACTID.ptr, null, &nsIDOMSerializer.IID, cast(void**)&serializer);
1497 if (rc !is XPCOM.NS_OK) error (rc); 1520 if (rc !is XPCOM.NS_OK) error (rc);
1498 if (serializer is null) error (XPCOM.NS_NOINTERFACE); 1521 if (serializer is null) error (XPCOM.NS_NOINTERFACE);
1499 // TODO: Lookup SerializeToString contract. Find out if the string must provide it's own memory to the method. -JJR 1522 // TODO: Lookup SerializeToString contract. Find out if the string must provide it's own memory to the method. -JJR
1500 PRUnichar* string; 1523 PRUnichar* string;
1501 //nsIDOMSerializer serializer = new nsIDOMSerializer (result[0]); 1524 //nsIDOMSerializer serializer = new nsIDOMSerializer (result[0]);
1504 serializer.Release (); 1527 serializer.Release ();
1505 1528
1506 //int length = XPCOM.strlen_PRUnichar (string); 1529 //int length = XPCOM.strlen_PRUnichar (string);
1507 //chars = new char[length]; 1530 //chars = new char[length];
1508 //XPCOM.memmove (chars, result[0], length * 2); 1531 //XPCOM.memmove (chars, result[0], length * 2);
1509 chars = Utf.toString(string.fromString16z); 1532 chars = Utf.toString(fromString16z(string));
1510 } 1533 }
1511 1534
1512 componentManager.Release (); 1535 componentManager.Release ();
1513 document.Release (); 1536 document.Release ();
1514 return chars.dup; 1537 return chars.dup;
1538 //int length = XPCOM.nsEmbedCString_Length (aSpec); 1561 //int length = XPCOM.nsEmbedCString_Length (aSpec);
1539 //int /*long*/ buffer = XPCOM.nsEmbedCString_get (aSpec); 1562 //int /*long*/ buffer = XPCOM.nsEmbedCString_get (aSpec);
1540 location = aSpec.toString; 1563 location = aSpec.toString;
1541 //XPCOM.memmove (dest, buffer, length); 1564 //XPCOM.memmove (dest, buffer, length);
1542 //XPCOM.nsEmbedCString_delete (aSpec); 1565 //XPCOM.nsEmbedCString_delete (aSpec);
1543 uri.Release (); 1566 aCurrentURI.Release ();
1544 } 1567 }
1545 if (location is null) return ""; //$NON-NLS-1$ 1568 if (location is null) return ""; //$NON-NLS-1$
1546 1569
1547 /* 1570 /*
1548 * If the URI indicates that the page is being rendered from memory 1571 * If the URI indicates that the page is being rendered from memory
1612 webNavigation.Release (); 1635 webNavigation.Release ();
1613 return aCanGoForward !is 0; 1636 return aCanGoForward !is 0;
1614 } 1637 }
1615 1638
1616 static String error (int code) { 1639 static String error (int code) {
1617 throw new DWTError ("XPCOM error " ~ code); //$NON-NLS-1$ 1640 throw new DWTError ("XPCOM error " ~ Integer.toString(code)); //$NON-NLS-1$
1618 } 1641 }
1619 1642
1620 void onDispose (Display display) { 1643 void onDispose (Display display) {
1621 int rc = webBrowser.RemoveWebBrowserListener (weakReference, &nsIWebProgressListener.IID); 1644 int rc = webBrowser.RemoveWebBrowserListener (cast(nsIWeakReference)this, &nsIWebProgressListener.IID);
1622 if (rc !is XPCOM.NS_OK) error (rc); 1645 if (rc !is XPCOM.NS_OK) error (rc);
1623 1646
1624 rc = webBrowser.SetParentURIContentListener (0); 1647 rc = webBrowser.SetParentURIContentListener (null);
1625 if (rc !is XPCOM.NS_OK) error (rc); 1648 if (rc !is XPCOM.NS_OK) error (rc);
1626 1649
1627 unhookDOMListeners (); 1650 unhookDOMListeners ();
1628 if (listener !is null) { 1651 if (listener !is null) {
1629 int[] folderEvents = [ 1652 int[] folderEvents = [
2139 } 2162 }
2140 return QueryInterface (riid, ppvObject); 2163 return QueryInterface (riid, ppvObject);
2141 } 2164 }
2142 2165
2143 nsresult GetWeakReference (void** ppvObject) { 2166 nsresult GetWeakReference (void** ppvObject) {
2144 *ppvObject = cast(void*)weakReference; 2167 *ppvObject = cast(void*)cast(nsIWeakReference)this;
2145 //XPCOM.memmove (ppvObject, new int /*long*/[] {weakReference.getAddress ()}, C.PTR_SIZEOF); 2168 //XPCOM.memmove (ppvObject, new int /*long*/[] {weakReference.getAddress ()}, C.PTR_SIZEOF);
2146 AddRef (); 2169 AddRef ();
2147 return XPCOM.NS_OK; 2170 return XPCOM.NS_OK;
2148 } 2171 }
2149 2172
2288 domWindow.Release (); 2311 domWindow.Release ();
2289 } 2312 }
2290 return XPCOM.NS_OK; 2313 return XPCOM.NS_OK;
2291 } 2314 }
2292 2315
2293 nsresult OnProgressChange (nsIWebProgress aWebProgress, nsIRequest aRequest, PRint32 aCurSelfProgress, PRInt32 aMaxSelfProgress, PRInt32 aCurTotalProgress, PRInt32 aMaxTotalProgress) { 2316 nsresult OnProgressChange (nsIWebProgress aWebProgress, nsIRequest aRequest, PRInt32 aCurSelfProgress, PRInt32 aMaxSelfProgress, PRInt32 aCurTotalProgress, PRInt32 aMaxTotalProgress) {
2294 if (awaitingNavigate || super.progressListeners.length is 0) return XPCOM.NS_OK; 2317 if (awaitingNavigate || super.progressListeners.length is 0) return XPCOM.NS_OK;
2295 ProgressEvent event = new ProgressEvent (browser); 2318 ProgressEvent event = new ProgressEvent (browser);
2296 event.display = browser.getDisplay (); 2319 event.display = browser.getDisplay ();
2297 event.widget = browser; 2320 event.widget = browser;
2298 event.current = aCurTotalProgress; 2321 event.current = aCurTotalProgress;
2368 locationListeners[i].changed (event); 2391 locationListeners[i].changed (event);
2369 } 2392 }
2370 return XPCOM.NS_OK; 2393 return XPCOM.NS_OK;
2371 } 2394 }
2372 2395
2373 int OnStatusChange (nsIWebProgress aWebProgress, nsIRequest aRequest, nsresult aStatus, PRUnichar* aMessage) { 2396 nsresult OnStatusChange (nsIWebProgress aWebProgress, nsIRequest aRequest, nsresult aStatus, PRUnichar* aMessage) {
2374 if (awaitingNavigate || statusTextListeners.length is 0) return XPCOM.NS_OK; 2397 if (awaitingNavigate || statusTextListeners.length is 0) return XPCOM.NS_OK;
2375 StatusTextEvent event = new StatusTextEvent (browser); 2398 StatusTextEvent event = new StatusTextEvent (browser);
2376 event.display = browser.getDisplay (); 2399 event.display = browser.getDisplay ();
2377 event.widget = browser; 2400 event.widget = browser;
2378 //int length = XPCOM.strlen_PRUnichar (aMessage); 2401 //int length = XPCOM.strlen_PRUnichar (aMessage);
2383 statusTextListeners[i].changed (event); 2406 statusTextListeners[i].changed (event);
2384 } 2407 }
2385 return XPCOM.NS_OK; 2408 return XPCOM.NS_OK;
2386 } 2409 }
2387 2410
2388 int OnSecurityChange (nsIWebProgress aWebProgress, nsIRequest aRequest, PRUint32 state) { 2411 nsresult OnSecurityChange (nsIWebProgress aWebProgress, nsIRequest aRequest, PRUint32 state) {
2389 return XPCOM.NS_OK; 2412 return XPCOM.NS_OK;
2390 } 2413 }
2391 2414
2392 /* nsIWebBrowserChrome */ 2415 /* nsIWebBrowserChrome */
2393 2416
2394 nsresult SetStatus (PRUint32 statusType, PRUinchar* status) { 2417 nsresult SetStatus (PRUint32 statusType, PRUnichar* status) {
2395 if (awaitingNavigate || statusTextListeners.length is 0) return XPCOM.NS_OK; 2418 if (awaitingNavigate || statusTextListeners.length is 0) return XPCOM.NS_OK;
2396 StatusTextEvent event = new StatusTextEvent (browser); 2419 StatusTextEvent event = new StatusTextEvent (browser);
2397 event.display = browser.getDisplay (); 2420 event.display = browser.getDisplay ();
2398 event.widget = browser; 2421 event.widget = browser;
2399 //int length = XPCOM.strlen_PRUnichar (status); 2422 //int length = XPCOM.strlen_PRUnichar (status);
2519 browser.getShell ().setSize (cx, cy); 2542 browser.getShell ().setSize (cx, cy);
2520 } 2543 }
2521 return XPCOM.NS_OK; 2544 return XPCOM.NS_OK;
2522 } 2545 }
2523 2546
2524 int GetDimensions (PRUint32 flags, PRInt32* x, PRInt32* y, PRInt32* cx, PRInt32* cy) { 2547 nsresult GetDimensions (PRUint32 flags, PRInt32* x, PRInt32* y, PRInt32* cx, PRInt32* cy) {
2525 if ((flags & nsIEmbeddingSiteWindow.DIM_FLAGS_POSITION) !is 0) { 2548 if ((flags & nsIEmbeddingSiteWindow.DIM_FLAGS_POSITION) !is 0) {
2526 Point location = browser.getShell ().getLocation (); 2549 Point location = browser.getShell ().getLocation ();
2527 if (x !is null) *x = location.x; /* PRInt32 */ 2550 if (x !is null) *x = location.x; /* PRInt32 */
2528 if (y !is null) *y = location.y; /* PRInt32 */ 2551 if (y !is null) *y = location.y; /* PRInt32 */
2529 } 2552 }