comparison dstep/foundation/NSURLDownload.d @ 14:89f3c3ef1fd2

Added the Foundation framework
author Jacob Carlborg <doob@me.com>
date Mon, 03 Aug 2009 15:23:15 +0200
parents
children 19885b43130e
comparison
equal deleted inserted replaced
13:4f583f7e242e 14:89f3c3ef1fd2
1 /**
2 * Copyright: Copyright (c) 2009 Jacob Carlborg.
3 * Authors: Jacob Carlborg
4 * Version: Initial created: Aug 3, 2009
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
6 */
7 module dstep.foundation.NSURLDownload;
8
9 import dstep.AvailabilityMacros;
10 import dstep.foundation.NSData;
11 import dstep.foundation.NSError;
12 import dstep.foundation.NSObject;
13 import dstep.foundation.NSString;
14 import dstep.foundation.NSURLAuthenticationChallenge;
15 import dstep.foundation.NSURLDownloadInternal;
16 import dstep.foundation.NSURLRequest;
17 import dstep.foundation.NSURLResponse;
18 import dstep.objc.bridge.Bridge;
19 import dstep.objc.objc : id;
20
21 class NSURLDownload : NSObject
22 {
23 mixin ObjcWrap;
24
25 static bool canResumeDownloadDecodedWithEncodingMIMEType (NSString MIMEType)
26 {
27 return invokeObjcSelfClass!(bool, "canResumeDownloadDecodedWithEncodingMIMEType:", NSString)(MIMEType);
28 }
29
30 Object initWithRequest (NSURLRequest request, Object delegate_)
31 {
32 return invokeObjcSelf!(Object, "initWithRequest:delegate:", NSURLRequest, Object)(request, delegate_);
33 }
34
35 this (NSURLRequest request, Object delegate_)
36 {
37 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
38 id result = Bridge.invokeObjcMethod!(id, "initWithRequest:delegate:", NSURLRequest, Object)(objcObject, request, delegate_);
39
40 if (result)
41 objcObject = ret;
42
43 dObject = this;
44 }
45
46 Object initWithResumeData (NSData resumeData, Object delegate_, NSString path)
47 {
48 return invokeObjcSelf!(Object, "initWithResumeData:delegate:path:", NSData, Object, NSString)(resumeData, delegate_, path);
49 }
50
51 this (NSData resumeData, Object delegate_, NSString path)
52 {
53 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
54 id result = Bridge.invokeObjcMethod!(id, "initWithResumeData:delegate:path:", NSData, Object, NSString)(objcObject, resumeData, delegate_, path);
55
56 if (result)
57 objcObject = ret;
58
59 dObject = this;
60 }
61
62 void cancel ()
63 {
64 return invokeObjcSelf!(void, "cancel");
65 }
66
67 void setDestination (NSString path, bool allowOverwrite)
68 {
69 return invokeObjcSelf!(void, "setDestination:allowOverwrite:", NSString, bool)(path, allowOverwrite);
70 }
71
72 NSURLRequest request ()
73 {
74 return invokeObjcSelf!(NSURLRequest, "request");
75 }
76
77 NSData resumeData ()
78 {
79 return invokeObjcSelf!(NSData, "resumeData");
80 }
81
82 void setDeletesFileUponFailure (bool deletesFileUponFailure)
83 {
84 return invokeObjcSelf!(void, "setDeletesFileUponFailure:", bool)(deletesFileUponFailure);
85 }
86
87 bool deletesFileUponFailure ()
88 {
89 return invokeObjcSelf!(bool, "deletesFileUponFailure");
90 }
91 }
92
93 template TNSURLDownloadDelegate ()
94 {
95 void downloadDidBegin (NSURLDownload download);
96 NSURLRequest download (NSURLDownload download, NSURLRequest request, NSURLResponse redirectResponse);
97 void download (NSURLDownload download, NSURLAuthenticationChallenge challenge);
98 void download (NSURLDownload download, NSURLAuthenticationChallenge challenge);
99 void download (NSURLDownload download, NSURLResponse response);
100 void download (NSURLDownload download, NSURLResponse response, long startingByte);
101 void download (NSURLDownload download, NSUInteger length);
102 bool download (NSURLDownload download, NSString encodingType);
103 void download (NSURLDownload download, NSString filename);
104 void download (NSURLDownload download, NSString path);
105 void downloadDidFinish (NSURLDownload download);
106 void download (NSURLDownload download, NSError error);
107 }
108