Пример #1
0
static void login_stage_3(LwqqAsyncEvent* ev,LwqqErrorCode* ec)
{
	if(lwqq_async_event_get_code(ev) == LWQQ_CALLBACK_FAILED) return;
	int err = lwqq_async_event_get_result(ev);
	if(ec) *ec=err;
	LwqqClient* lc = lwqq_async_event_get_owner(ev);
	if(!lwqq_client_valid(lc)) return;
	switch (err) {
		case LWQQ_EC_LOGIN_NEED_VC:
			lwqq_log(LOG_WARNING, "Need to enter verify code\n");
			lc->vc->cmd = _C_(2p,login_stage_4,lc,ec);
			get_verify_image(lc);
			return ;

		case LWQQ_EC_NETWORK_ERROR:
			lwqq_log(LOG_ERROR, "Network error\n");
			lc->stat = LWQQ_STATUS_LOGOUT;
			lc->args->login_ec = err;
			vp_do_repeat(lc->events->login_complete, NULL);
			return ;

		case LWQQ_EC_OK:
			lwqq_log(LOG_DEBUG, "Get verify code OK\n");
			break;

		default:
			lwqq_log(LOG_ERROR, "Unknown error\n");
			lc->stat = LWQQ_STATUS_LOGOUT;
			lc->args->login_ec = err;
			vp_do_repeat(lc->events->login_complete, NULL);
			return ;
	}

	login_stage_4(lc,ec);
}
Пример #2
0
static void login_stage_3(LwqqAsyncEvent* ev)
{
    if(lwqq_async_event_get_code(ev) == LWQQ_CALLBACK_FAILED) return;
    int err = lwqq_async_event_get_result(ev);
    LwqqClient* lc = lwqq_async_event_get_owner(ev);
    if(!lwqq_client_valid(lc)) return;
    switch (err) {
        case LWQQ_EC_LOGIN_NEED_VC:
            lwqq_log(LOG_WARNING, "Need to enter verify code\n");
            LwqqAsyncEvent* ev = get_verify_image(lc);
            lwqq_async_add_event_listener(ev,_C_(p,lc->async_opt->login_verify,lc));
            return ;

        case LWQQ_EC_NETWORK_ERROR:
            lwqq_log(LOG_ERROR, "Network error\n");
            lc->async_opt->login_complete(lc,err);
            return ;

        case LWQQ_EC_OK:
            lwqq_log(LOG_DEBUG, "Get verify code OK\n");
            break;

        default:
            lwqq_log(LOG_ERROR, "Unknown error\n");
            lc->async_opt->login_complete(lc,err);
            return ;
    }

    login_stage_4(lc);
}
Пример #3
0
static void login_stage_2(LwqqAsyncEvent* ev)
{
    if(lwqq_async_event_get_code(ev) == LWQQ_CALLBACK_FAILED) return;
    LwqqClient* lc = lwqq_async_event_get_owner(ev);
    if(!lwqq_client_valid(lc)) return;
    int err = lwqq_async_event_get_result(ev);
    if (err) {
        lwqq_log(LOG_ERROR, "Get webqq version error\n");
        lc->async_opt->login_complete(lc,err);
        return ;
    }
    lwqq_log(LOG_NOTICE, "Get webqq version: %s\n", lc->version);


    /**
     * Second, we get the verify code from server.
     * If server provide us a image and let us enter code shown
     * in image number, in this situation, we just return LWQQ_EC_LOGIN_NEED_VC
     * simply, so user should call lwqq_login() again after he set correct
     * code to vc->str;
     * Else, if we can get the code directly, do login immediately.
     * 
     */
    if (!lc->vc) {
        LwqqAsyncEvent* ev = get_verify_code(lc,APPID);
        lwqq_async_add_event_listener(ev,_C_(p,login_stage_3,ev));
        return;
    }

    login_stage_4(lc);
}
Пример #4
0
static void login_stage_f(LwqqAsyncEvent* ev)
{
    if(lwqq_async_event_get_code(ev) == LWQQ_CALLBACK_FAILED) return;
    int err = lwqq_async_event_get_result(ev);
    LwqqClient* lc = lwqq_async_event_get_owner(ev);
    if(!lwqq_client_valid(lc)) return;
    lc->async_opt->login_complete(lc,err);
    lwqq_vc_free(lc->vc);
    lc->vc = NULL;
}
Пример #5
0
static void login_stage_f(LwqqAsyncEvent* ev,LwqqErrorCode* ec)
{
	if(lwqq_async_event_get_code(ev) == LWQQ_CALLBACK_FAILED) return;
	int err = lwqq_async_event_get_result(ev);
	if(ec)(*ec=err);
	LwqqClient* lc = lwqq_async_event_get_owner(ev);
	if(!lwqq_client_valid(lc)) return;
	lwqq_vc_free(lc->vc);
	lc->vc = NULL;
	if(err) lc->stat = LWQQ_STATUS_LOGOUT;
	lc->args->login_ec = err;
	vp_do_repeat(lc->events->login_complete, NULL);
}
Пример #6
0
static void login_stage_5(LwqqAsyncEvent* ev)
{
    if(lwqq_async_event_get_code(ev) == LWQQ_CALLBACK_FAILED) return;
    int err = lwqq_async_event_get_result(ev);
    LwqqClient* lc = lwqq_async_event_get_owner(ev);
    if(!lwqq_client_valid(lc)) return;
    /* Free old value */

    if(err != LWQQ_EC_OK){
        lc->async_opt->login_complete(lc,err);
    }
    LwqqAsyncEvent* event = set_online_status(lc, lwqq_status_to_str(lc->stat));
    lwqq_async_add_event_listener(event,_C_(p,login_stage_f,event));
}
Пример #7
0
static void login_stage_5(LwqqAsyncEvent* ev,LwqqErrorCode* ec)
{
	if(lwqq_async_event_get_code(ev) == LWQQ_CALLBACK_FAILED) return;
	int err = lwqq_async_event_get_result(ev);
	if(ec)(*ec=err);
	LwqqClient* lc = lwqq_async_event_get_owner(ev);
	if(!lwqq_client_valid(lc)) return;
	/* Free old value */

	if(err != LWQQ_EC_OK){
		lc->stat = LWQQ_STATUS_LOGOUT;
		lc->args->login_ec = err;
		vp_do_repeat(lc->events->login_complete, NULL);
		return;
	}
	LwqqAsyncEvent* event = set_online_status(lc, lwqq_status_to_str(lc->stat));
	lwqq_async_add_event_listener(event,_C_(2p,login_stage_f,event,ec));
}
Пример #8
0
static void send_file(LwqqAsyncEvent* event,PurpleXfer *xfer)
{
    qq_account* ac = purple_connection_get_protocol_data(purple_account_get_connection(xfer->account));
    LwqqClient* lc = ac->qq;
    long errno = 0;
    if(lwqq_async_event_get_code(event)==LWQQ_CALLBACK_FAILED){
        s_free(xfer->data);
        return;
    }
    errno = lwqq_async_event_get_result(event);
    LwqqMsgOffFile* file = xfer->data;
    //purple_xfer_unref(xfer);
    if(errno) {
        qq_sys_msg_write(ac,LWQQ_MT_BUDDY_MSG, file->to,"上传空间不足",PURPLE_MESSAGE_ERROR,time(NULL));
        lwqq_msg_offfile_free(file);
        s_free(xfer->data);
        purple_xfer_set_completed(xfer,1);
    } else {
        LwqqAsyncEvent* ev = lwqq_msg_send_offfile(lc,file);
        lwqq_async_add_event_listener(ev,_C_(2p,send_offline_file_receipt,ev,xfer));
    }
}