comparison pidgin-twitter.c @ 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 1495b478680b
children 85484ddf8823
comparison
equal deleted inserted replaced
195:3e459b078788 196:b436d72447e8
22 22
23 23
24 /***********/ 24 /***********/
25 /* globals */ 25 /* globals */
26 /***********/ 26 /***********/
27 #define NUM_REGP 10 27 #define NUM_REGPS 11
28 #define NUM_SERVICES 4 /* twitter, wassr, identica, jisko. */ 28 #define NUM_SERVICES 4 /* twitter, wassr, identica, jisko. */
29 static GRegex *regp[NUM_REGP]; 29 static GRegex *regp[NUM_REGPS];
30 static gboolean suppress_oops = FALSE; 30 static gboolean suppress_oops = FALSE;
31 static GHashTable *icon_hash[NUM_SERVICES]; 31 static GHashTable *icon_hash[NUM_SERVICES];
32 static GHashTable *conv_hash = NULL; 32 static GHashTable *conv_hash = NULL;
33 static GList *statuseslist = NULL; 33 static GList *statuseslist = NULL;
34 static GList *postedlist = NULL; 34 static GList *postedlist = NULL;
1789 if(service == twitter_service) { 1789 if(service == twitter_service) {
1790 data = (icon_data *)g_hash_table_lookup( 1790 data = (icon_data *)g_hash_table_lookup(
1791 icon_hash[twitter_service], user_name); 1791 icon_hash[twitter_service], user_name);
1792 regp_id = IMAGE_TWITTER; 1792 regp_id = IMAGE_TWITTER;
1793 } 1793 }
1794 1794 else if(service == identica_service) {
1795 if(service == identica_service) {
1796 data = (icon_data *)g_hash_table_lookup( 1795 data = (icon_data *)g_hash_table_lookup(
1797 icon_hash[identica_service], user_name); 1796 icon_hash[identica_service], user_name);
1798 regp_id = IMAGE_IDENTICA; 1797 regp_id = IMAGE_IDENTICA;
1798 }
1799 else if(service == jisko_service) {
1800 data = (icon_data *)g_hash_table_lookup(
1801 icon_hash[jisko_service], user_name);
1802 regp_id = IMAGE_JISKO;
1799 } 1803 }
1800 1804
1801 if(!url_text) { 1805 if(!url_text) {
1802 if(data) { 1806 if(data) {
1803 data->requested = FALSE; 1807 data->requested = FALSE;
2161 break; 2165 break;
2162 case identica_service: 2166 case identica_service:
2163 url = g_strdup_printf("http://identi.ca/%s", user_name); 2167 url = g_strdup_printf("http://identi.ca/%s", user_name);
2164 break; 2168 break;
2165 case jisko_service: 2169 case jisko_service:
2166 url = g_strdup_printf("http://jisko.net/users/%s/img/avatar/thumb_side.png", 2170 url = g_strdup_printf("http://jisko.net/%s", user_name);
2167 user_name);
2168 data->img_type = "png";
2169 break; 2171 break;
2170 default: 2172 default:
2171 twitter_debug("unknown service\n"); 2173 twitter_debug("unknown service\n");
2172 break; 2174 break;
2173 } 2175 }
2177 gotdata->user_name = g_strdup(user_name); 2179 gotdata->user_name = g_strdup(user_name);
2178 gotdata->service = service; 2180 gotdata->service = service;
2179 2181
2180 /* gotdata will be released in got_icon_cb */ 2182 /* gotdata will be released in got_icon_cb */
2181 if(service == identica_service || 2183 if(service == identica_service ||
2182 service == twitter_service) { 2184 service == twitter_service ||
2185 service == jisko_service) {
2183 data->fetch_data = purple_util_fetch_url(url, TRUE, NULL, TRUE, 2186 data->fetch_data = purple_util_fetch_url(url, TRUE, NULL, TRUE,
2184 got_page_cb, gotdata); 2187 got_page_cb, gotdata);
2185 } 2188 }
2186 else { 2189 else {
2187 data->fetch_data = purple_util_fetch_url(url, TRUE, NULL, TRUE, 2190 data->fetch_data = purple_util_fetch_url(url, TRUE, NULL, TRUE,
2464 regp[USER_FIRST_LINE] = g_regex_new(P_USER_FIRST_LINE, 0, 0, NULL); 2467 regp[USER_FIRST_LINE] = g_regex_new(P_USER_FIRST_LINE, 0, 0, NULL);
2465 regp[USER_FORMATTED] = g_regex_new(P_USER_FORMATTED, G_REGEX_RAW, 0, NULL); 2468 regp[USER_FORMATTED] = g_regex_new(P_USER_FORMATTED, G_REGEX_RAW, 0, NULL);
2466 regp[CHANNEL] = g_regex_new(P_CHANNEL, 0, 0, NULL); 2469 regp[CHANNEL] = g_regex_new(P_CHANNEL, 0, 0, NULL);
2467 regp[IMAGE_IDENTICA] = g_regex_new(P_IMAGE_IDENTICA, 0, 0, NULL); 2470 regp[IMAGE_IDENTICA] = g_regex_new(P_IMAGE_IDENTICA, 0, 0, NULL);
2468 regp[IMAGE_TWITTER] = g_regex_new(P_IMAGE_TWITTER, 0, 0, NULL); 2471 regp[IMAGE_TWITTER] = g_regex_new(P_IMAGE_TWITTER, 0, 0, NULL);
2472 regp[IMAGE_JISKO] = g_regex_new(P_IMAGE_JISKO, 0, 0, NULL);
2469 2473
2470 for(i = twitter_service; i < NUM_SERVICES; i++) { 2474 for(i = twitter_service; i < NUM_SERVICES; i++) {
2471 icon_hash[i] = g_hash_table_new_full(g_str_hash, g_str_equal, 2475 icon_hash[i] = g_hash_table_new_full(g_str_hash, g_str_equal,
2472 g_free, NULL); 2476 g_free, NULL);
2473 } 2477 }
2547 purple_signal_disconnect(purple_connections_get_handle(), 2551 purple_signal_disconnect(purple_connections_get_handle(),
2548 "signed-on", 2552 "signed-on",
2549 plugin, PURPLE_CALLBACK(signed_on_cb)); 2553 plugin, PURPLE_CALLBACK(signed_on_cb));
2550 2554
2551 /* unreference regp */ 2555 /* unreference regp */
2552 for(i = 0; i < NUM_REGP; i++) { 2556 for(i = 0; i < NUM_REGPS; i++) {
2553 g_regex_unref(regp[i]); 2557 g_regex_unref(regp[i]);
2554 } 2558 }
2555 2559
2556 /* remove mark list in each hash entry */ 2560 /* remove mark list in each hash entry */
2557 /* cancel request that has not been finished yet */ 2561 /* cancel request that has not been finished yet */