im.pidgin.pidgin: 85f4bdbdd0d94a45b6fe65f5a5743ab8dffad8d8

sadrul at pidgin.im sadrul at pidgin.im
Sat Jan 26 23:50:45 EST 2008


-----------------------------------------------------------------
Revision: 85f4bdbdd0d94a45b6fe65f5a5743ab8dffad8d8
Ancestor: 8b27b75540a87e4b7dd58cff3eb4733550d273a8
Author: sadrul at pidgin.im
Date: 2008-01-27T04:06:39
Branch: im.pidgin.pidgin

Modified files:
        ChangeLog.API finch/gntblist.c finch/gntconv.c
        libpurple/blist.c libpurple/blist.h

ChangeLog: 

Add accessor and update finch to not touch the internals of PurpleBuddy and PurpleChat.

-------------- next part --------------
============================================================
--- ChangeLog.API	3853d8305a45524968da02bba23f91a3b7064a4a
+++ ChangeLog.API	648c910eb3e52630af53d71372117ce76d0b7fe4
@@ -39,6 +39,7 @@ version 2.4.0 (??/??/????):
 		  last received packet.
 		* Added some more accessor functions:
 			* purple_chat_get_account
+			* purple_chat_get_components
 			* purple_connection_get_prpl
 			* purple_xfer_get_start_time
 			* purple_xfer_get_end_time
============================================================
--- finch/gntblist.c	a8ada6ebaa3db1f92e2ce4c9e02b27d4cfad11b1
+++ finch/gntblist.c	b3a191d74d3ac494bc4328a298da5f9d8803b571
@@ -243,7 +243,7 @@ static gboolean default_create_tooltip(g
 			}
 			if (node == (PurpleBlistNode*)pr)
 				continue;
-			if (!purple_account_is_connected(buddy->account))
+			if (!purple_account_is_connected(purple_buddy_get_account(buddy)))
 				continue;
 			if (!showoffline && !PURPLE_BUDDY_IS_ONLINE(buddy))
 				continue;
@@ -266,7 +266,7 @@ static gboolean default_create_tooltip(g
 		title = g_strdup(group->name);
 	} else if (PURPLE_BLIST_NODE_IS_CHAT(node)) {
 		PurpleChat *chat = (PurpleChat *)node;
-		PurpleAccount *account = chat->account;
+		PurpleAccount *account = purple_chat_get_account(chat);
 
 		g_string_append_printf(str, _("Account: %s (%s)"),
 				purple_account_get_username(account),
@@ -659,7 +659,7 @@ add_chat_cb(void *data, PurpleRequestFie
 		purple_blist_alias_chat(chat, alias);
 		purple_blist_node_set_bool((PurpleBlistNode*)chat, "gnt-autojoin", autojoin);
 		if (autojoin)
-			serv_join_chat(purple_account_get_connection(chat->account), chat->components);
+			serv_join_chat(purple_account_get_connection(purple_chat_get_account(chat)), purple_chat_get_components(chat));
 	}
 }
 
@@ -838,7 +838,7 @@ add_chat(PurpleChat *chat, FinchBlist *g
 	PurpleBlistNode *node = (PurpleBlistNode *)chat;
 	if (FINCH_GET_DATA(node))
 		return;
-	if (!purple_account_is_connected(chat->account))
+	if (!purple_account_is_connected(purple_chat_get_account(chat)))
 		return;
 
 	parent = ggblist->manager->find_parent((PurpleBlistNode*)chat);
@@ -944,7 +944,7 @@ selection_activate(GntWidget *widget, Fi
 	else if (PURPLE_BLIST_NODE_IS_CHAT(node))
 	{
 		PurpleChat *chat = (PurpleChat*)node;
-		serv_join_chat(purple_account_get_connection(chat->account), chat->components);
+		serv_join_chat(purple_account_get_connection(purple_chat_get_account(chat)), purple_chat_get_components(chat));
 	}
 }
 
@@ -1031,7 +1031,7 @@ chat_components_edit_ok(PurpleChat *chat
 			else
 				val = g_strdup(purple_request_field_string_get_value(field));
 
-			g_hash_table_replace(chat->components, g_strdup(id), val);  /* val should not be free'd */
+			g_hash_table_replace(purple_chat_get_components(chat), g_strdup(id), val);  /* val should not be free'd */
 		}
 	}
 }
