updated on Sun Jan 15 08:01:04 UTC 2012
[aur-mirror.git] / firefox-pgo-beta / fix-nsGIOService.patch
blob21deb4a26c62c531c36caf244992ee2b6f5aa13d
1 Description: Various fixes for nsGIOService
2 1) Don't use the unversioned devel so
3 2) Ensure nsGIOMimeApp::GetCommand returns the full command string
4 3) Fix nsGIOService::CreateAppFromCommand to match the correct GAppInfo
5 Author: Chris Coulson <chris.coulson@canonical.com>
6 Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=611953
7 Forwarded: https://bug611953.bugzilla.mozilla.org/attachment.cgi?id=491149
9 diff --git a/toolkit/system/gnome/nsGIOService.cpp b/toolkit/system/gnome/nsGIOService.cpp
10 --- a/toolkit/system/gnome/nsGIOService.cpp
11 +++ b/toolkit/system/gnome/nsGIOService.cpp
12 @@ -101,25 +101,25 @@ nsGIOMimeApp::GetName(nsACString& aName)
13 return NS_OK;
16 NS_IMETHODIMP
17 nsGIOMimeApp::GetCommand(nsACString& aCommand)
19 get_commandline_t g_app_info_get_commandline_ptr;
21 - void *libHandle = dlopen("libgio-2.0.so", RTLD_LAZY);
22 + void *libHandle = dlopen("libgio-2.0.so.0", RTLD_LAZY);
23 if (!libHandle) {
24 return NS_ERROR_FAILURE;
26 dlerror(); /* clear any existing error */
27 g_app_info_get_commandline_ptr =
28 (get_commandline_t) dlsym(libHandle, "g_app_info_get_commandline");
29 - if (dlerror() != NULL) {
30 - const char cmd = *g_app_info_get_commandline_ptr(mApp);
31 + if (dlerror() == NULL) {
32 + const char *cmd = g_app_info_get_commandline_ptr(mApp);
33 if (!cmd) {
34 dlclose(libHandle);
35 return NS_ERROR_FAILURE;
37 aCommand.Assign(cmd);
39 dlclose(libHandle);
40 return NS_OK;
41 @@ -414,75 +414,46 @@ nsGIOService::CreateAppFromCommand(nsACS
42 nsIGIOMimeApp** appInfo)
44 GError *error = NULL;
45 *appInfo = nsnull;
47 GAppInfo *app_info = NULL, *app_info_from_list = NULL;
48 GList *apps = g_app_info_get_all();
49 GList *apps_p = apps;
50 - get_commandline_t g_app_info_get_commandline_ptr;
52 - void *libHandle = dlopen("libgio-2.0.so", RTLD_LAZY);
53 - if (!libHandle) {
54 - return NS_ERROR_FAILURE;
55 - }
56 - dlerror(); /* clear any existing error */
57 - g_app_info_get_commandline_ptr =
58 - (get_commandline_t) dlsym(libHandle, "g_app_info_get_commandline");
59 - if (dlerror() != NULL) {
60 - g_app_info_get_commandline_ptr = NULL;
61 - }
63 // Try to find relevant and existing GAppInfo in all installed application
64 + // We do this by comparing each GAppInfo's executable with out own
65 while (apps_p) {
66 app_info_from_list = (GAppInfo*) apps_p->data;
67 - /* This is a silly test. It just compares app names but not
68 - * commands. This is due to old version of Glib/Gio. The required
69 - * function which allows to do a regular check of existence of desktop file
70 - * is possible by using function g_app_info_get_commandline. This function
71 - * has been introduced in Glib 2.20. */
72 - if (app_info_from_list && strcmp(g_app_info_get_name(app_info_from_list),
73 - PromiseFlatCString(appName).get()) == 0 )
74 - {
75 - if (g_app_info_get_commandline_ptr)
76 - {
77 - /* Following test is only possible with Glib >= 2.20.
78 - * Compare path only by using strncmp */
79 - if (strncmp(g_app_info_get_commandline_ptr(app_info_from_list),
80 - PromiseFlatCString(cmd).get(),
81 - strlen(PromiseFlatCString(cmd).get())) == 0)
82 - {
83 - app_info = app_info_from_list;
84 - break;
85 - } else {
86 - g_object_unref(app_info_from_list);
87 - }
88 - } else {
89 + if (!app_info) {
90 + // If the executable is not absolute, get it's full path
91 + char *executable = g_find_program_in_path(g_app_info_get_executable(app_info_from_list));
93 + if (executable && strcmp(executable, PromiseFlatCString(cmd).get()) == 0) {
94 + g_object_ref (app_info_from_list);
95 app_info = app_info_from_list;
96 - break;
98 - } else {
99 - g_object_unref(app_info_from_list);
100 + g_free(executable);
103 + g_object_unref(app_info_from_list);
104 apps_p = apps_p->next;
106 g_list_free(apps);
108 if (!app_info) {
109 app_info = g_app_info_create_from_commandline(PromiseFlatCString(cmd).get(),
110 PromiseFlatCString(appName).get(),
111 G_APP_INFO_CREATE_SUPPORTS_URIS,
112 &error);
115 if (!app_info) {
116 g_warning("Cannot create application info from command: %s", error->message);
117 g_error_free(error);
118 - dlclose(libHandle);
119 return NS_ERROR_FAILURE;
121 nsGIOMimeApp *mozApp = new nsGIOMimeApp(app_info);
122 NS_ENSURE_TRUE(mozApp, NS_ERROR_OUT_OF_MEMORY);
123 NS_ADDREF(*appInfo = mozApp);
124 - dlclose(libHandle);
125 return NS_OK;