adium: 57a700cc: Add a function to update multiple attrib...

zacw at adiumx.com zacw at adiumx.com
Mon Apr 13 23:55:41 EDT 2009


-----------------------------------------------------------------
Revision: 57a700ccec4236d1b78682cd24d735b38604d0ea
Ancestor: 9fe8480e88fe4bea198b87f796810e35f34e6756
Author: zacw at adiumx.com
Date: 2009-04-14T03:23:44
Branch: im.pidgin.adium
URL: http://d.pidgin.im/viewmtn/revision/info/57a700ccec4236d1b78682cd24d735b38604d0ea

Modified files:
        libpurple/conversation.c libpurple/conversation.h
        libpurple/protocols/irc/msgs.c

ChangeLog: 

Add a function to update multiple attributes at once, so we don't end up calling update several times per user.

-------------- next part --------------
============================================================
--- libpurple/conversation.c	31c4acd7890ec64280f3128aebc45a42a10e387f
+++ libpurple/conversation.c	20f73b103031c2d42dbf0fff818fbef3453dc625
@@ -2103,6 +2103,26 @@ purple_conv_chat_cb_set_attribute(Purple
 		ops->chat_update_user(conv, cb->name);
 }
 
+void
+purple_conv_chat_cb_set_attributes(PurpleConvChat *chat, PurpleConvChatBuddy *cb, GList *keys, GList *values)
+{
+	g_return_if_fail(cb != NULL);
+	g_return_if_fail(keys != NULL);
+	g_return_if_fail(values != NULL);
+	
+	while (keys != NULL && values != NULL) {
+		g_hash_table_replace(cb->attributes, g_strdup(keys->data), g_strdup(values->data));
+		keys = g_list_next(keys);
+		values = g_list_next(values);
+	}
+	
+	PurpleConversation *conv = purple_conv_chat_get_conversation(chat);
+	PurpleConversationUiOps *ops = purple_conversation_get_ui_ops(conv);
+	
+	if (ops != NULL && ops->chat_update_user != NULL)
+		ops->chat_update_user(conv, cb->name);
+}
+
 GList *
 purple_conversation_get_extended_menu(PurpleConversation *conv)
 {
============================================================
--- libpurple/conversation.h	616789defc2dbbb5d1dbd07546890d83ce5c5eee
+++ libpurple/conversation.h	10dad50f086ddc74486e2c5166e3509a9ae77d24
@@ -1370,6 +1370,18 @@ void purple_conv_chat_cb_set_attribute(P
  * @param value	The value of the attribute.
  */
 void purple_conv_chat_cb_set_attribute(PurpleConvChat *chat, PurpleConvChatBuddy *cb, const char *key, const char *value);
+
+/**
+ * Set attributes of a chat buddy
+ *
+ * @param chat	The chat.
+ * @param cb	The chat buddy.
+ * @param keys	A GList of the keys.
+ * @param values A GList of the values.
+ */
+void
+purple_conv_chat_cb_set_attributes(PurpleConvChat *chat, PurpleConvChatBuddy *cb, GList *keys, GList *values);
+
 	
 /**
  * Destroys a chat buddy
============================================================
--- libpurple/protocols/irc/msgs.c	5d96235d4dd22b849ee2f379c08e026f38f50bc4
+++ libpurple/protocols/irc/msgs.c	4af690dd003debb2edd1025517a29972bf4cf721
@@ -437,9 +437,19 @@ void irc_msg_who(struct irc_conn *irc, c
 		char *userhost = g_strdup_printf("%s@%s", args[2], args[3]);
 		char *realname = g_strdup(args[8]);
 		
-		purple_conv_chat_cb_set_attribute(chat, cb, "userhost", userhost);
-		purple_conv_chat_cb_set_attribute(chat, cb, "realname", realname);
+		GList *keys = NULL, *values = NULL;
 		
+		g_list_append(keys, "userhost");
+		g_list_append(values, userhost);
+		
+		g_list_append(keys, "realname");
+		g_list_append(values, realname);
+		
+		purple_conv_chat_cb_set_attributes(chat, cb, keys, values);
+		
+		g_list_free(keys);
+		g_list_free(values);
+		
 		g_free(userhost);
 		g_free(realname);
 		


More information about the Commits mailing list