static int get_login_sig_back(LwqqHttpRequest* req) { LwqqErrorCode err = LWQQ_EC_OK; LwqqClient* lc = req->lc; lwqq__jump_if_http_fail(req, err); if(!req->response){err = LWQQ_EC_ERROR;goto done;} char* beg = strstr(req->response,"var g_login_sig="); char login_sig[256]; sscanf(beg,"var g_login_sig=encodeURIComponent(\"%[^\"]\")",login_sig); lwqq_override(lc->login_sig, s_strdup(login_sig)); done: lwqq_http_request_free(req); return err; }
/** * this process simple result; */ int lwqq__process_simple_response(LwqqHttpRequest* req) { //{"retcode":0,"result":{"ret":0}} int err = 0; json_t *root = NULL; lwqq__jump_if_http_fail(req,err); lwqq__jump_if_json_fail(root,req->response,err); int retcode = s_atoi(json_parse_simple_value(root, "retcode"),LWQQ_EC_ERROR); if(retcode != LWQQ_EC_OK){ err = retcode; } done: lwqq__log_if_error(err, req); lwqq__clean_json_and_req(root,req); return err; }
static int check_need_verify_back(LwqqHttpRequest* req) { int err = LWQQ_EC_OK; LwqqClient* lc = req->lc; if(req->failcode != LWQQ_CALLBACK_VALID){ err = LWQQ_EC_NETWORK_ERROR; lc->args->login_ec = err; vp_do_repeat(lc->events->login_complete, NULL); goto done; } lwqq__jump_if_http_fail(req, err); /** * * The http message body has two format: * * ptui_checkVC('1','9ed32e3f644d968809e8cbeaaf2cce42de62dfee12c14b74','\x00\x00\x00\x00\x04\x7e\x73\xb2'); * ptui_checkVC('0','!IJG', '\x00\x00\x00\x00\x54\xb3\x3c\x53'); * The former means we need verify code image and the second * parameter is vc_type. * The later means we don't need the verify code image. The second * parameter is the verify code. The vc_type is in the header * "Set-Cookie". */ int need_vf; char param2[256]; char param3[256]; sscanf(req->response,"ptui_checkVC('%d','%[^']','%[^']');",&need_vf,param2,param3); lc->vc = s_malloc0(sizeof(*lc->vc)); lc->vc->uin = s_strdup(param3); lc->vc->str = s_strdup(param2); lc->vc->lc = lc; if (need_vf == 0) { /* We need get the ptvfsession from the header "Set-Cookie" */ lwqq_log(LOG_NOTICE, "Verify code: %s\n", lc->vc->str); } else if (need_vf == 1) { err = LWQQ_EC_LOGIN_NEED_VC; lwqq_log(LOG_NOTICE, "We need verify code image: %s\n", lc->vc->str); } done: lwqq_http_request_free(req); return err; }
static int process_login2(LwqqHttpRequest* req) { /* * {"retcode":0,"result":{"uin":2501542492,"cip":3396791469,"index":1075,"port":49648,"status":"online","vfwebqq":"8e6abfdb20f9436be07e652397a1197553f49fabd3e67fc88ad7ee4de763f337e120fdf7036176c9","psessionid":"8368046764001d636f6e6e7365727665725f77656271714031302e3133392e372e31363000003bce00000f8a026e04005c821a956d0000000a407646664c41737a42416d000000288e6abfdb20f9436be07e652397a1197553f49fabd3e67fc88ad7ee4de763f337e120fdf7036176c9","user_state":0,"f":0}} */ int err = 0; LwqqClient* lc = req->lc; json_t* root = NULL,*result; lwqq__jump_if_http_fail(req,err); lwqq__jump_if_json_fail(root,req->response,err); result = lwqq__parse_retcode_result(root, &err); switch(err){ case 0: lwqq_puts("[ReLinkSuccess]"); break; case 103: lwqq_puts("[Not Relogin]"); vp_do_repeat(lc->events->poll_lost, NULL); goto done; case 113: case 115: case 112: lwqq_puts("[RelinkFailure]"); vp_do_repeat(lc->events->poll_lost, NULL); goto done; default: lwqq_puts("[RelinkStop]"); vp_do_repeat(lc->events->poll_lost, NULL); goto done; } if(result){ lwqq_override(lc->cip,lwqq__json_get_value(result,"cip")); lwqq_override(lc->index,lwqq__json_get_value(result,"index")); lwqq_override(lc->port,lwqq__json_get_value(result,"port")); lwqq_override(lc->psessionid,lwqq__json_get_value(result,"psessionid")); lwqq_override(lc->vfwebqq,lwqq__json_get_value(result,"vfwebqq")); lc->stat = lwqq_status_from_str(json_parse_simple_value(result, "status")); } done: lwqq__log_if_error(err, req); lwqq__clean_json_and_req(root,req); return err; }
static int set_online_status_back(LwqqHttpRequest* req) { int err = 0; LwqqClient* lc = req->lc; json_t* root = NULL,*result; lwqq__jump_if_http_fail(req,err); lwqq__jump_if_json_fail(root,req->response,err); result = lwqq__parse_retcode_result(root, &err); if(err) goto done; if(result){ lwqq_override(lc->seskey,lwqq__json_get_value(result,"seskey")); lwqq_override(lc->cip,lwqq__json_get_value(result,"cip")); lwqq_override(lc->myself->uin,lwqq__json_get_value(result,"uin")); lwqq_override(lc->index,lwqq__json_get_value(result,"index")); lwqq_override(lc->port,lwqq__json_get_value(result,"port")); lwqq_override(lc->psessionid,lwqq__json_get_value(result,"psessionid")); lwqq_override(lc->vfwebqq,lwqq__json_get_value(result,"vfwebqq")); lc->stat = lwqq_status_from_str(json_parse_simple_value(result, "status")); } done: lwqq__log_if_error(err, req); lwqq__clean_json_and_req(root,req); return err; }
static int process_login2(LwqqHttpRequest* req) { /* * {"retcode":0,"result":{"uin":2501542492,"cip":3396791469,"index":1075,"port":49648,"status":"online","vfwebqq":"8e6abfdb20f9436be07e652397a1197553f49fabd3e67fc88ad7ee4de763f337e120fdf7036176c9","psessionid":"8368046764001d636f6e6e7365727665725f77656271714031302e3133392e372e31363000003bce00000f8a026e04005c821a956d0000000a407646664c41737a42416d000000288e6abfdb20f9436be07e652397a1197553f49fabd3e67fc88ad7ee4de763f337e120fdf7036176c9","user_state":0,"f":0}} */ int err = 0; LwqqClient* lc = req->lc; json_t* root = NULL,*result; lwqq__jump_if_http_fail(req,err); lwqq__jump_if_json_fail(root,req->response,err); result = lwqq__parse_retcode_result(root, &err); if(err!=WEBQQ_OK) goto done; if(result){ lwqq__override(lc->cip,lwqq__json_get_value(result,"cip")); lwqq__override(lc->index,lwqq__json_get_value(result,"index")); lwqq__override(lc->port,lwqq__json_get_value(result,"port")); lwqq__override(lc->psessionid,lwqq__json_get_value(result,"psessionid")); lc->stat = lwqq_status_from_str(json_parse_simple_value(result, "status")); lwqq__override(lc->vfwebqq,lwqq__json_get_value(result,"vfwebqq")); } done: lwqq__clean_json_and_req(root,req); return err; }