annotate src/protocols/yahoo/yahoo_friend.c @ 9283:66ff39319900

[gaim-migrate @ 10086] Just some boring accessor function stuff. Move along folks. committer: Tailor Script <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Mon, 14 Jun 2004 16:44:32 +0000
parents fe7db2ea4a1e
children fe0291162312
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
9283
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
29 static YahooFriend *yahoo_friend_new(void)
9278
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
9281
adde46ad65e9 [gaim-migrate @ 10084]
Tim Ringenbach <marv@pidgin.im>
parents: 9279
diff changeset
74 void yahoo_friend_set_ip(YahooFriend *f, const char *ip)
adde46ad65e9 [gaim-migrate @ 10084]
Tim Ringenbach <marv@pidgin.im>
parents: 9279
diff changeset
75 {
adde46ad65e9 [gaim-migrate @ 10084]
Tim Ringenbach <marv@pidgin.im>
parents: 9279
diff changeset
76 if (f->ip)
adde46ad65e9 [gaim-migrate @ 10084]
Tim Ringenbach <marv@pidgin.im>
parents: 9279
diff changeset
77 g_free(f->ip);
adde46ad65e9 [gaim-migrate @ 10084]
Tim Ringenbach <marv@pidgin.im>
parents: 9279
diff changeset
78 f->ip = g_strdup(ip);
adde46ad65e9 [gaim-migrate @ 10084]
Tim Ringenbach <marv@pidgin.im>
parents: 9279
diff changeset
79 }
adde46ad65e9 [gaim-migrate @ 10084]
Tim Ringenbach <marv@pidgin.im>
parents: 9279
diff changeset
80
adde46ad65e9 [gaim-migrate @ 10084]
Tim Ringenbach <marv@pidgin.im>
parents: 9279
diff changeset
81 const char *yahoo_friend_get_ip(YahooFriend *f)
adde46ad65e9 [gaim-migrate @ 10084]
Tim Ringenbach <marv@pidgin.im>
parents: 9279
diff changeset
82 {
adde46ad65e9 [gaim-migrate @ 10084]
Tim Ringenbach <marv@pidgin.im>
parents: 9279
diff changeset
83 return f->ip;
adde46ad65e9 [gaim-migrate @ 10084]
Tim Ringenbach <marv@pidgin.im>
parents: 9279
diff changeset
84 }
adde46ad65e9 [gaim-migrate @ 10084]
Tim Ringenbach <marv@pidgin.im>
parents: 9279
diff changeset
85
9283
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
86 void yahoo_friend_set_game(YahooFriend *f, const char *game)
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
87 {
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
88 if (f->game)
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
89 g_free(f->game);
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
90
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
91 if (game)
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
92 f->game = g_strdup(game);
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
93 else
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
94 f->game = NULL;
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
95 }
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
96
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
97 const char *yahoo_friend_get_game(YahooFriend *f)
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
98 {
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
99 return f->game;
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
100 }
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
101
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
102 void yahoo_friend_set_status_message(YahooFriend *f, char *msg)
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
103 {
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
104 if (f->msg)
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
105 g_free(f->msg);
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
106
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
107 f->msg = msg;
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
108 }
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
109
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
110 const char *yahoo_friend_get_status_message(YahooFriend *f)
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
111 {
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
112 return f->msg;
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
113 }
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
114
9278
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
115 void yahoo_friend_free(gpointer p)
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
116 {
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
117 YahooFriend *f = p;
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
118 if (f->msg)
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
119 g_free(f->msg);
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
120 if (f->game)
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
121 g_free(f->game);
9282
fe7db2ea4a1e [gaim-migrate @ 10085]
Tim Ringenbach <marv@pidgin.im>
parents: 9281
diff changeset
122 if (f->ip)
fe7db2ea4a1e [gaim-migrate @ 10085]
Tim Ringenbach <marv@pidgin.im>
parents: 9281
diff changeset
123 g_free(f->ip);
9278
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
124 g_free(f);
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
125 }