Put compreg.dat in the profile.

master
Marco Pesenti Gritti 17 years ago
parent 4a8493f95e
commit ef00d72ca8

@ -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;
}

@ -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 */

@ -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();

Loading…
Cancel
Save