Mercurial > pidgin.yaz
annotate src/protocols/msn/user.c @ 6402:cc35d07a0dcc
[gaim-migrate @ 6907]
g_malloc0() -> g_new0()
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Thu, 07 Aug 2003 00:46:13 +0000 |
parents | bf2a7a7b739d |
children | b7e113a59b51 |
rev | line source |
---|---|
5309 | 1 /** |
2 * @file user.c User functions | |
3 * | |
4 * gaim | |
5 * | |
6 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org> | |
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 #include "msn.h" | |
23 #include "user.h" | |
24 | |
25 MsnUser * | |
26 msn_user_new(MsnSession *session, const char *passport, const char *name) | |
27 { | |
28 MsnUser *user; | |
29 | |
30 user = msn_users_find_with_passport(session->users, passport); | |
31 | |
5518
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
32 if (user == NULL) { |
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
33 user = g_new0(MsnUser, 1); |
5309 | 34 |
5518
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
35 user->session = session; |
5309 | 36 |
5518
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
37 msn_user_set_passport(user, passport); |
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
38 msn_user_set_group_id(user, -1); |
5309 | 39 |
5518
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
40 msn_users_add(session->users, user); |
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
41 } |
5309 | 42 |
43 if (name != NULL) | |
44 msn_user_set_name(user, name); | |
45 | |
46 msn_user_ref(user); | |
47 | |
48 return user; | |
49 } | |
50 | |
51 void | |
52 msn_user_destroy(MsnUser *user) | |
53 { | |
54 g_return_if_fail(user != NULL); | |
55 | |
56 if (user->ref_count > 0) { | |
57 msn_user_unref(user); | |
58 | |
59 return; | |
60 } | |
61 | |
62 if (user->session != NULL && user->session->users != NULL) | |
63 msn_users_remove(user->session->users, user); | |
64 | |
5475
ad9887c91a59
[gaim-migrate @ 5871]
Christian Hammond <chipx86@chipx86.com>
parents:
5363
diff
changeset
|
65 if (user->clientcaps != NULL) |
ad9887c91a59
[gaim-migrate @ 5871]
Christian Hammond <chipx86@chipx86.com>
parents:
5363
diff
changeset
|
66 g_hash_table_destroy(user->clientcaps); |
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
67 |
5363
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
68 if (user->passport != NULL) g_free(user->passport); |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
69 if (user->name != NULL) g_free(user->name); |
5309 | 70 |
5363
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
71 if (user->phone.home != NULL) g_free(user->phone.home); |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
72 if (user->phone.work != NULL) g_free(user->phone.work); |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
73 if (user->phone.mobile != NULL) g_free(user->phone.mobile); |
5309 | 74 |
75 g_free(user); | |
76 } | |
77 | |
78 MsnUser * | |
79 msn_user_ref(MsnUser *user) | |
80 { | |
81 g_return_val_if_fail(user != NULL, NULL); | |
82 | |
83 user->ref_count++; | |
84 | |
85 return user; | |
86 } | |
87 | |
88 MsnUser * | |
89 msn_user_unref(MsnUser *user) | |
90 { | |
91 g_return_val_if_fail(user != NULL, NULL); | |
92 | |
93 if (user->ref_count <= 0) | |
94 return NULL; | |
95 | |
96 user->ref_count--; | |
97 | |
98 if (user->ref_count == 0) { | |
99 msn_user_destroy(user); | |
100 | |
101 return NULL; | |
102 } | |
103 | |
104 return user; | |
105 } | |
106 | |
107 void | |
108 msn_user_set_passport(MsnUser *user, const char *passport) | |
109 { | |
110 g_return_if_fail(user != NULL); | |
111 | |
112 if (user->passport != NULL) | |
113 g_free(user->passport); | |
114 | |
115 user->passport = g_strdup(passport); | |
116 } | |
117 | |
118 void | |
119 msn_user_set_name(MsnUser *user, const char *name) | |
120 { | |
121 g_return_if_fail(user != NULL); | |
122 | |
123 if (user->name != NULL) | |
124 g_free(user->name); | |
125 | |
126 user->name = g_strdup(name); | |
127 } | |
128 | |
129 void | |
130 msn_user_set_group_id(MsnUser *user, int id) | |
131 { | |
132 g_return_if_fail(user != NULL); | |
133 | |
134 user->group_id = id; | |
135 } | |
136 | |
5363
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
137 void |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
138 msn_user_set_home_phone(MsnUser *user, const char *number) |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
139 { |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
140 g_return_if_fail(user != NULL); |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
141 |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
142 if (user->phone.home != NULL) |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
143 g_free(user->phone.home); |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
144 |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
145 user->phone.home = (number == NULL ? NULL : g_strdup(number)); |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
146 } |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
147 |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
148 void |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
149 msn_user_set_work_phone(MsnUser *user, const char *number) |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
150 { |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
151 g_return_if_fail(user != NULL); |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
152 |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
153 if (user->phone.work != NULL) |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
154 g_free(user->phone.work); |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
155 |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
156 user->phone.work = (number == NULL ? NULL : g_strdup(number)); |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
157 } |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
158 |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
159 void |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
160 msn_user_set_mobile_phone(MsnUser *user, const char *number) |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
161 { |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
162 g_return_if_fail(user != NULL); |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
163 |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
164 if (user->phone.mobile != NULL) |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
165 g_free(user->phone.mobile); |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
166 |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
167 user->phone.mobile = (number == NULL ? NULL : g_strdup(number)); |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
168 } |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
169 |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
170 |
5309 | 171 const char * |
172 msn_user_get_passport(const MsnUser *user) | |
173 { | |
174 g_return_val_if_fail(user != NULL, NULL); | |
175 | |
176 return user->passport; | |
177 } | |
178 | |
179 const char * | |
180 msn_user_get_name(const MsnUser *user) | |
181 { | |
182 g_return_val_if_fail(user != NULL, NULL); | |
183 | |
184 return user->name; | |
185 } | |
186 | |
187 int | |
188 msn_user_get_group_id(const MsnUser *user) | |
189 { | |
190 g_return_val_if_fail(user != NULL, -1); | |
191 | |
192 return user->group_id; | |
193 } | |
194 | |
5363
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
195 const char * |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
196 msn_user_get_home_phone(const MsnUser *user) |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
197 { |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
198 g_return_val_if_fail(user != NULL, NULL); |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
199 |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
200 return user->phone.home; |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
201 } |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
202 |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
203 const char * |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
204 msn_user_get_work_phone(const MsnUser *user) |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
205 { |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
206 g_return_val_if_fail(user != NULL, NULL); |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
207 |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
208 return user->phone.work; |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
209 } |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
210 |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
211 const char * |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
212 msn_user_get_mobile_phone(const MsnUser *user) |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
213 { |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
214 g_return_val_if_fail(user != NULL, NULL); |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
215 |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
216 return user->phone.mobile; |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
217 } |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
218 |
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
219 void |
5475
ad9887c91a59
[gaim-migrate @ 5871]
Christian Hammond <chipx86@chipx86.com>
parents:
5363
diff
changeset
|
220 msn_user_set_client_caps(MsnUser *user, GHashTable *info) |
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
221 { |
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
222 g_return_if_fail(user != NULL); |
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
223 g_return_if_fail(info != NULL); |
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
224 |
5475
ad9887c91a59
[gaim-migrate @ 5871]
Christian Hammond <chipx86@chipx86.com>
parents:
5363
diff
changeset
|
225 if (user->clientcaps != NULL) |
ad9887c91a59
[gaim-migrate @ 5871]
Christian Hammond <chipx86@chipx86.com>
parents:
5363
diff
changeset
|
226 g_hash_table_destroy(user->clientcaps); |
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
227 |
5475
ad9887c91a59
[gaim-migrate @ 5871]
Christian Hammond <chipx86@chipx86.com>
parents:
5363
diff
changeset
|
228 user->clientcaps = info; |
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
229 } |
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
230 |
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
231 GHashTable * |
5475
ad9887c91a59
[gaim-migrate @ 5871]
Christian Hammond <chipx86@chipx86.com>
parents:
5363
diff
changeset
|
232 msn_user_get_client_caps(const MsnUser *user) |
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
233 { |
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
234 g_return_val_if_fail(user != NULL, NULL); |
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
235 |
5475
ad9887c91a59
[gaim-migrate @ 5871]
Christian Hammond <chipx86@chipx86.com>
parents:
5363
diff
changeset
|
236 return user->clientcaps; |
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
237 } |
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
238 |
5309 | 239 MsnUsers * |
240 msn_users_new(void) | |
241 { | |
242 MsnUsers *users = g_new0(MsnUsers, 1); | |
243 | |
244 return users; | |
245 } | |
246 | |
247 void | |
248 msn_users_destroy(MsnUsers *users) | |
249 { | |
5518
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
250 GList *l, *l_next = NULL; |
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
251 |
5309 | 252 g_return_if_fail(users != NULL); |
253 | |
5518
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
254 for (l = users->users; l != NULL; l = l_next) { |
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
255 l_next = l->next; |
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
256 |
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
257 msn_user_destroy(l->data); |
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
258 |
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
259 users->users = g_list_remove(users->users, l->data); |
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
260 } |
5309 | 261 |
262 /* See if we've leaked anybody. */ | |
263 while (users->users != NULL) { | |
264 gaim_debug(GAIM_DEBUG_WARNING, "msn", | |
265 "Leaking user %s\n", | |
266 msn_user_get_passport(users->users->data)); | |
267 } | |
268 | |
269 g_free(users); | |
270 } | |
271 | |
272 void | |
273 msn_users_add(MsnUsers *users, MsnUser *user) | |
274 { | |
275 g_return_if_fail(users != NULL); | |
276 g_return_if_fail(user != NULL); | |
277 | |
278 users->users = g_list_append(users->users, user); | |
5518
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
279 |
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
280 users->count++; |
5309 | 281 } |
282 | |
283 void | |
284 msn_users_remove(MsnUsers *users, MsnUser *user) | |
285 { | |
286 g_return_if_fail(users != NULL); | |
5518
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
287 g_return_if_fail(user != NULL); |
5309 | 288 |
289 users->users = g_list_remove(users->users, user); | |
5518
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
290 |
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
291 users->count--; |
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
292 } |
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
293 |
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
294 size_t |
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
295 msn_users_get_count(const MsnUsers *users) |
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
296 { |
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
297 g_return_val_if_fail(users != NULL, 0); |
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
298 |
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
299 return users->count; |
5309 | 300 } |
301 | |
302 MsnUser * | |
303 msn_users_find_with_passport(MsnUsers *users, const char *passport) | |
304 { | |
305 GList *l; | |
306 | |
307 g_return_val_if_fail(users != NULL, NULL); | |
308 g_return_val_if_fail(passport != NULL, NULL); | |
309 | |
310 for (l = users->users; l != NULL; l = l->next) { | |
311 MsnUser *user = (MsnUser *)l->data; | |
312 | |
313 if (user->passport != NULL && | |
314 !g_ascii_strcasecmp(passport, user->passport)) { | |
315 | |
316 return user; | |
317 } | |
318 } | |
319 | |
320 return NULL; | |
321 } |