Mercurial > projects > dwt-mac
comparison dwt/internal/cocoa/NSURLCredential.d @ 0:380af2bdd8e5
Upload of whole dwt tree
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Sat, 09 Aug 2008 17:00:02 +0200 |
parents | |
children | 8b48be5454ce |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:380af2bdd8e5 |
---|---|
1 /******************************************************************************* | |
2 * Copyright (c) 2007 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * | |
11 * Port to the D Programming language: | |
12 * Jacob Carlborg <jacob.carlborg@gmail.com> | |
13 *******************************************************************************/ | |
14 module dwt.internal.cocoa.NSURLCredential; | |
15 | |
16 import dwt.internal.cocoa.id; | |
17 import dwt.internal.cocoa.NSObject; | |
18 import dwt.internal.cocoa.NSString; | |
19 import dwt.internal.cocoa.OS; | |
20 import objc = dwt.internal.objc.runtime; | |
21 | |
22 enum NSURLCredentialPersistence | |
23 { | |
24 NSURLCredentialPersistenceNone, | |
25 NSURLCredentialPersistenceForSession, | |
26 NSURLCredentialPersistencePermanent | |
27 } | |
28 | |
29 alias NSURLCredentialPersistence.NSURLCredentialPersistenceNone NSURLCredentialPersistenceNone; | |
30 alias NSURLCredentialPersistence.NSURLCredentialPersistenceForSession NSURLCredentialPersistenceForSession; | |
31 alias NSURLCredentialPersistence.NSURLCredentialPersistencePermanent NSURLCredentialPersistencePermanent; | |
32 | |
33 public class NSURLCredential : NSObject | |
34 { | |
35 | |
36 public this () | |
37 { | |
38 super(); | |
39 } | |
40 | |
41 public this (objc.id id) | |
42 { | |
43 super(id); | |
44 } | |
45 | |
46 public static NSURLCredential credentialWithUser (NSString user, NSString password, NSURLCredentialPersistence persistence) | |
47 { | |
48 objc.id result = OS.objc_msgSend(OS.class_NSURLCredential, OS.sel_credentialWithUser_1password_1persistence_1, | |
49 user !is null ? user.id : null, password !is null ? password.id : null, persistence); | |
50 return result !is null ? new NSURLCredential(result) : null; | |
51 } | |
52 | |
53 public bool hasPassword () | |
54 { | |
55 return OS.objc_msgSend(this.id, OS.sel_hasPassword) !is null; | |
56 } | |
57 | |
58 public id initWithUser (NSString user, NSString password, NSURLCredentialPersistence persistence) | |
59 { | |
60 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithUser_1password_1persistence_1, user !is null ? user.id : null, | |
61 password !is null ? password.id : null, persistence); | |
62 return result !is null ? new id(result) : null; | |
63 } | |
64 | |
65 public NSString password () | |
66 { | |
67 objc.id result = OS.objc_msgSend(this.id, OS.sel_password); | |
68 return result !is null ? new NSString(result) : null; | |
69 } | |
70 | |
71 public NSURLCredentialPersistence persistence () | |
72 { | |
73 return cast(NSURLCredentialPersistence) OS.objc_msgSend(this.id, OS.sel_persistence); | |
74 } | |
75 | |
76 public NSString user () | |
77 { | |
78 objc.id result = OS.objc_msgSend(this.id, OS.sel_user); | |
79 return result !is null ? new NSString(result) : null; | |
80 } | |
81 | |
82 } |