pidgin: 32f8ae7d: Add blist-node-(added|removed) and depre...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Sun May 3 16:20:30 EDT 2009


-----------------------------------------------------------------
Revision: 32f8ae7d8795036eb08cee5aeeca18fd270bd0e9
Ancestor: 424194d00a24be3efde47f14e0fb56a7098e4b28
Author: darkrain42 at pidgin.im
Date: 2009-05-03T17:10:51
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/32f8ae7d8795036eb08cee5aeeca18fd270bd0e9

Modified files:
        ChangeLog.API doc/blist-signals.dox libpurple/blist.c
        libpurple/plugins/signals-test.c pidgin/gtkconv.c

ChangeLog: 

Add blist-node-(added|removed) and deprecate buddy-(added|removed). Closes #8309

-------------- next part --------------
============================================================
--- ChangeLog.API	0a1a50aa1da396c399fbfbae4975fe844c28dcb2
+++ ChangeLog.API	5bab8a4b164f1279917dc8277adf8157cee087ad
@@ -13,6 +13,8 @@ version 2.6.0 (??/??/2009):
 			* account-actions-changed
 			* account-created
 			* account-destroying
+		* blist-node-added and blist-node-removed signals (see
+		  blist-signals.dox)
 		* purple_buddy_destroy
 		* purple_buddy_get_protocol_data
 		* purple_buddy_set_protocol_data
@@ -54,6 +56,7 @@ version 2.6.0 (??/??/2009):
 		  xmlnode_remove_with_namespace.
 
 		Deprecated:
+		* buddy-added and buddy-removed blist signals
 		* purple_buddy_get_local_alias
 		* purple_notify_user_info_remove_entry
 		* purple_status_type_set_primary_attr
