comparison libpurple/protocols/jabber/presence.c @ 27446:735e58197140

Rearranging this section and adding a catch for stuff that can't happen
author Paul Aurich <paul@darkrain42.org>
date Mon, 06 Jul 2009 03:00:41 +0000
parents eff7db4db632
children 712289e2aa6d
comparison
equal deleted inserted replaced
27445:eff7db4db632 27446:735e58197140
706 g_free(avatar_hash); 706 g_free(avatar_hash);
707 g_free(nickname); 707 g_free(nickname);
708 return; 708 return;
709 } 709 }
710 710
711 711 if (type == NULL) {
712 if (type && g_str_equal(type, "unavailable")) { 712 /*
713 * XEP-0045 mandates the presence to include a resource (which is
714 * treated as the chat nick). Some non-compliant servers allow
715 * joining without a nick.
716 */
717 if (!jid->resource) {
718 jabber_id_free(jid);
719 g_free(avatar_hash);
720 g_free(nickname);
721 g_free(status);
722 return;
723 }
724
725 if(!chat->conv) {
726 char *room_jid = g_strdup_printf("%s@%s", jid->node, jid->domain);
727 chat->id = i++;
728 chat->muc = muc;
729 chat->conv = serv_got_joined_chat(js->gc, chat->id, room_jid);
730 purple_conv_chat_set_nick(PURPLE_CONV_CHAT(chat->conv), chat->handle);
731
732 jabber_chat_disco_traffic(chat);
733 g_free(room_jid);
734 }
735
736 jabber_buddy_track_resource(jb, jid->resource, priority, state,
737 status);
738
739 jabber_chat_track_handle(chat, jid->resource, real_jid, affiliation, role);
740
741 if(!jabber_chat_find_buddy(chat->conv, jid->resource))
742 purple_conv_chat_add_user(PURPLE_CONV_CHAT(chat->conv), jid->resource,
743 real_jid, flags, !delayed);
744 else
745 purple_conv_chat_user_set_flags(PURPLE_CONV_CHAT(chat->conv), jid->resource,
746 flags);
747 } else if (g_str_equal(type, "unavailable")) {
713 gboolean nick_change = FALSE; 748 gboolean nick_change = FALSE;
714 gboolean kick = FALSE; 749 gboolean kick = FALSE;
715 gboolean is_our_resource = FALSE; /* Is the presence about us? */ 750 gboolean is_our_resource = FALSE; /* Is the presence about us? */
716 751
717 /* If the chat nick is invalid, we haven't yet joined, or we've 752 /* If the chat nick is invalid, we haven't yet joined, or we've
825 status); 860 status);
826 jabber_chat_remove_handle(chat, jid->resource); 861 jabber_chat_remove_handle(chat, jid->resource);
827 } 862 }
828 } 863 }
829 } else { 864 } else {
830 /* 865 /* A type that isn't available or unavailable */
831 * XEP-0045 mandates the presence to include a resource (which is 866 purple_debug_error("jabber", "MUC presence with bad type: %s\n",
832 * treated as the chat nick). Some non-compliant servers allow 867 type);
833 * joining without a nick. 868
834 */ 869 jabber_id_free(jid);
835 if (!jid->resource) { 870 g_free(avatar_hash);
836 jabber_id_free(jid); 871 g_free(status);
837 g_free(avatar_hash); 872 g_free(nickname);
838 g_free(nickname); 873 g_return_if_reached();
839 g_free(status);
840 return;
841 }
842
843 if(!chat->conv) {
844 char *room_jid = g_strdup_printf("%s@%s", jid->node, jid->domain);
845 chat->id = i++;
846 chat->muc = muc;
847 chat->conv = serv_got_joined_chat(js->gc, chat->id, room_jid);
848 purple_conv_chat_set_nick(PURPLE_CONV_CHAT(chat->conv), chat->handle);
849
850 jabber_chat_disco_traffic(chat);
851 g_free(room_jid);
852 }
853
854 jabber_buddy_track_resource(jb, jid->resource, priority, state,
855 status);
856
857 jabber_chat_track_handle(chat, jid->resource, real_jid, affiliation, role);
858
859 if(!jabber_chat_find_buddy(chat->conv, jid->resource))
860 purple_conv_chat_add_user(PURPLE_CONV_CHAT(chat->conv), jid->resource,
861 real_jid, flags, !delayed);
862 else
863 purple_conv_chat_user_set_flags(PURPLE_CONV_CHAT(chat->conv), jid->resource,
864 flags);
865 } 874 }
866 } else { 875 } else {
867 buddy_name = g_strdup_printf("%s%s%s", jid->node ? jid->node : "", 876 buddy_name = g_strdup_printf("%s%s%s", jid->node ? jid->node : "",
868 jid->node ? "@" : "", jid->domain); 877 jid->node ? "@" : "", jid->domain);
869 if((b = purple_find_buddy(js->gc->account, buddy_name)) == NULL) { 878 if((b = purple_find_buddy(js->gc->account, buddy_name)) == NULL) {