# HG changeset patch # User Marcus Lundblad # Date 1225149123 0 # Node ID bb9f7ba4f2995e1de43234ef0949792cc2812a4f # Parent e81b708a8986fad87ae97f47e003fa24be24a05c Added active conversation on GtkIMHtmlToolbar Connect "Attention" button on toolbar to attention action Print error message when failing to send attention on XMPP using prpl API diff -r e81b708a8986 -r bb9f7ba4f299 libpurple/protocols/jabber/jabber.c --- a/libpurple/protocols/jabber/jabber.c Mon Oct 27 23:08:32 2008 +0000 +++ b/libpurple/protocols/jabber/jabber.c Mon Oct 27 23:12:03 2008 +0000 @@ -2388,7 +2388,13 @@ gchar *error = NULL; if (!_jabber_send_buzz(js, username, &error)) { + PurpleAccount *account = purple_connection_get_account(gc); + PurpleConversation *conv = + purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, + username, account); purple_debug_error("jabber", "jabber_send_attention: jabber_cmd_buzz failed with error: %s\n", error ? error : "(NULL)"); + purple_conversation_write(conv, username, error, + PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NOTIFY, time(NULL)); g_free(error); return FALSE; } diff -r e81b708a8986 -r bb9f7ba4f299 pidgin/gtkconv.c --- a/pidgin/gtkconv.c Mon Oct 27 23:08:32 2008 +0000 +++ b/pidgin/gtkconv.c Mon Oct 27 23:12:03 2008 +0000 @@ -2242,6 +2242,11 @@ gtkconv = PIDGIN_CONVERSATION(conv); old_conv = gtkconv->active_conv; + purple_debug_info("gtkconv", "setting active conversation on toolbar %p\n", + conv); + gtk_imhtmltoolbar_switch_active_conversation(GTK_IMHTMLTOOLBAR(gtkconv->toolbar), + conv); + if (old_conv == conv) return; diff -r e81b708a8986 -r bb9f7ba4f299 pidgin/gtkimhtmltoolbar.c --- a/pidgin/gtkimhtmltoolbar.c Mon Oct 27 23:08:32 2008 +0000 +++ b/pidgin/gtkimhtmltoolbar.c Mon Oct 27 23:12:03 2008 +0000 @@ -33,6 +33,7 @@ #include "request.h" #include "pidginstock.h" #include "util.h" +#include "debug.h" #include "gtkdialogs.h" #include "gtkimhtmltoolbar.h" @@ -915,7 +916,12 @@ static void send_attention_cb(GtkWidget *attention, GtkIMHtmlToolbar *toolbar) { + PurpleConversation *conv = toolbar->active_conv; + const gchar *who = purple_conversation_get_name(conv); + PurpleConnection *gc = purple_conversation_get_gc(conv); + purple_conversation_attention(conv, who, 0, PURPLE_MESSAGE_SEND, time(NULL)); + purple_prpl_send_attention(gc, who, 0); } static void update_buttons_cb(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons, GtkIMHtmlToolbar *toolbar) @@ -1547,3 +1553,13 @@ g_free(toolbar->sml); toolbar->sml = g_strdup(proto_id); } + +void gtk_imhtmltoolbar_switch_active_conversation(GtkIMHtmlToolbar *toolbar, + PurpleConversation *conv) +{ + purple_debug_info("gtkimhtmltoolbar", "switch active conversation to %p\n", + conv); + toolbar->active_conv = conv; + // gray out buttons... +} + diff -r e81b708a8986 -r bb9f7ba4f299 pidgin/gtkimhtmltoolbar.h --- a/pidgin/gtkimhtmltoolbar.h Mon Oct 27 23:08:32 2008 +0000 +++ b/pidgin/gtkimhtmltoolbar.h Mon Oct 27 23:12:03 2008 +0000 @@ -77,6 +77,8 @@ char *sml; GtkWidget *strikethrough; GtkWidget *insert_hr; + + PurpleConversation *active_conv; }; struct _GtkIMHtmlToolbarClass { @@ -90,6 +92,8 @@ void gtk_imhtmltoolbar_attach (GtkIMHtmlToolbar *toolbar, GtkWidget *imhtml); void gtk_imhtmltoolbar_associate_smileys (GtkIMHtmlToolbar *toolbar, const char *proto_id); +void gtk_imhtmltoolbar_switch_active_conversation(GtkIMHtmlToolbar *toolbar, + PurpleConversation *conv); #ifdef __cplusplus }