@@ -1048,20 +1048,20 @@ chat_components_edit(PurpleBlistNode *se
 
 	purple_request_fields_add_group(fields, group);
 
-	gc = purple_account_get_connection(chat->account);
+	gc = purple_account_get_connection(purple_chat_get_account(chat));
 	parts = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc))->chat_info(gc);
 
 	for (iter = parts; iter; iter = iter->next) {
 		pce = iter->data;
 		if (pce->is_int) {
 			int val;
-			const char *str = g_hash_table_lookup(chat->components, pce->identifier);
+			const char *str = g_hash_table_lookup(purple_chat_get_components(chat), pce->identifier);
 			if (!str || sscanf(str, "%d", &val) != 1)
 				val = pce->min;
 			field = purple_request_field_int_new(pce->identifier, pce->label, val);
 		} else {
 			field = purple_request_field_string_new(pce->identifier, pce->label,
-					g_hash_table_lookup(chat->components, pce->identifier), FALSE);
+					g_hash_table_lookup(purple_chat_get_components(chat), pce->identifier), FALSE);
 		}
 
 		purple_request_field_group_add_field(group, field);
@@ -1143,13 +1143,13 @@ finch_blist_get_buddy_info_cb(PurpleBlis
 static void
 finch_blist_get_buddy_info_cb(PurpleBlistNode *selected, PurpleBuddy *buddy)
 {
-	finch_retrieve_user_info(purple_account_get_connection(buddy->account), purple_buddy_get_name(buddy));
+	finch_retrieve_user_info(purple_account_get_connection(purple_buddy_get_account(buddy)), purple_buddy_get_name(buddy));
 }
 
 static void
 finch_blist_menu_send_file_cb(PurpleBlistNode *selected, PurpleBuddy *buddy)
 {
-	serv_send_file(purple_account_get_connection(buddy->account), buddy->name, NULL);
+	serv_send_file(purple_account_get_connection(purple_buddy_get_account(buddy)), purple_buddy_get_name(buddy), NULL);
 }
 
 static void
@@ -1160,7 +1160,7 @@ finch_blist_pounce_node_cb(PurpleBlistNo
 		b = purple_contact_get_priority_buddy((PurpleContact *)node);
 	else
 		b = (PurpleBuddy *)node;
-	finch_pounce_editor_show(b->account, b->name, NULL);
+	finch_pounce_editor_show(purple_buddy_get_account(b), purple_buddy_get_name(b), NULL);
 }
 
 
@@ -1168,7 +1168,7 @@ create_buddy_menu(GntMenu *menu, PurpleB
 create_buddy_menu(GntMenu *menu, PurpleBuddy *buddy)
 {
 	PurplePluginProtocolInfo *prpl_info;
-	PurpleConnection *gc = purple_account_get_connection(buddy->account);
+	PurpleConnection *gc = purple_account_get_connection(purple_buddy_get_account(buddy));
 
 	prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc));
 	if (prpl_info && prpl_info->get_info)
@@ -1183,7 +1183,7 @@ create_buddy_menu(GntMenu *menu, PurpleB
 	if (prpl_info && prpl_info->send_file)
 	{
 		if (!prpl_info->can_receive_file ||
-			prpl_info->can_receive_file(gc, buddy->name))
+			prpl_info->can_receive_file(gc, purple_buddy_get_name(buddy)))
 			add_custom_action(menu, _("Send File"),
 					PURPLE_CALLBACK(finch_blist_menu_send_file_cb), buddy);
 	}
@@ -1221,8 +1221,9 @@ remove_contact(PurpleContact *contact)
 	group = (PurpleGroup*)purple_blist_node_get_parent(cnode);
 	for (bnode = purple_blist_node_get_first_child(cnode); bnode; bnode = purple_blist_node_get_sibling_next(bnode)) {
 		PurpleBuddy *buddy = (PurpleBuddy*)bnode;
-		if (purple_account_is_connected(buddy->account))
-			purple_account_remove_buddy(buddy->account, buddy, group);
+		PurpleAccount *account = purple_buddy_get_account(buddy);
+		if (purple_account_is_connected(account))
+			purple_account_remove_buddy(account, buddy, group);
 	}
 	purple_blist_remove_contact(contact);
 }
