changeset 29278:68f6de7d1408

Make it work again after the merge from i.p.p.... :) Had to duplicate some stuff from prpl.c in jabber.c to output the attention message when sending one using the /buzz command, until I figure out a better way of doing it...
author Marcus Lundblad <ml@update.uu.se>
date Mon, 02 Mar 2009 23:34:48 +0000
parents b98519a42e53
children 5640246d96c1
files libpurple/protocols/jabber/jabber.c libpurple/protocols/jabber/message.c libpurple/protocols/msn/msn.c pidgin/pidginstock.c
diffstat 4 files changed, 34 insertions(+), 70 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/jabber.c	Mon Mar 02 22:07:59 2009 +0000
+++ b/libpurple/protocols/jabber/jabber.c	Mon Mar 02 23:34:48 2009 +0000
@@ -2523,6 +2523,11 @@
 {
 	JabberStream *js = conv->account->gc->proto_data;
 	const gchar *who;
+	gchar *description;
+	PurpleBuddy *buddy;
+	const char *alias;
+	PurpleAttentionType *attn = 
+		purple_get_attention_type_from_code(conv->account, 0);
 
 	if (!args || !args[0]) {
 		/* use the buddy from conversation, if it's a one-to-one conversation */
@@ -2535,27 +2540,19 @@
 		who = args[0];
 	}
 
-	if (_jabber_send_buzz(js, who, error)) {
-		const gchar *alias;
-		gchar *str;
-		PurpleBuddy *buddy =
-			purple_find_buddy(purple_connection_get_account(conv->account->gc),
-				who);
-
-		if (buddy != NULL)
-			alias = purple_buddy_get_contact_alias(buddy);
-		else
-			alias = who;
-
-		str = g_strdup_printf(_("Buzzing %s..."), alias);
-		purple_conversation_write(conv, NULL, str,
-			PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NOTIFY, time(NULL));
-		g_free(str);
-
-		return PURPLE_CMD_RET_OK;
-	} else {
-		return PURPLE_CMD_RET_FAILED;
-	}
+	buddy = purple_find_buddy(conv->account, who);
+	if (buddy != NULL)
+		alias = purple_buddy_get_contact_alias(buddy);
+	else
+		alias = who;
+	
+	description = 
+		g_strdup_printf(purple_attention_type_get_outgoing_desc(attn), alias);
+	purple_conversation_attention(conv, who, 0, PURPLE_MESSAGE_SEND, time(NULL));
+	purple_conversation_write(conv, NULL, description, 
+		PURPLE_MESSAGE_NOTIFY | PURPLE_MESSAGE_SYSTEM, time(NULL));
+	g_free(description);
+	return _jabber_send_buzz(js, who, error)  ? PURPLE_CMD_RET_OK : PURPLE_CMD_RET_FAILED;
 }
 
 GList *jabber_attention_types(PurpleAccount *account)
--- a/libpurple/protocols/jabber/message.c	Mon Mar 02 22:07:59 2009 +0000
+++ b/libpurple/protocols/jabber/message.c	Mon Mar 02 23:34:48 2009 +0000
@@ -118,7 +118,7 @@
 				}
 			}
 			serv_got_typing_stopped(jm->js->gc, from);
-
+			
 		} else {
 			serv_got_typing_stopped(jm->js->gc, from);
 		}
@@ -138,7 +138,7 @@
 				g_free(jbr->thread_id);
 			jbr->thread_id = g_strdup(jbr->thread_id);
 		}
-
+		
 		if (jm->js->googletalk && jm->xhtml == NULL) {
 			char *tmp = jm->body;
 			jm->body = jabber_google_format_to_html(jm->body);
@@ -289,6 +289,8 @@
 static void handle_buzz(JabberMessage *jm) {
 	PurpleBuddy *buddy;
 	PurpleAccount *account;
+	PurpleConversation *c;
+	char *username;
 
 	/* Delayed buzz MUST NOT be accepted */
 	if(jm->delayed)
@@ -303,8 +305,16 @@
 	if ((buddy = purple_find_buddy(account, jm->from)) == NULL)
 		return; /* Do not accept buzzes from unknown people */
 
+	c = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, jm->from, account);
+	if (c == NULL)
+		c = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, jm->from);
+
+	username = g_markup_escape_text(purple_buddy_get_alias(buddy), -1);
 	/* xmpp only has 1 attention type, so index is 0 */
 	purple_prpl_got_attention(jm->js->gc, jm->from, 0);
