comparison libpurple/protocols/jabber/message.c @ 25237:401f548e3544

propagate from branch 'im.pidgin.pidgin' (head df6eba32e5b6b34d7483cbfb7e9f2e4c836ac35f) to branch 'org.darkrain42.pidgin.buddy-add' (head 6831808999a270f8c1a128c7430a73d3dc0bfae2)
author Paul Aurich <paul@darkrain42.org>
date Sun, 21 Dec 2008 18:32:37 +0000
parents bba38f03085d
children 689cfb82242e 9b1aea1c8df2
comparison
equal deleted inserted replaced
25172:125cac3e24ee 25237:401f548e3544
569 jm->to = g_strdup(xmlnode_get_attrib(packet, "to")); 569 jm->to = g_strdup(xmlnode_get_attrib(packet, "to"));
570 jm->id = g_strdup(xmlnode_get_attrib(packet, "id")); 570 jm->id = g_strdup(xmlnode_get_attrib(packet, "id"));
571 571
572 for(child = packet->child; child; child = child->next) { 572 for(child = packet->child; child; child = child->next) {
573 const char *xmlns = xmlnode_get_namespace(child); 573 const char *xmlns = xmlnode_get_namespace(child);
574 if(!xmlns)
575 xmlns = "";
576 if(child->type != XMLNODE_TYPE_TAG) 574 if(child->type != XMLNODE_TYPE_TAG)
577 continue; 575 continue;
578 576
579 if(!strcmp(child->name, "subject") && !strcmp(xmlns,"jabber:client")) { 577 if(!strcmp(child->name, "error")) {
578 const char *code = xmlnode_get_attrib(child, "code");
579 char *code_txt = NULL;
580 char *text = xmlnode_get_data(child);
581 if (!text) {
582 xmlnode *enclosed_text_node;
583
584 if ((enclosed_text_node = xmlnode_get_child(child, "text")))
585 text = xmlnode_get_data(enclosed_text_node);
586 }
587
588 if(code)
589 code_txt = g_strdup_printf(_("(Code %s)"), code);
590
591 if(!jm->error)
592 jm->error = g_strdup_printf("%s%s%s",
593 text ? text : "",
594 text && code_txt ? " " : "",
595 code_txt ? code_txt : "");
596
597 g_free(code_txt);
598 g_free(text);
599 } else if (xmlns == NULL) {
600 /* QuLogic: Not certain this is correct, but it would have happened
601 with the previous code. */
602 if(!strcmp(child->name, "x"))
603 jm->etc = g_list_append(jm->etc, child);
604 /* The following tests expect xmlns != NULL */
605 continue;
606 } else if(!strcmp(child->name, "subject") && !strcmp(xmlns,"jabber:client")) {
580 if(!jm->subject) 607 if(!jm->subject)
581 jm->subject = xmlnode_get_data(child); 608 jm->subject = xmlnode_get_data(child);
582 } else if(!strcmp(child->name, "thread") && !strcmp(xmlns,"jabber:client")) { 609 } else if(!strcmp(child->name, "thread") && !strcmp(xmlns,"jabber:client")) {
583 if(!jm->thread_id) 610 if(!jm->thread_id)
584 jm->thread_id = xmlnode_get_data(child); 611 jm->thread_id = xmlnode_get_data(child);
704 jm->type = JABBER_MESSAGE_EVENT; 731 jm->type = JABBER_MESSAGE_EVENT;
705 for(items = xmlnode_get_child(child,"items"); items; items = items->next) 732 for(items = xmlnode_get_child(child,"items"); items; items = items->next)
706 jm->eventitems = g_list_append(jm->eventitems, items); 733 jm->eventitems = g_list_append(jm->eventitems, items);
707 } else if(!strcmp(child->name, "attention") && !strcmp(xmlns,"http://www.xmpp.org/extensions/xep-0224.html#ns")) { 734 } else if(!strcmp(child->name, "attention") && !strcmp(xmlns,"http://www.xmpp.org/extensions/xep-0224.html#ns")) {
708 jm->hasBuzz = TRUE; 735 jm->hasBuzz = TRUE;
709 } else if(!strcmp(child->name, "error")) { 736 } else if(!strcmp(child->name, "delay") && !strcmp(xmlns,"urn:xmpp:delay")) {
710 const char *code = xmlnode_get_attrib(child, "code");
711 char *code_txt = NULL;
712 char *text = xmlnode_get_data(child);
713 if (!text) {
714 xmlnode *enclosed_text_node;
715
716 if ((enclosed_text_node = xmlnode_get_child(child, "text")))
717 text = xmlnode_get_data(enclosed_text_node);
718 }
719
720 if(code)
721 code_txt = g_strdup_printf(_("(Code %s)"), code);
722
723 if(!jm->error)
724 jm->error = g_strdup_printf("%s%s%s",
725 text ? text : "",
726 text && code_txt ? " " : "",
727 code_txt ? code_txt : "");
728
729 g_free(code_txt);
730 g_free(text);
731 } else if(!strcmp(child->name, "delay") && xmlns && !strcmp(xmlns,"urn:xmpp:delay")) {
732 const char *timestamp = xmlnode_get_attrib(child, "stamp"); 737 const char *timestamp = xmlnode_get_attrib(child, "stamp");
733 jm->delayed = TRUE; 738 jm->delayed = TRUE;
734 if(timestamp) 739 if(timestamp)
735 jm->sent = purple_str_to_time(timestamp, TRUE, NULL, NULL, NULL); 740 jm->sent = purple_str_to_time(timestamp, TRUE, NULL, NULL, NULL);
736 } else if(!strcmp(child->name, "x")) { 741 } else if(!strcmp(child->name, "x")) {
737 if(xmlns && !strcmp(xmlns, "jabber:x:event")) { 742 if(!strcmp(xmlns, "jabber:x:event")) {
738 if(xmlnode_get_child(child, "composing")) { 743 if(xmlnode_get_child(child, "composing")) {
739 if(jm->chat_state == JM_STATE_ACTIVE) 744 if(jm->chat_state == JM_STATE_ACTIVE)
740 jm->chat_state = JM_STATE_COMPOSING; 745 jm->chat_state = JM_STATE_COMPOSING;
741 jm->typing_style |= JM_TS_JEP_0022; 746 jm->typing_style |= JM_TS_JEP_0022;
742 } 747 }
743 } else if(xmlns && !strcmp(xmlns, "jabber:x:delay")) { 748 } else if(!strcmp(xmlns, "jabber:x:delay")) {
744 const char *timestamp = xmlnode_get_attrib(child, "stamp"); 749 const char *timestamp = xmlnode_get_attrib(child, "stamp");
745 jm->delayed = TRUE; 750 jm->delayed = TRUE;
746 if(timestamp) 751 if(timestamp)
747 jm->sent = purple_str_to_time(timestamp, TRUE, NULL, NULL, NULL); 752 jm->sent = purple_str_to_time(timestamp, TRUE, NULL, NULL, NULL);
748 } else if(xmlns && !strcmp(xmlns, "jabber:x:conference") && 753 } else if(!strcmp(xmlns, "jabber:x:conference") &&
749 jm->type != JABBER_MESSAGE_GROUPCHAT_INVITE && 754 jm->type != JABBER_MESSAGE_GROUPCHAT_INVITE &&
750 jm->type != JABBER_MESSAGE_ERROR) { 755 jm->type != JABBER_MESSAGE_ERROR) {
751 const char *jid = xmlnode_get_attrib(child, "jid"); 756 const char *jid = xmlnode_get_attrib(child, "jid");
752 if(jid) { 757 if(jid) {
753 jm->type = JABBER_MESSAGE_GROUPCHAT_INVITE; 758 jm->type = JABBER_MESSAGE_GROUPCHAT_INVITE;
754 g_free(jm->to); 759 g_free(jm->to);
755 jm->to = g_strdup(jid); 760 jm->to = g_strdup(jid);
756 } 761 }
757 } else if(xmlns && !strcmp(xmlns, 762 } else if(!strcmp(xmlns, "http://jabber.org/protocol/muc#user") &&
758 "http://jabber.org/protocol/muc#user") &&
759 jm->type != JABBER_MESSAGE_ERROR) { 763 jm->type != JABBER_MESSAGE_ERROR) {
760 xmlnode *invite = xmlnode_get_child(child, "invite"); 764 xmlnode *invite = xmlnode_get_child(child, "invite");
761 if(invite) { 765 if(invite) {
762 xmlnode *reason, *password; 766 xmlnode *reason, *password;
763 const char *jid = xmlnode_get_attrib(invite, "from"); 767 const char *jid = xmlnode_get_attrib(invite, "from");