@@ -1296,10 +1297,12 @@ remove_group(PurpleGroup *group)
 			while (bnode) {
 				PurpleBuddy *buddy;
 				if (PURPLE_BLIST_NODE_IS_BUDDY(bnode)) {
+					PurpleAccount *account;
 					buddy = (PurpleBuddy*)bnode;
 					bnode = purple_blist_node_get_sibling_next(bnode);
-					if (purple_account_is_connected(buddy->account)) {
-						purple_account_remove_buddy(buddy->account, buddy, group);
+					account = purple_buddy_get_account(buddy);
+					if (purple_account_is_connected(account)) {
+						purple_account_remove_buddy(account, buddy, group);
 						purple_blist_remove_buddy(buddy);
 					}
 				} else {
@@ -1309,7 +1312,7 @@ remove_group(PurpleGroup *group)
 		} else if (PURPLE_BLIST_NODE_IS_CHAT(cnode)) {
 			PurpleChat *chat = (PurpleChat *)cnode;
 			cnode = purple_blist_node_get_sibling_next(cnode);
-			if (purple_account_is_connected(chat->account))
+			if (purple_account_is_connected(purple_chat_get_account(chat)))
 				purple_blist_remove_chat(chat);
 		} else {
 			cnode = purple_blist_node_get_sibling_next(cnode);
@@ -2243,7 +2246,8 @@ get_contact_log_size(PurpleBlistNode *c)
 
 	for (node = purple_blist_node_get_first_child(c); node; node = purple_blist_node_get_sibling_next(node)) {
 		PurpleBuddy *b = (PurpleBuddy*)node;
-		log += purple_log_get_total_size(PURPLE_LOG_IM, b->name, b->account);
+		log += purple_log_get_total_size(PURPLE_LOG_IM, purple_buddy_get_name(b),
+				purple_buddy_get_account(b));
 	}
 
 	return log;
@@ -2262,8 +2266,8 @@ blist_node_compare_log(PurpleBlistNode *
 		case PURPLE_BLIST_BUDDY_NODE:
 			b1 = (PurpleBuddy*)n1;
 			b2 = (PurpleBuddy*)n2;
-			ret = purple_log_get_total_size(PURPLE_LOG_IM, b2->name, b2->account) - 
-					purple_log_get_total_size(PURPLE_LOG_IM, b1->name, b1->account);
+			ret = purple_log_get_total_size(PURPLE_LOG_IM, purple_buddy_get_name(b2), purple_buddy_get_account(b2)) -
+					purple_log_get_total_size(PURPLE_LOG_IM, purple_buddy_get_name(b1), purple_buddy_get_account(b1));
 			if (ret != 0)
 				return ret;
 			break;
@@ -2465,9 +2469,9 @@ auto_join_chats(gpointer data)
 			node = purple_blist_node_next(node, FALSE)) {
 		if (PURPLE_BLIST_NODE_IS_CHAT(node)) {
 			PurpleChat *chat = (PurpleChat*)node;
-			if (chat->account == account &&
+			if (purple_chat_get_account(chat) == account &&
 					purple_blist_node_get_bool(node, "gnt-autojoin"))
-				serv_join_chat(purple_account_get_connection(chat->account), chat->components);
+				serv_join_chat(purple_account_get_connection(account), purple_chat_get_components(chat));
 		}
 	}
 	return FALSE;
@@ -2561,7 +2565,7 @@ join_chat_select_cb(gpointer data, Purpl
 		if (info->chat_info_defaults != NULL)
 			hash = info->chat_info_defaults(gc, name);
 	} else {
-		hash = chat->components;
+		hash = purple_chat_get_components(chat);
 	}
 	serv_join_chat(gc, hash);
 	if (chat == NULL && hash != NULL)
============================================================
--- finch/gntconv.c	14cd0b7187b120e71d0110368be59acfe8a0e8b4
+++ finch/gntconv.c	085a571773e53f46d226b3ea62ba57c3e93eafba
@@ -255,7 +255,7 @@ find_conv_with_contact(PurpleAccount *ac
 		if (node == (PurpleBlistNode*)buddy)
 			continue;
 		if ((ret = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM,
-				((PurpleBuddy*)node)->name, ((PurpleBuddy*)node)->account)) != NULL)
+				purple_buddy_get_name((PurpleBuddy*)node), purple_buddy_get_account((PurpleBuddy*)node))) != NULL)
 			break;
 	}
 	return ret;
