Mercurial > pidgin.yaz
diff src/protocols/yahoo/yahoo_friend.c @ 9279:1eaa4d8dcf26
[gaim-migrate @ 10082]
Some more cleanups.
Add some yahoo_friend_* functions and made yahoo use them.
I may eventually make the structure opque.
committer: Tailor Script <tailor@pidgin.im>
author | Tim Ringenbach <marv@pidgin.im> |
---|---|
date | Mon, 14 Jun 2004 05:47:41 +0000 |
parents | 2401a9ef74a0 |
children | adde46ad65e9 |
line wrap: on
line diff
--- a/src/protocols/yahoo/yahoo_friend.c Mon Jun 14 04:51:14 2004 +0000 +++ b/src/protocols/yahoo/yahoo_friend.c Mon Jun 14 05:47:41 2004 +0000 @@ -22,6 +22,7 @@ */ #include "prpl.h" +#include "util.h" #include "yahoo_friend.h" @@ -35,6 +36,41 @@ return ret; } +YahooFriend *yahoo_friend_find(GaimConnection *gc, const char *name) +{ + struct yahoo_data *yd; + const char *norm; + + g_return_val_if_fail(gc != NULL, NULL); + g_return_val_if_fail(gc->proto_data != NULL, NULL); + + yd = gc->proto_data; + norm = gaim_normalize(gaim_connection_get_account(gc), name); + + return g_hash_table_lookup(yd->friends, norm); +} + +YahooFriend *yahoo_friend_find_or_new(GaimConnection *gc, const char *name) +{ + YahooFriend *f; + struct yahoo_data *yd; + const char *norm; + + g_return_val_if_fail(gc != NULL, NULL); + g_return_val_if_fail(gc->proto_data != NULL, NULL); + + yd = gc->proto_data; + norm = gaim_normalize(gaim_connection_get_account(gc), name); + + f = g_hash_table_lookup(yd->friends, norm); + if (!f) { + f = yahoo_friend_new(); + g_hash_table_insert(yd->friends, g_strdup(norm), f); + } + + return f; +} + void yahoo_friend_free(gpointer p) { YahooFriend *f = p;