diff dwt/internal/cocoa/NSURLProtocol.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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSURLProtocol.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     
+ * Port to the D Programming language:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSURLProtocol;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSCachedURLResponse;
+import dwt.internal.cocoa.NSMutableURLRequest;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSURLRequest;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSURLProtocol : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSCachedURLResponse cachedResponse ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_cachedResponse);
+        return result !is null ? new NSCachedURLResponse(result) : null;
+    }
+
+    public static bool canInitWithRequest (NSURLRequest request)
+    {
+        return OS.objc_msgSend(OS.class_NSURLProtocol, OS.sel_canInitWithRequest_1, request !is null ? request.id : null) !is null;
+    }
+
+    public static NSURLRequest canonicalRequestForRequest (NSURLRequest request)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSURLProtocol, OS.sel_canonicalRequestForRequest_1, request !is null ? request.id : null);
+        return result !is null ? new NSURLRequest(result) : null;
+    }
+
+    public id client ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_client);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithRequest (NSURLRequest request, NSCachedURLResponse cachedResponse, id client)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithRequest_1cachedResponse_1client_1, request !is null ? request.id : null,
+                cachedResponse !is null ? cachedResponse.id : null, client !is null ? client.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id propertyForKey (NSString key, NSURLRequest request)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSURLProtocol, OS.sel_propertyForKey_1inRequest_1, key !is null ? key.id : null,
+                request !is null ? request.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static bool registerClass (objc.Class protocolClass)
+    {
+        return OS.objc_msgSend(OS.class_NSURLProtocol, OS.sel_registerClass_1, protocolClass) !is null;
+    }
+
+    public static void removePropertyForKey (NSString key, NSMutableURLRequest request)
+    {
+        OS.objc_msgSend(OS.class_NSURLProtocol, OS.sel_removePropertyForKey_1inRequest_1, key !is null ? key.id : null,
+                request !is null ? request.id : null);
+    }
+
+    public NSURLRequest request ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_request);
+        return result !is null ? new NSURLRequest(result) : null;
+    }
+
+    public static bool requestIsCacheEquivalent (NSURLRequest a, NSURLRequest b)
+    {
+        return OS.objc_msgSend(OS.class_NSURLProtocol, OS.sel_requestIsCacheEquivalent_1toRequest_1, a !is null ? a.id : null,
+                b !is null ? b.id : null) !is null;
+    }
+
+    public static void setProperty (id value, NSString key, NSMutableURLRequest request)
+    {
+        OS.objc_msgSend(OS.class_NSURLProtocol, OS.sel_setProperty_1forKey_1inRequest_1, value !is null ? value.id : null,
+                key !is null ? key.id : null, request !is null ? request.id : null);
+    }
+
+    public void startLoading ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_startLoading);
+    }
+
+    public void stopLoading ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_stopLoading);
+    }
+
+    public static void unregisterClass (objc.Class protocolClass)
+    {
+        OS.objc_msgSend(OS.class_NSURLProtocol, OS.sel_unregisterClass_1, protocolClass);
+    }
+
+}