| 65 ggp_message_got_data *msg); |
65 ggp_message_got_data *msg); |
| 66 static void ggp_message_got_display(PurpleConnection *gc, |
66 static void ggp_message_got_display(PurpleConnection *gc, |
| 67 ggp_message_got_data *msg); |
67 ggp_message_got_data *msg); |
| 68 static void ggp_message_format_from_gg(ggp_message_got_data *msg, |
68 static void ggp_message_format_from_gg(ggp_message_got_data *msg, |
| 69 const gchar *text); |
69 const gchar *text); |
| 70 static gchar * ggp_message_format_to_gg(const gchar *text); |
70 static gchar * ggp_message_format_to_gg(PurpleConversation *conv, |
| |
71 const gchar *text); |
| 71 |
72 |
| 72 /**************/ |
73 /**************/ |
| 73 |
74 |
| 74 void ggp_message_setup_global(void) |
75 void ggp_message_setup_global(void) |
| 75 { |
76 { |
| 550 else if (tag == GGP_HTML_TAG_S) |
551 else if (tag == GGP_HTML_TAG_S) |
| 551 { |
552 { |
| 552 font_changed |= (font_new->s != !tag_close); |
553 font_changed |= (font_new->s != !tag_close); |
| 553 font_new->s = !tag_close; |
554 font_new->s = !tag_close; |
| 554 } |
555 } |
| |
556 else if (tag == GGP_HTML_TAG_IMG && !tag_close) |
| |
557 { |
| |
558 GHashTable *attribs = ggp_html_tag_attribs(attribs_str); |
| |
559 gchar *val = NULL; |
| |
560 uint64_t id; |
| |
561 int stored_id = -1; |
| |
562 ggp_image_prepare_result res = -1; |
| |
563 |
| |
564 if ((val = g_hash_table_lookup(attribs, "src")) != NULL |
| |
565 && g_str_has_prefix(val, |
| |
566 PURPLE_STORED_IMAGE_PROTOCOL)) |
| |
567 { |
| |
568 val += strlen(PURPLE_STORED_IMAGE_PROTOCOL); |
| |
569 if (sscanf(val, "%u", &stored_id) != 1) |
| |
570 stored_id = -1; |
| |
571 } |
| |
572 |
| |
573 if (stored_id >= 0) |
| |
574 res = ggp_image_prepare(conv, stored_id, &id); |
| |
575 |
| |
576 if (res == GGP_IMAGE_PREPARE_OK) |
| |
577 { |
| |
578 pending_objects = g_list_prepend( |
| |
579 pending_objects, g_strdup_printf( |
| |
580 "<img name=\"%016llx\">", id)); |
| |
581 } |
| |
582 else if (res == GGP_IMAGE_PREPARE_TOO_BIG) |
| |
583 { |
| |
584 purple_conversation_write(conv, "", |
| |
585 _("Image is too large, please try " |
| |
586 "smaller one."), PURPLE_MESSAGE_ERROR, |
| |
587 time(NULL)); |
| |
588 } |
| |
589 else |
| |
590 { |
| |
591 purple_conversation_write(conv, "", |
| |
592 _("Image cannot be sent."), |
| |
593 PURPLE_MESSAGE_ERROR, time(NULL)); |
| |
594 } |
| |
595 |
| |
596 g_hash_table_destroy(attribs); |
| |
597 } |
| 555 else if (tag == GGP_HTML_TAG_FONT && !tag_close) |
598 else if (tag == GGP_HTML_TAG_FONT && !tag_close) |
| 556 { |
599 { |
| 557 GHashTable *attribs = ggp_html_tag_attribs(attribs_str); |
600 GHashTable *attribs = ggp_html_tag_attribs(attribs_str); |
| 558 gchar *val = NULL; |
601 gchar *val = NULL; |
| 559 |
602 |
| 700 |
743 |
| 701 int ggp_message_send_im(PurpleConnection *gc, const char *who, |
744 int ggp_message_send_im(PurpleConnection *gc, const char *who, |
| 702 const char *message, PurpleMessageFlags flags) |
745 const char *message, PurpleMessageFlags flags) |
| 703 { |
746 { |
| 704 GGPInfo *info = purple_connection_get_protocol_data(gc); |
747 GGPInfo *info = purple_connection_get_protocol_data(gc); |
| |
748 PurpleConversation *conv; |
| 705 ggp_buddy_data *buddy_data; |
749 ggp_buddy_data *buddy_data; |
| 706 gchar *gg_msg; |
750 gchar *gg_msg; |
| 707 gboolean succ; |
751 gboolean succ; |
| 708 |
752 |
| 709 /* TODO: return -ENOTCONN, if not connected */ |
753 /* TODO: return -ENOTCONN, if not connected */ |
| 715 purple_connection_get_account(gc), who)); |
759 purple_connection_get_account(gc), who)); |
| 716 |
760 |
| 717 if (buddy_data->blocked) |
761 if (buddy_data->blocked) |
| 718 return -1; |
762 return -1; |
| 719 |
763 |
| 720 gg_msg = ggp_message_format_to_gg(message); |
764 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, |
| |
765 who, purple_connection_get_account(gc)); |
| |
766 |
| |
767 gg_msg = ggp_message_format_to_gg(conv, message); |
| 721 |
768 |
| 722 /* TODO: splitting messages */ |
769 /* TODO: splitting messages */ |
| 723 if (strlen(gg_msg) > GG_MSG_MAXSIZE) |
770 if (strlen(gg_msg) > GG_MSG_MAXSIZE) |
| 724 { |
771 { |
| 725 g_free(gg_msg); |
772 g_free(gg_msg); |