1 /*******************************************************************************
2  * Copyright (c) 2003, 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  * Port to the D programming language:
11  *      John Reimer <terminal.node@gmail.com>
12  *******************************************************************************/
13 module org.eclipse.swt.browser.DownloadFactory_1_8;
14 
15 import java.lang.all;
16 
17 //import org.eclipse.swt.internal.C;
18 import XPCOM = org.eclipse.swt.internal.mozilla.XPCOM;
19 import org.eclipse.swt.internal.mozilla.Common;
20 //import org.eclipse.swt.internal.mozilla.XPCOMObject;
21 import org.eclipse.swt.internal.mozilla.nsID;
22 import org.eclipse.swt.internal.mozilla.nsIFactory;
23 import org.eclipse.swt.internal.mozilla.nsISupports;
24 import org.eclipse.swt.browser.Download_1_8;
25 
26 class DownloadFactory_1_8 : nsIFactory {
27     //XPCOMObject supports;
28     //XPCOMObject factory;
29     int refCount = 0;
30 
31 this () {
32     //createCOMInterfaces ();
33 }
34 
35 extern(System)
36 nsrefcnt AddRef () {
37     refCount++;
38     return refCount;
39 }
40 
41 extern(System)
42 nsresult QueryInterface (in nsIID* riid, void** ppvObject) {
43     if (riid is null || ppvObject is null) return XPCOM.NS_ERROR_NO_INTERFACE;
44     //nsID guid = new nsID ();
45     //XPCOM.memmove (guid, riid, nsID.sizeof);
46     
47     if (*riid == nsISupports.IID) {
48         *ppvObject = cast(void*)cast(nsISupports)this;
49         AddRef ();
50         return XPCOM.NS_OK;
51     }
52     if (*riid == nsIFactory.IID) {
53         *ppvObject = cast(void*)cast(nsIFactory)this;
54         AddRef ();
55         return XPCOM.NS_OK;
56     }
57     
58     *ppvObject = null;
59     return XPCOM.NS_ERROR_NO_INTERFACE;
60 }
61 
62 extern(System)
63 nsrefcnt Release () {
64     refCount--;
65     //if (refCount is 0) disposeCOMInterfaces ();
66     return refCount;
67 }
68 
69 /* nsIFactory */
70 
71 extern(System)
72 nsresult CreateInstance (nsISupports aOuter, nsIID* iid, void** result) {
73     if (result is null) 
74         return XPCOM.NS_ERROR_INVALID_ARG;
75     auto download = new Download_1_8;
76     nsresult rv = download.QueryInterface( iid, result );
77     if (XPCOM.NS_FAILED(rv)) {
78         *result = null;
79         delete download;
80     }
81     return rv;
82 }
83 
84 extern(System)
85 nsresult LockFactory (PRBool lock) {
86     return XPCOM.NS_OK;
87 }
88 }