Mercurial > pidgin
annotate src/protocols/msn/user.c @ 6802:662f5bef41b7
[gaim-migrate @ 7342]
Fixed a nice little MSN bug I introduced where MSN messages weren't fully
getting sent. This caused truncated messages and switchboard disconnects.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Wed, 10 Sep 2003 04:21:15 +0000 |
parents | 8f228a7d5076 |
children | 885c6528843b |
rev | line source |
---|---|
5309 | 1 /** |
2 * @file user.c User functions | |
3 * | |
4 * gaim | |
5 * | |
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 | 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); |
5309 | 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 | 41 |
42 if (name != NULL) | |
43 msn_user_set_name(user, name); | |
44 | |
45 msn_user_ref(user); | |
46 | |
47 return user; | |
48 } | |
49 | |
50 void | |
51 msn_user_destroy(MsnUser *user) | |
52 { | |
53 g_return_if_fail(user != NULL); | |
54 | |
55 if (user->ref_count > 0) { | |
56 msn_user_unref(user); | |
57 | |
58 return; | |
59 } | |
60 | |
61 if (user->session != NULL && user->session->users != NULL) | |
62 msn_users_remove(user->session->users, user); | |
63 | |
5475
ad9887c91a59
[gaim-migrate @ 5871]
Christian Hammond <chipx86@chipx86.com>
parents:
5363
diff
changeset
|
64 if (user->clientcaps != NULL) |
ad9887c91a59
[gaim-migrate @ 5871]
Christian Hammond <chipx86@chipx86.com>
parents:
5363
diff
changeset
|
65 g_hash_table_destroy(user->clientcaps); |
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
66 |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5518
diff
changeset
|
67 if (user->group_ids != NULL) |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5518
diff
changeset
|
68 g_list_free(user->group_ids); |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5518
diff
changeset
|
69 |
6800
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6788
diff
changeset
|
70 if (user->msnobj != NULL) |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6788
diff
changeset
|
71 msn_object_destroy(user->msnobj); |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6788
diff
changeset
|
72 |
5363
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
73 if (user->passport != NULL) g_free(user->passport); |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
74 if (user->name != NULL) g_free(user->name); |
5309 | 75 |
5363
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
76 if (user->phone.home != NULL) g_free(user->phone.home); |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
77 if (user->phone.work != NULL) g_free(user->phone.work); |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
78 if (user->phone.mobile != NULL) g_free(user->phone.mobile); |
5309 | 79 |
80 g_free(user); | |
81 } | |
82 | |
83 MsnUser * | |
84 msn_user_ref(MsnUser *user) | |
85 { | |
86 g_return_val_if_fail(user != NULL, NULL); | |
87 | |
88 user->ref_count++; | |
89 | |
90 return user; | |
91 } | |
92 | |
93 MsnUser * | |
94 msn_user_unref(MsnUser *user) | |
95 { | |
96 g_return_val_if_fail(user != NULL, NULL); | |
97 | |
98 if (user->ref_count <= 0) | |
99 return NULL; | |
100 | |
101 user->ref_count--; | |
102 | |
103 if (user->ref_count == 0) { | |
104 msn_user_destroy(user); | |
105 | |
106 return NULL; | |
107 } | |
108 | |
109 return user; | |
110 } | |
111 | |
112 void | |
113 msn_user_set_passport(MsnUser *user, const char *passport) | |
114 { | |
115 g_return_if_fail(user != NULL); | |
116 | |
117 if (user->passport != NULL) | |
118 g_free(user->passport); | |
119 | |
120 user->passport = g_strdup(passport); | |
121 } | |
122 | |
123 void | |
124 msn_user_set_name(MsnUser *user, const char *name) | |
125 { | |
126 g_return_if_fail(user != NULL); | |
127 | |
128 if (user->name != NULL) | |
129 g_free(user->name); | |
130 | |
131 user->name = g_strdup(name); | |
132 } | |
133 | |
134 void | |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5518
diff
changeset
|
135 msn_user_set_group_ids(MsnUser *user, GList *ids) |
5309 | 136 { |
137 g_return_if_fail(user != NULL); | |
138 | |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5518
diff
changeset
|
139 user->group_ids = ids; |
5309 | 140 } |
141 | |
5363
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
142 void |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5518
diff
changeset
|
143 msn_user_add_group_id(MsnUser *user, int id) |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5518
diff
changeset
|
144 { |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5518
diff
changeset
|
145 g_return_if_fail(user != NULL); |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5518
diff
changeset
|
146 g_return_if_fail(id > -1); |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5518
diff
changeset
|
147 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5518
diff
changeset
|
148 if (!g_list_find(user->group_ids, GINT_TO_POINTER(id))) |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5518
diff
changeset
|
149 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
|
150 } |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5518
diff
changeset
|
151 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5518
diff
changeset
|
152 void |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5518
diff
changeset
|
153 msn_user_remove_group_id(MsnUser *user, int id) |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5518
diff
changeset
|
154 { |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5518
diff
changeset
|
155 g_return_if_fail(user != NULL); |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5518
diff
changeset
|
156 g_return_if_fail(id > -1); |
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 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
|
159 } |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5518
diff
changeset
|
160 void |
5363
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
161 msn_user_set_home_phone(MsnUser *user, const char *number) |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
162 { |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
163 g_return_if_fail(user != NULL); |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
164 |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
165 if (user->phone.home != NULL) |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
166 g_free(user->phone.home); |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
167 |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
168 user->phone.home = (number == NULL ? NULL : g_strdup(number)); |
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 |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
171 void |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
172 msn_user_set_work_phone(MsnUser *user, const char *number) |
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 g_return_if_fail(user != NULL); |
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 if (user->phone.work != NULL) |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
177 g_free(user->phone.work); |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
178 |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
179 user->phone.work = (number == NULL ? NULL : g_strdup(number)); |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
180 } |
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 void |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
183 msn_user_set_mobile_phone(MsnUser *user, const char *number) |
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 g_return_if_fail(user != NULL); |
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 if (user->phone.mobile != NULL) |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
188 g_free(user->phone.mobile); |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
189 |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
190 user->phone.mobile = (number == NULL ? NULL : g_strdup(number)); |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
191 } |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
192 |
6788
c1995194e3d1
[gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
193 void |
c1995194e3d1
[gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
194 msn_user_set_object(MsnUser *user, MsnObject *obj) |
c1995194e3d1
[gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
195 { |
c1995194e3d1
[gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
196 g_return_if_fail(user != NULL); |
c1995194e3d1
[gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
197 |
c1995194e3d1
[gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
198 if (user->msnobj != NULL) |
c1995194e3d1
[gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
199 msn_object_destroy(user->msnobj); |
c1995194e3d1
[gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
200 |
c1995194e3d1
[gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
201 user->msnobj = obj; |
c1995194e3d1
[gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
202 } |
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 void |
c1995194e3d1
[gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
205 msn_user_set_client_caps(MsnUser *user, GHashTable *info) |
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 g_return_if_fail(user != NULL); |
c1995194e3d1
[gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
208 g_return_if_fail(info != NULL); |
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 if (user->clientcaps != NULL) |
c1995194e3d1
[gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
211 g_hash_table_destroy(user->clientcaps); |
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 user->clientcaps = info; |
c1995194e3d1
[gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
214 } |
5363
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
215 |
5309 | 216 const char * |
217 msn_user_get_passport(const MsnUser *user) | |
218 { | |
219 g_return_val_if_fail(user != NULL, NULL); | |
220 | |
221 return user->passport; | |
222 } | |
223 | |
224 const char * | |
225 msn_user_get_name(const MsnUser *user) | |
226 { | |
227 g_return_val_if_fail(user != NULL, NULL); | |
228 | |
229 return user->name; | |
230 } | |
231 | |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5518
diff
changeset
|
232 GList * |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5518
diff
changeset
|
233 msn_user_get_group_ids(const MsnUser *user) |
5309 | 234 { |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5518
diff
changeset
|
235 g_return_val_if_fail(user != NULL, NULL); |
5309 | 236 |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5518
diff
changeset
|
237 return user->group_ids; |
5309 | 238 } |
239 | |
5363
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
240 const char * |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
241 msn_user_get_home_phone(const MsnUser *user) |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
242 { |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
243 g_return_val_if_fail(user != NULL, NULL); |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
244 |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
245 return user->phone.home; |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
246 } |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
247 |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
248 const char * |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
249 msn_user_get_work_phone(const MsnUser *user) |
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 g_return_val_if_fail(user != NULL, NULL); |
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 return user->phone.work; |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
254 } |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
255 |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
256 const char * |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
257 msn_user_get_mobile_phone(const MsnUser *user) |
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 g_return_val_if_fail(user != NULL, NULL); |
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 return user->phone.mobile; |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
262 } |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5316
diff
changeset
|
263 |
6788
c1995194e3d1
[gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
264 MsnObject * |
c1995194e3d1
[gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
265 msn_user_get_object(const MsnUser *user) |
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
266 { |
6788
c1995194e3d1
[gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
267 g_return_val_if_fail(user != NULL, NULL); |
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
268 |
6788
c1995194e3d1
[gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
269 return user->msnobj; |
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
270 } |
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
271 |
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
272 GHashTable * |
5475
ad9887c91a59
[gaim-migrate @ 5871]
Christian Hammond <chipx86@chipx86.com>
parents:
5363
diff
changeset
|
273 msn_user_get_client_caps(const MsnUser *user) |
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
274 { |
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
275 g_return_val_if_fail(user != NULL, NULL); |
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
276 |
5475
ad9887c91a59
[gaim-migrate @ 5871]
Christian Hammond <chipx86@chipx86.com>
parents:
5363
diff
changeset
|
277 return user->clientcaps; |
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
278 } |
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
279 |
5309 | 280 MsnUsers * |
281 msn_users_new(void) | |
282 { | |
283 MsnUsers *users = g_new0(MsnUsers, 1); | |
284 | |
285 return users; | |
286 } | |
287 | |
288 void | |
289 msn_users_destroy(MsnUsers *users) | |
290 { | |
5518
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
291 GList *l, *l_next = NULL; |
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
292 |
5309 | 293 g_return_if_fail(users != NULL); |
294 | |
5518
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
295 for (l = users->users; l != NULL; l = l_next) { |
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
296 l_next = l->next; |
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
297 |
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
298 msn_user_destroy(l->data); |
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
299 |
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
300 users->users = g_list_remove(users->users, l->data); |
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
301 } |
5309 | 302 |
303 /* See if we've leaked anybody. */ | |
304 while (users->users != NULL) { | |
305 gaim_debug(GAIM_DEBUG_WARNING, "msn", | |
306 "Leaking user %s\n", | |
307 msn_user_get_passport(users->users->data)); | |
308 } | |
309 | |
310 g_free(users); | |
311 } | |
312 | |
313 void | |
314 msn_users_add(MsnUsers *users, MsnUser *user) | |
315 { | |
316 g_return_if_fail(users != NULL); | |
317 g_return_if_fail(user != NULL); | |
318 | |
319 users->users = g_list_append(users->users, user); | |
5518
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
320 |
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
321 users->count++; |
5309 | 322 } |
323 | |
324 void | |
325 msn_users_remove(MsnUsers *users, MsnUser *user) | |
326 { | |
327 g_return_if_fail(users != NULL); | |
5518
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
328 g_return_if_fail(user != NULL); |
5309 | 329 |
330 users->users = g_list_remove(users->users, user); | |
5518
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
331 |
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
332 users->count--; |
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
333 } |
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
334 |
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
335 size_t |
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5475
diff
changeset
|
336 msn_users_get_count(const MsnUsers *users) |
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 g_return_val_if_fail(users != NULL, 0); |
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 return users->count; |
5309 | 341 } |
342 | |
343 MsnUser * | |
344 msn_users_find_with_passport(MsnUsers *users, const char *passport) | |
345 { | |
346 GList *l; | |
347 | |
348 g_return_val_if_fail(users != NULL, NULL); | |
349 g_return_val_if_fail(passport != NULL, NULL); | |
350 | |
351 for (l = users->users; l != NULL; l = l->next) { | |
352 MsnUser *user = (MsnUser *)l->data; | |
353 | |
354 if (user->passport != NULL && | |
355 !g_ascii_strcasecmp(passport, user->passport)) { | |
356 | |
357 return user; | |
358 } | |
359 } | |
360 | |
361 return NULL; | |
362 } |