# HG changeset patch # User Sadrul Habib Chowdhury # Date 1244048958 0 # Node ID 22bcf150f6c7640e2fd674e7bfb8596bcdda242d # Parent e696a0740a85f89c8d87cb3fc1ea399259933b17# Parent 1b47eb4abf9673040ddf1dce226666b627582324 merge of '84a23ef59e6a3bc88834f0948c67516f0a39234b' and 'c6d740f231b3d74f01b3afece4a09e6e4cde36a9' diff -r e696a0740a85 -r 22bcf150f6c7 ChangeLog --- a/ChangeLog Wed Jun 03 16:41:52 2009 +0000 +++ b/ChangeLog Wed Jun 03 17:09:18 2009 +0000 @@ -84,6 +84,7 @@ rejoin. * Always set unseen-count and unseen-state on conversations. (Joshua Stein) + * Fix a bug in 'Conversation Colors' plugin for RTL messages. Finch: * The hardware cursor is updated correctly. This will be useful diff -r e696a0740a85 -r 22bcf150f6c7 ChangeLog.API --- a/ChangeLog.API Wed Jun 03 16:41:52 2009 +0000 +++ b/ChangeLog.API Wed Jun 03 17:09:18 2009 +0000 @@ -36,6 +36,7 @@ * purple_global_proxy_set_info * purple_group_destroy * purple_log_get_activity_score + * purple_markup_is_rtl * purple_network_force_online * purple_network_set_stun_server * purple_network_set_turn_server diff -r e696a0740a85 -r 22bcf150f6c7 libpurple/protocols/msn/msn.c --- a/libpurple/protocols/msn/msn.c Wed Jun 03 16:41:52 2009 +0000 +++ b/libpurple/protocols/msn/msn.c Wed Jun 03 17:09:18 2009 +0000 @@ -1281,7 +1281,7 @@ imdata->gc = gc; imdata->who = who; imdata->msg = body_str; - imdata->flags = flags; + imdata->flags = flags & ~PURPLE_MESSAGE_SEND; imdata->when = time(NULL); purple_timeout_add(0, msn_send_me_im, imdata); } diff -r e696a0740a85 -r 22bcf150f6c7 libpurple/util.c --- a/libpurple/util.c Wed Jun 03 16:41:52 2009 +0000 +++ b/libpurple/util.c Wed Jun 03 17:09:18 2009 +0000 @@ -1041,6 +1041,35 @@ return ret; } +gboolean purple_markup_is_rtl(const char *html) +{ + GData *attributes; + const gchar *start, *end; + gboolean res = FALSE; + + if (purple_markup_find_tag("span", html, &start, &end, &attributes)) + { + /* tmp is a member of attributes and is free with g_datalist_clear call */ + const char *tmp = g_datalist_get_data(&attributes, "dir"); + if (tmp && !g_ascii_strcasecmp(tmp, "RTL")) + res = TRUE; + if (!res) + { + tmp = g_datalist_get_data(&attributes, "style"); + if (tmp) + { + char *tmp2 = purple_markup_get_css_property(tmp, "direction"); + if (tmp2 && !g_ascii_strcasecmp(tmp2, "RTL")) + res = TRUE; + g_free(tmp2); + } + + } + g_datalist_clear(&attributes); + } + return res; +} + gboolean purple_markup_find_tag(const char *needle, const char *haystack, const char **start, const char **end, GData **attributes) diff -r e696a0740a85 -r 22bcf150f6c7 libpurple/util.h --- a/libpurple/util.h Wed Jun 03 16:41:52 2009 +0000 +++ b/libpurple/util.h Wed Jun 03 17:09:18 2009 +0000 @@ -579,6 +579,16 @@ */ char * purple_markup_get_css_property(const gchar *style, const gchar *opt); +/** + * Check if the given HTML contains RTL text. + * + * @param html The HTML text. + * + * @return TRUE if the text contains RTL text, FALSE otherwise. + * + * @since 2.6.0 + */ +gboolean purple_markup_is_rtl(const char *html); /*@}*/ diff -r e696a0740a85 -r 22bcf150f6c7 pidgin/gtkconv.c --- a/pidgin/gtkconv.c Wed Jun 03 16:41:52 2009 +0000 +++ b/pidgin/gtkconv.c Wed Jun 03 17:09:18 2009 +0000 @@ -5629,38 +5629,6 @@ #endif } -/* Returns true if the given HTML contains RTL text */ -static gboolean -html_is_rtl(const char *html) -{ - GData *attributes; - const gchar *start, *end; - gboolean res = FALSE; - - if (purple_markup_find_tag("span", html, &start, &end, &attributes)) - { - /* tmp is a member of attributes and is free with g_datalist_clear call */ - const char *tmp = g_datalist_get_data(&attributes, "dir"); - if (tmp && !g_ascii_strcasecmp(tmp, "RTL")) - res = TRUE; - if (!res) - { - tmp = g_datalist_get_data(&attributes, "style"); - if (tmp) - { - char *tmp2 = purple_markup_get_css_property(tmp, "direction"); - if (tmp2 && !g_ascii_strcasecmp(tmp2, "RTL")) - res = TRUE; - g_free(tmp2); - } - - } - g_datalist_clear(&attributes); - } - return res; -} - - static void pidgin_conv_write_conv(PurpleConversation *conv, const char *name, const char *alias, const char *message, PurpleMessageFlags flags, @@ -5822,7 +5790,7 @@ } /* Bi-Directional support - set timestamp direction using unicode characters */ - is_rtl_message = html_is_rtl(message); + is_rtl_message = purple_markup_is_rtl(message); /* Enforce direction only if message is RTL - doesn't effect LTR users */ if (is_rtl_message) str_embed_direction_chars(&mdate); diff -r e696a0740a85 -r 22bcf150f6c7 pidgin/plugins/convcolors.c --- a/pidgin/plugins/convcolors.c Wed Jun 03 16:41:52 2009 +0000 +++ b/pidgin/plugins/convcolors.c Wed Jun 03 17:09:18 2009 +0000 @@ -101,6 +101,7 @@ gboolean bold, italic, underline; int f; const char *color; + gboolean rtl = FALSE; for (i = 0; formats[i].prefix; i++) if (flags & formats[i].flag) @@ -126,6 +127,7 @@ bold = (f & FONT_BOLD); italic = (f & FONT_ITALIC); underline = (f & FONT_UNDERLINE); + rtl = purple_markup_is_rtl(*displaying); if (purple_prefs_get_bool(PREF_IGNORE)) { @@ -156,11 +158,13 @@ } t = *displaying; - *displaying = g_strdup_printf("%s%s%s%s%s%s%s", + *displaying = g_strdup_printf("%s%s%s%s%s%s%s%s%s", bold ? "" : "", italic ? "" : "", underline ? "" : "", - t, + rtl ? "" : "", + t, + rtl ? "" : "", bold ? "" : "", italic ? "" : "", underline ? "" : ""