view dstep/foundation/NSURLProtectionSpace.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 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.AvailabilityMacros;
import dstep.foundation.NSObject;
import dstep.foundation.NSString;
import dstep.foundation.NSURLProtectionSpaceInternal;
import dstep.objc.bridge.Bridge;
import dstep.objc.objc : id;

import bindings = dstep.foundation.NSURLProtectionSpace_bindings;

const NSString NSURLProtectionSpaceHTTPProxy;
const NSString NSURLProtectionSpaceHTTPSProxy;
const NSString NSURLProtectionSpaceFTPProxy;
const NSString NSURLProtectionSpaceSOCKSProxy;
const NSString NSURLAuthenticationMethodDefault;
const NSString NSURLAuthenticationMethodHTTPBasic;
const NSString NSURLAuthenticationMethodHTTPDigest;
const NSString NSURLAuthenticationMethodHTMLForm;

static this ()
{
	NSURLProtectionSpaceHTTPProxy = new NSString(bindings.NSURLProtectionSpaceHTTPProxy);
	NSURLProtectionSpaceHTTPSProxy = new NSString(bindings.NSURLProtectionSpaceHTTPSProxy);
	NSURLProtectionSpaceFTPProxy = new NSString(bindings.NSURLProtectionSpaceFTPProxy);
	NSURLProtectionSpaceSOCKSProxy = new NSString(bindings.NSURLProtectionSpaceSOCKSProxy);
	NSURLAuthenticationMethodDefault = new NSString(bindings.NSURLAuthenticationMethodDefault);
	NSURLAuthenticationMethodHTTPBasic = new NSString(bindings.NSURLAuthenticationMethodHTTPBasic);
	NSURLAuthenticationMethodHTTPDigest = new NSString(bindings.NSURLAuthenticationMethodHTTPDigest);
	NSURLAuthenticationMethodHTMLForm = new NSString(bindings.NSURLAuthenticationMethodHTMLForm);
}

class NSURLProtectionSpace : NSObject, INSCopying
{
	mixin ObjcWrap;

	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)
	{
		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
		id result = Bridge.invokeObjcMethod!(id, "initWithHost:port:protocol:realm:authenticationMethod:", NSString, NSInteger, NSString, NSString, NSString)(objcObject, host, port, protocol, realm, authenticationMethod);

		if (result)
			objcObject = ret;

		dObject = this;
	}

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

	this (NSString host, NSInteger port, NSString type, NSString realm, NSString authenticationMethod)
	{
		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
		id result = Bridge.invokeObjcMethod!(id, "initWithProxyHost:port:type:realm:authenticationMethod:", NSString, NSInteger, NSString, NSString, NSString)(objcObject, host, port, type, realm, authenticationMethod);

		if (result)
			objcObject = ret;

		dObject = this;
	}

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