changeset 25851:291b84bf4f8b

Finish up the GNOME URL handler code: - Properly capture (and ignore) stderr. - If there exists a /desktop/gnome/url-handlers/PROTOCOL/enabled flag, honor it. Fixes #5715
author Richard Laager <rlaager@wiktel.com>
date Fri, 28 Nov 2008 00:42:22 +0000
parents 5b16203f76be
children b38cbefca6ad
files pidgin/gtkutils.c
diffstat 1 files changed, 24 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtkutils.c	Fri Nov 28 00:33:40 2008 +0000
+++ b/pidgin/gtkutils.c	Fri Nov 28 00:42:22 2008 +0000
@@ -3573,6 +3573,7 @@
 register_gnome_url_handlers()
 {
 	char *tmp;
+	char *err;
 	char *c;
 	char *start;
 
@@ -3582,8 +3583,13 @@
 
 	tmp = NULL;
 	if (!g_spawn_command_line_sync("gconftool-2 --all-dirs /desktop/gnome/url-handlers",
-	                               &tmp, NULL, NULL, NULL))
+	                               &tmp, &err, NULL, NULL))
+	{
+		g_free(err);
 		g_return_val_if_reached(FALSE);
+	}
+	g_free(err);
+	err = NULL;
 
 	for (c = start = tmp ; *c ; c++)
 	{
@@ -3595,8 +3601,25 @@
 			*c = '\0';
 			if (g_str_has_prefix(start, "/desktop/gnome/url-handlers/"))
 			{
+				char *cmd;
+				char *tmp2 = NULL;
 				char *protocol;
 
+				/* If there is an enabled boolean, honor it. */
+				cmd = g_strdup_printf("gconftool-2 -g %s/enabled", start);
+				if (g_spawn_command_line_sync(cmd, &tmp2, &err, NULL, NULL))
+				{
+					g_free(err);
+					if (!strcmp(tmp2, "false\n"))
+					{
+						g_free(tmp2);
+						start = c + 1;
+						continue;
+					}
+					else
+						g_free(tmp2);
+				}
+
 				start += sizeof("/desktop/gnome/url-handlers/") - 1;
 				protocol = g_strdup_printf("%s:", start);
 				gnome_url_handlers = g_list_prepend(gnome_url_handlers, protocol);