9278
|
1 /*
|
|
2 * gaim
|
|
3 *
|
|
4 * Gaim is the legal property of its developers, whose names are too numerous
|
|
5 * to list here. Please refer to the COPYRIGHT file distributed with this
|
|
6 * source distribution.
|
|
7 *
|
|
8 * This program is free software; you can redistribute it and/or modify
|
|
9 * it under the terms of the GNU General Public License as published by
|
|
10 * the Free Software Foundation; either version 2 of the License, or
|
|
11 * (at your option) any later version.
|
|
12 *
|
|
13 * This program is distributed in the hope that it will be useful,
|
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16 * GNU General Public License for more details.
|
|
17 *
|
|
18 * You should have received a copy of the GNU General Public License
|
|
19 * along with this program; if not, write to the Free Software
|
|
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
21 *
|
|
22 */
|
|
23
|
|
24 #include "prpl.h"
|
9279
|
25 #include "util.h"
|
9278
|
26
|
|
27 #include "yahoo_friend.h"
|
|
28
|
9283
|
29 static YahooFriend *yahoo_friend_new(void)
|
9278
|
30 {
|
|
31 YahooFriend *ret;
|
|
32
|
|
33 ret = g_new0(YahooFriend, 1);
|
|
34 ret->status = YAHOO_STATUS_OFFLINE;
|
|
35
|
|
36 return ret;
|
|
37 }
|
|
38
|
9279
|
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
|
9281
|
74 void yahoo_friend_set_ip(YahooFriend *f, const char *ip)
|
|
75 {
|
|
76 if (f->ip)
|
|
77 g_free(f->ip);
|
|
78 f->ip = g_strdup(ip);
|
|
79 }
|
|
80
|
|
81 const char *yahoo_friend_get_ip(YahooFriend *f)
|
|
82 {
|
|
83 return f->ip;
|
|
84 }
|
|
85
|
9283
|
86 void yahoo_friend_set_game(YahooFriend *f, const char *game)
|
|
87 {
|
|
88 if (f->game)
|
|
89 g_free(f->game);
|
|
90
|
|
91 if (game)
|
|
92 f->game = g_strdup(game);
|
|
93 else
|
|
94 f->game = NULL;
|
|
95 }
|
|
96
|
|
97 const char *yahoo_friend_get_game(YahooFriend *f)
|
|
98 {
|
|
99 return f->game;
|
|
100 }
|
|
101
|
|
102 void yahoo_friend_set_status_message(YahooFriend *f, char *msg)
|
|
103 {
|
|
104 if (f->msg)
|
|
105 g_free(f->msg);
|
|
106
|
|
107 f->msg = msg;
|
|
108 }
|
|
109
|
|
110 const char *yahoo_friend_get_status_message(YahooFriend *f)
|
|
111 {
|
|
112 return f->msg;
|
|
113 }
|
|
114
|
9278
|
115 void yahoo_friend_free(gpointer p)
|
|
116 {
|
|
117 YahooFriend *f = p;
|
|
118 if (f->msg)
|
|
119 g_free(f->msg);
|
|
120 if (f->game)
|
|
121 g_free(f->game);
|
9282
|
122 if (f->ip)
|
|
123 g_free(f->ip);
|
9278
|
124 g_free(f);
|
|
125 }
|