Mercurial > pidgin.yaz
comparison finch/gntblist.c @ 22814:2d10cd28aa57
Check to see if we are already in a room before attempting to join. If
we are already in that room, then focus the conversation. This should
address the issue where finch doesn't play well when adding a chat in the
buddylist with auto-join turned on while already in that chat.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sun, 04 May 2008 03:24:18 +0000 |
parents | 08befc594de4 |
children | 04e0d8677b9a |
comparison
equal
deleted
inserted
replaced
22813:e61d5778b065 | 22814:2d10cd28aa57 |
---|---|
642 account, NULL, NULL, | 642 account, NULL, NULL, |
643 NULL); | 643 NULL); |
644 } | 644 } |
645 | 645 |
646 static void | 646 static void |
647 join_chat(PurpleChat *chat) | |
648 { | |
649 PurpleAccount *account = purple_chat_get_account(chat); | |
650 const char *name; | |
651 PurpleConversation *conv; | |
652 const char *alias; | |
653 | |
654 /* This hack here is to work around the fact that there's no good way of | |
655 * getting the actual name of a chat. I don't understand why we return | |
656 * the alias for a chat when all we want is the name. */ | |
657 alias = chat->alias; | |
658 chat->alias = NULL; | |
659 name = purple_chat_get_name(chat); | |
660 conv = purple_find_conversation_with_account( | |
661 PURPLE_CONV_TYPE_CHAT, name, account); | |
662 chat->alias = (char *)alias; | |
663 | |
664 if (!conv || purple_conv_chat_has_left(PURPLE_CONV_CHAT(conv))) { | |
665 serv_join_chat(purple_account_get_connection(account), | |
666 purple_chat_get_components(chat)); | |
667 } else if (conv) { | |
668 purple_conversation_present(conv); | |
669 } | |
670 } | |
671 | |
672 static void | |
647 add_chat_cb(void *data, PurpleRequestFields *allfields) | 673 add_chat_cb(void *data, PurpleRequestFields *allfields) |
648 { | 674 { |
649 PurpleAccount *account; | 675 PurpleAccount *account; |
650 const char *alias, *name, *group; | 676 const char *alias, *name, *group; |
651 PurpleChat *chat; | 677 PurpleChat *chat; |
680 purple_blist_add_group(grp, NULL); | 706 purple_blist_add_group(grp, NULL); |
681 } | 707 } |
682 purple_blist_add_chat(chat, grp, NULL); | 708 purple_blist_add_chat(chat, grp, NULL); |
683 purple_blist_alias_chat(chat, alias); | 709 purple_blist_alias_chat(chat, alias); |
684 purple_blist_node_set_bool((PurpleBlistNode*)chat, "gnt-autojoin", autojoin); | 710 purple_blist_node_set_bool((PurpleBlistNode*)chat, "gnt-autojoin", autojoin); |
685 if (autojoin) | 711 if (autojoin) { |
686 serv_join_chat(purple_account_get_connection(purple_chat_get_account(chat)), purple_chat_get_components(chat)); | 712 join_chat(chat); |
713 } | |
687 } | 714 } |
688 } | 715 } |
689 | 716 |
690 static void | 717 static void |
691 finch_request_add_chat(PurpleAccount *account, PurpleGroup *grp, const char *alias, const char *name) | 718 finch_request_add_chat(PurpleAccount *account, PurpleGroup *grp, const char *alias, const char *name) |
943 GntTree *tree = GNT_TREE(ggblist->tree); | 970 GntTree *tree = GNT_TREE(ggblist->tree); |
944 PurpleBlistNode *node = gnt_tree_get_selection_data(tree); | 971 PurpleBlistNode *node = gnt_tree_get_selection_data(tree); |
945 | 972 |
946 if (!node) | 973 if (!node) |
947 return; | 974 return; |
948 | 975 |
949 if (PURPLE_BLIST_NODE_IS_CONTACT(node)) | 976 if (PURPLE_BLIST_NODE_IS_CONTACT(node)) |
950 node = (PurpleBlistNode*)purple_contact_get_priority_buddy((PurpleContact*)node); | 977 node = (PurpleBlistNode*)purple_contact_get_priority_buddy((PurpleContact*)node); |
951 | 978 |
952 if (PURPLE_BLIST_NODE_IS_BUDDY(node)) | 979 if (PURPLE_BLIST_NODE_IS_BUDDY(node)) |
953 { | 980 { |
966 } | 993 } |
967 finch_conversation_set_active(conv); | 994 finch_conversation_set_active(conv); |
968 } | 995 } |
969 else if (PURPLE_BLIST_NODE_IS_CHAT(node)) | 996 else if (PURPLE_BLIST_NODE_IS_CHAT(node)) |
970 { | 997 { |
971 PurpleChat *chat = (PurpleChat*)node; | 998 join_chat((PurpleChat*)node); |
972 serv_join_chat(purple_account_get_connection(purple_chat_get_account(chat)), purple_chat_get_components(chat)); | |
973 } | 999 } |
974 } | 1000 } |
975 | 1001 |
976 static void | 1002 static void |
977 context_menu_callback(GntMenuItem *item, gpointer data) | 1003 context_menu_callback(GntMenuItem *item, gpointer data) |