changeset 7644:4168b8881746

[gaim-migrate @ 8287] some error goodness committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Thu, 27 Nov 2003 07:04:26 +0000
parents 834570cb8d86
children 28100686bde9
files src/protocols/jabber/auth.c src/protocols/jabber/presence.c
diffstat 2 files changed, 30 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/jabber/auth.c	Wed Nov 26 17:59:04 2003 +0000
+++ b/src/protocols/jabber/auth.c	Thu Nov 27 07:04:26 2003 +0000
@@ -75,12 +75,17 @@
 
 	auth = xmlnode_new("auth");
 	xmlnode_set_attrib(auth, "xmlns", "urn:ietf:params:xml:ns:xmpp-sasl");
-	if(digest_md5) {
+	if(0 && digest_md5) {
 		xmlnode_set_attrib(auth, "mechanism", "DIGEST-MD5");
 		js->auth_type = JABBER_AUTH_DIGEST_MD5;
 		/*
 	} else if(plain) {
 		xmlnode_set_attrib(auth, "mechanism", "PLAIN");
+		xmlnode_insert_data(auth, "\0", 1);
+		xmlnode_insert_data(auth, js->user->node, -1);
+		xmlnode_insert_data(auth, "\0", 1);
+		xmlnode_insert_data(auth, gaim_account_get_password(js->gc->account),
+				-1);
 		js->auth_type = JABBER_AUTH_PLAIN;
 		*/
 	} else {
@@ -135,7 +140,20 @@
 	if(!type) {
 		return;
 	} else if(!strcmp(type, "error")) {
-		/* XXX: handle error */
+		/* XXX: still need to handle XMPP-style errors */
+		xmlnode *error;
+		char *buf, *err_txt = NULL;
+		const char *code = NULL;
+		if((error = xmlnode_get_child(packet, "error"))) {
+			code = xmlnode_get_attrib(error, "code");
+			err_txt = xmlnode_get_data(error);
+		}
+		buf = g_strdup_printf("%s%s%s", code ? code : "", code ? ": " : "",
+				err_txt ? err_txt : _("Unknown Error"));
+		gaim_connection_error(js->gc, buf);
+		if(err_txt)
+			g_free(err_txt);
+		g_free(buf);
 	} else if(!strcmp(type, "result")) {
 		query = xmlnode_get_child(packet, "query");
 		if(js->stream_id && xmlnode_get_child(query, "digest")) {
--- a/src/protocols/jabber/presence.c	Wed Nov 26 17:59:04 2003 +0000
+++ b/src/protocols/jabber/presence.c	Thu Nov 27 07:04:26 2003 +0000
@@ -163,17 +163,20 @@
 	}
 
 	if(type && !strcasecmp(type, "error")) {
+		const char *code = NULL;
+		char *err_txt = NULL;
+
 		state = JABBER_STATE_ERROR;
 		if((y = xmlnode_get_child(packet, "error")) != NULL) {
 			/* XXX: need to handle new XMPP-style errors */
-			char *txt = xmlnode_get_data(y);
-			jb->error_msg = g_strdup_printf(_("%s (Code %s)"),
-					txt ? txt : "Error", xmlnode_get_attrib(y, "code"));
-			if(txt)
-				g_free(txt);
-		} else {
-			jb->error_msg = g_strdup(_("Unknown Error in presence"));
+			code = xmlnode_get_attrib(y, "code");
+			err_txt = xmlnode_get_data(y);
 		}
+		jb->error_msg = g_strdup_printf("%s%s%s", code ? code : "",
+				code ? ": " : "", err_txt ? err_txt :
+				_("Unknown Error in presence"));
+		if(err_txt)
+			g_free(err_txt);
 	} else if(type && !strcasecmp(type, "subscribe")) {
 		struct _jabber_add_permit *jap = g_new0(struct _jabber_add_permit, 1);
 		char *msg = g_strdup_printf(_("The user %s wants to add you to their buddy list."), from);