| 223 * deal with the internals on its own time. Don't do this if the |
223 * deal with the internals on its own time. Don't do this if the |
| 224 * protocol already knows it left the chat. |
224 * protocol already knows it left the chat. |
| 225 */ |
225 */ |
| 226 if(!purple_chat_conversation_has_left(chat)) { |
226 if(!purple_chat_conversation_has_left(chat)) { |
| 227 purple_serv_chat_leave(gc, chat_id); |
227 purple_serv_chat_leave(gc, chat_id); |
| 228 } |
|
| 229 |
|
| 230 /* |
|
| 231 * If they didn't call purple_serv_got_chat_left by now, it's too late. |
|
| 232 * So we better do it for them before we destroy the thing. |
|
| 233 */ |
|
| 234 if(!purple_chat_conversation_has_left(chat)) { |
|
| 235 purple_serv_got_chat_left(gc, chat_id); |
|
| 236 } |
228 } |
| 237 } |
229 } |
| 238 |
230 |
| 239 g_clear_pointer(&priv->users, g_hash_table_destroy); |
231 g_clear_pointer(&priv->users, g_hash_table_destroy); |
| 240 |
232 |
| 476 purple_chat_conversation_add_users(PurpleChatConversation *chat, GList *users, |
468 purple_chat_conversation_add_users(PurpleChatConversation *chat, GList *users, |
| 477 GList *extra_msgs, GList *flags, |
469 GList *extra_msgs, GList *flags, |
| 478 gboolean new_arrivals) |
470 gboolean new_arrivals) |
| 479 { |
471 { |
| 480 PurpleConversation *conv; |
472 PurpleConversation *conv; |
| 481 PurpleConversationUiOps *ops; |
|
| 482 PurpleChatUser *chatuser; |
473 PurpleChatUser *chatuser; |
| 483 PurpleChatConversationPrivate *priv; |
474 PurpleChatConversationPrivate *priv; |
| 484 PurpleAccount *account; |
475 PurpleAccount *account; |
| 485 PurpleConnection *gc; |
476 PurpleConnection *gc; |
| 486 PurpleProtocol *protocol; |
477 PurpleProtocol *protocol; |
| 490 g_return_if_fail(PURPLE_IS_CHAT_CONVERSATION(chat)); |
481 g_return_if_fail(PURPLE_IS_CHAT_CONVERSATION(chat)); |
| 491 g_return_if_fail(users != NULL); |
482 g_return_if_fail(users != NULL); |
| 492 |
483 |
| 493 priv = purple_chat_conversation_get_instance_private(chat); |
484 priv = purple_chat_conversation_get_instance_private(chat); |
| 494 conv = PURPLE_CONVERSATION(chat); |
485 conv = PURPLE_CONVERSATION(chat); |
| 495 ops = purple_conversation_get_ui_ops(conv); |
|
| 496 |
486 |
| 497 account = purple_conversation_get_account(conv); |
487 account = purple_conversation_get_account(conv); |
| 498 gc = purple_conversation_get_connection(conv); |
488 gc = purple_conversation_get_connection(conv); |
| 499 g_return_if_fail(PURPLE_IS_CONNECTION(gc)); |
489 g_return_if_fail(PURPLE_IS_CONNECTION(gc)); |
| 500 |
490 |
| 576 } |
566 } |
| 577 } |
567 } |
| 578 |
568 |
| 579 cbuddies = g_list_sort(cbuddies, (GCompareFunc)purple_chat_user_compare); |
569 cbuddies = g_list_sort(cbuddies, (GCompareFunc)purple_chat_user_compare); |
| 580 |
570 |
| 581 if(ops != NULL && ops->chat_add_users != NULL) { |
|
| 582 ops->chat_add_users(chat, cbuddies, new_arrivals); |
|
| 583 } |
|
| 584 |
|
| 585 g_list_free(cbuddies); |
571 g_list_free(cbuddies); |
| 586 } |
572 } |
| 587 |
573 |
| 588 void |
574 void |
| 589 purple_chat_conversation_rename_user(PurpleChatConversation *chat, |
575 purple_chat_conversation_rename_user(PurpleChatConversation *chat, |
| 590 const gchar *old_user, |
576 const gchar *old_user, |
| 591 const gchar *new_user) |
577 const gchar *new_user) |
| 592 { |
578 { |
| 593 PurpleConversation *conv; |
579 PurpleConversation *conv; |
| 594 PurpleConversationUiOps *ops; |
|
| 595 PurpleAccount *account; |
580 PurpleAccount *account; |
| 596 PurpleConnection *gc; |
581 PurpleConnection *gc; |
| 597 PurpleProtocol *protocol; |
582 PurpleProtocol *protocol; |
| 598 PurpleChatUser *cb; |
583 PurpleChatUser *cb; |
| 599 PurpleChatUserFlags flags; |
584 PurpleChatUserFlags flags; |
| 607 g_return_if_fail(old_user != NULL); |
592 g_return_if_fail(old_user != NULL); |
| 608 g_return_if_fail(new_user != NULL); |
593 g_return_if_fail(new_user != NULL); |
| 609 |
594 |
| 610 priv = purple_chat_conversation_get_instance_private(chat); |
595 priv = purple_chat_conversation_get_instance_private(chat); |
| 611 conv = PURPLE_CONVERSATION(chat); |
596 conv = PURPLE_CONVERSATION(chat); |
| 612 ops = purple_conversation_get_ui_ops(conv); |
|
| 613 account = purple_conversation_get_account(conv); |
597 account = purple_conversation_get_account(conv); |
| 614 |
598 |
| 615 gc = purple_conversation_get_connection(conv); |
599 gc = purple_conversation_get_connection(conv); |
| 616 g_return_if_fail(PURPLE_IS_CONNECTION(gc)); |
600 g_return_if_fail(PURPLE_IS_CONNECTION(gc)); |
| 617 protocol = purple_connection_get_protocol(gc); |
601 protocol = purple_connection_get_protocol(gc); |
| 645 flags = purple_chat_user_get_flags(purple_chat_conversation_find_user(chat, old_user)); |
629 flags = purple_chat_user_get_flags(purple_chat_conversation_find_user(chat, old_user)); |
| 646 cb = purple_chat_user_new(chat, new_user, new_alias, flags); |
630 cb = purple_chat_user_new(chat, new_user, new_alias, flags); |
| 647 |
631 |
| 648 g_hash_table_replace(priv->users, |
632 g_hash_table_replace(priv->users, |
| 649 g_strdup(purple_chat_user_get_name(cb)), cb); |
633 g_strdup(purple_chat_user_get_name(cb)), cb); |
| 650 |
|
| 651 if(ops != NULL && ops->chat_rename_user != NULL) { |
|
| 652 ops->chat_rename_user(chat, old_user, new_user, new_alias); |
|
| 653 } |
|
| 654 |
634 |
| 655 cb = purple_chat_conversation_find_user(chat, old_user); |
635 cb = purple_chat_conversation_find_user(chat, old_user); |
| 656 if(cb) { |
636 if(cb) { |
| 657 g_hash_table_remove(priv->users, purple_chat_user_get_name(cb)); |
637 g_hash_table_remove(priv->users, purple_chat_user_get_name(cb)); |
| 658 } |
638 } |
| 714 GList *users, const gchar *reason) |
694 GList *users, const gchar *reason) |
| 715 { |
695 { |
| 716 PurpleConversation *conv; |
696 PurpleConversation *conv; |
| 717 PurpleConnection *gc; |
697 PurpleConnection *gc; |
| 718 PurpleProtocol *protocol; |
698 PurpleProtocol *protocol; |
| 719 PurpleConversationUiOps *ops; |
|
| 720 PurpleChatUser *cb; |
699 PurpleChatUser *cb; |
| 721 PurpleChatConversationPrivate *priv; |
700 PurpleChatConversationPrivate *priv; |
| 722 GList *l; |
701 GList *l; |
| 723 gboolean quiet; |
702 gboolean quiet; |
| 724 gpointer handle; |
703 gpointer handle; |
| 733 g_return_if_fail(PURPLE_IS_CONNECTION(gc)); |
712 g_return_if_fail(PURPLE_IS_CONNECTION(gc)); |
| 734 |
713 |
| 735 protocol = purple_connection_get_protocol(gc); |
714 protocol = purple_connection_get_protocol(gc); |
| 736 g_return_if_fail(PURPLE_IS_PROTOCOL(protocol)); |
715 g_return_if_fail(PURPLE_IS_PROTOCOL(protocol)); |
| 737 |
716 |
| 738 ops = purple_conversation_get_ui_ops(conv); |
|
| 739 handle = purple_conversations_get_handle(); |
717 handle = purple_conversations_get_handle(); |
| 740 |
718 |
| 741 for(l = users; l != NULL; l = l->next) { |
719 for(l = users; l != NULL; l = l->next) { |
| 742 const gchar *user = (const gchar *)l->data; |
720 const gchar *user = (const gchar *)l->data; |
| 743 quiet = GPOINTER_TO_INT(purple_signal_emit_return_1(handle, |
721 quiet = GPOINTER_TO_INT(purple_signal_emit_return_1(handle, |
| 782 |
760 |
| 783 purple_signal_emit(handle, "chat-user-left", conv, user, reason); |
761 purple_signal_emit(handle, "chat-user-left", conv, user, reason); |
| 784 |
762 |
| 785 g_signal_emit(chat, signals[SIG_USER_LEFT], 0, user, reason); |
763 g_signal_emit(chat, signals[SIG_USER_LEFT], 0, user, reason); |
| 786 } |
764 } |
| 787 |
|
| 788 if(ops != NULL && ops->chat_remove_users != NULL) { |
|
| 789 ops->chat_remove_users(chat, users); |
|
| 790 } |
|
| 791 } |
765 } |
| 792 |
766 |
| 793 void |
767 void |
| 794 purple_chat_conversation_clear_users(PurpleChatConversation *chat) { |
768 purple_chat_conversation_clear_users(PurpleChatConversation *chat) { |
| 795 PurpleChatConversationPrivate *priv = NULL; |
769 PurpleChatConversationPrivate *priv = NULL; |
| 796 PurpleConversationUiOps *ops = NULL; |
|
| 797 GList *names = NULL; |
770 GList *names = NULL; |
| 798 |
771 |
| 799 g_return_if_fail(PURPLE_IS_CHAT_CONVERSATION(chat)); |
772 g_return_if_fail(PURPLE_IS_CHAT_CONVERSATION(chat)); |
| 800 |
773 |
| 801 priv = purple_chat_conversation_get_instance_private(chat); |
774 priv = purple_chat_conversation_get_instance_private(chat); |
| 802 ops = purple_conversation_get_ui_ops(PURPLE_CONVERSATION(chat)); |
|
| 803 names = g_hash_table_get_keys(priv->users); |
775 names = g_hash_table_get_keys(priv->users); |
| 804 |
|
| 805 if(ops != NULL && ops->chat_remove_users != NULL) { |
|
| 806 ops->chat_remove_users(chat, names); |
|
| 807 } |
|
| 808 |
776 |
| 809 g_list_foreach(names, purple_chat_conversation_clear_users_helper, chat); |
777 g_list_foreach(names, purple_chat_conversation_clear_users_helper, chat); |
| 810 |
778 |
| 811 g_list_free(names); |
779 g_list_free(names); |
| 812 g_hash_table_remove_all(priv->users); |
780 g_hash_table_remove_all(priv->users); |