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