libpurple/protocols/myspace/markup.c

branch
release-2.2.1
changeset 20404
d5e4f520e5e7
parent 20166
49c243c1fe12
parent 20402
a3a7cbfe1c1c
equal deleted inserted replaced
20187:11fecadc1233 20404:d5e4f520e5e7
256 g_string_append(gs_begin, "<u>"); 256 g_string_append(gs_begin, "<u>");
257 g_string_append(gs_end, "</u>"); 257 g_string_append(gs_end, "</u>");
258 } 258 }
259 259
260 260
261 *begin = g_string_free(gs_begin, FALSE); 261 *begin = g_string_free(gs_begin,FALSE);
262 *end = g_string_free(gs_end, FALSE); 262 *end = g_string_free(gs_end, FALSE);
263 } 263 }
264 264
265 /** Convert a msim markup color to a color suitable for libpurple. 265 /** Convert a msim markup color to a color suitable for libpurple.
266 * 266 *
424 /** Convert an individual HTML tag to msim markup. */ 424 /** Convert an individual HTML tag to msim markup. */
425 static void 425 static void
426 html_tag_to_msim_markup(MsimSession *session, xmlnode *root, gchar **begin, 426 html_tag_to_msim_markup(MsimSession *session, xmlnode *root, gchar **begin,
427 gchar **end) 427 gchar **end)
428 { 428 {
429 if (!purple_utf8_strcasecmp(root->name, "root") || 429 if (!purple_utf8_strcasecmp(root->name, "root") ||
430 !purple_utf8_strcasecmp(root->name, "html")) { 430 !purple_utf8_strcasecmp(root->name, "html")) {
431 *begin = g_strdup(""); 431 *begin = g_strdup("");
432 *end = g_strdup(""); 432 *end = g_strdup("");
433 /* TODO: Coalesce nested tags into one <f> tag! 433 /* TODO: Coalesce nested tags into one <f> tag!
434 * Currently, the 's' value will be overwritten when b/i/u is nested 434 * Currently, the 's' value will be overwritten when b/i/u is nested
435 * within another one, and only the inner-most formatting will be 435 * within another one, and only the inner-most formatting will be
436 * applied to the text. */ 436 * applied to the text. */
437 } else if (!purple_utf8_strcasecmp(root->name, "b")) { 437 } else if (!purple_utf8_strcasecmp(root->name, "b")) {
438 *begin = g_strdup_printf("<f s='%d'>", MSIM_TEXT_BOLD); 438 *begin = g_strdup_printf("<f s='%d'>", MSIM_TEXT_BOLD);
439 *end = g_strdup("</f>"); 439 *end = g_strdup("</f>");
440 } else if (!purple_utf8_strcasecmp(root->name, "i")) { 440 } else if (!purple_utf8_strcasecmp(root->name, "i")) {
441 *begin = g_strdup_printf("<f s='%d'>", MSIM_TEXT_ITALIC); 441 *begin = g_strdup_printf("<f s='%d'>", MSIM_TEXT_ITALIC);
502 502
503 *end = g_strdup("</f>"); 503 *end = g_strdup("</f>");
504 504
505 /* TODO: color (bg uses <body>), emoticons */ 505 /* TODO: color (bg uses <body>), emoticons */
506 } else { 506 } else {
507 gchar *err; 507 gchar *err;
508 508
509 #ifdef MSIM_MARKUP_SHOW_UNKNOWN_TAGS 509 #ifdef MSIM_MARKUP_SHOW_UNKNOWN_TAGS
510 *begin = g_strdup_printf("[%s]", root->name); 510 *begin = g_strdup_printf("[%s]", root->name);
511 *end = g_strdup_printf("[/%s]", root->name); 511 *end = g_strdup_printf("[/%s]", root->name);
512 #else 512 #else
513 *begin = g_strdup(""); 513 *begin = g_strdup("");
514 *end = g_strdup(""); 514 *end = g_strdup("");
515 #endif 515 #endif
516 516
517 err = g_strdup_printf("html_tag_to_msim_markup: unrecognized " 517 err = g_strdup_printf("html_tag_to_msim_markup: unrecognized "
518 "HTML tag %s was sent by the IM client; ignoring", (root->name ? root->name : "(NULL)")); 518 "HTML tag %s was sent by the IM client; ignoring", (root->name ? root->name : "(NULL)"));
519 msim_unrecognized(NULL, NULL, err); 519 msim_unrecognized(NULL, NULL, err);
520 g_free(err); 520 g_free(err);
521 } 521 }
522 } 522 }
523 523
524 /** Convert an xmlnode of msim markup or HTML to an HTML string or msim markup. 524 /** Convert an xmlnode of msim markup or HTML to an HTML string or msim markup.
525 * 525 *
593 g_string_append(final, end); 593 g_string_append(final, end);
594 594
595 purple_debug_info("msim", "msim_markup_xmlnode_to_gtkhtml: RETURNING %s\n", 595 purple_debug_info("msim", "msim_markup_xmlnode_to_gtkhtml: RETURNING %s\n",
596 (final && final->str) ? final->str : "(NULL)"); 596 (final && final->str) ? final->str : "(NULL)");
597 597
598 return g_string_free(final, FALSE); 598 return g_string_free(final, FALSE);
599 } 599 }
600 600
601 /** Convert XML to something based on MSIM_XMLNODE_CONVERT. */ 601 /** Convert XML to something based on MSIM_XMLNODE_CONVERT. */
602 static gchar * 602 static gchar *
603 msim_convert_xml(MsimSession *session, const gchar *raw, MSIM_XMLNODE_CONVERT f) 603 msim_convert_xml(MsimSession *session, const gchar *raw, MSIM_XMLNODE_CONVERT f)

mercurial