Mercurial > pidgin
changeset 17956:60f40fc52aa4
Support emoticons on incoming messages, approximating MySpaceIM's smileys
with Pidgin's.
author | Jeffrey Connelly <jaconnel@calpoly.edu> |
---|---|
date | Thu, 19 Jul 2007 05:52:10 +0000 |
parents | 9e8943111022 |
children | 3bd88cbdd204 |
files | libpurple/protocols/myspace/myspace.c |
diffstat | 1 files changed, 36 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/myspace/myspace.c Thu Jul 19 04:33:40 2007 +0000 +++ b/libpurple/protocols/myspace/myspace.c Thu Jul 19 05:52:10 2007 +0000 @@ -119,8 +119,8 @@ /* Replacement codes to be replaced with associated replacement text, * used for protocol message escaping / unescaping. */ -static gchar* msim_replacement_code[] = { "/1", "/2", "/3", NULL }; -static gchar* msim_replacement_text[] = { "/", "\\", "|", NULL }; +static gchar* msim_replacement_code[] = { "/1", "/2", /* "/3", */ NULL }; +static gchar* msim_replacement_text[] = { "/", "\\", /* "|", */ NULL }; /** * Unescape or escape a protocol message. @@ -861,12 +861,32 @@ *end = g_strdup("</p>"); } -/** Convert the msim markup <i> tag (emoticon image) into HTML. TODO: Test */ +/** Convert the msim markup <i> tag (emoticon image) into HTML. */ static void msim_markup_i_to_html(MsimSession *session, xmlnode *root, gchar **begin, gchar **end) { const gchar *name; - + guint i; + + /* Based on Miranda plugin by Scott Ellis, formatting.cpp, + * https://server.scottellis.com.au/websvn/filedetails.php?repname=Miranda+Plugins&path=%2FMySpace%2Fformatting.cpp&rev=0&sc=0 */ + + static const char *words[] = { + "happi", /* ??? */ + "bigsmile", "growl", "mad", "scared", "tongue", + "devil", "happy", "messed", "sidefrown", "upset", + "frazzled", "heart", "nerd", "sinister", "wink", /* wink doesn't work */ + "geek", "laugh", "oops", "smirk", "worried", + "googles", "mohawk", "pirate", "straight", "kiss"}; + + static const char *symbols[] = { + ":-)", + ":D", ">:o", ":-[", "=-O", ":p", + "O:-)" /*:)*/, ":)", "8-)", ":-$", ":-$", + ":-/", ";-)", "8-)" /*:)*/, ":-D", ";-)", + ":-X", ":-D", ":-/", "8-)", ":(", + "8-)", ":-X", ":-)", ":-$", ":-*"}; + name = xmlnode_get_attrib(root, "n"); if (!name) { @@ -877,15 +897,18 @@ return; } - /* TODO: Support these emoticons: - * - * bigsmile growl mad scared tongue devil happy messed sidefrown upset - * frazzled heart nerd sinister wink geek laugh oops smirk worried - * googles mohawk pirate straight kiss - */ - - *begin = g_strdup_printf("<img id='%s'>", name); - *end = g_strdup("</p>"); + for (i = 0; i < sizeof(words) / sizeof(words[0]); ++i) + { + if (!strcmp(name, words[i])) + { + *begin = g_strdup(symbols[i]); + *end = g_strdup(""); + return; + } + } + + *begin = g_strdup(name); + *end = g_strdup(""); } /** Convert an individual msim markup tag to HTML. */