# HG changeset patch # User Mikael Berthe # Date 1126468917 -7200 # Node ID d03663d2e7d99e04a377e359fcfb699e550464a1 # Parent 0bb3d37579aaab4da6ca4ae6f505f9555949ed83 Display error messages as specified in RFC3920 (9.3) If possible, we display the child element corresponding to the stanza error conditions defined in RFC3920. Error code and error text will be displayed if available. diff -r 0bb3d37579aa -r d03663d2e7d9 mcabber/src/jabglue.c --- a/mcabber/src/jabglue.c Sat Sep 10 14:53:01 2005 +0200 +++ b/mcabber/src/jabglue.c Sun Sep 11 22:01:57 2005 +0200 @@ -621,28 +621,42 @@ return desc; } +// display_server_error(x) +// Display the error to the user +// x: error tag xmlnode pointer void display_server_error(xmlnode x) { + const char *desc = NULL; + int code = 0; char *s; - const char *desc; - int code; + const char *p; + /* RFC3920: + * The element: + * o MUST contain a child element corresponding to one of the defined + * stanza error conditions specified below; this element MUST be + * qualified by the 'urn:ietf:params:xml:ns:xmpp-stanzas' namespace. + */ + p = xmlnode_get_name(xmlnode_get_firstchild(x)); + if (p) + scr_LogPrint(LPRINT_LOGNORM, "Received error packet [%s]", p); + + // For backward compatibility if ((s = xmlnode_get_attrib(x, "code")) != NULL) { code = atoi(s); - // Default message - desc = defaulterrormsg(atoi(s)); + desc = defaulterrormsg(code); + } - // Error tag data is better, if available - s = xmlnode_get_data(x); - if (s && *s) desc = s; + // Error tag data is better, if available + s = xmlnode_get_data(x); + if (s && *s) desc = s; - // And sometimes there is a text message - s = xmlnode_get_tag_data(x, "text"); - if (s && *s) desc = s; // FIXME utf8?? + // And sometimes there is a text message + s = xmlnode_get_tag_data(x, "text"); + if (s && *s) desc = s; // FIXME utf8?? - scr_LogPrint(LPRINT_LOGNORM, "Error code from server: %d %s", code, desc); - } + scr_LogPrint(LPRINT_LOGNORM, "Error code from server: %d %s", code, desc); } void statehandler(jconn conn, int state)