Mercurial > pidgin.yaz
annotate src/protocols/msn/notification.c @ 5481:084147a0d9e4
[gaim-migrate @ 5877]
This is the first thing to use the new request API.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Thu, 22 May 2003 10:21:55 +0000 |
parents | 175de59cd1c5 |
children | cce2d7868c78 |
rev | line source |
---|---|
5309 | 1 /** |
2 * @file notification.c Notification server functions | |
3 * | |
4 * gaim | |
5 * | |
6 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org> | |
7 * | |
8 * This program is free software; you can redistribute it and/or modify | |
9 * it under the terms of the GNU General Public License as published by | |
10 * the Free Software Foundation; either version 2 of the License, or | |
11 * (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, | |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 * GNU General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU General Public License | |
19 * along with this program; if not, write to the Free Software | |
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 */ | |
22 #include "msn.h" | |
23 #include "notification.h" | |
5361
953aa05279f4
[gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
5358
diff
changeset
|
24 #include "state.h" |
5309 | 25 #include "error.h" |
26 #include "utils.h" | |
27 | |
28 typedef struct | |
29 { | |
30 struct gaim_connection *gc; | |
31 MsnUser *user; | |
32 | |
33 } MsnPermitAdd; | |
34 | |
35 static GHashTable *notification_commands = NULL; | |
36 static GHashTable *notification_msg_types = NULL; | |
5312
89948fedf782
[gaim-migrate @ 5684]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
37 G_MODULE_IMPORT GSList *connections; |
5309 | 38 |
39 /************************************************************************** | |
5457
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
40 * Utility functions |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
41 **************************************************************************/ |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
42 static gboolean |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
43 __add_buddy(MsnServConn *servconn, MsnUser *user) |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
44 { |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
45 MsnSession *session = servconn->session; |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
46 struct gaim_connection *gc = session->account->gc; |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
47 struct buddy *b; |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
48 |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
49 b = gaim_find_buddy(gc->account, msn_user_get_passport(user)); |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
50 |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
51 if (b == NULL) { |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
52 struct group *g = NULL; |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
53 const char *group_name = NULL; |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
54 int group_id; |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
55 |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
56 group_id = msn_user_get_group_id(user); |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
57 |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
58 if (group_id > -1) { |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
59 group_name = g_hash_table_lookup(session->group_names, |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
60 &group_id); |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
61 } |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
62 |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
63 if (group_name == NULL) { |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
64 gaim_debug(GAIM_DEBUG_WARNING, "msn", |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
65 "Group ID %d for user %s was not defined.\n", |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
66 group_id, msn_user_get_passport(user)); |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
67 } |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
68 else if ((g = gaim_find_group(group_name)) == NULL) { |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
69 gaim_debug(GAIM_DEBUG_ERROR, "msn", |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
70 "Group '%s' appears in server-side " |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
71 "buddy list, but not here!", |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
72 group_name); |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
73 } |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
74 |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
75 if (g == NULL) { |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
76 if ((g = gaim_find_group(_("Buddies"))) == NULL) { |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
77 g = gaim_group_new(_("Buddies")); |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
78 gaim_blist_add_group(g, NULL); |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
79 } |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
80 } |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
81 |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
82 b = gaim_buddy_new(gc->account, |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
83 msn_user_get_passport(user), NULL); |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
84 |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
85 gaim_blist_add_buddy(b, g, NULL); |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
86 } |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
87 |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
88 b->proto_data = user; |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
89 |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
90 serv_got_alias(gc, (char *)msn_user_get_passport(user), |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
91 (char *)msn_user_get_name(user)); |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
92 |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
93 return TRUE; |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
94 } |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
95 |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
96 |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
97 /************************************************************************** |
5309 | 98 * Callbacks |
99 **************************************************************************/ | |
100 static void | |
101 msn_accept_add_cb(MsnPermitAdd *pa) | |
102 { | |
103 if (g_slist_find(connections, pa->gc) != NULL) { | |
104 MsnSession *session = pa->gc->proto_data; | |
105 char outparams[MSN_BUF_LEN]; | |
106 | |
107 g_snprintf(outparams, sizeof(outparams), "AL %s %s", | |
108 msn_user_get_passport(pa->user), | |
109 msn_url_encode(msn_user_get_name(pa->user))); | |
110 | |
111 if (msn_servconn_send_command(session->notification_conn, | |
112 "ADD", outparams) <= 0) { | |
113 hide_login_progress(pa->gc, _("Write error")); | |
114 signoff(pa->gc); | |
115 return; | |
116 } | |
117 | |
118 gaim_privacy_permit_add(pa->gc->account, | |
119 msn_user_get_passport(pa->user)); | |
120 build_allow_list(); | |
121 | |
122 show_got_added(pa->gc, NULL, msn_user_get_passport(pa->user), | |
123 msn_user_get_name(pa->user), NULL); | |
124 } | |
125 | |
126 msn_user_destroy(pa->user); | |
127 g_free(pa); | |
128 } | |
129 | |
130 static void | |
131 msn_cancel_add_cb(MsnPermitAdd *pa) | |
132 { | |
133 if (g_slist_find(connections, pa->gc) != NULL) { | |
134 MsnSession *session = pa->gc->proto_data; | |
135 char outparams[MSN_BUF_LEN]; | |
136 | |
137 g_snprintf(outparams, sizeof(outparams), "BL %s %s", | |
138 msn_user_get_passport(pa->user), | |
139 msn_url_encode(msn_user_get_name(pa->user))); | |
140 | |
141 if (msn_servconn_send_command(session->notification_conn, | |
142 "ADD", outparams) <= 0) { | |
143 hide_login_progress(pa->gc, _("Write error")); | |
144 signoff(pa->gc); | |
145 return; | |
146 } | |
147 | |
148 gaim_privacy_deny_add(pa->gc->account, | |
149 msn_user_get_passport(pa->user)); | |
150 build_block_list(); | |
151 } | |
152 | |
153 msn_user_destroy(pa->user); | |
154 g_free(pa); | |
155 } | |
156 | |
157 /************************************************************************** | |
158 * Catch-all commands | |
159 **************************************************************************/ | |
160 static gboolean | |
161 __blank_cmd(MsnServConn *servconn, const char *command, const char **params, | |
162 size_t param_count) | |
163 { | |
164 return TRUE; | |
165 } | |
166 | |
167 static gboolean | |
168 __unknown_cmd(MsnServConn *servconn, const char *command, const char **params, | |
169 size_t param_count) | |
170 { | |
5318
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
171 char buf[MSN_BUF_LEN]; |
5309 | 172 |
5334
bbf2141d30d0
[gaim-migrate @ 5709]
Christian Hammond <chipx86@chipx86.com>
parents:
5333
diff
changeset
|
173 if (isdigit(*command)) { |
bbf2141d30d0
[gaim-migrate @ 5709]
Christian Hammond <chipx86@chipx86.com>
parents:
5333
diff
changeset
|
174 int errnum = atoi(command); |
bbf2141d30d0
[gaim-migrate @ 5709]
Christian Hammond <chipx86@chipx86.com>
parents:
5333
diff
changeset
|
175 |
bbf2141d30d0
[gaim-migrate @ 5709]
Christian Hammond <chipx86@chipx86.com>
parents:
5333
diff
changeset
|
176 if (errnum == 225) { |
bbf2141d30d0
[gaim-migrate @ 5709]
Christian Hammond <chipx86@chipx86.com>
parents:
5333
diff
changeset
|
177 /* |
bbf2141d30d0
[gaim-migrate @ 5709]
Christian Hammond <chipx86@chipx86.com>
parents:
5333
diff
changeset
|
178 * Ignore this. It happens as a result of moving a buddy from |
bbf2141d30d0
[gaim-migrate @ 5709]
Christian Hammond <chipx86@chipx86.com>
parents:
5333
diff
changeset
|
179 * one group that isn't on the server to another that is. |
bbf2141d30d0
[gaim-migrate @ 5709]
Christian Hammond <chipx86@chipx86.com>
parents:
5333
diff
changeset
|
180 * The user doesn't care if the old group was there or not. |
bbf2141d30d0
[gaim-migrate @ 5709]
Christian Hammond <chipx86@chipx86.com>
parents:
5333
diff
changeset
|
181 */ |
bbf2141d30d0
[gaim-migrate @ 5709]
Christian Hammond <chipx86@chipx86.com>
parents:
5333
diff
changeset
|
182 return TRUE; |
bbf2141d30d0
[gaim-migrate @ 5709]
Christian Hammond <chipx86@chipx86.com>
parents:
5333
diff
changeset
|
183 } |
bbf2141d30d0
[gaim-migrate @ 5709]
Christian Hammond <chipx86@chipx86.com>
parents:
5333
diff
changeset
|
184 |
bbf2141d30d0
[gaim-migrate @ 5709]
Christian Hammond <chipx86@chipx86.com>
parents:
5333
diff
changeset
|
185 g_snprintf(buf, sizeof(buf), "MSN Error: %s\n", |
bbf2141d30d0
[gaim-migrate @ 5709]
Christian Hammond <chipx86@chipx86.com>
parents:
5333
diff
changeset
|
186 msn_error_get_text(errnum)); |
bbf2141d30d0
[gaim-migrate @ 5709]
Christian Hammond <chipx86@chipx86.com>
parents:
5333
diff
changeset
|
187 } |
bbf2141d30d0
[gaim-migrate @ 5709]
Christian Hammond <chipx86@chipx86.com>
parents:
5333
diff
changeset
|
188 else { |
bbf2141d30d0
[gaim-migrate @ 5709]
Christian Hammond <chipx86@chipx86.com>
parents:
5333
diff
changeset
|
189 g_snprintf(buf, sizeof(buf), "MSN Error: Unable to parse message\n"); |
bbf2141d30d0
[gaim-migrate @ 5709]
Christian Hammond <chipx86@chipx86.com>
parents:
5333
diff
changeset
|
190 } |
5309 | 191 |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5406
diff
changeset
|
192 gaim_notify_error(servconn->session->account->gc, NULL, buf, NULL); |
5309 | 193 |
5318
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
194 return TRUE; |
5309 | 195 } |
196 | |
197 | |
198 /************************************************************************** | |
199 * Login | |
200 **************************************************************************/ | |
201 static gboolean | |
202 __ver_cmd(MsnServConn *servconn, const char *command, const char **params, | |
203 size_t param_count) | |
204 { | |
205 struct gaim_connection *gc = servconn->session->account->gc; | |
206 size_t i; | |
207 gboolean msnp5_found = FALSE; | |
208 | |
209 for (i = 1; i < param_count; i++) { | |
210 if (!strcmp(params[i], "MSNP5")) { | |
211 msnp5_found = TRUE; | |
212 break; | |
213 } | |
214 } | |
215 | |
216 if (!msnp5_found) { | |
217 hide_login_progress(gc, _("Protocol not supported")); | |
218 signoff(gc); | |
219 | |
220 return FALSE; | |
221 } | |
222 | |
223 if (!msn_servconn_send_command(servconn, "INF", NULL)) { | |
224 hide_login_progress(gc, _("Unable to request INF")); | |
225 signoff(gc); | |
226 | |
227 return FALSE; | |
228 } | |
229 | |
230 return TRUE; | |
231 } | |
232 | |
233 static gboolean | |
234 __inf_cmd(MsnServConn *servconn, const char *command, const char **params, | |
235 size_t param_count) | |
236 { | |
237 struct gaim_connection *gc = servconn->session->account->gc; | |
238 char outparams[MSN_BUF_LEN]; | |
239 | |
240 if (strcmp(params[1], "MD5")) { | |
241 hide_login_progress(gc, _("Unable to login using MD5")); | |
242 signoff(gc); | |
243 | |
244 return FALSE; | |
245 } | |
246 | |
247 g_snprintf(outparams, sizeof(outparams), "MD5 I %s", gc->username); | |
248 | |
249 if (!msn_servconn_send_command(servconn, "USR", outparams)) { | |
250 hide_login_progress(gc, _("Unable to send USR")); | |
251 signoff(gc); | |
252 | |
253 return FALSE; | |
254 } | |
255 | |
5326
9737d5ce9dcd
[gaim-migrate @ 5699]
Christian Hammond <chipx86@chipx86.com>
parents:
5323
diff
changeset
|
256 set_login_progress(gc, 4, _("Requesting to send password")); |
5309 | 257 |
258 return TRUE; | |
259 } | |
260 | |
261 static gboolean | |
262 __usr_cmd(MsnServConn *servconn, const char *command, const char **params, | |
263 size_t param_count) | |
264 { | |
5326
9737d5ce9dcd
[gaim-migrate @ 5699]
Christian Hammond <chipx86@chipx86.com>
parents:
5323
diff
changeset
|
265 MsnSession *session = servconn->session; |
9737d5ce9dcd
[gaim-migrate @ 5699]
Christian Hammond <chipx86@chipx86.com>
parents:
5323
diff
changeset
|
266 struct gaim_connection *gc = session->account->gc; |
5309 | 267 char outparams[MSN_BUF_LEN]; |
268 | |
269 /* We're either getting the challenge or the OK. Let's find out. */ | |
270 if (!g_ascii_strcasecmp(params[1], "OK")) { | |
271 /* OK */ | |
272 | |
5456
40e976d42028
[gaim-migrate @ 5844]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
273 session->syncing_lists = TRUE; |
40e976d42028
[gaim-migrate @ 5844]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
274 |
5309 | 275 if (!msn_servconn_send_command(servconn, "SYN", "0")) { |
276 hide_login_progress(gc, _("Unable to write")); | |
277 signoff(gc); | |
278 | |
279 return FALSE; | |
280 } | |
5326
9737d5ce9dcd
[gaim-migrate @ 5699]
Christian Hammond <chipx86@chipx86.com>
parents:
5323
diff
changeset
|
281 |
9737d5ce9dcd
[gaim-migrate @ 5699]
Christian Hammond <chipx86@chipx86.com>
parents:
5323
diff
changeset
|
282 set_login_progress(session->account->gc, 4, _("Retrieving buddy list")); |
5309 | 283 } |
284 else { | |
285 /* Challenge */ | |
286 const char *challenge = params[3]; | |
287 char buf[MSN_BUF_LEN]; | |
288 md5_state_t st; | |
289 md5_byte_t di[16]; | |
290 int i; | |
291 | |
292 g_snprintf(buf, sizeof(buf), "%s%s", challenge, gc->password); | |
293 | |
294 md5_init(&st); | |
295 md5_append(&st, (const md5_byte_t *)buf, strlen(buf)); | |
296 md5_finish(&st, di); | |
297 | |
298 g_snprintf(outparams, sizeof(outparams), "MD5 S "); | |
299 | |
300 for (i = 0; i < 16; i++) { | |
301 g_snprintf(buf, sizeof(buf), "%02x", di[i]); | |
302 strcat(outparams, buf); | |
303 } | |
304 | |
305 if (!msn_servconn_send_command(servconn, "USR", outparams)) { | |
306 hide_login_progress(gc, _("Unable to send password")); | |
307 signoff(gc); | |
308 | |
309 return FALSE; | |
310 } | |
311 | |
312 set_login_progress(gc, 4, _("Password sent")); | |
313 } | |
314 | |
315 return TRUE; | |
316 } | |
317 | |
318 /************************************************************************** | |
319 * Log out | |
320 **************************************************************************/ | |
321 static gboolean | |
322 __out_cmd(MsnServConn *servconn, const char *command, const char **params, | |
323 size_t param_count) | |
324 { | |
325 struct gaim_connection *gc = servconn->session->account->gc; | |
326 | |
327 if (!g_ascii_strcasecmp(params[0], "OTH")) { | |
328 hide_login_progress(gc, | |
329 _("You have been disconnected. You have " | |
330 "signed on from another location.")); | |
331 signoff(gc); | |
332 } | |
333 else if (!g_ascii_strcasecmp(params[0], "SSD")) { | |
334 hide_login_progress(gc, | |
335 _("You have been disconnected. The MSN servers " | |
336 "are going down temporarily.")); | |
337 signoff(gc); | |
338 } | |
339 | |
340 return FALSE; | |
341 } | |
342 | |
343 /************************************************************************** | |
344 * Messages | |
345 **************************************************************************/ | |
346 static gboolean | |
347 __msg_cmd(MsnServConn *servconn, const char *command, const char **params, | |
348 size_t param_count) | |
349 { | |
350 gaim_debug(GAIM_DEBUG_INFO, "msn", "Found message. Parsing.\n"); | |
351 | |
352 servconn->parsing_msg = TRUE; | |
353 servconn->msg_passport = g_strdup(params[0]); | |
354 servconn->msg_friendly = g_strdup(params[1]); | |
355 servconn->msg_len = atoi(params[2]); | |
356 | |
357 return TRUE; | |
358 } | |
359 | |
360 /************************************************************************** | |
361 * Challenges | |
362 **************************************************************************/ | |
363 static gboolean | |
364 __chl_cmd(MsnServConn *servconn, const char *command, const char **params, | |
365 size_t param_count) | |
366 { | |
367 struct gaim_connection *gc = servconn->session->account->gc; | |
368 char buf[MSN_BUF_LEN]; | |
369 char buf2[3]; | |
370 md5_state_t st; | |
371 md5_byte_t di[16]; | |
372 int i; | |
373 | |
374 md5_init(&st); | |
375 md5_append(&st, (const md5_byte_t *)params[1], strlen(params[1])); | |
376 md5_append(&st, (const md5_byte_t *)"Q1P7W2E4J9R8U3S5", | |
377 strlen("Q1P7W2E4J9R8U3S5")); | |
378 md5_finish(&st, di); | |
379 | |
380 g_snprintf(buf, sizeof(buf), | |
381 "QRY %u msmsgs@msnmsgr.com 32\r\n", | |
382 servconn->session->trId++); | |
383 | |
384 for (i = 0; i < 16; i++) { | |
385 g_snprintf(buf2, sizeof(buf2), "%02x", di[i]); | |
386 strcat(buf, buf2); | |
387 } | |
388 | |
389 if (msn_servconn_write(servconn, buf, strlen(buf)) <= 0) { | |
390 hide_login_progress(gc, _("Unable to write to server")); | |
391 signoff(gc); | |
392 } | |
393 | |
394 return TRUE; | |
395 } | |
396 | |
397 /************************************************************************** | |
398 * Buddy Lists | |
399 **************************************************************************/ | |
400 static gboolean | |
401 __add_cmd(MsnServConn *servconn, const char *command, const char **params, | |
402 size_t param_count) | |
403 { | |
404 MsnSession *session = servconn->session; | |
5457
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
405 MsnUser *user; |
5309 | 406 struct gaim_connection *gc = session->account->gc; |
407 MsnPermitAdd *pa; | |
408 GSList *sl; | |
409 const char *list, *passport; | |
410 char *friend; | |
411 char msg[MSN_BUF_LEN]; | |
412 | |
413 list = params[1]; | |
414 passport = params[3]; | |
415 | |
416 friend = msn_url_decode(params[4]); | |
417 | |
5457
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
418 if (!g_ascii_strcasecmp(list, "FL")) { |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
419 user = msn_user_new(session, passport, friend); |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
420 |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
421 __add_buddy(servconn, user); |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
422 |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
423 return TRUE; |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
424 } |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
425 else if (g_ascii_strcasecmp(list, "RL")) |
5309 | 426 return TRUE; |
427 | |
428 for (sl = gc->account->permit; sl != NULL; sl = sl->next) { | |
429 if (!gaim_utf8_strcasecmp(sl->data, passport)) | |
430 return TRUE; | |
431 } | |
432 | |
5457
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
433 user = msn_user_new(session, passport, friend); |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
434 |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
435 pa = g_new0(MsnPermitAdd, 1); |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
436 pa->user = user; |
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
437 pa->gc = gc; |
5309 | 438 |
439 g_snprintf(msg, sizeof(msg), | |
440 _("The user %s (%s) wants to add %s to his or her buddy list."), | |
441 passport, friend, gc->username); | |
442 | |
443 do_ask_dialog(msg, NULL, pa, | |
444 _("Authorize"), msn_accept_add_cb, | |
445 _("Deny"), msn_cancel_add_cb, | |
446 session->prpl->handle, FALSE); | |
447 | |
448 return TRUE; | |
449 } | |
450 | |
451 static gboolean | |
5322
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
452 __adg_cmd(MsnServConn *servconn, const char *command, const char **params, |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
453 size_t param_count) |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
454 { |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
455 MsnSession *session = servconn->session; |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
456 gint *group_id; |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
457 char *group_name; |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
458 |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
459 group_id = g_new(gint, 1); |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
460 *group_id = atoi(params[3]); |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
461 |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
462 group_name = msn_url_decode(params[2]); |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
463 |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
464 gaim_debug(GAIM_DEBUG_INFO, "msn", "Added group %s (id %d)\n", |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
465 group_name, group_id); |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
466 |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
467 g_hash_table_insert(session->group_ids, group_name, group_id); |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
468 g_hash_table_insert(session->group_names, group_id, g_strdup(group_name)); |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
469 |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
470 return TRUE; |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
471 } |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
472 |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
473 static gboolean |
5309 | 474 __blp_cmd(MsnServConn *servconn, const char *command, const char **params, |
475 size_t param_count) | |
476 { | |
477 struct gaim_connection *gc = servconn->session->account->gc; | |
478 | |
479 if (!g_ascii_strcasecmp(params[2], "AL")) { | |
480 /* | |
481 * If the current setting is AL, messages from users who | |
482 * are not in BL will be delivered. | |
483 * | |
484 * In other words, deny some. | |
485 */ | |
486 gc->account->permdeny = DENY_SOME; | |
487 } | |
488 else { | |
489 /* If the current setting is BL, only messages from people | |
490 * who are in the AL will be delivered. | |
491 * | |
492 * In other words, permit some. | |
493 */ | |
494 gc->account->permdeny = PERMIT_SOME; | |
495 } | |
496 | |
497 return TRUE; | |
498 } | |
499 | |
500 static gboolean | |
5361
953aa05279f4
[gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
5358
diff
changeset
|
501 __bpr_cmd(MsnServConn *servconn, const char *command, const char **params, |
953aa05279f4
[gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
5358
diff
changeset
|
502 size_t param_count) |
953aa05279f4
[gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
5358
diff
changeset
|
503 { |
5363
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5361
diff
changeset
|
504 MsnSession *session = servconn->session; |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5361
diff
changeset
|
505 struct gaim_connection *gc = session->account->gc; |
5361
953aa05279f4
[gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
5358
diff
changeset
|
506 const char *passport, *type, *value; |
5375
d8ebee2f749c
[gaim-migrate @ 5751]
Christian Hammond <chipx86@chipx86.com>
parents:
5373
diff
changeset
|
507 struct buddy *b; |
5363
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5361
diff
changeset
|
508 MsnUser *user; |
5361
953aa05279f4
[gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
5358
diff
changeset
|
509 |
953aa05279f4
[gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
5358
diff
changeset
|
510 passport = params[1]; |
953aa05279f4
[gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
5358
diff
changeset
|
511 type = params[2]; |
953aa05279f4
[gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
5358
diff
changeset
|
512 value = params[3]; |
953aa05279f4
[gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
5358
diff
changeset
|
513 |
5363
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5361
diff
changeset
|
514 user = msn_users_find_with_passport(session->users, passport); |
5361
953aa05279f4
[gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
5358
diff
changeset
|
515 |
5363
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5361
diff
changeset
|
516 if (value != NULL) { |
5375
d8ebee2f749c
[gaim-migrate @ 5751]
Christian Hammond <chipx86@chipx86.com>
parents:
5373
diff
changeset
|
517 if (!strcmp(type, "MOB")) { |
d8ebee2f749c
[gaim-migrate @ 5751]
Christian Hammond <chipx86@chipx86.com>
parents:
5373
diff
changeset
|
518 if (!strcmp(value, "Y")) { |
d8ebee2f749c
[gaim-migrate @ 5751]
Christian Hammond <chipx86@chipx86.com>
parents:
5373
diff
changeset
|
519 user->mobile = TRUE; |
d8ebee2f749c
[gaim-migrate @ 5751]
Christian Hammond <chipx86@chipx86.com>
parents:
5373
diff
changeset
|
520 |
d8ebee2f749c
[gaim-migrate @ 5751]
Christian Hammond <chipx86@chipx86.com>
parents:
5373
diff
changeset
|
521 if ((b = gaim_find_buddy(gc->account, passport)) != NULL) { |
d8ebee2f749c
[gaim-migrate @ 5751]
Christian Hammond <chipx86@chipx86.com>
parents:
5373
diff
changeset
|
522 if (GAIM_BUDDY_IS_ONLINE(b)) { |
d8ebee2f749c
[gaim-migrate @ 5751]
Christian Hammond <chipx86@chipx86.com>
parents:
5373
diff
changeset
|
523 serv_got_update(gc, (char *)passport, |
d8ebee2f749c
[gaim-migrate @ 5751]
Christian Hammond <chipx86@chipx86.com>
parents:
5373
diff
changeset
|
524 1, 0, 0, 0, b->uc); |
d8ebee2f749c
[gaim-migrate @ 5751]
Christian Hammond <chipx86@chipx86.com>
parents:
5373
diff
changeset
|
525 } |
d8ebee2f749c
[gaim-migrate @ 5751]
Christian Hammond <chipx86@chipx86.com>
parents:
5373
diff
changeset
|
526 } |
d8ebee2f749c
[gaim-migrate @ 5751]
Christian Hammond <chipx86@chipx86.com>
parents:
5373
diff
changeset
|
527 } |
d8ebee2f749c
[gaim-migrate @ 5751]
Christian Hammond <chipx86@chipx86.com>
parents:
5373
diff
changeset
|
528 } |
5363
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5361
diff
changeset
|
529 else if (!strcmp(type, "PHH")) |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5361
diff
changeset
|
530 msn_user_set_home_phone(user, msn_url_decode(value)); |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5361
diff
changeset
|
531 else if (!strcmp(type, "PHW")) |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5361
diff
changeset
|
532 msn_user_set_work_phone(user, msn_url_decode(value)); |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5361
diff
changeset
|
533 else if (!strcmp(type, "PHM")) |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5361
diff
changeset
|
534 msn_user_set_mobile_phone(user, msn_url_decode(value)); |
5361
953aa05279f4
[gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
5358
diff
changeset
|
535 } |
953aa05279f4
[gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
5358
diff
changeset
|
536 |
953aa05279f4
[gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
5358
diff
changeset
|
537 return TRUE; |
953aa05279f4
[gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
5358
diff
changeset
|
538 } |
953aa05279f4
[gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
5358
diff
changeset
|
539 |
953aa05279f4
[gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
5358
diff
changeset
|
540 static gboolean |
5309 | 541 __fln_cmd(MsnServConn *servconn, const char *command, const char **params, |
542 size_t param_count) | |
543 { | |
544 struct gaim_connection *gc = servconn->session->account->gc; | |
545 | |
546 serv_got_update(gc, (char *)params[0], 0, 0, 0, 0, 0); | |
547 | |
548 return TRUE; | |
549 } | |
550 | |
551 static gboolean | |
552 __iln_cmd(MsnServConn *servconn, const char *command, const char **params, | |
553 size_t param_count) | |
554 { | |
555 struct gaim_connection *gc = servconn->session->account->gc; | |
556 int status = 0; | |
557 const char *state, *passport, *friend; | |
5361
953aa05279f4
[gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
5358
diff
changeset
|
558 struct buddy *b; |
5309 | 559 |
560 state = params[1]; | |
561 passport = params[2]; | |
562 friend = msn_url_decode(params[3]); | |
563 | |
564 serv_got_alias(gc, (char *)passport, (char *)friend); | |
565 | |
5361
953aa05279f4
[gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
5358
diff
changeset
|
566 if ((b = gaim_find_buddy(gc->account, passport)) != NULL) |
953aa05279f4
[gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
5358
diff
changeset
|
567 status |= ((((b->uc) >> 1) & 0xF0) << 1); |
953aa05279f4
[gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
5358
diff
changeset
|
568 |
5309 | 569 if (!g_ascii_strcasecmp(state, "BSY")) |
570 status |= UC_UNAVAILABLE | (MSN_BUSY << 1); | |
571 else if (!g_ascii_strcasecmp(state, "IDL")) | |
572 status |= UC_UNAVAILABLE | (MSN_IDLE << 1); | |
573 else if (!g_ascii_strcasecmp(state, "BRB")) | |
574 status |= UC_UNAVAILABLE | (MSN_BRB << 1); | |
575 else if (!g_ascii_strcasecmp(state, "AWY")) | |
576 status |= UC_UNAVAILABLE | (MSN_AWAY << 1); | |
577 else if (!g_ascii_strcasecmp(state, "PHN")) | |
578 status |= UC_UNAVAILABLE | (MSN_PHONE << 1); | |
579 else if (!g_ascii_strcasecmp(state, "LUN")) | |
580 status |= UC_UNAVAILABLE | (MSN_LUNCH << 1); | |
581 | |
582 serv_got_update(gc, (char *)passport, 1, 0, 0, 0, status); | |
583 | |
584 return TRUE; | |
585 } | |
586 | |
587 static gboolean | |
588 __lsg_cmd(MsnServConn *servconn, const char *command, const char **params, | |
589 size_t param_count) | |
590 { | |
591 MsnSession *session = servconn->session; | |
592 struct group *g; | |
593 const char *name; | |
594 int group_num, num_groups, group_id; | |
5318
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
595 gint *group_id_1, *group_id_2; |
5309 | 596 |
597 group_num = atoi(params[2]); | |
598 num_groups = atoi(params[3]); | |
599 group_id = atoi(params[4]); | |
600 name = msn_url_decode(params[5]); | |
601 | |
5318
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
602 if (num_groups == 0) |
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
603 return TRUE; |
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
604 |
5309 | 605 if (group_num == 1) { |
5318
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
606 session->group_names = g_hash_table_new_full(g_int_hash, g_int_equal, |
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
607 g_free, g_free); |
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
608 session->group_ids = g_hash_table_new_full(g_str_hash, g_str_equal, |
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
609 g_free, g_free); |
5309 | 610 } |
611 | |
5318
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
612 group_id_1 = g_new(gint, 1); |
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
613 group_id_2 = g_new(gint, 1); |
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
614 |
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
615 *group_id_1 = group_id; |
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
616 *group_id_2 = group_id; |
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
617 |
5323
29754a7d94e5
[gaim-migrate @ 5695]
Christian Hammond <chipx86@chipx86.com>
parents:
5322
diff
changeset
|
618 if (!strcmp(name, "~")) |
29754a7d94e5
[gaim-migrate @ 5695]
Christian Hammond <chipx86@chipx86.com>
parents:
5322
diff
changeset
|
619 name = _("Buddies"); |
29754a7d94e5
[gaim-migrate @ 5695]
Christian Hammond <chipx86@chipx86.com>
parents:
5322
diff
changeset
|
620 |
5318
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
621 g_hash_table_insert(session->group_names, group_id_1, g_strdup(name)); |
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
622 g_hash_table_insert(session->group_ids, g_strdup(name), group_id_2); |
5309 | 623 |
624 if ((g = gaim_find_group(name)) == NULL) { | |
625 g = gaim_group_new(name); | |
626 gaim_blist_add_group(g, NULL); | |
627 } | |
628 | |
629 return TRUE; | |
630 } | |
631 | |
632 static gboolean | |
633 __lst_cmd(MsnServConn *servconn, const char *command, const char **params, | |
634 size_t param_count) | |
635 { | |
636 MsnSession *session = servconn->session; | |
637 struct gaim_connection *gc = session->account->gc; | |
638 int user_num; | |
639 int num_users; | |
640 const char *type; | |
641 const char *passport; | |
642 const char *friend; | |
643 | |
644 user_num = atoi(params[3]); | |
645 num_users = atoi(params[4]); | |
646 | |
647 if (user_num == 0 && num_users == 0) | |
648 return TRUE; /* There are no users on this list. */ | |
649 | |
650 type = params[1]; | |
651 passport = params[5]; | |
652 friend = msn_url_decode(params[6]); | |
653 | |
5456
40e976d42028
[gaim-migrate @ 5844]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
654 if (session->syncing_lists && session->lists_synced) |
5406
9acf4832c0dc
[gaim-migrate @ 5782]
Christian Hammond <chipx86@chipx86.com>
parents:
5385
diff
changeset
|
655 return TRUE; |
9acf4832c0dc
[gaim-migrate @ 5782]
Christian Hammond <chipx86@chipx86.com>
parents:
5385
diff
changeset
|
656 |
5309 | 657 if (!g_ascii_strcasecmp(type, "FL") && user_num != 0) { |
658 /* These are users on our contact list. */ | |
659 MsnUser *user; | |
660 | |
661 user = msn_user_new(session, passport, friend); | |
662 | |
663 if (param_count == 8) | |
664 msn_user_set_group_id(user, atoi(params[7])); | |
665 | |
666 session->lists.forward = g_slist_append(session->lists.forward, user); | |
667 } | |
668 else if (!g_ascii_strcasecmp(type, "AL") && user_num != 0) { | |
669 /* These are users who are allowed to see our status. */ | |
670 if (g_slist_find_custom(gc->account->deny, passport, | |
671 (GCompareFunc)strcmp)) { | |
672 | |
673 gaim_debug(GAIM_DEBUG_INFO, "msn", | |
674 "Moving user from deny list to permit: %s (%s)\n", | |
675 passport, friend); | |
676 | |
677 gaim_privacy_deny_remove(gc->account, passport); | |
678 } | |
679 | |
680 gaim_privacy_permit_add(gc->account, passport); | |
681 } | |
682 else if (!g_ascii_strcasecmp(type, "BL") && user_num != 0) { | |
683 /* These are users who are not allowed to see our status. */ | |
684 gaim_privacy_deny_add(gc->account, passport); | |
685 } | |
686 else if (!g_ascii_strcasecmp(type, "RL")) { | |
687 /* These are users who have us on their contact list. */ | |
688 if (user_num > 0) { | |
689 gboolean new_entry = TRUE; | |
690 | |
691 if (g_slist_find_custom(gc->account->permit, passport, | |
692 (GCompareFunc)g_ascii_strcasecmp)) { | |
693 new_entry = FALSE; | |
694 } | |
695 | |
696 if (g_slist_find_custom(gc->account->deny, passport, | |
697 (GCompareFunc)g_ascii_strcasecmp)) { | |
698 new_entry = FALSE; | |
699 } | |
700 | |
701 if (new_entry) { | |
702 MsnPermitAdd *pa; | |
703 char msg[MSN_BUF_LEN]; | |
704 | |
705 gaim_debug(GAIM_DEBUG_WARNING, "msn", | |
706 "Unresolved MSN RL entry: %s\n", passport); | |
707 | |
708 pa = g_new0(MsnPermitAdd, 1); | |
709 pa->user = msn_user_new(session, passport, friend); | |
710 pa->gc = gc; | |
711 | |
712 g_snprintf(msg, sizeof(msg), | |
713 _("The user %s (%s) wants to add you to their " | |
714 "buddy list."), | |
715 msn_user_get_passport(pa->user), | |
716 msn_user_get_name(pa->user)); | |
717 | |
718 do_ask_dialog(msg, NULL, pa, | |
719 _("Authorize"), msn_accept_add_cb, | |
720 _("Deny"), msn_cancel_add_cb, | |
721 session->prpl->handle, FALSE); | |
722 } | |
723 } | |
724 | |
725 if (user_num != num_users) | |
726 return TRUE; /* This isn't the last one in the RL. */ | |
727 | |
5456
40e976d42028
[gaim-migrate @ 5844]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
728 /* Now we're at the last one, so we can do final work. */ |
40e976d42028
[gaim-migrate @ 5844]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
729 if (!session->lists_synced) { |
40e976d42028
[gaim-migrate @ 5844]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
730 if (!msn_servconn_send_command(servconn, "CHG", "NLN")) { |
40e976d42028
[gaim-migrate @ 5844]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
731 hide_login_progress(gc, _("Unable to write")); |
40e976d42028
[gaim-migrate @ 5844]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
732 signoff(gc); |
5309 | 733 |
5456
40e976d42028
[gaim-migrate @ 5844]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
734 return FALSE; |
40e976d42028
[gaim-migrate @ 5844]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
735 } |
40e976d42028
[gaim-migrate @ 5844]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
736 |
40e976d42028
[gaim-migrate @ 5844]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
737 account_online(gc); |
40e976d42028
[gaim-migrate @ 5844]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
738 serv_finish_login(gc); |
5309 | 739 } |
740 | |
5456
40e976d42028
[gaim-migrate @ 5844]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
741 if (session->lists.allow == NULL) |
40e976d42028
[gaim-migrate @ 5844]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
742 session->lists.allow = g_slist_copy(gc->account->permit); |
40e976d42028
[gaim-migrate @ 5844]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
743 else |
40e976d42028
[gaim-migrate @ 5844]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
744 session->lists.allow = g_slist_concat(session->lists.allow, |
40e976d42028
[gaim-migrate @ 5844]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
745 gc->account->permit); |
5309 | 746 |
5456
40e976d42028
[gaim-migrate @ 5844]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
747 if (session->lists.block == NULL) |
40e976d42028
[gaim-migrate @ 5844]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
748 session->lists.block = g_slist_copy(gc->account->deny); |
40e976d42028
[gaim-migrate @ 5844]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
749 else |
40e976d42028
[gaim-migrate @ 5844]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
750 session->lists.block = g_slist_concat(session->lists.block, |
40e976d42028
[gaim-migrate @ 5844]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
751 gc->account->deny); |
5309 | 752 |
753 while (session->lists.forward != NULL) { | |
754 MsnUser *user = session->lists.forward->data; | |
755 | |
756 session->lists.forward = g_slist_remove(session->lists.forward, | |
757 user); | |
758 | |
5457
c8c290021b7b
[gaim-migrate @ 5845]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
759 __add_buddy(servconn, user); |
5309 | 760 } |
5406
9acf4832c0dc
[gaim-migrate @ 5782]
Christian Hammond <chipx86@chipx86.com>
parents:
5385
diff
changeset
|
761 |
5456
40e976d42028
[gaim-migrate @ 5844]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
762 session->syncing_lists = FALSE; |
40e976d42028
[gaim-migrate @ 5844]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
763 session->lists_synced = TRUE; |
5309 | 764 } |
765 | |
766 return TRUE; | |
767 } | |
768 | |
769 static gboolean | |
770 __nln_cmd(MsnServConn *servconn, const char *command, const char **params, | |
771 size_t param_count) | |
772 { | |
773 MsnSession *session = servconn->session; | |
774 struct gaim_connection *gc = session->account->gc; | |
775 const char *state; | |
776 const char *passport; | |
777 const char *friend; | |
778 int status = 0; | |
779 | |
780 state = params[0]; | |
781 passport = params[1]; | |
782 friend = msn_url_decode(params[2]); | |
783 | |
784 serv_got_alias(gc, (char *)passport, (char *)friend); | |
785 | |
786 if (!g_ascii_strcasecmp(state, "BSY")) | |
787 status |= UC_UNAVAILABLE | (MSN_BUSY << 1); | |
788 else if (!g_ascii_strcasecmp(state, "IDL")) | |
789 status |= UC_UNAVAILABLE | (MSN_IDLE << 1); | |
790 else if (!g_ascii_strcasecmp(state, "BRB")) | |
791 status |= UC_UNAVAILABLE | (MSN_BRB << 1); | |
792 else if (!g_ascii_strcasecmp(state, "AWY")) | |
793 status |= UC_UNAVAILABLE | (MSN_AWAY << 1); | |
794 else if (!g_ascii_strcasecmp(state, "PHN")) | |
795 status |= UC_UNAVAILABLE | (MSN_PHONE << 1); | |
796 else if (!g_ascii_strcasecmp(state, "LUN")) | |
797 status |= UC_UNAVAILABLE | (MSN_LUNCH << 1); | |
798 | |
799 serv_got_update(gc, (char *)passport, 1, 0, 0, 0, status); | |
800 | |
801 return TRUE; | |
802 } | |
803 | |
804 static gboolean | |
5363
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5361
diff
changeset
|
805 __prp_cmd(MsnServConn *servconn, const char *command, const char **params, |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5361
diff
changeset
|
806 size_t param_count) |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5361
diff
changeset
|
807 { |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5361
diff
changeset
|
808 MsnSession *session = servconn->session; |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5361
diff
changeset
|
809 const char *type, *value; |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5361
diff
changeset
|
810 |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5361
diff
changeset
|
811 type = params[2]; |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5361
diff
changeset
|
812 value = params[3]; |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5361
diff
changeset
|
813 |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5361
diff
changeset
|
814 if (param_count == 4) { |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5361
diff
changeset
|
815 if (!strcmp(type, "PHH")) |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5361
diff
changeset
|
816 msn_user_set_home_phone(session->user, msn_url_decode(value)); |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5361
diff
changeset
|
817 else if (!strcmp(type, "PHW")) |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5361
diff
changeset
|
818 msn_user_set_work_phone(session->user, msn_url_decode(value)); |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5361
diff
changeset
|
819 else if (!strcmp(type, "PHM")) |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5361
diff
changeset
|
820 msn_user_set_mobile_phone(session->user, msn_url_decode(value)); |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5361
diff
changeset
|
821 } |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5361
diff
changeset
|
822 |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5361
diff
changeset
|
823 return TRUE; |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5361
diff
changeset
|
824 } |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5361
diff
changeset
|
825 |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5361
diff
changeset
|
826 static gboolean |
5309 | 827 __rea_cmd(MsnServConn *servconn, const char *command, const char **params, |
828 size_t param_count) | |
829 { | |
830 MsnSession *session = servconn->session; | |
831 struct gaim_connection *gc = session->account->gc; | |
832 char *friend; | |
833 | |
5479
175de59cd1c5
[gaim-migrate @ 5875]
Christian Hammond <chipx86@chipx86.com>
parents:
5457
diff
changeset
|
834 friend = msn_url_decode(params[3]); |
5309 | 835 |
5479
175de59cd1c5
[gaim-migrate @ 5875]
Christian Hammond <chipx86@chipx86.com>
parents:
5457
diff
changeset
|
836 gaim_debug(GAIM_DEBUG_INFO, "msn", "Setting friendly name to %s\n", |
175de59cd1c5
[gaim-migrate @ 5875]
Christian Hammond <chipx86@chipx86.com>
parents:
5457
diff
changeset
|
837 friend); |
5309 | 838 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", friend); |
839 | |
840 return TRUE; | |
841 } | |
842 | |
5318
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
843 static gboolean |
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
844 __reg_cmd(MsnServConn *servconn, const char *command, const char **params, |
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
845 size_t param_count) |
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
846 { |
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
847 MsnSession *session = servconn->session; |
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
848 gint *group_id; |
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
849 char *group_name; |
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
850 |
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
851 group_id = g_new(gint, 1); |
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
852 *group_id = atoi(params[2]); |
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
853 |
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
854 group_name = msn_url_decode(params[3]); |
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
855 |
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
856 gaim_debug(GAIM_DEBUG_INFO, "msn", "Renamed group %s to %s\n", |
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
857 g_hash_table_lookup(session->group_names, group_id), |
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
858 group_name); |
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
859 |
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
860 g_hash_table_replace(session->group_names, group_id, g_strdup(group_name)); |
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
861 |
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
862 g_hash_table_remove(session->group_ids, group_name); |
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
863 g_hash_table_insert(session->group_ids, group_name, group_id); |
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
864 |
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
865 return TRUE; |
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
866 } |
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
867 |
5322
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
868 static gboolean |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
869 __rem_cmd(MsnServConn *servconn, const char *command, const char **params, |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
870 size_t param_count) |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
871 { |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
872 MsnSession *session = servconn->session; |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
873 |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
874 /* I hate this. */ |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
875 if (session->moving_buddy) { |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
876 struct gaim_connection *gc = session->account->gc; |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
877 const char *passport = params[3]; |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
878 char outparams[MSN_BUF_LEN]; |
5327
b716ffc25d2d
[gaim-migrate @ 5700]
Christian Hammond <chipx86@chipx86.com>
parents:
5326
diff
changeset
|
879 int *group_id; |
b716ffc25d2d
[gaim-migrate @ 5700]
Christian Hammond <chipx86@chipx86.com>
parents:
5326
diff
changeset
|
880 |
b716ffc25d2d
[gaim-migrate @ 5700]
Christian Hammond <chipx86@chipx86.com>
parents:
5326
diff
changeset
|
881 group_id = g_hash_table_lookup(session->group_ids, |
b716ffc25d2d
[gaim-migrate @ 5700]
Christian Hammond <chipx86@chipx86.com>
parents:
5326
diff
changeset
|
882 session->dest_group_name); |
b716ffc25d2d
[gaim-migrate @ 5700]
Christian Hammond <chipx86@chipx86.com>
parents:
5326
diff
changeset
|
883 |
b716ffc25d2d
[gaim-migrate @ 5700]
Christian Hammond <chipx86@chipx86.com>
parents:
5326
diff
changeset
|
884 g_free(session->dest_group_name); |
b716ffc25d2d
[gaim-migrate @ 5700]
Christian Hammond <chipx86@chipx86.com>
parents:
5326
diff
changeset
|
885 session->dest_group_name = NULL; |
b716ffc25d2d
[gaim-migrate @ 5700]
Christian Hammond <chipx86@chipx86.com>
parents:
5326
diff
changeset
|
886 session->moving_buddy = FALSE; |
b716ffc25d2d
[gaim-migrate @ 5700]
Christian Hammond <chipx86@chipx86.com>
parents:
5326
diff
changeset
|
887 |
b716ffc25d2d
[gaim-migrate @ 5700]
Christian Hammond <chipx86@chipx86.com>
parents:
5326
diff
changeset
|
888 if (group_id == NULL) { |
b716ffc25d2d
[gaim-migrate @ 5700]
Christian Hammond <chipx86@chipx86.com>
parents:
5326
diff
changeset
|
889 gaim_debug(GAIM_DEBUG_ERROR, "msn", |
b716ffc25d2d
[gaim-migrate @ 5700]
Christian Hammond <chipx86@chipx86.com>
parents:
5326
diff
changeset
|
890 "Still don't have a group ID for %s while moving %s!\n", |
b716ffc25d2d
[gaim-migrate @ 5700]
Christian Hammond <chipx86@chipx86.com>
parents:
5326
diff
changeset
|
891 session->dest_group_name, passport); |
b716ffc25d2d
[gaim-migrate @ 5700]
Christian Hammond <chipx86@chipx86.com>
parents:
5326
diff
changeset
|
892 return TRUE; |
b716ffc25d2d
[gaim-migrate @ 5700]
Christian Hammond <chipx86@chipx86.com>
parents:
5326
diff
changeset
|
893 } |
5322
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
894 |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
895 g_snprintf(outparams, sizeof(outparams), "FL %s %s %d", |
5327
b716ffc25d2d
[gaim-migrate @ 5700]
Christian Hammond <chipx86@chipx86.com>
parents:
5326
diff
changeset
|
896 passport, passport, *group_id); |
5322
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
897 |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
898 if (!msn_servconn_send_command(session->notification_conn, |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
899 "ADD", outparams)) { |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
900 hide_login_progress(gc, _("Write error")); |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
901 signoff(gc); |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
902 } |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
903 } |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
904 |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
905 return TRUE; |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
906 } |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
907 |
5309 | 908 /************************************************************************** |
909 * Misc commands | |
910 **************************************************************************/ | |
911 static gboolean | |
912 __url_cmd(MsnServConn *servconn, const char *command, const char **params, | |
913 size_t param_count) | |
914 { | |
915 MsnSession *session = servconn->session; | |
916 struct gaim_connection *gc = session->account->gc; | |
917 const char *rru; | |
918 const char *url; | |
919 md5_state_t st; | |
920 md5_byte_t di[16]; | |
921 FILE *fd; | |
922 char buf[2048]; | |
923 char buf2[3]; | |
924 char sendbuf[64]; | |
925 int i; | |
926 | |
927 rru = params[1]; | |
928 url = params[2]; | |
929 | |
930 g_snprintf(buf, sizeof(buf), "%s%lu%s", | |
931 session->passport_info.mspauth, | |
932 time(NULL) - session->passport_info.sl, gc->password); | |
933 | |
934 md5_init(&st); | |
935 md5_append(&st, (const md5_byte_t *)buf, strlen(buf)); | |
936 md5_finish(&st, di); | |
937 | |
938 memset(sendbuf, 0, sizeof(sendbuf)); | |
939 | |
940 for (i = 0; i < 16; i++) { | |
941 g_snprintf(buf2, sizeof(buf2), "%02x", di[i]); | |
942 strcat(sendbuf, buf2); | |
943 } | |
944 | |
945 if (session->passport_info.file != NULL) { | |
946 unlink(session->passport_info.file); | |
947 g_free(session->passport_info.file); | |
948 } | |
949 | |
950 if ((fd = gaim_mkstemp(&session->passport_info.file)) == NULL) { | |
951 gaim_debug(GAIM_DEBUG_ERROR, "msn", | |
952 "Error opening temp passport file: %s\n", | |
953 strerror(errno)); | |
954 } | |
955 else { | |
956 fputs("<html>\n" | |
957 "<head>\n" | |
958 "<noscript>\n" | |
959 "<meta http-equiv=\"Refresh\" content=\"0; " | |
960 "url=http://www.hotmail.com\">\n" | |
961 "</noscript>\n" | |
962 "</head>\n\n", | |
963 fd); | |
964 | |
965 fprintf(fd, "<body onload=\"document.pform.submit(); \">\n"); | |
966 fprintf(fd, "<form name=\"pform\" action=\"%s\" method=\"POST\">\n\n", | |
967 url); | |
968 fprintf(fd, "<input type=\"hidden\" name=\"mode\" value=\"ttl\">\n"); | |
969 fprintf(fd, "<input type=\"hidden\" name=\"login\" value=\"%s\">\n", | |
970 gc->username); | |
971 fprintf(fd, "<input type=\"hidden\" name=\"username\" value=\"%s\">\n", | |
972 gc->username); | |
973 fprintf(fd, "<input type=\"hidden\" name=\"sid\" value=\"%s\">\n", | |
974 session->passport_info.sid); | |
975 fprintf(fd, "<input type=\"hidden\" name=\"kv\" value=\"%s\">\n", | |
976 session->passport_info.kv); | |
977 fprintf(fd, "<input type=\"hidden\" name=\"id\" value=\"2\">\n"); | |
978 fprintf(fd, "<input type=\"hidden\" name=\"sl\" value=\"%ld\">\n", | |
979 time(NULL) - session->passport_info.sl); | |
980 fprintf(fd, "<input type=\"hidden\" name=\"rru\" value=\"%s\">\n", | |
981 rru); | |
982 fprintf(fd, "<input type=\"hidden\" name=\"auth\" value=\"%s\">\n", | |
983 session->passport_info.mspauth); | |
984 fprintf(fd, "<input type=\"hidden\" name=\"creds\" value=\"%s\">\n", | |
985 sendbuf); /* TODO Digest me (huh? -- ChipX86) */ | |
986 fprintf(fd, "<input type=\"hidden\" name=\"svc\" value=\"mail\">\n"); | |
987 fprintf(fd, "<input type=\"hiden\" name=\"js\" value=\"yes\">\n"); | |
988 fprintf(fd, "</form></body>\n"); | |
989 fprintf(fd, "</html>\n"); | |
990 | |
991 if (fclose(fd)) { | |
992 gaim_debug(GAIM_DEBUG_ERROR, "msn", | |
993 "Error closing temp passport file: %s\n", | |
994 strerror(errno)); | |
995 | |
996 unlink(session->passport_info.file); | |
997 g_free(session->passport_info.file); | |
998 } | |
999 else { | |
1000 /* | |
1001 * Renaming file with .html extension, so that the | |
1002 * win32 open_url will work. | |
1003 */ | |
1004 char *tmp; | |
1005 | |
1006 if ((tmp = g_strdup_printf("%s.html", | |
1007 session->passport_info.file)) != NULL) { | |
1008 | |
1009 if (rename(session->passport_info.file, tmp) == 0) { | |
1010 g_free(session->passport_info.file); | |
1011 session->passport_info.file = tmp; | |
1012 } | |
1013 else | |
1014 g_free(tmp); | |
1015 } | |
1016 } | |
1017 } | |
1018 | |
1019 return TRUE; | |
1020 } | |
1021 /************************************************************************** | |
1022 * Switchboards | |
1023 **************************************************************************/ | |
1024 static gboolean | |
1025 __rng_cmd(MsnServConn *servconn, const char *command, const char **params, | |
1026 size_t param_count) | |
1027 { | |
1028 MsnSession *session = servconn->session; | |
1029 MsnSwitchBoard *swboard; | |
1030 MsnUser *user; | |
1031 const char *session_id; | |
1032 char *host, *c; | |
1033 int port; | |
1034 | |
1035 session_id = params[0]; | |
1036 | |
1037 host = g_strdup(params[1]); | |
1038 | |
1039 if ((c = strchr(host, ':')) != NULL) { | |
1040 *c = '\0'; | |
1041 port = atoi(c + 1); | |
1042 } | |
1043 else | |
1044 port = 1863; | |
1045 | |
1046 swboard = msn_switchboard_new(session); | |
1047 | |
1048 user = msn_user_new(session, params[4], NULL); | |
1049 | |
1050 msn_switchboard_set_invited(swboard, TRUE); | |
1051 msn_switchboard_set_session_id(swboard, params[0]); | |
1052 msn_switchboard_set_auth_key(swboard, params[3]); | |
1053 msn_switchboard_set_user(swboard, user); | |
1054 | |
1055 if (!msn_switchboard_connect(swboard, host, port)) { | |
1056 gaim_debug(GAIM_DEBUG_ERROR, "msn", | |
1057 "Unable to connect to switchboard on %s, port %d\n", | |
1058 host, port); | |
1059 | |
1060 g_free(host); | |
1061 | |
1062 return FALSE; | |
1063 } | |
1064 | |
1065 g_free(host); | |
1066 | |
1067 return TRUE; | |
1068 } | |
1069 | |
1070 static gboolean | |
1071 __xfr_cmd(MsnServConn *servconn, const char *command, const char **params, | |
1072 size_t param_count) | |
1073 { | |
1074 MsnSession *session = servconn->session; | |
1075 MsnSwitchBoard *swboard; | |
1076 struct gaim_connection *gc = session->account->gc; | |
1077 char *host; | |
1078 char *c; | |
1079 int port; | |
1080 | |
5385
150cf1615098
[gaim-migrate @ 5761]
Christian Hammond <chipx86@chipx86.com>
parents:
5375
diff
changeset
|
1081 if (strcmp(params[1], "SB") && strcmp(params[1], "NS")) { |
5309 | 1082 hide_login_progress(gc, _("Got invalid XFR")); |
1083 signoff(gc); | |
1084 | |
1085 return FALSE; | |
1086 } | |
1087 | |
1088 host = g_strdup(params[2]); | |
1089 | |
1090 if ((c = strchr(host, ':')) != NULL) { | |
1091 *c = '\0'; | |
1092 port = atoi(c + 1); | |
1093 } | |
1094 else | |
1095 port = 1863; | |
1096 | |
5385
150cf1615098
[gaim-migrate @ 5761]
Christian Hammond <chipx86@chipx86.com>
parents:
5375
diff
changeset
|
1097 if (!strcmp(params[1], "SB")) { |
150cf1615098
[gaim-migrate @ 5761]
Christian Hammond <chipx86@chipx86.com>
parents:
5375
diff
changeset
|
1098 swboard = msn_session_find_unused_switch(session); |
5309 | 1099 |
5385
150cf1615098
[gaim-migrate @ 5761]
Christian Hammond <chipx86@chipx86.com>
parents:
5375
diff
changeset
|
1100 if (swboard == NULL) { |
150cf1615098
[gaim-migrate @ 5761]
Christian Hammond <chipx86@chipx86.com>
parents:
5375
diff
changeset
|
1101 gaim_debug(GAIM_DEBUG_ERROR, "msn", |
150cf1615098
[gaim-migrate @ 5761]
Christian Hammond <chipx86@chipx86.com>
parents:
5375
diff
changeset
|
1102 "Received an XFR SB request when there's no unused " |
150cf1615098
[gaim-migrate @ 5761]
Christian Hammond <chipx86@chipx86.com>
parents:
5375
diff
changeset
|
1103 "switchboards!\n"); |
150cf1615098
[gaim-migrate @ 5761]
Christian Hammond <chipx86@chipx86.com>
parents:
5375
diff
changeset
|
1104 return FALSE; |
150cf1615098
[gaim-migrate @ 5761]
Christian Hammond <chipx86@chipx86.com>
parents:
5375
diff
changeset
|
1105 } |
150cf1615098
[gaim-migrate @ 5761]
Christian Hammond <chipx86@chipx86.com>
parents:
5375
diff
changeset
|
1106 |
150cf1615098
[gaim-migrate @ 5761]
Christian Hammond <chipx86@chipx86.com>
parents:
5375
diff
changeset
|
1107 msn_switchboard_set_auth_key(swboard, params[4]); |
150cf1615098
[gaim-migrate @ 5761]
Christian Hammond <chipx86@chipx86.com>
parents:
5375
diff
changeset
|
1108 |
150cf1615098
[gaim-migrate @ 5761]
Christian Hammond <chipx86@chipx86.com>
parents:
5375
diff
changeset
|
1109 if (!msn_switchboard_connect(swboard, host, port)) { |
150cf1615098
[gaim-migrate @ 5761]
Christian Hammond <chipx86@chipx86.com>
parents:
5375
diff
changeset
|
1110 gaim_debug(GAIM_DEBUG_ERROR, "msn", |
150cf1615098
[gaim-migrate @ 5761]
Christian Hammond <chipx86@chipx86.com>
parents:
5375
diff
changeset
|
1111 "Unable to connect to switchboard on %s, port %d\n", |
150cf1615098
[gaim-migrate @ 5761]
Christian Hammond <chipx86@chipx86.com>
parents:
5375
diff
changeset
|
1112 host, port); |
5309 | 1113 |
5385
150cf1615098
[gaim-migrate @ 5761]
Christian Hammond <chipx86@chipx86.com>
parents:
5375
diff
changeset
|
1114 g_free(host); |
150cf1615098
[gaim-migrate @ 5761]
Christian Hammond <chipx86@chipx86.com>
parents:
5375
diff
changeset
|
1115 |
150cf1615098
[gaim-migrate @ 5761]
Christian Hammond <chipx86@chipx86.com>
parents:
5375
diff
changeset
|
1116 return FALSE; |
150cf1615098
[gaim-migrate @ 5761]
Christian Hammond <chipx86@chipx86.com>
parents:
5375
diff
changeset
|
1117 } |
150cf1615098
[gaim-migrate @ 5761]
Christian Hammond <chipx86@chipx86.com>
parents:
5375
diff
changeset
|
1118 } |
150cf1615098
[gaim-migrate @ 5761]
Christian Hammond <chipx86@chipx86.com>
parents:
5375
diff
changeset
|
1119 else if (!strcmp(params[1], "NS")) { |
150cf1615098
[gaim-migrate @ 5761]
Christian Hammond <chipx86@chipx86.com>
parents:
5375
diff
changeset
|
1120 msn_servconn_destroy(session->notification_conn); |
5309 | 1121 |
5385
150cf1615098
[gaim-migrate @ 5761]
Christian Hammond <chipx86@chipx86.com>
parents:
5375
diff
changeset
|
1122 session->notification_conn = msn_notification_new(session, host, port); |
5309 | 1123 |
5385
150cf1615098
[gaim-migrate @ 5761]
Christian Hammond <chipx86@chipx86.com>
parents:
5375
diff
changeset
|
1124 if (!msn_servconn_connect(session->notification_conn)) { |
150cf1615098
[gaim-migrate @ 5761]
Christian Hammond <chipx86@chipx86.com>
parents:
5375
diff
changeset
|
1125 hide_login_progress(gc, _("Unable to transfer to " |
150cf1615098
[gaim-migrate @ 5761]
Christian Hammond <chipx86@chipx86.com>
parents:
5375
diff
changeset
|
1126 "notification server")); |
150cf1615098
[gaim-migrate @ 5761]
Christian Hammond <chipx86@chipx86.com>
parents:
5375
diff
changeset
|
1127 signoff(gc); |
5309 | 1128 |
5385
150cf1615098
[gaim-migrate @ 5761]
Christian Hammond <chipx86@chipx86.com>
parents:
5375
diff
changeset
|
1129 return FALSE; |
150cf1615098
[gaim-migrate @ 5761]
Christian Hammond <chipx86@chipx86.com>
parents:
5375
diff
changeset
|
1130 } |
5309 | 1131 } |
1132 | |
1133 g_free(host); | |
1134 | |
1135 return TRUE; | |
1136 } | |
1137 | |
1138 /************************************************************************** | |
1139 * Message Types | |
1140 **************************************************************************/ | |
1141 static gboolean | |
1142 __profile_msg(MsnServConn *servconn, const MsnMessage *msg) | |
1143 { | |
1144 MsnSession *session = servconn->session; | |
1145 const char *value; | |
1146 | |
5333
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1147 if (strcmp(servconn->msg_passport, "Hotmail")) { |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1148 /* This isn't an official message. */ |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1149 return TRUE; |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1150 } |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1151 |
5309 | 1152 if ((value = msn_message_get_attr(msg, "kv")) != NULL) |
1153 session->passport_info.kv = g_strdup(value); | |
1154 | |
1155 if ((value = msn_message_get_attr(msg, "sid")) != NULL) | |
1156 session->passport_info.sid = g_strdup(value); | |
1157 | |
1158 if ((value = msn_message_get_attr(msg, "MSPAuth")) != NULL) | |
1159 session->passport_info.mspauth = g_strdup(value); | |
1160 | |
1161 return TRUE; | |
1162 } | |
1163 | |
1164 static gboolean | |
1165 __initial_email_msg(MsnServConn *servconn, const MsnMessage *msg) | |
1166 { | |
1167 MsnSession *session = servconn->session; | |
1168 struct gaim_connection *gc = session->account->gc; | |
1169 GHashTable *table; | |
1170 const char *unread; | |
1171 | |
5333
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1172 if (strcmp(servconn->msg_passport, "Hotmail")) { |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1173 /* This isn't an official message. */ |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1174 return TRUE; |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1175 } |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1176 |
5358
91db34a45cbe
[gaim-migrate @ 5734]
Christian Hammond <chipx86@chipx86.com>
parents:
5353
diff
changeset
|
1177 if (session->passport_info.file == NULL) { |
91db34a45cbe
[gaim-migrate @ 5734]
Christian Hammond <chipx86@chipx86.com>
parents:
5353
diff
changeset
|
1178 msn_servconn_send_command(servconn, "URL", "INBOX"); |
91db34a45cbe
[gaim-migrate @ 5734]
Christian Hammond <chipx86@chipx86.com>
parents:
5353
diff
changeset
|
1179 return TRUE; |
91db34a45cbe
[gaim-migrate @ 5734]
Christian Hammond <chipx86@chipx86.com>
parents:
5353
diff
changeset
|
1180 } |
91db34a45cbe
[gaim-migrate @ 5734]
Christian Hammond <chipx86@chipx86.com>
parents:
5353
diff
changeset
|
1181 |
5309 | 1182 table = msn_message_get_hashtable_from_body(msg); |
1183 | |
1184 unread = g_hash_table_lookup(table, "Inbox-Unread"); | |
1185 | |
1186 if (unread != NULL) | |
1187 connection_has_mail(gc, atoi(unread), NULL, NULL, | |
1188 session->passport_info.file); | |
1189 | |
1190 g_hash_table_destroy(table); | |
1191 | |
1192 return TRUE; | |
1193 } | |
1194 | |
1195 static gboolean | |
1196 __email_msg(MsnServConn *servconn, const MsnMessage *msg) | |
1197 { | |
1198 MsnSession *session = servconn->session; | |
1199 struct gaim_connection *gc = session->account->gc; | |
1200 GHashTable *table; | |
1201 const char *from, *subject; | |
1202 | |
5333
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1203 if (strcmp(servconn->msg_passport, "Hotmail")) { |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1204 /* This isn't an official message. */ |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1205 return TRUE; |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1206 } |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1207 |
5358
91db34a45cbe
[gaim-migrate @ 5734]
Christian Hammond <chipx86@chipx86.com>
parents:
5353
diff
changeset
|
1208 if (session->passport_info.file == NULL) { |
91db34a45cbe
[gaim-migrate @ 5734]
Christian Hammond <chipx86@chipx86.com>
parents:
5353
diff
changeset
|
1209 msn_servconn_send_command(servconn, "URL", "INBOX"); |
91db34a45cbe
[gaim-migrate @ 5734]
Christian Hammond <chipx86@chipx86.com>
parents:
5353
diff
changeset
|
1210 return TRUE; |
91db34a45cbe
[gaim-migrate @ 5734]
Christian Hammond <chipx86@chipx86.com>
parents:
5353
diff
changeset
|
1211 } |
91db34a45cbe
[gaim-migrate @ 5734]
Christian Hammond <chipx86@chipx86.com>
parents:
5353
diff
changeset
|
1212 |
5309 | 1213 table = msn_message_get_hashtable_from_body(msg); |
1214 | |
1215 from = g_hash_table_lookup(table, "From"); | |
1216 subject = g_hash_table_lookup(table, "Subject"); | |
1217 | |
1218 if (from == NULL || subject == NULL) { | |
1219 connection_has_mail(gc, 1, NULL, NULL, session->passport_info.file); | |
1220 } | |
1221 else { | |
1222 connection_has_mail(gc, -1, from, subject, | |
1223 session->passport_info.file); | |
1224 } | |
1225 | |
1226 g_hash_table_destroy(table); | |
1227 | |
1228 return TRUE; | |
1229 } | |
1230 | |
1231 static gboolean | |
5333
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1232 __system_msg(MsnServConn *servconn, const MsnMessage *msg) |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1233 { |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1234 GHashTable *table; |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1235 const char *type_s; |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1236 |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1237 if (strcmp(servconn->msg_passport, "Hotmail")) { |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1238 /* This isn't an official message. */ |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1239 return TRUE; |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1240 } |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1241 |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1242 table = msn_message_get_hashtable_from_body(msg); |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1243 |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1244 if ((type_s = g_hash_table_lookup(table, "Type")) != NULL) { |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1245 int type = atoi(type_s); |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1246 char buf[MSN_BUF_LEN]; |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1247 |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1248 switch (type) { |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1249 case 1: |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1250 g_snprintf(buf, sizeof(buf), |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1251 _("The MSN server will shut down for maintenance " |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1252 "in %d minute(s). You will automatically be " |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1253 "signed out at that time. Please finish any " |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1254 "conversations in progress.\n\n" |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1255 "After the maintenance has been completed, you " |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1256 "will be able to successfully sign in."), |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1257 atoi(g_hash_table_lookup(table, "Arg1"))); |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1258 |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1259 default: |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1260 break; |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1261 } |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1262 |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5406
diff
changeset
|
1263 if (*buf != '\0') |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5406
diff
changeset
|
1264 gaim_notify_info(servconn->session->account->gc, NULL, buf, NULL); |
5333
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1265 } |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1266 |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1267 g_hash_table_destroy(table); |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1268 |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1269 return TRUE; |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1270 } |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1271 static gboolean |
5309 | 1272 __connect_cb(gpointer data, gint source, GaimInputCondition cond) |
1273 { | |
1274 MsnServConn *notification = data; | |
1275 MsnSession *session = notification->session; | |
1276 struct gaim_connection *gc = session->account->gc; | |
1277 | |
1278 if (source == -1) { | |
1279 hide_login_progress(session->account->gc, _("Unable to connect")); | |
1280 signoff(session->account->gc); | |
1281 return FALSE; | |
1282 } | |
1283 | |
1284 if (notification->fd != source) | |
1285 notification->fd = source; | |
1286 | |
1287 if (!msn_servconn_send_command(notification, "VER", | |
5318
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
1288 "MSNP7 MSNP6 MSNP5 MSNP4 CVR0")) { |
5309 | 1289 hide_login_progress(gc, _("Unable to write to server")); |
1290 signoff(gc); | |
1291 return FALSE; | |
1292 } | |
1293 | |
5363
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5361
diff
changeset
|
1294 session->user = msn_user_new(session, gc->username, NULL); |
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5361
diff
changeset
|
1295 |
5326
9737d5ce9dcd
[gaim-migrate @ 5699]
Christian Hammond <chipx86@chipx86.com>
parents:
5323
diff
changeset
|
1296 set_login_progress(session->account->gc, 4, _("Syncing with server")); |
5309 | 1297 |
1298 return TRUE; | |
1299 } | |
1300 | |
1301 static void | |
1302 __failed_read_cb(gpointer data, gint source, GaimInputCondition cond) | |
1303 { | |
1304 MsnServConn *notification = data; | |
1305 struct gaim_connection *gc; | |
1306 | |
1307 gc = notification->session->account->gc; | |
1308 | |
1309 hide_login_progress(gc, _("Error reading from server")); | |
1310 signoff(gc); | |
1311 } | |
1312 | |
1313 MsnServConn * | |
1314 msn_notification_new(MsnSession *session, const char *server, int port) | |
1315 { | |
1316 MsnServConn *notification; | |
1317 | |
1318 notification = msn_servconn_new(session); | |
1319 | |
1320 msn_servconn_set_server(notification, server, port); | |
1321 msn_servconn_set_connect_cb(notification, __connect_cb); | |
1322 msn_servconn_set_failed_read_cb(notification, __failed_read_cb); | |
1323 | |
1324 if (notification_commands == NULL) { | |
1325 /* Register the command callbacks. */ | |
1326 msn_servconn_register_command(notification, "ADD", __add_cmd); | |
5322
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
1327 msn_servconn_register_command(notification, "ADG", __adg_cmd); |
5309 | 1328 msn_servconn_register_command(notification, "BLP", __blp_cmd); |
5361
953aa05279f4
[gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
5358
diff
changeset
|
1329 msn_servconn_register_command(notification, "BPR", __bpr_cmd); |
5309 | 1330 msn_servconn_register_command(notification, "CHG", __blank_cmd); |
1331 msn_servconn_register_command(notification, "CHL", __chl_cmd); | |
1332 msn_servconn_register_command(notification, "FLN", __fln_cmd); | |
1333 msn_servconn_register_command(notification, "GTC", __blank_cmd); | |
1334 msn_servconn_register_command(notification, "ILN", __iln_cmd); | |
1335 msn_servconn_register_command(notification, "INF", __inf_cmd); | |
1336 msn_servconn_register_command(notification, "LSG", __lsg_cmd); | |
1337 msn_servconn_register_command(notification, "LST", __lst_cmd); | |
1338 msn_servconn_register_command(notification, "MSG", __msg_cmd); | |
1339 msn_servconn_register_command(notification, "NLN", __nln_cmd); | |
1340 msn_servconn_register_command(notification, "OUT", __out_cmd); | |
5363
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5361
diff
changeset
|
1341 msn_servconn_register_command(notification, "PRP", __prp_cmd); |
5309 | 1342 msn_servconn_register_command(notification, "QNG", __blank_cmd); |
1343 msn_servconn_register_command(notification, "QRY", __blank_cmd); | |
1344 msn_servconn_register_command(notification, "REA", __rea_cmd); | |
5318
bd98232872a3
[gaim-migrate @ 5690]
Christian Hammond <chipx86@chipx86.com>
parents:
5312
diff
changeset
|
1345 msn_servconn_register_command(notification, "REG", __reg_cmd); |
5322
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
1346 msn_servconn_register_command(notification, "REM", __rem_cmd); |
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
1347 msn_servconn_register_command(notification, "RMG", __blank_cmd); |
5309 | 1348 msn_servconn_register_command(notification, "RNG", __rng_cmd); |
1349 msn_servconn_register_command(notification, "SYN", __blank_cmd); | |
1350 msn_servconn_register_command(notification, "URL", __url_cmd); | |
1351 msn_servconn_register_command(notification, "USR", __usr_cmd); | |
1352 msn_servconn_register_command(notification, "VER", __ver_cmd); | |
1353 msn_servconn_register_command(notification, "XFR", __xfr_cmd); | |
1354 msn_servconn_register_command(notification, "_unknown_", __unknown_cmd); | |
1355 | |
1356 /* Register the message type callbacks. */ | |
1357 msn_servconn_register_msg_type(notification, "text/x-msmsgsprofile", | |
1358 __profile_msg); | |
1359 msn_servconn_register_msg_type(notification, | |
1360 "text/x-msmsgsinitialemailnotification", | |
1361 __initial_email_msg); | |
1362 msn_servconn_register_msg_type(notification, | |
1363 "text/x-msmsgsemailnotification", | |
1364 __email_msg); | |
5333
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1365 msn_servconn_register_msg_type(notification, |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1366 "application/x-msmsgssystemmessage", |
bbbf616bd924
[gaim-migrate @ 5708]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
1367 __system_msg); |
5309 | 1368 |
1369 /* Save these for future use. */ | |
1370 notification_commands = notification->commands; | |
1371 notification_msg_types = notification->msg_types; | |
1372 } | |
1373 else { | |
1374 g_hash_table_destroy(notification->commands); | |
1375 g_hash_table_destroy(notification->msg_types); | |
1376 | |
1377 notification->commands = notification_commands; | |
1378 notification->msg_types = notification_msg_types; | |
1379 } | |
1380 | |
1381 return notification; | |
1382 } |