Mercurial > projects > dwt-linux
annotate dwt/browser/FilePickerFactory.d @ 341:942da4b6558a
Ongoing fixup for compile
author | John Reimer <terminal.node@gmail.com> |
---|---|
date | Sun, 26 Oct 2008 21:19:51 -0700 |
parents | eec6ddb07873 |
children | 5abc6f7f7a95 |
rev | line source |
---|---|
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
1 /******************************************************************************* |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2003, 2007 IBM Corporation and others. |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
3 * All rights reserved. This program and the accompanying materials |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
4 * are made available under the terms of the Eclipse Public License v1.0 |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
5 * which accompanies this distribution, and is available at |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
6 * http://www.eclipse.org/legal/epl-v10.html |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
7 * |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
8 * Contributors: |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
9 * IBM Corporation - initial API and implementation |
298
eec6ddb07873
More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
10 * Port to the D programming language: |
eec6ddb07873
More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
11 * John Reimer <terminal.node@gmail.com> |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
12 *******************************************************************************/ |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
13 module dwt.browser.FilePickerFactory; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
14 |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
15 import dwt.dwthelper.utils; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
16 |
298
eec6ddb07873
More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
17 //import dwt.internal.C; |
341
942da4b6558a
Ongoing fixup for compile
John Reimer <terminal.node@gmail.com>
parents:
298
diff
changeset
|
18 import XPCOM = dwt.internal.mozilla.XPCOM; |
298
eec6ddb07873
More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
19 //import dwt.internal.mozilla.XPCOMObject; |
341
942da4b6558a
Ongoing fixup for compile
John Reimer <terminal.node@gmail.com>
parents:
298
diff
changeset
|
20 import dwt.internal.mozilla.Common; |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
21 import dwt.internal.mozilla.nsID; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
22 import dwt.internal.mozilla.nsIFactory; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
23 import dwt.internal.mozilla.nsISupports; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
24 |
341
942da4b6558a
Ongoing fixup for compile
John Reimer <terminal.node@gmail.com>
parents:
298
diff
changeset
|
25 class FilePickerFactory : nsIFactory { |
298
eec6ddb07873
More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
26 //XPCOMObject supports; |
eec6ddb07873
More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
27 //XPCOMObject factory; |
286 | 28 int refCount = 0; |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
29 |
298
eec6ddb07873
More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
30 this () { |
eec6ddb07873
More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
31 // createCOMInterfaces (); |
286 | 32 } |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
33 |
298
eec6ddb07873
More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
34 nsrefcnt AddRef () { |
286 | 35 refCount++; |
36 return refCount; | |
37 } | |
298
eec6ddb07873
More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
38 /+ |
286 | 39 void createCOMInterfaces () { |
40 /* Create each of the interfaces that this object implements */ | |
41 supports = new XPCOMObject (new int[] {2, 0, 0}) { | |
42 public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} | |
43 public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} | |
44 public int /*long*/ method2 (int /*long*/[] args) {return Release ();} | |
45 }; | |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
46 |
286 | 47 factory = new XPCOMObject (new int[] {2, 0, 0, 3, 1}) { |
48 public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} | |
49 public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} | |
50 public int /*long*/ method2 (int /*long*/[] args) {return Release ();} | |
51 public int /*long*/ method3 (int /*long*/[] args) {return CreateInstance (args[0], args[1], args[2]);} | |
52 public int /*long*/ method4 (int /*long*/[] args) {return LockFactory ((int)/*64*/args[0]);} | |
53 }; | |
54 } | |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
55 |
286 | 56 void disposeCOMInterfaces () { |
57 if (supports !is null) { | |
58 supports.dispose (); | |
59 supports = null; | |
60 } | |
61 if (factory !is null) { | |
62 factory.dispose (); | |
63 factory = null; | |
64 } | |
65 } | |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
66 |
286 | 67 int /*long*/ getAddress () { |
68 return factory.getAddress (); | |
69 } | |
298
eec6ddb07873
More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
70 +/ |
eec6ddb07873
More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
71 nsresult QueryInterface (nsID* riid, void** ppvObject) { |
eec6ddb07873
More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
72 if (riid is null || ppvObject is null) return XPCOM.NS_ERROR_NO_INTERFACE; |
eec6ddb07873
More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
73 //nsID guid = new nsID (); |
eec6ddb07873
More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
74 //XPCOM.memmove (guid, riid, nsID.sizeof); |
286 | 75 |
298
eec6ddb07873
More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
76 if (*riid == nsISupports.IID) { |
eec6ddb07873
More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
77 *ppvObject = cast(void*)cast(nsISupports)this; |
286 | 78 AddRef (); |
79 return XPCOM.NS_OK; | |
80 } | |
298
eec6ddb07873
More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
81 if (*riid == nsIFactory.IID) { |
eec6ddb07873
More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
82 *ppvObject = cast(void*)cast(nsIFactory)this; |
286 | 83 AddRef (); |
84 return XPCOM.NS_OK; | |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
85 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
86 |
298
eec6ddb07873
More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
87 *ppvObject = null; |
286 | 88 return XPCOM.NS_ERROR_NO_INTERFACE; |
89 } | |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
90 |
298
eec6ddb07873
More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
91 nsrefcnt Release () { |
286 | 92 refCount--; |
298
eec6ddb07873
More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
93 //if (refCount is 0) disposeCOMInterfaces (); |
286 | 94 return refCount; |
95 } | |
96 | |
97 /* nsIFactory */ | |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
98 |
298
eec6ddb07873
More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
99 nsresult CreateInstance (nsISupports aOuter, nsID* iid, void** result) { |
eec6ddb07873
More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
100 if (result is null) |
eec6ddb07873
More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
101 return XPCOM.NS_ERROR_INVALID_ARG; |
eec6ddb07873
More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
102 auto picker = new FilePicker; |
eec6ddb07873
More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
103 nsresult rv = picker.QueryInterface( iid, result ); |
eec6ddb07873
More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
104 if (XPCOM.NS_FAILED(rv)) { |
eec6ddb07873
More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
105 *result = null; |
eec6ddb07873
More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
106 delete picker; |
eec6ddb07873
More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
107 } |
eec6ddb07873
More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
108 return rv; |
286 | 109 } |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
110 |
298
eec6ddb07873
More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
111 nsresult LockFactory (PRBool lock) { |
286 | 112 return XPCOM.NS_OK; |
113 } | |
114 } |