# HG changeset patch # User Yoshiki Yazawa # Date 1218531696 -32400 # Node ID 6c6fe6375ce478bbe3ef377a2fb885d336df44de # Parent 67d8eaba446d8d64ff0fc9d3a14309204283dff2 revised identi.ca tag support. diff -r 67d8eaba446d -r 6c6fe6375ce4 pidgin-twitter.c --- 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, diff -r 67d8eaba446d -r 6c6fe6375ce4 pidgin-twitter.h --- 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%s: " #define CHANNEL_FORMAT_WASSR "%s%s " #define CHANNEL_FORMAT_IDENTICA "%s%s " +#define TAG_FORMAT_IDENTICA "#%s" + #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 "" @@ -145,6 +148,8 @@ #define P_IMAGE_TWITTER "" #define P_IMAGE_WASSR "
" #define P_IMAGE_IDENTICA "\"[A-Za-z0-0_]+\"/" +#define P_TAG_IDENTICA "#([A-Za-z0-9]+)" + /* twitter API specific macros */ #define TWITTER_BASE_URL "http://twitter.com"