+	purple_conversation_attention(c, jm->from, 0, PURPLE_MESSAGE_RECV, time(NULL));
+
+	g_free(username);
 }
 
 /* used internally by the functions below */
--- a/libpurple/protocols/msn/msn.c	Mon Mar 02 22:07:59 2009 +0000
+++ b/libpurple/protocols/msn/msn.c	Mon Mar 02 23:34:48 2009 +0000
@@ -162,6 +162,8 @@
 	username = purple_conversation_get_name(conv);
 
 	purple_prpl_send_attention(gc, username, MSN_NUDGE);
+	purple_conversation_attention(conv, username, 0, PURPLE_MESSAGE_SEND,
+		time(NULL));
 
 	return PURPLE_CMD_RET_OK;
 }
--- a/pidgin/pidginstock.c	Mon Mar 02 22:07:59 2009 +0000
+++ b/pidgin/pidginstock.c	Mon Mar 02 23:34:48 2009 +0000
@@ -197,7 +197,8 @@
 	{ PIDGIN_STOCK_TOOLBAR_UNBLOCK,		"toolbar", "unblock.png",	 FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
 	{ PIDGIN_STOCK_TOOLBAR_SELECT_AVATAR,	"toolbar", "select-avatar.png",	 FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, NULL  },
 	{ PIDGIN_STOCK_TOOLBAR_SEND_FILE,	"toolbar", "send-file.png",	 FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
-	{ PIDGIN_STOCK_TOOLBAR_TRANSFER,	"toolbar", "transfer.png",	 FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  }
+	{ PIDGIN_STOCK_TOOLBAR_TRANSFER,	"toolbar", "transfer.png",	 FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
+	{ PIDGIN_STOCK_TOOLBAR_SEND_ATTENTION, "toolbar", "get-attention.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  }
 };
 
 const SizedStockIcon sized_status_icons [] = {
@@ -277,52 +278,6 @@
 	return ret;
 }
 
-static void
-add_sized_icon(GtkIconSet *iconset, GtkIconSize sizeid, const char *dir, 
-	       gboolean rtl, const char *size, const char *file)
-{
-	char *filename;
-	GtkIconSource *source;	
-
-	filename = g_build_filename(DATADIR, "pixmaps", "pidgin", dir, size, file, NULL);
-	source = gtk_icon_source_new();
-        gtk_icon_source_set_filename(source, filename);
-	gtk_icon_source_set_direction(source, GTK_TEXT_DIR_LTR);
-        gtk_icon_source_set_direction_wildcarded(source, !rtl);
-	gtk_icon_source_set_size(source, sizeid);
-        gtk_icon_source_set_size_wildcarded(source, FALSE);
-        gtk_icon_source_set_state_wildcarded(source, TRUE);
-        gtk_icon_set_add_source(iconset, source);
-	gtk_icon_source_free(source);
-
-	if (sizeid == gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL)) {
-		source = gtk_icon_source_new();
-	        gtk_icon_source_set_filename(source, filename);
-        	gtk_icon_source_set_direction_wildcarded(source, TRUE);
-	        gtk_icon_source_set_size(source, GTK_ICON_SIZE_MENU);
-	        gtk_icon_source_set_size_wildcarded(source, FALSE);
-        	gtk_icon_source_set_state_wildcarded(source, TRUE);
-	        gtk_icon_set_add_source(iconset, source);
-	        gtk_icon_source_free(source);
-	}
-        g_free(filename);
-
-       if (rtl) {
-		filename = g_build_filename(DATADIR, "pixmaps", "pidgin", dir, size, "rtl", file, NULL);
-                source = gtk_icon_source_new();
-                gtk_icon_source_set_filename(source, filename);
-                gtk_icon_source_set_direction(source, GTK_TEXT_DIR_RTL);
-                gtk_icon_source_set_size(source, sizeid);
-                gtk_icon_source_set_size_wildcarded(source, FALSE);
-                gtk_icon_source_set_state_wildcarded(source, TRUE);
-                gtk_icon_set_add_source(iconset, source);
-		g_free(filename);
-		gtk_icon_source_free(source);
-        }
-
-
-}
-
 /* Altered from do_colorshift in gnome-panel */
 static void
 do_alphashift(GdkPixbuf *dest, GdkPixbuf *src)