Mercurial > projects > dstep
diff dstep/foundation/NSURLAuthenticationChallenge.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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dstep/foundation/NSURLAuthenticationChallenge.d Mon Aug 03 15:23:15 2009 +0200 @@ -0,0 +1,92 @@ +/** + * 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.NSURLAuthenticationChallenge; + +import dstep.AvailabilityMacros; +import dstep.foundation.NSError; +import dstep.foundation.NSObject; +import dstep.foundation.NSURLAuthenticationChallengeInternal; +import dstep.foundation.NSURLCredential; +import dstep.foundation.NSURLProtectionSpace; +import dstep.foundation.NSURLResponse; +import dstep.objc.bridge.Bridge; +import dstep.objc.objc : id; + +class NSURLAuthenticationChallenge : NSObject +{ + mixin ObjcWrap; + + Object initWithProtectionSpace (NSURLProtectionSpace space, NSURLCredential credential, NSInteger previousFailureCount, NSURLResponse response, NSError error, INSURLAuthenticationChallengeSender sender) + { + return invokeObjcSelf!(Object, "initWithProtectionSpace:proposedCredential:previousFailureCount:failureResponse:error:sender:", NSURLProtectionSpace, NSURLCredential, NSInteger, NSURLResponse, NSError, INSURLAuthenticationChallengeSender)(space, credential, previousFailureCount, response, error, sender); + } + + this (NSURLProtectionSpace space, NSURLCredential credential, NSInteger previousFailureCount, NSURLResponse response, NSError error, INSURLAuthenticationChallengeSender sender) + { + objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); + id result = Bridge.invokeObjcMethod!(id, "initWithProtectionSpace:proposedCredential:previousFailureCount:failureResponse:error:sender:", NSURLProtectionSpace, NSURLCredential, NSInteger, NSURLResponse, NSError, INSURLAuthenticationChallengeSender)(objcObject, space, credential, previousFailureCount, response, error, sender); + + if (result) + objcObject = ret; + + dObject = this; + } + + Object initWithAuthenticationChallenge (NSURLAuthenticationChallenge challenge, INSURLAuthenticationChallengeSender sender) + { + return invokeObjcSelf!(Object, "initWithAuthenticationChallenge:sender:", NSURLAuthenticationChallenge, INSURLAuthenticationChallengeSender)(challenge, sender); + } + + this (NSURLAuthenticationChallenge challenge, INSURLAuthenticationChallengeSender sender) + { + objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); + id result = Bridge.invokeObjcMethod!(id, "initWithAuthenticationChallenge:sender:", NSURLAuthenticationChallenge, INSURLAuthenticationChallengeSender)(objcObject, challenge, sender); + + if (result) + objcObject = ret; + + dObject = this; + } + + NSURLProtectionSpace protectionSpace () + { + return invokeObjcSelf!(NSURLProtectionSpace, "protectionSpace"); + } + + NSURLCredential proposedCredential () + { + return invokeObjcSelf!(NSURLCredential, "proposedCredential"); + } + + NSInteger previousFailureCount () + { + return invokeObjcSelf!(NSInteger, "previousFailureCount"); + } + + NSURLResponse failureResponse () + { + return invokeObjcSelf!(NSURLResponse, "failureResponse"); + } + + NSError error () + { + return invokeObjcSelf!(NSError, "error"); + } + + INSURLAuthenticationChallengeSender sender () + { + return invokeObjcSelf!(INSURLAuthenticationChallengeSender, "sender"); + } +} + +interface INSURLAuthenticationChallengeSender : INSObject +{ + void useCredential (NSURLCredential credential, NSURLAuthenticationChallenge challenge); + void continueWithoutCredentialForAuthenticationChallenge (NSURLAuthenticationChallenge challenge); + void cancelAuthenticationChallenge (NSURLAuthenticationChallenge challenge); +} +