changeset 356:8ebacc5c07dc

Fixes for TANGOSVN r4235 -- still some warnings but builds
author John Reimer <terminal.node@gmail.com>
date Sun, 04 Jan 2009 02:47:54 -0500
parents fe52206e0ece
children a229cf799859
files dwt/browser/Mozilla.d dwt/dwthelper/FileInputStream.d dwt/dwthelper/FileOutputStream.d dwt/dwthelper/InflaterInputStream.d dwt/dwthelper/utils.d dwt/program/Program.d
diffstat 6 files changed, 97 insertions(+), 242 deletions(-) [+]
line wrap: on
line diff
--- a/dwt/browser/Mozilla.d	Sun Dec 14 02:31:38 2008 -0500
+++ b/dwt/browser/Mozilla.d	Sun Jan 04 02:47:54 2009 -0500
@@ -14,7 +14,7 @@
 
 import dwt.dwthelper.utils;
 
-import tango.text.locale.Core;  // Necessary for Region/Culture/Locale code
+import tango.text.locale.Core;
 import tango.io.Stdout;
 import tango.text.convert.Format;
 import tango.io.Console;
@@ -202,32 +202,25 @@
                 int rc = XPCOM.NS_GetServiceManager (&serviceManager);
                 if (rc !is XPCOM.NS_OK) error (rc, __FILE__, __LINE__);
                 if (serviceManager is null) error (XPCOM.NS_NOINTERFACE, __FILE__, __LINE__);
-                //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.ptr, &nsICookieManager.IID, cast(void**)&manager);
                 if (rc !is XPCOM.NS_OK) error (rc, __FILE__, __LINE__);
                 if (manager is null) error (XPCOM.NS_NOINTERFACE, __FILE__, __LINE__);
                 serviceManager.Release ();
 
-                //nsICookieManager manager = new nsICookieManager (result[0]);
-                //result[0] = 0;
                 nsISimpleEnumerator enumerator;
                 rc = manager.GetEnumerator (&enumerator);
                 if (rc !is XPCOM.NS_OK) error (rc, __FILE__, __LINE__);
                 manager.Release ();
 
-                //nsISimpleEnumerator enumerator = new nsISimpleEnumerator (result[0]);
-                PRBool moreElements; /* PRBool */
+                PRBool moreElements;
                 rc = enumerator.HasMoreElements (&moreElements);
                 if (rc !is XPCOM.NS_OK) error (rc, __FILE__, __LINE__);
                 while (moreElements !is 0) {
-                    //result[0] = 0;
                     nsICookie cookie;
                     rc = enumerator.GetNext (cast(nsISupports*)&cookie);
                     if (rc !is XPCOM.NS_OK) error (rc, __FILE__, __LINE__);
-                    //nsICookie cookie = new nsICookie (result[0]);
                     PRUint64 expires;
                     rc = cookie.GetExpires (&expires);
                     if (expires is 0) {
@@ -239,9 +232,6 @@
                         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, __FILE__, __LINE__);
                     }
                     cookie.Release ();
@@ -258,7 +248,6 @@
     mozDelegate = new MozillaDelegate (super.browser);
     Display display = parent.getDisplay ();
 