============================================================
--- doc/blist-signals.dox	4b13b4842a77bdfeecf8174bea103cf109babbe8
+++ doc/blist-signals.dox	a21dc4c3643e12d114e95a0a01d7da8b3e63051b
@@ -74,13 +74,30 @@ void (*blist_node_extended_menu)(PurpleB
    a GList of PurpleBlistNodeAction's allowing a plugin to add menu items
  @endsignaldef
 
+ @signaldef blist-node-added
+  @signalproto
+void (*blist_node_added)(PurpleBlistNode *node)
+  @endsignalproto
+  @signaldesc
+   Emitted when a new blist node is added to the buddy list.
+ @endsignaldef
+
+ @signaldef blist-node-removed
+  @signalproto
+void (*blist_node_removed)(PurpleBlistNode *node)
+  @endsignalproto
+  @signaldesc
+   Emitted when a blist node is removed from the buddy list.
+ @endsignaldef
+
  @signaldef buddy-added
   @signalproto
 void (*buddy_added)(PurpleBuddy *buddy)
   @endsignalproto
   @signaldesc
    Emitted when a new buddy is added to the buddy list.
-  @endsignaldef
+  @deprecated Use blist-node-added instead.
+ @endsignaldef
 
  @signaldef buddy-removed
   @signalproto
@@ -88,7 +105,8 @@ void (*buddy_removed)(PurpleBuddy *buddy
   @endsignalproto
   @signaldesc
    Emitted when a buddy is removed from the buddy list.
-  @endsignaldef
+  @deprecated Use blist-node-removed instead.
+ @endsignaldef
 
  @signaldef buddy-icon-changed
   @signalproto
============================================================
--- libpurple/blist.c	30522a639b649fbb0276288c11086b244fdd6354
+++ libpurple/blist.c	c19c1ab51d9428857b76795b79a8afea84b78320
@@ -1468,6 +1468,9 @@ void purple_blist_add_chat(PurpleChat *c
 
 	if (ops && ops->update)
 		ops->update(purplebuddylist, (PurpleBlistNode *)cnode);
+
+	purple_signal_emit(purple_blist_get_handle(), "blist-node-added",
+			cnode);
 }
 
 void purple_blist_add_buddy(PurpleBuddy *buddy, PurpleContact *contact, PurpleGroup *group, PurpleBlistNode *node)
@@ -1615,6 +1618,9 @@ void purple_blist_add_buddy(PurpleBuddy 
 
 	/* Signal that the buddy has been added */
 	purple_signal_emit(purple_blist_get_handle(), "buddy-added", buddy);
+
+	purple_signal_emit(purple_blist_get_handle(), "blist-node-added",
+			PURPLE_BLIST_NODE(buddy));
 }
 
 PurpleContact *purple_contact_new()
@@ -1952,6 +1958,9 @@ void purple_blist_add_group(PurpleGroup 
 		for (node = gnode->child; node; node = node->next)
 			ops->update(purplebuddylist, node);
 	}
+
+	purple_signal_emit(purple_blist_get_handle(), "blist-node-added",
+			gnode);
 }
 
 void purple_blist_remove_contact(PurpleContact *contact)
@@ -1994,6 +2003,9 @@ void purple_blist_remove_contact(PurpleC
 		if (ops && ops->remove)
 			ops->remove(purplebuddylist, node);
 
+		purple_signal_emit(purple_blist_get_handle(), "blist-node-removed",
+				PURPLE_BLIST_NODE(contact));
+
 		/* Delete the node */
 		purple_contact_destroy(contact);
 	}
@@ -2066,6 +2078,9 @@ void purple_blist_remove_buddy(PurpleBud
 	/* Signal that the buddy has been removed before freeing the memory for it */
 	purple_signal_emit(purple_blist_get_handle(), "buddy-removed", buddy);
 
+	purple_signal_emit(purple_blist_get_handle(), "blist-node-removed",
+			PURPLE_BLIST_NODE(buddy));
+
 	purple_buddy_destroy(buddy);
 
 	/* If the contact is empty then remove it */
@@ -2109,6 +2124,9 @@ void purple_blist_remove_chat(PurpleChat
 	if (ops && ops->remove)
 		ops->remove(purplebuddylist, node);
 
+	purple_signal_emit(purple_blist_get_handle(), "blist-node-removed",
+			PURPLE_BLIST_NODE(chat));
+
 	/* Delete the node */
 	purple_chat_destroy(chat);
 }
@@ -2141,6 +2159,9 @@ void purple_blist_remove_group(PurpleGro
 	if (ops && ops->remove)
 		ops->remove(purplebuddylist, node);
 
+	purple_signal_emit(purple_blist_get_handle(), "blist-node-removed",
+			PURPLE_BLIST_NODE(group));
+
 	/* Remove the group from all accounts that are online */
 	for (l = purple_connections_get_all(); l != NULL; l = l->next)
 	{
@@ -2973,6 +2994,16 @@ purple_blist_init(void)
 						 purple_value_new(PURPLE_TYPE_SUBTYPE,
 										PURPLE_SUBTYPE_BLIST_BUDDY));
 
+	purple_signal_register(handle, "blist-node-added",
+						 purple_marshal_VOID__POINTER, NULL, 1,
+						 purple_value_new(PURPLE_TYPE_SUBTYPE,
+										PURPLE_SUBTYPE_BLIST_NODE));
+
+	purple_signal_register(handle, "blist-node-removed",
+						 purple_marshal_VOID__POINTER, NULL, 1,
+						 purple_value_new(PURPLE_TYPE_SUBTYPE,
+										PURPLE_SUBTYPE_BLIST_NODE));
+
 	purple_signal_register(handle, "buddy-added",
 						 purple_marshal_VOID__POINTER, NULL, 1,
 						 purple_value_new(PURPLE_TYPE_SUBTYPE,
============================================================
--- libpurple/plugins/signals-test.c	6fd6f5f657418e082b36247affc3d4ed1ea24c21
+++ libpurple/plugins/signals-test.c	c0bbcda4e92bb62a954e7188819ee3da3b02be74
@@ -145,16 +145,39 @@ static void
 }
 
 static void
-buddy_added_cb(PurpleBuddy *buddy, void *data)
+blist_node_added_cb(PurpleBlistNode *bnode, void *data)
 {
-	purple_debug_misc("signals test", "buddy_added_cb (%s)\n",
-	                  purple_buddy_get_name(buddy));
+	const char *name;
+	if (PURPLE_BLIST_NODE_IS_GROUP(bnode))
+		name = purple_group_get_name(PURPLE_GROUP(bnode));
+	else if (PURPLE_BLIST_NODE_IS_CONTACT(bnode))
+		/* Close enough */
+		name = purple_contact_get_alias(PURPLE_CONTACT(bnode));
+	else if (PURPLE_BLIST_NODE_IS_BUDDY(bnode))
+		name = purple_buddy_get_name(PURPLE_BUDDY(bnode));
+	else
+		name = "(unknown)";
+
+	purple_debug_misc("signals test", "blist_node_added_cb (%s)\n",
+	                  name ? name : "(null)");
 }
 
 static void
-buddy_removed_cb(PurpleBuddy *buddy, void *data)
+blist_node_removed_cb(PurpleBlistNode *bnode, void *data)
 {
-	purple_debug_misc("signals test", "buddy_removed_cb (%s)\n", purple_buddy_get_name(buddy));
+	const char *name;
+	if (PURPLE_BLIST_NODE_IS_GROUP(bnode))
+		name = purple_group_get_name(PURPLE_GROUP(bnode));
+	else if (PURPLE_BLIST_NODE_IS_CONTACT(bnode))
+		/* Close enough */
+		name = purple_contact_get_alias(PURPLE_CONTACT(bnode));
+	else if (PURPLE_BLIST_NODE_IS_BUDDY(bnode))
+		name = purple_buddy_get_name(PURPLE_BUDDY(bnode));
+	else
+		name = "(unknown)";
+
+	purple_debug_misc("signals test", "blist_node_removed_cb (%s)\n",
+	                  name ? name : "(null)");
 }
 
 static void
@@ -643,10 +666,10 @@ plugin_load(PurplePlugin *plugin)
 						plugin, PURPLE_CALLBACK(buddy_signed_on_cb), NULL);
 	purple_signal_connect(blist_handle, "buddy-signed-off",
 						plugin, PURPLE_CALLBACK(buddy_signed_off_cb), NULL);
-	purple_signal_connect(blist_handle, "buddy-added",
-						plugin, PURPLE_CALLBACK(buddy_added_cb), NULL);
-	purple_signal_connect(blist_handle, "buddy-removed",
-						plugin, PURPLE_CALLBACK(buddy_removed_cb), NULL);
+	purple_signal_connect(blist_handle, "blist-node-added",
+						plugin, PURPLE_CALLBACK(blist_node_added_cb), NULL);
+	purple_signal_connect(blist_handle, "blist-node-removed",
+						plugin, PURPLE_CALLBACK(blist_node_removed_cb), NULL);
 	purple_signal_connect(blist_handle, "buddy-icon-changed",
 						plugin, PURPLE_CALLBACK(buddy_icon_changed_cb), NULL);
 	purple_signal_connect(blist_handle, "blist-node-aliased",
============================================================
--- pidgin/gtkconv.c	4dad28b1826e62198a492a3c2d3e574f1bae1881
+++ pidgin/gtkconv.c	a137d6aa5c0ddc8f065ca4cf4cd87514be50db25
@@ -4496,19 +4496,26 @@ static void
 }
 
 static void
-buddy_added_cb(PurpleBuddy *buddy, PurpleConversation *conv)
+buddy_added_cb(PurpleBlistNode *node, PurpleConversation *conv)
 {
-	buddy_cb_common(buddy, conv, TRUE);
+	if (!PURPLE_BLIST_NODE_IS_BUDDY(node))
+		return;
+
+	buddy_cb_common(PURPLE_BUDDY(node), conv, TRUE);
 }
 
 static void
-buddy_removed_cb(PurpleBuddy *buddy, PurpleConversation *conv)
+buddy_removed_cb(PurpleBlistNode *node, PurpleConversation *conv)
 {
+	if (!PURPLE_BLIST_NODE_IS_BUDDY(node))
+		return;
+
 	/* If there's another buddy for the same "dude" on the list, do nothing. */
-	if (purple_find_buddy(buddy->account, buddy->name) != NULL)
+	if (purple_find_buddy(purple_buddy_get_account(PURPLE_BUDDY(node)),
+		                  purple_buddy_get_name(PURPLE_BUDDY(node))) != NULL)
 		return;
 
-	buddy_cb_common(buddy, conv, FALSE);
+	buddy_cb_common(PURPLE_BUDDY(node), conv, FALSE);
 }
 
 static void send_menu_cb(GtkWidget *widget, PidginConversation *gtkconv)
@@ -4747,9 +4754,9 @@ setup_chat_userlist(PidginConversation *
 	                                               "weight", CHAT_USERS_WEIGHT_COLUMN,
 	                                               NULL);
 
-	purple_signal_connect(blist_handle, "buddy-added",
+	purple_signal_connect(blist_handle, "blist-node-added",
 						gtkchat, PURPLE_CALLBACK(buddy_added_cb), conv);
-	purple_signal_connect(blist_handle, "buddy-removed",
+	purple_signal_connect(blist_handle, "blist-node-removed",
 						gtkchat, PURPLE_CALLBACK(buddy_removed_cb), conv);
 	purple_signal_connect(blist_handle, "blist-node-aliased",
 						gtkchat, PURPLE_CALLBACK(blist_node_aliased_cb), conv);
@@ -5121,7 +5128,8 @@ buddy_update_cb(PurpleBlistNode *bnode, 
 	GList *list;
 
 	g_return_if_fail(bnode);
-	g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(bnode));
+	if (!PURPLE_BLIST_NODE_IS_BUDDY(bnode))
+		return;
 
 	for (list = pidgin_conv_windows_get_list(); list; list = list->next)
 	{
@@ -8017,9 +8025,9 @@ pidgin_conversations_init(void)
                         handle, PURPLE_CALLBACK(account_status_changed_cb), NULL);
 
 	/* Callbacks to update a conversation */
-	purple_signal_connect(blist_handle, "buddy-added", handle,
+	purple_signal_connect(blist_handle, "blist-node-added", handle,
 						G_CALLBACK(buddy_update_cb), NULL);
-	purple_signal_connect(blist_handle, "buddy-removed", handle,
+	purple_signal_connect(blist_handle, "blist-node-removed", handle,
 						G_CALLBACK(buddy_update_cb), NULL);
 	purple_signal_connect(blist_handle, "buddy-signed-on",
 						handle, PURPLE_CALLBACK(update_buddy_sign), "on");


More information about the Commits mailing list