Mercurial > pidgin.yaz
changeset 6456:ccfdf9f2cdd1
[gaim-migrate @ 6965]
Conversation placement by group now applies to chats in the buddy list as
well. Also added functions for finding a chat by name, and getting its
parent group.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Wed, 13 Aug 2003 21:08:29 +0000 |
parents | cd0b5eaf9460 |
children | 5ce6fdb10c91 |
files | ChangeLog src/blist.c src/blist.h src/conversation.c src/server.c |
diffstat | 5 files changed, 130 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Wed Aug 13 20:13:06 2003 +0000 +++ b/ChangeLog Wed Aug 13 21:08:29 2003 +0000 @@ -12,6 +12,8 @@ * Shows "hiptop" icon for AIM buddies using hiptop devices (Robey Pointer) * Privacy core/UI split. + * Conversation placement by group now applies to chats in the buddy + list as well. * Events in a conversation (user logged in, logged out, window closed, etc.) now grey the tab. * Various bug fixes (larne from irc, Tim Ringenbach, Bjoern
--- a/src/blist.c Wed Aug 13 20:13:06 2003 +0000 +++ b/src/blist.c Wed Aug 13 21:08:29 2003 +0000 @@ -870,6 +870,57 @@ } return NULL; } + +struct chat * +gaim_blist_find_chat(GaimAccount *account, const char *name) +{ + char *chat_name; + struct chat *chat; + GaimPlugin *prpl; + GaimPluginProtocolInfo *prpl_info = NULL; + struct proto_chat_entry *pce; + GaimBlistNode *node, *group; + GList *parts; + + g_return_val_if_fail(gaim_get_blist() != NULL, NULL); + g_return_val_if_fail(name != NULL, NULL); + + for (group = gaimbuddylist->root; group != NULL; group = group->next) { + for (node = group->child; node != NULL; node = node->next) { + if (GAIM_BLIST_NODE_IS_CHAT(node)) { + + chat = (struct chat *)node; + + prpl = gaim_find_prpl(gaim_account_get_protocol(chat->account)); + prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); + + parts = prpl_info->chat_info( + gaim_account_get_connection(chat->account)); + + pce = parts->data; + chat_name = g_hash_table_lookup(chat->components, + pce->identifier); + + if (chat->account == account && + name != NULL && !strcmp(chat_name, name)) { + + return chat; + } + } + } + } + + return NULL; +} + +struct group * +gaim_blist_chat_get_group(struct chat *chat) +{ + g_return_val_if_fail(chat != NULL, NULL); + + return (struct group *)(((GaimBlistNode *)chat)->parent); +} + struct group *gaim_find_buddys_group(struct buddy *buddy) { if (!buddy)
--- a/src/blist.h Wed Aug 13 20:13:06 2003 +0000 +++ b/src/blist.h Wed Aug 13 21:08:29 2003 +0000 @@ -433,6 +433,24 @@ struct group *gaim_find_group(const char *name); /** + * Finds a chat by name. + * + * @param name The chat's name. + * + * @return The chat, or @c NULL if the chat does not exist. + */ +struct chat *gaim_blist_find_chat(GaimAccount *account, const char *name); + +/** + * Returns the group of which the chat is a member. + * + * @param chat The chat. + * + * @return The parent group, or @c NULL if the chat is not in a group. + */ +struct group *gaim_blist_chat_get_group(struct chat *chat); + +/** * Returns the group of which the buddy is a member. * * @param buddy The buddy
--- a/src/conversation.c Wed Aug 13 20:13:06 2003 +0000 +++ b/src/conversation.c Wed Aug 13 21:08:29 2003 +0000 @@ -2220,15 +2220,7 @@ type = gaim_conversation_get_type(conv); - if (type != GAIM_CONV_IM) { - win = gaim_get_last_window_with_type(type); - - if (win == NULL) - conv_placement_new_window(conv); - else - gaim_window_add_conversation(win, conv); - } - else { + if (type == GAIM_CONV_IM) { struct buddy *b; struct group *grp = NULL; GList *wins, *convs; @@ -2271,6 +2263,58 @@ /* Make a new window. */ conv_placement_new_window(conv); } + else if (type == GAIM_CONV_CHAT) { + struct chat *chat; + struct group *group = NULL; + GList *wins, *convs; + + chat = gaim_blist_find_chat(gaim_conversation_get_account(conv), + gaim_conversation_get_name(conv)); + + if (chat != NULL) + group = gaim_blist_chat_get_group(chat); + + /* Go through the list of chats and find one with this group. */ + for (wins = gaim_get_windows(); wins != NULL; wins = wins->next) { + GaimWindow *win2; + GaimConversation *conv2; + struct chat *chat2; + struct group *group2 = NULL; + + win2 = (GaimWindow *)wins->data; + + for (convs = gaim_window_get_conversations(win2); + convs != NULL; + convs = convs->next) { + + conv2 = (GaimConversation *)convs->data; + + chat2 = gaim_blist_find_chat( + gaim_conversation_get_account(conv2), + gaim_conversation_get_name(conv2)); + + if (chat2 != NULL) + group2 = gaim_blist_chat_get_group(chat2); + + if (group == group2) { + gaim_window_add_conversation(win2, conv); + + return; + } + } + } + + /* Make a new window. */ + conv_placement_new_window(conv); + } + else { + win = gaim_get_last_window_with_type(type); + + if (win == NULL) + conv_placement_new_window(conv); + else + gaim_window_add_conversation(win, conv); + } } /* This groups things by account. Otherwise, the same semantics as above */
--- a/src/server.c Wed Aug 13 20:13:06 2003 +0000 +++ b/src/server.c Wed Aug 13 21:08:29 2003 +0000 @@ -1192,13 +1192,12 @@ gaim_event_broadcast(event_got_typing, gc, name); - if (b != NULL) - if (state == GAIM_TYPING) - gaim_pounce_execute(gc->account, name, - GAIM_POUNCE_TYPING); - else - gaim_pounce_execute(gc->account, name, - GAIM_POUNCE_TYPING_STOPPED); + if (b != NULL) { + if (state == GAIM_TYPING) + gaim_pounce_execute(gc->account, name, GAIM_POUNCE_TYPING); + else + gaim_pounce_execute(gc->account, name, GAIM_POUNCE_TYPING_STOPPED); + } if (timeout > 0) gaim_im_start_typing_timeout(im, timeout);