Группа :: Сети/WWW
Пакет: firefox
Главная Изменения Спек Патчи Загрузить Bugs and FR
Патч: firefox-1.0-user-searchplugins-dir.patch
diff -Naur mozilla.old/xpcom/io/nsAppDirectoryServiceDefs.h mozilla/xpcom/io/nsAppDirectoryServiceDefs.h
--- mozilla.old/xpcom/io/nsAppDirectoryServiceDefs.h 2005-02-15 08:49:09 +0000
+++ mozilla/xpcom/io/nsAppDirectoryServiceDefs.h 2005-02-15 09:01:31 +0000
@@ -75,8 +75,10 @@
#define NS_APP_CHROME_DIR "AChrom"
#define NS_APP_PLUGINS_DIR "APlugns" // Deprecated - use NS_APP_PLUGINS_DIR_LIST
#define NS_APP_SEARCH_DIR "SrchPlugns"
+#define NS_USER_SEARCH_DIR "UsrSrchPlugns"
#define NS_APP_PLUGINS_DIR_LIST "APluginsDL"
+#define NS_APP_SEARCH_DIR_LIST "ASearchDL"
// --------------------------------------------------------------------------------------
// Files and directories which exist on a per-profile basis
diff -Naur mozilla.old/xpcom/io/nsAppFileLocationProvider.cpp mozilla/xpcom/io/nsAppFileLocationProvider.cpp
--- mozilla.old/xpcom/io/nsAppFileLocationProvider.cpp 2005-02-15 08:49:09 +0000
+++ mozilla/xpcom/io/nsAppFileLocationProvider.cpp 2005-02-15 08:53:55 +0000
@@ -252,6 +252,12 @@
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativeNativePath(SEARCH_DIR_NAME);
}
+ else if (nsCRT::strcmp(prop, NS_USER_SEARCH_DIR) == 0)
+ {
+ rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, _retval );
+ if (NS_FAILED(rv)) return rv;
+ return (*_retval)->AppendNative(SEARCH_DIR_NAME);
+ }
else if (nsCRT::strcmp(prop, NS_APP_INSTALL_CLEANUP_DIR) == 0)
{
// This is cloned so that embeddors will have a hook to override
@@ -589,5 +595,16 @@
NS_IF_ADDREF(*_retval);
rv = *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
+ if (!nsCRT::strcmp(prop, NS_APP_SEARCH_DIR_LIST))
+ {
+ static const char* keys[] = { nsnull, NS_USER_SEARCH_DIR, NS_APP_SEARCH_DIR, nsnull };
+ if (!keys[0] && !(keys[0] = PR_GetEnv("MOZ_SEARCH_ENGINE_PATH"))) {
+ static const char nullstr = 0;
+ keys[0] = &nullstr;
+ }
+ *_retval = new nsPathsDirectoryEnumerator(this, keys);
+ NS_IF_ADDREF(*_retval);
+ rv = *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
+ }
return rv;
}
diff -Naur mozilla.old/xpfe/components/search/src/nsInternetSearchService.cpp mozilla/xpfe/components/search/src/nsInternetSearchService.cpp
--- mozilla.old/xpfe/components/search/src/nsInternetSearchService.cpp 2005-02-15 08:49:36 +0000
+++ mozilla/xpfe/components/search/src/nsInternetSearchService.cpp 2005-02-15 08:53:45 +0000
@@ -997,8 +997,25 @@
// get available search engines
nsCOMPtr<nsIFile> nativeDir;
- if (NS_SUCCEEDED(rv = GetSearchFolder(getter_AddRefs(nativeDir))))
- {
+
+ nsCOMPtr<nsIProperties> dirService(do_GetService("@mozilla.org/file/directory_service;1", &rv));
+ if (NS_FAILED(rv)) return rv;
+
+ nsCOMPtr<nsISimpleEnumerator> dirList;
+ rv = dirService->Get(NS_APP_SEARCH_DIR_LIST, NS_GET_IID(nsISimpleEnumerator), getter_AddRefs(dirList));
+ if (NS_FAILED(rv)) return rv;
+
+ PRBool hasMore;
+ while (NS_SUCCEEDED(dirList->HasMoreElements(&hasMore)) && hasMore)
+ {
+ nsCOMPtr<nsISupports> supports;
+ rv = dirList->GetNext(getter_AddRefs(supports));
+ if (NS_FAILED(rv))
+ continue;
+ nativeDir = do_QueryInterface(supports, &rv);
+ if (NS_FAILED(rv))
+ continue;
+
rv = GetSearchEngineList(nativeDir, PR_FALSE, PR_FALSE);
// read in category list
@@ -2560,6 +2577,15 @@
nsCOMPtr<nsIFile> outFile;
if (NS_FAILED(rv = GetSearchFolder(getter_AddRefs(outFile)))) return(rv);
+ PRBool exists;
+ rv = outFile->Exists(&exists);
+ if (NS_FAILED(rv)) return(rv);
+ if (!exists)
+ {
+ rv = outFile->Create(nsIFile::DIRECTORY_TYPE, 0755);
+ if (NS_FAILED(rv)) return(rv);
+ }
+
const PRUnichar *dataBuf = nsnull;
if (NS_FAILED(rv = context->GetBufferConst(&dataBuf))) return(rv);
@@ -4100,7 +4126,7 @@
*searchDir = nsnull;
nsCOMPtr<nsIFile> aDir;
- nsresult rv = NS_GetSpecialDirectory(NS_APP_SEARCH_DIR, getter_AddRefs(aDir));
+ nsresult rv = NS_GetSpecialDirectory(NS_USER_SEARCH_DIR, getter_AddRefs(aDir));
if (NS_FAILED(rv)) return rv;
*searchDir = aDir;