comparison libpurple/protocols/jabber/message.c @ 19696:481749fc0b6b

merge of '1c7910841138381c841363256ca3c7905b1f26b0' and '5818cbd5fe95d6a167f1555b882526f36790b141'
author Daniel Atallah <daniel.atallah@gmail.com>
date Mon, 10 Sep 2007 13:57:15 +0000
parents 472bcd9d502e 44b4e8bd759b
children 159a46ec0e33
comparison
equal deleted inserted replaced
19695:301f1597d41f 19696:481749fc0b6b
8 * the Free Software Foundation; either version 2 of the License, or 8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version. 9 * (at your option) any later version.
10 * 10 *
11 * This program is distributed in the hope that it will be useful, 11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License 16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software 17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
19 * 19 *
20 */ 20 */
21 #include "internal.h" 21 #include "internal.h"
22 22
23 #include "debug.h" 23 #include "debug.h"
60 jb = jabber_buddy_find(jm->js, jm->from, TRUE); 60 jb = jabber_buddy_find(jm->js, jm->from, TRUE);
61 jbr = jabber_buddy_find_resource(jb, jid->resource); 61 jbr = jabber_buddy_find_resource(jb, jid->resource);
62 62
63 if(jabber_find_unnormalized_conv(jm->from, jm->js->gc->account)) { 63 if(jabber_find_unnormalized_conv(jm->from, jm->js->gc->account)) {
64 from = g_strdup(jm->from); 64 from = g_strdup(jm->from);
65 } else if(jid->node) { 65 } else if(jid->node) {
66 if(jid->resource) { 66 if(jid->resource) {
67 PurpleConversation *conv; 67 PurpleConversation *conv;
68 68
69 from = g_strdup_printf("%s@%s", jid->node, jid->domain); 69 from = g_strdup_printf("%s@%s", jid->node, jid->domain);
70 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, from, jm->js->gc->account); 70 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, from, jm->js->gc->account);
98 98
99 who = purple_buddy_get_alias(buddy); 99 who = purple_buddy_get_alias(buddy);
100 escaped = g_markup_escape_text(who, -1); 100 escaped = g_markup_escape_text(who, -1);
101 101
102 g_snprintf(buf, sizeof(buf), 102 g_snprintf(buf, sizeof(buf),
103 _("%s has left the conversation."), escaped); 103 _("%s has left the conversation."), escaped);
104 104
105 /* At some point when we restructure PurpleConversation, 105 /* At some point when we restructure PurpleConversation,
106 * this should be able to be implemented by removing the 106 * this should be able to be implemented by removing the
107 * user from the conversation like we do with chats now. */ 107 * user from the conversation like we do with chats now. */
108 purple_conversation_write(conv, "", buf, 108 purple_conversation_write(conv, "", buf,
109 PURPLE_MESSAGE_SYSTEM, time(NULL)); 109 PURPLE_MESSAGE_SYSTEM, time(NULL));
110 } 110 }
111 } 111 }
112 serv_got_typing_stopped(jm->js->gc, from); 112 serv_got_typing_stopped(jm->js->gc, from);
113 113
114 } else { 114 } else {
148 static void handle_headline(JabberMessage *jm) 148 static void handle_headline(JabberMessage *jm)
149 { 149 {
150 char *title; 150 char *title;
151 GString *body; 151 GString *body;
152 GList *etc; 152 GList *etc;
153 153
154 if(!jm->xhtml && !jm->body) 154 if(!jm->xhtml && !jm->body)
155 return; /* ignore headlines without any content */ 155 return; /* ignore headlines without any content */
156 156
157 body = g_string_new(""); 157 body = g_string_new("");
158 title = g_strdup_printf(_("Message from %s"), jm->from); 158 title = g_strdup_printf(_("Message from %s"), jm->from);
363 } 363 }
364 } else if(!strcmp(child->name, "html") && !strcmp(xmlns,"http://jabber.org/protocol/xhtml-im")) { 364 } else if(!strcmp(child->name, "html") && !strcmp(xmlns,"http://jabber.org/protocol/xhtml-im")) {
365 if(!jm->xhtml && xmlnode_get_child(child, "body")) { 365 if(!jm->xhtml && xmlnode_get_child(child, "body")) {
366 char *c; 366 char *c;
367 jm->xhtml = xmlnode_to_str(child, NULL); 367 jm->xhtml = xmlnode_to_str(child, NULL);
368 /* Convert all newlines to whitespace. Technically, even regular, non-XML HTML is supposed to ignore newlines, but Pidgin has, as convention 368 /* Convert all newlines to whitespace. Technically, even regular, non-XML HTML is supposed to ignore newlines, but Pidgin has, as convention
369 * treated \n as a newline for compatibility with other protocols 369 * treated \n as a newline for compatibility with other protocols
370 */ 370 */
371 for (c = jm->xhtml; *c != '\0'; c++) { 371 for (c = jm->xhtml; *c != '\0'; c++) {
372 if (*c == '\n') 372 if (*c == '\n')
373 *c = ' '; 373 *c = ' ';
374 } 374 }
457 } else { 457 } else {
458 jm->etc = g_list_append(jm->etc, child); 458 jm->etc = g_list_append(jm->etc, child);
459 } 459 }
460 } 460 }
461 } 461 }
462 462
463 if(jm->hasBuzz) 463 if(jm->hasBuzz)
464 handle_buzz(jm); 464 handle_buzz(jm);
465 465
466 switch(jm->type) { 466 switch(jm->type) {
467 case JABBER_MESSAGE_NORMAL: 467 case JABBER_MESSAGE_NORMAL: