# HG changeset patch # User Jeffrey Connelly # Date 1186901655 0 # Node ID da2f37d232a9a8a5bec72794436878928d824ce6 # Parent 3159f259bbe46409ebfbed48c345320896a90a00 Support sending and receiving hyperlinks. diff -r 3159f259bbe4 -r da2f37d232a9 libpurple/protocols/myspace/myspace.c --- a/libpurple/protocols/myspace/myspace.c Sun Aug 12 02:41:54 2007 +0000 +++ b/libpurple/protocols/myspace/myspace.c Sun Aug 12 06:54:15 2007 +0000 @@ -1009,6 +1009,21 @@ return g_strdup_printf("#%.2x%.2x%.2x", red, green, blue); } +/** Convert the msim markup (anchor) tag into HTML. */ +static void +msim_markup_a_to_html(MsimSession *session, xmlnode *root, gchar **begin, gchar **end) +{ + const gchar *href; + + href = xmlnode_get_attrib(root, "h"); + if (!href) { + href = ""; + } + + *begin = g_strdup_printf("%s", href, href); + *end = g_strdup(""); +} + /** Convert the msim markup

(paragraph) tag into HTML. */ static void msim_markup_p_to_html(MsimSession *session, xmlnode *root, gchar **begin, gchar **end) @@ -1110,6 +1125,8 @@ { if (!strcmp(root->name, "f")) { msim_markup_f_to_html(session, root, begin, end); + } else if (!strcmp(root->name, "a")) { + msim_markup_a_to_html(session, root, begin, end); } else if (!strcmp(root->name, "p")) { msim_markup_p_to_html(session, root, begin, end); } else if (!strcmp(root->name, "c")) { @@ -1136,19 +1153,55 @@ * Currently, the 's' value will be overwritten when b/i/u is nested * within another one, and only the inner-most formatting will be * applied to the text. */ - if (!strcmp(root->name, "root")) { + if (!stricmp(root->name, "root")) { *begin = g_strdup(""); *end = g_strdup(""); - } else if (!strcmp(root->name, "b")) { + } else if (!stricmp(root->name, "b")) { *begin = g_strdup_printf("", MSIM_TEXT_BOLD); *end = g_strdup(""); - } else if (!strcmp(root->name, "i")) { + } else if (!stricmp(root->name, "i")) { *begin = g_strdup_printf("", MSIM_TEXT_ITALIC); *end = g_strdup(""); - } else if (!strcmp(root->name, "u")) { + } else if (!stricmp(root->name, "u")) { *begin = g_strdup_printf("", MSIM_TEXT_UNDERLINE); *end = g_strdup(""); - } else if (!strcmp(root->name, "font")) { + } else if (!stricmp(root->name, "a")) { + const gchar *href, *link_text; + + href = xmlnode_get_attrib(root, "href"); + + if (!href) { + href = xmlnode_get_attrib(root, "HREF"); + } + + link_text = xmlnode_get_data(root); + + if (href) { + if (!strcmp(link_text, href)) { + /* Purple gives us: URL + * Translate to + * Displayed as text of URL with link to URL + */ + *begin = g_strdup_printf("", href); + } else { + /* But if we get: text + * Translate to: text: + * + * Because official client only supports self-closed + * tags; you can't change the link text. + */ + *begin = g_strdup_printf("%s: ", link_text, href); + } + } else { + *begin = g_strdup(""); + } + + /* Sorry, kid. MySpace doesn't support you within tags. */ + xmlnode_free(root->child); + root->child = NULL; + + *end = g_strdup(""); + } else if (!stricmp(root->name, "font")) { const gchar *size; const gchar *face;