Mercurial > projects > dstep
view dstep/foundation/NSURLDownload.d @ 16:19885b43130e
Huge update, the bridge actually works now
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sun, 03 Jan 2010 22:06:11 +0100 |
parents | 89f3c3ef1fd2 |
children | b9de51448c6b |
line wrap: on
line source
/** * Copyright: Copyright (c) 2009 Jacob Carlborg. * Authors: Jacob Carlborg * Version: Initial created: Aug 3, 2009 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) */ module dstep.foundation.NSURLDownload; import dstep.foundation.NSData; import dstep.foundation.NSError; import dstep.foundation.NSObject; import dstep.foundation.NSString; import dstep.foundation.NSURLAuthenticationChallenge; import dstep.foundation.NSURLRequest; import dstep.foundation.NSURLResponse; import dstep.objc.bridge.Bridge; import dstep.objc.objc; class NSURLDownload : NSObject { mixin (ObjcWrap); this () { super(typeof(this).alloc.init.objcObject); } typeof(this) init () { return invokeObjcSelf!(typeof(this), "init"); } static bool canResumeDownloadDecodedWithEncodingMIMEType (NSString MIMEType) { return invokeObjcSuperClass!(bool, "canResumeDownloadDecodedWithEncodingMIMEType:", NSString)(MIMEType); } Object initWithRequest (NSURLRequest request, Object delegate_) { return invokeObjcSelf!(Object, "initWithRequest:delegate:", NSURLRequest, Object)(request, delegate_); } this (NSURLRequest request, Object delegate_) { typeof(this).alloc.initWithRequest(request, delegate_); } Object initWithResumeData (NSData resumeData, Object delegate_, NSString path) { return invokeObjcSelf!(Object, "initWithResumeData:delegate:path:", NSData, Object, NSString)(resumeData, delegate_, path); } this (NSData resumeData, Object delegate_, NSString path) { typeof(this).alloc.initWithResumeData(resumeData, delegate_, path); } void cancel () { return invokeObjcSelf!(void, "cancel"); } void setDestination (NSString path, bool allowOverwrite) { return invokeObjcSelf!(void, "setDestination:allowOverwrite:", NSString, bool)(path, allowOverwrite); } NSURLRequest request () { return invokeObjcSelf!(NSURLRequest, "request"); } NSData resumeData () { return invokeObjcSelf!(NSData, "resumeData"); } void setDeletesFileUponFailure (bool deletesFileUponFailure) { return invokeObjcSelf!(void, "setDeletesFileUponFailure:", bool)(deletesFileUponFailure); } bool deletesFileUponFailure () { return invokeObjcSelf!(bool, "deletesFileUponFailure"); } } const TNSURLDownloadDelegate = ` void downloadDidBegin (NSURLDownload download) { return invokeObjcSelf!(void, "downloadDidBegin:", NSURLDownload)(download); } NSURLRequest download (NSURLDownload download, NSURLRequest request, NSURLResponse redirectResponse) { return invokeObjcSelf!(NSURLRequest, "download:willSendRequest:redirectResponse:", NSURLDownload, NSURLRequest, NSURLResponse)(download, request, redirectResponse); } void download (NSURLDownload download, NSURLAuthenticationChallenge challenge) { return invokeObjcSelf!(void, "download:didReceiveAuthenticationChallenge:", NSURLDownload, NSURLAuthenticationChallenge)(download, challenge); } void download_didCancelAuthenticationChallenge (NSURLDownload download, NSURLAuthenticationChallenge challenge) { return invokeObjcSelf!(void, "download:didCancelAuthenticationChallenge:", NSURLDownload, NSURLAuthenticationChallenge)(download, challenge); } void download (NSURLDownload download, NSURLResponse response) { return invokeObjcSelf!(void, "download:didReceiveResponse:", NSURLDownload, NSURLResponse)(download, response); } void download (NSURLDownload download, NSURLResponse response, long startingByte) { return invokeObjcSelf!(void, "download:willResumeWithResponse:fromByte:", NSURLDownload, NSURLResponse, long)(download, response, startingByte); } void download (NSURLDownload download, NSUInteger length) { return invokeObjcSelf!(void, "download:didReceiveDataOfLength:", NSURLDownload, NSUInteger)(download, length); } bool download (NSURLDownload download, NSString encodingType) { return invokeObjcSelf!(bool, "download:shouldDecodeSourceDataOfMIMEType:", NSURLDownload, NSString)(download, encodingType); } void download_decideDestinationWithSuggestedFilename (NSURLDownload download, NSString filename) { return invokeObjcSelf!(void, "download:decideDestinationWithSuggestedFilename:", NSURLDownload, NSString)(download, filename); } void download_didCreateDestination (NSURLDownload download, NSString path) { return invokeObjcSelf!(void, "download:didCreateDestination:", NSURLDownload, NSString)(download, path); } void downloadDidFinish (NSURLDownload download) { return invokeObjcSelf!(void, "downloadDidFinish:", NSURLDownload)(download); } void download (NSURLDownload download, NSError error) { return invokeObjcSelf!(void, "download:didFailWithError:", NSURLDownload, NSError)(download, error); } //mixin ObjcBindMethod!(downloadDidBegin, "downloadDidBegin:"); //mixin ObjcBindMethod!(download, "download:willSendRequest:redirectResponse:"); //mixin ObjcBindMethod!(download, "download:didReceiveAuthenticationChallenge:"); //mixin ObjcBindMethod!(download_didCancelAuthenticationChallenge, "download:didCancelAuthenticationChallenge:"); //mixin ObjcBindMethod!(download, "download:didReceiveResponse:"); //mixin ObjcBindMethod!(download, "download:willResumeWithResponse:fromByte:"); //mixin ObjcBindMethod!(download, "download:didReceiveDataOfLength:"); //mixin ObjcBindMethod!(download, "download:shouldDecodeSourceDataOfMIMEType:"); //mixin ObjcBindMethod!(download_decideDestinationWithSuggestedFilename, "download:decideDestinationWithSuggestedFilename:"); //mixin ObjcBindMethod!(download_didCreateDestination, "download:didCreateDestination:"); //mixin ObjcBindMethod!(downloadDidFinish, "downloadDidFinish:"); //mixin ObjcBindMethod!(download, "download:didFailWithError:"); `;