changeset 196:b436d72447e8

make use of got_page_cb to obtain icons for jisko.
author Yoshiki Yazawa <yaz@honeyplnaet.jp>
date Sat, 09 Aug 2008 13:42:12 +0900
parents 3e459b078788
children 85484ddf8823
files pidgin-twitter.c pidgin-twitter.h
diffstat 2 files changed, 16 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin-twitter.c	Sat Aug 09 12:20:29 2008 +0900
+++ b/pidgin-twitter.c	Sat Aug 09 13:42:12 2008 +0900
@@ -24,9 +24,9 @@
 /***********/
 /* globals */
 /***********/
-#define NUM_REGP 10
+#define NUM_REGPS 11
 #define NUM_SERVICES 4          /* twitter, wassr, identica, jisko. */
-static GRegex *regp[NUM_REGP];
+static GRegex *regp[NUM_REGPS];
 static gboolean suppress_oops = FALSE;
 static GHashTable *icon_hash[NUM_SERVICES];
 static GHashTable *conv_hash = NULL;
@@ -1791,12 +1791,16 @@
             icon_hash[twitter_service], user_name);
         regp_id = IMAGE_TWITTER;
     }
-
-    if(service == identica_service) {
+    else if(service == identica_service) {
         data = (icon_data *)g_hash_table_lookup(
             icon_hash[identica_service], user_name);
         regp_id = IMAGE_IDENTICA;
     }
+    else if(service == jisko_service) {
+        data = (icon_data *)g_hash_table_lookup(
+            icon_hash[jisko_service], user_name);
+        regp_id = IMAGE_JISKO;
+    }
 
     if(!url_text) {
         if(data) {
@@ -2163,9 +2167,7 @@
         url = g_strdup_printf("http://identi.ca/%s", user_name);
         break;
     case jisko_service:
-        url = g_strdup_printf("http://jisko.net/users/%s/img/avatar/thumb_side.png",
-                              user_name);
-        data->img_type = "png";
+        url = g_strdup_printf("http://jisko.net/%s", user_name);
         break;
     default:
         twitter_debug("unknown service\n");
@@ -2179,7 +2181,8 @@
 
         /* gotdata will be released in got_icon_cb */
         if(service == identica_service ||
-           service == twitter_service) {
+           service == twitter_service ||
+           service == jisko_service) {
             data->fetch_data = purple_util_fetch_url(url, TRUE, NULL, TRUE,
                                                      got_page_cb, gotdata);
         }
@@ -2466,6 +2469,7 @@
     regp[CHANNEL]   = g_regex_new(P_CHANNEL, 0, 0, NULL);
     regp[IMAGE_IDENTICA] = g_regex_new(P_IMAGE_IDENTICA, 0, 0, NULL);
     regp[IMAGE_TWITTER]  = g_regex_new(P_IMAGE_TWITTER, 0, 0, NULL);
+    regp[IMAGE_JISKO]    = g_regex_new(P_IMAGE_JISKO, 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,
@@ -2549,7 +2553,7 @@
                              plugin, PURPLE_CALLBACK(signed_on_cb));
 
     /* unreference regp */
-    for(i = 0; i < NUM_REGP; i++) {
+    for(i = 0; i < NUM_REGPS; i++) {
         g_regex_unref(regp[i]);
     }
 
--- a/pidgin-twitter.h	Sat Aug 09 12:20:29 2008 +0900
+++ b/pidgin-twitter.h	Sat Aug 09 13:42:12 2008 +0900
@@ -35,7 +35,8 @@
     USER_FORMATTED,
     CHANNEL,
     IMAGE_IDENTICA,
-    IMAGE_TWITTER
+    IMAGE_TWITTER,
+    IMAGE_JISKO
 };
 
 /* service id */
@@ -145,6 +146,7 @@
 #define P_CHANNEL           "^(.*?<a .+?>[A-Za-z0-9_]+</a>: \\r?\\n?#)([A-Za-z0-9_]+) "
 #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_IMAGE_TWITTER     "<a href=\"/account/profile_image/.+?\"><img .+? id=\"profile-image\".*src=\"(http://.+)\" .+?/>"
+#define P_IMAGE_JISKO       "<img src=\"(http://jisko.net/users/.+/img/avatar/thumb_side\\..+)\" alt=\"Avatar\" />"
 
 /* twitter API specific macros */
 #define TWITTER_BASE_URL "http://twitter.com"