comparison 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
comparison
equal deleted inserted replaced
9278:2401a9ef74a0 9279:1eaa4d8dcf26
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 * 21 *
22 */ 22 */
23 23
24 #include "prpl.h" 24 #include "prpl.h"
25 #include "util.h"
25 26
26 #include "yahoo_friend.h" 27 #include "yahoo_friend.h"
27 28
28 YahooFriend *yahoo_friend_new(void) 29 YahooFriend *yahoo_friend_new(void)
29 { 30 {
33 ret->status = YAHOO_STATUS_OFFLINE; 34 ret->status = YAHOO_STATUS_OFFLINE;
34 35
35 return ret; 36 return ret;
36 } 37 }
37 38
39 YahooFriend *yahoo_friend_find(GaimConnection *gc, const char *name)
40 {
41 struct yahoo_data *yd;
42 const char *norm;
43
44 g_return_val_if_fail(gc != NULL, NULL);
45 g_return_val_if_fail(gc->proto_data != NULL, NULL);
46
47 yd = gc->proto_data;
48 norm = gaim_normalize(gaim_connection_get_account(gc), name);
49
50 return g_hash_table_lookup(yd->friends, norm);
51 }
52
53 YahooFriend *yahoo_friend_find_or_new(GaimConnection *gc, const char *name)
54 {
55 YahooFriend *f;
56 struct yahoo_data *yd;
57 const char *norm;
58
59 g_return_val_if_fail(gc != NULL, NULL);
60 g_return_val_if_fail(gc->proto_data != NULL, NULL);
61
62 yd = gc->proto_data;
63 norm = gaim_normalize(gaim_connection_get_account(gc), name);
64
65 f = g_hash_table_lookup(yd->friends, norm);
66 if (!f) {
67 f = yahoo_friend_new();
68 g_hash_table_insert(yd->friends, g_strdup(norm), f);
69 }
70
71 return f;
72 }
73
38 void yahoo_friend_free(gpointer p) 74 void yahoo_friend_free(gpointer p)
39 { 75 {
40 YahooFriend *f = p; 76 YahooFriend *f = p;
41 if (f->msg) 77 if (f->msg)
42 g_free(f->msg); 78 g_free(f->msg);