Mercurial > pidgin
changeset 22214:2b426862ffbf
Add accessor and update finch to not touch the internals of PurpleConnection.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 26 Jan 2008 21:13:46 +0000 |
parents | 16ff37f64e29 |
children | 07c2b8fa7bb4 |
files | ChangeLog.API finch/gntblist.c finch/gntconn.c finch/gntconv.c finch/gntroomlist.c libpurple/connection.c libpurple/connection.h |
diffstat | 7 files changed, 48 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog.API Sat Jan 26 20:45:41 2008 +0000 +++ b/ChangeLog.API Sat Jan 26 21:13:46 2008 +0000 @@ -35,9 +35,11 @@ * purple_blist_node_get_first_child * purple_blist_node_get_sibling_next * purple_blist_node_get_sibling_prev - * purple_chat_get_account * Added last_received to PurpleConnection, the time_t of the last received packet. + * Added some more accessor functions: + * purple_chat_get_account + * purple_connection_get_prpl Pidgin: Added:
--- a/finch/gntblist.c Sat Jan 26 20:45:41 2008 +0000 +++ b/finch/gntblist.c Sat Jan 26 21:13:46 2008 +0000 @@ -629,6 +629,7 @@ GHashTable *hash = NULL; PurpleConnection *gc; gboolean autojoin; + PurplePluginProtocolInfo *info; account = purple_request_fields_get_account(allfields, "account"); name = purple_request_fields_get_string(allfields, "name"); @@ -638,15 +639,15 @@ if (!purple_account_is_connected(account) || !name || !*name) return; - + if (!group || !*group) group = _("Chats"); gc = purple_account_get_connection(account); - - if (PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults != NULL) - hash = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults(gc, name); - + info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)); + if (info->chat_info_defaults != NULL) + hash = info->chat_info_defaults(gc, name); + chat = purple_chat_new(account, name, hash); if (chat != NULL) { @@ -988,7 +989,7 @@ append_proto_menu(GntMenu *menu, PurpleConnection *gc, PurpleBlistNode *node) { GList *list; - PurplePluginProtocolInfo *prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); + PurplePluginProtocolInfo *prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)); if(!prpl_info || !prpl_info->blist_node_menu) return; @@ -1048,7 +1049,7 @@ purple_request_fields_add_group(fields, group); gc = purple_account_get_connection(chat->account); - parts = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info(gc); + parts = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc))->chat_info(gc); for (iter = parts; iter; iter = iter->next) { pce = iter->data; @@ -1169,7 +1170,7 @@ PurplePluginProtocolInfo *prpl_info; PurpleConnection *gc = purple_account_get_connection(buddy->account); - prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); + prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)); if (prpl_info && prpl_info->get_info) { add_custom_action(menu, _("Get Info"), @@ -2419,7 +2420,7 @@ if (!gc || !PURPLE_CONNECTION_IS_CONNECTED(gc)) continue; - prpl = gc->prpl; + prpl = purple_connection_get_prpl(gc); if (PURPLE_PLUGIN_HAS_ACTIONS(prpl)) { item = gnt_menuitem_new(purple_account_get_username(account)); @@ -2552,12 +2553,13 @@ if (!purple_account_is_connected(account)) return; - gc = purple_account_get_connection(account); + gc = purple_account_get_connection(account); purple_conversation_new(PURPLE_CONV_TYPE_CHAT, account, name); chat = purple_blist_find_chat(account, name); if (chat == NULL) { - if (PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults != NULL) - hash = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults(gc, name); + PurplePluginProtocolInfo *info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)); + if (info->chat_info_defaults != NULL) + hash = info->chat_info_defaults(gc, name); } else { hash = chat->components; }
--- a/finch/gntconn.c Sat Jan 26 20:45:41 2008 +0000 +++ b/finch/gntconn.c Sat Jan 26 21:13:46 2008 +0000 @@ -101,13 +101,14 @@ } static void -finch_connection_report_disconnect(PurpleConnection *gc, const char *text) +finch_connection_report_disconnect(PurpleConnection *gc, PurpleConnectionError reason, + const char *text) { FinchAutoRecon *info; PurpleAccount *account = purple_connection_get_account(gc); GList *list; - if (!gc->wants_to_die) { + if (!purple_connection_error_is_fatal(reason)) { info = g_hash_table_lookup(hash, account); if (info == NULL) { @@ -179,10 +180,10 @@ NULL, /* connected */ NULL, /* disconnected */ NULL, /* notice */ - finch_connection_report_disconnect, + NULL, NULL, /* network_connected */ NULL, /* network_disconnected */ - NULL, + finch_connection_report_disconnect, NULL, NULL, NULL
--- a/finch/gntconv.c Sat Jan 26 20:45:41 2008 +0000 +++ b/finch/gntconv.c Sat Jan 26 21:13:46 2008 +0000 @@ -332,14 +332,15 @@ GHashTable *comps = NULL; list = list->next; - if (conv->account != gc->account || + if (conv->account != purple_connection_get_account(gc) || !purple_conversation_get_data(conv, "want-to-rejoin")) continue; chat = purple_blist_find_chat(conv->account, conv->name); if (chat == NULL) { - if (PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults != NULL) - comps = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults(gc, conv->name); + PurplePluginProtocolInfo *info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)); + if (info->chat_info_defaults != NULL) + comps = info->chat_info_defaults(gc, conv->name); } else { comps = chat->components; } @@ -532,7 +533,8 @@ if (purple_conversation_get_type(ggc->active_conv) == PURPLE_CONV_TYPE_IM) { PurpleAccount *account = purple_conversation_get_account(ggc->active_conv); PurpleConnection *gc = purple_account_get_connection(account); - PurplePluginProtocolInfo *pinfo = gc ? PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl) : NULL; + PurplePluginProtocolInfo *pinfo = + gc ? PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)) : NULL; if (pinfo && pinfo->get_info) { item = gnt_menuitem_new(_("Get Info"));
--- a/finch/gntroomlist.c Sat Jan 26 20:45:41 2008 +0000 +++ b/finch/gntroomlist.c Sat Jan 26 21:13:46 2008 +0000 @@ -116,7 +116,7 @@ if (gc == NULL || room == NULL) return; - prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); + prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)); if(prpl_info != NULL && prpl_info->roomlist_room_serialize) name = prpl_info->roomlist_room_serialize(room); @@ -238,7 +238,7 @@ PurplePluginProtocolInfo *prpl_info = NULL; PurpleConnection *gc = list->data; - prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); + prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)); if (prpl_info->roomlist_get_list != NULL) { PurpleAccount *account = purple_connection_get_account(gc); char *text = g_strdup_printf("%s (%s)",
--- a/libpurple/connection.c Sat Jan 26 20:45:41 2008 +0000 +++ b/libpurple/connection.c Sat Jan 26 21:13:46 2008 +0000 @@ -424,6 +424,14 @@ return gc->account; } +PurplePlugin * +purple_connection_get_prpl(const PurpleConnection *gc) +{ + g_return_val_if_fail(gc != NULL, NULL); + + return gc->prpl; +} + const char * purple_connection_get_password(const PurpleConnection *gc) {
--- a/libpurple/connection.h Sat Jan 26 20:45:41 2008 +0000 +++ b/libpurple/connection.h Sat Jan 26 21:13:46 2008 +0000 @@ -364,7 +364,7 @@ * @return TRUE if the account is connected, otherwise returns FALSE. */ #define PURPLE_CONNECTION_IS_CONNECTED(gc) \ - (gc->state == PURPLE_CONNECTED) + (purple_connection_get_state(gc) == PURPLE_CONNECTED) /** * Returns the connection's account. @@ -376,6 +376,15 @@ PurpleAccount *purple_connection_get_account(const PurpleConnection *gc); /** + * Returns the protocol plugin managing a connection. + * + * @param gc The connection. + * + * @return The protocol plugin. + */ +PurplePlugin * purple_connection_get_prpl(const PurpleConnection *gc); + +/** * Returns the connection's password. * * @param gc The connection.