comparison libpurple/protocols/jabber/message.c @ 27590:a08e84032814

merge of '2348ff22f0ff3453774b8b25b36238465580c609' and 'e76f11543c2a4aa05bdf584f087cbe3439029661'
author Paul Aurich <paul@darkrain42.org>
date Sun, 12 Jul 2009 05:43:38 +0000
parents 048bcf41deef ed284238509b
children f44eda839ea4
comparison
equal deleted inserted replaced
27104:048bcf41deef 27590:a08e84032814
85 } else { 85 } else {
86 from = g_strdup(jid->domain); 86 from = g_strdup(jid->domain);
87 } 87 }
88 88
89 if(!jm->xhtml && !jm->body) { 89 if(!jm->xhtml && !jm->body) {
90 if (jbr)
91 jbr->chat_states = JABBER_CHAT_STATES_SUPPORTED;
92
90 if(JM_STATE_COMPOSING == jm->chat_state) { 93 if(JM_STATE_COMPOSING == jm->chat_state) {
91 serv_got_typing(jm->js->gc, from, 0, PURPLE_TYPING); 94 serv_got_typing(jm->js->gc, from, 0, PURPLE_TYPING);
92 } else if(JM_STATE_PAUSED == jm->chat_state) { 95 } else if(JM_STATE_PAUSED == jm->chat_state) {
93 serv_got_typing(jm->js->gc, from, 0, PURPLE_TYPED); 96 serv_got_typing(jm->js->gc, from, 0, PURPLE_TYPED);
94 } else if(JM_STATE_GONE == jm->chat_state) { 97 } else if(JM_STATE_GONE == jm->chat_state) {
620 } else if(!strcmp(child->name, "html") && !strcmp(xmlns,"http://jabber.org/protocol/xhtml-im")) { 623 } else if(!strcmp(child->name, "html") && !strcmp(xmlns,"http://jabber.org/protocol/xhtml-im")) {
621 if(!jm->xhtml && xmlnode_get_child(child, "body")) { 624 if(!jm->xhtml && xmlnode_get_child(child, "body")) {
622 char *c; 625 char *c;
623 626
624 const PurpleConnection *gc = js->gc; 627 const PurpleConnection *gc = js->gc;
625 const gchar *who = xmlnode_get_attrib(packet, "from");
626 PurpleAccount *account = purple_connection_get_account(gc); 628 PurpleAccount *account = purple_connection_get_account(gc);
627 PurpleConversation *conv = NULL; 629 PurpleConversation *conv = NULL;
628 GList *smiley_refs = NULL; 630 GList *smiley_refs = NULL;
629 gchar *reformatted_xhtml; 631 gchar *reformatted_xhtml;
630 632
648 jabber_id_free(jid); 650 jabber_id_free(jid);
649 } else if (jm->type == JABBER_MESSAGE_NORMAL || 651 } else if (jm->type == JABBER_MESSAGE_NORMAL ||
650 jm->type == JABBER_MESSAGE_CHAT) { 652 jm->type == JABBER_MESSAGE_CHAT) {
651 conv = 653 conv =
652 purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, 654 purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY,
653 who, account); 655 from, account);
654 if (!conv) { 656 if (!conv) {
655 /* we need to create the conversation here */ 657 /* we need to create the conversation here */
656 conv = 658 conv =
657 purple_conversation_new(PURPLE_CONV_TYPE_IM, 659 purple_conversation_new(PURPLE_CONV_TYPE_IM,
658 account, who); 660 account, from);
659 } 661 }
660 } 662 }
661 } 663 }
662 664
663 /* process any newly provided smileys */ 665 /* process any newly provided smileys */
698 purple_conv_custom_smiley_close(conv, alt); 700 purple_conv_custom_smiley_close(conv, alt);
699 } else { 701 } else {
700 /* we need to request the smiley (data) */ 702 /* we need to request the smiley (data) */
701 purple_debug_info("jabber", 703 purple_debug_info("jabber",
702 "data is unknown, need to request it\n"); 704 "data is unknown, need to request it\n");
703 jabber_message_send_data_request(js, conv, cid, who, 705 jabber_message_send_data_request(js, conv, cid, from,
704 alt); 706 alt);
705 } 707 }
706 } 708 }
707 g_free(ref->cid); 709 g_free(ref->cid);
708 g_free(ref->alt); 710 g_free(ref->alt);
1039 if(jm->thread_id) { 1041 if(jm->thread_id) {
1040 child = xmlnode_new_child(message, "thread"); 1042 child = xmlnode_new_child(message, "thread");
1041 xmlnode_insert_data(child, jm->thread_id, -1); 1043 xmlnode_insert_data(child, jm->thread_id, -1);
1042 } 1044 }
1043 1045
1044 if (jm->chat_state != JM_STATE_NONE) { 1046 child = NULL;
1045 child = NULL; 1047 switch(jm->chat_state)
1046 switch(jm->chat_state) 1048 {
1047 { 1049 case JM_STATE_ACTIVE:
1048 case JM_STATE_ACTIVE: 1050 child = xmlnode_new_child(message, "active");
1049 child = xmlnode_new_child(message, "active"); 1051 break;
1050 break; 1052 case JM_STATE_COMPOSING:
1051 case JM_STATE_COMPOSING: 1053 child = xmlnode_new_child(message, "composing");
1052 child = xmlnode_new_child(message, "composing"); 1054 break;
1053 break; 1055 case JM_STATE_PAUSED:
1054 case JM_STATE_PAUSED: 1056 child = xmlnode_new_child(message, "paused");
1055 child = xmlnode_new_child(message, "paused"); 1057 break;
1056 break; 1058 case JM_STATE_INACTIVE:
1057 case JM_STATE_INACTIVE: 1059 child = xmlnode_new_child(message, "inactive");
1058 child = xmlnode_new_child(message, "inactive"); 1060 break;
1059 break; 1061 case JM_STATE_GONE:
1060 case JM_STATE_GONE: 1062 child = xmlnode_new_child(message, "gone");
1061 child = xmlnode_new_child(message, "gone"); 1063 break;
1062 break; 1064 case JM_STATE_NONE:
1063 } 1065 /* yep, nothing */
1064 if(child) 1066 break;
1065 xmlnode_set_namespace(child, "http://jabber.org/protocol/chatstates"); 1067 }
1066 } 1068 if(child)
1069 xmlnode_set_namespace(child, "http://jabber.org/protocol/chatstates");
1067 1070
1068 if(jm->subject) { 1071 if(jm->subject) {
1069 child = xmlnode_new_child(message, "subject"); 1072 child = xmlnode_new_child(message, "subject");
1070 xmlnode_insert_data(child, jm->subject, -1); 1073 xmlnode_insert_data(child, jm->subject, -1);
1071 } 1074 }
1173 if (tmp) { 1176 if (tmp) {
1174 g_free(xhtml); 1177 g_free(xhtml);
1175 xhtml = tmp; 1178 xhtml = tmp;
1176 } 1179 }
1177 1180
1178 if ((!jbr || jbr->capabilities & JABBER_CAP_XHTML) && 1181 /*
1179 !jabber_xhtml_plain_equal(xhtml, jm->body)) 1182 * For backward compatibility with user expectations or for those not on
1180 jm->xhtml = g_strdup_printf("<html xmlns='http://jabber.org/protocol/xhtml-im'><body xmlns='http://www.w3.org/1999/xhtml'>%s</body></html>", xhtml); 1183 * the user's roster, allow sending XHTML-IM markup.
1184 */
1185 if (!jbr || !jbr->caps.info ||
1186 jabber_resource_has_capability(jbr, "http://jabber.org/protocol/xhtml-im")) {
1187 if (!jabber_xhtml_plain_equal(xhtml, jm->body))
1188 jm->xhtml = g_strdup_printf("<html xmlns='http://jabber.org/protocol/xhtml-im'><body xmlns='http://www.w3.org/1999/xhtml'>%s</body></html>", xhtml);
1189 }
1181 1190
1182 g_free(xhtml); 1191 g_free(xhtml);
1183 1192
1184 jabber_message_send(jm); 1193 jabber_message_send(jm);
1185 jabber_message_free(jm); 1194 jabber_message_free(jm);
1239 jb = jabber_buddy_find(gc->proto_data, who, TRUE); 1248 jb = jabber_buddy_find(gc->proto_data, who, TRUE);
1240 jbr = jabber_buddy_find_resource(jb, resource); 1249 jbr = jabber_buddy_find_resource(jb, resource);
1241 1250
1242 g_free(resource); 1251 g_free(resource);
1243 1252
1244 if (!jbr || (jbr->chat_states != JABBER_CHAT_STATES_UNSUPPORTED)) 1253 if (!jbr || (jbr->chat_states == JABBER_CHAT_STATES_UNSUPPORTED))
1245 return 0; 1254 return 0;
1246 1255
1247 /* TODO: figure out threading */ 1256 /* TODO: figure out threading */
1248 jm = g_new0(JabberMessage, 1); 1257 jm = g_new0(JabberMessage, 1);
1249 jm->js = gc->proto_data; 1258 jm->js = gc->proto_data;