-    //int /*long*/[] result = new int /*long*/[1];
     if (!Initialized) {
         bool initLoaded = false;
         bool IsXULRunner = false;
@@ -273,22 +262,8 @@
         }
         String mozillaPath = System.getProperty (XULRUNNER_PATH);
         if (mozillaPath is null) {
-            // we don't need to load an initial library in DWT, so set to "true"
+            // we don't need to load an initial library in D, so set to "true"
             initLoaded = true;
-/+
-        if (mozillaPath is null) {
-            try {
-                String libName = mozDelegate.getSWTInitLibraryName ();
-                Library.loadLibrary (libName);
-                initLoaded = true;
-            } catch (UnsatisfiedLinkError e) {
-                /* 
-                * If this library failed to load then do not attempt to detect a
-                * xulrunner to use.  The Browser may still be usable if MOZILLA_FIVE_HOME
-                * points at a GRE. 
-                */
-            }
-+/
         } else {
             mozillaPath ~= SEPARATOR_OS ~ mozDelegate.getLibraryName ();
             IsXULRunner = true;
@@ -297,46 +272,29 @@
         if (initLoaded) {
             /* attempt to discover a XULRunner to use as the GRE */
             XPCOMInit.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 = GRERANGE_LOWER.ptr;
             range.lowerInclusive = LowerRangeInclusive;
 
-            //bytes = MozillaDelegate.wcsToMbcs (null, GRERANGE_UPPER, true);
-            //int /*long*/ upper = C.malloc (bytes.length);
-            //C.memmove (upper, bytes, bytes.length);
             range.upper = GRERANGE_UPPER.ptr;
             range.upperInclusive = UpperRangeInclusive;
 
-            //int length = XPCOMInit.PATH_MAX;
-            //int /*long*/ greBuffer = C.malloc (length);
             char[] greBuffer = new char[XPCOMInit.PATH_MAX];
-            //int /*long*/ propertiesPtr = C.malloc (2 * C.PTR_SIZEOF);
+
             int rc = XPCOMInit.GRE_GetGREPathWithProperties (&range, 1, null, 0, greBuffer.ptr, greBuffer.length);
 
             /*
              * A XULRunner was not found that supports wrapping of XPCOM handles as JavaXPCOM objects.
              * Drop the lower version bound and try to detect an earlier XULRunner installation.
              */
+
             if (rc !is XPCOM.NS_OK) {
-                //C.free (lower);
-                //bytes = MozillaDelegate.wcsToMbcs (null, GRERANGE_LOWER_FALLBACK, true);
-                //lower = C.malloc (bytes.length);
-                //C.memmove (lower, bytes, bytes.length);
                 range.lower = GRERANGE_LOWER_FALLBACK.ptr;
                 rc = XPCOMInit.GRE_GetGREPathWithProperties (&range, 1, null, 0, greBuffer.ptr, greBuffer.length);
             }
 
-            //C.free (lower);
-            //C.free (upper);
-            //C.free (propertiesPtr);
             if (rc is XPCOM.NS_OK) {
                 /* indicates that a XULRunner was found */
-                //length = C.strlen (greBuffer);
-                //bytes = new byte[length];
-                //C.memmove (bytes, greBuffer, length);
-                //mozillaPath = new String (MozillaDelegate.mbcsToWcs (null, bytes));
                 mozillaPath = greBuffer;
                 IsXULRunner = mozillaPath.length > 0;
 
@@ -348,8 +306,8 @@
                  * One case where this will fail is attempting to use a 64-bit xulrunner while swt
                  * is running in 32-bit mode, or vice versa.
                  */
+
                 if (IsXULRunner) {
-                    // byte[] path = MozillaDelegate.wcsToMbcs (null, mozillaPath, true);
                     rc = XPCOMInit.XPCOMGlueStartup (mozillaPath.ptr);
                     if (rc !is XPCOM.NS_OK) {
                         mozillaPath = mozillaPath.substring (0, mozillaPath.lastIndexOf (SEPARATOR_OS));
@@ -357,12 +315,10 @@
                         
                         /* attempt to XPCOMGlueStartup the GRE pointed at by MOZILLA_FIVE_HOME */
                         auto ptr = Environment.get(XPCOM.MOZILLA_FIVE_HOME);
+
                         if (ptr is null) {
                             IsXULRunner = false;
                         } else {
-                            //length = C.strlen (ptr);
-                            //byte[] buffer = new byte[length];
-                            //C.memmove (buffer, ptr, length);
                             mozillaPath = ptr;
                             /*
                              * Attempting to XPCOMGlueStartup a mozilla-based GRE !is xulrunner can
@@ -387,26 +343,11 @@
                     }
                 }
             }
-            //C.free (greBuffer);
         }
 
         if (IsXULRunner) {
             if (Device.DEBUG) Cerr ("XULRunner path: ") (mozillaPath).newline; //$NON-NLS-1$
-/+
-            try {
-                Library.loadLibrary ("swt-xulrunner"); //$NON-NLS-1$
-            } catch (UnsatisfiedLinkError e) {
-                DWT.error (DWT.ERROR_NO_HANDLES, e);
-            }
-            
-            byte[] path = MozillaDelegate.wcsToMbcs (null, mozillaPath, true);
-            int rc = XPCOM.XPCOMGlueStartup (path);  
 
-            if (rc !is XPCOM.NS_OK) {
-                browser.dispose ();
-                error (rc, __FILE__, __LINE__);
-            }
-+/          // No need for double layer initialization in DWT; XPCOMInit was glued
             XPCOMWasGlued = true;
 
             /*
@@ -426,9 +367,6 @@
             /* attempt to use the GRE pointed at by MOZILLA_FIVE_HOME */
             auto mozFiveHome = Environment.get(XPCOM.MOZILLA_FIVE_HOME);
             if (mozFiveHome !is null) {
-                //int length = C.strlen (ptr);
-                //byte[] buffer = new byte[length];
-                //C.memmove (buffer, ptr, length);
                 mozillaPath = mozFiveHome;
             } else {
                 browser.dispose ();
@@ -446,34 +384,12 @@
                 browser.dispose ();
                 DWT.error (DWT.ERROR_NO_HANDLES, null, " [Mozilla GTK2 required (GTK1.2 detected)]"); //$NON-NLS-1$                         
             }
-/+
-            try {
-                Library.loadLibrary ("swt-mozilla"); //$NON-NLS-1$
-            } catch (UnsatisfiedLinkError e) {
-                try {
-                    /* 
-                     * The initial loadLibrary attempt may have failed as a result of the user's
-                     * system not having libstdc++.so.6 installed, so try to load the alternate
-                     * swt mozilla library that depends on libswtc++.so.5 instead.
-                     */
-                    Library.loadLibrary ("swt-mozilla-gcc3"); //$NON-NLS-1$
-                } catch (UnsatisfiedLinkError ex) {
-                    browser.dispose ();
-                    /*
-                     * Print the error from the first failed attempt since at this point it's
-                     * known that the failure was not due to the libstdc++.so.6 dependency.
-                     */
-                    DWT.error (DWT.ERROR_NO_HANDLES, e, " [MOZILLA_FIVE_HOME='" + mozillaPath + "']"); //$NON-NLS-1$ //$NON-NLS-2$
-                }
-            } 
-+/
         }
 
         if (!Initialized) {
             nsILocalFile localFile;
             scope auto pathString = new nsEmbedString (mozillaPath.toString16());
             nsresult rc = XPCOM.NS_NewLocalFile (cast(nsAString*)pathString, 1, &localFile);
-            //pathString.dispose ();
             if (rc !is XPCOM.NS_OK) {
                 browser.dispose ();
                 error (rc, __FILE__, __LINE__);
@@ -486,7 +402,6 @@
             LocationProvider = new AppFileLocProvider (mozillaPath);
             LocationProvider.AddRef ();
 
-            //nsIFile localFile = new nsILocalFile (retVal[0]);
             nsIDirectoryServiceProvider directoryServiceProvider;
             rc = LocationProvider.QueryInterface( &nsIDirectoryServiceProvider.IID, cast(void**)&directoryServiceProvider);
             if (rc !is XPCOM.NS_OK) {
@@ -505,35 +420,7 @@
                 System.setProperty (XULRUNNER_PATH, mozillaPath);
             }
         }
-/+
-        /* If JavaXPCOM is detected then attempt to initialize it with the XULRunner being used */
-        if (IsXULRunner) {
-            try {
-                Class clazz = Class.forName ("org.mozilla.xpcom.Mozilla"); //$NON-NLS-1$
-                Method method = clazz.getMethod ("getInstance", new Class[0]); //$NON-NLS-1$
-                Object mozilla = method.invoke (null, new Object[0]);
-                method = clazz.getMethod ("getComponentManager", new Class[0]); //$NON-NLS-1$
-                try {
-                    method.invoke (mozilla, new Object[0]);
-                } catch (InvocationTargetException e) {
-                    /* indicates that JavaXPCOM has not been initialized yet */
-                    Class fileClass = Class.forName ("java.io.File"); //$NON-NLS-1$
-                    method = clazz.getMethod ("initialize", new Class[] {fileClass}); //$NON-NLS-1$
-                    Constructor constructor = fileClass.getDeclaredConstructor (new Class[] {String.class});
-                    Object argument = constructor.newInstance (new Object[] {mozillaPath});
-                    method.invoke (mozilla, new Object[] {argument});
-                }
-            } catch (ClassNotFoundException e) {
-                /* JavaXPCOM is not on the classpath */
-            } catch (NoSuchMethodException e) {
-                /* the JavaXPCOM on the classpath does not implement initialize() */
-            } catch (IllegalArgumentException e) {
-            } catch (IllegalAccessException e) {
-            } catch (InvocationTargetException e) {
-            } catch (InstantiationException e) {
-            }
-        }
-+/
+
         nsIComponentManager componentManager;
         int rc = XPCOM.NS_GetComponentManager (&componentManager);
         if (rc !is XPCOM.NS_OK) {
@@ -545,8 +432,6 @@
             error (XPCOM.NS_NOINTERFACE, __FILE__, __LINE__);
         }
         
-        //nsIComponentManager componentManager = new nsIComponentManager (result[0]);
-        //result[0] = 0;
         if (mozDelegate.needsSpinup ()) {
             /* nsIAppShell is discontinued as of xulrunner 1.9, so do not fail if it is not found */
             rc = componentManager.CreateInstance (&XPCOM.NS_APPSHELL_CID, null, &nsIAppShell.IID, cast(void**)&AppShell);
@@ -560,7 +445,6 @@
                     error (XPCOM.NS_NOINTERFACE, __FILE__, __LINE__);
                 }
     
-                //AppShell = new nsIAppShell (result[0]);
                 rc = AppShell.Create (null, null);
                 if (rc !is XPCOM.NS_OK) {
                     browser.dispose ();
@@ -572,7 +456,6 @@
                     error (rc, __FILE__, __LINE__);
                 }
             }
-            //result[0] = 0;
         }
 
         WindowCreator = new WindowCreator2;
@@ -589,9 +472,6 @@
             error (XPCOM.NS_NOINTERFACE, __FILE__, __LINE__);
         }
         
-        //nsIServiceManager serviceManager = new nsIServiceManager (result[0]);
-        //result[0] = 0;      
-        //byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_WINDOWWATCHER_CONTRACTID, true);
         nsIWindowWatcher windowWatcher;
         rc = serviceManager.GetServiceByContractID (XPCOM.NS_WINDOWWATCHER_CONTRACTID.ptr, &nsIWindowWatcher.IID, cast(void**)&windowWatcher);
         if (rc !is XPCOM.NS_OK) {
@@ -603,8 +483,6 @@
             error (XPCOM.NS_NOINTERFACE, __FILE__, __LINE__);       
         }
 
-        //nsIWindowWatcher windowWatcher = new nsIWindowWatcher (result[0]);
-        //result[0] = 0;
         rc = windowWatcher.SetWindowCreator (cast(nsIWindowCreator)WindowCreator);
         if (rc !is XPCOM.NS_OK) {
             browser.dispose ();
@@ -612,10 +490,8 @@
         }
         windowWatcher.Release ();
 
-        /* compute the profile directory and set it on the AppFileLocProvider */
         if (LocationProvider !is null) {
             nsIDirectoryService directoryService;
-            //byte[] buffer = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_DIRECTORYSERVICE_CONTRACTID, true);
             rc = serviceManager.GetServiceByContractID (XPCOM.NS_DIRECTORYSERVICE_CONTRACTID.ptr, &nsIDirectoryService.IID, cast(void**)&directoryService);
             if (rc !is XPCOM.NS_OK) {
                 browser.dispose ();
@@ -626,8 +502,6 @@
                 error (XPCOM.NS_NOINTERFACE, __FILE__, __LINE__);
             }
 
-            //nsIDirectoryService directoryService = new nsIDirectoryService (result[0]);
-            //result[0] = 0;
             nsIProperties properties;
             rc = directoryService.QueryInterface (&nsIProperties.IID, cast(void**)&properties);
             if (rc !is XPCOM.NS_OK) {
@@ -640,9 +514,6 @@
             }
             directoryService.Release ();
 
-            //nsIProperties properties = new nsIProperties (result[0]);
-            //result[0] = 0;
-            //buffer = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_APP_APPLICATION_REGISTRY_DIR, true);
             nsIFile profileDir;
             rc = properties.Get (XPCOM.NS_APP_APPLICATION_REGISTRY_DIR.ptr, &nsIFile.IID, cast(void**)&profileDir);
             if (rc !is XPCOM.NS_OK) {
@@ -655,26 +526,20 @@
             }
             properties.Release ();
 
-            //nsIFile profileDir = new nsIFile (result[0]);
-            //result[0] = 0;
             scope auto path = new nsEmbedCString;
             rc = profileDir.GetNativePath (cast(nsACString*)path);
             if (rc !is XPCOM.NS_OK) {
                 browser.dispose ();
                 error (rc, __FILE__, __LINE__);
             }
-            //int length = XPCOM.nsEmbedCString_Length (path);
-            //int /*long*/ ptr = XPCOM.nsEmbedCString_get (path);
-            //buffer = new byte [length];
-            //XPCOM.memmove (buffer, ptr, length);
+
             String profilePath = path.toString() ~ PROFILE_DIR;
             LocationProvider.setProfilePath (profilePath);
             LocationProvider.isXULRunner = IsXULRunner;
-            //XPCOM.nsEmbedCString_delete (path);
+
             profileDir.Release ();
 
             /* notify observers of a new profile directory being used */
-            //buffer = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_OBSERVER_CONTRACTID, true);
             nsIObserverService observerService;
             rc = serviceManager.GetServiceByContractID (XPCOM.NS_OBSERVER_CONTRACTID.ptr, &nsIObserverService.IID, cast(void**)&observerService);
             if (rc !is XPCOM.NS_OK) {
@@ -686,19 +551,13 @@
                 error (XPCOM.NS_NOINTERFACE, __FILE__, __LINE__);
             }
 
-            //nsIObserverService observerService = new nsIObserverService (result[0]);
-            //result[0] = 0;
-            //buffer = MozillaDelegate.wcsToMbcs (null, PROFILE_DO_CHANGE, true);
-            //length = STARTUP.length ();
-            //char[] chars = new char [length + 1];
-            //STARTUP.getChars (0, length, chars, 0);
             wchar* chars = STARTUP.toString16().toString16z();
             rc = observerService.NotifyObservers (null, PROFILE_DO_CHANGE.ptr, chars);
             if (rc !is XPCOM.NS_OK) {
                 browser.dispose ();
                 error (rc, __FILE__, __LINE__);
             }
-            //buffer = MozillaDelegate.wcsToMbcs (null, PROFILE_AFTER_CHANGE, true);
+
             rc = observerService.NotifyObservers (null, PROFILE_AFTER_CHANGE.ptr, chars);
             if (rc !is XPCOM.NS_OK) {
                 browser.dispose ();
@@ -712,7 +571,7 @@
          * and charset.  The fix for this is to set mozilla's locale and charset
          * preference values according to the user's current locale and charset.
          */
-        //aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_PREFSERVICE_CONTRACTID, true);
+
         nsIPrefService prefService;
         rc = serviceManager.GetServiceByContractID (XPCOM.NS_PREFSERVICE_CONTRACTID.ptr, &nsIPrefService.IID, cast(void**)&prefService);
         serviceManager.Release ();
@@ -725,8 +584,6 @@
             error (XPCOM.NS_NOINTERFACE, __FILE__, __LINE__);
         }
 
-        //nsIPrefService prefService = new nsIPrefService (result[0]);
-        //result[0] = 0;
         char[1] buffer = new char[1];
         nsIPrefBranch prefBranch;
         rc = prefService.GetBranch (buffer.ptr, &prefBranch);    /* empty buffer denotes root preference level */
@@ -740,9 +597,6 @@
             error (XPCOM.NS_NOINTERFACE, __FILE__, __LINE__);
         }
 
-        //nsIPrefBranch prefBranch = new nsIPrefBranch (result[0]);
-        //result[0] = 0;
-
         /* get Mozilla's current locale preference value */
         String prefLocales = null;
         nsIPrefLocalizedString localizedString = null;
@@ -761,8 +615,6 @@
                 browser.dispose ();
                 error (XPCOM.NS_NOINTERFACE, __FILE__, __LINE__);
             }
-            //localizedString = new nsIPrefLocalizedString (result[0]);
-            //result[0] = 0;
             PRUnichar* tmpChars;
             rc = localizedString.ToString (&tmpChars);
             if (rc !is XPCOM.NS_OK) {
@@ -774,22 +626,18 @@
                 error (XPCOM.NS_NOINTERFACE, __FILE__, __LINE__);
             }
             int span = XPCOM.strlen_PRUnichar (tmpChars);
-            //char[] dest = new char[length];
-            //XPCOM.memmove (dest, result[0], length * 2);
             prefLocales = Utf.toString(tmpChars[0 .. span]) ~ TOKENIZER_LOCALE;
         }
-        //result[0] = 0;
 
         /*
          * construct the new locale preference value by prepending the
          * user's current locale and language to the original value 
          */
-        //Culture locale = Culture.current;
-        //Region region = Region.current;
-        //Locale locale = Locale.getDefault ();
+
         String language = Culture.current.twoLetterLanguageName ();
         String country = Region.current.twoLetterRegionName ();
         String stringBuffer = language.dup;
+
         stringBuffer ~= SEPARATOR_LOCALE;
         stringBuffer ~= country.toLowerCase ();
         stringBuffer ~= TOKENIZER_LOCALE;
@@ -819,11 +667,7 @@
         if (!newLocales.equals (prefLocales)) {
             /* write the new locale value */
             newLocales = newLocales.substring (0, newLocales.length () - TOKENIZER_LOCALE.length ()); /* remove trailing tokenizer */
-            //int span = newLocales.length ();
-            //char[] charBuffer = new char[span + 1];
-            //newLocales.getChars (0, span, charBuffer, 0);
             if (localizedString is null) {
-                //byte[] contractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_PREFLOCALIZEDSTRING_CONTRACTID, true);
                 rc = componentManager.CreateInstanceByContractID (XPCOM.NS_PREFLOCALIZEDSTRING_CONTRACTID.ptr, null, &nsIPrefLocalizedString.IID, cast(void**)&localizedString);
                 if (rc !is XPCOM.NS_OK) {
                     browser.dispose ();
@@ -833,8 +677,6 @@
                     browser.dispose ();
                     error (XPCOM.NS_NOINTERFACE, __FILE__, __LINE__);
                 }
-                //localizedString = new nsIPrefLocalizedString (result[0]);
-                //result[0] = 0;
             }
             localizedString.SetDataWithLength (newLocales.length, newLocales.toString16().toString16z());
             rc = prefBranch.SetComplexValue (PREFERENCE_LANGUAGES.ptr, &nsIPrefLocalizedString.IID, cast(nsISupports)localizedString);
@@ -846,7 +688,6 @@
 
         /* get Mozilla's current charset preference value */
         String prefCharset = null;
-        //buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_CHARSET, true);
         rc = prefBranch.GetComplexValue (PREFERENCE_CHARSET.ptr, &nsIPrefLocalizedString.IID, cast(void**)&localizedString);
         /* 
          * Feature of Debian.  For some reason attempting to query for the current charset
@@ -861,8 +702,6 @@
                 browser.dispose ();
                 error (XPCOM.NS_NOINTERFACE, __FILE__, __LINE__);
             }
-            //localizedString = new nsIPrefLocalizedString (result[0]);
-            //result[0] = 0;
             PRUnichar* tmpChar;
             rc = localizedString.ToString (&tmpChar);
             if (rc !is XPCOM.NS_OK) {
@@ -874,20 +713,13 @@
                 error (XPCOM.NS_NOINTERFACE, __FILE__, __LINE__);
             }
             int span = XPCOM.strlen_PRUnichar (tmpChar);
-            //char[] dest = new char[length];
-            //XPCOM.memmove (dest, result[0], length * 2);
             prefCharset = Utf.toString(tmpChar[0 .. span]);
         }
-        //result[0] = 0;
 
         String newCharset = System.getProperty ("file.encoding");   // $NON-NLS-1$
         if (!newCharset.equals (prefCharset)) {
             /* write the new charset value */
-            //int length = newCharset.length ();
-            //char[] charBuffer = new char[length + 1];
-            //newCharset.getChars (0, length, charBuffer, 0);
             if (localizedString is null) {
-                //byte[] contractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_PREFLOCALIZEDSTRING_CONTRACTID, true);
                 rc = componentManager.CreateInstanceByContractID (XPCOM.NS_PREFLOCALIZEDSTRING_CONTRACTID.ptr, null, &nsIPrefLocalizedString.IID, cast(void**)&localizedString);
                 if (rc !is XPCOM.NS_OK) {
                     browser.dispose ();
@@ -897,8 +729,6 @@
                     browser.dispose ();
                     error (XPCOM.NS_NOINTERFACE, __FILE__, __LINE__);
                 }
-                //localizedString = new nsIPrefLocalizedString (result[0]);
-                //result[0] = 0;
             }
             localizedString.SetDataWithLength (newCharset.length, newCharset.toString16().toString16z());
             rc = prefBranch.SetComplexValue (PREFERENCE_CHARSET.ptr, &nsIPrefLocalizedString.IID, cast(nsISupports)localizedString);
@@ -911,6 +741,7 @@
         */
 
         // NOTE: in dwt, these properties don't exist so both keys will return null
+        // (which appears to be ok in this situaion)
         String proxyHost = System.getProperty (PROPERTY_PROXYHOST);
         String proxyPortString = System.getProperty (PROPERTY_PROXYPORT);
 
@@ -925,44 +756,31 @@
         }
 
         if (proxyHost !is null) {
-            //byte[] contractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_PREFLOCALIZEDSTRING_CONTRACTID, true);
             rc = componentManager.CreateInstanceByContractID (XPCOM.NS_PREFLOCALIZEDSTRING_CONTRACTID.ptr, null, &nsIPrefLocalizedString.IID, cast(void**)&localizedString);
             if (rc !is XPCOM.NS_OK) error (rc, __FILE__, __LINE__);
             if (localizedString is null) error (XPCOM.NS_NOINTERFACE, __FILE__, __LINE__);
 
-            //localizedString = new nsIPrefLocalizedString (result[0]);
-            //result[0] = 0;
-            //int length = proxyHost.length ();
-            //char[] charBuffer = new char[length + 1];
-            //proxyHost.getChars (0, length, charBuffer, 0);
             rc = localizedString.SetDataWithLength (proxyHost.length, proxyHost.toString16().toString16z());
             if (rc !is XPCOM.NS_OK) error (rc, __FILE__, __LINE__);
-            //buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_PROXYHOST_FTP, true);
             rc = prefBranch.SetComplexValue (PREFERENCE_PROXYHOST_FTP.ptr, &nsIPrefLocalizedString.IID, cast(nsISupports)localizedString);
             if (rc !is XPCOM.NS_OK) error (rc, __FILE__, __LINE__);
-            //buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_PROXYHOST_HTTP, true);
             rc = prefBranch.SetComplexValue (PREFERENCE_PROXYHOST_HTTP.ptr, &nsIPrefLocalizedString.IID, cast(nsISupports)localizedString);
             if (rc !is XPCOM.NS_OK) error (rc, __FILE__, __LINE__);
-            //buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_PROXYHOST_SSL, true);
             rc = prefBranch.SetComplexValue (PREFERENCE_PROXYHOST_SSL.ptr, &nsIPrefLocalizedString.IID, cast(nsISupports)localizedString);
             if (rc !is XPCOM.NS_OK) error (rc, __FILE__, __LINE__);
             localizedString.Release ();
         }
 
         if (port !is -1) {
-            //buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_PROXYPORT_FTP, true);
             rc = prefBranch.SetIntPref (PREFERENCE_PROXYPORT_FTP.ptr, port);
             if (rc !is XPCOM.NS_OK) error (rc, __FILE__, __LINE__);
-            //buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_PROXYPORT_HTTP, true);
             rc = prefBranch.SetIntPref (PREFERENCE_PROXYPORT_HTTP.ptr, port);
             if (rc !is XPCOM.NS_OK) error (rc, __FILE__, __LINE__);
-            //buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_PROXYPORT_SSL, true);
             rc = prefBranch.SetIntPref (PREFERENCE_PROXYPORT_SSL.ptr, port);
             if (rc !is XPCOM.NS_OK) error (rc, __FILE__, __LINE__);
         }
 
         if (proxyHost !is null || port !is -1) {
-            //buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_PROXYTYPE, true);
             rc = prefBranch.SetIntPref (PREFERENCE_PROXYTYPE.ptr, 1);
             if (rc !is XPCOM.NS_OK) error (rc, __FILE__, __LINE__);
         }
@@ -974,7 +792,6 @@
         * is responsible for creating the new Browser and Shell in an OpenWindowListener,
         * they should decide whether the new window is unwelcome or not and act accordingly. 
         */
-        //buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_DISABLEOPENDURINGLOAD, true);
         rc = prefBranch.SetBoolPref (PREFERENCE_DISABLEOPENDURINGLOAD.ptr, 0);
         if (rc !is XPCOM.NS_OK) {
             browser.dispose ();
@@ -982,7 +799,6 @@
         }
 
         /* Ensure that the status text can be set through means like javascript */ 
-        //buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_DISABLEWINDOWSTATUSCHANGE, true);
         rc = prefBranch.SetBoolPref (PREFERENCE_DISABLEWINDOWSTATUSCHANGE.ptr, 0);
         if (rc !is XPCOM.NS_OK) {
             browser.dispose ();
@@ -1005,11 +821,7 @@
             error (XPCOM.NS_NOINTERFACE, __FILE__, __LINE__);
         }
         
-        //nsIComponentRegistrar componentRegistrar = new nsIComponentRegistrar (result[0]);
-        //result[0] = 0;
-        //aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_PROMPTSERVICE_CONTRACTID, true);
         String aClassName = "Prompt Service"; 
-        //byte[] aClassName = MozillaDelegate.wcsToMbcs (null, "Prompt Service", true); //$NON-NLS-1$
 
         rc = componentRegistrar.RegisterFactory (&XPCOM.NS_PROMPTSERVICE_CID, aClassName.ptr, XPCOM.NS_PROMPTSERVICE_CONTRACTID.ptr, cast(nsIFactory)factory);
 
@@ -1028,9 +840,7 @@
         */
         DownloadFactory downloadFactory = new DownloadFactory ();
         downloadFactory.AddRef ();
-        //aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_DOWNLOAD_CONTRACTID, true);
         aClassName = "Download";
-        //aClassName = MozillaDelegate.wcsToMbcs (null, "Download", true); //$NON-NLS-1$
         rc = componentRegistrar.RegisterFactory (&XPCOM.NS_DOWNLOAD_CID, aClassName.ptr, XPCOM.NS_DOWNLOAD_CONTRACTID.ptr, cast(nsIFactory)downloadFactory);
         if (rc !is XPCOM.NS_OK) {
             browser.dispose ();
@@ -1040,9 +850,7 @@
 
         FilePickerFactory pickerFactory = IsXULRunner ? new FilePickerFactory_1_8 () : new FilePickerFactory ();
         pickerFactory.AddRef ();
-        //aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_FILEPICKER_CONTRACTID, true);
         aClassName = "FilePicker";
-        //aClassName = MozillaDelegate.wcsToMbcs (null, "FilePicker", true); //$NON-NLS-1$
         rc = componentRegistrar.RegisterFactory (&XPCOM.NS_FILEPICKER_CID, aClassName.ptr, XPCOM.NS_FILEPICKER_CONTRACTID.ptr, cast(nsIFactory)pickerFactory);
         if (rc !is XPCOM.NS_OK) {
             browser.dispose ();
@@ -1073,9 +881,6 @@
         error (XPCOM.NS_NOINTERFACE, __FILE__, __LINE__);
     }
     
-    //nsIComponentManager componentManager = new nsIComponentManager (result[0]);
-    //result[0] = 0;
-    //nsIWebBrowser webBrowser;
     nsID NS_IWEBBROWSER_CID = { 0xF1EAC761, 0x87E9, 0x11d3, [0xAF, 0x80, 0x00, 0xA0, 0x24, 0xFF, 0xC0, 0x8C] }; //$NON-NLS-1$
     rc = componentManager.CreateInstance (&NS_IWEBBROWSER_CID, null, &nsIWebBrowser.IID, cast(void**)&webBrowser);
     if (rc !is XPCOM.NS_OK) {
@@ -1106,8 +911,6 @@
         error (XPCOM.NS_ERROR_NO_INTERFACE, __FILE__, __LINE__);
     }
     
-    //nsIBaseWindow baseWindow = new nsIBaseWindow (result[0]);
-    //result[0] = 0;
     Rectangle rect = browser.getClientArea ();
     if (rect.isEmpty ()) {
         rect.width = 1;
@@ -1149,7 +952,6 @@
 
         HelperAppLauncherDialogFactory dialogFactory = new HelperAppLauncherDialogFactory ();
         dialogFactory.AddRef ();
-        //byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_HELPERAPPLAUNCHERDIALOG_CONTRACTID, true);
         String aClassName = "Helper App Launcher Dialog"; //$NON-NLS-1$
         rc = componentRegistrar.RegisterFactory (&XPCOM.NS_HELPERAPPLAUNCHERDIALOG_CID, aClassName.ptr, XPCOM.NS_HELPERAPPLAUNCHERDIALOG_CONTRACTID.ptr, cast(nsIFactory)dialogFactory);
         if (rc !is XPCOM.NS_OK) {
@@ -1172,8 +974,6 @@
             browser.dispose ();
             error (XPCOM.NS_ERROR_NO_INTERFACE, __FILE__, __LINE__);
         }
-        //nsIInterfaceRequestor interfaceRequestor = new nsIInterfaceRequestor (result[0]);
-        //result[0] = 0;
 
         nsIDocShell docShell;
         rc = interfaceRequestor.GetInterface (&nsIDocShell.IID, cast(void**)&docShell);
@@ -1181,7 +981,6 @@
             IsPre_1_8 = true;
             docShell.Release ();
         }
-        //result[0] = 0;
 
         /*
         * A Download factory for contract "Transfer" must be registered iff the GRE's version is 1.8.x.
@@ -1200,7 +999,6 @@
  
                 DownloadFactory_1_8 downloadFactory_1_8 = new DownloadFactory_1_8 ();
                 downloadFactory_1_8.AddRef ();
-                // byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_TRANSFER_CONTRACTID, true);
                 
                 aClassName = "Transfer"; //$NON-NLS-1$
                 rc = componentRegistrar.RegisterFactory (&XPCOM.NS_DOWNLOAD_CID, aClassName.ptr, XPCOM.NS_TRANSFER_CONTRACTID.ptr, cast(nsIFactory)downloadFactory_1_8);
@@ -1229,15 +1027,11 @@
                     browser.dispose ();
                     error (XPCOM.NS_ERROR_NO_INTERFACE, __FILE__, __LINE__);
                 }
-                //nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]);
-                //char[] uri = new char[ABOUT_BLANK.length () + 1];
-                //ABOUT_BLANK.getChars (0, ABOUT_BLANK.length (), uri, 0);
                 rc = webNavigation.LoadURI (ABOUT_BLANK.toString16().toString16z(), nsIWebNavigation.LOAD_FLAGS_NONE, null, null, null);
                 webNavigation.Release ();
                 dialogFactory.isPre_1_9 = false;
             }
         }
-        //result[0] = 0;
         interfaceRequestor.Release ();
         componentRegistrar.Release ();
     }
@@ -1284,6 +1078,22 @@
     }
 }
 
+/*******************************************************************************
+
+    Event Handlers for the Mozilla Class:
+    
+    These represent replacements for SWT's anonymous classes as used within
+    the Mozilla class.  Since D 1.0x anonymous classes do not work equivalently 
+    to Java's, we replace the anonymous classes with D delegates and templates
+    (ie dgListener which wrap the delegate in a class).  This circumvents some
+    nasty, evasive bugs.
+    
+    extern(D) becomes a necessary override on these methods because this class 
+    implements a XPCOM/COM interface resulting in all class methods defaulting
+    to extern(System). -JJR
+
+ ******************************************************************************/
+
 extern(D)
 private void handleDisposeEvent (Event event, Display display) {
     if (BrowserCount > 0) return; /* another display is still active */
@@ -1390,7 +1200,11 @@
                 default: break;
             }
         }
-        
+
+/*******************************************************************************
+
+*******************************************************************************/
+    
 extern(D)
 public bool back () {
     if (awaitingNavigate) return false;
@@ -1895,15 +1709,11 @@
 public bool setUrl (String url) {
     awaitingNavigate = false;
 
-    //int /*long*/[] result = new int /*long*/[1];
     nsIWebNavigation webNavigation;
     int rc = webBrowser.QueryInterface (&nsIWebNavigation.IID, cast(void**)&webNavigation);
     if (rc !is XPCOM.NS_OK) error (rc, __FILE__, __LINE__);
     if (webNavigation is null) error (XPCOM.NS_ERROR_NO_INTERFACE, __FILE__, __LINE__);
 
-    //nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]);
-    //char[] uri = new char[url.length () + 1];
-    //url.getChars (0, url.length (), uri, 0);
     rc = webNavigation.LoadURI (url.toString16().toString16z(), nsIWebNavigation.LOAD_FLAGS_NONE, null, null, null);
     webNavigation.Release ();
     return rc is XPCOM.NS_OK;
--- a/dwt/dwthelper/FileInputStream.d	Sun Dec 14 02:31:38 2008 -0500
+++ b/dwt/dwthelper/FileInputStream.d	Sun Jan 04 02:47:54 2009 -0500
@@ -8,9 +8,9 @@
 import dwt.dwthelper.InputStream;
 
 version(TANGOSVN){
-import tango.io.device.FileConduit;
+    import tango.io.device.File;
 } else {
-import tango.io.FileConduit;
+    import tango.io.FileConduit;
 }
 import tango.io.protocol.Reader;
 import tango.core.Exception;
@@ -20,7 +20,11 @@
 
     alias dwt.dwthelper.InputStream.InputStream.read read;
 
-    private FileConduit conduit;
+    version(TANGOSVN)
+        private tango.io.device.File.File file_;
+    else
+        private FileConduit conduit;
+        
     private ubyte[] buffer;
     private int buf_pos;
     private int buf_size;
@@ -28,13 +32,20 @@
     private bool eof;
 
     public this ( String name ){
-        conduit = new FileConduit( name );
+        version(TANGOSVN)
+            file_ = new tango.io.device.File.File( name );
+        else
+            conduit = new FileConduit( name );
+            
         buffer = new ubyte[]( BUFFER_SIZE );
     }
 
     public this ( dwt.dwthelper.File.File file ){
         implMissing( __FILE__, __LINE__ );
-        conduit = new FileConduit( file.getAbsolutePath(), FileConduit.ReadExisting );
+        version(TANGOSVN)
+            file_ = new tango.io.device.File.File ( file.getAbsolutePath(), tango.io.device.File.File.ReadExisting );
+        else
+            conduit = new FileConduit( file.getAbsolutePath(), FileConduit.ReadExisting );
         buffer = new ubyte[]( BUFFER_SIZE );
     }
 
@@ -45,7 +56,10 @@
         try{
             if( buf_pos == buf_size ){
                 buf_pos = 0;
-                buf_size = conduit.input.read( buffer );
+                version(TANGOSVN)
+                    buf_size = file_.read( buffer );
+                else
+                    buf_size = conduit.input.read( buffer );
             }
             if( buf_size <= 0 ){
                 eof = true;
@@ -74,7 +88,10 @@
     }
 
     public override void close(){
-        conduit.close();
+        version(TANGOSVN)
+            file_.close();
+        else
+            conduit.close();
     }
 }
 
--- a/dwt/dwthelper/FileOutputStream.d	Sun Dec 14 02:31:38 2008 -0500
+++ b/dwt/dwthelper/FileOutputStream.d	Sun Jan 04 02:47:54 2009 -0500
@@ -9,7 +9,7 @@
 import dwt.dwthelper.utils;
 
 version(TANGOSVN){
-import tango.io.device.FileConduit;
+import tango.io.device.File;
 } else {
 import tango.io.FileConduit;
 }
@@ -18,14 +18,24 @@
 
     alias dwt.dwthelper.OutputStream.OutputStream.write write;
     alias dwt.dwthelper.OutputStream.OutputStream.close close;
-    FileConduit fc;
+    
+    version(TANGOSVN)
+        tango.io.device.File.File fc;
+    else
+        FileConduit fc;
     
     public this ( String name ){
-        fc = new FileConduit( name, FileConduit.WriteCreate );
+        version(TANGOSVN)
+            fc = new tango.io.device.File.File( name, tango.io.device.File.File.WriteCreate );
+        else
+            fc = new FileConduit( name, FileConduit.WriteCreate );
     }
 
     public this ( String name, bool append ){
-        fc = new FileConduit( name, append ? FileConduit.WriteAppending : FileConduit.WriteCreate );
+        version(TANGOSVN)
+            fc = new tango.io.device.File.File( name, append ? tango.io.device.File.File.WriteAppending : tango.io.device.File.File.WriteCreate );
+        else    
+            fc = new FileConduit( name, append ? FileConduit.WriteAppending : FileConduit.WriteCreate );
     }
 
     public this ( dwt.dwthelper.File.File file ){
--- a/dwt/dwthelper/InflaterInputStream.d	Sun Dec 14 02:31:38 2008 -0500
+++ b/dwt/dwthelper/InflaterInputStream.d	Sun Jan 04 02:47:54 2009 -0500
@@ -38,6 +38,11 @@
         return this;
     }
 
+    long seek ( long offset, IOStream.Anchor anchor = IOStream.Anchor.Begin )
+    {
+        throw new IOException(__FILE__ ~ "seek method not implemented");
+    }
+    
     tango.io.model.IConduit.IConduit conduit (){
         return null;
     }
@@ -45,6 +50,10 @@
     void close (){
         istr.close();
     }
+    
+    tango.io.model.IConduit.InputStream input() {
+        return this; //??
+    }
 }
 
 public class InflaterInputStream : dwt.dwthelper.InputStream.InputStream {
--- a/dwt/dwthelper/utils.d	Sun Dec 14 02:31:38 2008 -0500
+++ b/dwt/dwthelper/utils.d	Sun Jan 04 02:47:54 2009 -0500
@@ -10,7 +10,13 @@
 public import tango.core.Exception : IllegalArgumentException, IOException;
 
 import tango.io.Stdout;
-import tango.io.Print;
+version(TANGOSVN) {
+    import tango.io.stream.Format;
+    alias FormatOutput Print;
+}
+else
+    import tango.io.Print;
+
 static import tango.stdc.stringz;
 static import tango.text.Util;
 static import tango.text.Text;
--- a/dwt/program/Program.d	Sun Dec 14 02:31:38 2008 -0500
+++ b/dwt/program/Program.d	Sun Jan 04 02:47:54 2009 -0500
@@ -28,7 +28,7 @@
 import tango.core.Array;
 import tango.text.convert.Format;
 version (TANGOSVN) {
-import tango.io.device.FileConduit;
+import tango.io.device.File;
 } else {
 import tango.io.FileConduit;
 }
@@ -598,7 +598,10 @@
  + This is a temporary workaround until SWT will get the real implementation.
  +/
 static String[][ String ] gnome24_getMimeInfo() {
-    scope file = new FileConduit ("/usr/share/mime/globs");
+    version(TANGOSVN)
+        scope file = new tango.io.device.File.File ("/usr/share/mime/globs");
+    else
+        scope file = new FileConduit ("/usr/share/mime/globs");
     scope it = new LineIterator!(char)(file);
     // process file one line at a time
     String[][ String ] mimeInfo;