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
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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
42 if (name != NULL)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
43 msn_user_set_name(user, name);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
44
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
45 msn_user_ref(user);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
46
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
47 return user;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
48 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
49
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
50 void
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
51 msn_user_destroy(MsnUser *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 g_return_if_fail(user != NULL);
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 if (user->ref_count > 0) {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
56 msn_user_unref(user);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
57
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
58 return;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
59 }
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->session != NULL && user->session->users != NULL)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
62 msn_users_remove(user->session->users, user);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
79
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
80 g_free(user);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
81 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
82
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
83 MsnUser *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
84 msn_user_ref(MsnUser *user)
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_return_val_if_fail(user != NULL, NULL);
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 user->ref_count++;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
89
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
90 return 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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
93 MsnUser *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
94 msn_user_unref(MsnUser *user)
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 g_return_val_if_fail(user != NULL, NULL);
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 if (user->ref_count <= 0)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
99 return NULL;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
100
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
101 user->ref_count--;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
102
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
103 if (user->ref_count == 0) {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
104 msn_user_destroy(user);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
105
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
106 return NULL;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
107 }
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 return user;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
110 }
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 void
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
113 msn_user_set_passport(MsnUser *user, const char *passport)
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 g_return_if_fail(user != NULL);
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 if (user->passport != NULL)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
118 g_free(user->passport);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
119
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
120 user->passport = g_strdup(passport);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
121 }
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 void
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
124 msn_user_set_name(MsnUser *user, const char *name)
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 g_return_if_fail(user != NULL);
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 if (user->name != NULL)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
129 g_free(user->name);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
130
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
131 user->name = g_strdup(name);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
132 }
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 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
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 g_return_if_fail(user != NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
138
6701
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
139 user->group_ids = ids;
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
140 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
216 const char *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
217 msn_user_get_passport(const MsnUser *user)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
218 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
219 g_return_val_if_fail(user != NULL, NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
220
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
221 return user->passport;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
222 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
223
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
224 const char *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
225 msn_user_get_name(const MsnUser *user)
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 g_return_val_if_fail(user != NULL, NULL);
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 return user->name;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
230 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
236
6701
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
237 return user->group_ids;
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
238 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
280 MsnUsers *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
281 msn_users_new(void)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
282 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
283 MsnUsers *users = g_new0(MsnUsers, 1);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
284
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
285 return users;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
286 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
287
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
288 void
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
289 msn_users_destroy(MsnUsers *users)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
293 g_return_if_fail(users != NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
302
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
303 /* See if we've leaked anybody. */
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
304 while (users->users != NULL) {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
305 gaim_debug(GAIM_DEBUG_WARNING, "msn",
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
306 "Leaking user %s\n",
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
307 msn_user_get_passport(users->users->data));
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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
310 g_free(users);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
311 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
312
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
313 void
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
314 msn_users_add(MsnUsers *users, MsnUser *user)
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_return_if_fail(users != NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
317 g_return_if_fail(user != NULL);
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 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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
322 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
323
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
324 void
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
325 msn_users_remove(MsnUsers *users, MsnUser *user)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
326 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
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
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 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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
341 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
342
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
343 MsnUser *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
344 msn_users_find_with_passport(MsnUsers *users, const char *passport)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
345 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
346 GList *l;
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 g_return_val_if_fail(users != NULL, NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
349 g_return_val_if_fail(passport != NULL, NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
350
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
351 for (l = users->users; l != NULL; l = l->next) {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
352 MsnUser *user = (MsnUser *)l->data;
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 if (user->passport != NULL &&
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
355 !g_ascii_strcasecmp(passport, user->passport)) {
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 return user;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
358 }
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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
361 return NULL;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
362 }