comparison pidgin-twitter.c @ 122:a37dd74c8355

- adapted to identi.ca changes. - try to get rid of variable 'timezone'.
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Fri, 18 Jul 2008 18:19:58 +0900
parents 8b58990f5ee9
children 76012df4e194
comparison
equal deleted inserted replaced
121:8b58990f5ee9 122:a37dd74c8355
21 #include "pidgin-twitter.h" 21 #include "pidgin-twitter.h"
22 22
23 /***********/ 23 /***********/
24 /* globals */ 24 /* globals */
25 /***********/ 25 /***********/
26 static GRegex *regp[9]; 26 #define NUM_REGP 9
27 static GRegex *regp[NUM_REGP];
27 static gboolean suppress_oops = FALSE; 28 static gboolean suppress_oops = FALSE;
28 static GHashTable *icon_data_by_user = NULL; // twitter 29 static GHashTable *icon_data_by_user = NULL; // twitter
29 static GHashTable *icon_data_by_user2 = NULL; // wassr 30 static GHashTable *icon_data_by_user2 = NULL; // wassr
30 static GHashTable *icon_data_by_user3 = NULL; // identi.ca 31 static GHashTable *icon_data_by_user3 = NULL; // identi.ca
31 static GHashTable *conv_hash = NULL; 32 static GHashTable *conv_hash = NULL;
311 /* read time stamp */ 312 /* read time stamp */
312 struct tm res; 313 struct tm res;
313 memset(&res, 0x00, sizeof(struct tm)); 314 memset(&res, 0x00, sizeof(struct tm));
314 strptime(str, "%a %b %d %T %z %Y", &res); 315 strptime(str, "%a %b %d %T %z %Y", &res);
315 tzset(); 316 tzset();
316 st->time = mktime(&res) - timezone; 317 st->time = mktime(&res) - res.tm_gmtoff;
317 318
318 /* restore locale */ 319 /* restore locale */
319 setlocale(LC_TIME, lc_time); 320 setlocale(LC_TIME, lc_time);
320 321
321 xmlFree(str); 322 xmlFree(str);
789 static void 790 static void
790 translate(gchar **str, gint which, gint service) 791 translate(gchar **str, gint which, gint service)
791 { 792 {
792 gchar *newstr; 793 gchar *newstr;
793 eval_data *data = g_new0(eval_data, 1); 794 eval_data *data = g_new0(eval_data, 1);
795 gint regp_id;
794 796
795 data->which = which; 797 data->which = which;
796 data->service = service; 798 data->service = service;
797 799
798 newstr = g_regex_replace_eval(regp[which], // compiled regex 800 regp_id = which; /* for future use --yaz */
801 newstr = g_regex_replace_eval(regp[regp_id], // compiled regex
799 *str, // subject string 802 *str, // subject string
800 -1, // length of the subject string 803 -1, // length of the subject string
801 0, // start position 804 0, // start position
802 0, // match options 805 0, // match options
803 eval, // function to be called for each match 806 eval, // function to be called for each match
891 *buffer = m; 894 *buffer = m;
892 } 895 }
893 } 896 }
894 897
895 /* strip all markups */ 898 /* strip all markups */
896 strip_markup(buffer); // it causes missing of strings surrounded by <> 899 strip_markup(buffer); //it causes missing of strings surrounded by <>
897 900
898 /* playsound */ 901 /* playsound */
899 if(purple_prefs_get_bool(OPT_PLAYSOUND_SENDER)) { 902 if(purple_prefs_get_bool(OPT_PLAYSOUND_SENDER)) {
900 playsound(buffer, SENDER); 903 playsound(buffer, SENDER);
901 } 904 }
2251 purple_signal_disconnect(purple_connections_get_handle(), 2254 purple_signal_disconnect(purple_connections_get_handle(),
2252 "signed-on", 2255 "signed-on",
2253 plugin, PURPLE_CALLBACK(signed_on_cb)); 2256 plugin, PURPLE_CALLBACK(signed_on_cb));
2254 2257
2255 /* unreference regp */ 2258 /* unreference regp */
2256 g_regex_unref(regp[RECIPIENT]); 2259 int i;
2257 g_regex_unref(regp[SENDER]); 2260 for(i = 0; i < NUM_REGP; i++) {
2258 g_regex_unref(regp[COMMAND]); 2261 g_regex_unref(regp[i]);
2259 g_regex_unref(regp[PSEUDO]); 2262 }
2260 g_regex_unref(regp[USER]);
2261 g_regex_unref(regp[USER_FIRST_LINE]);
2262 g_regex_unref(regp[USER_FORMATTED]);
2263 g_regex_unref(regp[CHANNEL]);
2264 g_regex_unref(regp[IMAGE_IDENTICA]);
2265 2263
2266 /* remove mark list in each hash entry */ 2264 /* remove mark list in each hash entry */
2267 g_hash_table_foreach(icon_data_by_user, (GHFunc)remove_marks_func, NULL); 2265 g_hash_table_foreach(icon_data_by_user, (GHFunc)remove_marks_func, NULL);
2268 g_hash_table_foreach(icon_data_by_user2, (GHFunc)remove_marks_func, NULL); 2266 g_hash_table_foreach(icon_data_by_user2, (GHFunc)remove_marks_func, NULL);
2269 g_hash_table_foreach(icon_data_by_user3, (GHFunc)remove_marks_func, NULL); 2267 g_hash_table_foreach(icon_data_by_user3, (GHFunc)remove_marks_func, NULL);