annotate src/protocols/msn/user.c @ 7591:24b9b6405f36

[gaim-migrate @ 8209] We're sending a buddy icon, not an emoticon. Smart one, Chippy. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Sat, 22 Nov 2003 00:49:48 +0000
parents 3a48ade4f510
children b8b83826cc61
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
7590
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
32 if (user == NULL)
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
33 {
5518
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
34 user = g_new0(MsnUser, 1);
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
35
5518
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
36 user->session = session;
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
37
5518
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
38 msn_user_set_passport(user, passport);
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
39
5518
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
40 msn_users_add(session->users, user);
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
41 }
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
42
6858
885c6528843b [gaim-migrate @ 7403]
Christian Hammond <chipx86@chipx86.com>
parents: 6800
diff changeset
43 /*
885c6528843b [gaim-migrate @ 7403]
Christian Hammond <chipx86@chipx86.com>
parents: 6800
diff changeset
44 * 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
45 * to the passport when moving users. So, screw it :)
885c6528843b [gaim-migrate @ 7403]
Christian Hammond <chipx86@chipx86.com>
parents: 6800
diff changeset
46 */
885c6528843b [gaim-migrate @ 7403]
Christian Hammond <chipx86@chipx86.com>
parents: 6800
diff changeset
47 #if 0
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
48 if (name != NULL)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
49 msn_user_set_name(user, name);
6858
885c6528843b [gaim-migrate @ 7403]
Christian Hammond <chipx86@chipx86.com>
parents: 6800
diff changeset
50 #endif
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
51
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
52 msn_user_ref(user);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
53
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
54 return user;
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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
57 void
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
58 msn_user_destroy(MsnUser *user)
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 g_return_if_fail(user != NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
61
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
62 if (user->ref_count > 0) {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
63 msn_user_unref(user);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
64
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
65 return;
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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
68 if (user->session != NULL && user->session->users != NULL)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
69 msn_users_remove(user->session->users, user);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
70
5475
ad9887c91a59 [gaim-migrate @ 5871]
Christian Hammond <chipx86@chipx86.com>
parents: 5363
diff changeset
71 if (user->clientcaps != NULL)
ad9887c91a59 [gaim-migrate @ 5871]
Christian Hammond <chipx86@chipx86.com>
parents: 5363
diff changeset
72 g_hash_table_destroy(user->clientcaps);
5316
d5690ed70085 [gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents: 5309
diff changeset
73
6701
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
74 if (user->group_ids != NULL)
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
75 g_list_free(user->group_ids);
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
76
6800
8f228a7d5076 [gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents: 6788
diff changeset
77 if (user->msnobj != NULL)
8f228a7d5076 [gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents: 6788
diff changeset
78 msn_object_destroy(user->msnobj);
8f228a7d5076 [gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents: 6788
diff changeset
79
5363
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
80 if (user->passport != NULL) g_free(user->passport);
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
81 if (user->name != NULL) g_free(user->name);
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
82
5363
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
83 if (user->phone.home != NULL) g_free(user->phone.home);
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
84 if (user->phone.work != NULL) g_free(user->phone.work);
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
85 if (user->phone.mobile != NULL) g_free(user->phone.mobile);
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
86
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
87 g_free(user);
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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
90 MsnUser *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
91 msn_user_ref(MsnUser *user)
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 g_return_val_if_fail(user != NULL, NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
94
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
95 user->ref_count++;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
96
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
97 return user;
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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
100 MsnUser *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
101 msn_user_unref(MsnUser *user)
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 g_return_val_if_fail(user != NULL, NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
104
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
105 if (user->ref_count <= 0)
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 user->ref_count--;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
109
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
110 if (user->ref_count == 0) {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
111 msn_user_destroy(user);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
112
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
113 return NULL;
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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
116 return user;
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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
119 void
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
120 msn_user_set_passport(MsnUser *user, const char *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 g_return_if_fail(user != NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
123
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
124 if (user->passport != NULL)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
125 g_free(user->passport);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
126
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
127 user->passport = g_strdup(passport);
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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
130 void
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
131 msn_user_set_name(MsnUser *user, const char *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 g_return_if_fail(user != NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
134
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
135 if (user->name != NULL)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
136 g_free(user->name);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
137
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
138 user->name = g_strdup(name);
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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
141 void
7590
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
142 msn_user_set_buddy_icon(MsnUser *user, const char *filename)
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
143 {
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
144 struct stat st;
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
145 FILE *fp;
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
146 MsnObject *msnobj = msn_user_get_object(user);
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
147
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
148 g_return_if_fail(user != NULL);
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
149
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
150 if (filename == NULL || stat(filename, &st) == -1)
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
151 msn_user_set_object(user, NULL);
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
152 else if ((fp = fopen(filename, "rb")) != NULL)
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
153 {
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
154 unsigned char *buf;
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
155 SHA_CTX ctx;
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
156 size_t len;
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
157 char *base64;
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
158 unsigned char digest[20];
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
159
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
160 if (msnobj == NULL)
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
161 {
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
162 msnobj = msn_object_new();
7591
24b9b6405f36 [gaim-migrate @ 8209]
Christian Hammond <chipx86@chipx86.com>
parents: 7590
diff changeset
163 msn_object_set_type(msnobj, MSN_OBJECT_USERTILE);
7590
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
164 msn_object_set_location(msnobj, "TFR2C.tmp");
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
165 msn_object_set_creator(msnobj, msn_user_get_passport(user));
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
166
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
167 msn_user_set_object(user, msnobj);
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
168 }
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
169
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
170 buf = g_malloc(st.st_size);
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
171 len = fread(buf, 1, st.st_size, fp);
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
172
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
173 fclose(fp);
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
174
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
175 /* Compute the SHA1D field. */
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
176 memset(digest, 0, sizeof(digest));
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
177
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
178 shaInit(&ctx);
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
179 shaUpdate(&ctx, buf, st.st_size);
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
180 shaFinal(&ctx, digest);
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
181 g_free(buf);
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
182
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
183 base64 = gaim_base64_encode(digest, sizeof(digest));
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
184 msn_object_set_sha1d(msnobj, base64);
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
185 g_free(base64);
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
186
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
187 msn_object_set_size(msnobj, st.st_size);
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
188
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
189 /* Compute the SHA1C field. */
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
190 buf = g_strdup_printf(
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
191 "Creator%sSize%dType%dLocation%sFriendly%sSHA1D%s",
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
192 msn_object_get_creator(msnobj),
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
193 msn_object_get_size(msnobj),
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
194 msn_object_get_type(msnobj),
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
195 msn_object_get_location(msnobj),
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
196 msn_object_get_friendly(msnobj),
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
197 msn_object_get_sha1d(msnobj));
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
198
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
199 memset(digest, 0, sizeof(digest));
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
200
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
201 shaInit(&ctx);
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
202 shaUpdate(&ctx, buf, strlen(buf));
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
203 shaFinal(&ctx, digest);
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
204 g_free(buf);
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
205
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
206 base64 = gaim_base64_encode(digest, sizeof(digest));
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
207 msn_object_set_sha1c(msnobj, base64);
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
208 g_free(base64);
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
209 }
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
210 else
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
211 {
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
212 gaim_debug_error("msn", "Unable to open buddy icon %s!\n", filename);
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
213 msn_user_set_object(user, NULL);
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
214 }
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
215 }
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
216
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 6858
diff changeset
217 void
6701
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
218 msn_user_set_group_ids(MsnUser *user, GList *ids)
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
219 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
220 g_return_if_fail(user != NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
221
6701
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
222 user->group_ids = ids;
5309
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
5363
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
225 void
6701
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
226 msn_user_add_group_id(MsnUser *user, int id)
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
227 {
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
228 g_return_if_fail(user != NULL);
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
229 g_return_if_fail(id > -1);
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
230
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
231 if (!g_list_find(user->group_ids, GINT_TO_POINTER(id)))
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
232 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
233 }
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
234
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
235 void
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
236 msn_user_remove_group_id(MsnUser *user, int id)
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
237 {
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
238 g_return_if_fail(user != NULL);
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
239 g_return_if_fail(id > -1);
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
240
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
241 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
242 }
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
243 void
5363
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
244 msn_user_set_home_phone(MsnUser *user, const char *number)
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
245 {
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
246 g_return_if_fail(user != NULL);
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 if (user->phone.home != NULL)
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
249 g_free(user->phone.home);
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 user->phone.home = (number == NULL ? NULL : g_strdup(number));
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 void
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
255 msn_user_set_work_phone(MsnUser *user, const char *number)
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_if_fail(user != 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 if (user->phone.work != NULL)
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
260 g_free(user->phone.work);
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 user->phone.work = (number == NULL ? NULL : g_strdup(number));
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
263 }
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 void
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
266 msn_user_set_mobile_phone(MsnUser *user, const char *number)
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
267 {
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
268 g_return_if_fail(user != NULL);
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
269
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
270 if (user->phone.mobile != NULL)
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
271 g_free(user->phone.mobile);
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
272
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
273 user->phone.mobile = (number == NULL ? NULL : g_strdup(number));
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
274 }
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
275
6788
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
276 void
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
277 msn_user_set_object(MsnUser *user, MsnObject *obj)
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
278 {
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
279 g_return_if_fail(user != NULL);
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
280
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
281 if (user->msnobj != NULL)
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
282 msn_object_destroy(user->msnobj);
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
283
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
284 user->msnobj = obj;
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
285 }
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
286
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
287 void
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
288 msn_user_set_client_caps(MsnUser *user, GHashTable *info)
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
289 {
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
290 g_return_if_fail(user != NULL);
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
291 g_return_if_fail(info != NULL);
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
292
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
293 if (user->clientcaps != NULL)
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
294 g_hash_table_destroy(user->clientcaps);
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
295
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
296 user->clientcaps = info;
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
297 }
5363
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
298
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
299 const char *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
300 msn_user_get_passport(const MsnUser *user)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
301 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
302 g_return_val_if_fail(user != NULL, NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
303
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
304 return user->passport;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
305 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
306
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
307 const char *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
308 msn_user_get_name(const MsnUser *user)
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_return_val_if_fail(user != NULL, NULL);
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 return user->name;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
313 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
314
6701
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
315 GList *
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
316 msn_user_get_group_ids(const MsnUser *user)
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
317 {
6701
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
318 g_return_val_if_fail(user != NULL, NULL);
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
319
6701
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5518
diff changeset
320 return user->group_ids;
5309
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
5363
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
323 const char *
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
324 msn_user_get_home_phone(const MsnUser *user)
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
325 {
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
326 g_return_val_if_fail(user != NULL, NULL);
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
327
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
328 return user->phone.home;
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
329 }
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
330
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
331 const char *
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
332 msn_user_get_work_phone(const MsnUser *user)
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
333 {
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
334 g_return_val_if_fail(user != NULL, NULL);
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
335
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
336 return user->phone.work;
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
337 }
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
338
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
339 const char *
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
340 msn_user_get_mobile_phone(const MsnUser *user)
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
341 {
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
342 g_return_val_if_fail(user != NULL, NULL);
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
343
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
344 return user->phone.mobile;
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
345 }
ebebc833cf77 [gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents: 5316
diff changeset
346
6788
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
347 MsnObject *
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
348 msn_user_get_object(const MsnUser *user)
5316
d5690ed70085 [gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents: 5309
diff changeset
349 {
6788
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
350 g_return_val_if_fail(user != NULL, NULL);
5316
d5690ed70085 [gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents: 5309
diff changeset
351
6788
c1995194e3d1 [gaim-migrate @ 7327]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
352 return user->msnobj;
5316
d5690ed70085 [gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents: 5309
diff changeset
353 }
d5690ed70085 [gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents: 5309
diff changeset
354
d5690ed70085 [gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents: 5309
diff changeset
355 GHashTable *
5475
ad9887c91a59 [gaim-migrate @ 5871]
Christian Hammond <chipx86@chipx86.com>
parents: 5363
diff changeset
356 msn_user_get_client_caps(const MsnUser *user)
5316
d5690ed70085 [gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents: 5309
diff changeset
357 {
d5690ed70085 [gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents: 5309
diff changeset
358 g_return_val_if_fail(user != NULL, NULL);
d5690ed70085 [gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents: 5309
diff changeset
359
5475
ad9887c91a59 [gaim-migrate @ 5871]
Christian Hammond <chipx86@chipx86.com>
parents: 5363
diff changeset
360 return user->clientcaps;
5316
d5690ed70085 [gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents: 5309
diff changeset
361 }
d5690ed70085 [gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents: 5309
diff changeset
362
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
363 MsnUsers *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
364 msn_users_new(void)
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 MsnUsers *users = g_new0(MsnUsers, 1);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
367
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
368 return users;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
369 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
370
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
371 void
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
372 msn_users_destroy(MsnUsers *users)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
373 {
5518
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
374 GList *l, *l_next = NULL;
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
375
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
376 g_return_if_fail(users != NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
377
5518
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
378 for (l = users->users; l != NULL; l = l_next) {
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
379 l_next = l->next;
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
380
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
381 msn_user_destroy(l->data);
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
382
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
383 users->users = g_list_remove(users->users, l->data);
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
384 }
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
385
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
386 /* See if we've leaked anybody. */
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
387 while (users->users != NULL) {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
388 gaim_debug(GAIM_DEBUG_WARNING, "msn",
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
389 "Leaking user %s\n",
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
390 msn_user_get_passport(users->users->data));
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
391 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
392
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
393 g_free(users);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
394 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
395
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
396 void
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
397 msn_users_add(MsnUsers *users, MsnUser *user)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
398 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
399 g_return_if_fail(users != NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
400 g_return_if_fail(user != NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
401
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
402 users->users = g_list_append(users->users, user);
5518
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
403
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
404 users->count++;
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
405 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
406
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
407 void
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
408 msn_users_remove(MsnUsers *users, MsnUser *user)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
409 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
410 g_return_if_fail(users != NULL);
5518
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
411 g_return_if_fail(user != NULL);
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
412
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
413 users->users = g_list_remove(users->users, user);
5518
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
414
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
415 users->count--;
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
416 }
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
417
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
418 size_t
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
419 msn_users_get_count(const MsnUsers *users)
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
420 {
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
421 g_return_val_if_fail(users != NULL, 0);
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
422
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5475
diff changeset
423 return users->count;
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
424 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
425
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
426 MsnUser *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
427 msn_users_find_with_passport(MsnUsers *users, const char *passport)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
428 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
429 GList *l;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
430
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
431 g_return_val_if_fail(users != NULL, NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
432 g_return_val_if_fail(passport != NULL, NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
433
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
434 for (l = users->users; l != NULL; l = l->next) {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
435 MsnUser *user = (MsnUser *)l->data;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
436
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
437 if (user->passport != NULL &&
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
438 !g_ascii_strcasecmp(passport, user->passport)) {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
439
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
440 return user;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
441 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
442 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
443
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
444 return NULL;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
445 }