diff dwt/browser.old/DownloadFactory.d @ 288:4ee8c4237614

old branches... commit by mistake
author John Reimer<terminal.node@gmail.com>
date Tue, 05 Aug 2008 18:00:50 -0700
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser.old/DownloadFactory.d	Tue Aug 05 18:00:50 2008 -0700
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 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:
+ *     John Reimer <terminal.node@gmail.com>
+ *******************************************************************************/
+module dwt.browser.DownloadFactory;
+
+import dwt.dwthelper.utils;
+
+import dwt.browser.Download;
+
+import dwt.internal.mozilla.nsID;
+import dwt.internal.mozilla.nsIFactory;
+import dwt.internal.mozilla.nsISupports;
+
+class DownloadFactory : nsIFactory
+{
+    int _refCount = 0;
+
+    nsrefcnt AddRef () 
+    {
+        _refCount++;
+        return _refCount;
+    }
+
+    int QueryInterface ( ref nsIID riid, void** ppvObject) 
+    {
+        if (riid is null || ppvObject is null) 
+            return NS_ERROR_NO_INTERFACE;
+        
+        if ( riid == nsISupports.IID) 
+        {
+            *ppvObject = cast(void*)cast(nsISupports)this;
+            AddRef ();
+            return NS_OK;
+        }
+
+        if ( riid == nsIFactory.IID) 
+        {
+            *ppvObject = cast(void*)cast(nsIFactory)this;
+            AddRef ();
+            return NS_OK;
+        }
+    
+        *ppvObject = null;
+        return NS_ERROR_NO_INTERFACE;
+    }
+            
+    nsrefcnt Release () 
+    {
+        _refCount--;
+        if (_refCount is 0) 
+            _refCount = 0;
+    return _refCount;
+    }
+    
+/* nsIFactory */
+
+    nsresult CreateInstance ( nsISupports aOuter, nsIID* iid, void** result) 
+    {
+        Download download = new Download ();
+        download.AddRef ();
+        nsresult rv = download.QueryInterface( iid, result );
+        return rv;
+    }
+
+    nsresult LockFactory (int lock) 
+    {
+        return NS_OK;
+    }
+}