# HG changeset patch # User John Reimer # Date 1218770729 25200 # Node ID 16ba3d9cb209c13cc95bfbf798d1d1c3f8c9c4ba # Parent b72d84d1ba95f40efdfbfe1693cc0ba86fca05cd Update XPCOM Interfaces; More Mozilla module work diff -r b72d84d1ba95 -r 16ba3d9cb209 dwt/browser/Browser.d --- a/dwt/browser/Browser.d Wed Aug 13 18:49:58 2008 -0700 +++ b/dwt/browser/Browser.d Thu Aug 14 20:25:29 2008 -0700 @@ -95,7 +95,7 @@ DWT.error(DWT.ERROR_NO_HANDLES); } */ - auto webBrowser = new Mozilla; + webBrowser = new Mozilla; if (webBrowser is null) { dispose (); DWT.error (DWT.ERROR_NO_HANDLES); diff -r b72d84d1ba95 -r 16ba3d9cb209 dwt/browser/Mozilla.d --- a/dwt/browser/Mozilla.d Wed Aug 13 18:49:58 2008 -0700 +++ b/dwt/browser/Mozilla.d Thu Aug 14 20:25:29 2008 -0700 @@ -7,6 +7,8 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Port to the D programming language: + * John Reimer *******************************************************************************/ module dwt.browser.Mozilla; @@ -164,7 +166,7 @@ static final String PREFERENCE_PROXYTYPE = "network.proxy.type"; //$NON-NLS-1$ static final String PROFILE_AFTER_CHANGE = "profile-after-change"; //$NON-NLS-1$ static final String PROFILE_BEFORE_CHANGE = "profile-before-change"; //$NON-NLS-1$ - static final String PROFILE_DIR = SEPARATOR_OS + "eclipse" + SEPARATOR_OS; //$NON-NLS-1$ + static final String PROFILE_DIR = SEPARATOR_OS + "eclipse" ~ SEPARATOR_OS; //$NON-NLS-1$ static final String PROFILE_DO_CHANGE = "profile-do-change"; //$NON-NLS-1$ static final String PROPERTY_PROXYPORT = "network.proxy_port"; //$NON-NLS-1$ static final String PROPERTY_PROXYHOST = "network.proxy_host"; //$NON-NLS-1$ @@ -182,51 +184,54 @@ MozillaClearSessions = new Runnable () { public void run () { if (!Initialized) return; - int /*long*/[] result = new int /*long*/[1]; - int rc = XPCOM.NS_GetServiceManager (result); + nsIServiceManager serviceManager; + int rc = XPCOM.NS_GetServiceManager (&serviceManager); if (rc !is XPCOM.NS_OK) error (rc); - if (result[0] is 0) error (XPCOM.NS_NOINTERFACE); - nsIServiceManager serviceManager = new nsIServiceManager (result[0]); - result[0] = 0; - byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_COOKIEMANAGER_CONTRACTID, true); - rc = serviceManager.GetServiceByContractID (aContractID, nsICookieManager.NS_ICOOKIEMANAGER_IID, result); + if (serviceManager is null) error (XPCOM.NS_NOINTERFACE); + //nsIServiceManager serviceManager = new nsIServiceManager (result[0]); + //result[0] = 0; + //byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_COOKIEMANAGER_CONTRACTID, true); + nsICookieManager manager; + rc = serviceManager.GetServiceByContractID (XPCOM.NS_COOKIEMANAGER_CONTRACTID, nsICookieManager.IID, cast(void**)&manager); if (rc !is XPCOM.NS_OK) error (rc); - if (result[0] is 0) error (XPCOM.NS_NOINTERFACE); + if (manager is null) error (XPCOM.NS_NOINTERFACE); serviceManager.Release (); - nsICookieManager manager = new nsICookieManager (result[0]); - result[0] = 0; - rc = manager.GetEnumerator (result); + //nsICookieManager manager = new nsICookieManager (result[0]); + //result[0] = 0; + nsISimpleEnumerator enumerator; + rc = manager.GetEnumerator (&enumerator); if (rc !is XPCOM.NS_OK) error (rc); manager.Release (); - nsISimpleEnumerator enumerator = new nsISimpleEnumerator (result[0]); - int[] moreElements = new int[1]; /* PRBool */ - rc = enumerator.HasMoreElements (moreElements); + //nsISimpleEnumerator enumerator = new nsISimpleEnumerator (result[0]); + PRBool moreElements; /* PRBool */ + rc = enumerator.HasMoreElements (&moreElements); if (rc !is XPCOM.NS_OK) error (rc); - while (moreElements[0] !is 0) { - result[0] = 0; - rc = enumerator.GetNext (result); + while (moreElements !is 0) { + //result[0] = 0; + nsICookie cookie; + rc = enumerator.GetNext (cast(nsISupports*)&cookie); if (rc !is XPCOM.NS_OK) error (rc); - nsICookie cookie = new nsICookie (result[0]); - long[] expires = new long[1]; - rc = cookie.GetExpires (expires); - if (expires[0] is 0) { + //nsICookie cookie = new nsICookie (result[0]); + PRUint64 expires; + rc = cookie.GetExpires (&expires); + if (expires is 0) { /* indicates a session cookie */ - int /*long*/ domain = XPCOM.nsEmbedCString_new (); - int /*long*/ name = XPCOM.nsEmbedCString_new (); - int /*long*/ path = XPCOM.nsEmbedCString_new (); - cookie.GetHost (domain); - cookie.GetName (name); - cookie.GetPath (path); - rc = manager.Remove (domain, name, path, 0); - XPCOM.nsEmbedCString_delete (domain); - XPCOM.nsEmbedCString_delete (name); - XPCOM.nsEmbedCString_delete (path); + scope auto domain = new nsEmbedCString; + scope auto name = new nsEmbedCString; + scope auto path = new nsEmbedCString; + cookie.GetHost (cast(nsACString*)domain); + cookie.GetName (cast(nsACString*)name); + cookie.GetPath (cast(nsACString*)path); + rc = manager.Remove (cast(nsACString*)domain, cast(nsACString*)name, cast(nsACString*)path, 0); + //XPCOM.nsEmbedCString_delete (domain); + //XPCOM.nsEmbedCString_delete (name); + //XPCOM.nsEmbedCString_delete (path); if (rc !is XPCOM.NS_OK) error (rc); } cookie.Release (); - rc = enumerator.HasMoreElements (moreElements); + rc = enumerator.HasMoreElements (&moreElements); if (rc !is XPCOM.NS_OK) error (rc); } enumerator.Release (); @@ -235,16 +240,16 @@ } public void create (Composite parent, int style) { - mozDelegate = new MozillaDelegate (browser); + mozDelegate = new MozillaDelegate (super.browser); Display display = parent.getDisplay (); - int /*long*/[] result = new int /*long*/[1]; + //int /*long*/[] result = new int /*long*/[1]; if (!Initialized) { bool initLoaded = false; bool IsXULRunner = false; String greInitialized = System.getProperty (GRE_INITIALIZED); - if ("true".equals (greInitialized)) { //$NON-NLS-1$ + if ("true" == greInitialized)) { //$NON-NLS-1$ /* * Another browser has already initialized xulrunner in this process, * so just bind to it instead of trying to initialize a new one. @@ -252,7 +257,7 @@ Initialized = true; } String mozillaPath = System.getProperty (XULRUNNER_PATH); - if (mozillaPath is null) { + /+ if (mozillaPath is null) { try { String libName = mozDelegate.getSWTInitLibraryName (); Library.loadLibrary (libName); @@ -264,15 +269,15 @@ * points at a GRE. */ } - } else { - mozillaPath += SEPARATOR_OS + mozDelegate.getLibraryName (); + } else { +/ + mozillaPath ~= SEPARATOR_OS ~ mozDelegate.getLibraryName (); IsXULRunner = true; - } + // } if (initLoaded) { /* attempt to discover a XULRunner to use as the GRE */ - GREVersionRange range = new GREVersionRange (); - byte[] bytes = MozillaDelegate.wcsToMbcs (null, GRERANGE_LOWER, true); + GREVersionRange range; + //byte[] bytes = MozillaDelegate.wcsToMbcs (null, GRERANGE_LOWER, true); int /*long*/ lower = C.malloc (bytes.length); C.memmove (lower, bytes, bytes.length); range.lower = lower; @@ -1301,172 +1306,6 @@ return rc is XPCOM.NS_OK; } -void createCOMInterfaces () { - // Create each of the interfaces that this object implements - supports = new XPCOMObject (new int[] {2, 0, 0}) { - public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} - public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} - public int /*long*/ method2 (int /*long*/[] args) {return Release ();} - }; - - weakReference = new XPCOMObject (new int[] {2, 0, 0, 2}) { - public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} - public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} - public int /*long*/ method2 (int /*long*/[] args) {return Release ();} - public int /*long*/ method3 (int /*long*/[] args) {return QueryReferent (args[0], args[1]);} - }; - - webProgressListener = new XPCOMObject (new int[] {2, 0, 0, 4, 6, 3, 4, 3}) { - public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} - public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} - public int /*long*/ method2 (int /*long*/[] args) {return Release ();} - public int /*long*/ method3 (int /*long*/[] args) {return OnStateChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3]);} - public int /*long*/ method4 (int /*long*/[] args) {return OnProgressChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3], (int)/*64*/args[4], (int)/*64*/args[5]);} - public int /*long*/ method5 (int /*long*/[] args) {return OnLocationChange (args[0], args[1], args[2]);} - public int /*long*/ method6 (int /*long*/[] args) {return OnStatusChange (args[0], args[1], (int)/*64*/args[2], args[3]);} - public int /*long*/ method7 (int /*long*/[] args) {return OnSecurityChange (args[0], args[1], (int)/*64*/args[2]);} - }; - - webBrowserChrome = new XPCOMObject (new int[] {2, 0, 0, 2, 1, 1, 1, 1, 0, 2, 0, 1, 1}) { - public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} - public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} - public int /*long*/ method2 (int /*long*/[] args) {return Release ();} - public int /*long*/ method3 (int /*long*/[] args) {return SetStatus ((int)/*64*/args[0], args[1]);} - public int /*long*/ method4 (int /*long*/[] args) {return GetWebBrowser (args[0]);} - public int /*long*/ method5 (int /*long*/[] args) {return SetWebBrowser (args[0]);} - public int /*long*/ method6 (int /*long*/[] args) {return GetChromeFlags (args[0]);} - public int /*long*/ method7 (int /*long*/[] args) {return SetChromeFlags ((int)/*64*/args[0]);} - public int /*long*/ method8 (int /*long*/[] args) {return DestroyBrowserWindow ();} - public int /*long*/ method9 (int /*long*/[] args) {return SizeBrowserTo ((int)/*64*/args[0], (int)/*64*/args[1]);} - public int /*long*/ method10 (int /*long*/[] args) {return ShowAsModal ();} - public int /*long*/ method11 (int /*long*/[] args) {return IsWindowModal (args[0]);} - public int /*long*/ method12 (int /*long*/[] args) {return ExitModalEventLoop ((int)/*64*/args[0]);} - }; - - webBrowserChromeFocus = new XPCOMObject (new int[] {2, 0, 0, 0, 0}) { - public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} - public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} - public int /*long*/ method2 (int /*long*/[] args) {return Release ();} - public int /*long*/ method3 (int /*long*/[] args) {return FocusNextElement ();} - public int /*long*/ method4 (int /*long*/[] args) {return FocusPrevElement ();} - }; - - embeddingSiteWindow = new XPCOMObject (new int[] {2, 0, 0, 5, 5, 0, 1, 1, 1, 1, 1}) { - public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} - public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} - public int /*long*/ method2 (int /*long*/[] args) {return Release ();} - public int /*long*/ method3 (int /*long*/[] args) {return SetDimensions ((int)/*64*/args[0], (int)/*64*/args[1], (int)/*64*/args[2], (int)/*64*/args[3], (int)/*64*/args[4]);} - public int /*long*/ method4 (int /*long*/[] args) {return GetDimensions ((int)/*64*/args[0], args[1], args[2], args[3], args[4]);} - public int /*long*/ method5 (int /*long*/[] args) {return SetFocus ();} - public int /*long*/ method6 (int /*long*/[] args) {return GetVisibility (args[0]);} - public int /*long*/ method7 (int /*long*/[] args) {return SetVisibility ((int)/*64*/args[0]);} - public int /*long*/ method8 (int /*long*/[] args) {return GetTitle (args[0]);} - public int /*long*/ method9 (int /*long*/[] args) {return SetTitle (args[0]);} - public int /*long*/ method10 (int /*long*/[] args) {return GetSiteWindow (args[0]);} - }; - - interfaceRequestor = new XPCOMObject (new int[] {2, 0, 0, 2} ){ - public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} - public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} - public int /*long*/ method2 (int /*long*/[] args) {return Release ();} - public int /*long*/ method3 (int /*long*/[] args) {return GetInterface (args[0], args[1]);} - }; - - supportsWeakReference = new XPCOMObject (new int[] {2, 0, 0, 1}) { - public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} - public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} - public int /*long*/ method2 (int /*long*/[] args) {return Release ();} - public int /*long*/ method3 (int /*long*/[] args) {return GetWeakReference (args[0]);} - }; - - contextMenuListener = new XPCOMObject (new int[] {2, 0, 0, 3}) { - public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} - public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} - public int /*long*/ method2 (int /*long*/[] args) {return Release ();} - public int /*long*/ method3 (int /*long*/[] args) {return OnShowContextMenu ((int)/*64*/args[0], args[1], args[2]);} - }; - - uriContentListener = new XPCOMObject (new int[] {2, 0, 0, 2, 5, 3, 4, 1, 1, 1, 1}) { - public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} - public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} - public int /*long*/ method2 (int /*long*/[] args) {return Release ();} - public int /*long*/ method3 (int /*long*/[] args) {return OnStartURIOpen (args[0], args[1]);} - public int /*long*/ method4 (int /*long*/[] args) {return DoContent (args[0], (int)/*64*/args[1], args[2], args[3], args[4]);} - public int /*long*/ method5 (int /*long*/[] args) {return IsPreferred (args[0], args[1], args[2]);} - public int /*long*/ method6 (int /*long*/[] args) {return CanHandleContent (args[0], (int)/*64*/args[1], args[2], args[3]);} - public int /*long*/ method7 (int /*long*/[] args) {return GetLoadCookie (args[0]);} - public int /*long*/ method8 (int /*long*/[] args) {return SetLoadCookie (args[0]);} - public int /*long*/ method9 (int /*long*/[] args) {return GetParentContentListener (args[0]);} - public int /*long*/ method10 (int /*long*/[] args) {return SetParentContentListener (args[0]);} - }; - - tooltipListener = new XPCOMObject (new int[] {2, 0, 0, 3, 0}) { - public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} - public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} - public int /*long*/ method2 (int /*long*/[] args) {return Release ();} - public int /*long*/ method3 (int /*long*/[] args) {return OnShowTooltip ((int)/*64*/args[0], (int)/*64*/args[1], args[2]);} - public int /*long*/ method4 (int /*long*/[] args) {return OnHideTooltip ();} - }; - - domEventListener = new XPCOMObject (new int[] {2, 0, 0, 1}) { - public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} - public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} - public int /*long*/ method2 (int /*long*/[] args) {return Release ();} - public int /*long*/ method3 (int /*long*/[] args) {return HandleEvent (args[0]);} - }; -} - -void disposeCOMInterfaces () { - if (supports !is null) { - supports.dispose (); - supports = null; - } - if (weakReference !is null) { - weakReference.dispose (); - weakReference = null; - } - if (webProgressListener !is null) { - webProgressListener.dispose (); - webProgressListener = null; - } - if (webBrowserChrome !is null) { - webBrowserChrome.dispose (); - webBrowserChrome = null; - } - if (webBrowserChromeFocus !is null) { - webBrowserChromeFocus.dispose (); - webBrowserChromeFocus = null; - } - if (embeddingSiteWindow !is null) { - embeddingSiteWindow.dispose (); - embeddingSiteWindow = null; - } - if (interfaceRequestor !is null) { - interfaceRequestor.dispose (); - interfaceRequestor = null; - } - if (supportsWeakReference !is null) { - supportsWeakReference.dispose (); - supportsWeakReference = null; - } - if (contextMenuListener !is null) { - contextMenuListener.dispose (); - contextMenuListener = null; - } - if (uriContentListener !is null) { - uriContentListener.dispose (); - uriContentListener = null; - } - if (tooltipListener !is null) { - tooltipListener.dispose (); - tooltipListener = null; - } - if (domEventListener !is null) { - domEventListener.dispose (); - domEventListener = null; - } -} - public bool execute (String script) { if (awaitingNavigate) return false; diff -r b72d84d1ba95 -r 16ba3d9cb209 dwt/internal/mozilla/nsIDOMSerializer.d --- a/dwt/internal/mozilla/nsIDOMSerializer.d Wed Aug 13 18:49:58 2008 -0700 +++ b/dwt/internal/mozilla/nsIDOMSerializer.d Thu Aug 14 20:25:29 2008 -0700 @@ -7,11 +7,11 @@ import dwt.internal.mozilla.nsIDOMNode; import dwt.internal.mozilla.nsStringAPI; -const char[] NS_IDOMSERIALIZER_IID_STR = "9fd4ba15-e67c-4c98-b52c-7715f62c9196"; +const char[] NS_IDOMSERIALIZER_IID_STR = "a6cf9123-15b3-11d2-932e-00805f8add32"; const nsIID NS_IDOMSERIALIZER_IID= - {0x9fd4ba15, 0xe67c, 0x4c98, - [ 0xb5, 0x2c, 0x77, 0x15, 0xf6, 0x2c, 0x91, 0x96 ]}; + {0xa6cf9123, 0x15b3, 0x11d2, + [ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 ]}; extern(System) @@ -20,8 +20,8 @@ static const char[] IID_STR = NS_IDOMSERIALIZER_IID_STR; static const nsIID IID = NS_IDOMSERIALIZER_IID; - nsresult SerializeToString(nsIDOMNode root, nsAString * _retval); - nsresult SerializeToStream(nsIDOMNode root, nsIOutputStream stream, nsACString * charset); + nsresult SerializeToString(nsIDOMNode root, PRUnichar ** _retval); + nsresult SerializeToStream(nsIDOMNode root, nsIOutputStream stream, char* charset); } diff -r b72d84d1ba95 -r 16ba3d9cb209 dwt/internal/mozilla/nsIDOMSerializer_1_7.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla/nsIDOMSerializer_1_7.d Thu Aug 14 20:25:29 2008 -0700 @@ -0,0 +1,27 @@ +module dwt.internal.mozilla.nsIDOMSerializer; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsIOutputStream; +import dwt.internal.mozilla.nsIDOMNode; +import dwt.internal.mozilla.nsStringAPI; + +const char[] NS_IDOMSERIALIZER_IID_STR = "9fd4ba15-e67c-4c98-b52c-7715f62c9196"; + +const nsIID NS_IDOMSERIALIZER_IID= + {0x9fd4ba15, 0xe67c, 0x4c98, + [ 0xb5, 0x2c, 0x77, 0x15, 0xf6, 0x2c, 0x91, 0x96 ]}; + +extern(System) + +interface nsIDOMSerializer : nsISupports { + + static const char[] IID_STR = NS_IDOMSERIALIZER_IID_STR; + static const nsIID IID = NS_IDOMSERIALIZER_IID; + + nsresult SerializeToString(nsIDOMNode root, nsAString * _retval); + nsresult SerializeToStream(nsIDOMNode root, nsIOutputStream stream, nsACString * charset); + +} +