comparison libpurple/protocols/qq/login_logout.c @ 19640:1a16d474c459

Spaces to tabs
author Mark Doliner <mark@kingant.net>
date Tue, 04 Sep 2007 07:20:16 +0000
parents b9a0b1bd321b
children 44b4e8bd759b
comparison
equal deleted inserted replaced
19639:fc8a6f67b030 19640:1a16d474c459
378 purple_debug(PURPLE_DEBUG_ERROR, "QQ", "Fail create login packet\n"); 378 purple_debug(PURPLE_DEBUG_ERROR, "QQ", "Fail create login packet\n");
379 } 379 }
380 380
381 void qq_process_request_login_token_reply(guint8 *buf, gint buf_len, PurpleConnection *gc) 381 void qq_process_request_login_token_reply(guint8 *buf, gint buf_len, PurpleConnection *gc)
382 { 382 {
383 qq_data *qd; 383 qq_data *qd;
384 gchar *hex_dump; 384 gchar *hex_dump;
385 385
386 g_return_if_fail(buf != NULL && buf_len != 0); 386 g_return_if_fail(buf != NULL && buf_len != 0);
387 387
388 qd = (qq_data *) gc->proto_data; 388 qd = (qq_data *) gc->proto_data;
389 389
390 if (buf[0] == QQ_REQUEST_LOGIN_TOKEN_REPLY_OK) { 390 if (buf[0] == QQ_REQUEST_LOGIN_TOKEN_REPLY_OK) {
391 if (buf[1] != buf_len-2) { 391 if (buf[1] != buf_len-2) {
392 purple_debug(PURPLE_DEBUG_INFO, "QQ", 392 purple_debug(PURPLE_DEBUG_INFO, "QQ",
393 "Malformed login token reply packet. Packet specifies length of %d, actual length is %d\n", buf[1], buf_len-2); 393 "Malformed login token reply packet. Packet specifies length of %d, actual length is %d\n", buf[1], buf_len-2);
394 purple_debug(PURPLE_DEBUG_INFO, "QQ", 394 purple_debug(PURPLE_DEBUG_INFO, "QQ",
395 "Attempting to proceed with the actual packet length.\n"); 395 "Attempting to proceed with the actual packet length.\n");
396 } 396 }
397 hex_dump = hex_dump_to_str(buf+2, buf_len-2); 397 hex_dump = hex_dump_to_str(buf+2, buf_len-2);
398 purple_debug(PURPLE_DEBUG_INFO, "QQ", 398 purple_debug(PURPLE_DEBUG_INFO, "QQ",
399 "<<< got a token with %d bytes -> [default] decrypt and dump\n%s", buf_len-2, hex_dump); 399 "<<< got a token with %d bytes -> [default] decrypt and dump\n%s", buf_len-2, hex_dump);
400 qq_send_packet_login(gc, buf_len-2, buf+2); 400 qq_send_packet_login(gc, buf_len-2, buf+2);
401 } else { 401 } else {
402 purple_debug(PURPLE_DEBUG_ERROR, "QQ", "Unknown request login token reply code : %d\n", buf[0]); 402 purple_debug(PURPLE_DEBUG_ERROR, "QQ", "Unknown request login token reply code : %d\n", buf[0]);
403 hex_dump = hex_dump_to_str(buf, buf_len); 403 hex_dump = hex_dump_to_str(buf, buf_len);
404 purple_debug(PURPLE_DEBUG_WARNING, "QQ", 404 purple_debug(PURPLE_DEBUG_WARNING, "QQ",
405 ">>> %d bytes -> [default] decrypt and dump\n%s", 405 ">>> %d bytes -> [default] decrypt and dump\n%s",
406 buf_len, hex_dump); 406 buf_len, hex_dump);
407 try_dump_as_gbk(buf, buf_len); 407 try_dump_as_gbk(buf, buf_len);
408 purple_connection_error(gc, _("Error requesting login token")); 408 purple_connection_error(gc, _("Error requesting login token"));
409 } 409 }
410 g_free(hex_dump); 410 g_free(hex_dump);
411 } 411 }
412 412
413 /* send logout packets to QQ server */ 413 /* send logout packets to QQ server */
414 void qq_send_packet_logout(PurpleConnection *gc) 414 void qq_send_packet_logout(PurpleConnection *gc)
461 ret = _qq_process_login_wrong_pwd(gc, data, len); 461 ret = _qq_process_login_wrong_pwd(gc, data, len);
462 break; 462 break;
463 default: 463 default:
464 purple_debug(PURPLE_DEBUG_ERROR, "QQ", "Unknown reply code: %d\n", data[0]); 464 purple_debug(PURPLE_DEBUG_ERROR, "QQ", "Unknown reply code: %d\n", data[0]);
465 hex_dump = hex_dump_to_str(data, len); 465 hex_dump = hex_dump_to_str(data, len);
466 purple_debug(PURPLE_DEBUG_WARNING, "QQ", 466 purple_debug(PURPLE_DEBUG_WARNING, "QQ",
467 ">>> %d bytes -> [default] decrypt and dump\n%s", 467 ">>> %d bytes -> [default] decrypt and dump\n%s",
468 buf_len, hex_dump); 468 buf_len, hex_dump);
469 g_free(hex_dump); 469 g_free(hex_dump);
470 try_dump_as_gbk(data, len); 470 try_dump_as_gbk(data, len);
471 471
472 ret = QQ_LOGIN_REPLY_MISC_ERROR; 472 ret = QQ_LOGIN_REPLY_MISC_ERROR;
473 } 473 }
474 } else { /* no idea how to decrypt */ 474 } else { /* no idea how to decrypt */
475 purple_debug(PURPLE_DEBUG_ERROR, "QQ", "No idea how to decrypt login reply\n"); 475 purple_debug(PURPLE_DEBUG_ERROR, "QQ", "No idea how to decrypt login reply\n");