Mercurial > pidgin-twitter
diff pidgin-twitter.c @ 69:d1f92d980f58
fixed that icon had not appeard in the first message.
author | mikanbako <maoutwo@gmail.com> |
---|---|
date | Mon, 23 Jun 2008 12:18:34 +0900 |
parents | 41dbb74bf029 |
children | 74524f379440 |
line wrap: on
line diff
--- a/pidgin-twitter.c Mon Jun 23 11:49:43 2008 +0900 +++ b/pidgin-twitter.c Mon Jun 23 12:18:34 2008 +0900 @@ -22,7 +22,7 @@ #include "pidgin-twitter.h" /* globals */ -static GRegex *regp[8]; +static GRegex *regp[7]; static gboolean suppress_oops = FALSE; static GHashTable *icon_id_by_user; static GList *requested_users = NULL; @@ -661,10 +661,9 @@ twitter_debug("called\n"); twitter_debug("buffer = %s suppress_oops = %d\n", *buffer, suppress_oops); - /* request to attach icon to the buffer */ - request_icon(*buffer); - - /* check if the conv is not NULL and is a twitter conv. */ + /* Check if the conv is not NULL to avoid a clash. + * conv is null when the conversation window has not opened yet. + * And if check is a twitter conv. */ if(!(conv && is_twitter_conv(conv))) { return FALSE; } @@ -843,42 +842,11 @@ } static void -request_icon(const char *buffer) +request_icon(char *user_name) { - GMatchInfo *match_info = NULL; - gchar *user_name = NULL; - gchar *message = NULL; gchar *url = NULL; PurpleUtilFetchUrlData *fetch_data = NULL; - /* get user name */ - g_regex_match(regp[MESSAGE], buffer, 0, &match_info); - if(!g_match_info_matches(match_info)) { - twitter_debug("Message was not matched : %s\n", buffer); - g_match_info_free(match_info); - return; - } - - message = g_match_info_fetch(match_info, 1); - g_match_info_free(match_info); - match_info = NULL; - - g_regex_match(regp[SENDER], message, 0, &match_info); - if(!g_match_info_matches(match_info)) { - twitter_debug("user's name was not matched : %s\n", message); - g_match_info_free(match_info); - g_free(message); - return; - } - - user_name = g_match_info_fetch(match_info, 2); - g_match_info_free(match_info); - g_free(message); - - /***********************/ - /* request user's icon */ - /***********************/ - /* look local icon cache for the requested icon */ gchar *filename = NULL; gchar *path = NULL; @@ -887,6 +855,7 @@ /* if img has been registerd, just return */ icon_id = GPOINTER_TO_INT(g_hash_table_lookup(icon_id_by_user, user_name)); if(icon_id) { + g_free(user_name); return; } @@ -956,10 +925,7 @@ GtkTextIter inserting_point; int icon_id; - /* Check that conv is not null to avoid a clash. - * conv is null when the conversation window has not opened yet. - */ - if(!(conv && is_twitter_conv(conv))) { + if(!is_twitter_conv(conv)) { return; } @@ -993,7 +959,10 @@ text_buffer, NULL, &inserting_point, FALSE)); twitter_debug("%s's icon has not been downloaded.", user_name); - g_free(user_name); + /* request to attach icon to the buffer + * user_name is owned by the function. */ + request_icon(user_name); + /* user_name must not free */ return; } @@ -1025,7 +994,6 @@ regp[SENDER] = g_regex_new(P_SENDER, 0, 0, NULL); regp[COMMAND] = g_regex_new(P_COMMAND, G_REGEX_RAW, 0, NULL); regp[PSEUDO] = g_regex_new(P_PSEUDO, G_REGEX_RAW, 0, NULL); - regp[MESSAGE] = g_regex_new(P_MESSAGE, 0, 0, NULL); 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); @@ -1074,7 +1042,6 @@ g_regex_unref(regp[SENDER]); g_regex_unref(regp[COMMAND]); g_regex_unref(regp[PSEUDO]); - g_regex_unref(regp[MESSAGE]); g_regex_unref(regp[USER]); g_regex_unref(regp[USER_FIRST_LINE]); g_regex_unref(regp[USER_FORMATTED]);