Mercurial > pidgin.yaz
changeset 22213:16ff37f64e29
Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 26 Jan 2008 20:45:41 +0000 |
parents | 6bb29f94862c |
children | 2b426862ffbf |
files | finch/gntaccount.c finch/gntblist.c finch/gntconv.c finch/gntpounce.c |
diffstat | 4 files changed, 47 insertions(+), 40 deletions(-) [+] |
line wrap: on
line diff
--- a/finch/gntaccount.c Sat Jan 26 20:32:26 2008 +0000 +++ b/finch/gntaccount.c Sat Jan 26 20:45:41 2008 +0000 @@ -686,7 +686,7 @@ } g_signal_connect(G_OBJECT(accounts.tree), "toggled", G_CALLBACK(account_toggled), NULL); - + gnt_tree_set_col_width(GNT_TREE(accounts.tree), 0, 40); gnt_tree_set_col_width(GNT_TREE(accounts.tree), 1, 10); gnt_box_add_widget(GNT_BOX(accounts.window), accounts.tree); @@ -708,11 +708,11 @@ gnt_box_add_widget(GNT_BOX(box), button); gnt_util_set_trigger_widget(GNT_WIDGET(accounts.tree), GNT_KEY_DEL, button); g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(delete_account_cb), accounts.tree); - + gnt_box_add_widget(GNT_BOX(accounts.window), box); g_signal_connect(G_OBJECT(accounts.window), "destroy", G_CALLBACK(reset_accounts_win), NULL); - + gnt_widget_show(accounts.window); } @@ -981,7 +981,7 @@ gnt_box_add_widget(GNT_BOX(uihandle), gnt_hline_new()); - widget = finch_retrieve_user_info(account->gc, remote_user); + widget = finch_retrieve_user_info(purple_account_get_connection(account), remote_user); for (iter = GNT_BOX(widget)->list; iter; iter = iter->next) { if (GNT_IS_BUTTON(iter->data)) { gnt_widget_destroy(iter->data);
--- a/finch/gntblist.c Sat Jan 26 20:32:26 2008 +0000 +++ b/finch/gntblist.c Sat Jan 26 20:45:41 2008 +0000 @@ -658,7 +658,7 @@ purple_blist_alias_chat(chat, alias); purple_blist_node_set_bool((PurpleBlistNode*)chat, "gnt-autojoin", autojoin); if (autojoin) - serv_join_chat(chat->account->gc, chat->components); + serv_join_chat(purple_account_get_connection(chat->account), chat->components); } } @@ -943,7 +943,7 @@ else if (PURPLE_BLIST_NODE_IS_CHAT(node)) { PurpleChat *chat = (PurpleChat*)node; - serv_join_chat(chat->account->gc, chat->components); + serv_join_chat(purple_account_get_connection(chat->account), chat->components); } } @@ -1043,10 +1043,12 @@ PurpleRequestField *field; GList *parts, *iter; struct proto_chat_entry *pce; + PurpleConnection *gc; purple_request_fields_add_group(fields, group); - parts = PURPLE_PLUGIN_PROTOCOL_INFO(chat->account->gc->prpl)->chat_info(chat->account->gc); + gc = purple_account_get_connection(chat->account); + parts = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info(gc); for (iter = parts; iter; iter = iter->next) { pce = iter->data; @@ -1140,13 +1142,13 @@ static void finch_blist_get_buddy_info_cb(PurpleBlistNode *selected, PurpleBuddy *buddy) { - finch_retrieve_user_info(buddy->account->gc, purple_buddy_get_name(buddy)); + finch_retrieve_user_info(purple_account_get_connection(buddy->account), purple_buddy_get_name(buddy)); } static void finch_blist_menu_send_file_cb(PurpleBlistNode *selected, PurpleBuddy *buddy) { - serv_send_file(buddy->account->gc, buddy->name, NULL); + serv_send_file(purple_account_get_connection(buddy->account), buddy->name, NULL); } static void @@ -1165,8 +1167,9 @@ create_buddy_menu(GntMenu *menu, PurpleBuddy *buddy) { PurplePluginProtocolInfo *prpl_info; - - prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(buddy->account->gc->prpl); + PurpleConnection *gc = purple_account_get_connection(buddy->account); + + prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); if (prpl_info && prpl_info->get_info) { add_custom_action(menu, _("Get Info"), @@ -1179,7 +1182,7 @@ if (prpl_info && prpl_info->send_file) { if (!prpl_info->can_receive_file || - prpl_info->can_receive_file(buddy->account->gc, buddy->name)) + prpl_info->can_receive_file(gc, buddy->name)) add_custom_action(menu, _("Send File"), PURPLE_CALLBACK(finch_blist_menu_send_file_cb), buddy); }
--- a/finch/gntconv.c Sat Jan 26 20:32:26 2008 +0000 +++ b/finch/gntconv.c Sat Jan 26 20:45:41 2008 +0000 @@ -531,7 +531,8 @@ if (purple_conversation_get_type(ggc->active_conv) == PURPLE_CONV_TYPE_IM) { PurpleAccount *account = purple_conversation_get_account(ggc->active_conv); - PurplePluginProtocolInfo *pinfo = account->gc ? PURPLE_PLUGIN_PROTOCOL_INFO(account->gc->prpl) : NULL; + PurpleConnection *gc = purple_account_get_connection(account); + PurplePluginProtocolInfo *pinfo = gc ? PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl) : NULL; if (pinfo && pinfo->get_info) { item = gnt_menuitem_new(_("Get Info")); @@ -545,7 +546,7 @@ if (pinfo && pinfo->send_file && (!pinfo->can_receive_file || - pinfo->can_receive_file(account->gc, purple_conversation_get_name(ggc->active_conv)))) { + pinfo->can_receive_file(gc, purple_conversation_get_name(ggc->active_conv)))) { item = gnt_menuitem_new(_("Send File")); gnt_menu_add_item(GNT_MENU(sub), item); gnt_menuitem_set_callback(item, send_file_cb, ggc);
--- a/finch/gntpounce.c Sat Jan 26 20:32:26 2008 +0000 +++ b/finch/gntpounce.c Sat Jan 26 20:45:41 2008 +0000 @@ -808,39 +808,42 @@ if (purple_pounce_action_is_enabled(pounce, "popup-notify")) { - char *tmp; + char *tmp = NULL; const char *name_shown; const char *reason; + struct { + PurplePounceEvent event; + const char *format; + } messages[] = { + {PURPLE_POUNCE_TYPING, _("%s has started typing to you (%s)")}, + {PURPLE_POUNCE_TYPED, _("%s has paused while typing to you (%s)")}, + {PURPLE_POUNCE_SIGNON, _("%s has signed on (%s)")}, + {PURPLE_POUNCE_IDLE_RETURN, _("%s has returned from being idle (%s)")}, + {PURPLE_POUNCE_AWAY_RETURN, _("%s has returned from being away (%s)")}, + {PURPLE_POUNCE_TYPING_STOPPED, _("%s has stopped typing to you (%s)")}, + {PURPLE_POUNCE_SIGNOFF, _("%s has signed off (%s)")}, + {PURPLE_POUNCE_IDLE, _("%s has become idle (%s)")}, + {PURPLE_POUNCE_AWAY, _("%s has gone away. (%s)")}, + {PURPLE_POUNCE_MESSAGE_RECEIVED, _("%s has sent you a message. (%s)")}, + {0, NULL} + }; + int i; reason = purple_pounce_action_get_attribute(pounce, "popup-notify", - "reason"); + "reason"); /* * Here we place the protocol name in the pounce dialog to lessen * confusion about what protocol a pounce is for. */ - tmp = g_strdup_printf( - (events & PURPLE_POUNCE_TYPING) ? - _("%s has started typing to you (%s)") : - (events & PURPLE_POUNCE_TYPED) ? - _("%s has paused while typing to you (%s)") : - (events & PURPLE_POUNCE_SIGNON) ? - _("%s has signed on (%s)") : - (events & PURPLE_POUNCE_IDLE_RETURN) ? - _("%s has returned from being idle (%s)") : - (events & PURPLE_POUNCE_AWAY_RETURN) ? - _("%s has returned from being away (%s)") : - (events & PURPLE_POUNCE_TYPING_STOPPED) ? - _("%s has stopped typing to you (%s)") : - (events & PURPLE_POUNCE_SIGNOFF) ? - _("%s has signed off (%s)") : - (events & PURPLE_POUNCE_IDLE) ? - _("%s has become idle (%s)") : - (events & PURPLE_POUNCE_AWAY) ? - _("%s has gone away. (%s)") : - (events & PURPLE_POUNCE_MESSAGE_RECEIVED) ? - _("%s has sent you a message. (%s)") : - _("Unknown pounce event. Please report this!"), - alias, purple_account_get_protocol_name(account)); + for (i = 0; messages[i].format != NULL; i++) { + if (messages[i].event & events) { + tmp = g_strdup_printf(messages[i].format, alias, + purple_account_get_protocol_name(account)); + break; + } + } + if (tmp == NULL) + tmp = g_strdup(_("Unknown pounce event. Please report this!")); /* * Ok here is where I change the second argument, title, from @@ -880,7 +883,7 @@ purple_conversation_write(conv, NULL, message, PURPLE_MESSAGE_SEND, time(NULL)); - serv_send_im(account->gc, (char *)pouncee, (char *)message, 0); + serv_send_im(purple_account_get_connection(account), (char *)pouncee, (char *)message, 0); } }