diff pidgin-twitter.c @ 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
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);