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