Mercurial > projects > dwt-linux
comparison dwt/browser/Mozilla.d @ 305:c7c696cdfec2
Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
author | John Reimer<terminal.node@gmail.com> |
---|---|
date | Sat, 16 Aug 2008 22:53:35 -0700 |
parents | 16ba3d9cb209 |
children | 8235a17d9255 |
comparison
equal
deleted
inserted
replaced
304:16ba3d9cb209 | 305:c7c696cdfec2 |
---|---|
164 static final String PREFERENCE_PROXYHOST_SSL = "network.proxy.ssl"; //$NON-NLS-1$ | 164 static final String PREFERENCE_PROXYHOST_SSL = "network.proxy.ssl"; //$NON-NLS-1$ |
165 static final String PREFERENCE_PROXYPORT_SSL = "network.proxy.ssl_port"; //$NON-NLS-1$ | 165 static final String PREFERENCE_PROXYPORT_SSL = "network.proxy.ssl_port"; //$NON-NLS-1$ |
166 static final String PREFERENCE_PROXYTYPE = "network.proxy.type"; //$NON-NLS-1$ | 166 static final String PREFERENCE_PROXYTYPE = "network.proxy.type"; //$NON-NLS-1$ |
167 static final String PROFILE_AFTER_CHANGE = "profile-after-change"; //$NON-NLS-1$ | 167 static final String PROFILE_AFTER_CHANGE = "profile-after-change"; //$NON-NLS-1$ |
168 static final String PROFILE_BEFORE_CHANGE = "profile-before-change"; //$NON-NLS-1$ | 168 static final String PROFILE_BEFORE_CHANGE = "profile-before-change"; //$NON-NLS-1$ |
169 static final String PROFILE_DIR = SEPARATOR_OS + "eclipse" ~ SEPARATOR_OS; //$NON-NLS-1$ | 169 static final String PROFILE_DIR = SEPARATOR_OS ~ "eclipse" ~ SEPARATOR_OS; //$NON-NLS-1$ |
170 static final String PROFILE_DO_CHANGE = "profile-do-change"; //$NON-NLS-1$ | 170 static final String PROFILE_DO_CHANGE = "profile-do-change"; //$NON-NLS-1$ |
171 static final String PROPERTY_PROXYPORT = "network.proxy_port"; //$NON-NLS-1$ | 171 static final String PROPERTY_PROXYPORT = "network.proxy_port"; //$NON-NLS-1$ |
172 static final String PROPERTY_PROXYHOST = "network.proxy_host"; //$NON-NLS-1$ | 172 static final String PROPERTY_PROXYHOST = "network.proxy_host"; //$NON-NLS-1$ |
173 static final String SEPARATOR_LOCALE = "-"; //$NON-NLS-1$ | 173 static final String SEPARATOR_LOCALE = "-"; //$NON-NLS-1$ |
174 static final String SHUTDOWN_PERSIST = "shutdown-persist"; //$NON-NLS-1$ | 174 static final String SHUTDOWN_PERSIST = "shutdown-persist"; //$NON-NLS-1$ |
255 * so just bind to it instead of trying to initialize a new one. | 255 * so just bind to it instead of trying to initialize a new one. |
256 */ | 256 */ |
257 Initialized = true; | 257 Initialized = true; |
258 } | 258 } |
259 String mozillaPath = System.getProperty (XULRUNNER_PATH); | 259 String mozillaPath = System.getProperty (XULRUNNER_PATH); |
260 /+ if (mozillaPath is null) { | 260 if (mozillaPath is null) { |
261 // we don't have to load an initial library in DWT, so set to "true" | |
262 initLoaded = true; | |
263 /+ | |
264 if (mozillaPath is null) { | |
261 try { | 265 try { |
262 String libName = mozDelegate.getSWTInitLibraryName (); | 266 String libName = mozDelegate.getSWTInitLibraryName (); |
263 Library.loadLibrary (libName); | 267 Library.loadLibrary (libName); |
264 initLoaded = true; | 268 initLoaded = true; |
265 } catch (UnsatisfiedLinkError e) { | 269 } catch (UnsatisfiedLinkError e) { |
267 * If this library failed to load then do not attempt to detect a | 271 * If this library failed to load then do not attempt to detect a |
268 * xulrunner to use. The Browser may still be usable if MOZILLA_FIVE_HOME | 272 * xulrunner to use. The Browser may still be usable if MOZILLA_FIVE_HOME |
269 * points at a GRE. | 273 * points at a GRE. |
270 */ | 274 */ |
271 } | 275 } |
272 } else { +/ | 276 +/ |
277 } else { | |
273 mozillaPath ~= SEPARATOR_OS ~ mozDelegate.getLibraryName (); | 278 mozillaPath ~= SEPARATOR_OS ~ mozDelegate.getLibraryName (); |
274 IsXULRunner = true; | 279 IsXULRunner = true; |
275 // } | 280 } |
276 | 281 |
277 if (initLoaded) { | 282 if (initLoaded) { |
278 /* attempt to discover a XULRunner to use as the GRE */ | 283 /* attempt to discover a XULRunner to use as the GRE */ |
279 GREVersionRange range; | 284 GREVersionRange range; |
280 //byte[] bytes = MozillaDelegate.wcsToMbcs (null, GRERANGE_LOWER, true); | 285 //byte[] bytes = MozillaDelegate.wcsToMbcs (null, GRERANGE_LOWER, true); |
281 int /*long*/ lower = C.malloc (bytes.length); | 286 //int /*long*/ lower = C.malloc (bytes.length); |
282 C.memmove (lower, bytes, bytes.length); | 287 //C.memmove (lower, bytes, bytes.length); |
283 range.lower = lower; | 288 range.lower = GRERANGE_LOWER; |
284 range.lowerInclusive = LowerRangeInclusive; | 289 range.lowerInclusive = LowerRangeInclusive; |
285 | 290 |
286 bytes = MozillaDelegate.wcsToMbcs (null, GRERANGE_UPPER, true); | 291 //bytes = MozillaDelegate.wcsToMbcs (null, GRERANGE_UPPER, true); |
287 int /*long*/ upper = C.malloc (bytes.length); | 292 //int /*long*/ upper = C.malloc (bytes.length); |
288 C.memmove (upper, bytes, bytes.length); | 293 //C.memmove (upper, bytes, bytes.length); |
289 range.upper = upper; | 294 range.upper = GRERANGE_UPPER; |
290 range.upperInclusive = UpperRangeInclusive; | 295 range.upperInclusive = UpperRangeInclusive; |
291 | 296 |
292 int length = XPCOMInit.PATH_MAX; | 297 //int length = XPCOMInit.PATH_MAX; |
293 int /*long*/ greBuffer = C.malloc (length); | 298 //int /*long*/ greBuffer = C.malloc (length); |
294 int /*long*/ propertiesPtr = C.malloc (2 * C.PTR_SIZEOF); | 299 char[] greBuffer = new char[XPCOMInit.PATH_MAX]; |
295 int rc = XPCOMInit.GRE_GetGREPathWithProperties (range, 1, propertiesPtr, 0, greBuffer, length); | 300 //int /*long*/ propertiesPtr = C.malloc (2 * C.PTR_SIZEOF); |
301 int rc = XPCOMInit.GRE_GetGREPathWithProperties (&range, 1, null, 0, greBuffer.ptr, greBuffer.length); | |
296 | 302 |
297 /* | 303 /* |
298 * A XULRunner was not found that supports wrapping of XPCOM handles as JavaXPCOM objects. | 304 * A XULRunner was not found that supports wrapping of XPCOM handles as JavaXPCOM objects. |
299 * Drop the lower version bound and try to detect an earlier XULRunner installation. | 305 * Drop the lower version bound and try to detect an earlier XULRunner installation. |
300 */ | 306 */ |
301 if (rc !is XPCOM.NS_OK) { | 307 if (rc !is XPCOM.NS_OK) { |
302 C.free (lower); | 308 //C.free (lower); |
303 bytes = MozillaDelegate.wcsToMbcs (null, GRERANGE_LOWER_FALLBACK, true); | 309 //bytes = MozillaDelegate.wcsToMbcs (null, GRERANGE_LOWER_FALLBACK, true); |
304 lower = C.malloc (bytes.length); | 310 //lower = C.malloc (bytes.length); |
305 C.memmove (lower, bytes, bytes.length); | 311 //C.memmove (lower, bytes, bytes.length); |
306 range.lower = lower; | 312 range.lower = GRERANGE_LOWER_FALLBACK; |
307 rc = XPCOMInit.GRE_GetGREPathWithProperties (range, 1, propertiesPtr, 0, greBuffer, length); | 313 rc = XPCOMInit.GRE_GetGREPathWithProperties (&range, 1, null, 0, greBuffer.ptr, greBuffer.length); |
308 } | 314 } |
309 | 315 |
310 C.free (lower); | 316 //C.free (lower); |
311 C.free (upper); | 317 //C.free (upper); |
312 C.free (propertiesPtr); | 318 //C.free (propertiesPtr); |
313 if (rc is XPCOM.NS_OK) { | 319 if (rc is XPCOM.NS_OK) { |
314 /* indicates that a XULRunner was found */ | 320 /* indicates that a XULRunner was found */ |
315 length = C.strlen (greBuffer); | 321 //length = C.strlen (greBuffer); |
316 bytes = new byte[length]; | 322 //bytes = new byte[length]; |
317 C.memmove (bytes, greBuffer, length); | 323 //C.memmove (bytes, greBuffer, length); |
318 mozillaPath = new String (MozillaDelegate.mbcsToWcs (null, bytes)); | 324 //mozillaPath = new String (MozillaDelegate.mbcsToWcs (null, bytes)); |
319 IsXULRunner = mozillaPath.length () > 0; | 325 mozillaPath = greBuffer; |
326 IsXULRunner = mozillaPath.length > 0; | |
320 | 327 |
321 /* | 328 /* |
322 * Test whether the detected XULRunner can be used as the GRE before loading swt's | 329 * Test whether the detected XULRunner can be used as the GRE before loading swt's |
323 * XULRunner library. If it cannot be used then fall back to attempting to use | 330 * XULRunner library. If it cannot be used then fall back to attempting to use |
324 * the GRE pointed to by MOZILLA_FIVE_HOME. | 331 * the GRE pointed to by MOZILLA_FIVE_HOME. |
325 * | 332 * |
326 * One case where this will fail is attempting to use a 64-bit xulrunner while swt | 333 * One case where this will fail is attempting to use a 64-bit xulrunner while swt |
327 * is running in 32-bit mode, or vice versa. | 334 * is running in 32-bit mode, or vice versa. |
328 */ | 335 */ |
329 if (IsXULRunner) { | 336 if (IsXULRunner) { |
330 byte[] path = MozillaDelegate.wcsToMbcs (null, mozillaPath, true); | 337 // byte[] path = MozillaDelegate.wcsToMbcs (null, mozillaPath, true); |
331 rc = XPCOMInit.XPCOMGlueStartup (path); | 338 rc = XPCOMInit.XPCOMGlueStartup (mozillaPath.ptr); |
332 if (rc !is XPCOM.NS_OK) { | 339 if (rc !is XPCOM.NS_OK) { |
333 IsXULRunner = false; /* failed */ | 340 IsXULRunner = false; /* failed */ |
334 mozillaPath = mozillaPath.substring (0, mozillaPath.lastIndexOf (SEPARATOR_OS)); | 341 mozillaPath = mozillaPath[0 .. locatePrior( mozillaPath, SEPARATOR_OS )]; |
335 if (Device.DEBUG) System.out.println ("cannot use detected XULRunner: " + mozillaPath); //$NON-NLS-1$ | 342 //mozillaPath = mozillaPath.substring (0, mozillaPath.lastIndexOf (SEPARATOR_OS)); |
343 if (Device.DEBUG) Stdout ("cannot use detected XULRunner: ") (mozillaPath).newline; //$NON-NLS-1$ | |
336 } else { | 344 } else { |
337 XPCOMInitWasGlued = true; | 345 XPCOMInitWasGlued = true; |
338 } | 346 } |
339 } | 347 } |
340 } | 348 } |
341 C.free (greBuffer); | 349 //C.free (greBuffer); |
342 } | 350 } |
343 | 351 |
344 if (IsXULRunner) { | 352 if (IsXULRunner) { |
345 if (Device.DEBUG) System.out.println ("XULRunner path: " + mozillaPath); //$NON-NLS-1$ | 353 if (Device.DEBUG) Stdout ("XULRunner path: ") (mozillaPath).newline; //$NON-NLS-1$ |
354 /+ | |
346 try { | 355 try { |
347 Library.loadLibrary ("swt-xulrunner"); //$NON-NLS-1$ | 356 Library.loadLibrary ("swt-xulrunner"); //$NON-NLS-1$ |
348 } catch (UnsatisfiedLinkError e) { | 357 } catch (UnsatisfiedLinkError e) { |
349 DWT.error (DWT.ERROR_NO_HANDLES, e); | 358 DWT.error (DWT.ERROR_NO_HANDLES, e); |
350 } | 359 } |
360 | |
351 byte[] path = MozillaDelegate.wcsToMbcs (null, mozillaPath, true); | 361 byte[] path = MozillaDelegate.wcsToMbcs (null, mozillaPath, true); |
352 int rc = XPCOM.XPCOMGlueStartup (path); | 362 int rc = XPCOM.XPCOMGlueStartup (path); |
363 | |
353 if (rc !is XPCOM.NS_OK) { | 364 if (rc !is XPCOM.NS_OK) { |
354 browser.dispose (); | 365 browser.dispose (); |
355 error (rc); | 366 error (rc); |
356 } | 367 } |
368 +/ // No need for double layer initialization in DWT; glue is initialized -JJR | |
357 XPCOMWasGlued = true; | 369 XPCOMWasGlued = true; |
358 | 370 |
359 /* | 371 /* |
360 * Remove the trailing xpcom lib name from mozillaPath because the | 372 * Remove the trailing xpcom lib name from mozillaPath because the |
361 * Mozilla.initialize and NS_InitXPCOM2 invocations require a directory name only. | 373 * Mozilla.initialize and NS_InitXPCOM2 invocations require a directory name only. |
362 */ | 374 */ |
363 mozillaPath = mozillaPath.substring (0, mozillaPath.lastIndexOf (SEPARATOR_OS)); | 375 mozillaPath = mozillaPath[0 .. locatePrior( mozillaPath, SEPARATOR_OS )]; |
376 //mozillaPath = mozillaPath.substring (0, mozillaPath.lastIndexOf (SEPARATOR_OS)); | |
364 } else { | 377 } else { |
365 if ((style & DWT.MOZILLA) !is 0) { | 378 if ((style & DWT.MOZILLA) !is 0) { |
366 browser.dispose (); | 379 browser.dispose (); |
367 String errorString = (mozillaPath !is null && mozillaPath.length () > 0) ? | 380 String errorString = (mozillaPath !is null && mozillaPath.length > 0) ? |
368 " [Failed to use detected XULRunner: " + mozillaPath + "]" : | 381 " [Failed to use detected XULRunner: " ~ mozillaPath ~ "]" : |
369 " [Could not detect registered XULRunner to use]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ | 382 " [Could not detect registered XULRunner to use]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
370 DWT.error (DWT.ERROR_NO_HANDLES, null, errorString); | 383 DWT.error (DWT.ERROR_NO_HANDLES, null, errorString); |
371 } | 384 } |
372 | 385 |
373 /* attempt to use the GRE pointed at by MOZILLA_FIVE_HOME */ | 386 /* attempt to use the GRE pointed at by MOZILLA_FIVE_HOME */ |
374 int /*long*/ ptr = C.getenv (MozillaDelegate.wcsToMbcs (null, XPCOM.MOZILLA_FIVE_HOME, true)); | 387 auto mozFiveHome = tango.sys.Environment.get(XPCOM.MOZILLA_FIVE_HOME); |
375 if (ptr !is 0) { | 388 if (mozFiveHome !is null) { |
376 int length = C.strlen (ptr); | 389 //int length = C.strlen (ptr); |
377 byte[] buffer = new byte[length]; | 390 //byte[] buffer = new byte[length]; |
378 C.memmove (buffer, ptr, length); | 391 //C.memmove (buffer, ptr, length); |
379 mozillaPath = new String (MozillaDelegate.mbcsToWcs (null, buffer)); | 392 mozillaPath = mozFiveHome; |
380 } else { | 393 } else { |
381 browser.dispose (); | 394 browser.dispose (); |
382 DWT.error (DWT.ERROR_NO_HANDLES, null, " [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)]"); //$NON-NLS-1$ | 395 DWT.error (DWT.ERROR_NO_HANDLES, null, " [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)]"); //$NON-NLS-1$ |
383 } | 396 } |
384 if (Device.DEBUG) System.out.println ("Mozilla path: " + mozillaPath); //$NON-NLS-1$ | 397 if (Device.DEBUG) Stdout ("Mozilla path: ") (mozillaPath).newline; //$NON-NLS-1$ |
385 | 398 |
386 /* | 399 /* |
387 * Note. Embedding a Mozilla GTK1.2 causes a crash. The workaround | 400 * Note. Embedding a Mozilla GTK1.2 causes a crash. The workaround |
388 * is to check the version of GTK used by Mozilla by looking for | 401 * is to check the version of GTK used by Mozilla by looking for |
389 * the libwidget_gtk.so library used by Mozilla GTK1.2. Mozilla GTK2 | 402 * the libwidget_gtk.so library used by Mozilla GTK1.2. Mozilla GTK2 |
391 */ | 404 */ |
392 if (Compatibility.fileExists (mozillaPath, "components/libwidget_gtk.so")) { //$NON-NLS-1$ | 405 if (Compatibility.fileExists (mozillaPath, "components/libwidget_gtk.so")) { //$NON-NLS-1$ |
393 browser.dispose (); | 406 browser.dispose (); |
394 DWT.error (DWT.ERROR_NO_HANDLES, null, " [Mozilla GTK2 required (GTK1.2 detected)]"); //$NON-NLS-1$ | 407 DWT.error (DWT.ERROR_NO_HANDLES, null, " [Mozilla GTK2 required (GTK1.2 detected)]"); //$NON-NLS-1$ |
395 } | 408 } |
396 | 409 /+ |
397 try { | 410 try { |
398 Library.loadLibrary ("swt-mozilla"); //$NON-NLS-1$ | 411 Library.loadLibrary ("swt-mozilla"); //$NON-NLS-1$ |
399 } catch (UnsatisfiedLinkError e) { | 412 } catch (UnsatisfiedLinkError e) { |
400 try { | 413 try { |
401 /* | 414 /* |
410 * Print the error from the first failed attempt since at this point it's | 423 * Print the error from the first failed attempt since at this point it's |
411 * known that the failure was not due to the libstdc++.so.6 dependency. | 424 * known that the failure was not due to the libstdc++.so.6 dependency. |
412 */ | 425 */ |
413 DWT.error (DWT.ERROR_NO_HANDLES, e, " [MOZILLA_FIVE_HOME='" + mozillaPath + "']"); //$NON-NLS-1$ //$NON-NLS-2$ | 426 DWT.error (DWT.ERROR_NO_HANDLES, e, " [MOZILLA_FIVE_HOME='" + mozillaPath + "']"); //$NON-NLS-1$ //$NON-NLS-2$ |
414 } | 427 } |
415 } | 428 } |
429 +/ | |
416 } | 430 } |
417 | 431 |
418 if (!Initialized) { | 432 if (!Initialized) { |
419 int /*long*/[] retVal = new int /*long*/[1]; | 433 nsILocalFile file; |
420 nsEmbedString pathString = new nsEmbedString (mozillaPath); | 434 scope auto pathString = new nsEmbedString (mozillaPath); |
421 int rc = XPCOM.NS_NewLocalFile (pathString.getAddress (), 1, retVal); | 435 nsresult rc = XPCOM.NS_NewLocalFile (cast(nsAString*)pathString, 1, &localFile); |
422 pathString.dispose (); | 436 //pathString.dispose (); |
423 if (rc !is XPCOM.NS_OK) { | 437 if (rc !is XPCOM.NS_OK) { |
424 browser.dispose (); | 438 browser.dispose (); |
425 error (rc); | 439 error (rc); |
426 } | 440 } |
427 if (retVal[0] is 0) { | 441 if (localFile is null) { |
428 browser.dispose (); | 442 browser.dispose (); |
429 error (XPCOM.NS_ERROR_NULL_POINTER); | 443 error (XPCOM.NS_ERROR_NULL_POINTER); |
430 } | 444 } |
431 | 445 |
432 LocationProvider = new AppFileLocProvider (mozillaPath); | 446 LocationProvider = new AppFileLocProvider (mozillaPath); |
433 LocationProvider.AddRef (); | 447 LocationProvider.AddRef (); |
434 | 448 |
435 nsIFile localFile = new nsILocalFile (retVal[0]); | 449 //nsIFile localFile = new nsILocalFile (retVal[0]); |
436 rc = XPCOM.NS_InitXPCOM2 (0, localFile.getAddress(), LocationProvider.getAddress ()); | 450 nsIDirectoryServiceProvider directoryServiceProvider; |
451 nsIServiceManager serviceManager; | |
452 rc = LocationProvider.QueryInterface( &nsIDirectoryServiceProvider.IID, cast(void**)&directoryServiceProvider); | |
453 if (rc !is XPCOM.NS_OK) { | |
454 browser.dispose(); | |
455 error(rc); | |
456 } | |
457 rc = XPCOM.NS_GetServiceManager(&serviceManager); | |
458 if (rc !is XPCOM.NS_OK) { | |
459 browser.dispose(); | |
460 error(rc); | |
461 } | |
462 if (serviceManager is null || directoryServiceProvider is null) { | |
463 browser.dispose; | |
464 error (XPCOM.NS_ERROR_NULL_POINTER); | |
465 } | |
466 rc = XPCOM.NS_InitXPCOM2 (&serviceManager, 0, cast(IFile*)&localFile, &directoryServiceProvider); | |
437 localFile.Release (); | 467 localFile.Release (); |
468 serviceManager.Release(); | |
469 //LocationProvider.Release(); | |
438 if (rc !is XPCOM.NS_OK) { | 470 if (rc !is XPCOM.NS_OK) { |
439 browser.dispose (); | 471 browser.dispose (); |
440 DWT.error (DWT.ERROR_NO_HANDLES, null, " [MOZILLA_FIVE_HOME may not point at an embeddable GRE] [NS_InitEmbedding " + mozillaPath + " error " + rc + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ | 472 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$ |
441 } | 473 } |
442 System.setProperty (GRE_INITIALIZED, "true"); //$NON-NLS-1$ | 474 System.setProperty (GRE_INITIALIZED, "true"); //$NON-NLS-1$ |
443 if (IsXULRunner) { | 475 if (IsXULRunner) { |
444 System.setProperty (XULRUNNER_PATH, mozillaPath); | 476 System.setProperty (XULRUNNER_PATH, mozillaPath); |
445 } | 477 } |
446 } | 478 } |
447 | 479 /+ |
448 /* If JavaXPCOM is detected then attempt to initialize it with the XULRunner being used */ | 480 /* If JavaXPCOM is detected then attempt to initialize it with the XULRunner being used */ |
449 if (IsXULRunner) { | 481 if (IsXULRunner) { |
450 try { | 482 try { |
451 Class clazz = Class.forName ("org.mozilla.xpcom.Mozilla"); //$NON-NLS-1$ | 483 Class clazz = Class.forName ("org.mozilla.xpcom.Mozilla"); //$NON-NLS-1$ |
452 Method method = clazz.getMethod ("getInstance", new Class[0]); //$NON-NLS-1$ | 484 Method method = clazz.getMethod ("getInstance", new Class[0]); //$NON-NLS-1$ |
470 } catch (IllegalAccessException e) { | 502 } catch (IllegalAccessException e) { |
471 } catch (InvocationTargetException e) { | 503 } catch (InvocationTargetException e) { |
472 } catch (InstantiationException e) { | 504 } catch (InstantiationException e) { |
473 } | 505 } |
474 } | 506 } |
475 | 507 +/ |
476 int rc = XPCOM.NS_GetComponentManager (result); | 508 nsIComponentManager componentManager; |
509 int rc = XPCOM.NS_GetComponentManager (&componentManager); | |
477 if (rc !is XPCOM.NS_OK) { | 510 if (rc !is XPCOM.NS_OK) { |
478 browser.dispose (); | 511 browser.dispose (); |
479 error (rc); | 512 error (rc); |
480 } | 513 } |
481 if (result[0] is 0) { | 514 if (componentManager is null) { |
482 browser.dispose (); | 515 browser.dispose (); |
483 error (XPCOM.NS_NOINTERFACE); | 516 error (XPCOM.NS_NOINTERFACE); |
484 } | 517 } |
485 | 518 |
486 nsIComponentManager componentManager = new nsIComponentManager (result[0]); | 519 //nsIComponentManager componentManager = new nsIComponentManager (result[0]); |
487 result[0] = 0; | 520 //result[0] = 0; |
488 if (mozDelegate.needsSpinup ()) { | 521 if (mozDelegate.needsSpinup ()) { |
489 /* nsIAppShell is discontinued as of xulrunner 1.9, so do not fail if it is not found */ | 522 /* nsIAppShell is discontinued as of xulrunner 1.9, so do not fail if it is not found */ |
490 rc = componentManager.CreateInstance (XPCOM.NS_APPSHELL_CID, 0, nsIAppShell.NS_IAPPSHELL_IID, result); | 523 rc = componentManager.CreateInstance (XPCOM.NS_APPSHELL_CID, 0, nsIAppShell.IID, cast(void**)&AppShell); |
491 if (rc !is XPCOM.NS_ERROR_NO_INTERFACE) { | 524 if (rc !is XPCOM.NS_ERROR_NO_INTERFACE) { |
492 if (rc !is XPCOM.NS_OK) { | 525 if (rc !is XPCOM.NS_OK) { |
493 browser.dispose (); | 526 browser.dispose (); |
494 error (rc); | 527 error (rc); |
495 } | 528 } |
496 if (result[0] is 0) { | 529 if (AppShell is null) { |
497 browser.dispose (); | 530 browser.dispose (); |
498 error (XPCOM.NS_NOINTERFACE); | 531 error (XPCOM.NS_NOINTERFACE); |
499 } | 532 } |
500 | 533 |
501 AppShell = new nsIAppShell (result[0]); | 534 //AppShell = new nsIAppShell (result[0]); |
502 rc = AppShell.Create (0, null); | 535 rc = AppShell.Create (0, null); |
503 if (rc !is XPCOM.NS_OK) { | 536 if (rc !is XPCOM.NS_OK) { |
504 browser.dispose (); | 537 browser.dispose (); |
505 error (rc); | 538 error (rc); |
506 } | 539 } |
508 if (rc !is XPCOM.NS_OK) { | 541 if (rc !is XPCOM.NS_OK) { |
509 browser.dispose (); | 542 browser.dispose (); |
510 error (rc); | 543 error (rc); |
511 } | 544 } |
512 } | 545 } |
513 result[0] = 0; | 546 //result[0] = 0; |
514 } | 547 } |
515 | 548 |
516 WindowCreator = new WindowCreator2 (); | 549 WindowCreator = new WindowCreator2; |
517 WindowCreator.AddRef (); | 550 WindowCreator.AddRef (); |
518 | 551 |
519 rc = XPCOM.NS_GetServiceManager (result); | 552 nsIServiceManager serviceManager; |
553 rc = XPCOM.NS_GetServiceManager (&serviceManager); | |
520 if (rc !is XPCOM.NS_OK) { | 554 if (rc !is XPCOM.NS_OK) { |
521 browser.dispose (); | 555 browser.dispose (); |
522 error (rc); | 556 error (rc); |
523 } | 557 } |
524 if (result[0] is 0) { | 558 if (serviceManager is null) { |
525 browser.dispose (); | 559 browser.dispose (); |
526 error (XPCOM.NS_NOINTERFACE); | 560 error (XPCOM.NS_NOINTERFACE); |
527 } | 561 } |
528 | 562 |
529 nsIServiceManager serviceManager = new nsIServiceManager (result[0]); | 563 //nsIServiceManager serviceManager = new nsIServiceManager (result[0]); |
530 result[0] = 0; | 564 //result[0] = 0; |
531 byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_WINDOWWATCHER_CONTRACTID, true); | 565 //byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_WINDOWWATCHER_CONTRACTID, true); |
532 rc = serviceManager.GetServiceByContractID (aContractID, nsIWindowWatcher.NS_IWINDOWWATCHER_IID, result); | 566 nsIWindowWatcher windowWatcher; |
567 rc = serviceManager.GetServiceByContractID (XPCOM.NS_WINDOWWATCHER_CONTRACTID, nsIWindowWatcher.IID, cast(void**)&windowWatcher); | |
533 if (rc !is XPCOM.NS_OK) { | 568 if (rc !is XPCOM.NS_OK) { |
534 browser.dispose (); | 569 browser.dispose (); |
535 error (rc); | 570 error (rc); |
536 } | 571 } |
537 if (result[0] is 0) { | 572 if (windowWatcher is null) { |
538 browser.dispose (); | 573 browser.dispose (); |
539 error (XPCOM.NS_NOINTERFACE); | 574 error (XPCOM.NS_NOINTERFACE); |
540 } | 575 } |
541 | 576 |
542 nsIWindowWatcher windowWatcher = new nsIWindowWatcher (result[0]); | 577 //nsIWindowWatcher windowWatcher = new nsIWindowWatcher (result[0]); |
543 result[0] = 0; | 578 //result[0] = 0; |
544 rc = windowWatcher.SetWindowCreator (WindowCreator.getAddress()); | 579 rc = windowWatcher.SetWindowCreator (&WindowCreator); |
545 if (rc !is XPCOM.NS_OK) { | 580 if (rc !is XPCOM.NS_OK) { |
546 browser.dispose (); | 581 browser.dispose (); |
547 error (rc); | 582 error (rc); |
548 } | 583 } |
549 windowWatcher.Release (); | 584 windowWatcher.Release (); |