comparison dwt/browser/Download_1_8.d @ 348:9a4d7706df52

Test Update to fix linux XPCOM interface issues
author John Reimer <terminal.node@gmail.com>
date Fri, 31 Oct 2008 21:46:44 -0700
parents 8198e6052012
children a3c5f744d03f
comparison
equal deleted inserted replaced
347:ff6dd48f5248 348:9a4d7706df52
15 import dwt.dwthelper.utils; 15 import dwt.dwthelper.utils;
16 import tango.text.convert.Format; 16 import tango.text.convert.Format;
17 17
18 import dwt.DWT; 18 import dwt.DWT;
19 19
20 // import dwt.internal.Compatibility;
21 import XPCOM = dwt.internal.mozilla.XPCOM; 20 import XPCOM = dwt.internal.mozilla.XPCOM;
22 21
23 import dwt.internal.mozilla.Common; 22 import dwt.internal.mozilla.Common;
24 import dwt.internal.mozilla.prtime; 23 import dwt.internal.mozilla.prtime;
25 import dwt.internal.mozilla.nsICancelable; 24 import dwt.internal.mozilla.nsICancelable;
59 //static final bool is32 = C.PTR_SIZEOF is 4; //determine if 32 or 64 bit platform? 58 //static final bool is32 = C.PTR_SIZEOF is 4; //determine if 32 or 64 bit platform?
60 59
61 this () { 60 this () {
62 } 61 }
63 62
63 extern(System)
64 nsrefcnt AddRef () { 64 nsrefcnt AddRef () {
65 refCount++; 65 refCount++;
66 return refCount; 66 return refCount;
67 } 67 }
68 68
69 extern(System)
69 nsresult QueryInterface ( nsID* riid, void** ppvObject) { 70 nsresult QueryInterface ( nsID* riid, void** ppvObject) {
70 if (riid is null || ppvObject is null) return XPCOM.NS_ERROR_NO_INTERFACE; 71 if (riid is null || ppvObject is null) return XPCOM.NS_ERROR_NO_INTERFACE;
71 72
72 if (*riid == nsISupports.IID) { 73 if (*riid == nsISupports.IID) {
73 *ppvObject = cast(void*)cast(nsISupports)this; 74 *ppvObject = cast(void*)cast(nsISupports)this;
91 } 92 }
92 *ppvObject = null; 93 *ppvObject = null;
93 return XPCOM.NS_ERROR_NO_INTERFACE; 94 return XPCOM.NS_ERROR_NO_INTERFACE;
94 } 95 }
95 96
97 extern(System)
96 nsrefcnt Release () { 98 nsrefcnt Release () {
97 refCount--; 99 refCount--;
98 if (refCount is 0) return 0; 100 if (refCount is 0) return 0;
99 return refCount; 101 return refCount;
100 } 102 }
101 103
102 /* nsIDownload */ 104 /* nsIDownload */
103 105
104 /* Note. The argument startTime is defined as a PRInt64. This translates into two java ints. */ 106 /* Note. The argument startTime is defined as a PRInt64. This translates into two java ints. */
107 extern(System)
105 nsresult Init_32 (nsIURI aSource, nsIURI aTarget, nsAString* aDisplayName, nsIMIMEInfo aMIMEInfo, PRInt32 startTime1, PRInt32 startTime2, nsILocalFile aTempFile, nsICancelable aCancelable) { 108 nsresult Init_32 (nsIURI aSource, nsIURI aTarget, nsAString* aDisplayName, nsIMIMEInfo aMIMEInfo, PRInt32 startTime1, PRInt32 startTime2, nsILocalFile aTempFile, nsICancelable aCancelable) {
106 long startTime = (startTime2 << 32) + startTime1; 109 long startTime = (startTime2 << 32) + startTime1;
107 return Init (aSource, aTarget, aDisplayName, aMIMEInfo, startTime, aTempFile, aCancelable); 110 return Init (aSource, aTarget, aDisplayName, aMIMEInfo, startTime, aTempFile, aCancelable);
108 } 111 }
109 112
110 // FIXME: I've hardcoded the string values in place of Compatibility.getMessage calls in 113 // FIXME: I've hardcoded the string values in place of Compatibility.getMessage calls in
111 // the Init method; this will need fixing in future releases. -JJR 114 // the Init method; this will need fixing in future releases. -JJR
112 115 extern(System)
113 nsresult Init (nsIURI aSource, nsIURI aTarget, nsAString* aDisplayName, nsIMIMEInfo aMIMEInfo, PRTime startTime, nsILocalFile aTempFile, nsICancelable aCancelable) { 116 nsresult Init (nsIURI aSource, nsIURI aTarget, nsAString* aDisplayName, nsIMIMEInfo aMIMEInfo, PRTime startTime, nsILocalFile aTempFile, nsICancelable aCancelable) {
114 cancelable = aCancelable; 117 cancelable = aCancelable;
115 // nsIURI source = new nsIURI (aSource); 118 // nsIURI source = new nsIURI (aSource);
116 scope auto aSpec = new nsEmbedCString; 119 scope auto aSpec = new nsEmbedCString;
117 int rc = aSource.GetHost (cast(nsACString*)aSpec); 120 int rc = aSource.GetHost (cast(nsACString*)aSpec);
183 shell.pack (); 186 shell.pack ();
184 shell.open (); 187 shell.open ();
185 return XPCOM.NS_OK; 188 return XPCOM.NS_OK;
186 } 189 }
187 190
191 extern(System)
188 nsresult GetAmountTransferred (PRUint64* arg0) { 192 nsresult GetAmountTransferred (PRUint64* arg0) {
189 return XPCOM.NS_ERROR_NOT_IMPLEMENTED; 193 return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
190 } 194 }
191 195
196 extern(System)
192 nsresult GetCancelable (nsICancelable* arg0) { 197 nsresult GetCancelable (nsICancelable* arg0) {
193 return XPCOM.NS_ERROR_NOT_IMPLEMENTED; 198 return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
194 } 199 }
195 200
201 extern(System)
196 nsresult GetDisplayName (PRUnichar** aDisplayName) { 202 nsresult GetDisplayName (PRUnichar** aDisplayName) {
197 return XPCOM.NS_ERROR_NOT_IMPLEMENTED; 203 return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
198 } 204 }
199 205
206 extern(System)
200 nsresult GetMIMEInfo (nsIMIMEInfo* aMIMEInfo) { 207 nsresult GetMIMEInfo (nsIMIMEInfo* aMIMEInfo) {
201 return XPCOM.NS_ERROR_NOT_IMPLEMENTED; 208 return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
202 } 209 }
203 210
211 extern(System)
204 nsresult GetPercentComplete (PRInt32* aPercentComplete) { 212 nsresult GetPercentComplete (PRInt32* aPercentComplete) {
205 return XPCOM.NS_ERROR_NOT_IMPLEMENTED; 213 return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
206 } 214 }
207 215
216 extern(System)
208 nsresult GetSize (PRUint64* arg0) { 217 nsresult GetSize (PRUint64* arg0) {
209 return XPCOM.NS_ERROR_NOT_IMPLEMENTED; 218 return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
210 } 219 }
211 220
221 extern(System)
212 nsresult GetSource (nsIURI* aSource) { 222 nsresult GetSource (nsIURI* aSource) {
213 return XPCOM.NS_ERROR_NOT_IMPLEMENTED; 223 return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
214 } 224 }
215 225
226 extern(System)
216 nsresult GetStartTime (PRInt64* aStartTime) { 227 nsresult GetStartTime (PRInt64* aStartTime) {
217 return XPCOM.NS_ERROR_NOT_IMPLEMENTED; 228 return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
218 } 229 }
219 230
231 extern(System)
220 nsresult GetTarget (nsIURI* aTarget) { 232 nsresult GetTarget (nsIURI* aTarget) {
221 return XPCOM.NS_ERROR_NOT_IMPLEMENTED; 233 return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
222 } 234 }
223 235
236 extern(System)
224 nsresult GetTargetFile (nsILocalFile* arg0) { 237 nsresult GetTargetFile (nsILocalFile* arg0) {
225 return XPCOM.NS_ERROR_NOT_IMPLEMENTED; 238 return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
226 } 239 }
227 240
228 /* nsIProgressDialog */ 241 /* nsIProgressDialog */
242
243 extern(System)
229 nsresult GetCancelDownloadOnClose (PRBool* aCancelDownloadOnClose) { 244 nsresult GetCancelDownloadOnClose (PRBool* aCancelDownloadOnClose) {
230 return XPCOM.NS_ERROR_NOT_IMPLEMENTED; 245 return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
231 } 246 }
232 247
248 extern(System)
233 nsresult GetDialog (nsIDOMWindow* aDialog) { 249 nsresult GetDialog (nsIDOMWindow* aDialog) {
234 return XPCOM.NS_ERROR_NOT_IMPLEMENTED; 250 return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
235 } 251 }
236 252
253 extern(System)
237 nsresult GetObserver (nsIObserver* aObserver) { 254 nsresult GetObserver (nsIObserver* aObserver) {
238 return XPCOM.NS_ERROR_NOT_IMPLEMENTED; 255 return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
239 } 256 }
240 257
258 extern(System)
241 nsresult Open (nsIDOMWindow aParent) { 259 nsresult Open (nsIDOMWindow aParent) {
242 return XPCOM.NS_ERROR_NOT_IMPLEMENTED; 260 return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
243 } 261 }
244 262
263 extern(System)
245 nsresult SetCancelDownloadOnClose (PRBool aCancelDownloadOnClose) { 264 nsresult SetCancelDownloadOnClose (PRBool aCancelDownloadOnClose) {
246 return XPCOM.NS_ERROR_NOT_IMPLEMENTED; 265 return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
247 } 266 }
248 267
268 extern(System)
249 nsresult SetDialog (nsIDOMWindow aDialog) { 269 nsresult SetDialog (nsIDOMWindow aDialog) {
250 return XPCOM.NS_ERROR_NOT_IMPLEMENTED; 270 return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
251 } 271 }
252 272
273 extern(System)
253 nsresult SetObserver (nsIObserver aObserver) { 274 nsresult SetObserver (nsIObserver aObserver) {
254 return XPCOM.NS_ERROR_NOT_IMPLEMENTED; 275 return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
255 } 276 }
256 277
257 /* nsIWebProgressListener */ 278 /* nsIWebProgressListener */
258 279
280 extern(System)
259 nsresult OnLocationChange (nsIWebProgress aWebProgress, nsIRequest aRequest, nsIURI aLocation) { 281 nsresult OnLocationChange (nsIWebProgress aWebProgress, nsIRequest aRequest, nsIURI aLocation) {
260 return XPCOM.NS_OK; 282 return XPCOM.NS_OK;
261 } 283 }
262 284
285 extern(System)
263 nsresult OnProgressChange (nsIWebProgress aWebProgress, nsIRequest aRequest, PRInt32 aCurSelfProgress, PRInt32 aMaxSelfProgress, PRInt32 aCurTotalProgress, PRInt32 aMaxTotalProgress) { 286 nsresult OnProgressChange (nsIWebProgress aWebProgress, nsIRequest aRequest, PRInt32 aCurSelfProgress, PRInt32 aMaxSelfProgress, PRInt32 aCurTotalProgress, PRInt32 aMaxTotalProgress) {
264 return OnProgressChange64 (aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress); 287 return OnProgressChange64 (aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress);
265 } 288 }
266 /++ 289 /++
267 /* Note. The last 4 args in the original interface are defined as PRInt64. These each translate into two java ints. */ 290 /* Note. The last 4 args in the original interface are defined as PRInt64. These each translate into two java ints. */
271 long aCurTotalProgress = (aCurTotalProgress2 << 32) + aCurTotalProgress1; 294 long aCurTotalProgress = (aCurTotalProgress2 << 32) + aCurTotalProgress1;
272 long aMaxTotalProgress = (aMaxTotalProgress2 << 32) + aMaxTotalProgress1; 295 long aMaxTotalProgress = (aMaxTotalProgress2 << 32) + aMaxTotalProgress1;
273 return OnProgressChange64 (aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress); 296 return OnProgressChange64 (aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress);
274 } 297 }
275 ++/ 298 ++/
299 extern(System)
276 nsresult OnProgressChange64 (nsIWebProgress aWebProgress, nsIRequest aRequest, PRInt64 aCurSelfProgress, PRInt64 aMaxSelfProgress, PRInt64 aCurTotalProgress, PRInt64 aMaxTotalProgress) { 300 nsresult OnProgressChange64 (nsIWebProgress aWebProgress, nsIRequest aRequest, PRInt64 aCurSelfProgress, PRInt64 aMaxSelfProgress, PRInt64 aCurTotalProgress, PRInt64 aMaxTotalProgress) {
277 long currentKBytes = aCurTotalProgress / 1024; 301 long currentKBytes = aCurTotalProgress / 1024;
278 long totalKBytes = aMaxTotalProgress / 1024; 302 long totalKBytes = aMaxTotalProgress / 1024;
279 if (shell !is null && !shell.isDisposed ()) { 303 if (shell !is null && !shell.isDisposed ()) {
280 //Object[] arguments = {new Long (currentKBytes), new Long (totalKBytes)}; 304 //Object[] arguments = {new Long (currentKBytes), new Long (totalKBytes)};
285 shell.getDisplay ().update (); 309 shell.getDisplay ().update ();
286 } 310 }
287 return XPCOM.NS_OK; 311 return XPCOM.NS_OK;
288 } 312 }
289 313
314 extern(System)
290 nsresult OnSecurityChange (nsIWebProgress aWebProgress, nsIRequest aRequest, PRUint32 state) { 315 nsresult OnSecurityChange (nsIWebProgress aWebProgress, nsIRequest aRequest, PRUint32 state) {
291 return XPCOM.NS_OK; 316 return XPCOM.NS_OK;
292 } 317 }
293 318
319 extern(System)
294 nsresult OnStateChange (nsIWebProgress aWebProgress, nsIRequest aRequest, PRUint32 aStateFlags, nsresult aStatus) { 320 nsresult OnStateChange (nsIWebProgress aWebProgress, nsIRequest aRequest, PRUint32 aStateFlags, nsresult aStatus) {
295 if ((aStateFlags & nsIWebProgressListener.STATE_STOP) !is 0) { 321 if ((aStateFlags & nsIWebProgressListener.STATE_STOP) !is 0) {
296 cancelable = null; 322 cancelable = null;
297 if (shell !is null && !shell.isDisposed ()) shell.dispose (); 323 if (shell !is null && !shell.isDisposed ()) shell.dispose ();
298 shell = null; 324 shell = null;
299 } 325 }
300 return XPCOM.NS_OK; 326 return XPCOM.NS_OK;
301 } 327 }
302 328
329 extern(System)
303 nsresult OnStatusChange (nsIWebProgress aWebProgress, nsIRequest aRequest, nsresult aStatus, PRUnichar* aMessage) { 330 nsresult OnStatusChange (nsIWebProgress aWebProgress, nsIRequest aRequest, nsresult aStatus, PRUnichar* aMessage) {
304 return XPCOM.NS_OK; 331 return XPCOM.NS_OK;
305 } 332 }
306 } 333 }