Mercurial > pidgin.yaz
annotate libgaim/protocols/msn/user.c @ 20389:e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
to branch 'im.pidgin.rlaager.merging.soc-msnp13-to-svn18164' (head 5b5cde92182d2a922a8e7e6c2308342a5490a8c9)
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Sun, 15 Apr 2007 02:10:37 +0000 |
parents | 175d85e4c8fa |
children | 0b0ecee55091 |
rev | line source |
---|---|
14192 | 1 /** |
2 * @file user.c User functions | |
3 * | |
4 * gaim | |
5 * | |
6 * Gaim is the legal property of its developers, whose names are too numerous | |
7 * to list here. Please refer to the COPYRIGHT file distributed with this | |
8 * source distribution. | |
9 * | |
10 * This program is free software; you can redistribute it and/or modify | |
11 * it under the terms of the GNU General Public License as published by | |
12 * the Free Software Foundation; either version 2 of the License, or | |
13 * (at your option) any later version. | |
14 * | |
15 * This program is distributed in the hope that it will be useful, | |
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 * GNU General Public License for more details. | |
19 * | |
20 * You should have received a copy of the GNU General Public License | |
21 * along with this program; if not, write to the Free Software | |
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
23 */ | |
24 #include "msn.h" | |
25 #include "user.h" | |
26 #include "slp.h" | |
27 | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
28 /*new a user object*/ |
14192 | 29 MsnUser * |
30 msn_user_new(MsnUserList *userlist, const char *passport, | |
31 const char *store_name) | |
32 { | |
33 MsnUser *user; | |
34 | |
35 user = g_new0(MsnUser, 1); | |
36 | |
37 user->userlist = userlist; | |
38 | |
39 msn_user_set_passport(user, passport); | |
40 msn_user_set_store_name(user, store_name); | |
41 | |
42 /* | |
43 * XXX This seems to reset the friendly name from what it should be | |
44 * to the passport when moving users. So, screw it :) | |
45 */ | |
46 #if 0 | |
47 if (name != NULL) | |
48 msn_user_set_name(user, name); | |
49 #endif | |
50 | |
51 return user; | |
52 } | |
53 | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
54 /*destroy a user object*/ |
14192 | 55 void |
56 msn_user_destroy(MsnUser *user) | |
57 { | |
58 g_return_if_fail(user != NULL); | |
59 | |
60 if (user->clientcaps != NULL) | |
61 g_hash_table_destroy(user->clientcaps); | |
62 | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
63 if (user->group_ids != NULL){ |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
64 GList *l; |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
65 for (l = user->group_ids; l != NULL; l = l->next){ |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
66 g_free(l->data); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
67 } |
14192 | 68 g_list_free(user->group_ids); |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
69 } |
14192 | 70 |
71 if (user->msnobj != NULL) | |
72 msn_object_destroy(user->msnobj); | |
73 | |
74 g_free(user->passport); | |
75 g_free(user->friendly_name); | |
76 g_free(user->store_name); | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
77 g_free(user->uid); |
14192 | 78 g_free(user->phone.home); |
79 g_free(user->phone.work); | |
80 g_free(user->phone.mobile); | |
81 | |
82 g_free(user); | |
83 } | |
84 | |
85 void | |
86 msn_user_update(MsnUser *user) | |
87 { | |
88 GaimAccount *account; | |
89 | |
90 account = user->userlist->session->account; | |
91 | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
92 if (user->statusline != NULL) { |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
93 char *status = g_strdup_printf("%s - %s", user->status, user->statusline); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
94 gaim_prpl_got_user_status(account, user->passport, user->status, "message", user->statusline, NULL); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
95 } |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
96 else if (user->status != NULL) { |
14192 | 97 gaim_prpl_got_user_status(account, user->passport, user->status, NULL); |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
98 } |
14192 | 99 |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
100 if (user->idle){ |
14192 | 101 gaim_prpl_got_user_idle(account, user->passport, TRUE, -1); |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
102 }else{ |
14192 | 103 gaim_prpl_got_user_idle(account, user->passport, FALSE, 0); |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
104 } |
14192 | 105 } |
106 | |
107 void | |
108 msn_user_set_state(MsnUser *user, const char *state) | |
109 { | |
110 const char *status; | |
111 | |
112 if (!g_ascii_strcasecmp(state, "BSY")) | |
113 status = "busy"; | |
114 else if (!g_ascii_strcasecmp(state, "BRB")) | |
115 status = "brb"; | |
116 else if (!g_ascii_strcasecmp(state, "AWY")) | |
117 status = "away"; | |
118 else if (!g_ascii_strcasecmp(state, "PHN")) | |
119 status = "phone"; | |
120 else if (!g_ascii_strcasecmp(state, "LUN")) | |
121 status = "lunch"; | |
122 else | |
123 status = "available"; | |
124 | |
125 if (!g_ascii_strcasecmp(state, "IDL")) | |
126 user->idle = TRUE; | |
127 else | |
128 user->idle = FALSE; | |
129 | |
130 user->status = status; | |
131 } | |
132 | |
133 void | |
134 msn_user_set_passport(MsnUser *user, const char *passport) | |
135 { | |
136 g_return_if_fail(user != NULL); | |
137 | |
138 g_free(user->passport); | |
139 user->passport = g_strdup(passport); | |
140 } | |
141 | |
142 void | |
143 msn_user_set_friendly_name(MsnUser *user, const char *name) | |
144 { | |
145 g_return_if_fail(user != NULL); | |
146 | |
147 g_free(user->friendly_name); | |
148 user->friendly_name = g_strdup(name); | |
149 } | |
150 | |
151 void | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
152 msn_user_set_statusline(MsnUser *user, const char *statusline) |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
153 { |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
154 g_return_if_fail(user != NULL); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
155 |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
156 g_free(user->statusline); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
157 user->statusline = g_strdup(statusline); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
158 } |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
159 |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
160 void |
14192 | 161 msn_user_set_store_name(MsnUser *user, const char *name) |
162 { | |
163 g_return_if_fail(user != NULL); | |
164 | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
165 if (name != NULL){ |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
166 g_free(user->store_name); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
167 user->store_name = g_strdup(name); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
168 } |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
169 } |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
170 |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
171 void |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
172 msn_user_set_uid(MsnUser *user, const char *uid) |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
173 { |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
174 g_return_if_fail(user != NULL); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
175 |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
176 g_free(user->uid); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
177 user->uid = g_strdup(uid); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
178 } |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
179 |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
180 void |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
181 msn_user_set_type(MsnUser *user,int type) |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
182 { |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
183 g_return_if_fail(user != NULL); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
184 |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
185 user->type = type; |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
186 } |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
187 |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
188 void |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
189 msn_user_set_op(MsnUser *user,int list_op) |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
190 { |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
191 g_return_if_fail(list_op != NULL); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
192 user->list_op |= list_op; |
14192 | 193 } |
194 | |
195 void | |
196 msn_user_set_buddy_icon(MsnUser *user, const char *filename) | |
197 { | |
198 struct stat st; | |
199 FILE *fp; | |
200 MsnObject *msnobj = msn_user_get_object(user); | |
201 | |
202 g_return_if_fail(user != NULL); | |
203 | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
204 if (filename == NULL || g_stat(filename, &st) == -1){ |
14192 | 205 msn_user_set_object(user, NULL); |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
206 }else if ((fp = g_fopen(filename, "rb")) != NULL){ |
14192 | 207 GaimCipherContext *ctx; |
208 char *buf; | |
209 gsize len; | |
210 char *base64; | |
211 unsigned char digest[20]; | |
212 | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
213 if (msnobj == NULL) { |
14192 | 214 msnobj = msn_object_new(); |
215 msn_object_set_local(msnobj); | |
216 msn_object_set_type(msnobj, MSN_OBJECT_USERTILE); | |
217 msn_object_set_location(msnobj, "TFR2C2.tmp"); | |
218 msn_object_set_creator(msnobj, msn_user_get_passport(user)); | |
219 | |
220 msn_user_set_object(user, msnobj); | |
221 } | |
222 | |
223 msn_object_set_real_location(msnobj, filename); | |
224 | |
225 buf = g_malloc(st.st_size); | |
226 len = fread(buf, 1, st.st_size, fp); | |
227 | |
228 fclose(fp); | |
229 | |
230 /* Compute the SHA1D field. */ | |
231 memset(digest, 0, sizeof(digest)); | |
232 | |
233 ctx = gaim_cipher_context_new_by_name("sha1", NULL); | |
234 gaim_cipher_context_append(ctx, (const guchar *)buf, st.st_size); | |
235 gaim_cipher_context_digest(ctx, sizeof(digest), digest, NULL); | |
236 g_free(buf); | |
237 | |
238 base64 = gaim_base64_encode(digest, sizeof(digest)); | |
239 msn_object_set_sha1d(msnobj, base64); | |
240 g_free(base64); | |
241 | |
242 msn_object_set_size(msnobj, st.st_size); | |
243 | |
244 /* Compute the SHA1C field. */ | |
245 buf = g_strdup_printf( | |
246 "Creator%sSize%dType%dLocation%sFriendly%sSHA1D%s", | |
247 msn_object_get_creator(msnobj), | |
248 msn_object_get_size(msnobj), | |
249 msn_object_get_type(msnobj), | |
250 msn_object_get_location(msnobj), | |
251 msn_object_get_friendly(msnobj), | |
252 msn_object_get_sha1d(msnobj)); | |
253 | |
254 memset(digest, 0, sizeof(digest)); | |
255 | |
256 gaim_cipher_context_reset(ctx, NULL); | |
257 gaim_cipher_context_append(ctx, (const guchar *)buf, strlen(buf)); | |
258 gaim_cipher_context_digest(ctx, sizeof(digest), digest, NULL); | |
259 gaim_cipher_context_destroy(ctx); | |
260 g_free(buf); | |
261 | |
262 base64 = gaim_base64_encode(digest, sizeof(digest)); | |
263 msn_object_set_sha1c(msnobj, base64); | |
264 g_free(base64); | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
265 }else{ |
14192 | 266 gaim_debug_error("msn", "Unable to open buddy icon %s!\n", filename); |
267 msn_user_set_object(user, NULL); | |
268 } | |
269 } | |
270 | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
271 /*add group id to User object*/ |
14192 | 272 void |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
273 msn_user_add_group_id(MsnUser *user, const char* id) |
14192 | 274 { |
275 MsnUserList *userlist; | |
276 GaimAccount *account; | |
277 GaimBuddy *b; | |
278 GaimGroup *g; | |
279 const char *passport; | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
280 const char *group_id; |
14192 | 281 const char *group_name; |
282 | |
283 g_return_if_fail(user != NULL); | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
284 g_return_if_fail(id != NULL); |
14192 | 285 |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
286 group_id = g_strdup(id); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
287 user->group_ids = g_list_append(user->group_ids,group_id); |
14192 | 288 |
289 userlist = user->userlist; | |
290 account = userlist->session->account; | |
291 passport = msn_user_get_passport(user); | |
292 | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
293 group_name = msn_userlist_find_group_name(userlist, group_id); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
294 |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
295 gaim_debug_info("User","group id:%s,name:%s,user:%s\n",group_id,group_name,passport); |
14192 | 296 |
297 g = gaim_find_group(group_name); | |
298 | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
299 if ((id == NULL) && (g == NULL)){ |
14192 | 300 g = gaim_group_new(group_name); |
301 gaim_blist_add_group(g, NULL); | |
302 } | |
303 | |
304 b = gaim_find_buddy_in_group(account, passport, g); | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
305 if (b == NULL){ |
14192 | 306 b = gaim_buddy_new(account, passport, NULL); |
307 gaim_blist_add_buddy(b, NULL, g, NULL); | |
308 } | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
309 b->proto_data = user; |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
310 /*Update the blist Node info*/ |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
311 // gaim_blist_node_set_string(&(b->node), "", ""); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
312 } |
14192 | 313 |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
314 /*check if the msn user is online*/ |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
315 gboolean |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
316 msn_user_is_online(GaimAccount *account, const char *name) |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
317 { |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
318 GaimBuddy *buddy; |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
319 |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
320 buddy =gaim_find_buddy(account,name); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
321 return GAIM_BUDDY_IS_ONLINE(buddy); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
322 } |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
323 |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
324 /*check to see if user is yahoo user? |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
325 * TODO: we need to identify it via contact parse |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
326 */ |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
327 gboolean |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
328 msn_user_is_yahoo(GaimAccount *account ,const char *name) |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
329 { |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
330 return (strstr(name,"yahoo") != NULL); |
14192 | 331 } |
332 | |
333 void | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
334 msn_user_remove_group_id(MsnUser *user, const char * id) |
14192 | 335 { |
336 g_return_if_fail(user != NULL); | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
337 g_return_if_fail(id != NULL); |
14192 | 338 |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
339 user->group_ids = g_list_remove(user->group_ids, id); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
14763
diff
changeset
|
340 g_free(id); |
14192 | 341 } |
342 | |
343 void | |
344 msn_user_set_home_phone(MsnUser *user, const char *number) | |
345 { | |
346 g_return_if_fail(user != NULL); | |
347 | |
348 if (user->phone.home != NULL) | |
349 g_free(user->phone.home); | |
350 | |
351 user->phone.home = (number == NULL ? NULL : g_strdup(number)); | |
352 } | |
353 | |
354 void | |
355 msn_user_set_work_phone(MsnUser *user, const char *number) | |
356 { | |
357 g_return_if_fail(user != NULL); | |
358 | |
359 if (user->phone.work != NULL) | |
360 g_free(user->phone.work); | |
361 | |
362 user->phone.work = (number == NULL ? NULL : g_strdup(number)); | |
363 } | |
364 | |
365 void | |
366 msn_user_set_mobile_phone(MsnUser *user, const char *number) | |
367 { | |
368 g_return_if_fail(user != NULL); | |
369 | |
370 if (user->phone.mobile != NULL) | |
371 g_free(user->phone.mobile); | |
372 | |
373 user->phone.mobile = (number == NULL ? NULL : g_strdup(number)); | |
374 } | |
375 | |
376 void | |
377 msn_user_set_object(MsnUser *user, MsnObject *obj) | |
378 { | |
379 g_return_if_fail(user != NULL); | |
380 | |
381 if (user->msnobj != NULL) | |
382 msn_object_destroy(user->msnobj); | |
383 | |
384 user->msnobj = obj; | |
385 | |
386 if (user->list_op & MSN_LIST_FL_OP) | |
387 msn_queue_buddy_icon_request(user); | |
388 } | |
389 | |
390 void | |
391 msn_user_set_client_caps(MsnUser *user, GHashTable *info) | |
392 { | |
393 g_return_if_fail(user != NULL); | |
394 g_return_if_fail(info != NULL); | |
395 | |
396 if (user->clientcaps != NULL) | |
397 g_hash_table_destroy(user->clientcaps); | |
398 | |
399 user->clientcaps = info; | |
400 } | |
401 | |
402 const char * | |
403 msn_user_get_passport(const MsnUser *user) | |
404 { | |
405 g_return_val_if_fail(user != NULL, NULL); | |
406 | |
407 return user->passport; | |
408 } | |
409 | |
410 const char * | |
411 msn_user_get_friendly_name(const MsnUser *user) | |
412 { | |
413 g_return_val_if_fail(user != NULL, NULL); | |
414 | |
415 return user->friendly_name; | |
416 } | |
417 | |
418 const char * | |
419 msn_user_get_store_name(const MsnUser *user) | |
420 { | |
421 g_return_val_if_fail(user != NULL, NULL); | |
422 | |
423 return user->store_name; | |
424 } | |
425 | |
426 const char * | |
427 msn_user_get_home_phone(const MsnUser *user) | |
428 { | |
429 g_return_val_if_fail(user != NULL, NULL); | |
430 | |
431 return user->phone.home; | |
432 } | |
433 | |
434 const char * | |
435 msn_user_get_work_phone(const MsnUser *user) | |
436 { | |
437 g_return_val_if_fail(user != NULL, NULL); | |
438 | |
439 return user->phone.work; | |
440 } | |
441 | |
442 const char * | |
443 msn_user_get_mobile_phone(const MsnUser *user) | |
444 { | |
445 g_return_val_if_fail(user != NULL, NULL); | |
446 | |
447 return user->phone.mobile; | |
448 } | |
449 | |
450 MsnObject * | |
451 msn_user_get_object(const MsnUser *user) | |
452 { | |
453 g_return_val_if_fail(user != NULL, NULL); | |
454 | |
455 return user->msnobj; | |
456 } | |
457 | |
458 GHashTable * | |
459 msn_user_get_client_caps(const MsnUser *user) | |
460 { | |
461 g_return_val_if_fail(user != NULL, NULL); | |
462 | |
463 return user->clientcaps; | |
464 } |