aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2012-04-04 09:59:07 -0500
committerCharles Kerr <charles.kerr@canonical.com>2012-04-04 09:59:07 -0500
commit0a10a54cffe3e7f1cbc709461c1a8c32a66d4d70 (patch)
tree99c101a6f887b81b6a92fca9dbd7c05ebc114c12
parent3891a6cbb69599fe8de9b11d70cd058ecefb9722 (diff)
parentf2aefd61b55b2784cc8a2a24026e64cef84f0e4d (diff)
downloadayatana-indicator-messages-0a10a54cffe3e7f1cbc709461c1a8c32a66d4d70.tar.gz
ayatana-indicator-messages-0a10a54cffe3e7f1cbc709461c1a8c32a66d4d70.tar.bz2
ayatana-indicator-messages-0a10a54cffe3e7f1cbc709461c1a8c32a66d4d70.zip
Merge lp:~larsu/indicator-messages/fix-blacklist-again to revert blacklist changes so that apps relying on the old behavior will work again.
The new policy is: if a file in the blacklist folder is a symbolic link, use its target. If its filename ends on .desktop, use the file's basename (so that copying files works). Otherwise, use the contents of file (first line should contain path to a desktop file). Xref: bug #939258 and http://bazaar.launchpad.net/~indicator-applet-developers/indicator-messages/trunk.0.6/revision/259
-rw-r--r--src/messages-service.c46
1 files changed, 45 insertions, 1 deletions
diff --git a/src/messages-service.c b/src/messages-service.c
index c975df1..981c286 100644
--- a/src/messages-service.c
+++ b/src/messages-service.c
@@ -321,14 +321,58 @@ desktop_file_from_keyfile (const gchar * definition_file)
return desktopfile;
}
+/* Check if path is a symlink and return its target if it is */
+static gchar *
+get_symlink_target (const gchar *path)
+{
+ GFile *file;
+ GFileInfo *fileinfo;
+ gchar *target = NULL;
+
+ file = g_file_new_for_path (path);
+
+ fileinfo = g_file_query_info (file, "standard::is-symlink",
+ G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+ NULL, NULL);
+ g_object_unref (file);
+
+ if (!fileinfo)
+ return NULL;
+
+ if (g_file_info_get_is_symlink (fileinfo))
+ target = g_strdup (g_file_info_get_symlink_target (fileinfo));
+
+ g_object_unref (fileinfo);
+ return target;
+}
+
/* Add a definition file into the black list and eclipse
any launchers that have the same file. */
static gboolean
blacklist_add (gpointer udata)
{
gchar * definition_file = (gchar *)udata;
+ gchar * symlink_target = get_symlink_target (definition_file);
+ gchar * contents = NULL;
- blacklist_add_core(definition_file, definition_file);
+ if (symlink_target)
+ {
+ blacklist_add_core (symlink_target, definition_file);
+ g_free (symlink_target);
+ }
+ else if (g_str_has_suffix (definition_file, ".desktop"))
+ {
+ blacklist_add_core(definition_file, definition_file);
+ }
+ else if (g_file_get_contents (definition_file, &contents, NULL, NULL))
+ {
+ gchar *trimmed = pango_trim_string (contents);
+ blacklist_add_core (trimmed, definition_file);
+ g_free (trimmed);
+ g_free (contents);
+ }
+ else
+ g_warning ("invalid blacklist entry: %s", definition_file);
return FALSE;
}