pidgin: 5a1afef5: Rearranging this section and adding a ca...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Mon Jul 6 00:25:35 EDT 2009


-----------------------------------------------------------------
Revision: 5a1afef54c3bd057cb0fce0e5beb314ab8508eb7
Ancestor: b44e65f12c2fce86cb96214a15233bc1850de4e4
Author: darkrain42 at pidgin.im
Date: 2009-07-06T03:00:41
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/5a1afef54c3bd057cb0fce0e5beb314ab8508eb7

Modified files:
        libpurple/protocols/jabber/presence.c

ChangeLog: 

Rearranging this section and adding a catch for stuff that can't happen

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/presence.c	d78466bdec8eafb1d6a72539f687017b418ad931
+++ libpurple/protocols/jabber/presence.c	2692a1019c97eb43492ced782c47e0afc38f701d
@@ -708,8 +708,43 @@ void jabber_presence_parse(JabberStream 
 			return;
 		}
 
+		if (type == NULL) {
+			/*
+			 * XEP-0045 mandates the presence to include a resource (which is
+			 * treated as the chat nick). Some non-compliant servers allow
+			 * joining without a nick.
+			 */
+			if (!jid->resource) {
+				jabber_id_free(jid);
+				g_free(avatar_hash);
+				g_free(nickname);
+				g_free(status);
+				return;
+			}
 
-		if (type && g_str_equal(type, "unavailable")) {
+			if(!chat->conv) {
+				char *room_jid = g_strdup_printf("%s@%s", jid->node, jid->domain);
+				chat->id = i++;
+				chat->muc = muc;
+				chat->conv = serv_got_joined_chat(js->gc, chat->id, room_jid);
+				purple_conv_chat_set_nick(PURPLE_CONV_CHAT(chat->conv), chat->handle);
+
+				jabber_chat_disco_traffic(chat);
+				g_free(room_jid);
+			}
+
+			jabber_buddy_track_resource(jb, jid->resource, priority, state,
+					status);
+
+			jabber_chat_track_handle(chat, jid->resource, real_jid, affiliation, role);
+
+			if(!jabber_chat_find_buddy(chat->conv, jid->resource))
+				purple_conv_chat_add_user(PURPLE_CONV_CHAT(chat->conv), jid->resource,
+						real_jid, flags, !delayed);
+			else
+				purple_conv_chat_user_set_flags(PURPLE_CONV_CHAT(chat->conv), jid->resource,
+						flags);
+		} else if (g_str_equal(type, "unavailable")) {
 			gboolean nick_change = FALSE;
 			gboolean kick = FALSE;
 			gboolean is_our_resource = FALSE; /* Is the presence about us? */
@@ -827,41 +862,15 @@ void jabber_presence_parse(JabberStream 
 				}
 			}
 		} else {
-			/*
-			 * XEP-0045 mandates the presence to include a resource (which is
-			 * treated as the chat nick). Some non-compliant servers allow
-			 * joining without a nick.
-			 */
-			if (!jid->resource) {
-				jabber_id_free(jid);
-				g_free(avatar_hash);
-				g_free(nickname);
-				g_free(status);
-				return;
-			}
+			/* A type that isn't available or unavailable */
+			purple_debug_error("jabber", "MUC presence with bad type: %s\n",
+			                   type);
 
-			if(!chat->conv) {
-				char *room_jid = g_strdup_printf("%s@%s", jid->node, jid->domain);
-				chat->id = i++;
-				chat->muc = muc;
-				chat->conv = serv_got_joined_chat(js->gc, chat->id, room_jid);
-				purple_conv_chat_set_nick(PURPLE_CONV_CHAT(chat->conv), chat->handle);
-
-				jabber_chat_disco_traffic(chat);
-				g_free(room_jid);
-			}
-
-			jabber_buddy_track_resource(jb, jid->resource, priority, state,
-					status);
-
-			jabber_chat_track_handle(chat, jid->resource, real_jid, affiliation, role);
-
-			if(!jabber_chat_find_buddy(chat->conv, jid->resource))
-				purple_conv_chat_add_user(PURPLE_CONV_CHAT(chat->conv), jid->resource,
-						real_jid, flags, !delayed);
-			else
-				purple_conv_chat_user_set_flags(PURPLE_CONV_CHAT(chat->conv), jid->resource,
-						flags);
+			jabber_id_free(jid);
+			g_free(avatar_hash);
+			g_free(status);
+			g_free(nickname);
+			g_return_if_reached();
 		}
 	} else {
 		buddy_name = g_strdup_printf("%s%s%s", jid->node ? jid->node : "",


More information about the Commits mailing list