im.pidgin.pidgin: 4c2f13fa0f00a747c4c6262594abbd812155225c

markdoliner at pidgin.im markdoliner at pidgin.im
Sun Dec 2 15:10:42 EST 2007


-----------------------------------------------------------------
Revision: 4c2f13fa0f00a747c4c6262594abbd812155225c
Ancestor: f54573b65af85e75346c81a3b92d66dc8956d6f2
Author: markdoliner at pidgin.im
Date: 2007-12-02T20:03:34
Branch: im.pidgin.pidgin

Modified files:
        libpurple/protocols/oscar/family_chatnav.c

ChangeLog: 

Handle invalid room names and invalid exchanges better, by showing a
message to the user if the room couldn't be created.

-------------- next part --------------
============================================================
--- libpurple/protocols/oscar/family_chatnav.c	46c8b38077948de1b82f19e8219550ae73e2d67a
+++ libpurple/protocols/oscar/family_chatnav.c	1570a3a72f707fc111b7aac97e4635b5d46ddef1
@@ -29,6 +29,49 @@
 
 #include "oscar.h"
 
+static int
+error(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
+{
+	int ret = 0;
+	aim_snac_t *snac2;
+	guint16 error, chatnav_error;
+	GSList *tlvlist;
+
+	if (!(snac2 = aim_remsnac(od, snac->id))) {
+		purple_debug_warning("oscar", "chatnav error: received response to unknown request (%08lx)\n", snac->id);
+		return 0;
+	}
+
+	if (snac2->family != 0x000d) {
+		purple_debug_warning("oscar", "chatnav error: received response that maps to corrupt request (fam=%04x)\n", snac2->family);
+		return 0;
+	}
+
+	/*
+	 * We now know what the original SNAC subtype was.
+	 */
+	if (snac2->type == 0x0008) /* create room */
+	{
+		error = byte_stream_get16(bs);
+		tlvlist = aim_tlvlist_read(bs);
+		chatnav_error = aim_tlv_get16(tlvlist, 0x0008, 1);
+
+		purple_debug_warning("oscar",
+				"Could not join room, error=0x%04hx, chatnav_error=0x%04hx\n",
+				error, chatnav_error);
+		purple_notify_error(od->gc, NULL, _("Could not join chat room"),
+				chatnav_error == 0x0033 ? _("Invalid chat room name") : _("Unknown error"));
+
+		ret = 1;
+	}
+
+	if (snac2)
+		g_free(snac2->data);
+	g_free(snac2);
+
+	return ret;
+}
+
 /*
  * Subtype 0x0002
  *
@@ -451,7 +494,9 @@ snachandler(OscarData *od, FlapConnectio
 static int
 snachandler(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
 {
-	if (snac->subtype == 0x0009)
+	if (snac->subtype == 0x0001)
+		return error(od, conn, mod, frame, snac, bs);
+	else if (snac->subtype == 0x0009)
 		return parseinfo(od, conn, mod, frame, snac, bs);
 
 	return 0;


More information about the Commits mailing list