Put compreg.dat in the profile.
This commit is contained in:
parent
4a8493f95e
commit
ef00d72ca8
@ -16,23 +16,43 @@ NS_IMPL_ISUPPORTS2 (GeckoDirectoryProvider,
|
|||||||
nsIDirectoryServiceProvider,
|
nsIDirectoryServiceProvider,
|
||||||
nsIDirectoryServiceProvider2)
|
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()
|
GeckoDirectoryProvider::~GeckoDirectoryProvider()
|
||||||
{
|
{
|
||||||
if(mComponentPath)
|
if(mComponentPath)
|
||||||
g_free(mComponentPath);
|
g_free(mComponentPath);
|
||||||
|
if(mCompregPath)
|
||||||
|
g_free(mCompregPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* nsIFile getFile (in string prop, out PRBool persistent); */
|
/* nsIFile getFile (in string prop, out PRBool persistent); */
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
GeckoDirectoryProvider::GetFile (const char *prop,
|
GeckoDirectoryProvider::GetFile (const char *prop,
|
||||||
PRBool *persistent,
|
PRBool *persistent,
|
||||||
nsIFile **_retval)
|
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;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +67,7 @@ GeckoDirectoryProvider::GetFiles (const char *aProperty, nsISimpleEnumerator **a
|
|||||||
nsCOMPtr<nsILocalFile> componentDir;
|
nsCOMPtr<nsILocalFile> componentDir;
|
||||||
rv = NS_NewNativeLocalFile(nsDependentCString(mComponentPath),
|
rv = NS_NewNativeLocalFile(nsDependentCString(mComponentPath),
|
||||||
PR_TRUE,
|
PR_TRUE,
|
||||||
getter_AddRefs (componentDir));
|
getter_AddRefs(componentDir));
|
||||||
NS_ENSURE_SUCCESS (rv, rv);
|
NS_ENSURE_SUCCESS (rv, rv);
|
||||||
|
|
||||||
nsCOMArray<nsIFile> array;
|
nsCOMArray<nsIFile> array;
|
||||||
@ -61,6 +81,6 @@ GeckoDirectoryProvider::GetFiles (const char *aProperty, nsISimpleEnumerator **a
|
|||||||
rv = NS_SUCCESS_AGGREGATE_RESULT;
|
rv = NS_SUCCESS_AGGREGATE_RESULT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -28,11 +28,13 @@ class GeckoDirectoryProvider : public nsIDirectoryServiceProvider2
|
|||||||
NS_DECL_NSIDIRECTORYSERVICEPROVIDER
|
NS_DECL_NSIDIRECTORYSERVICEPROVIDER
|
||||||
NS_DECL_NSIDIRECTORYSERVICEPROVIDER2
|
NS_DECL_NSIDIRECTORYSERVICEPROVIDER2
|
||||||
|
|
||||||
GeckoDirectoryProvider(const char *sugar_path);
|
GeckoDirectoryProvider(const char *sugar_path,
|
||||||
|
const char *profile_path);
|
||||||
virtual ~GeckoDirectoryProvider();
|
virtual ~GeckoDirectoryProvider();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char *mComponentPath;
|
char *mComponentPath;
|
||||||
|
char *mCompregPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* GECKO_DIRECTORY_PROVIDER_H */
|
#endif /* GECKO_DIRECTORY_PROVIDER_H */
|
||||||
|
@ -148,6 +148,39 @@ setup_plugin_path ()
|
|||||||
g_free (new_path);
|
g_free (new_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
setup_directory_provider(const char *full_prof_path)
|
||||||
|
{
|
||||||
|
const char *prefix = g_getenv("SUGAR_PREFIX");
|
||||||
|
if (prefix == NULL) {
|
||||||
|
g_print("The SUGAR_PREFIX environment variable is not set.");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *components_path = g_build_filename(prefix, "share/sugar", NULL);
|
||||||
|
|
||||||
|
GeckoDirectoryProvider *dirProvider =
|
||||||
|
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));
|
||||||
|
NS_RELEASE (dirProvider);
|
||||||
|
dirProvider = nsnull;
|
||||||
|
|
||||||
|
if (!dp) return FALSE;
|
||||||
|
|
||||||
|
gtk_moz_embed_set_directory_service_provider(dp);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
sugar_browser_startup(const char *profile_path, const char *profile_name)
|
sugar_browser_startup(const char *profile_path, const char *profile_name)
|
||||||
{
|
{
|
||||||
@ -159,32 +192,11 @@ sugar_browser_startup(const char *profile_path, const char *profile_name)
|
|||||||
|
|
||||||
old_handler = XSetErrorHandler(error_handler);
|
old_handler = XSetErrorHandler(error_handler);
|
||||||
|
|
||||||
const char *prefix = g_getenv("SUGAR_PREFIX");
|
char *full_prof_path = g_build_filename(profile_path, profile_name, NULL);
|
||||||
if (prefix == NULL) {
|
if (!setup_directory_provider(full_prof_path)) {
|
||||||
g_print("The SUGAR_PREFIX environment variable is not set.");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *components_path = g_build_filename(prefix, "share/sugar", NULL);
|
|
||||||
|
|
||||||
GeckoDirectoryProvider *dirProvider =
|
|
||||||
new GeckoDirectoryProvider(components_path);
|
|
||||||
if (!dirProvider) {
|
|
||||||
g_warning ("failed to create GeckoDirectoryProvider");
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
g_free(full_prof_path);
|
||||||
g_free(components_path);
|
|
||||||
|
|
||||||
NS_ADDREF (dirProvider);
|
|
||||||
|
|
||||||
nsCOMPtr<nsIDirectoryServiceProvider> dp (do_QueryInterface (dirProvider));
|
|
||||||
NS_RELEASE (dirProvider);
|
|
||||||
dirProvider = nsnull;
|
|
||||||
|
|
||||||
if (!dp) return FALSE;
|
|
||||||
|
|
||||||
gtk_moz_embed_set_directory_service_provider(dp);
|
|
||||||
|
|
||||||
gtk_moz_embed_push_startup();
|
gtk_moz_embed_push_startup();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user