Mercurial > pidgin-twitter
changeset 44:4f456c7150ed
cleanups
author | Yoshiki Yazawa <yaz@cc.rim.or.jp> |
---|---|
date | Tue, 13 May 2008 03:42:45 +0900 |
parents | caa42301f520 |
children | 746ff3b54c10 |
files | pidgin-twitter.c |
diffstat | 1 files changed, 45 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
--- a/pidgin-twitter.c Tue May 13 02:22:05 2008 +0900 +++ b/pidgin-twitter.c Tue May 13 03:42:45 2008 +0900 @@ -35,9 +35,9 @@ #define SENDER 1 #define COMMAND 2 #define PSEUDO 3 -#define EXCESS_MARKUP 4 -#define FONT_MARKUP 5 -#define ATMARK_AFTER_A 6 +#define EXCESS_MARKUP 4 +#define FONT_MARKUP 5 +#define ATMARK_AFTER_A 6 #define PLUGIN_ID "gtk-honeyplanet-pidgin_twitter" #define PLUGIN_NAME "pidgin-twitter" @@ -91,19 +91,20 @@ static PurplePluginPrefFrame *get_plugin_pref_frame(PurplePlugin *plugin); static void init_plugin(PurplePlugin *plugin); + /* implementation */ static void strip_excess_markup(gchar **str) { gchar *newstr = NULL; - /* strip font */ + /* strip font tag */ newstr = g_regex_replace(regp[FONT_MARKUP], *str, -1, 0, "\\1", 0, NULL); twitter_debug("*str = %s newstr = %s\n", *str, newstr); g_free(*str); *str = newstr; - /* change from atmark after a to atmark before a */ + /* move @ prior to anchor tag */ newstr = g_regex_replace(regp[ATMARK_AFTER_A], *str, -1, 0, "@\\1", 0, NULL); twitter_debug("*str = %s newstr = %s\n", *str, newstr); g_free(*str); @@ -169,22 +170,23 @@ void *data) { /* check if the message is from twitter */ - if(is_twitter_account(account, recipient)) { - /* strip excess markup */ - strip_excess_markup(buffer); + if(!is_twitter_account(account, recipient)) + return FALSE; + + /* strip excess markup */ + strip_excess_markup(buffer); - /* escape pseudo command */ - if(purple_prefs_get_bool(OPT_ESCAPE_PSEUDO)) { - escape(buffer); - } + /* escape pseudo command */ + if(purple_prefs_get_bool(OPT_ESCAPE_PSEUDO)) { + escape(buffer); + } - /* try to suppress oops message */ - gint utflen = g_utf8_strlen(*buffer, -1); - gint bytes = strlen(*buffer); - twitter_debug("utflen = %d bytes = %d\n", utflen, bytes); - if(bytes > 140 && utflen <= 140) - suppress_oops = TRUE; - } + /* try to suppress oops message */ + gint utflen = g_utf8_strlen(*buffer, -1); + gint bytes = strlen(*buffer); + twitter_debug("utflen = %d bytes = %d\n", utflen, bytes); + if(bytes > 140 && utflen <= 140) + suppress_oops = TRUE; return FALSE; } @@ -271,31 +273,34 @@ PurpleConversation *conv, int *flags, void *data) { /* check if the message is from twitter */ - if(is_twitter_account(account, sender)) { - /* playsound */ - if(purple_prefs_get_bool(OPT_PLAYSOUND_SENDER)) { - playsound(buffer, SENDER); - } - if(purple_prefs_get_bool(OPT_PLAYSOUND_RECIPIENT)) { - playsound(buffer, RECIPIENT); - } + if(!is_twitter_account(account, sender)) + return FALSE; + - /* strip excess markup */ - strip_excess_markup(buffer); + /* playsound */ + if(purple_prefs_get_bool(OPT_PLAYSOUND_SENDER)) { + playsound(buffer, SENDER); + } + if(purple_prefs_get_bool(OPT_PLAYSOUND_RECIPIENT)) { + playsound(buffer, RECIPIENT); + } - /* translate */ - if(purple_prefs_get_bool(OPT_TRANSLATE_SENDER)) { - translate(buffer, SENDER); - } - if(purple_prefs_get_bool(OPT_TRANSLATE_RECIPIENT)) { - translate(buffer, RECIPIENT); - } + /* strip excess markup */ + strip_excess_markup(buffer); - /* escape pseudo command */ - if(purple_prefs_get_bool(OPT_ESCAPE_PSEUDO)) { - escape(buffer); - } + /* translate */ + if(purple_prefs_get_bool(OPT_TRANSLATE_SENDER)) { + translate(buffer, SENDER); + } + if(purple_prefs_get_bool(OPT_TRANSLATE_RECIPIENT)) { + translate(buffer, RECIPIENT); } + + /* escape pseudo command */ + if(purple_prefs_get_bool(OPT_ESCAPE_PSEUDO)) { + escape(buffer); + } + return FALSE; } @@ -522,7 +527,6 @@ regp[RECIPIENT] = g_regex_new("@([A-Za-z0-9_]+)", 0, 0, NULL); regp[SENDER] = g_regex_new("<body>([A-Za-z0-9_]+): ", 0, 0, NULL); regp[COMMAND] = -// g_regex_new("^(?:\\s*)([dDfFgGlLmMnNtTwW]{1}\\s+[A-Za-z0-9_]+\\Z)", g_regex_new("^(?:\\s*)([dDfFgGlLmMnNtTwW]{1}\\s+[A-Za-z0-9_]+)(?:\\s*\\Z)", G_REGEX_RAW, 0, NULL); regp[PSEUDO] =