예제 #1
0
파일: internal.c 프로젝트: btbxbob/lwqq
/**
 * 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;
}
예제 #2
0
파일: login.c 프로젝트: GrayMissing/lwqq
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;
}
예제 #3
0
파일: login.c 프로젝트: GrayMissing/lwqq
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;
}
예제 #4
0
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;
}