25
|
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 *******************************************************************************/
|
|
11 module org.eclipse.swt.browser.DownloadFactory;
|
|
12
|
|
13 import java.lang.all;
|
|
14
|
|
15 //import org.eclipse.swt.internal.C;
|
|
16 import XPCOM = org.eclipse.swt.internal.mozilla.XPCOM;
|
|
17 import org.eclipse.swt.internal.mozilla.Common;
|
|
18 //import org.eclipse.swt.internal.mozilla.XPCOMObject;
|
|
19 import org.eclipse.swt.internal.mozilla.nsID;
|
|
20 import org.eclipse.swt.internal.mozilla.nsIFactory;
|
|
21 import org.eclipse.swt.internal.mozilla.nsISupports;
|
|
22
|
|
23 import org.eclipse.swt.browser.Download;
|
|
24
|
|
25 class DownloadFactory : nsIFactory {
|
|
26 int refCount = 0;
|
|
27
|
|
28 this () {}
|
|
29
|
|
30 extern(System)
|
|
31 nsrefcnt AddRef () {
|
|
32 refCount++;
|
|
33 return refCount;
|
|
34 }
|
|
35
|
|
36 extern(System)
|
53
|
37 nsresult QueryInterface (cnsID* riid, void** ppvObject) {
|
25
|
38 if (riid is null || ppvObject is null) return XPCOM.NS_ERROR_NO_INTERFACE;
|
|
39
|
|
40 if (*riid == nsISupports.IID) {
|
|
41 *ppvObject = cast(void*)cast(nsISupports)this;
|
|
42 AddRef ();
|
|
43 return XPCOM.NS_OK;
|
|
44 }
|
|
45 if (*riid == nsIFactory.IID) {
|
|
46 *ppvObject = cast(void*)cast(nsIFactory)this;
|
|
47 AddRef ();
|
|
48 return XPCOM.NS_OK;
|
|
49 }
|
|
50
|
|
51 *ppvObject = null;
|
|
52 return XPCOM.NS_ERROR_NO_INTERFACE;
|
|
53 }
|
|
54
|
|
55 extern(System)
|
|
56 nsrefcnt Release () {
|
|
57 refCount--;
|
|
58 //if (refCount is 0) disposeCOMInterfaces ();
|
|
59 return refCount;
|
|
60 }
|
|
61
|
|
62 /* nsIFactory */
|
|
63
|
|
64 extern(System)
|
|
65 nsresult CreateInstance (nsISupports aOuter, nsID* iid, void** result) {
|
|
66 if (result is null)
|
|
67 return XPCOM.NS_ERROR_INVALID_ARG;
|
|
68 auto download = new Download();
|
|
69 nsresult rv = download.QueryInterface( iid, result );
|
|
70 if (XPCOM.NS_FAILED(rv)) {
|
|
71 *result = null;
|
|
72 delete download;
|
|
73 }
|
|
74 return rv;
|
|
75 }
|
|
76
|
|
77 extern(System)
|
|
78 nsresult LockFactory (int lock) {
|
|
79 return XPCOM.NS_OK;
|
|
80 }
|
|
81 }
|