pidgin: 8c322571: oscar: Display more detailed error messa...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Tue Nov 3 02:50:37 EST 2009


-----------------------------------------------------------------
Revision: 8c322571bfb4f2d00c9126e59746445f877be296
Ancestor: 5a26df137b0f0dbaaea3eccd318e7f028cae5a87
Author: aman at tmm1.net
Date: 2009-11-03T07:46:01
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/8c322571bfb4f2d00c9126e59746445f877be296

Modified files:
        ChangeLog libpurple/protocols/oscar/family_icbm.c
        libpurple/protocols/oscar/oscar.c

ChangeLog: 

oscar: Display more detailed error messages when an outgoing message is bounced.

Patch from Aman "tmm1" Gupta.

These errors are taken from http://dev.aol.com/aim/oscar/#ICBM__ERROR_SUBCODE,
but the SMS ones are confusing (I [darkrain] am not sure who is required to
accept the the legal text, for example).

-------------- next part --------------
============================================================
--- ChangeLog	2d850dc74aad6a0b9a12a591e8dc992ac042e31f
+++ ChangeLog	096e2a88dbc05c60df9c9b6e36f54a4074f8b900
@@ -13,6 +13,7 @@ version 2.6.4 (??/??/20??):
 
 	AIM and ICQ:
 	* Better rate limit calculations and other improvements.  (Aman Gupta)
+	* More detailed error messages when messages fail to send.  (Aman Gupta)
 
 	MSN:
 	* Don't forget display names for buddies.
============================================================
--- libpurple/protocols/oscar/family_icbm.c	ded57ce4424f17f04656b6539fe824e5b2167d17
+++ libpurple/protocols/oscar/family_icbm.c	d202b35b83353a3e4b4f72fb372e44fe6b02a015
@@ -151,6 +151,55 @@ guint16 aim_im_fingerprint(const guint8 
 	return AIM_CLIENTTYPE_UNKNOWN;
 }
 
+/*
+ * Subtype 0x0001 - Error
+ */
+static int
+error(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
+{
+	int ret = 0;
+	aim_rxcallback_t userfunc;
+	aim_snac_t *snac2;
+	guint16 reason, errcode = 0;
+	char *bn;
+	GSList *tlvlist;
+
+	if (!(snac2 = aim_remsnac(od, snac->id))) {
+		purple_debug_misc("oscar", "icbm error: received response from unknown request!\n");
+		return 0;
+	}
+
+	if (snac2->family != SNAC_FAMILY_ICBM) {
+		purple_debug_misc("oscar", "icbm error: received response from invalid request! %d\n", snac2->family);
+		g_free(snac2->data);
+		g_free(snac2);
+		return 0;
+	}
+
+	if (!(bn = snac2->data)) {
+		purple_debug_misc("oscar", "icbm error: received response from request without a buddy name!\n");
+		g_free(snac2);
+		return 0;
+	}
+
+	reason = byte_stream_get16(bs);
+
+	tlvlist = aim_tlvlist_read(bs);
+	if (aim_tlv_gettlv(tlvlist, 0x0008, 1))
+		errcode = aim_tlv_get16(tlvlist, 0x0008, 1);
+	aim_tlvlist_free(tlvlist);
+
+	/* Notify the user that the message wasn't delivered */
+	if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
+		ret = userfunc(od, conn, frame, reason, errcode, bn);
+
+	if (snac2)
+		g_free(snac2->data);
+	g_free(snac2);
+
+	return ret;
+}
+
 /**
  * Subtype 0x0002 - Set ICBM parameters.
  *
@@ -2789,7 +2838,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 == 0x0005)
+	if (snac->subtype == 0x0001)
+		return error(od, conn, mod, frame, snac, bs);
+	else if (snac->subtype == 0x0005)
 		return aim_im_paraminfo(od, conn, mod, frame, snac, bs);
 	else if (snac->subtype == 0x0006)
 		return outgoingim(od, conn, mod, frame, snac, bs);
============================================================
--- libpurple/protocols/oscar/oscar.c	eb9598cfa477d506fbfad9a1b96eb6ee21c1d02e
+++ libpurple/protocols/oscar/oscar.c	8aa8048150010726641d66d77ed5cb348df8917a
@@ -144,6 +144,26 @@ static const int msgerrreasonlen = G_N_E
 };
 static const int msgerrreasonlen = G_N_ELEMENTS(msgerrreason);
 
+static const char * const errcodereason[] = {
+	N_("Invalid error"),
+	N_("Not logged in"),
+	N_("Cannot receive IM due to parental controls"),
+	N_("Cannot send SMS without accepting terms"),
+	N_("Cannot send SMS"), /* SMS_WITHOUT_DISCLAIMER is weird */
+	N_("Cannot send SMS to this country"),
+	N_("Unknown error"), /* Undocumented */
+	N_("Unknown error"), /* Undocumented */
+	N_("Cannot send SMS to unknown country"),
+	N_("Bot accounts cannot initiate IMs"),
+	N_("Bot account cannot IM this user"),
+	N_("Bot account reached IM limit"),
+	N_("Bot account reached daily IM limit"),
+	N_("Bot account reached monthly IM limit"),
+	N_("Unable to receive offline messages"),
+	N_("Offline message store full")
+};
+static const int errcodereasonlen = G_N_ELEMENTS(errcodereason);
+
 /* All the libfaim->purple callback functions */
 
 /* Only used when connecting with the old-style BUCP login */
@@ -3217,17 +3237,18 @@ static int purple_parse_msgerr(OscarData
 	PurpleXfer *xfer;
 #endif
 	va_list ap;
-	guint16 reason;
-	char *data, *buf;
+	guint16 reason, errcode;
+	char *data, *reason_str, *buf, *error;
 
 	va_start(ap, fr);
 	reason = (guint16)va_arg(ap, unsigned int);
+	errcode = (guint16)va_arg(ap, unsigned int);
 	data = va_arg(ap, char *);
 	va_end(ap);
 
 	purple_debug_error("oscar",
-			   "Message error with data %s and reason %hu\n",
-				(data != NULL ? data : ""), reason);
+			   "Message error with data %s and reason %hu and errcode %hu\n",
+				(data != NULL ? data : ""), reason, errcode);
 
 	if ((data == NULL) || (*data == '\0'))
 		/* We can't do anything if data is empty */
@@ -3242,14 +3263,21 @@ static int purple_parse_msgerr(OscarData
 #endif
 
 	/* Data is assumed to be the destination bn */
-	buf = g_strdup_printf(_("Unable to send message: %s"), (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason."));
+	reason_str = g_strdup((reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason"));
+	if (errcode != 0 && errcode < errcodereasonlen) {
+		error = g_strdup_printf("%s: %s", reason_str, _(errcodereason[errcode]));
+		g_free(reason_str);
+	} else
+		error = reason_str;
+
+	buf = g_strdup_printf(_("Unable to send message: %s"), error);
 	if (!purple_conv_present_error(data, purple_connection_get_account(gc), buf)) {
 		g_free(buf);
 		buf = g_strdup_printf(_("Unable to send message to %s:"), data ? data : "(unknown)");
-		purple_notify_error(od->gc, NULL, buf,
-				  (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason."));
+		purple_notify_error(od->gc, NULL, buf, error);
 	}
 	g_free(buf);
+	g_free(error);
 
 	return 1;
 }


More information about the Commits mailing list