49 Components.utils.import(
"resource://app/jsmodules/PlatformUtils.jsm");
50 Components.utils.import(
"resource://app/jsmodules/SBDataRemoteUtils.jsm");
51 Components.utils.import(
"resource://app/jsmodules/StringUtils.jsm");
60 const Cc = Components.classes;
61 const Ci = Components.interfaces;
62 const Cr = Components.results
67 var directorySvc =
Cc[
"@mozilla.org/file/directory_service;1"]
68 .getService(
Ci.nsIProperties);
71 if (directorySvc.has(
"Home")) {
72 homeDir = directorySvc.get(
"Home",
Ci.nsIFile);
77 var defaultScanPath =
null;
78 var platform = PlatformUtils.platformString;
83 musicDir = directorySvc.get(
"Music",
Ci.nsIFile);
89 if(musicDir && musicDir.exists() && musicDir.isReadable()) {
91 defaultScanPath = musicDir;
95 let folder = directorySvc.get(
"Pers",
Ci.nsIFile).clone();
98 folder.append(
SBString(
"folder_paths.music.windows",
"My Music"));
100 if(folder.exists() && folder.isReadable()) {
101 defaultScanPath = folder;
106 folder = homeDir.clone();
107 folder.append(
SBString(
"folder_paths.music.vista",
"Music"));
109 if(folder.exists() && folder.isReadable()) {
110 defaultScanPath = folder;
118 musicDir = directorySvc.get(
"Music",
Ci.nsIFile);
124 if(musicDir && musicDir.exists() && musicDir.isReadable()) {
126 defaultScanPath = musicDir;
130 let defaultScanDir = homeDir.clone();
131 defaultScanDir.append(
SBString(
"folder_paths.music.darwin",
"Music"));
132 if (defaultScanDir.exists()) {
133 defaultScanPath = defaultScanDir;
143 musicDir = directorySvc.get(
"XDGMusic",
Ci.nsIFile);
149 if(musicDir && musicDir.exists() && musicDir.isReadable()) {
151 defaultScanPath = musicDir;
154 let folder = homeDir.clone();
155 let folderName =
SBString(
"folder_paths.music.linux",
"Music");
156 folder.append(folderName);
158 if(folder.exists() && folder.isReadable()) {
159 defaultScanPath = folder;
162 folder = homeDir.clone();
163 folder.append(folderName.toLowerCase());
165 if(folder.exists() && folder.isReadable()) {
166 defaultScanPath = folder;
173 defaultScanPath =
null;
177 return defaultScanPath;
182 var directorySvc =
Cc[
"@mozilla.org/file/directory_service;1"]
183 .getService(
Ci.nsIProperties);
186 if (directorySvc.has(
"Home")) {
187 homeDir = directorySvc.get(
"Home",
Ci.nsIFile);
192 var defaultScanPath =
null;
193 var platform = PlatformUtils.platformString;
198 mediaDir = directorySvc.get(
"Video",
Ci.nsIFile);
204 if(mediaDir && mediaDir.exists() && mediaDir.isReadable()) {
206 defaultScanPath = mediaDir;
210 let folder = directorySvc.get(
"Pers",
Ci.nsIFile).clone();
213 folder.append(
SBString(
"folder_paths.videos.windows",
"My Videos"));
215 if(folder.exists() && folder.isReadable()) {
216 defaultScanPath = folder;
221 folder = homeDir.clone();
222 folder.append(
SBString(
"folder_paths.videos.vista",
"Videos"));
224 if(folder.exists() && folder.isReadable()) {
225 defaultScanPath = folder;
233 mediaDir = directorySvc.get(
"Movies",
Ci.nsIFile);
239 if(mediaDir && mediaDir.exists() && mediaDir.isReadable()) {
241 defaultScanPath = mediaDir;
245 let defaultScanDir = homeDir.clone();
246 defaultScanDir.append(
SBString(
"folder_paths.videos.darwin",
"Movies"));
247 if (defaultScanDir.exists()) {
248 defaultScanPath = defaultScanDir;
258 mediaDir = directorySvc.get(
"XDGVids",
Ci.nsIFile);
264 if(mediaDir && mediaDir.exists() && mediaDir.isReadable()) {
266 defaultScanPath = mediaDir;
269 let folder = homeDir.clone();
270 let folderName =
SBString(
"folder_paths.videos.linux",
"Videos");
271 folder.append(folderName);
273 if(folder.exists() && folder.isReadable()) {
274 defaultScanPath = folder;
277 folder = homeDir.clone();
278 folder.append(folderName.toLowerCase());
280 if(folder.exists() && folder.isReadable()) {
281 defaultScanPath = folder;
288 defaultScanPath =
null;
292 return defaultScanPath;
295 getMediaFolder:
function (aContentType) {
296 switch (aContentType) {
297 case "audio":
return this.musicFolder
298 case Ci.sbIMediaList.CONTENTTYPE_AUDIO:
return this.musicFolder;
299 case "video":
return this.videoFolder;
300 case Ci.sbIMediaList.CONTENTTYPE_VIDEO:
return this.videoFolder;
306 getDownloadFolder:
function (aContentType) {
307 var downloadFolder = this.getMediaFolder(aContentType);
309 if(downloadFolder ==
null) {
310 var directorySvc =
Cc[
"@mozilla.org/file/directory_service;1"]
311 .getService(
Ci.nsIProperties);
315 downloadFolder = directorySvc.get(
"Desk",
Ci.nsIFile);
318 downloadFolder =
null;
322 return downloadFolder;
function SBString(aKey, aDefault, aStringBundle)