diff options
author | Marco Pesenti Gritti <marco@localhost.localdomain> | 2007-05-15 10:22:26 (GMT) |
---|---|---|
committer | Marco Pesenti Gritti <marco@localhost.localdomain> | 2007-05-15 10:22:26 (GMT) |
commit | ef00d72ca806e53063a7834679833a906e12bcb0 (patch) | |
tree | f99a146159c9bb4b28108ab4586828ad83c8e84f | |
parent | 4a8493f95e4df95cfbdb0705c146342f4b8cab58 (diff) |
Put compreg.dat in the profile.
-rw-r--r-- | browser/GeckoDirectoryProvider.cpp | 32 | ||||
-rw-r--r-- | browser/GeckoDirectoryProvider.h | 4 | ||||
-rw-r--r-- | browser/sugar-browser.cpp | 36 |
3 files changed, 53 insertions, 19 deletions
diff --git a/browser/GeckoDirectoryProvider.cpp b/browser/GeckoDirectoryProvider.cpp index c94a7cf..f59d26a 100644 --- a/browser/GeckoDirectoryProvider.cpp +++ b/browser/GeckoDirectoryProvider.cpp @@ -16,23 +16,43 @@ NS_IMPL_ISUPPORTS2 (GeckoDirectoryProvider, nsIDirectoryServiceProvider, nsIDirectoryServiceProvider2) -GeckoDirectoryProvider::GeckoDirectoryProvider(const char *sugar_path) +GeckoDirectoryProvider::GeckoDirectoryProvider(const char *sugar_path, + const char *profile_path) { - mComponentPath = g_strconcat(sugar_path, "/mozilla/components", NULL); + mComponentPath = g_build_filename + (sugar_path, "mozilla", "components", NULL); + mCompregPath = g_build_filename + (profile_path, "compreg.dat", NULL); } GeckoDirectoryProvider::~GeckoDirectoryProvider() { if(mComponentPath) g_free(mComponentPath); + if(mCompregPath) + g_free(mCompregPath); } /* nsIFile getFile (in string prop, out PRBool persistent); */ NS_IMETHODIMP GeckoDirectoryProvider::GetFile (const char *prop, - PRBool *persistent, - nsIFile **_retval) + PRBool *persistent, + nsIFile **_retval) { + nsresult rv = NS_ERROR_FAILURE; + nsCOMPtr<nsILocalFile> file; + + if (!strcmp(prop, NS_XPCOM_COMPONENT_REGISTRY_FILE)) { + rv = NS_NewNativeLocalFile(nsDependentCString(mCompregPath), + PR_TRUE, + getter_AddRefs(file)); + } + + if (NS_SUCCEEDED(rv) && file) { + NS_ADDREF(*_retval = file); + return NS_OK; + } + return NS_ERROR_FAILURE; } @@ -47,7 +67,7 @@ GeckoDirectoryProvider::GetFiles (const char *aProperty, nsISimpleEnumerator **a nsCOMPtr<nsILocalFile> componentDir; rv = NS_NewNativeLocalFile(nsDependentCString(mComponentPath), PR_TRUE, - getter_AddRefs (componentDir)); + getter_AddRefs(componentDir)); NS_ENSURE_SUCCESS (rv, rv); nsCOMArray<nsIFile> array; @@ -61,6 +81,6 @@ GeckoDirectoryProvider::GetFiles (const char *aProperty, nsISimpleEnumerator **a rv = NS_SUCCESS_AGGREGATE_RESULT; } } - + return rv; } diff --git a/browser/GeckoDirectoryProvider.h b/browser/GeckoDirectoryProvider.h index 5b74169..db6ccc9 100644 --- a/browser/GeckoDirectoryProvider.h +++ b/browser/GeckoDirectoryProvider.h @@ -28,11 +28,13 @@ class GeckoDirectoryProvider : public nsIDirectoryServiceProvider2 NS_DECL_NSIDIRECTORYSERVICEPROVIDER NS_DECL_NSIDIRECTORYSERVICEPROVIDER2 - GeckoDirectoryProvider(const char *sugar_path); + GeckoDirectoryProvider(const char *sugar_path, + const char *profile_path); virtual ~GeckoDirectoryProvider(); private: char *mComponentPath; + char *mCompregPath; }; #endif /* GECKO_DIRECTORY_PROVIDER_H */ diff --git a/browser/sugar-browser.cpp b/browser/sugar-browser.cpp index d5644da..2cee6d2 100644 --- a/browser/sugar-browser.cpp +++ b/browser/sugar-browser.cpp @@ -148,17 +148,9 @@ setup_plugin_path () g_free (new_path); } -gboolean -sugar_browser_startup(const char *profile_path, const char *profile_name) +static gboolean +setup_directory_provider(const char *full_prof_path) { - nsresult rv; - - setup_plugin_path(); - - gtk_moz_embed_set_profile_path(profile_path, profile_name); - - old_handler = XSetErrorHandler(error_handler); - const char *prefix = g_getenv("SUGAR_PREFIX"); if (prefix == NULL) { g_print("The SUGAR_PREFIX environment variable is not set."); @@ -168,14 +160,14 @@ sugar_browser_startup(const char *profile_path, const char *profile_name) char *components_path = g_build_filename(prefix, "share/sugar", NULL); GeckoDirectoryProvider *dirProvider = - new GeckoDirectoryProvider(components_path); + new GeckoDirectoryProvider(components_path, full_prof_path); if (!dirProvider) { g_warning ("failed to create GeckoDirectoryProvider"); return FALSE; } g_free(components_path); - + NS_ADDREF (dirProvider); nsCOMPtr<nsIDirectoryServiceProvider> dp (do_QueryInterface (dirProvider)); @@ -185,6 +177,26 @@ sugar_browser_startup(const char *profile_path, const char *profile_name) if (!dp) return FALSE; gtk_moz_embed_set_directory_service_provider(dp); + + return TRUE; +} + +gboolean +sugar_browser_startup(const char *profile_path, const char *profile_name) +{ + nsresult rv; + + setup_plugin_path(); + + gtk_moz_embed_set_profile_path(profile_path, profile_name); + + old_handler = XSetErrorHandler(error_handler); + + char *full_prof_path = g_build_filename(profile_path, profile_name, NULL); + if (!setup_directory_provider(full_prof_path)) { + return FALSE; + } + g_free(full_prof_path); gtk_moz_embed_push_startup(); |