annotate src/protocols/msn/user.c @ 7210:234178fd9787

[gaim-migrate @ 7779] Commitinating my NEWS. What else should I be doing at school? Studying? Hah. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Thu, 09 Oct 2003 20:13:05 +0000
parents 885c6528843b
children 3a48ade4f510
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1 /**
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2 * @file user.c User functions
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
3 *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
4 * gaim
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
5 *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
6 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org>
6701
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
7 *
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
11 * (at your option) any later version.
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12 *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 * GNU General Public License for more details.
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21 */
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
22 #include "msn.h"
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
23 #include "user.h"
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
24
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
25 MsnUser *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
26 msn_user_new(MsnSession *session, const char *passport, const char *name)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
27 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
28 MsnUser *user;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
29
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
30 user = msn_users_find_with_passport(session->users, passport);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
34
5518
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
35 user->session = session;
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
36
5518
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
37 msn_user_set_passport(user, passport);
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
38
5518
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
39 msn_users_add(session->users, user);
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
40 }
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
41
6858
885c6528843b [gaim-migrate @ 7403]
Christian Hammond <chipx86@chipx86.com>
parents: 6800
diff changeset
42 /*
885c6528843b [gaim-migrate @ 7403]
Christian Hammond <chipx86@chipx86.com>
parents: 6800
diff changeset
43 * XXX This seems to reset the friendly name from what it should be
885c6528843b [gaim-migrate @ 7403]
Christian Hammond <chipx86@chipx86.com>
parents: 6800
diff changeset
44 * to the passport when moving users. So, screw it :)
885c6528843b [gaim-migrate @ 7403]
Christian Hammond <chipx86@chipx86.com>
parents: 6800
diff changeset
45 */
885c6528843b [gaim-migrate @ 7403]
Christian Hammond <chipx86@chipx86.com>
parents: 6800
diff changeset
46 #if 0
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
47 if (name != NULL)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
48 msn_user_set_name(user, name);
6858
885c6528843b [gaim-migrate @ 7403]
Christian Hammond <chipx86@chipx86.com>
parents: 6800
diff changeset
49 #endif
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
50
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
51 msn_user_ref(user);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
52
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
53 return user;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
54 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
55
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
56 void
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
57 msn_user_destroy(MsnUser *user)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
58 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
59 g_return_if_fail(user != NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
60
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
61 if (user->ref_count > 0) {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
62 msn_user_unref(user);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
63
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
64 return;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
65 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
66
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
67 if (user->session != NULL && user->session->users != NULL)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
68 msn_users_remove(user->session->users, user);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
69
5475
ad9887c91a59 [gaim-migrate @ 5871]
Christian Hammond <chipx86@chipx86.com>
parents: 5363
diff changeset
70 if (user->clientcaps != NULL)
ad9887c91a59 [gaim-migrate @ 5871]
Christian Hammond <chipx86@chipx86.com>
parents: 5363
diff changeset
71 g_hash_table_destroy(user->clientcaps);
5316
d5690ed70085 [gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents: 5309
diff changeset
72
6701
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
73 if (user->group_ids != NULL)
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
74 g_list_free(user->group_ids);
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
75
6800
8f228a7d5076 [gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents: 6788
diff changeset
76 if (user->msnobj != NULL)
8f228a7d5076 [gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents: 6788
diff changeset
77 msn_object_destroy(user->msnobj);
8f228a7d5076 [gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents: 6788
diff changeset
78
5363
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
79 if (user->passport != NULL) g_free(user->passport);
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
80 if (user->name != NULL) g_free(user->name);
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
81
5363
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
82 if (user->phone.home != NULL) g_free(user->phone.home);
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
83 if (user->phone.work != NULL) g_free(user->phone.work);
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
84 if (user->phone.mobile != NULL) g_free(user->phone.mobile);
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
85
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
86 g_free(user);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
87 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
88
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
89 MsnUser *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
90 msn_user_ref(MsnUser *user)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
91 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
92 g_return_val_if_fail(user != NULL, NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
93
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
94 user->ref_count++;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
95
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
96 return user;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
97 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
98
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
99 MsnUser *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
100 msn_user_unref(MsnUser *user)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
101 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
102 g_return_val_if_fail(user != NULL, NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
103
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
104 if (user->ref_count <= 0)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
105 return NULL;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
106
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
107 user->ref_count--;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
108
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
109 if (user->ref_count == 0) {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
110 msn_user_destroy(user);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
111
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
112 return NULL;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
113 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
114
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
115 return user;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
116 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
117
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
118 void
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
119 msn_user_set_passport(MsnUser *user, const char *passport)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
120 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
121 g_return_if_fail(user != NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
122
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
123 if (user->passport != NULL)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
124 g_free(user->passport);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
125
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
126 user->passport = g_strdup(passport);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
127 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
128
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
129 void
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
130 msn_user_set_name(MsnUser *user, const char *name)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
131 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
132 g_return_if_fail(user != NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
133
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
134 if (user->name != NULL)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
135 g_free(user->name);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
136
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
137 user->name = g_strdup(name);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
138 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
139
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
140 void
6701
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
141 msn_user_set_group_ids(MsnUser *user, GList *ids)
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
142 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
143 g_return_if_fail(user != NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
144
6701
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
145 user->group_ids = ids;
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
146 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
147
5363
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
148 void
6701
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
149 msn_user_add_group_id(MsnUser *user, int id)
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
150 {
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
151 g_return_if_fail(user != NULL);
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
152 g_return_if_fail(id > -1);
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
153
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
154 if (!g_list_find(user->group_ids, GINT_TO_POINTER(id)))
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
155 user->group_ids = g_list_append(user->group_ids, GINT_TO_POINTER(id));
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
156 }
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
157
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
158 void
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
159 msn_user_remove_group_id(MsnUser *user, int id)
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
160 {
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
161 g_return_if_fail(user != NULL);
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
162 g_return_if_fail(id > -1);
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
163
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
164 user->group_ids = g_list_remove(user->group_ids, GINT_TO_POINTER(id));
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
165 }
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
166 void
5363
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
167 msn_user_set_home_phone(MsnUser *user, const char *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 g_return_if_fail(user != NULL);
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
170
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
171 if (user->phone.home != NULL)
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
172 g_free(user->phone.home);
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
173
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
174 user->phone.home = (number == NULL ? NULL : g_strdup(number));
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
175 }
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
176
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
177 void
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
178 msn_user_set_work_phone(MsnUser *user, const char *number)
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
179 {
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
180 g_return_if_fail(user != NULL);
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
181
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
182 if (user->phone.work != NULL)
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
183 g_free(user->phone.work);
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
184
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
185 user->phone.work = (number == NULL ? NULL : g_strdup(number));
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
186 }
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
187
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
188 void
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
189 msn_user_set_mobile_phone(MsnUser *user, const char *number)
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
190 {
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
191 g_return_if_fail(user != NULL);
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
192
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
193 if (user->phone.mobile != NULL)
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
194 g_free(user->phone.mobile);
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
195
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
196 user->phone.mobile = (number == NULL ? NULL : g_strdup(number));
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
6788
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
199 void
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
200 msn_user_set_object(MsnUser *user, MsnObject *obj)
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
201 {
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
202 g_return_if_fail(user != NULL);
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
203
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
204 if (user->msnobj != NULL)
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
205 msn_object_destroy(user->msnobj);
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
206
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
207 user->msnobj = obj;
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
208 }
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
209
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
210 void
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
211 msn_user_set_client_caps(MsnUser *user, GHashTable *info)
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
212 {
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
213 g_return_if_fail(user != NULL);
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
214 g_return_if_fail(info != NULL);
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
215
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
216 if (user->clientcaps != NULL)
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
217 g_hash_table_destroy(user->clientcaps);
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
218
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
219 user->clientcaps = info;
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
220 }
5363
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
221
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
222 const char *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
223 msn_user_get_passport(const MsnUser *user)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
224 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
225 g_return_val_if_fail(user != NULL, NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
226
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
227 return user->passport;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
228 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
229
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
230 const char *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
231 msn_user_get_name(const MsnUser *user)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
232 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
233 g_return_val_if_fail(user != NULL, NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
234
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
235 return user->name;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
236 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
237
6701
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
238 GList *
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
239 msn_user_get_group_ids(const MsnUser *user)
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
240 {
6701
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
241 g_return_val_if_fail(user != NULL, NULL);
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
242
6701
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
243 return user->group_ids;
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
244 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
245
5363
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
246 const char *
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
247 msn_user_get_home_phone(const MsnUser *user)
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
248 {
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
249 g_return_val_if_fail(user != NULL, NULL);
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
250
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
251 return user->phone.home;
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
252 }
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
253
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
254 const char *
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
255 msn_user_get_work_phone(const MsnUser *user)
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
256 {
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
257 g_return_val_if_fail(user != NULL, NULL);
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
258
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
259 return user->phone.work;
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
260 }
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
261
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
262 const char *
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
263 msn_user_get_mobile_phone(const MsnUser *user)
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
264 {
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
265 g_return_val_if_fail(user != NULL, NULL);
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
266
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
267 return user->phone.mobile;
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
268 }
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
269
6788
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
270 MsnObject *
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
271 msn_user_get_object(const MsnUser *user)
5316
d5690ed70085 [gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents: 5309
diff changeset
272 {
6788
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
273 g_return_val_if_fail(user != NULL, NULL);
5316
d5690ed70085 [gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents: 5309
diff changeset
274
6788
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
275 return user->msnobj;
5316
d5690ed70085 [gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents: 5309
diff changeset
276 }
d5690ed70085 [gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents: 5309
diff changeset
277
d5690ed70085 [gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents: 5309
diff changeset
278 GHashTable *
5475
ad9887c91a59 [gaim-migrate @ 5871]
Christian Hammond <chipx86@chipx86.com>
parents: 5363
diff changeset
279 msn_user_get_client_caps(const MsnUser *user)
5316
d5690ed70085 [gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents: 5309
diff changeset
280 {
d5690ed70085 [gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents: 5309
diff changeset
281 g_return_val_if_fail(user != NULL, NULL);
d5690ed70085 [gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents: 5309
diff changeset
282
5475
ad9887c91a59 [gaim-migrate @ 5871]
Christian Hammond <chipx86@chipx86.com>
parents: 5363
diff changeset
283 return user->clientcaps;
5316
d5690ed70085 [gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents: 5309
diff changeset
284 }
d5690ed70085 [gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents: 5309
diff changeset
285
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
286 MsnUsers *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
287 msn_users_new(void)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
288 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
289 MsnUsers *users = g_new0(MsnUsers, 1);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
290
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
291 return users;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
292 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
293
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
294 void
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
295 msn_users_destroy(MsnUsers *users)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
296 {
5518
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
297 GList *l, *l_next = NULL;
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
298
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
299 g_return_if_fail(users != NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
300
5518
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
301 for (l = users->users; l != NULL; l = l_next) {
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
302 l_next = l->next;
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
303
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
304 msn_user_destroy(l->data);
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
305
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
306 users->users = g_list_remove(users->users, l->data);
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
307 }
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
308
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
309 /* See if we've leaked anybody. */
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
310 while (users->users != NULL) {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
311 gaim_debug(GAIM_DEBUG_WARNING, "msn",
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
312 "Leaking user %s\n",
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
313 msn_user_get_passport(users->users->data));
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
314 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
315
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
316 g_free(users);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
317 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
318
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
319 void
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
320 msn_users_add(MsnUsers *users, MsnUser *user)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
321 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
322 g_return_if_fail(users != NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
323 g_return_if_fail(user != NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
324
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
325 users->users = g_list_append(users->users, user);
5518
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
326
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
327 users->count++;
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
328 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
329
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
330 void
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
331 msn_users_remove(MsnUsers *users, MsnUser *user)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
332 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
333 g_return_if_fail(users != NULL);
5518
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
334 g_return_if_fail(user != NULL);
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
335
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
336 users->users = g_list_remove(users->users, user);
5518
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
337
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
338 users->count--;
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
339 }
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
340
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
341 size_t
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
342 msn_users_get_count(const MsnUsers *users)
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
343 {
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
344 g_return_val_if_fail(users != NULL, 0);
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
345
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
346 return users->count;
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
347 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
348
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
349 MsnUser *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
350 msn_users_find_with_passport(MsnUsers *users, const char *passport)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
351 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
352 GList *l;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
353
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
354 g_return_val_if_fail(users != NULL, NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
355 g_return_val_if_fail(passport != NULL, NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
356
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
357 for (l = users->users; l != NULL; l = l->next) {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
358 MsnUser *user = (MsnUser *)l->data;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
359
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
360 if (user->passport != NULL &&
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
361 !g_ascii_strcasecmp(passport, user->passport)) {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
362
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
363 return user;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
364 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
365 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
366
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
367 return NULL;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
368 }