comparison dwt/internal/cocoa/NSHTTPCookieStorage.d @ 45:d8635bb48c7c

Merge with SWT 3.5
author Jacob Carlborg <doob@me.com>
date Mon, 01 Dec 2008 17:07:00 +0100
parents f565d3a95c0a
children
comparison
equal deleted inserted replaced
44:ca5e494f2bbf 45:d8635bb48c7c
1 /******************************************************************************* 1 /*******************************************************************************
2 * Copyright (c) 2007 IBM Corporation and others. 2 * Copyright (c) 2000, 2008 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials 3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0 4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at 5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html 6 * http://www.eclipse.org/legal/epl-v10.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * IBM Corporation - initial API and implementation 9 * IBM Corporation - initial API and implementation
10 * 10 *
11 * Port to the D programming language: 11 * Port to the D programming language:
12 * Jacob Carlborg <jacob.carlborg@gmail.com> 12 * Jacob Carlborg <doob@me.com>
13 *******************************************************************************/ 13 *******************************************************************************/
14 module dwt.internal.cocoa.NSHTTPCookieStorage; 14 module dwt.internal.cocoa.NSHTTPCookieStorage;
15 15
16 import dwt.dwthelper.utils;
17 import cocoa = dwt.internal.cocoa.id;
16 import dwt.internal.cocoa.NSArray; 18 import dwt.internal.cocoa.NSArray;
17 import dwt.internal.cocoa.NSHTTPCookie; 19 import dwt.internal.cocoa.NSHTTPCookie;
18 import dwt.internal.cocoa.NSObject; 20 import dwt.internal.cocoa.NSObject;
19 import dwt.internal.cocoa.NSURL;
20 import dwt.internal.cocoa.OS; 21 import dwt.internal.cocoa.OS;
21 import objc = dwt.internal.objc.runtime; 22 import objc = dwt.internal.objc.runtime;
22 23
23 enum NSHTTPCookieAcceptPolicy 24 public class NSHTTPCookieStorage : NSObject {
24 { 25
25 NSHTTPCookieAcceptPolicyAlways, 26 public this() {
26 NSHTTPCookieAcceptPolicyNever, 27 super();
27 NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain
28 } 28 }
29 29
30 public class NSHTTPCookieStorage : NSObject 30 public this(objc.id id) {
31 { 31 super(id);
32 }
32 33
33 public this () 34 public this(cocoa.id id) {
34 { 35 super(id);
35 super(); 36 }
36 }
37 37
38 public this (objc.id id) 38 public NSArray cookies() {
39 { 39 objc.id result = OS.objc_msgSend(this.id, OS.sel_cookies);
40 super(id); 40 return result !is null ? new NSArray(result) : null;
41 } 41 }
42 42
43 public NSHTTPCookieAcceptPolicy cookieAcceptPolicy () 43 public void deleteCookie(NSHTTPCookie cookie) {
44 { 44 OS.objc_msgSend(this.id, OS.sel_deleteCookie_, cookie !is null ? cookie.id : null);
45 return cast(NSHTTPCookieAcceptPolicy) OS.objc_msgSend(this.id_, OS.sel_cookieAcceptPolicy); 45 }
46 }
47 46
48 public NSArray cookies () 47 public static NSHTTPCookieStorage sharedHTTPCookieStorage() {
49 { 48 objc.id result = OS.objc_msgSend(OS.class_NSHTTPCookieStorage, OS.sel_sharedHTTPCookieStorage);
50 objc.id result = OS.objc_msgSend(this.id_, OS.sel_cookies); 49 return result !is null ? new NSHTTPCookieStorage(result) : null;
51 return result !is null ? new NSArray(result) : null; 50 }
52 }
53
54 public NSArray cookiesForURL (NSURL URL)
55 {
56 objc.id result = OS.objc_msgSend(this.id_, OS.sel_cookiesForURL_1, URL !is null ? URL.id_ : null);
57 return result !is null ? new NSArray(result) : null;
58 }
59
60 public void deleteCookie (NSHTTPCookie cookie)
61 {
62 OS.objc_msgSend(this.id_, OS.sel_deleteCookie_1, cookie !is null ? cookie.id_ : null);
63 }
64
65 public void setCookie (NSHTTPCookie cookie)
66 {
67 OS.objc_msgSend(this.id_, OS.sel_setCookie_1, cookie !is null ? cookie.id_ : null);
68 }
69
70 public void setCookieAcceptPolicy (NSHTTPCookieAcceptPolicy cookieAcceptPolicy)
71 {
72 OS.objc_msgSend(this.id_, OS.sel_setCookieAcceptPolicy_1, cookieAcceptPolicy);
73 }
74
75 public void setCookies (NSArray cookies, NSURL URL, NSURL mainDocumentURL)
76 {
77 OS.objc_msgSend(this.id_, OS.sel_setCookies_1forURL_1mainDocumentURL_1, cookies !is null ? cookies.id_ : null, URL !is null ? URL.id_ : null,
78 mainDocumentURL !is null ? mainDocumentURL.id_ : null);
79 }
80
81 public static NSHTTPCookieStorage sharedHTTPCookieStorage ()
82 {
83 objc.id result = OS.objc_msgSend(OS.class_NSHTTPCookieStorage, OS.sel_sharedHTTPCookieStorage);
84 return result !is null ? new NSHTTPCookieStorage(result) : null;
85 }
86 51
87 } 52 }