From 564b5157b51c99c201597b06fe6c9f02e62b94eb Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Wed, 4 Apr 2012 10:46:05 +0200 Subject: 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). --- src/messages-service.c | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) (limited to 'src') 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; } -- cgit v1.2.3 From f2aefd61b55b2784cc8a2a24026e64cef84f0e4d Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Wed, 4 Apr 2012 16:48:53 +0200 Subject: messages-service.c: fix leak --- src/messages-service.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/messages-service.c b/src/messages-service.c index 26eaf78..981c286 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -356,9 +356,14 @@ blacklist_add (gpointer udata) gchar * contents = NULL; 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); -- cgit v1.2.3 From d0eae41a0c2f1d70e00eba6961020657fdaaa2a4 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Wed, 4 Apr 2012 18:57:15 +0200 Subject: Workaround for lp #956147: don't show empty icons in the gtk2 version --- src/messages-service.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/messages-service.c b/src/messages-service.c index c975df1..8f636b5 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -29,6 +29,7 @@ with this program. If not, see . #include #include #include +#include #include #include @@ -620,7 +621,9 @@ server_shortcut_added (AppMenuItem * appitem, DbusmenuMenuitem * mi, gpointer da g_debug("Application Shortcut added: %s", mi != NULL ? dbusmenu_menuitem_property_get(mi, DBUSMENU_MENUITEM_PROP_LABEL) : "none"); DbusmenuMenuitem * shell = DBUSMENU_MENUITEM(data); if (mi != NULL) { +#if GTK_CHECK_VERSION(3, 0, 0) dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_ICON_NAME, ""); +#endif dbusmenu_menuitem_child_append(shell, mi); } resort_menu(shell); -- cgit v1.2.3 From f6c8b38729069405066ed632702990c30eec8c3c Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Thu, 5 Apr 2012 16:37:12 +0200 Subject: messages-service.c: add missing resort_menu This might fix lp:856284, but I couldn't verify because I can't reproduce the bug. --- src/messages-service.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/messages-service.c b/src/messages-service.c index 98e84c7..8e85da2 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -1102,6 +1102,7 @@ indicator_added (IndicateListener * listener, IndicateListenerServer * server, I } else { g_warning("Unable to find server menu item"); dbusmenu_menuitem_child_append(menushell, DBUSMENU_MENUITEM(menuitem)); + resort_menu (root_menuitem); } return; -- cgit v1.2.3 From 2025ac02553ad74d8409a6343b4f495227014dbb Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Thu, 5 Apr 2012 13:10:17 -0500 Subject: fix merge error --- src/messages-service-dbus.c | 205 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 205 insertions(+) (limited to 'src') diff --git a/src/messages-service-dbus.c b/src/messages-service-dbus.c index 1585ac0..2b72f2e 100644 --- a/src/messages-service-dbus.c +++ b/src/messages-service-dbus.c @@ -42,6 +42,8 @@ typedef struct _MessageServiceDbusPrivate MessageServiceDbusPrivate; struct _MessageServiceDbusPrivate { GDBusConnection * connection; + GCancellable * accounts_cancel; + GDBusProxy * accounts_user; gboolean dot; gboolean hidden; }; @@ -154,10 +156,200 @@ connection_cb (GObject * object, GAsyncResult * res, gpointer user_data) return; } +static void +accounts_notify_cb (GObject *source_object, GAsyncResult *res, + gpointer user_data) +{ + GError * error = NULL; + GVariant * answer = g_dbus_proxy_call_finish(G_DBUS_PROXY(source_object), res, &error); + + if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + g_error_free(error); + return; /* Must exit before accessing freed memory */ + } + + MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(user_data); + + if (priv->accounts_cancel != NULL) { + g_object_unref(priv->accounts_cancel); + priv->accounts_cancel = NULL; + } + + if (error != NULL) { + g_warning("Unable to get notify accounts service of message status: %s", error->message); + g_error_free(error); + return; + } + + g_variant_unref (answer); +} + +static void +accounts_notify (MessageServiceDbus *self) +{ + MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self); + + if (priv->accounts_user == NULL) + return; /* We're not able to talk to accounts service */ + + if (priv->accounts_cancel != NULL) { + /* Cancel old notify before starting new one */ + g_cancellable_cancel(priv->accounts_cancel); + g_object_unref(priv->accounts_cancel); + priv->accounts_cancel = NULL; + } + + priv->accounts_cancel = g_cancellable_new(); + g_dbus_proxy_call(priv->accounts_user, + "SetXHasMessages", + g_variant_new ("(b)", priv->dot), + G_DBUS_CALL_FLAGS_NONE, + -1, /* timeout */ + priv->accounts_cancel, + accounts_notify_cb, + self); +} + +static void +get_accounts_user_proxy_cb (GObject *source_object, GAsyncResult *res, + gpointer user_data) +{ + GError * error = NULL; + GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish(res, &error); + + if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + g_error_free(error); + return; /* Must exit before accessing freed memory */ + } + + MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(user_data); + + if (priv->accounts_cancel != NULL) { + g_object_unref(priv->accounts_cancel); + priv->accounts_cancel = NULL; + } + + if (error != NULL) { + g_warning("Unable to get proxy of accountsservice: %s", error->message); + g_error_free(error); + return; + } + + priv->accounts_user = proxy; + accounts_notify (MESSAGE_SERVICE_DBUS (user_data)); +} + +static void +get_accounts_user_find_user_cb (GObject *source_object, GAsyncResult *res, + gpointer user_data) +{ + GError * error = NULL; + GVariant * answer = g_dbus_proxy_call_finish(G_DBUS_PROXY(source_object), res, &error); + + /* We're done with main accounts proxy now */ + g_object_unref (source_object); + + if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + g_error_free(error); + return; /* Must exit before accessing freed memory */ + } + + MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(user_data); + + if (priv->accounts_cancel != NULL) { + g_object_unref(priv->accounts_cancel); + priv->accounts_cancel = NULL; + } + + if (error != NULL) { + g_warning("Unable to get object name of user from accountsservice: %s", error->message); + g_error_free(error); + return; + } + + if (!g_variant_is_of_type (answer, G_VARIANT_TYPE ("(o)"))) { + g_warning("Unexpected type from FindUserByName: %s", g_variant_get_type_string (answer)); + g_variant_unref(answer); + return; + } + + const gchar *path; + g_variant_get(answer, "(&o)", &path); + + priv->accounts_cancel = g_cancellable_new(); + g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM, + G_DBUS_PROXY_FLAGS_NONE, + NULL, + "org.freedesktop.Accounts", + path, + "org.freedesktop.Accounts.User", + priv->accounts_cancel, + get_accounts_user_proxy_cb, + user_data); + + g_variant_unref (answer); +} + +static void +get_accounts_proxy_cb (GObject *source_object, GAsyncResult *res, + gpointer user_data) +{ + GError * error = NULL; + GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish(res, &error); + + if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + g_error_free(error); + return; /* Must exit before accessing freed memory */ + } + + MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(user_data); + + if (priv->accounts_cancel != NULL) { + g_object_unref(priv->accounts_cancel); + priv->accounts_cancel = NULL; + } + + if (error != NULL) { + g_warning("Unable to get proxy of accountsservice: %s", error->message); + g_error_free(error); + return; + } + + priv->accounts_cancel = g_cancellable_new(); + g_dbus_proxy_call(proxy, + "FindUserByName", + g_variant_new ("(s)", g_get_user_name ()), + G_DBUS_CALL_FLAGS_NONE, + -1, /* timeout */ + priv->accounts_cancel, + get_accounts_user_find_user_cb, + user_data); +} + +static void +get_accounts_proxy (MessageServiceDbus *self) +{ + MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self); + + g_return_if_fail(priv->accounts_cancel == NULL); + + priv->accounts_cancel = g_cancellable_new(); + g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM, + G_DBUS_PROXY_FLAGS_NONE, + NULL, + "org.freedesktop.Accounts", + "/org/freedesktop/Accounts", + "org.freedesktop.Accounts", + priv->accounts_cancel, + get_accounts_proxy_cb, + self); +} + static void message_service_dbus_init (MessageServiceDbus *self) { g_bus_get(G_BUS_TYPE_SESSION, NULL, connection_cb, self); + get_accounts_proxy (self); MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self); @@ -177,6 +369,17 @@ message_service_dbus_dispose (GObject *object) priv->connection = NULL; } + if (priv->accounts_cancel != NULL) { + g_cancellable_cancel(priv->accounts_cancel); + g_object_unref(priv->accounts_cancel); + priv->accounts_cancel = NULL; + } + + if (priv->accounts_user != NULL) { + g_object_unref(priv->accounts_user); + priv->accounts_user = NULL; + } + G_OBJECT_CLASS (message_service_dbus_parent_class)->dispose (object); return; } @@ -240,6 +443,8 @@ message_service_dbus_set_attention (MessageServiceDbus * self, gboolean attentio g_variant_new("(b)", priv->dot), NULL); } + + accounts_notify (self); } return; } -- cgit v1.2.3