Mercurial > pidgin.yaz
changeset 22219:797230b3e48e
Add accessor and update finch to not touch the internals of PurpleBuddy and PurpleChat.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sun, 27 Jan 2008 04:06:39 +0000 |
parents | 5152a14d06a3 |
children | 1f256f63c52c |
files | ChangeLog.API finch/gntblist.c finch/gntconv.c libpurple/blist.c libpurple/blist.h |
diffstat | 5 files changed, 52 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog.API Sat Jan 26 22:36:01 2008 +0000 +++ b/ChangeLog.API Sun Jan 27 04:06:39 2008 +0000 @@ -39,6 +39,7 @@ 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
--- a/finch/gntblist.c Sat Jan 26 22:36:01 2008 +0000 +++ b/finch/gntblist.c Sun Jan 27 04:06:39 2008 +0000 @@ -243,7 +243,7 @@ } 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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, 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 @@ 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 @@ 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 @@ 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 @@ } 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 @@ 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 @@ 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 @@ 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 @@ 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)
--- a/finch/gntconv.c Sat Jan 26 22:36:01 2008 +0000 +++ b/finch/gntconv.c Sun Jan 27 04:06:39 2008 +0000 @@ -255,7 +255,7 @@ 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 @@ 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 @@ 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)
--- a/libpurple/blist.c Sat Jan 26 22:36:01 2008 +0000 +++ b/libpurple/blist.c Sun Jan 27 04:06:39 2008 +0000 @@ -2260,6 +2260,14 @@ 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);
--- a/libpurple/blist.h Sat Jan 26 22:36:01 2008 +0000 +++ b/libpurple/blist.h Sun Jan 27 04:06:39 2008 +0000 @@ -59,7 +59,7 @@ #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(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