# HG changeset patch # User Tim Ringenbach # Date 1087231472 0 # Node ID 66ff39319900cf142064568ac7f1beb29b64654b # Parent fe7db2ea4a1e6be859b8f24c57631e8c8a78938f [gaim-migrate @ 10086] Just some boring accessor function stuff. Move along folks. committer: Tailor Script diff -r fe7db2ea4a1e -r 66ff39319900 src/protocols/yahoo/yahoo.c --- a/src/protocols/yahoo/yahoo.c Mon Jun 14 07:06:37 2004 +0000 +++ b/src/protocols/yahoo/yahoo.c Mon Jun 14 16:44:32 2004 +0000 @@ -327,19 +327,14 @@ f->idle = time(NULL); else f->idle = 0; - if (f->status != YAHOO_STATUS_CUSTOM) { - g_free(f->msg); - f->msg = NULL; - } + if (f->status != YAHOO_STATUS_CUSTOM) + yahoo_friend_set_status_message(f, NULL); f->sms = 0; break; case 19: /* custom message */ - if (f) { - if (f->msg) - g_free(f->msg); - f->msg = yahoo_string_decode(gc, pair->value, FALSE); - } + if (f) + yahoo_friend_set_status_message(f, yahoo_string_decode(gc, pair->value, FALSE)); break; case 11: /* this is the buddy's session id */ break; @@ -678,13 +673,10 @@ if (!f) return; /* if they're not on the list, don't bother */ - if (f->game) { - g_free(f->game); - f->game = NULL; - } + yahoo_friend_set_game(f, NULL); if (*stat == '1') { - f->game = g_strdup(game); + yahoo_friend_set_game(f, game); if (bud) yahoo_update_status(gc, from, f); } @@ -2345,7 +2337,7 @@ emblems[i++] = "away"; if (f->sms) emblems[i++] = "wireless"; - if (f->game) + if (yahoo_friend_get_game(f)) emblems[i++] = "game"; } *se = emblems[0]; @@ -2419,7 +2411,8 @@ GaimConnection *gc; struct yahoo_data *yd; - char *game = NULL; + const char *game; + char *game2; char *t; char url[256]; YahooFriend *f; @@ -2434,22 +2427,23 @@ if (!f) return; - game = f->game; + game = yahoo_friend_get_game(f); if (!game) return; - t = game = g_strdup(strstr(game, "ante?room=")); - while (*t != '\t') + t = game2 = g_strdup(strstr(game, "ante?room=")); + while (*t && *t != '\t') t++; *t = 0; - g_snprintf(url, sizeof url, "http://games.yahoo.com/games/%s", game); + g_snprintf(url, sizeof url, "http://games.yahoo.com/games/%s", game2); gaim_notify_uri(gc, url); - g_free(game); + g_free(game2); } static char *yahoo_status_text(GaimBuddy *b) { YahooFriend *f = NULL; + const char *msg; f = yahoo_friend_find(b->account->gc, b->name); if (!f) @@ -2463,9 +2457,9 @@ return g_strdup(yahoo_get_status_string(f->status)); return NULL; case YAHOO_STATUS_CUSTOM: - if (!f->msg) + if (!(msg = yahoo_friend_get_status_message(f))) return NULL; - return g_markup_escape_text(f->msg, strlen(f->msg)); + return g_markup_escape_text(msg, strlen(msg)); default: return g_strdup(yahoo_get_status_string(f->status)); @@ -2489,9 +2483,9 @@ } return NULL; case YAHOO_STATUS_CUSTOM: - if (!f->msg) + if (!yahoo_friend_get_status_message(f)) return NULL; - status = g_strdup(f->msg); + status = g_strdup(yahoo_friend_get_status_message(f)); break; default: status = g_strdup(yahoo_get_status_string(f->status)); @@ -2583,14 +2577,11 @@ yahoo_ask_send_file_menu, NULL); m = g_list_append(m, act); - if (f->game) { - char *game = f->game; + if (yahoo_friend_get_game(f)) { + const char *game = yahoo_friend_get_game(f); char *room; char *t; - if (!game) - return m; - if (!(room = strstr(game, "&follow="))) /* skip ahead to the url */ return m; while (*room && *room != '\t') /* skip to the tab */ diff -r fe7db2ea4a1e -r 66ff39319900 src/protocols/yahoo/yahoo_friend.c --- a/src/protocols/yahoo/yahoo_friend.c Mon Jun 14 07:06:37 2004 +0000 +++ b/src/protocols/yahoo/yahoo_friend.c Mon Jun 14 16:44:32 2004 +0000 @@ -26,7 +26,7 @@ #include "yahoo_friend.h" -YahooFriend *yahoo_friend_new(void) +static YahooFriend *yahoo_friend_new(void) { YahooFriend *ret; @@ -83,6 +83,35 @@ return f->ip; } +void yahoo_friend_set_game(YahooFriend *f, const char *game) +{ + if (f->game) + g_free(f->game); + + if (game) + f->game = g_strdup(game); + else + f->game = NULL; +} + +const char *yahoo_friend_get_game(YahooFriend *f) +{ + return f->game; +} + +void yahoo_friend_set_status_message(YahooFriend *f, char *msg) +{ + if (f->msg) + g_free(f->msg); + + f->msg = msg; +} + +const char *yahoo_friend_get_status_message(YahooFriend *f) +{ + return f->msg; +} + void yahoo_friend_free(gpointer p) { YahooFriend *f = p; diff -r fe7db2ea4a1e -r 66ff39319900 src/protocols/yahoo/yahoo_friend.h --- a/src/protocols/yahoo/yahoo_friend.h Mon Jun 14 07:06:37 2004 +0000 +++ b/src/protocols/yahoo/yahoo_friend.h Mon Jun 14 16:44:32 2004 +0000 @@ -42,13 +42,19 @@ gboolean bicon_have; } YahooFriend; -YahooFriend *yahoo_friend_new(void); + YahooFriend *yahoo_friend_find(GaimConnection *gc, const char *name); YahooFriend *yahoo_friend_find_or_new(GaimConnection *gc, const char *name); void yahoo_friend_set_ip(YahooFriend *f, const char *ip); const char *yahoo_friend_get_ip(YahooFriend *f); +void yahoo_friend_set_game(YahooFriend *f, const char *game); +const char *yahoo_friend_get_game(YahooFriend *f); + +void yahoo_friend_set_status_message(YahooFriend *f, char *msg); +const char *yahoo_friend_get_status_message(YahooFriend *f); + void yahoo_friend_free(gpointer p); #endif /* _YAHOO_FRIEND_H_ */