comparison libpurple/protocols/jabber/message.c @ 25443:5f9a24d1c25e

Remove some extra trailing whitespace I noticed after merging mlundblad's xmpp branches.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Mon, 02 Mar 2009 06:37:05 +0000
parents 1dda1c292c50
children c4fd9222dda1 ae41d8e827e3 d8e6a2d592a4 b98519a42e53
comparison
equal deleted inserted replaced
25442:13574de83636 25443:5f9a24d1c25e
116 purple_conversation_write(conv, "", buf, 116 purple_conversation_write(conv, "", buf,
117 PURPLE_MESSAGE_SYSTEM, time(NULL)); 117 PURPLE_MESSAGE_SYSTEM, time(NULL));
118 } 118 }
119 } 119 }
120 serv_got_typing_stopped(jm->js->gc, from); 120 serv_got_typing_stopped(jm->js->gc, from);
121 121
122 } else { 122 } else {
123 serv_got_typing_stopped(jm->js->gc, from); 123 serv_got_typing_stopped(jm->js->gc, from);
124 } 124 }
125 } else { 125 } else {
126 if(jbr) { 126 if(jbr) {
136 136
137 if(jbr->thread_id) 137 if(jbr->thread_id)
138 g_free(jbr->thread_id); 138 g_free(jbr->thread_id);
139 jbr->thread_id = g_strdup(jbr->thread_id); 139 jbr->thread_id = g_strdup(jbr->thread_id);
140 } 140 }
141 141
142 if (jm->js->googletalk && jm->xhtml == NULL) { 142 if (jm->js->googletalk && jm->xhtml == NULL) {
143 char *tmp = jm->body; 143 char *tmp = jm->body;
144 jm->body = jabber_google_format_to_html(jm->body); 144 jm->body = jabber_google_format_to_html(jm->body);
145 g_free(tmp); 145 g_free(tmp);
146 } 146 }
317 static void 317 static void
318 jabber_message_get_refs_from_xmlnode_internal(const xmlnode *message, 318 jabber_message_get_refs_from_xmlnode_internal(const xmlnode *message,
319 GHashTable *table) 319 GHashTable *table)
320 { 320 {
321 xmlnode *child; 321 xmlnode *child;
322 322
323 for (child = xmlnode_get_child(message, "img") ; child ; 323 for (child = xmlnode_get_child(message, "img") ; child ;
324 child = xmlnode_get_next_twin(child)) { 324 child = xmlnode_get_next_twin(child)) {
325 const gchar *src = xmlnode_get_attrib(child, "src"); 325 const gchar *src = xmlnode_get_attrib(child, "src");
326 326
327 if (g_str_has_prefix(src, "cid:")) { 327 if (g_str_has_prefix(src, "cid:")) {
328 const gchar *cid = src + 4; 328 const gchar *cid = src + 4;
329 329
330 /* if we haven't "fetched" this yet... */ 330 /* if we haven't "fetched" this yet... */
331 if (!g_hash_table_lookup(table, cid)) { 331 if (!g_hash_table_lookup(table, cid)) {
332 /* take a copy of the cid and let the SmileyRef own it... */ 332 /* take a copy of the cid and let the SmileyRef own it... */
333 gchar *temp_cid = g_strdup(cid); 333 gchar *temp_cid = g_strdup(cid);
334 JabberSmileyRef *ref = g_new0(JabberSmileyRef, 1); 334 JabberSmileyRef *ref = g_new0(JabberSmileyRef, 1);
335 const gchar *alt = xmlnode_get_attrib(child, "alt"); 335 const gchar *alt = xmlnode_get_attrib(child, "alt");
336 ref->cid = temp_cid; 336 ref->cid = temp_cid;
337 /* if there is no "alt" string, use the cid... 337 /* if there is no "alt" string, use the cid...
338 include the entire src, eg. "cid:.." to avoid linkification */ 338 include the entire src, eg. "cid:.." to avoid linkification */
339 if (alt && alt[0] != '\0') { 339 if (alt && alt[0] != '\0') {
340 /* workaround for when "alt" is set to the value of the 340 /* workaround for when "alt" is set to the value of the
341 CID (which Jabbim seems to do), to avoid it showing up 341 CID (which Jabbim seems to do), to avoid it showing up
342 as an mailto: link */ 342 as an mailto: link */
343 if (purple_email_is_valid(alt)) { 343 if (purple_email_is_valid(alt)) {
344 ref->alt = g_strdup_printf("smiley:%s", alt); 344 ref->alt = g_strdup_printf("smiley:%s", alt);
345 } else { 345 } else {
346 ref->alt = g_strdup(alt); 346 ref->alt = g_strdup(alt);
347 } 347 }
348 } else { 348 } else {
349 ref->alt = g_strdup(src); 349 ref->alt = g_strdup(src);
350 } 350 }
351 g_hash_table_insert(table, temp_cid, ref); 351 g_hash_table_insert(table, temp_cid, ref);
352 } 352 }
353 } 353 }
354 } 354 }
355 355
356 for (child = message->child ; child ; child = child->next) { 356 for (child = message->child ; child ; child = child->next) {
357 jabber_message_get_refs_from_xmlnode_internal(child, table); 357 jabber_message_get_refs_from_xmlnode_internal(child, table);
358 } 358 }
359 } 359 }
360 360
361 static gboolean 361 static gboolean
362 jabber_message_get_refs_steal(gpointer key, gpointer value, gpointer user_data) 362 jabber_message_get_refs_steal(gpointer key, gpointer value, gpointer user_data)
363 { 363 {
364 GList **refs = (GList **) user_data; 364 GList **refs = (GList **) user_data;
365 JabberSmileyRef *ref = (JabberSmileyRef *) value; 365 JabberSmileyRef *ref = (JabberSmileyRef *) value;
366 366
367 *refs = g_list_append(*refs, ref); 367 *refs = g_list_append(*refs, ref);
368 368
369 return TRUE; 369 return TRUE;
370 } 370 }
371 371
372 static GList * 372 static GList *
373 jabber_message_get_refs_from_xmlnode(const xmlnode *message) 373 jabber_message_get_refs_from_xmlnode(const xmlnode *message)
374 { 374 {
375 GList *refs = NULL; 375 GList *refs = NULL;
376 GHashTable *unique_refs = g_hash_table_new(g_str_hash, g_str_equal); 376 GHashTable *unique_refs = g_hash_table_new(g_str_hash, g_str_equal);
377 377
378 jabber_message_get_refs_from_xmlnode_internal(message, unique_refs); 378 jabber_message_get_refs_from_xmlnode_internal(message, unique_refs);
379 (void) g_hash_table_foreach_steal(unique_refs, 379 (void) g_hash_table_foreach_steal(unique_refs,
380 jabber_message_get_refs_steal, (gpointer) &refs); 380 jabber_message_get_refs_steal, (gpointer) &refs);
381 g_hash_table_destroy(unique_refs); 381 g_hash_table_destroy(unique_refs);
382 return refs; 382 return refs;
383 } 383 }
384 384
507 g_free(ref); 507 g_free(ref);
508 } 508 }
509 509
510 static void 510 static void
511 jabber_message_send_data_request(JabberStream *js, PurpleConversation *conv, 511 jabber_message_send_data_request(JabberStream *js, PurpleConversation *conv,
512 const gchar *cid, const gchar *who, 512 const gchar *cid, const gchar *who,
513 const gchar *alt) 513 const gchar *alt)
514 { 514 {
515 JabberIq *request = jabber_iq_new(js, JABBER_IQ_GET); 515 JabberIq *request = jabber_iq_new(js, JABBER_IQ_GET);
516 JabberDataRef *ref = g_new0(JabberDataRef, 1); 516 JabberDataRef *ref = g_new0(JabberDataRef, 1);
517 xmlnode *data_request = jabber_data_get_xml_request(cid); 517 xmlnode *data_request = jabber_data_get_xml_request(cid);
569 const char *code = xmlnode_get_attrib(child, "code"); 569 const char *code = xmlnode_get_attrib(child, "code");
570 char *code_txt = NULL; 570 char *code_txt = NULL;
571 char *text = xmlnode_get_data(child); 571 char *text = xmlnode_get_data(child);
572 if (!text) { 572 if (!text) {
573 xmlnode *enclosed_text_node; 573 xmlnode *enclosed_text_node;
574 574
575 if ((enclosed_text_node = xmlnode_get_child(child, "text"))) 575 if ((enclosed_text_node = xmlnode_get_child(child, "text")))
576 text = xmlnode_get_data(enclosed_text_node); 576 text = xmlnode_get_data(enclosed_text_node);
577 } 577 }
578 578
579 if(code) 579 if(code)
621 /* find a list of smileys ("cid" and "alt" text pairs) 621 /* find a list of smileys ("cid" and "alt" text pairs)
622 occuring in the message */ 622 occuring in the message */
623 smiley_refs = jabber_message_get_refs_from_xmlnode(child); 623 smiley_refs = jabber_message_get_refs_from_xmlnode(child);
624 purple_debug_info("jabber", "found %d smileys\n", 624 purple_debug_info("jabber", "found %d smileys\n",
625 g_list_length(smiley_refs)); 625 g_list_length(smiley_refs));
626 626
627 if (jm->type == JABBER_MESSAGE_GROUPCHAT) { 627 if (jm->type == JABBER_MESSAGE_GROUPCHAT) {
628 JabberID *jid = jabber_id_new(jm->from); 628 JabberID *jid = jabber_id_new(jm->from);
629 JabberChat *chat = NULL; 629 JabberChat *chat = NULL;
630 630
631 if (jid) { 631 if (jid) {
665 for (; conv && smiley_refs ; smiley_refs = g_list_delete_link(smiley_refs, smiley_refs)) { 665 for (; conv && smiley_refs ; smiley_refs = g_list_delete_link(smiley_refs, smiley_refs)) {
666 JabberSmileyRef *ref = (JabberSmileyRef *) smiley_refs->data; 666 JabberSmileyRef *ref = (JabberSmileyRef *) smiley_refs->data;
667 const gchar *cid = ref->cid; 667 const gchar *cid = ref->cid;
668 const gchar *alt = ref->alt; 668 const gchar *alt = ref->alt;
669 669
670 purple_debug_info("jabber", 670 purple_debug_info("jabber",
671 "about to add custom smiley %s to the conv\n", alt); 671 "about to add custom smiley %s to the conv\n", alt);
672 if (purple_conv_custom_smiley_add(conv, alt, "cid", cid, 672 if (purple_conv_custom_smiley_add(conv, alt, "cid", cid,
673 TRUE)) { 673 TRUE)) {
674 const JabberData *data = 674 const JabberData *data =
675 jabber_data_find_remote_by_cid(cid); 675 jabber_data_find_remote_by_cid(cid);
676 /* if data is already known, we add write it immediatly */ 676 /* if data is already known, we add write it immediatly */
677 if (data) { 677 if (data) {
678 purple_debug_info("jabber", 678 purple_debug_info("jabber",
679 "data is already known\n"); 679 "data is already known\n");
680 purple_conv_custom_smiley_write(conv, alt, 680 purple_conv_custom_smiley_write(conv, alt,
681 jabber_data_get_data(data), 681 jabber_data_get_data(data),
682 jabber_data_get_size(data)); 682 jabber_data_get_size(data));
683 purple_conv_custom_smiley_close(conv, alt); 683 purple_conv_custom_smiley_close(conv, alt);
684 } else { 684 } else {
899 const PurpleConversation *conv, 899 const PurpleConversation *conv,
900 const gchar *who) 900 const gchar *who)
901 { 901 {
902 JabberStream *js = (JabberStream *) gc->proto_data; 902 JabberStream *js = (JabberStream *) gc->proto_data;
903 JabberBuddy *jb; 903 JabberBuddy *jb;
904 904
905 if (!js) { 905 if (!js) {
906 purple_debug_error("jabber", 906 purple_debug_error("jabber",
907 "jabber_conv_support_custom_smileys: could not find stream\n"); 907 "jabber_conv_support_custom_smileys: could not find stream\n");
908 return FALSE; 908 return FALSE;
909 } 909 }
910 910
911 switch (purple_conversation_get_type(conv)) { 911 switch (purple_conversation_get_type(conv)) {
954 break; 954 break;
955 } 955 }
956 956
957 if(type) 957 if(type)
958 xmlnode_set_attrib(message, "type", type); 958 xmlnode_set_attrib(message, "type", type);
959 959
960 if (jm->id) 960 if (jm->id)
961 xmlnode_set_attrib(message, "id", jm->id); 961 xmlnode_set_attrib(message, "id", jm->id);
962 962
963 xmlnode_set_attrib(message, "to", jm->to); 963 xmlnode_set_attrib(message, "to", jm->to);
964 964
1011 if(jm->xhtml) { 1011 if(jm->xhtml) {
1012 PurpleAccount *account = purple_connection_get_account(jm->js->gc); 1012 PurpleAccount *account = purple_connection_get_account(jm->js->gc);
1013 PurpleConversation *conv = 1013 PurpleConversation *conv =
1014 purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, jm->to, 1014 purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, jm->to,
1015 account); 1015 account);
1016 1016
1017 if (jabber_conv_support_custom_smileys(jm->js->gc, conv, jm->to)) { 1017 if (jabber_conv_support_custom_smileys(jm->js->gc, conv, jm->to)) {
1018 GList *found_smileys = jabber_message_xhtml_find_smileys(jm->xhtml); 1018 GList *found_smileys = jabber_message_xhtml_find_smileys(jm->xhtml);
1019 1019
1020 if (found_smileys) { 1020 if (found_smileys) {
1021 gchar *smileyfied_xhtml = NULL; 1021 gchar *smileyfied_xhtml = NULL;
1026 const PurpleSmiley *smiley = 1026 const PurpleSmiley *smiley =
1027 (PurpleSmiley *) iterator->data; 1027 (PurpleSmiley *) iterator->data;
1028 const gchar *shortcut = purple_smiley_get_shortcut(smiley); 1028 const gchar *shortcut = purple_smiley_get_shortcut(smiley);
1029 const JabberData *data = 1029 const JabberData *data =
1030 jabber_data_find_local_by_alt(shortcut); 1030 jabber_data_find_local_by_alt(shortcut);
1031 1031
1032 /* the object has not been sent before */ 1032 /* the object has not been sent before */
1033 if (!data) { 1033 if (!data) {
1034 PurpleStoredImage *image = 1034 PurpleStoredImage *image =
1035 purple_smiley_get_stored_image(smiley); 1035 purple_smiley_get_stored_image(smiley);
1036 const gchar *ext = purple_imgstore_get_extension(image); 1036 const gchar *ext = purple_imgstore_get_extension(image);
1037 JabberStream *js = jm->js; 1037 JabberStream *js = jm->js;
1038 1038
1039 JabberData *new_data = 1039 JabberData *new_data =
1040 jabber_data_create_from_data(purple_imgstore_get_data(image), 1040 jabber_data_create_from_data(purple_imgstore_get_data(image),
1041 purple_imgstore_get_size(image), 1041 purple_imgstore_get_size(image),
1042 jabber_message_get_mimetype_from_ext(ext), js); 1042 jabber_message_get_mimetype_from_ext(ext), js);
1043 purple_debug_info("jabber", 1043 purple_debug_info("jabber",
1044 "cache local smiley alt = %s, cid = %s\n", 1044 "cache local smiley alt = %s, cid = %s\n",
1045 shortcut, jabber_data_get_cid(new_data)); 1045 shortcut, jabber_data_get_cid(new_data));
1046 jabber_data_associate_local(new_data, shortcut); 1046 jabber_data_associate_local(new_data, shortcut);
1047 } 1047 }
1048 } 1048 }
1113 if(jbr->chat_states != JABBER_CHAT_STATES_SUPPORTED) 1113 if(jbr->chat_states != JABBER_CHAT_STATES_SUPPORTED)
1114 jm->typing_style |= JM_TS_JEP_0022; 1114 jm->typing_style |= JM_TS_JEP_0022;
1115 } 1115 }
1116 1116
1117 buf = g_strdup_printf("<html xmlns='http://jabber.org/protocol/xhtml-im'><body xmlns='http://www.w3.org/1999/xhtml'>%s</body></html>", msg); 1117 buf = g_strdup_printf("<html xmlns='http://jabber.org/protocol/xhtml-im'><body xmlns='http://www.w3.org/1999/xhtml'>%s</body></html>", msg);
1118 1118
1119 purple_markup_html_to_xhtml(buf, &xhtml, &jm->body); 1119 purple_markup_html_to_xhtml(buf, &xhtml, &jm->body);
1120 g_free(buf); 1120 g_free(buf);
1121 1121
1122 if(!jbr || jbr->capabilities & JABBER_CAP_XHTML) 1122 if(!jbr || jbr->capabilities & JABBER_CAP_XHTML)
1123 jm->xhtml = xhtml; 1123 jm->xhtml = xhtml;