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

import dstep.foundation.NSObjCRuntime;
import dstep.foundation.NSObject;
import dstep.foundation.NSString;
import dstep.foundation.NSZone;
import dstep.objc.bridge.Bridge;
import dstep.objc.objc;



import bindings = dstep.foundation.NSURLProtectionSpace_bindings;

private
{
	NSString NSURLProtectionSpaceHTTPProxy_;
	NSString NSURLProtectionSpaceHTTPSProxy_;
	NSString NSURLProtectionSpaceFTPProxy_;
	NSString NSURLProtectionSpaceSOCKSProxy_;
	NSString NSURLAuthenticationMethodDefault_;
	NSString NSURLAuthenticationMethodHTTPBasic_;
	NSString NSURLAuthenticationMethodHTTPDigest_;
	NSString NSURLAuthenticationMethodHTMLForm_;
}

NSString NSURLProtectionSpaceHTTPProxy ()
{
	if (NSURLProtectionSpaceHTTPProxy_)
		return NSURLProtectionSpaceHTTPProxy_;
		
	return NSURLProtectionSpaceHTTPProxy_ = new NSString(bindings.NSURLProtectionSpaceHTTPProxy);
}

NSString NSURLProtectionSpaceHTTPSProxy ()
{
	if (NSURLProtectionSpaceHTTPSProxy_)
		return NSURLProtectionSpaceHTTPSProxy_;
		
	return NSURLProtectionSpaceHTTPSProxy_ = new NSString(bindings.NSURLProtectionSpaceHTTPSProxy);
}

NSString NSURLProtectionSpaceFTPProxy ()
{
	if (NSURLProtectionSpaceFTPProxy_)
		return NSURLProtectionSpaceFTPProxy_;
		
	return NSURLProtectionSpaceFTPProxy_ = new NSString(bindings.NSURLProtectionSpaceFTPProxy);
}

NSString NSURLProtectionSpaceSOCKSProxy ()
{
	if (NSURLProtectionSpaceSOCKSProxy_)
		return NSURLProtectionSpaceSOCKSProxy_;
		
	return NSURLProtectionSpaceSOCKSProxy_ = new NSString(bindings.NSURLProtectionSpaceSOCKSProxy);
}

NSString NSURLAuthenticationMethodDefault ()
{
	if (NSURLAuthenticationMethodDefault_)
		return NSURLAuthenticationMethodDefault_;
		
	return NSURLAuthenticationMethodDefault_ = new NSString(bindings.NSURLAuthenticationMethodDefault);
}

NSString NSURLAuthenticationMethodHTTPBasic ()
{
	if (NSURLAuthenticationMethodHTTPBasic_)
		return NSURLAuthenticationMethodHTTPBasic_;
		
	return NSURLAuthenticationMethodHTTPBasic_ = new NSString(bindings.NSURLAuthenticationMethodHTTPBasic);
}

NSString NSURLAuthenticationMethodHTTPDigest ()
{
	if (NSURLAuthenticationMethodHTTPDigest_)
		return NSURLAuthenticationMethodHTTPDigest_;
		
	return NSURLAuthenticationMethodHTTPDigest_ = new NSString(bindings.NSURLAuthenticationMethodHTTPDigest);
}

NSString NSURLAuthenticationMethodHTMLForm ()
{
	if (NSURLAuthenticationMethodHTMLForm_)
		return NSURLAuthenticationMethodHTMLForm_;
		
	return NSURLAuthenticationMethodHTMLForm_ = new NSString(bindings.NSURLAuthenticationMethodHTMLForm);
}

class NSURLProtectionSpace : NSObject, INSCopying
{
	mixin (ObjcWrap);
	
	this ()
	{
		super(typeof(this).alloc.init.objcObject);
	}
	
	typeof(this) init ()
	{
		return invokeObjcSelf!(typeof(this), "init");
	}

	Object initWithHost (NSString host, NSInteger port, NSString protocol, NSString realm, NSString authenticationMethod)
	{
		return invokeObjcSelf!(Object, "initWithHost:port:protocol:realm:authenticationMethod:", NSString, NSInteger, NSString, NSString, NSString)(host, port, protocol, realm, authenticationMethod);
	}

	this (NSString host, NSInteger port, NSString protocol, NSString realm, NSString authenticationMethod)
	{
		typeof(this).alloc.initWithHost(host, port, protocol, realm, authenticationMethod);
	}

	Object initWithProxyHost (NSString host, NSInteger port, NSString type, NSString realm, NSString authenticationMethod)
	{
		return invokeObjcSelf!(Object, "initWithProxyHost:port:type:realm:authenticationMethod:", NSString, NSInteger, NSString, NSString, NSString)(host, port, type, realm, authenticationMethod);
	}

	NSString realm ()
	{
		return invokeObjcSelf!(NSString, "realm");
	}

	bool receivesCredentialSecurely ()
	{
		return invokeObjcSelf!(bool, "receivesCredentialSecurely");
	}

	bool isProxy ()
	{
		return invokeObjcSelf!(bool, "isProxy");
	}

	NSString host ()
	{
		return invokeObjcSelf!(NSString, "host");
	}

	NSInteger port ()
	{
		return invokeObjcSelf!(NSInteger, "port");
	}

	NSString proxyType ()
	{
		return invokeObjcSelf!(NSString, "proxyType");
	}

	NSString protocol ()
	{
		return invokeObjcSelf!(NSString, "protocol");
	}

	NSString authenticationMethod ()
	{
		return invokeObjcSelf!(NSString, "authenticationMethod");
	}

	Object copyWithZone (NSZone* zone)
	{
		return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone);
	}
}