Mercurial > pidgin-twitter
changeset 97:24ad534e438e
linkfy #channelname per user configuration.
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Thu, 10 Jul 2008 19:41:26 +0900 |
parents | 987607b5ba32 |
children | e460e1978ca3 |
files | pidgin-twitter.c pidgin-twitter.h |
diffstat | 2 files changed, 25 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/pidgin-twitter.c Thu Jul 10 17:31:19 2008 +0900 +++ b/pidgin-twitter.c Thu Jul 10 19:41:26 2008 +0900 @@ -21,7 +21,7 @@ #include "pidgin-twitter.h" /* globals */ -static GRegex *regp[7]; +static GRegex *regp[8]; static gboolean suppress_oops = FALSE; static GHashTable *icon_data_by_user = NULL; static GHashTable *icon_data_by_user2 = NULL; @@ -556,6 +556,14 @@ g_free(match1); g_free(match2); } + else if(service == wassr_service && which == CHANNEL) { + gchar *match = g_match_info_fetch(match_info, 1); + const gchar *format = CHANNEL_FORMAT_WASSR; + + snprintf(sub, 128, format, match, match); + + g_free(match); + } g_string_append(result, sub); twitter_debug("sub = %s\n", sub); @@ -567,7 +575,6 @@ translate(gchar **str, gint which, gint service) { gchar *newstr; - eval_data *data = g_new0(eval_data, 1); data->which = which; @@ -675,6 +682,10 @@ if(purple_prefs_get_bool(OPT_TRANSLATE_RECIPIENT)) { translate(buffer, RECIPIENT, service); } + if(service == wassr_service && + purple_prefs_get_bool(OPT_TRANSLATE_CHANNEL)) { + translate(buffer, CHANNEL, service); + } /* escape pseudo command (to show same result to sending message) */ if(is_twitter_conv(conv) && purple_prefs_get_bool(OPT_ESCAPE_PSEUDO)) { @@ -1689,6 +1700,8 @@ regp[USER] = g_regex_new(P_USER, 0, 0, NULL); regp[USER_FIRST_LINE] = g_regex_new(P_USER_FIRST_LINE, 0, 0, NULL); regp[USER_FORMATTED] = g_regex_new(P_USER_FORMATTED, G_REGEX_RAW, 0, NULL); + regp[CHANNEL] = g_regex_new(P_CHANNEL, 0, 0, NULL); + icon_data_by_user = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); @@ -1763,6 +1776,7 @@ g_regex_unref(regp[USER]); g_regex_unref(regp[USER_FIRST_LINE]); g_regex_unref(regp[USER_FORMATTED]); + g_regex_unref(regp[CHANNEL]); /* remove mark list in each hash entry */ g_hash_table_foreach(icon_data_by_user, (GHFunc)remove_marks_func, NULL); @@ -1826,6 +1840,10 @@ "Translate sender name to link"); purple_plugin_pref_frame_add(frame, pref); + pref = purple_plugin_pref_new_with_name_and_label(OPT_TRANSLATE_CHANNEL, + "Translate channel name to link (wassr only)"); + purple_plugin_pref_frame_add(frame, pref); + /*************************/ /* miscellaneous heading */ @@ -1995,6 +2013,7 @@ purple_prefs_add_none(OPT_PIDGINTWITTER); purple_prefs_add_bool(OPT_TRANSLATE_RECIPIENT, TRUE); purple_prefs_add_bool(OPT_TRANSLATE_SENDER, TRUE); + purple_prefs_add_bool(OPT_TRANSLATE_CHANNEL, TRUE); purple_prefs_add_bool(OPT_ESCAPE_PSEUDO, TRUE); purple_prefs_add_bool(OPT_PLAYSOUND_RECIPIENT, TRUE);
--- a/pidgin-twitter.h Thu Jul 10 17:31:19 2008 +0900 +++ b/pidgin-twitter.h Thu Jul 10 19:41:26 2008 +0900 @@ -24,6 +24,7 @@ #define USER 4 #define USER_FIRST_LINE 5 #define USER_FORMATTED 6 +#define CHANNEL 7 #define PLUGIN_ID "gtk-honeyplanet-pidgin_twitter" #define PLUGIN_NAME "pidgin-twitter" @@ -32,6 +33,7 @@ #define OPT_PIDGINTWITTER "/plugins/pidgin_twitter" #define OPT_TRANSLATE_RECIPIENT OPT_PIDGINTWITTER "/translate_recipient" #define OPT_TRANSLATE_SENDER OPT_PIDGINTWITTER "/translate_sender" +#define OPT_TRANSLATE_CHANNEL OPT_PIDGINTWITTER "/translate_channel" #define OPT_PLAYSOUND_RECIPIENT OPT_PIDGINTWITTER "/playsound_recipient" #define OPT_PLAYSOUND_SENDER OPT_PIDGINTWITTER "/playsound_sender" #define OPT_SOUNDID_RECIPIENT OPT_PIDGINTWITTER "/soundid_recipient" @@ -57,6 +59,7 @@ #define DEFAULT_LIST "(list of users: separated with ' ,:;')" #define OOPS_MESSAGE "<body>Oops! Your update was over 140 characters. We sent the short version to your friends (they can view the entire update on the web).<BR></body>" #define EMPTY "" +#define CHANNEL_FORMAT_WASSR "#<a href='http://wassr.jp/channel/%s'>%s</a> " /* patterns */ #define P_RECIPIENT "@([A-Za-z0-9_]+)" @@ -66,6 +69,7 @@ #define P_USER "^\\(.+?\\)\\s*([A-Za-z0-9_]+):" #define P_USER_FIRST_LINE "^\\(.+?\\)\\s*.+:\\s*([A-Za-z0-9_]+):" #define P_USER_FORMATTED "^.*?<a .+?>([A-Za-z0-9_]+)</a>:" +#define P_CHANNEL "^.*?<a .+?>(?:[A-Za-z0-9_]+)</a>: #([A-Za-z0-9_]+) " /* debug macros */ #define twitter_debug(fmt, ...) purple_debug(PURPLE_DEBUG_INFO, PLUGIN_NAME, "%s():%4d: " fmt, __FUNCTION__, (int)__LINE__, ## __VA_ARGS__);