14
|
1 /**
|
|
2 * Copyright: Copyright (c) 2009 Jacob Carlborg.
|
|
3 * Authors: Jacob Carlborg
|
|
4 * Version: Initial created: Aug 3, 2009
|
|
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
|
|
6 */
|
|
7 module dstep.foundation.NSURLCredential;
|
|
8
|
|
9 import dstep.AvailabilityMacros;
|
|
10 import dstep.foundation.NSObject;
|
|
11 import dstep.foundation.NSString;
|
|
12 import dstep.foundation.NSURLCredentialInternal;
|
|
13 import dstep.objc.bridge.Bridge;
|
|
14 import dstep.objc.objc : id;
|
|
15
|
|
16 alias NSUInteger NSURLCredentialPersistence;
|
|
17
|
|
18 enum
|
|
19 {
|
|
20 NSURLCredentialPersistenceNone,
|
|
21 NSURLCredentialPersistenceForSession,
|
|
22 NSURLCredentialPersistencePermanent
|
|
23 }
|
|
24
|
|
25 class NSURLCredential : NSObject, INSCopying
|
|
26 {
|
|
27 mixin ObjcWrap;
|
|
28
|
|
29 Object initWithUser (NSString user, NSString password, uint persistence)
|
|
30 {
|
|
31 return invokeObjcSelf!(Object, "initWithUser:password:persistence:", NSString, NSString, uint)(user, password, persistence);
|
|
32 }
|
|
33
|
|
34 this (NSString user, NSString password, uint persistence)
|
|
35 {
|
|
36 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
|
|
37 id result = Bridge.invokeObjcMethod!(id, "initWithUser:password:persistence:", NSString, NSString, uint)(objcObject, user, password, persistence);
|
|
38
|
|
39 if (result)
|
|
40 objcObject = ret;
|
|
41
|
|
42 dObject = this;
|
|
43 }
|
|
44
|
|
45 static NSURLCredential credentialWithUser (NSString user, NSString password, uint persistence)
|
|
46 {
|
|
47 return invokeObjcSelfClass!(NSURLCredential, "credentialWithUser:password:persistence:", NSString, NSString, uint)(user, password, persistencereturn result is this.objcObject ? this : (result !is null ? new NSURLCredential(result) : null); }
|
|
48
|
|
49 NSString user ()
|
|
50 {
|
|
51 return invokeObjcSelf!(NSString, "user");
|
|
52 }
|
|
53
|
|
54 NSString password ()
|
|
55 {
|
|
56 return invokeObjcSelf!(NSString, "password");
|
|
57 }
|
|
58
|
|
59 bool hasPassword ()
|
|
60 {
|
|
61 return invokeObjcSelf!(bool, "hasPassword");
|
|
62 }
|
|
63
|
|
64 uint persistence ()
|
|
65 {
|
|
66 return invokeObjcSelf!(uint, "persistence");
|
|
67 }
|
|
68
|
|
69 Object copyWithZone (NSZone* zone)
|
|
70 {
|
|
71 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone);
|
|
72 }
|
|
73 }
|
|
74
|