@@ -318,7 +318,7 @@ buddy_signed_on_off(PurpleBuddy *buddy, 
 static void
 buddy_signed_on_off(PurpleBuddy *buddy, gpointer null)
 {
-	PurpleConversation *conv = find_conv_with_contact(buddy->account, buddy->name);
+	PurpleConversation *conv = find_conv_with_contact(purple_buddy_get_account(buddy), purple_buddy_get_name(buddy));
 	if (conv == NULL)
 		return;
 	generate_send_to_menu(FINCH_GET_DATA(conv));
@@ -357,7 +357,7 @@ account_signed_on_off(PurpleConnection *
 				if (info->chat_info_defaults != NULL)
 					comps = info->chat_info_defaults(gc, purple_conversation_get_name(conv));
 			} else {
-				comps = chat->components;
+				comps = purple_chat_get_components(chat);
 			}
 			serv_join_chat(gc, comps);
 			if (chat == NULL && comps != NULL)
============================================================
--- libpurple/blist.c	1c4a5cf9fa2a7e7458741c9943794de3f507dc91
+++ libpurple/blist.c	161630d41acb5ec0eeac73f47f8fead0f8c9380b
@@ -2260,6 +2260,14 @@ purple_chat_get_account(PurpleChat *chat
 	return chat->account;
 }
 
+GHashTable *
+purple_chat_get_components(PurpleChat *chat)
+{
+	g_return_val_if_fail(chat != NULL, NULL);
+
+	return chat->components;
+}
+
 PurpleContact *purple_buddy_get_contact(PurpleBuddy *buddy)
 {
 	g_return_val_if_fail(buddy != NULL, NULL);
============================================================
--- libpurple/blist.h	4433863091966bac35d3c530d2f7105a553a4764
+++ libpurple/blist.h	4dfb47ccb73205a2f3e6abd6afd4c7057b6cc8c2
@@ -59,7 +59,7 @@ typedef enum
 #define PURPLE_BLIST_NODE_IS_GROUP(n)   (purple_blist_node_get_type(n) == PURPLE_BLIST_GROUP_NODE)
 
 #define PURPLE_BUDDY_IS_ONLINE(b) \
-	((b) != NULL && purple_account_is_connected((b)->account) && \
+	((b) != NULL && purple_account_is_connected(purple_buddy_get_account(b)) && \
 	 purple_presence_is_online(purple_buddy_get_presence(b)))
 
 typedef enum
@@ -733,6 +733,16 @@ PurpleAccount *purple_chat_get_account(P
 PurpleAccount *purple_chat_get_account(PurpleChat *chat);
 
 /**
+ * Get a hashtable containing information about a chat.
+ *
+ * @param chat  The chat.
+ *
+ * @constreturn  The hashtable.
+ * @since 2.4.0
+ */
+GHashTable *purple_chat_get_components(PurpleChat *chat);
+
+/**
  * Returns the group of which the buddy is a member.
  *
  * @param buddy   The buddy


More information about the Commits mailing list