comparison dwt/browser/Download.d @ 352:a3c5f744d03f

Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
author John Reimer <terminal.node@gmail.com>
date Tue, 04 Nov 2008 21:20:45 -0800
parents 9a4d7706df52
children
comparison
equal deleted inserted replaced
351:f1bb3949939b 352:a3c5f744d03f
18 18
19 import dwt.DWT; 19 import dwt.DWT;
20 20
21 import dwt.browser.Mozilla; 21 import dwt.browser.Mozilla;
22 22
23 //import dwt.internal.Compatibility;
24 import XPCOM = dwt.internal.mozilla.XPCOM; 23 import XPCOM = dwt.internal.mozilla.XPCOM;
25 //import dwt.internal.mozilla.XPCOMObject; 24
26 import dwt.internal.mozilla.prtime; 25 import dwt.internal.mozilla.prtime;
27 import dwt.internal.mozilla.Common; 26 import dwt.internal.mozilla.Common;
28 import dwt.internal.mozilla.nsID; 27 import dwt.internal.mozilla.nsID;
29 import dwt.internal.mozilla.nsIDownload; 28 import dwt.internal.mozilla.nsIDownload;
30 import dwt.internal.mozilla.nsIHelperAppLauncher; 29 import dwt.internal.mozilla.nsIHelperAppLauncher;
123 * As of mozilla 1.7 the second argument of the nsIDownload interface's 122 * As of mozilla 1.7 the second argument of the nsIDownload interface's
124 * Init function changed from nsILocalFile to nsIURI. Detect which of 123 * Init function changed from nsILocalFile to nsIURI. Detect which of
125 * these interfaces the second argument implements and act accordingly. 124 * these interfaces the second argument implements and act accordingly.
126 */ 125 */
127 String filename = null; 126 String filename = null;
128 //nsISupports supports = new nsISupports (aTarget); 127 nsISupports supports = cast(nsISupports)aTarget;
129 nsIURI target = null; 128 nsIURI target;
130 rc = aTarget.QueryInterface (&nsIURI.IID, cast(void**)&target); 129 rc = supports.QueryInterface (&nsIURI.IID, cast(void**)&target);
131 if (rc is 0) { /* >= 1.7 */ 130 if (rc is 0) { /* >= 1.7 */
132 //result[0] = 0; 131 //result[0] = 0;
133 //int /*long*/ aPath = XPCOM.nsEmbedCString_new (); 132 //int /*long*/ aPath = XPCOM.nsEmbedCString_new ();
134 scope auto aPath = new nsEmbedCString; 133 scope auto aPath = new nsEmbedCString;
135 rc = target.GetPath (cast(nsACString*)aPath); 134 rc = target.GetPath (cast(nsACString*)aPath);
136 if (rc !is XPCOM.NS_OK) Mozilla.error (rc); 135 if (rc !is XPCOM.NS_OK) Mozilla.error (rc,__FILE__,__LINE__);
137 //length = XPCOM.nsEmbedCString_Length (aPath); 136 //length = XPCOM.nsEmbedCString_Length (aPath);
138 //buffer = XPCOM.nsEmbedCString_get (aPath); 137 //buffer = XPCOM.nsEmbedCString_get (aPath);
139 //dest = new byte[length]; 138 //dest = new byte[length];
140 //XPCOM.memmove (dest, buffer, length); 139 //XPCOM.memmove (dest, buffer, length);
141 //XPCOM.nsEmbedCString_delete (aPath); 140 //XPCOM.nsEmbedCString_delete (aPath);
142 filename = aPath.toString; 141 filename = aPath.toString;
143 int separator = filename.lastIndexOf (System.getProperty ("file.separator")); //$NON-NLS-1$ 142 int separator = filename.lastIndexOf (System.getProperty ("file.separator")); //$NON-NLS-1$
144 filename = filename.substring (separator + 1); 143 filename = filename.substring (separator + 1);
145 target.Release (); 144 target.Release ();
146 } else { /* < 1.7 */ 145 } else { /* < 1.7 */
147 // Earlier versions (<1.7) of Mozilla are not really supported 146 nsILocalFile target2 = cast(nsILocalFile) aTarget;
148 // in the D port (yet) because we depend on bindings where the interface
149 // is directly mapped, not wrapped as in the Java SWT case
150 implMissing(__FILE__,__LINE__);
151 /*
152 //nsILocalFile target = new nsILocalFile (aTarget);
153 scope auto aNativeTarget = new nsEmbedCString; 147 scope auto aNativeTarget = new nsEmbedCString;
154 rc = aTarget.GetNativeLeafName (cast(nsACString*)aNativeTarget); 148 rc = target2.GetNativeLeafName (cast(nsACString*)aNativeTarget);
155 if (rc !is XPCOM.NS_OK) Mozilla.error (rc); 149 if (rc !is XPCOM.NS_OK) Mozilla.error (rc,__FILE__,__LINE__);
156 //length = XPCOM.nsEmbedCString_Length (aNativeTarget); 150 //length = XPCOM.nsEmbedCString_Length (aNativeTarget);
157 //buffer = XPCOM.nsEmbedCString_get (aNativeTarget); 151 //buffer = XPCOM.nsEmbedCString_get (aNativeTarget);
158 //dest = new byte[length]; 152 //dest = new byte[length];
159 //XPCOM.memmove (dest, buffer, length); 153 //XPCOM.memmove (dest, buffer, length);
160 //XPCOM.nsEmbedCString_delete (aNativeTarget); 154 //XPCOM.nsEmbedCString_delete (aNativeTarget);
161 filename = aNativeTarget.toString; 155 filename = aNativeTarget.toString;
162 */
163 } 156 }
164 157
165 Listener listener = new class() Listener { 158 Listener listener = new class() Listener {
166 public void handleEvent (Event event) { 159 public void handleEvent (Event event) {
167 if (event.widget is cancel) { 160 if (event.widget is cancel) {