Annotation of /trunk/mozilla-firefox/patches/mozilla-firefox-1.0.7-usr-search-dir.patch
Parent Directory | Revision Log
Revision 153 -
(hide annotations)
(download)
Tue May 8 20:52:56 2007 UTC (17 years, 4 months ago) by niro
File size: 3835 byte(s)
Tue May 8 20:52:56 2007 UTC (17 years, 4 months ago) by niro
File size: 3835 byte(s)
-import
1 | niro | 153 | --- mozilla-firefox-1.0.4.orig/xpcom/io/nsAppDirectoryServiceDefs.h |
2 | +++ mozilla-firefox-1.0.4/xpcom/io/nsAppDirectoryServiceDefs.h | ||
3 | @@ -75,8 +75,10 @@ | ||
4 | #define NS_APP_CHROME_DIR "AChrom" | ||
5 | #define NS_APP_PLUGINS_DIR "APlugns" // Deprecated - use NS_APP_PLUGINS_DIR_LIST | ||
6 | #define NS_APP_SEARCH_DIR "SrchPlugns" | ||
7 | +#define NS_USER_SEARCH_DIR "UsrSrchPlugns" | ||
8 | |||
9 | #define NS_APP_PLUGINS_DIR_LIST "APluginsDL" | ||
10 | +#define NS_APP_SEARCH_DIR_LIST "ASearchDL" | ||
11 | |||
12 | // -------------------------------------------------------------------------------------- | ||
13 | // Files and directories which exist on a per-profile basis | ||
14 | --- mozilla-firefox-1.0.4.orig/xpcom/io/nsAppFileLocationProvider.cpp | ||
15 | +++ mozilla-firefox-1.0.4/xpcom/io/nsAppFileLocationProvider.cpp | ||
16 | @@ -252,6 +252,12 @@ | ||
17 | if (NS_SUCCEEDED(rv)) | ||
18 | rv = localFile->AppendRelativeNativePath(SEARCH_DIR_NAME); | ||
19 | } | ||
20 | + else if (nsCRT::strcmp(prop, NS_USER_SEARCH_DIR) == 0) | ||
21 | + { | ||
22 | + rv = GetProductDirectory(getter_AddRefs(localFile)); | ||
23 | + if (NS_SUCCEEDED(rv)) | ||
24 | + rv = localFile->AppendRelativeNativePath(SEARCH_DIR_NAME); | ||
25 | + } | ||
26 | else if (nsCRT::strcmp(prop, NS_APP_INSTALL_CLEANUP_DIR) == 0) | ||
27 | { | ||
28 | // This is cloned so that embeddors will have a hook to override | ||
29 | @@ -589,5 +595,16 @@ | ||
30 | NS_IF_ADDREF(*_retval); | ||
31 | rv = *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY; | ||
32 | } | ||
33 | + if (!nsCRT::strcmp(prop, NS_APP_SEARCH_DIR_LIST)) | ||
34 | + { | ||
35 | + static const char* keys[] = { nsnull, NS_USER_SEARCH_DIR, NS_APP_SEARCH_DIR, nsnull }; | ||
36 | + if (!keys[0] && !(keys[0] = PR_GetEnv("MOZ_SEARCH_ENGINE_PATH"))) { | ||
37 | + static const char nullstr = 0; | ||
38 | + keys[0] = &nullstr; | ||
39 | + } | ||
40 | + *_retval = new nsPathsDirectoryEnumerator(this, keys); | ||
41 | + NS_IF_ADDREF(*_retval); | ||
42 | + rv = *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY; | ||
43 | + } | ||
44 | return rv; | ||
45 | } | ||
46 | --- mozilla-firefox-1.0.4.orig/xpfe/components/search/src/nsInternetSearchService.cpp | ||
47 | +++ mozilla-firefox-1.0.4/xpfe/components/search/src/nsInternetSearchService.cpp | ||
48 | @@ -997,8 +997,25 @@ | ||
49 | |||
50 | // get available search engines | ||
51 | nsCOMPtr<nsIFile> nativeDir; | ||
52 | - if (NS_SUCCEEDED(rv = GetSearchFolder(getter_AddRefs(nativeDir)))) | ||
53 | - { | ||
54 | + | ||
55 | + nsCOMPtr<nsIProperties> dirService(do_GetService("@mozilla.org/file/directory_service;1", &rv)); | ||
56 | + if (NS_FAILED(rv)) return rv; | ||
57 | + | ||
58 | + nsCOMPtr<nsISimpleEnumerator> dirList; | ||
59 | + rv = dirService->Get(NS_APP_SEARCH_DIR_LIST, NS_GET_IID(nsISimpleEnumerator), getter_AddRefs(dirList)); | ||
60 | + if (NS_FAILED(rv)) return rv; | ||
61 | + | ||
62 | + PRBool hasMore; | ||
63 | + while (NS_SUCCEEDED(dirList->HasMoreElements(&hasMore)) && hasMore) | ||
64 | + { | ||
65 | + nsCOMPtr<nsISupports> supports; | ||
66 | + rv = dirList->GetNext(getter_AddRefs(supports)); | ||
67 | + if (NS_FAILED(rv)) | ||
68 | + continue; | ||
69 | + nativeDir = do_QueryInterface(supports, &rv); | ||
70 | + if (NS_FAILED(rv)) | ||
71 | + continue; | ||
72 | + | ||
73 | rv = GetSearchEngineList(nativeDir, PR_FALSE, PR_FALSE); | ||
74 | |||
75 | // read in category list | ||
76 | @@ -2574,6 +2591,15 @@ | ||
77 | nsCOMPtr<nsIFile> outFile; | ||
78 | if (NS_FAILED(rv = GetSearchFolder(getter_AddRefs(outFile)))) return(rv); | ||
79 | |||
80 | + PRBool exists; | ||
81 | + rv = outFile->Exists(&exists); | ||
82 | + if (NS_FAILED(rv)) return(rv); | ||
83 | + if (!exists) | ||
84 | + { | ||
85 | + rv = outFile->Create(nsIFile::DIRECTORY_TYPE, 0755); | ||
86 | + if (NS_FAILED(rv)) return(rv); | ||
87 | + } | ||
88 | + | ||
89 | const PRUnichar *dataBuf = nsnull; | ||
90 | if (NS_FAILED(rv = context->GetBufferConst(&dataBuf))) return(rv); | ||
91 | |||
92 | @@ -4133,7 +4159,7 @@ | ||
93 | *searchDir = nsnull; | ||
94 | |||
95 | nsCOMPtr<nsIFile> aDir; | ||
96 | - nsresult rv = NS_GetSpecialDirectory(NS_APP_SEARCH_DIR, getter_AddRefs(aDir)); | ||
97 | + nsresult rv = NS_GetSpecialDirectory(NS_USER_SEARCH_DIR, getter_AddRefs(aDir)); | ||
98 | if (NS_FAILED(rv)) return rv; | ||
99 | |||
100 | *searchDir = aDir; |