comparison dwt/browser/DownloadFactory.d @ 278:93409d9838c5

Commit more browser/xpcom updates, including still uncoverted source.
author John Reimer<terminal.node@gmail.com>
date Thu, 31 Jul 2008 19:17:51 -0700
parents
children 44258e0b6687
comparison
equal deleted inserted replaced
277:687f261028b8 278:93409d9838c5
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 dwt.browser.DownloadFactory;
14
15 import dwt.dwthelper.utils;
16
17 import dwt.browser.Download;
18
19 import dwt.internal.mozilla.nsID;
20 import dwt.internal.mozilla.nsIFactory;
21 import dwt.internal.mozilla.nsISupports;
22
23 class DownloadFactory : nsIFactory
24 {
25 int _refCount = 0;
26
27 nsrefcnt AddRef ()
28 {
29 _refCount++;
30 return _refCount;
31 }
32
33 int QueryInterface ( ref nsIID riid, void** ppvObject)
34 {
35 if (riid is null || ppvObject is null)
36 return NS_ERROR_NO_INTERFACE;
37
38 if ( riid == nsISupports.IID)
39 {
40 *ppvObject = cast(void*)cast(nsISupports)this;
41 AddRef ();
42 return NS_OK;
43 }
44
45 if ( riid == nsIFactory.IID)
46 {
47 *ppvObject = cast(void*)cast(nsIFactory)this;
48 AddRef ();
49 return NS_OK;
50 }
51
52 *ppvObject = null;
53 return NS_ERROR_NO_INTERFACE;
54 }
55
56 nsrefcnt Release ()
57 {
58 _refCount--;
59 if (_refCount is 0)
60 _refCount = 0;
61 return _refCount;
62 }
63
64 /* nsIFactory */
65
66 nsresult CreateInstance ( nsISupports aOuter, nsIID* iid, void** result)
67 {
68 Download download = new Download ();
69 download.AddRef ();
70 nsresult rv = download.QueryInterface( iid, result );
71 return rv;
72 }
73
74 nsresult LockFactory (int lock)
75 {
76 return NS_OK;
77 }
78 }