fixing non libxul directory service handling; thanks smaug

This commit is contained in:
timeless%mozdev.org 2006-12-04 15:39:33 +00:00
Родитель 192ae56099
Коммит 0bbc537403
2 изменённых файлов: 28 добавлений и 10 удалений

Просмотреть файл

@ -574,12 +574,20 @@ nsresult EmbedGlobalHistory::InitFile()
// Get the history file in our profile dir.
// Notice we are not just getting NS_APP_HISTORY_50_FILE
// because it is used by the "real" global history component.
#ifdef MOZ_ENABLE_LIBXUL
if (EmbedPrivate::sProfileDir) {
nsString path;
EmbedPrivate::sProfileDir->GetPath(path);
mHistoryFile = g_strdup_printf("%s/history.dat", NS_ConvertUTF16toUTF8(path).get());
nsCString path;
EmbedPrivate::sProfileDir->GetNativePath(path);
mHistoryFile = g_strdup_printf("%s/history.dat", path.get());
BROKEN_STRING_BUILDER(mHistoryFile);
} else {
} else
#else
if (EmbedPrivate::sProfileDirS) {
mHistoryFile = g_strdup_printf("%s/history.dat", EmbedPrivate::sProfileDirS);
BROKEN_STRING_BUILDER(mHistoryFile);
} else
#endif
{
mHistoryFile = g_strdup_printf("%s/history.dat", g_get_tmp_dir());
}
void *uri = file_handle_uri_new(mHistoryFile);

Просмотреть файл

@ -243,9 +243,21 @@ GTKEmbedDirectoryProvider::GetFile(const char *aKey, PRBool *aPersist,
return rv;
}
if (EmbedPrivate::sProfileDir && !strcmp(aKey, NS_APP_USER_PROFILE_50_DIR)) {
if (!strcmp(aKey, NS_APP_USER_PROFILE_50_DIR)) {
#ifdef MOZ_ENABLE_LIBXUL
EmbedPrivate::sProfileDir && !strcmp(aKey, NS_APP_USER_PROFILE_50_DIR)) {
*aPersist = PR_TRUE;
return EmbedPrivate::sProfileDir->Clone(aResult);
#else
nsCOMPtr<nsILocalFile> profDir =
do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv);
if (NS_FAILED(rv))
return rv;
rv = profDir->InitWithNativePath(nsDependentCString(EmbedPrivate::sProfileDirS));
if (NS_FAILED(rv))
return rv;
NS_ADDREF(*aResult = profDir);
#endif
}
return NS_ERROR_FAILURE;
@ -927,18 +939,16 @@ EmbedPrivate::SetAppComponents(const nsModuleComponentInfo* aComps,
void
EmbedPrivate::SetProfilePath(const char *aDir, const char *aName)
{
#ifdef MOZ_ENABLE_LIBXUL
if (EmbedPrivate::sProfileDir) {
if (sWidgetCount) {
NS_ERROR("Cannot change profile directory during run.");
return;
}
#ifdef MOZ_ENABLE_LIBXUL
NS_RELEASE(EmbedPrivate::sProfileDir);
NS_RELEASE(EmbedPrivate::sProfileLock);
#endif
}
#ifdef MOZ_ENABLE_LIBXUL
nsresult rv =
NS_NewNativeLocalFile(nsDependentCString(aDir), PR_TRUE, &EmbedPrivate::sProfileDir);
@ -964,9 +974,9 @@ EmbedPrivate::SetProfilePath(const char *aDir, const char *aName)
NS_IF_RELEASE(EmbedPrivate::sProfileDir);
NS_IF_RELEASE(EmbedPrivate::sProfileLock);
#else
if (sProfileDir) {
if (sProfileDirS) {
nsMemory::Free(sProfileDirS);
sProfileDir = nsnull;
sProfileDirS = nsnull;
}
if (sProfileName) {