im.pidgin.pidgin: e434795e65b6b517f87e2bc5a7b5ce1b51ee0792
sadrul at pidgin.im
sadrul at pidgin.im
Sat Jan 26 17:01:13 EST 2008
-----------------------------------------------------------------
Revision: e434795e65b6b517f87e2bc5a7b5ce1b51ee0792
Ancestor: 72bbb00c0c78543131719af4cdd9dfc2d9a1c3ef
Author: sadrul at pidgin.im
Date: 2008-01-26T20:45:41
Branch: im.pidgin.pidgin
Modified files:
finch/gntaccount.c finch/gntblist.c finch/gntconv.c
finch/gntpounce.c
ChangeLog:
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.
-------------- next part --------------
============================================================
--- finch/gntaccount.c bfa0738a6e5a1d73f510c1f286bb5399cb2c7c2f
+++ finch/gntaccount.c b3a3e93a028b0a918e11a6a1f9008e29d32d3197
@@ -686,7 +686,7 @@ void finch_accounts_show_all()
}
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 @@ void finch_accounts_show_all()
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 @@ finch_request_authorize(PurpleAccount *a
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);
============================================================
--- finch/gntblist.c 0e620928f08f2b77fa10c61734dfe1a34365bb94
+++ finch/gntblist.c d5db0530516a95edf16b90521c290943e70fd028
@@ -658,7 +658,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(chat->account->gc, chat->components);
+ serv_join_chat(purple_account_get_connection(chat->account), chat->components);
}
}
@@ -943,7 +943,7 @@ selection_activate(GntWidget *widget, Fi
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 @@ chat_components_edit(PurpleBlistNode *se
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 @@ finch_blist_get_buddy_info_cb(PurpleBlis
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, PurpleB
create_buddy_menu(GntMenu *menu, PurpleBuddy *buddy)
{
PurplePluginProtocolInfo *prpl_info;
+ PurpleConnection *gc = purple_account_get_connection(buddy->account);
- prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(buddy->account->gc->prpl);
+ 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 @@ create_buddy_menu(GntMenu *menu, PurpleB
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);
}
============================================================
--- finch/gntconv.c 917dbec5c5000682efb7336cc6e79f9fa2cfd57b
+++ finch/gntconv.c cab40bda2c1af4ecf545d2a4a58fa0dc0baac63d
@@ -531,7 +531,8 @@ gg_create_menu(FinchConv *ggc)
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 @@ gg_create_menu(FinchConv *ggc)
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);
============================================================
--- finch/gntpounce.c 6c342cc5589ee7de6275c9669026b9c1f2feaa45
+++ finch/gntpounce.c 36a85ed06e9924bd5e4f5f5a6bf2230b4b3cec2a
@@ -808,39 +808,42 @@ pounce_cb(PurplePounce *pounce, PurplePo
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 @@ pounce_cb(PurplePounce *pounce, PurplePo
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);
}
}
More information about the Commits
mailing list