| 700 msim_msg_free(msg); |
700 msim_msg_free(msg); |
| 701 |
701 |
| 702 return rc; |
702 return rc; |
| 703 } |
703 } |
| 704 |
704 |
| 705 /** Convert a font point size to purple's HTML font size. |
|
| 706 * |
|
| 707 * Based on libpurple/protocols/bonjour/jabber.c. |
|
| 708 */ |
|
| 709 static guint |
|
| 710 msim_font_size_to_purple(int size) |
|
| 711 { |
|
| 712 if (size > 24) { |
|
| 713 return 7; |
|
| 714 } else if (size >= 21) { |
|
| 715 return 6; |
|
| 716 } else if (size >= 17) { |
|
| 717 return 5; |
|
| 718 } else if (size >= 14) { |
|
| 719 return 4; |
|
| 720 } else if (size >= 12) { |
|
| 721 return 3; |
|
| 722 } else if (size >= 10) { |
|
| 723 return 2; |
|
| 724 } |
|
| 725 |
|
| 726 return 1; |
|
| 727 } |
|
| 728 |
|
| 729 /** Convert a msim markup font height to points. */ |
705 /** Convert a msim markup font height to points. */ |
| 730 static guint |
706 static guint |
| 731 msim_font_height_to_point(guint height) |
707 msim_font_height_to_point(guint height) |
| 732 { |
708 { |
| 733 /* See also: libpurple/protocols/bonjour/jabber.c |
709 /* See also: libpurple/protocols/bonjour/jabber.c |
| 754 { |
730 { |
| 755 const gchar *face, *height_str, *decor_str; |
731 const gchar *face, *height_str, *decor_str; |
| 756 GString *gs_end, *gs_begin; |
732 GString *gs_end, *gs_begin; |
| 757 guint decor, height; |
733 guint decor, height; |
| 758 |
734 |
| 759 face = xmlnode_get_attrib(root, "n"); |
735 face = xmlnode_get_attrib(root, "f"); |
| 760 height_str = xmlnode_get_attrib(root, "h"); |
736 height_str = xmlnode_get_attrib(root, "h"); |
| 761 decor_str = xmlnode_get_attrib(root, "s"); |
737 decor_str = xmlnode_get_attrib(root, "s"); |
| 762 |
738 |
| 763 if (height_str) |
739 if (height_str) |
| 764 height = atol(height_str); |
740 height = atol(height_str); |
| 769 decor = atol(decor_str); |
745 decor = atol(decor_str); |
| 770 else |
746 else |
| 771 decor = 0; |
747 decor = 0; |
| 772 |
748 |
| 773 gs_begin = g_string_new(""); |
749 gs_begin = g_string_new(""); |
| |
750 #ifdef MSIM_FONT_SIZE_WORKS |
| |
751 /* TODO: get font size working */ |
| 774 if (!face) |
752 if (!face) |
| 775 g_string_printf(gs_begin, "<font size='%d'>", |
753 g_string_printf(gs_begin, "<font size='%d'>", |
| 776 msim_font_size_to_purple(msim_font_height_to_point(height))); |
754 msim_font_height_to_point(height)); |
| 777 else |
755 else |
| 778 g_string_printf(gs_begin, "<font face='%s' size='%d'>", face, |
756 g_string_printf(gs_begin, "<font face='%s' size='%d'>", face, |
| 779 msim_font_size_to_purple(msim_font_height_to_point(height))); |
757 msim_font_height_to_point(height)); |
| |
758 #else |
| |
759 if (face) |
| |
760 { |
| |
761 g_string_printf(gs_begin, "<font face='%s'>", face); |
| |
762 } else { |
| |
763 g_string_printf(gs_begin, "<font>"); |
| |
764 } |
| |
765 #endif |
| |
766 |
| 780 |
767 |
| 781 /* No support for font-size CSS? */ |
768 /* No support for font-size CSS? */ |
| 782 /* g_string_printf(gs_begin, "<span style='font-family: %s; font-size: %dpt'>", face, |
769 /* g_string_printf(gs_begin, "<span style='font-family: %s; font-size: %dpt'>", face, |
| 783 msim_font_height_to_point(height)); */ |
770 msim_font_height_to_point(height)); */ |
| 784 |
771 |
| 975 /* Literal text. */ |
962 /* Literal text. */ |
| 976 inner = g_new0(char, node->data_sz + 1); |
963 inner = g_new0(char, node->data_sz + 1); |
| 977 strncpy(inner, node->data, node->data_sz); |
964 strncpy(inner, node->data, node->data_sz); |
| 978 inner[node->data_sz + 1] = 0; |
965 inner[node->data_sz + 1] = 0; |
| 979 |
966 |
| 980 purple_debug_info("msim", " ** node data=%s (%s)\n", inner, |
967 purple_debug_info("msim", " ** node data=%s\n", inner); |
| 981 node->data); |
|
| 982 break; |
968 break; |
| 983 |
969 |
| 984 default: |
970 default: |
| 985 purple_debug_info("msim", |
971 purple_debug_info("msim", |
| 986 "msim_markup_xmlnode_to_html: strange node\n"); |
972 "msim_markup_xmlnode_to_html: strange node\n"); |
| 2658 } |
2644 } |
| 2659 |
2645 |
| 2660 /** Callbacks called by Purple, to access this plugin. */ |
2646 /** Callbacks called by Purple, to access this plugin. */ |
| 2661 PurplePluginProtocolInfo prpl_info = |
2647 PurplePluginProtocolInfo prpl_info = |
| 2662 { |
2648 { |
| 2663 OPT_PROTO_MAIL_CHECK,/* options - TODO: myspace will notify of mail */ |
2649 /* options */ |
| |
2650 OPT_PROTO_USE_POINTSIZE /* specify font size in sane point size */ |
| |
2651 /* | OPT_PROTO_MAIL_CHECK - TODO: myspace will notify of mail */ |
| |
2652 /* | OPT_PROTO_IM_IMAGE - TODO: direct images. */ |
| |
2653 , |
| 2664 NULL, /* user_splits */ |
2654 NULL, /* user_splits */ |
| 2665 NULL, /* protocol_options */ |
2655 NULL, /* protocol_options */ |
| 2666 NO_BUDDY_ICONS, /* icon_spec - TODO: eventually should add this */ |
2656 NO_BUDDY_ICONS, /* icon_spec - TODO: eventually should add this */ |
| 2667 msim_list_icon, /* list_icon */ |
2657 msim_list_icon, /* list_icon */ |
| 2668 NULL, /* list_emblems */ |
2658 NULL, /* list_emblems */ |