Mercurial > projects > dwt-linux
annotate dwt/browser/AppFileLocProvider.d @ 348:9a4d7706df52
Test Update to fix linux XPCOM interface issues
author | John Reimer <terminal.node@gmail.com> |
---|---|
date | Fri, 31 Oct 2008 21:46:44 -0700 |
parents | 2e591eb01162 |
children |
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 |
286 | 10 * Port to the D programming language: |
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 *******************************************************************************/ |
286 | 13 module dwt.browser.AppFileLocProvider; |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
14 |
286 | 15 import tango.sys.Environment; |
16 import tango.text.Util; | |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
17 |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
18 import dwt.dwthelper.utils; |
340 | 19 import dwt.browser.Mozilla; |
344 | 20 import dwt.browser.SimpleEnumerator; |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
21 |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
22 import dwt.internal.Compatibility; |
340 | 23 |
24 import XPCOM = dwt.internal.mozilla.XPCOM; | |
25 | |
26 import dwt.internal.mozilla.Common; | |
27 import dwt.internal.mozilla.nsISimpleEnumerator; | |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
28 import dwt.internal.mozilla.nsEmbedString; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
29 import dwt.internal.mozilla.nsID; |
340 | 30 import dwt.internal.mozilla.nsIDirectoryService; |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
31 import dwt.internal.mozilla.nsIFile; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
32 import dwt.internal.mozilla.nsILocalFile; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
33 import dwt.internal.mozilla.nsISupports; |
340 | 34 import dwt.internal.mozilla.nsStringAPI; |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
35 |
305
c7c696cdfec2
Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents:
298
diff
changeset
|
36 class AppFileLocProvider : nsIDirectoryServiceProvider2 { |
286 | 37 int refCount = 0; |
38 String mozillaPath, profilePath; | |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
39 String[] pluginDirs; |
286 | 40 bool isXULRunner; |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
41 |
346
2e591eb01162
Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents:
344
diff
changeset
|
42 static String SEPARATOR_OS; |
286 | 43 static final String CHROME_DIR = "chrome"; //$NON-NLS-1$ |
44 static final String COMPONENTS_DIR = "components"; //$NON-NLS-1$ | |
45 static final String HISTORY_FILE = "history.dat"; //$NON-NLS-1$ | |
46 static final String LOCALSTORE_FILE = "localstore.rdf"; //$NON-NLS-1$ | |
47 static final String MIMETYPES_FILE = "mimeTypes.rdf"; //$NON-NLS-1$ | |
48 static final String PLUGINS_DIR = "plugins"; //$NON-NLS-1$ | |
346
2e591eb01162
Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents:
344
diff
changeset
|
49 static String USER_PLUGINS_DIR; |
286 | 50 static final String PREFERENCES_FILE = "prefs.js"; //$NON-NLS-1$ |
346
2e591eb01162
Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents:
344
diff
changeset
|
51 |
2e591eb01162
Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents:
344
diff
changeset
|
52 static this () { |
2e591eb01162
Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents:
344
diff
changeset
|
53 SEPARATOR_OS = System.getProperty ("file.separator"); |
2e591eb01162
Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents:
344
diff
changeset
|
54 USER_PLUGINS_DIR = ".mozilla" ~ SEPARATOR_OS ~ "plugins"; |
2e591eb01162
Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents:
344
diff
changeset
|
55 } |
2e591eb01162
Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents:
344
diff
changeset
|
56 |
286 | 57 this (String path) { |
333
8235a17d9255
Continued progress on Mozilla.d
John Reimer <terminal.node@gmail.com>
parents:
305
diff
changeset
|
58 mozillaPath = path ~ SEPARATOR_OS; |
286 | 59 } |
60 | |
348
9a4d7706df52
Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents:
346
diff
changeset
|
61 extern(System) |
333
8235a17d9255
Continued progress on Mozilla.d
John Reimer <terminal.node@gmail.com>
parents:
305
diff
changeset
|
62 nsrefcnt AddRef () { |
286 | 63 refCount++; |
64 return refCount; | |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
65 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
66 |
348
9a4d7706df52
Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents:
346
diff
changeset
|
67 extern(System) |
340 | 68 nsresult QueryInterface (nsID* riid, void** ppvObject) { |
286 | 69 if (riid is null || ppvObject is null) return XPCOM.NS_ERROR_NO_INTERFACE; |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
70 |
340 | 71 if (*riid == nsISupports.IID) { |
286 | 72 *ppvObject = cast(void*)cast(nsISupports)this; |
73 AddRef (); | |
74 return XPCOM.NS_OK; | |
75 } | |
76 if (*riid == nsIDirectoryServiceProvider.IID) { | |
77 *ppvObject = cast(void*)cast(nsIDirectoryServiceProvider)this; | |
78 AddRef (); | |
79 return XPCOM.NS_OK; | |
80 } | |
81 if (*riid == nsIDirectoryServiceProvider2.IID) { | |
82 *ppvObject = cast(void*)cast(nsIDirectoryServiceProvider2)this; | |
83 AddRef (); | |
84 return XPCOM.NS_OK; | |
85 } | |
86 | |
87 *ppvObject = null; | |
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 |
348
9a4d7706df52
Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents:
346
diff
changeset
|
91 extern(System) |
333
8235a17d9255
Continued progress on Mozilla.d
John Reimer <terminal.node@gmail.com>
parents:
305
diff
changeset
|
92 nsrefcnt Release () { |
286 | 93 refCount--; |
94 if (refCount is 0) return 0; | |
95 return refCount; | |
96 } | |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
97 |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
98 void setProfilePath (String path) { |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
99 profilePath = path; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
100 if (!Compatibility.fileExists (path, "")) { //$NON-NLS-1$ |
344 | 101 nsILocalFile file; |
340 | 102 scope auto nsEmbedString pathString = new nsEmbedString (toString16(path)); |
344 | 103 int rc = XPCOM.NS_NewLocalFile (cast(nsAString*)pathString, 1, &file); |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
104 if (rc !is XPCOM.NS_OK) Mozilla.error (rc); |
344 | 105 if (file is null) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER); |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
106 |
344 | 107 rc = file.Create (nsILocalFile.DIRECTORY_TYPE, 0700); |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
108 if (rc !is XPCOM.NS_OK) Mozilla.error (rc); |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
109 file.Release (); |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
110 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
111 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
112 |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
113 /* nsIDirectoryServiceProvider2 */ |
348
9a4d7706df52
Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents:
346
diff
changeset
|
114 extern(System) |
286 | 115 nsresult GetFiles (char* prop, nsISimpleEnumerator* _retval) { |
344 | 116 String propertyName = fromStringz(prop); |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
117 String[] propertyValues = null; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
118 |
286 | 119 if (propertyName == XPCOM.NS_APP_PLUGINS_DIR_LIST) { |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
120 if (pluginDirs is null) { |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
121 int index = 0; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
122 /* set the first value(s) to the MOZ_PLUGIN_PATH environment variable value if it's defined */ |
286 | 123 String value = Environment.get (XPCOM.MOZILLA_PLUGIN_PATH); |
298
eec6ddb07873
More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents:
291
diff
changeset
|
124 if (value !is null) { |
286 | 125 if (value.length > 0) { |
344 | 126 String separator = System.getProperty ("file.separator"); // $NON-NLS-1$ |
127 foreach (segment; delimiters(value, separator)) | |
286 | 128 pluginDirs ~= segment; |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
129 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
130 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
131 if (pluginDirs is null) { |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
132 pluginDirs = new String[2]; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
133 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
134 |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
135 /* set the next value to the GRE path + "plugins" */ |
286 | 136 pluginDirs ~= mozillaPath ~ PLUGINS_DIR; |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
137 |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
138 /* set the next value to the home directory + "/.mozilla/plugins" */ |
286 | 139 pluginDirs ~= System.getProperty("user.home") ~ SEPARATOR_OS ~ USER_PLUGINS_DIR; |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
140 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
141 propertyValues = pluginDirs; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
142 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
143 |
286 | 144 *_retval = null; |
145 //XPCOM.memmove(_retval, new int /*long*/[] {0}, C.PTR_SIZEOF); | |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
146 if (propertyValues !is null) { |
286 | 147 nsILocalFile localFile; |
148 nsIFile file; | |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
149 nsISupports[] files = new nsISupports [propertyValues.length]; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
150 int index = 0; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
151 for (int i = 0; i < propertyValues.length; i++) { |
344 | 152 scope auto pathString = new nsEmbedString (toString16(propertyValues[i])); |
153 int rc = XPCOM.NS_NewLocalFile (cast(nsAString*)pathString, 1, &localFile); | |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
154 if (rc !is XPCOM.NS_ERROR_FILE_UNRECOGNIZED_PATH) { |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
155 /* value appears to be a valid pathname */ |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
156 if (rc !is XPCOM.NS_OK) Mozilla.error (rc); |
286 | 157 if (localFile is null) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER); |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
158 |
344 | 159 rc = localFile.QueryInterface (&nsIFile.IID, cast(void**)&file); |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
160 if (rc !is XPCOM.NS_OK) Mozilla.error (rc); |
286 | 161 if (file is null) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE); |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
162 localFile.Release (); |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
163 |
286 | 164 files[index++] = cast(nsISupports)file; |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
165 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
166 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
167 |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
168 if (index < propertyValues.length) { |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
169 /* there were some invalid values so remove the trailing empty array slots */ |
344 | 170 files = files[0..index]; |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
171 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
172 |
286 | 173 auto enumerator = new SimpleEnumerator (files); |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
174 enumerator.AddRef (); |
286 | 175 *_retval = cast(nsISimpleEnumerator)enumerator; |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
176 return XPCOM.NS_OK; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
177 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
178 |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
179 return XPCOM.NS_ERROR_FAILURE; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
180 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
181 |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
182 /* nsIDirectoryServiceProvider implementation */ |
348
9a4d7706df52
Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents:
346
diff
changeset
|
183 extern(System) |
286 | 184 nsresult GetFile(char* prop, PRBool* persistent, nsIFile* _retval) { |
185 String propertyName = tango.stdc.stringz.fromStringz( prop ); | |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
186 String propertyValue = null; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
187 |
286 | 188 if (propertyName == (XPCOM.NS_APP_HISTORY_50_FILE)) { |
189 propertyValue = profilePath ~ HISTORY_FILE; | |
190 } else if (propertyName == (XPCOM.NS_APP_USER_MIMETYPES_50_FILE)) { | |
191 propertyValue = profilePath ~ MIMETYPES_FILE; | |
192 } else if (propertyName == (XPCOM.NS_APP_PREFS_50_FILE)) { | |
193 propertyValue = profilePath ~ PREFERENCES_FILE; | |
194 } else if (propertyName == (XPCOM.NS_APP_PREFS_50_DIR)) { | |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
195 propertyValue = profilePath; |
286 | 196 } else if (propertyName == (XPCOM.NS_APP_USER_CHROME_DIR)) { |
197 propertyValue = profilePath ~ CHROME_DIR; | |
198 } else if (propertyName == (XPCOM.NS_APP_USER_PROFILE_50_DIR)) { | |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
199 propertyValue = profilePath; |
286 | 200 } else if (propertyName == (XPCOM.NS_APP_LOCALSTORE_50_FILE)) { |
201 propertyValue = profilePath ~ LOCALSTORE_FILE; | |
202 } else if (propertyName == (XPCOM.NS_APP_CACHE_PARENT_DIR)) { | |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
203 propertyValue = profilePath; |
286 | 204 } else if (propertyName == (XPCOM.NS_OS_HOME_DIR)) { |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
205 propertyValue = System.getProperty("user.home"); //$NON-NLS-1$ |
286 | 206 } else if (propertyName == (XPCOM.NS_OS_TEMP_DIR)) { |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
207 propertyValue = System.getProperty("java.io.tmpdir"); //$NON-NLS-1$ |
286 | 208 } else if (propertyName == (XPCOM.NS_GRE_DIR)) { |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
209 propertyValue = mozillaPath; |
286 | 210 } else if (propertyName == (XPCOM.NS_GRE_COMPONENT_DIR)) { |
211 propertyValue = mozillaPath ~ COMPONENTS_DIR; | |
212 } else if (propertyName == (XPCOM.NS_XPCOM_INIT_CURRENT_PROCESS_DIR)) { | |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
213 propertyValue = mozillaPath; |
286 | 214 } else if (propertyName == (XPCOM.NS_OS_CURRENT_PROCESS_DIR)) { |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
215 propertyValue = mozillaPath; |
286 | 216 } else if (propertyName == (XPCOM.NS_XPCOM_COMPONENT_DIR)) { |
217 propertyValue = mozillaPath ~ COMPONENTS_DIR; | |
218 } else if (propertyName == (XPCOM.NS_XPCOM_CURRENT_PROCESS_DIR)) { | |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
219 propertyValue = mozillaPath; |
286 | 220 } else if (propertyName == (XPCOM.NS_APP_PREF_DEFAULTS_50_DIR)) { |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
221 /* |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
222 * Answering a value for this property causes problems in Mozilla versions |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
223 * < 1.7. Unfortunately this property is queried early enough in the |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
224 * Browser creation process that the Mozilla version being used is not |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
225 * yet determined. However it is known if XULRunner is being used or not. |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
226 * |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
227 * For now answer a value for this property iff XULRunner is the GRE. |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
228 * If the range of Mozilla versions supported by the Browser is changed |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
229 * in the future to be >= 1.7 then this value can always be answered. |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
230 */ |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
231 if (isXULRunner) propertyValue = profilePath; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
232 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
233 |
286 | 234 *persistent = true; /* PRBool */ |
235 *_retval = null; | |
236 if (propertyValue !is null && propertyValue.length > 0) { | |
237 nsILocalFile localFile; | |
344 | 238 scope auto pathString = new nsEmbedString (propertyValue.toString16()); |
239 int rc = XPCOM.NS_NewLocalFile (cast(nsAString*)pathString, 1, &localFile); | |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
240 if (rc !is XPCOM.NS_OK) Mozilla.error (rc); |
286 | 241 if (localFile is null) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER); |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
242 |
286 | 243 nsIFile file; |
340 | 244 rc = localFile.QueryInterface (&nsIFile.IID, cast(void**)&file); |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
245 if (rc !is XPCOM.NS_OK) Mozilla.error (rc); |
286 | 246 if (file is null) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE); |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
247 |
286 | 248 *_retval = file; |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
249 localFile.Release (); |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
250 return XPCOM.NS_OK; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
251 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
252 |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
253 return XPCOM.NS_ERROR_FAILURE; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
254 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
255 } |