Mercurial > pidgin-twitter
changeset 34:44ffbd056f33
added patch to strip excessive hyper link on @username when it copied and pasted from message window. patch by mikanbako (maoutwo@gmail.com).
author | Yoshiki Yazawa <yaz@cc.rim.or.jp> |
---|---|
date | Sat, 10 May 2008 20:18:20 +0900 |
parents | abe31282e2de |
children | 7d07fcb9c616 |
files | pidgin-twitter.c |
diffstat | 1 files changed, 19 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/pidgin-twitter.c Sat May 10 19:25:13 2008 +0900 +++ b/pidgin-twitter.c Sat May 10 20:18:20 2008 +0900 @@ -35,6 +35,7 @@ #define SENDER 1 #define COMMAND 2 #define PSEUDO 3 +#define SENDER_WITH_LINK 4 #define PLUGIN_ID "gtk-honeyplanet-pidgin_twitter" #define PLUGIN_NAME "pidgin-twitter" @@ -61,7 +62,21 @@ #define twitter_error(fmt, ...) purple_debug(PURPLE_DEBUG_ERROR, PLUGIN_NAME, \ /* globals */ -static GRegex *regp[4]; +static GRegex *regp[5]; + +static void +delete_sender_with_link(gchar **str) +{ + gchar *newstr = NULL; + + /* replace senders with link */ + newstr = g_regex_replace(regp[SENDER_WITH_LINK], *str, -1, 0, "@\\1", 0, NULL); + twitter_debug("*str = %s\n", *str); + twitter_debug("rnewstr = %s\n", newstr); + + g_free(*str); + *str = newstr; +} /* prototypes */ static gboolean is_twitter_conv(PurpleConversation *conv); @@ -134,6 +149,7 @@ if(purple_prefs_get_bool(OPT_ESCAPE_PSEUDO)) { escape(buffer); } + delete_sender_with_link(buffer); } return FALSE; } @@ -460,6 +476,7 @@ regp[PSEUDO] = g_regex_new( "^\\s*(?:[\"#$%&'()*+,\\-./:;<=>?\\[\\\\\\]_`{|}~]|[^\\s\\x21-\\x7E])*([dDfFgGlLmMnNtTwW]{1})(?:\\Z|\\s+|[^\\x21-\\x7E]+\\Z)", G_REGEX_RAW, 0, NULL); + regp[SENDER_WITH_LINK] = g_regex_new("@<a href=.+?>([A-Za-z0-9_]+?)</a>", 0, 0, NULL); /* attach counter to the existing twitter window*/ gboolean enabled = purple_prefs_get_bool(OPT_COUNTER); @@ -491,6 +508,7 @@ g_regex_unref(regp[SENDER]); g_regex_unref(regp[COMMAND]); g_regex_unref(regp[PSEUDO]); + g_regex_unref(regp[SENDER_WITH_LINK]); /* detach from twitter window */ detach_from_window();