comparison mcabber/src/jabglue.c @ 430:d03663d2e7d9

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.
author Mikael Berthe <mikael@lilotux.net>
date Sun, 11 Sep 2005 22:01:57 +0200
parents 2706ef3e25a7
children 802da817a684
comparison
equal deleted inserted replaced
429:0bb3d37579aa 430:d03663d2e7d9
619 } 619 }
620 620
621 return desc; 621 return desc;
622 } 622 }
623 623
624 // display_server_error(x)
625 // Display the error to the user
626 // x: error tag xmlnode pointer
624 void display_server_error(xmlnode x) 627 void display_server_error(xmlnode x)
625 { 628 {
629 const char *desc = NULL;
630 int code = 0;
626 char *s; 631 char *s;
627 const char *desc; 632 const char *p;
628 int code; 633
629 634 /* RFC3920:
635 * The <error/> element:
636 * o MUST contain a child element corresponding to one of the defined
637 * stanza error conditions specified below; this element MUST be
638 * qualified by the 'urn:ietf:params:xml:ns:xmpp-stanzas' namespace.
639 */
640 p = xmlnode_get_name(xmlnode_get_firstchild(x));
641 if (p)
642 scr_LogPrint(LPRINT_LOGNORM, "Received error packet [%s]", p);
643
644 // For backward compatibility
630 if ((s = xmlnode_get_attrib(x, "code")) != NULL) { 645 if ((s = xmlnode_get_attrib(x, "code")) != NULL) {
631 code = atoi(s); 646 code = atoi(s);
632
633 // Default message 647 // Default message
634 desc = defaulterrormsg(atoi(s)); 648 desc = defaulterrormsg(code);
635 649 }
636 // Error tag data is better, if available 650
637 s = xmlnode_get_data(x); 651 // Error tag data is better, if available
638 if (s && *s) desc = s; 652 s = xmlnode_get_data(x);
639 653 if (s && *s) desc = s;
640 // And sometimes there is a text message 654
641 s = xmlnode_get_tag_data(x, "text"); 655 // And sometimes there is a text message
642 if (s && *s) desc = s; // FIXME utf8?? 656 s = xmlnode_get_tag_data(x, "text");
643 657 if (s && *s) desc = s; // FIXME utf8??
644 scr_LogPrint(LPRINT_LOGNORM, "Error code from server: %d %s", code, desc); 658
645 } 659 scr_LogPrint(LPRINT_LOGNORM, "Error code from server: %d %s", code, desc);
646 } 660 }
647 661
648 void statehandler(jconn conn, int state) 662 void statehandler(jconn conn, int state)
649 { 663 {
650 static int previous_state = -1; 664 static int previous_state = -1;