diff dstep/foundation/NSURLCredential.d @ 14:89f3c3ef1fd2

Added the Foundation framework
author Jacob Carlborg <doob@me.com>
date Mon, 03 Aug 2009 15:23:15 +0200
parents
children 7ff919f595d5
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dstep/foundation/NSURLCredential.d	Mon Aug 03 15:23:15 2009 +0200
@@ -0,0 +1,74 @@
+/**
+ * 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.NSURLCredential;
+
+import dstep.AvailabilityMacros;
+import dstep.foundation.NSObject;
+import dstep.foundation.NSString;
+import dstep.foundation.NSURLCredentialInternal;
+import dstep.objc.bridge.Bridge;
+import dstep.objc.objc : id;
+
+alias NSUInteger NSURLCredentialPersistence;
+
+enum
+{
+	NSURLCredentialPersistenceNone,
+	NSURLCredentialPersistenceForSession,
+	NSURLCredentialPersistencePermanent
+}
+
+class NSURLCredential : NSObject, INSCopying
+{
+	mixin ObjcWrap;
+
+	Object initWithUser (NSString user, NSString password, uint persistence)
+	{
+		return invokeObjcSelf!(Object, "initWithUser:password:persistence:", NSString, NSString, uint)(user, password, persistence);
+	}
+
+	this (NSString user, NSString password, uint persistence)
+	{
+		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
+		id result = Bridge.invokeObjcMethod!(id, "initWithUser:password:persistence:", NSString, NSString, uint)(objcObject, user, password, persistence);
+
+		if (result)
+			objcObject = ret;
+
+		dObject = this;
+	}
+
+	static NSURLCredential credentialWithUser (NSString user, NSString password, uint persistence)
+	{
+		return invokeObjcSelfClass!(NSURLCredential, "credentialWithUser:password:persistence:", NSString, NSString, uint)(user, password, persistencereturn result is this.objcObject ? this : (result !is null ? new NSURLCredential(result) : null);	}
+
+	NSString user ()
+	{
+		return invokeObjcSelf!(NSString, "user");
+	}
+
+	NSString password ()
+	{
+		return invokeObjcSelf!(NSString, "password");
+	}
+
+	bool hasPassword ()
+	{
+		return invokeObjcSelf!(bool, "hasPassword");
+	}
+
+	uint persistence ()
+	{
+		return invokeObjcSelf!(uint, "persistence");
+	}
+
+	Object copyWithZone (NSZone* zone)
+	{
+		return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone);
+	}
+}
+