changeset 29249:bb9f7ba4f299

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
author Marcus Lundblad <ml@update.uu.se>
date Mon, 27 Oct 2008 23:12:03 +0000
parents e81b708a8986
children 0efd688ed086
files libpurple/protocols/jabber/jabber.c pidgin/gtkconv.c pidgin/gtkimhtmltoolbar.c pidgin/gtkimhtmltoolbar.h
diffstat 4 files changed, 31 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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;
 	}
--- 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;
 
--- 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...
+}
+
--- 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
 }