changeset 203:6c6fe6375ce4

revised identi.ca tag support.
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Tue, 12 Aug 2008 18:01:36 +0900
parents 67d8eaba446d
children d66ad3343119
files pidgin-twitter.c pidgin-twitter.h
diffstat 2 files changed, 18 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin-twitter.c	Tue Aug 12 17:26:40 2008 +0900
+++ b/pidgin-twitter.c	Tue Aug 12 18:01:36 2008 +0900
@@ -24,7 +24,7 @@
 /***********/
 /* globals */
 /***********/
-#define NUM_REGPS 11
+#define NUM_REGPS 12
 #define NUM_SERVICES 3          /* twitter, wassr, identica. */
 static GRegex *regp[NUM_REGPS];
 static gboolean suppress_oops = FALSE;
@@ -881,7 +881,7 @@
         g_free(match1);
         g_free(match2);
     }
-    else if(which == CHANNEL && service == wassr_service) {
+    else if(which == CHANNEL_WASSR && service == wassr_service) {
         gchar *match1 = g_match_info_fetch(match_info, 1); /*before channel*/
         gchar *match2 = g_match_info_fetch(match_info, 2); /* channel */
         const gchar *format = CHANNEL_FORMAT_WASSR;
@@ -891,15 +891,11 @@
         g_free(match1);
         g_free(match2);
     }
-    else if(which == CHANNEL && service == identica_service) {
-        gchar *match1 = g_match_info_fetch(match_info, 1); /*before channel*/
-        gchar *match2 = g_match_info_fetch(match_info, 2); /* channel */
-        const gchar *format = CHANNEL_FORMAT_IDENTICA;
-
-        g_snprintf(sub, 128, format, match1 ? match1: "", match2, match2);
-
-        g_free(match1);
-        g_free(match2);
+    else if(which == TAG_IDENTICA && service == identica_service) {
+        gchar *match = g_match_info_fetch(match_info, 1);
+        const gchar *format = TAG_FORMAT_IDENTICA;
+        g_snprintf(sub, 128, format, match, match);
+        g_free(match);
     }
 
     g_string_append(result, sub);
@@ -1036,11 +1032,11 @@
     }
     if(service == wassr_service &&
        purple_prefs_get_bool(OPT_TRANSLATE_CHANNEL)) {
-        translate(buffer, CHANNEL, service);
+        translate(buffer, CHANNEL_WASSR, service);
     }
     if(service == identica_service &&
        purple_prefs_get_bool(OPT_TRANSLATE_CHANNEL)) {
-        translate(buffer, CHANNEL, service);
+        translate(buffer, TAG_IDENTICA, service);
     }
 
     /* escape pseudo command (to show same result to sending message) */
@@ -2425,10 +2421,11 @@
     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);
+    regp[CHANNEL_WASSR]  = g_regex_new(P_CHANNEL, 0, 0, NULL);
     regp[IMAGE_TWITTER]  = g_regex_new(P_IMAGE_TWITTER, 0, 0, NULL);
     regp[IMAGE_WASSR]    = g_regex_new(P_IMAGE_WASSR, 0, 0, NULL);
     regp[IMAGE_IDENTICA] = g_regex_new(P_IMAGE_IDENTICA, 0, 0, NULL);
+    regp[TAG_IDENTICA]   = g_regex_new(P_TAG_IDENTICA, 0, 0, NULL);
 
     for(i = twitter_service; i < NUM_SERVICES; i++) {
         icon_hash[i] = g_hash_table_new_full(g_str_hash, g_str_equal,
--- a/pidgin-twitter.h	Tue Aug 12 17:26:40 2008 +0900
+++ b/pidgin-twitter.h	Tue Aug 12 18:01:36 2008 +0900
@@ -33,10 +33,11 @@
     USER,
     USER_FIRST_LINE,
     USER_FORMATTED,
-    CHANNEL,
+    CHANNEL_WASSR,
     IMAGE_TWITTER,
     IMAGE_WASSR,
-    IMAGE_IDENTICA
+    IMAGE_IDENTICA,
+    TAG_IDENTICA
 };
 
 /* service id */
@@ -129,6 +130,8 @@
 #define SENDER_FORMAT_IDENTICA  "%s<a href='http://identi.ca/%s'>%s</a>: "
 #define CHANNEL_FORMAT_WASSR    "%s<a href='http://wassr.jp/channel/%s'>%s</a> "
 #define CHANNEL_FORMAT_IDENTICA "%s<a href='http://identi.ca/tag/%s'>%s</a> "
+#define TAG_FORMAT_IDENTICA     "#<a href='http://identi.ca/tag/%s'>%s</a>"
+
 #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                   ""
@@ -145,6 +148,8 @@
 #define P_IMAGE_TWITTER     "<a href=\"/account/profile_image/.+?\"><img .+? id=\"profile-image\".*src=\"(http://.+)\" .+?/>"
 #define P_IMAGE_WASSR       "<div class=\"image\"><a href=\".+\"><img src=\"(.+)\" width=\".+?\" /></a></div>"
 #define P_IMAGE_IDENTICA    "<img src=\"(http://avatar.identi.ca/[A-Za-z0-9-.]+)\" class=\"avatar profile\" width=\"96\" height=\"96\" alt=\"[A-Za-z0-0_]+\"/>"
+#define P_TAG_IDENTICA      "#([A-Za-z0-9]+)"
+
 
 /* twitter API specific macros */
 #define TWITTER_BASE_URL "http://twitter.com"