Mercurial > projects > dwt-linux
annotate dwt/browser/AppFileLocProvider.d @ 340:3f4a5c7d138f
Fixes
author | John Reimer <terminal.node@gmail.com> |
---|---|
date | Sun, 26 Oct 2008 08:09:00 -0700 |
parents | 8235a17d9255 |
children | 8198e6052012 |
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; |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
20 |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
21 import dwt.internal.Compatibility; |
340 | 22 |
23 import XPCOM = dwt.internal.mozilla.XPCOM; | |
24 | |
25 import dwt.internal.mozilla.Common; | |
26 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
|
27 import dwt.internal.mozilla.nsEmbedString; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
28 import dwt.internal.mozilla.nsID; |
340 | 29 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
|
30 import dwt.internal.mozilla.nsIFile; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
31 import dwt.internal.mozilla.nsILocalFile; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
32 import dwt.internal.mozilla.nsISupports; |
340 | 33 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
|
34 |
305
c7c696cdfec2
Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents:
298
diff
changeset
|
35 class AppFileLocProvider : nsIDirectoryServiceProvider2 { |
286 | 36 int refCount = 0; |
37 String mozillaPath, profilePath; | |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
38 String[] pluginDirs; |
286 | 39 bool isXULRunner; |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
40 |
286 | 41 static final String SEPARATOR_OS = System.getProperty ("file.separator"); //$NON-NLS-1$ |
42 static final String CHROME_DIR = "chrome"; //$NON-NLS-1$ | |
43 static final String COMPONENTS_DIR = "components"; //$NON-NLS-1$ | |
44 static final String HISTORY_FILE = "history.dat"; //$NON-NLS-1$ | |
45 static final String LOCALSTORE_FILE = "localstore.rdf"; //$NON-NLS-1$ | |
46 static final String MIMETYPES_FILE = "mimeTypes.rdf"; //$NON-NLS-1$ | |
47 static final String PLUGINS_DIR = "plugins"; //$NON-NLS-1$ | |
48 static final String USER_PLUGINS_DIR = ".mozilla" ~ SEPARATOR_OS ~ "plugins"; //$NON-NLS-1$ //$NON-NLS-2$ | |
49 static final String PREFERENCES_FILE = "prefs.js"; //$NON-NLS-1$ | |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
50 |
286 | 51 this (String path) { |
333
8235a17d9255
Continued progress on Mozilla.d
John Reimer <terminal.node@gmail.com>
parents:
305
diff
changeset
|
52 mozillaPath = path ~ SEPARATOR_OS; |
286 | 53 } |
54 | |
333
8235a17d9255
Continued progress on Mozilla.d
John Reimer <terminal.node@gmail.com>
parents:
305
diff
changeset
|
55 nsrefcnt AddRef () { |
286 | 56 refCount++; |
57 return refCount; | |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
58 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
59 |
340 | 60 nsresult QueryInterface (nsID* riid, void** ppvObject) { |
286 | 61 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
|
62 |
340 | 63 if (*riid == nsISupports.IID) { |
286 | 64 *ppvObject = cast(void*)cast(nsISupports)this; |
65 AddRef (); | |
66 return XPCOM.NS_OK; | |
67 } | |
68 if (*riid == nsIDirectoryServiceProvider.IID) { | |
69 *ppvObject = cast(void*)cast(nsIDirectoryServiceProvider)this; | |
70 AddRef (); | |
71 return XPCOM.NS_OK; | |
72 } | |
73 if (*riid == nsIDirectoryServiceProvider2.IID) { | |
74 *ppvObject = cast(void*)cast(nsIDirectoryServiceProvider2)this; | |
75 AddRef (); | |
76 return XPCOM.NS_OK; | |
77 } | |
78 | |
79 *ppvObject = null; | |
80 return XPCOM.NS_ERROR_NO_INTERFACE; | |
81 } | |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
82 |
333
8235a17d9255
Continued progress on Mozilla.d
John Reimer <terminal.node@gmail.com>
parents:
305
diff
changeset
|
83 nsrefcnt Release () { |
286 | 84 refCount--; |
85 if (refCount is 0) return 0; | |
86 return refCount; | |
87 } | |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
88 |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
89 void setProfilePath (String path) { |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
90 profilePath = path; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
91 if (!Compatibility.fileExists (path, "")) { //$NON-NLS-1$ |
286 | 92 nsILocalFile result; |
340 | 93 scope auto nsEmbedString pathString = new nsEmbedString (toString16(path)); |
286 | 94 int rc = XPCOM.NS_NewLocalFile (cast(nsAString*)pathString, 1, &result); |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
95 if (rc !is XPCOM.NS_OK) Mozilla.error (rc); |
286 | 96 if (result 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
|
97 |
286 | 98 rc = result.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
|
99 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
|
100 file.Release (); |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
101 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
102 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
103 |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
104 /* nsIDirectoryServiceProvider2 */ |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
105 |
286 | 106 nsresult GetFiles (char* prop, nsISimpleEnumerator* _retval) { |
340 | 107 String propertyName = prop.fromStringz; |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
108 String[] propertyValues = null; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
109 |
286 | 110 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
|
111 if (pluginDirs is null) { |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
112 int index = 0; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
113 /* set the first value(s) to the MOZ_PLUGIN_PATH environment variable value if it's defined */ |
286 | 114 String value = Environment.get (XPCOM.MOZILLA_PLUGIN_PATH); |
298
eec6ddb07873
More xpcom/mozilla port
John Reimer<terminal.node@gmail.com>
parents:
291
diff
changeset
|
115 if (value !is null) { |
286 | 116 if (value.length > 0) { |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
117 String separator = System.getProperty ("path.separator"); // $NON-NLS-1$ |
286 | 118 foreach (segment; delimiter(value, separator)) |
119 pluginDirs ~= segment; | |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
120 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
121 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
122 if (pluginDirs is null) { |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
123 pluginDirs = new String[2]; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
124 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
125 |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
126 /* set the next value to the GRE path + "plugins" */ |
286 | 127 pluginDirs ~= mozillaPath ~ PLUGINS_DIR; |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
128 |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
129 /* set the next value to the home directory + "/.mozilla/plugins" */ |
286 | 130 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
|
131 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
132 propertyValues = pluginDirs; |
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 |
286 | 135 *_retval = null; |
136 //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
|
137 if (propertyValues !is null) { |
286 | 138 nsILocalFile localFile; |
139 nsIFile file; | |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
140 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
|
141 int index = 0; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
142 for (int i = 0; i < propertyValues.length; i++) { |
286 | 143 scope auto pathString = new nsEmbedString (propertyValues[i]); |
144 int rc = XPCOM.NS_NewLocalFile (cast(nsAString*)pathString, 1, &(cast(void*)localFile)); | |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
145 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
|
146 /* 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
|
147 if (rc !is XPCOM.NS_OK) Mozilla.error (rc); |
286 | 148 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
|
149 |
333
8235a17d9255
Continued progress on Mozilla.d
John Reimer <terminal.node@gmail.com>
parents:
305
diff
changeset
|
150 rc = localFile.QueryInterface (nsIFile.NS_IFILE_IID, cast(void**)&file); |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
151 if (rc !is XPCOM.NS_OK) Mozilla.error (rc); |
286 | 152 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
|
153 localFile.Release (); |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
154 |
286 | 155 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
|
156 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
157 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
158 |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
159 if (index < propertyValues.length) { |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
160 /* there were some invalid values so remove the trailing empty array slots */ |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
161 nsISupports[] temp = new nsISupports [index]; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
162 System.arraycopy (files, 0, temp, 0, index); |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
163 files = temp; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
164 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
165 |
286 | 166 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
|
167 enumerator.AddRef (); |
286 | 168 *_retval = cast(nsISimpleEnumerator)enumerator; |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
169 return XPCOM.NS_OK; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
170 } |
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 return XPCOM.NS_ERROR_FAILURE; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
173 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
174 |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
175 /* nsIDirectoryServiceProvider implementation */ |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
176 |
286 | 177 nsresult GetFile(char* prop, PRBool* persistent, nsIFile* _retval) { |
178 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
|
179 String propertyValue = null; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
180 |
286 | 181 if (propertyName == (XPCOM.NS_APP_HISTORY_50_FILE)) { |
182 propertyValue = profilePath ~ HISTORY_FILE; | |
183 } else if (propertyName == (XPCOM.NS_APP_USER_MIMETYPES_50_FILE)) { | |
184 propertyValue = profilePath ~ MIMETYPES_FILE; | |
185 } else if (propertyName == (XPCOM.NS_APP_PREFS_50_FILE)) { | |
186 propertyValue = profilePath ~ PREFERENCES_FILE; | |
187 } 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
|
188 propertyValue = profilePath; |
286 | 189 } else if (propertyName == (XPCOM.NS_APP_USER_CHROME_DIR)) { |
190 propertyValue = profilePath ~ CHROME_DIR; | |
191 } 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
|
192 propertyValue = profilePath; |
286 | 193 } else if (propertyName == (XPCOM.NS_APP_LOCALSTORE_50_FILE)) { |
194 propertyValue = profilePath ~ LOCALSTORE_FILE; | |
195 } 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
|
196 propertyValue = profilePath; |
286 | 197 } 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
|
198 propertyValue = System.getProperty("user.home"); //$NON-NLS-1$ |
286 | 199 } 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
|
200 propertyValue = System.getProperty("java.io.tmpdir"); //$NON-NLS-1$ |
286 | 201 } 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
|
202 propertyValue = mozillaPath; |
286 | 203 } else if (propertyName == (XPCOM.NS_GRE_COMPONENT_DIR)) { |
204 propertyValue = mozillaPath ~ COMPONENTS_DIR; | |
205 } 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
|
206 propertyValue = mozillaPath; |
286 | 207 } 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
|
208 propertyValue = mozillaPath; |
286 | 209 } else if (propertyName == (XPCOM.NS_XPCOM_COMPONENT_DIR)) { |
210 propertyValue = mozillaPath ~ COMPONENTS_DIR; | |
211 } 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
|
212 propertyValue = mozillaPath; |
286 | 213 } 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
|
214 /* |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
215 * 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
|
216 * < 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
|
217 * 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
|
218 * 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
|
219 * |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
220 * 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
|
221 * 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
|
222 * 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
|
223 */ |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
224 if (isXULRunner) propertyValue = profilePath; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
225 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
226 |
286 | 227 *persistent = true; /* PRBool */ |
228 *_retval = null; | |
229 if (propertyValue !is null && propertyValue.length > 0) { | |
230 nsILocalFile localFile; | |
231 scope auto pathString = new nsEmbedString (propertyValue); | |
232 int rc = XPCOM.NS_NewLocalFile (cast(nsAString*)pathString, 1, &(cast(void*)localFile)); | |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
233 if (rc !is XPCOM.NS_OK) Mozilla.error (rc); |
286 | 234 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
|
235 |
286 | 236 nsIFile file; |
340 | 237 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
|
238 if (rc !is XPCOM.NS_OK) Mozilla.error (rc); |
286 | 239 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
|
240 |
286 | 241 *_retval = file; |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
242 localFile.Release (); |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
243 return XPCOM.NS_OK; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
244 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
245 |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
246 return XPCOM.NS_ERROR_FAILURE; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
247 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
248 } |