# HG changeset patch # User Yoshiki Yazawa # Date 1215686486 -32400 # Node ID 24ad534e438e5cc21b6f7a26f077877ae1ee5bb4 # Parent 987607b5ba32d7142de9a7c3c1affa6018d3564e linkfy #channelname per user configuration. diff -r 987607b5ba32 -r 24ad534e438e pidgin-twitter.c --- 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); diff -r 987607b5ba32 -r 24ad534e438e pidgin-twitter.h --- 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 "Oops! Your update was over 140 characters. We sent the short version to your friends (they can view the entire update on the web).
" #define EMPTY "" +#define CHANNEL_FORMAT_WASSR "#%s " /* 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-Za-z0-9_]+):" +#define P_CHANNEL "^.*?(?:[A-Za-z0-9_]+): #([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__);