diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-07-06 21:58:05 +0800 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-07-08 19:21:01 +0800 |
commit | c5efee19e257658a47b74e5113dfc046b4b31bcc (patch) | |
tree | d3c2d18615b649924f722262a4a8e0ab2ef855fd | |
parent | 6fcaaa418bffeb06c81f1bf1d581e7d2e323fabe (diff) | |
download | gsoc2013-empathy-c5efee19e257658a47b74e5113dfc046b4b31bcc.tar gsoc2013-empathy-c5efee19e257658a47b74e5113dfc046b4b31bcc.tar.gz gsoc2013-empathy-c5efee19e257658a47b74e5113dfc046b4b31bcc.tar.bz2 gsoc2013-empathy-c5efee19e257658a47b74e5113dfc046b4b31bcc.tar.lz gsoc2013-empathy-c5efee19e257658a47b74e5113dfc046b4b31bcc.tar.xz gsoc2013-empathy-c5efee19e257658a47b74e5113dfc046b4b31bcc.tar.zst gsoc2013-empathy-c5efee19e257658a47b74e5113dfc046b4b31bcc.zip |
theme-adium: use the pending-message-id instead of message-token in x-empathy-message-id
message-token is not guaranteed to be implemented by all CMs while
pending-message-id is (for incoming messages).
https://bugzilla.gnome.org/show_bug.cgi?id=654015
-rw-r--r-- | libempathy-gtk/empathy-theme-adium.c | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/libempathy-gtk/empathy-theme-adium.c b/libempathy-gtk/empathy-theme-adium.c index de9716960..14e149e18 100644 --- a/libempathy-gtk/empathy-theme-adium.c +++ b/libempathy-gtk/empathy-theme-adium.c @@ -61,7 +61,7 @@ typedef struct { guint pages_loading; /* Queue of QueuedItem*s containing an EmpathyMessage or string */ GQueue message_queue; - /* Queue of owned gchar* of message token to remove unread + /* Queue of guint32 of pending message id to remove unread * marker for when we lose focus. */ GQueue acked_messages; GtkWidget *inspector_window; @@ -992,11 +992,14 @@ theme_adium_append_message (EmpathyChatView *view, * message later. */ tp_msg = empathy_message_get_tp_message (msg); if (tp_msg != NULL) { - gchar *tmp = tp_escape_as_identifier ( - tp_message_get_token (tp_msg)); - g_string_append_printf (message_classes, - " x-empathy-message-id-%s", tmp); - g_free (tmp); + guint32 id; + gboolean valid; + + id = tp_message_get_pending_message_id (tp_msg, &valid); + if (valid) { + g_string_append_printf (message_classes, + " x-empathy-message-id-%u", id); + } } /* Define javascript function to use */ @@ -1259,11 +1262,11 @@ theme_adium_copy_clipboard (EmpathyChatView *view) static void theme_adium_remove_mark_from_message (EmpathyThemeAdium *self, - const gchar *token) + guint32 id) { WebKitDOMDocument *dom; WebKitDOMNodeList *nodes; - gchar *class, *tmp; + gchar *class; GError *error = NULL; dom = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (self)); @@ -1271,9 +1274,7 @@ theme_adium_remove_mark_from_message (EmpathyThemeAdium *self, return; } - tmp = tp_escape_as_identifier (token); - class = g_strdup_printf (".x-empathy-message-id-%s", tmp); - g_free (tmp); + class = g_strdup_printf (".x-empathy-message-id-%u", id); /* Get all nodes with focus class */ nodes = webkit_dom_document_query_selector_all (dom, class, &error); @@ -1294,10 +1295,9 @@ theme_adium_remove_acked_message_unread_mark_foreach (gpointer data, gpointer user_data) { EmpathyThemeAdium *self = user_data; - gchar *token = data; + guint32 id = GPOINTER_TO_UINT (data); - theme_adium_remove_mark_from_message (self, token); - g_free (token); + theme_adium_remove_mark_from_message (self, id); } static void @@ -1326,6 +1326,8 @@ theme_adium_message_acknowledged (EmpathyChatView *view, EmpathyThemeAdium *self = (EmpathyThemeAdium *) view; EmpathyThemeAdiumPriv *priv = GET_PRIV (view); TpMessage *tp_msg; + guint32 id; + gboolean valid; tp_msg = empathy_message_get_tp_message (message); @@ -1333,18 +1335,23 @@ theme_adium_message_acknowledged (EmpathyChatView *view, return; } + id = tp_message_get_pending_message_id (tp_msg, &valid); + if (!valid) { + g_warning ("Acknoledged message doesn't have a pending ID"); + return; + } + /* We only want to actually remove the unread marker if the * view doesn't have focus. If we did it all the time we would * never see the unread markers, ever! So, we'll queue these * up, and when we lose focus, we'll remove the markers. */ if (priv->has_focus) { g_queue_push_tail (&priv->acked_messages, - g_strdup (tp_message_get_token (tp_msg))); + GUINT_TO_POINTER (id)); return; } - theme_adium_remove_mark_from_message (self, - tp_message_get_token (tp_msg)); + theme_adium_remove_mark_from_message (self, id); } static void @@ -1543,7 +1550,6 @@ theme_adium_dispose (GObject *object) } if (priv->acked_messages.length > 0) { - g_queue_foreach (&priv->acked_messages, (GFunc) g_free, NULL); g_queue_clear (&priv->acked_messages); } |