annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9278
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
1 /*
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
2 * gaim
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
3 *
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
4 * Gaim is the legal property of its developers, whose names are too numerous
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
6 * source distribution.
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
7 *
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
11 * (at your option) any later version.
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
12 *
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
16 * GNU General Public License for more details.
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
17 *
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
21 *
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
22 */
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
23
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
24 #include "prpl.h"
9279
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
25 #include "util.h"
9278
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
26
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
27 #include "yahoo_friend.h"
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
28
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
29 YahooFriend *yahoo_friend_new(void)
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
30 {
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
31 YahooFriend *ret;
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
32
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
33 ret = g_new0(YahooFriend, 1);
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
34 ret->status = YAHOO_STATUS_OFFLINE;
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
35
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
36 return ret;
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
37 }
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
38
9279
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
39 YahooFriend *yahoo_friend_find(GaimConnection *gc, const char *name)
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
40 {
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
41 struct yahoo_data *yd;
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
42 const char *norm;
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
43
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
44 g_return_val_if_fail(gc != NULL, NULL);
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
45 g_return_val_if_fail(gc->proto_data != NULL, NULL);
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
46
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
47 yd = gc->proto_data;
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
48 norm = gaim_normalize(gaim_connection_get_account(gc), name);
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
49
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
50 return g_hash_table_lookup(yd->friends, norm);
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
51 }
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
52
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
53 YahooFriend *yahoo_friend_find_or_new(GaimConnection *gc, const char *name)
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
54 {
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
55 YahooFriend *f;
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
56 struct yahoo_data *yd;
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
57 const char *norm;
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
58
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
59 g_return_val_if_fail(gc != NULL, NULL);
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
60 g_return_val_if_fail(gc->proto_data != NULL, NULL);
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
61
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
62 yd = gc->proto_data;
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
63 norm = gaim_normalize(gaim_connection_get_account(gc), name);
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
64
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
65 f = g_hash_table_lookup(yd->friends, norm);
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
66 if (!f) {
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
67 f = yahoo_friend_new();
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
68 g_hash_table_insert(yd->friends, g_strdup(norm), f);
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
69 }
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
70
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
71 return f;
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
72 }
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
73
9278
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
74 void yahoo_friend_free(gpointer p)
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
75 {
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
76 YahooFriend *f = p;
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
77 if (f->msg)
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
78 g_free(f->msg);
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
79 if (f->game)
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
80 g_free(f->game);
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
81 g_free(f);
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
82 }