diff dwt/browser/Download.d @ 345:5abc6f7f7a95

Fixups
author John Reimer <terminal.node@gmail.com>
date Tue, 28 Oct 2008 22:07:01 -0700
parents 8198e6052012
children 9a4d7706df52
line wrap: on
line diff
--- a/dwt/browser/Download.d	Mon Oct 27 22:41:01 2008 -0700
+++ b/dwt/browser/Download.d	Tue Oct 28 22:07:01 2008 -0700
@@ -18,6 +18,8 @@
 
 import dwt.DWT;
 
+import dwt.browser.Mozilla;
+
 //import dwt.internal.Compatibility;
 import XPCOM = dwt.internal.mozilla.XPCOM;
 //import dwt.internal.mozilla.XPCOMObject;
@@ -37,6 +39,7 @@
 import dwt.internal.mozilla.nsIWebProgress;
 import dwt.internal.mozilla.nsIRequest;
 import dwt.internal.mozilla.nsStringAPI;
+import dwt.internal.mozilla.nsEmbedString;
 
 import dwt.layout.GridData;
 import dwt.layout.GridLayout;
@@ -98,10 +101,11 @@
 /* nsIDownload */
 
 /* Note. The argument startTime is defined as a PRInt64. This translates into two java ints. */
+/* EXCEPTION: not for D */
 nsresult Init (nsIURI aSource, nsIURI aTarget, nsAString* aDisplayName, nsIMIMEInfo aMIMEInfo, PRTime startTime, PRBool aPersist) {
     //nsIURI source = new nsIURI (aSource);
-    scope auto aSpec = new nsEmbedString;
-    int rc = aSource.GetHost (cast(nsAString*)aSpec);
+    scope auto aSpec = new nsEmbedCString;
+    int rc = aSource.GetHost (cast(nsACString*)aSpec);
     if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
     //int length = XPCOM.nsEmbedCString_Length (aSpec);
     //int /*long*/ buffer = XPCOM.nsEmbedCString_get (aSpec);
@@ -118,7 +122,7 @@
     String filename = null;
     //nsISupports supports = new nsISupports (aTarget);
     nsIURI target = null;
-    rc = aTarget.QueryInterface (nsIURI.IID, cast(void**)&target);
+    rc = aTarget.QueryInterface (&nsIURI.IID, cast(void**)&target);
     if (rc is 0) {  /* >= 1.7 */
         //result[0] = 0;
         //int /*long*/ aPath = XPCOM.nsEmbedCString_new ();
@@ -131,10 +135,15 @@
         //XPCOM.memmove (dest, buffer, length);
         //XPCOM.nsEmbedCString_delete (aPath);
         filename = aPath.toString;
-        int separator = Util.locatePrior(filename, System.getProperty ("file.separator"));   //$NON-NLS-1$
-        filename = filename[separator + 1 .. $];
+        int separator = filename.lastIndexOf (System.getProperty ("file.separator"));   //$NON-NLS-1$
+        filename = filename.substring (separator + 1);
         target.Release ();
     } else {    /* < 1.7 */
+        // Earlier versions (<1.7) of Mozilla are not really supported
+        // in the D port (yet) because we depend on bindings where the interface
+        // is directly mapped, not wrapped as in the Java SWT case
+        implMissing(__FILE__,__LINE__);
+    /*
         //nsILocalFile target = new nsILocalFile (aTarget);
         scope auto aNativeTarget = new nsEmbedCString;
         rc = aTarget.GetNativeLeafName (cast(nsACString*)aNativeTarget);
@@ -145,6 +154,7 @@
         //XPCOM.memmove (dest, buffer, length);
         //XPCOM.nsEmbedCString_delete (aNativeTarget);
         filename = aNativeTarget.toString;
+    */
     }
 
     Listener listener = new class() Listener  {
@@ -215,7 +225,7 @@
     return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
 }
 
-nsresult GetStartTime (PRInt64 aStartTime) {
+nsresult GetStartTime (PRInt64* aStartTime) {
     return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
 }
 
@@ -239,7 +249,7 @@
     if (aObserver !is null) {
         // nsISupports supports = new nsISupports (aObserver);
         nsIHelperAppLauncher result;
-        int rc = aObserver.QueryInterface (nsIHelperAppLauncher.IID, cast(void**)&result);
+        int rc = aObserver.QueryInterface (&nsIHelperAppLauncher.IID, cast(void**)&result);
         if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
         if (result is null) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE);
         helperAppLauncher = result;