Bug 465783: Fennec default download location inaccessible to users. r=sdwilsh sr=bsmedberg

This commit is contained in:
Antonio Gomes (tonikitoo) 2009-02-25 03:26:45 -04:00
parent 65d0af3965
commit f2a9697470
2 changed files with 111 additions and 82 deletions

View File

@ -1156,6 +1156,16 @@ nsDownloadManager::GetDefaultDownloadsDirectory(nsILocalFile **aResult)
}
}
#elif defined(XP_UNIX)
#if defined(NS_OSSO)
// As maemo does not follow the XDG "standard" (as usually desktop
// Linux distros do) neither has a working $HOME/Desktop folder
// for us to fallback into, "$HOME/MyDocs/.documents/" is the folder
// we found most apropriate to be the default target folder for downloads
// on the platform.
rv = dirService->Get(NS_UNIX_XDG_DOCUMENTS_DIR,
NS_GET_IID(nsILocalFile),
getter_AddRefs(downloadDir));
#else
rv = dirService->Get(NS_UNIX_DEFAULT_DOWNLOAD_DIR,
NS_GET_IID(nsILocalFile),
getter_AddRefs(downloadDir));
@ -1168,6 +1178,7 @@ nsDownloadManager::GetDefaultDownloadsDirectory(nsILocalFile **aResult)
rv = downloadDir->Append(folderName);
NS_ENSURE_SUCCESS(rv, rv);
}
#endif
#else
rv = dirService->Get(NS_OS_HOME_DIR,
NS_GET_IID(nsILocalFile),

View File

@ -421,7 +421,7 @@ GetUnixXDGUserDirectory(SystemDirectories aSystemDirectory,
{
char *dir = xdg_user_dir_lookup
(xdg_user_dirs + xdg_user_dir_offsets[aSystemDirectory -
Unix_XDG_Desktop]);
Unix_XDG_Desktop]);
nsresult rv;
nsCOMPtr<nsILocalFile> file;
@ -437,10 +437,28 @@ GetUnixXDGUserDirectory(SystemDirectories aSystemDirectory,
return rv;
rv = file->AppendNative(NS_LITERAL_CSTRING("Desktop"));
} else {
}
#if defined(NS_OSSO)
// "MYDOCSDIR" is exported to point to "/home/user/MyDocs" in maemo.
else if (Unix_XDG_Documents == aSystemDirectory) {
char *myDocs = PR_GetEnv("MYDOCSDIR");
if (!myDocs || !*myDocs)
return NS_ERROR_FAILURE;
rv = NS_NewNativeLocalFile(nsDependentCString(myDocs), PR_TRUE,
getter_AddRefs(file));
if (NS_FAILED(rv))
return rv;
rv = file->AppendNative(NS_LITERAL_CSTRING(".documents"));
}
#else
else {
// no fallback for the other XDG dirs
rv = NS_ERROR_FAILURE;
}
#endif
if (NS_FAILED(rv))
return rv;