comparison libpurple/protocols/qq/qq_base.c @ 24682:8f757b2139d2

String changes (a few of which I had already made, grumble grumble). I tried to re-use strings that exist in other protocols as much as possible. When calling purple_connection_update_progress() the strings should not have ellipsis. When calling purple_connection_error_reason() due to a keep alive timeout, do not include the number of seconds, because there shouldn't be a reason for users to care
author Mark Doliner <mark@kingant.net>
date Thu, 11 Dec 2008 07:17:32 +0000
parents 55b7371eadf4
children f541583e31bd
comparison
equal deleted inserted replaced
24681:662fdd4836aa 24682:8f757b2139d2
422 422
423 default: 423 default:
424 qq_hex_dump(PURPLE_DEBUG_WARNING, "QQ", data, data_len, 424 qq_hex_dump(PURPLE_DEBUG_WARNING, "QQ", data, data_len,
425 ">>> [default] decrypt and dump"); 425 ">>> [default] decrypt and dump");
426 error = g_strdup_printf( 426 error = g_strdup_printf(
427 _("Unknown reply code when login (0x%02X)"), 427 _("Unknown reply code when logging in (0x%02X)"),
428 ret ); 428 ret );
429 reason = PURPLE_CONNECTION_ERROR_OTHER_ERROR; 429 reason = PURPLE_CONNECTION_ERROR_OTHER_ERROR;
430 break; 430 break;
431 } 431 }
432 432
462 gboolean qq_process_keep_alive(guint8 *data, gint data_len, PurpleConnection *gc) 462 gboolean qq_process_keep_alive(guint8 *data, gint data_len, PurpleConnection *gc)
463 { 463 {
464 qq_data *qd; 464 qq_data *qd;
465 gchar **segments; 465 gchar **segments;
466 466
467 g_return_val_if_fail(data != NULL && data_len != 0, FALSE); 467 g_return_val_if_fail(data != NULL, FALSE);
468 g_return_val_if_fail(data_len != 0, FALSE);
468 469
469 qd = (qq_data *) gc->proto_data; 470 qd = (qq_data *) gc->proto_data;
470 471
471 /* qq_show_packet("Keep alive reply packet", data, len); */ 472 /* qq_show_packet("Keep alive reply packet", data, len); */
472 473
473 /* the last one is 60, don't know what it is */ 474 /* the last one is 60, don't know what it is */
474 if (NULL == (segments = split_data(data, data_len, "\x1f", 6))) 475 segments = split_data(data, data_len, "\x1f", 6);
476 if (segments == NULL)
475 return TRUE; 477 return TRUE;
476 478
477 /* segments[0] and segment[1] are all 0x30 ("0") */ 479 /* segments[0] and segment[1] are all 0x30 ("0") */
478 qd->online_total = strtol(segments[2], NULL, 10); 480 qd->online_total = strtol(segments[2], NULL, 10);
479 if(0 == qd->online_total) { 481 if(0 == qd->online_total) {
480 purple_connection_error_reason(gc, 482 purple_connection_error_reason(gc,
481 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 483 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
482 _("Keep alive error")); 484 _("Lost connection with server"));
483 } 485 }
484 qd->my_ip.s_addr = inet_addr(segments[3]); 486 qd->my_ip.s_addr = inet_addr(segments[3]);
485 qd->my_port = strtol(segments[4], NULL, 10); 487 qd->my_port = strtol(segments[4], NULL, 10);
486 488
487 purple_debug_info("QQ", "keep alive, %s:%d\n", 489 purple_debug_info("QQ", "keep alive, %s:%d\n",
526 bytes += qq_get8(&ret, data + bytes); 528 bytes += qq_get8(&ret, data + bytes);
527 bytes += qq_get32(&qd->online_total, data + bytes); 529 bytes += qq_get32(&qd->online_total, data + bytes);
528 if(0 == qd->online_total) { 530 if(0 == qd->online_total) {
529 purple_connection_error_reason(gc, 531 purple_connection_error_reason(gc,
530 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 532 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
531 _("Keep alive error")); 533 _("Lost connection with server"));
532 } 534 }
533 535
534 bytes += qq_getIP(&qd->my_ip, data + bytes); 536 bytes += qq_getIP(&qd->my_ip, data + bytes);
535 bytes += qq_get16(&qd->my_port, data + bytes); 537 bytes += qq_get16(&qd->my_port, data + bytes);
536 return TRUE; 538 return TRUE;
570 bytes += qq_get8(&ret, data + bytes); 572 bytes += qq_get8(&ret, data + bytes);
571 bytes += qq_get32(&qd->online_total, data + bytes); 573 bytes += qq_get32(&qd->online_total, data + bytes);
572 if(0 == qd->online_total) { 574 if(0 == qd->online_total) {
573 purple_connection_error_reason(gc, 575 purple_connection_error_reason(gc,
574 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 576 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
575 _("Keep alive error")); 577 _("Lost connection with server"));
576 } 578 }
577 579
578 bytes += qq_getIP(&qd->my_ip, data + bytes); 580 bytes += qq_getIP(&qd->my_ip, data + bytes);
579 bytes += qq_get16(&qd->my_port, data + bytes); 581 bytes += qq_get16(&qd->my_port, data + bytes);
580 /* skip 2 byytes, 0x(00 3c) */ 582 /* skip 2 byytes, 0x(00 3c) */
651 } 653 }
652 654
653 if (data_len < 15) { 655 if (data_len < 15) {
654 purple_connection_error_reason(gc, 656 purple_connection_error_reason(gc,
655 PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR, 657 PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR,
656 _("Can not decrypt get server reply")); 658 _("Could not decrypt server reply"));
657 return QQ_LOGIN_REPLY_ERR; 659 return QQ_LOGIN_REPLY_ERR;
658 } 660 }
659 661
660 qd->redirect_len = data_len; 662 qd->redirect_len = data_len;
661 qd->redirect = g_realloc(qd->redirect, qd->redirect_len); 663 qd->redirect = g_realloc(qd->redirect, qd->redirect_len);
743 bytes += qq_putdata(buf + bytes, encrypted, encrypted_len); 745 bytes += qq_putdata(buf + bytes, encrypted, encrypted_len);
744 746
745 qd->send_seq++; 747 qd->send_seq++;
746 qq_send_cmd_encrypted(gc, QQ_CMD_TOKEN_EX, qd->send_seq, buf, bytes, TRUE); 748 qq_send_cmd_encrypted(gc, QQ_CMD_TOKEN_EX, qd->send_seq, buf, bytes, TRUE);
747 749
748 purple_connection_update_progress(gc, _("Requesting captcha ..."), 3, QQ_CONNECT_STEPS); 750 purple_connection_update_progress(gc, _("Requesting captcha"), 3, QQ_CONNECT_STEPS);
749 } 751 }
750 752
751 static void request_token_ex_code(PurpleConnection *gc, 753 static void request_token_ex_code(PurpleConnection *gc,
752 guint8 *token, guint16 token_len, guint8 *code, guint16 code_len) 754 guint8 *token, guint16 token_len, guint8 *code, guint16 code_len)
753 { 755 {
788 bytes += qq_putdata(buf + bytes, encrypted, encrypted_len); 790 bytes += qq_putdata(buf + bytes, encrypted, encrypted_len);
789 791
790 qd->send_seq++; 792 qd->send_seq++;
791 qq_send_cmd_encrypted(gc, QQ_CMD_TOKEN_EX, qd->send_seq, buf, bytes, TRUE); 793 qq_send_cmd_encrypted(gc, QQ_CMD_TOKEN_EX, qd->send_seq, buf, bytes, TRUE);
792 794
793 purple_connection_update_progress(gc, _("Checking code of captcha ..."), 3, QQ_CONNECT_STEPS); 795 purple_connection_update_progress(gc, _("Checking captcha"), 3, QQ_CONNECT_STEPS);
794 } 796 }
795 797
796 typedef struct { 798 typedef struct {
797 PurpleConnection *gc; 799 PurpleConnection *gc;
798 guint8 *token; 800 guint8 *token;
811 { 813 {
812 captcha_request_destory(captcha_req); 814 captcha_request_destory(captcha_req);
813 815
814 purple_connection_error_reason(captcha_req->gc, 816 purple_connection_error_reason(captcha_req->gc,
815 PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, 817 PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED,
816 _("Failed captcha verify")); 818 _("Failed captcha verification"));
817 } 819 }
818 820
819 static void captcha_input_ok_cb(qq_captcha_request *captcha_req, 821 static void captcha_input_ok_cb(qq_captcha_request *captcha_req,
820 PurpleRequestFields *fields) 822 PurpleRequestFields *fields)
821 { 823 {
870 _("Enter code"), "", FALSE); 872 _("Enter code"), "", FALSE);
871 purple_request_field_string_set_masked(field, FALSE); 873 purple_request_field_string_set_masked(field, FALSE);
872 purple_request_field_group_add_field(group, field); 874 purple_request_field_group_add_field(group, field);
873 875
874 purple_request_fields(account, 876 purple_request_fields(account,
875 _("QQ Captcha Verifying"), 877 _("QQ Captcha Verification"),
876 _("QQ Captcha Verifying"), 878 _("QQ Captcha Verification"),
877 _("Enter the text from the image"), 879 _("Enter the text from the image"),
878 fields, 880 fields,
879 _("OK"), G_CALLBACK(captcha_input_ok_cb), 881 _("OK"), G_CALLBACK(captcha_input_ok_cb),
880 _("Cancel"), G_CALLBACK(captcha_input_cancel_cb), 882 _("Cancel"), G_CALLBACK(captcha_input_cancel_cb),
881 purple_connection_get_account(gc), NULL, NULL, 883 purple_connection_get_account(gc), NULL, NULL,
1109 break; 1111 break;
1110 default: 1112 default:
1111 qq_hex_dump(PURPLE_DEBUG_WARNING, "QQ", data, data_len, 1113 qq_hex_dump(PURPLE_DEBUG_WARNING, "QQ", data, data_len,
1112 ">>> [default] decrypt and dump"); 1114 ">>> [default] decrypt and dump");
1113 error = g_strdup_printf( 1115 error = g_strdup_printf(
1114 _("Unknown reply code when checking password (0x%02X)"), 1116 _("Unknown reply when checking password (0x%02X)"),
1115 ret ); 1117 ret );
1116 reason = PURPLE_CONNECTION_ERROR_OTHER_ERROR; 1118 reason = PURPLE_CONNECTION_ERROR_OTHER_ERROR;
1117 break; 1119 break;
1118 } 1120 }
1119 1121
1255 case 0x0A: 1257 case 0x0A:
1256 /* 0a 2d 9a 4b 9a 01 01 00 00 00 05 00 00 00 00 79 0e 5f fd */ 1258 /* 0a 2d 9a 4b 9a 01 01 00 00 00 05 00 00 00 00 79 0e 5f fd */
1257 /* Missing get server before login*/ 1259 /* Missing get server before login*/
1258 default: 1260 default:
1259 error = g_strdup_printf( 1261 error = g_strdup_printf(
1260 _("Unknown reply code when login (0x%02X):\n%s"), 1262 _("Unknown reply code when logging in (0x%02X):\n%s"),
1261 ret, msg_utf8); 1263 ret, msg_utf8);
1262 break; 1264 break;
1263 } 1265 }
1264 1266
1265 purple_debug_error("QQ", "%s\n", error); 1267 purple_debug_error("QQ", "%s\n", error);
1444 purple_debug_error("QQ", "Server busy for %s\n", msg_utf8); 1446 purple_debug_error("QQ", "Server busy for %s\n", msg_utf8);
1445 return QQ_LOGIN_REPLY_REDIRECT; 1447 return QQ_LOGIN_REPLY_REDIRECT;
1446 break; 1448 break;
1447 default: 1449 default:
1448 error = g_strdup_printf( 1450 error = g_strdup_printf(
1449 _("Unknown reply code when login (0x%02X):\n%s"), 1451 _("Unknown reply code when logging in (0x%02X):\n%s"),
1450 ret, msg_utf8); 1452 ret, msg_utf8);
1451 break; 1453 break;
1452 } 1454 }
1453 1455
1454 purple_debug_error("QQ", "%s\n", error); 1456 purple_debug_error("QQ", "%s\n", error);