Mercurial > projects > dwt-mac
comparison dwt/internal/cocoa/NSURLDownload.d @ 45:d8635bb48c7c
Merge with SWT 3.5
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Mon, 01 Dec 2008 17:07:00 +0100 |
parents | f565d3a95c0a |
children |
comparison
equal
deleted
inserted
replaced
44:ca5e494f2bbf | 45:d8635bb48c7c |
---|---|
1 /******************************************************************************* | 1 /******************************************************************************* |
2 * Copyright (c) 2007 IBM Corporation and others. | 2 * Copyright (c) 2000, 2008 IBM Corporation and others. |
3 * All rights reserved. This program and the accompanying materials | 3 * All rights reserved. This program and the accompanying materials |
4 * are made available under the terms of the Eclipse Public License v1.0 | 4 * are made available under the terms of the Eclipse Public License v1.0 |
5 * which accompanies this distribution, and is available at | 5 * which accompanies this distribution, and is available at |
6 * http://www.eclipse.org/legal/epl-v10.html | 6 * http://www.eclipse.org/legal/epl-v10.html |
7 * | 7 * |
8 * Contributors: | 8 * Contributors: |
9 * IBM Corporation - initial API and implementation | 9 * IBM Corporation - initial API and implementation |
10 * | 10 * |
11 * Port to the D programming language: | 11 * Port to the D programming language: |
12 * Jacob Carlborg <jacob.carlborg@gmail.com> | 12 * Jacob Carlborg <doob@me.com> |
13 *******************************************************************************/ | 13 *******************************************************************************/ |
14 module dwt.internal.cocoa.NSURLDownload; | 14 module dwt.internal.cocoa.NSURLDownload; |
15 | 15 |
16 import dwt.internal.cocoa.id; | 16 import dwt.dwthelper.utils; |
17 import dwt.internal.cocoa.NSData; | 17 import cocoa = dwt.internal.cocoa.id; |
18 import dwt.internal.cocoa.NSObject; | 18 import dwt.internal.cocoa.NSObject; |
19 import dwt.internal.cocoa.NSString; | 19 import dwt.internal.cocoa.NSString; |
20 import dwt.internal.cocoa.NSURLRequest; | |
21 import dwt.internal.cocoa.OS; | 20 import dwt.internal.cocoa.OS; |
22 import objc = dwt.internal.objc.runtime; | 21 import objc = dwt.internal.objc.runtime; |
23 | 22 |
24 public class NSURLDownload : NSObject | 23 public class NSURLDownload : NSObject { |
25 { | |
26 | 24 |
27 public this () | 25 public this() { |
28 { | 26 super(); |
29 super(); | 27 } |
30 } | |
31 | 28 |
32 public this (objc.id id) | 29 public this(objc.id id) { |
33 { | 30 super(id); |
34 super(id); | 31 } |
35 } | |
36 | 32 |
37 public static bool canResumeDownloadDecodedWithEncodingMIMEType (NSString MIMEType) | 33 public this(cocoa.id id) { |
38 { | 34 super(id); |
39 return OS.objc_msgSend(OS.class_NSURLDownload, OS.sel_canResumeDownloadDecodedWithEncodingMIMEType_1, MIMEType !is null ? MIMEType.id_ : null) !is null; | 35 } |
40 } | |
41 | 36 |
42 public void cancel () | 37 public void cancel() { |
43 { | 38 OS.objc_msgSend(this.id, OS.sel_cancel); |
44 OS.objc_msgSend(this.id_, OS.sel_cancel); | 39 } |
45 } | |
46 | 40 |
47 public bool deletesFileUponFailure () | 41 public void setDestination(NSString path, bool allowOverwrite) { |
48 { | 42 OS.objc_msgSend(this.id, OS.sel_setDestination_allowOverwrite_, path !is null ? path.id : null, allowOverwrite); |
49 return OS.objc_msgSend(this.id_, OS.sel_deletesFileUponFailure) !is null; | 43 } |
50 } | |
51 | |
52 public id initWithRequest (NSURLRequest request, id delegatee) | |
53 { | |
54 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithRequest_1delegate_1, request !is null ? request.id_ : null, | |
55 delegatee !is null ? delegatee.id_ : null); | |
56 return result !is null ? new id(result) : null; | |
57 } | |
58 | |
59 public id initWithResumeData (NSData resumeData, id delegatee, NSString path) | |
60 { | |
61 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithResumeData_1delegate_1path_1, resumeData !is null ? resumeData.id_ : null, | |
62 delegatee !is null ? delegatee.id_ : null, path !is null ? path.id_ : null); | |
63 return result !is null ? new id(result) : null; | |
64 } | |
65 | |
66 public NSURLRequest request () | |
67 { | |
68 objc.id result = OS.objc_msgSend(this.id_, OS.sel_request); | |
69 return result !is null ? new NSURLRequest(result) : null; | |
70 } | |
71 | |
72 public NSData resumeData () | |
73 { | |
74 objc.id result = OS.objc_msgSend(this.id_, OS.sel_resumeData); | |
75 return result !is null ? new NSData(result) : null; | |
76 } | |
77 | |
78 public void setDeletesFileUponFailure (bool deletesFileUponFailure) | |
79 { | |
80 OS.objc_msgSend(this.id_, OS.sel_setDeletesFileUponFailure_1, deletesFileUponFailure); | |
81 } | |
82 | |
83 public void setDestination (NSString path, bool allowOverwrite) | |
84 { | |
85 OS.objc_msgSend(this.id_, OS.sel_setDestination_1allowOverwrite_1, path !is null ? path.id_ : null, allowOverwrite); | |
86 } | |
87 | 44 |
88 } | 45 } |