Mercurial > pidgin
comparison src/protocols/msn/user.c @ 5518:bf2a7a7b739d
[gaim-migrate @ 5918]
Reworked the group support. You should now be able to delete groups by
dragging a user into them and then back out.
I stress _should_. This will likely have bugs. I cleaned up the ones I
found, I think, but I'm not 100% confident here :) Please test! Preferably
on test accounts, but it won't kill things, just reorder stuff.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Sun, 25 May 2003 22:51:19 +0000 |
parents | ad9887c91a59 |
children | b7e113a59b51 |
comparison
equal
deleted
inserted
replaced
5517:e9b9fbf89c42 | 5518:bf2a7a7b739d |
---|---|
27 { | 27 { |
28 MsnUser *user; | 28 MsnUser *user; |
29 | 29 |
30 user = msn_users_find_with_passport(session->users, passport); | 30 user = msn_users_find_with_passport(session->users, passport); |
31 | 31 |
32 if (user != NULL) { | 32 if (user == NULL) { |
33 if (name != NULL) | 33 user = g_new0(MsnUser, 1); |
34 msn_user_set_name(user, name); | 34 |
35 | 35 user->session = session; |
36 msn_user_ref(user); | 36 |
37 | 37 msn_user_set_passport(user, passport); |
38 return user; | 38 msn_user_set_group_id(user, -1); |
39 } | 39 |
40 | 40 msn_users_add(session->users, user); |
41 user = g_new0(MsnUser, 1); | 41 } |
42 | |
43 user->session = session; | |
44 | 42 |
45 if (name != NULL) | 43 if (name != NULL) |
46 msn_user_set_name(user, name); | 44 msn_user_set_name(user, name); |
47 | |
48 msn_user_set_passport(user, passport); | |
49 msn_user_set_group_id(user, -1); | |
50 | |
51 msn_users_add(session->users, user); | |
52 | 45 |
53 msn_user_ref(user); | 46 msn_user_ref(user); |
54 | 47 |
55 return user; | 48 return user; |
56 } | 49 } |
252 } | 245 } |
253 | 246 |
254 void | 247 void |
255 msn_users_destroy(MsnUsers *users) | 248 msn_users_destroy(MsnUsers *users) |
256 { | 249 { |
250 GList *l, *l_next = NULL; | |
251 | |
257 g_return_if_fail(users != NULL); | 252 g_return_if_fail(users != NULL); |
258 | 253 |
259 while (users->users != NULL) | 254 for (l = users->users; l != NULL; l = l_next) { |
260 msn_user_destroy(users->users->data); | 255 l_next = l->next; |
256 | |
257 msn_user_destroy(l->data); | |
258 | |
259 users->users = g_list_remove(users->users, l->data); | |
260 } | |
261 | 261 |
262 /* See if we've leaked anybody. */ | 262 /* See if we've leaked anybody. */ |
263 while (users->users != NULL) { | 263 while (users->users != NULL) { |
264 gaim_debug(GAIM_DEBUG_WARNING, "msn", | 264 gaim_debug(GAIM_DEBUG_WARNING, "msn", |
265 "Leaking user %s\n", | 265 "Leaking user %s\n", |
274 { | 274 { |
275 g_return_if_fail(users != NULL); | 275 g_return_if_fail(users != NULL); |
276 g_return_if_fail(user != NULL); | 276 g_return_if_fail(user != NULL); |
277 | 277 |
278 users->users = g_list_append(users->users, user); | 278 users->users = g_list_append(users->users, user); |
279 | |
280 users->count++; | |
279 } | 281 } |
280 | 282 |
281 void | 283 void |
282 msn_users_remove(MsnUsers *users, MsnUser *user) | 284 msn_users_remove(MsnUsers *users, MsnUser *user) |
283 { | 285 { |
284 g_return_if_fail(users != NULL); | 286 g_return_if_fail(users != NULL); |
285 g_return_if_fail(user != NULL); | 287 g_return_if_fail(user != NULL); |
286 | 288 |
287 users->users = g_list_remove(users->users, user); | 289 users->users = g_list_remove(users->users, user); |
290 | |
291 users->count--; | |
292 } | |
293 | |
294 size_t | |
295 msn_users_get_count(const MsnUsers *users) | |
296 { | |
297 g_return_val_if_fail(users != NULL, 0); | |
298 | |
299 return users->count; | |
288 } | 300 } |
289 | 301 |
290 MsnUser * | 302 MsnUser * |
291 msn_users_find_with_passport(MsnUsers *users, const char *passport) | 303 msn_users_find_with_passport(MsnUsers *users, const char *passport) |
292 { | 304 { |