aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Uebernickel <lars.uebernickel@canonical.com>2012-04-04 10:46:05 +0200
committerLars Uebernickel <lars.uebernickel@canonical.com>2012-04-04 10:46:05 +0200
commit564b5157b51c99c201597b06fe6c9f02e62b94eb (patch)
tree9795a5daa84d50372efb3aa7f6ed544e68069cfa
parent3891a6cbb69599fe8de9b11d70cd058ecefb9722 (diff)
downloadayatana-indicator-messages-564b5157b51c99c201597b06fe6c9f02e62b94eb.tar.gz
ayatana-indicator-messages-564b5157b51c99c201597b06fe6c9f02e62b94eb.tar.bz2
ayatana-indicator-messages-564b5157b51c99c201597b06fe6c9f02e62b94eb.zip
Revert blacklist changes make apps relying on old behavior 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).
-rw-r--r--src/messages-service.c43
1 files changed, 41 insertions, 2 deletions
diff --git a/src/messages-service.c b/src/messages-service.c
index c975df1..26eaf78 100644
--- a/src/messages-service.c
+++ b/src/messages-service.c
@@ -321,14 +321,53 @@ 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;
-
- blacklist_add_core(definition_file, definition_file);
+ gchar * symlink_target = get_symlink_target (definition_file);
+ gchar * contents = NULL;
+
+ if (symlink_target)
+ blacklist_add_core (symlink_target, definition_file);
+ 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;
}