view dstep/foundation/NSURLAuthenticationChallenge.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.NSURLAuthenticationChallenge;

import dstep.foundation.NSError;
import dstep.foundation.NSObjCRuntime;
import dstep.foundation.NSObject;
import dstep.foundation.NSURLCredential;
import dstep.foundation.NSURLProtectionSpace;
import dstep.foundation.NSURLResponse;
import dstep.objc.bridge.Bridge;
import dstep.objc.objc;

class NSURLAuthenticationChallenge : NSObject
{
	mixin (ObjcWrap);
	
	this ()
	{
		super(typeof(this).alloc.init.objcObject);
	}
	
	typeof(this) init ()
	{
		return invokeObjcSelf!(typeof(this), "init");
	}
	
	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 = result;

		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 = result;

		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);
}