Esempio n. 1
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);
}
Esempio n. 2
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);
}
Esempio n. 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);
}
Esempio n. 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;
}
Esempio n. 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);
}
Esempio n. 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));
}
Esempio n. 7
0
static void send_offline_file_receipt(LwqqAsyncEvent* ev,PurpleXfer* xfer)
{
    int errno = lwqq_async_event_get_result(ev);
    qq_account* ac = purple_connection_get_protocol_data(purple_account_get_connection(xfer->account));
    LwqqMsgOffFile* file = xfer->data;

    if(errno == 0){
        qq_sys_msg_write(ac, LWQQ_MT_BUDDY_MSG, file->to, "发送离线文件成功", PURPLE_MESSAGE_SYSTEM, time(NULL));
    }else{
        qq_sys_msg_write(ac, LWQQ_MT_BUDDY_MSG, file->to, "发送离线文件失败", PURPLE_MESSAGE_ERROR, time(NULL));
    }
    lwqq_msg_offfile_free(file);
    purple_xfer_set_completed(xfer,1);
}
Esempio n. 8
0
static void send_offline_file_receipt(LwqqAsyncEvent* ev,PurpleXfer* xfer)
{
	int err = lwqq_async_event_get_result(ev);
	qq_account* ac = purple_connection_get_protocol_data(purple_account_get_connection(xfer->account));
	LwqqMsgOffFile* file = xfer->data;

	if(err == 0){
		qq_sys_msg_write(ac, LWQQ_MS_BUDDY_MSG, file->super.to, _("Send offline file successful"), PURPLE_MESSAGE_SYSTEM, time(NULL));
	}else{
		char buf[512];
		snprintf(buf,sizeof(buf),_("Send offline file failed,Error Code:%d"),err);
		qq_sys_msg_write(ac, LWQQ_MS_BUDDY_MSG, file->super.to, buf, PURPLE_MESSAGE_ERROR, time(NULL));
	}
	lwqq_msg_free((LwqqMsg*)file);
	purple_xfer_set_completed(xfer,1);
}
Esempio n. 9
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));
}
Esempio n. 10
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));
    }
}
Esempio n. 11
0
static void send_file(LwqqAsyncEvent* event,PurpleXfer *xfer)
{
    //now xfer is not valid.
    if(event->failcode != LWQQ_CALLBACK_VALID) return;
    qq_account* ac = purple_connection_get_protocol_data(purple_account_get_connection(xfer->account));
    LwqqClient* lc = ac->qq;
    long errno = 0;
    if(event->failcode==LWQQ_CALLBACK_FAILED) {
        lwqq_msg_free((LwqqMsg*)xfer->data);
        return;
    }
    errno = lwqq_async_event_get_result(event);
    LwqqMsgOffFile* file = xfer->data;
    if(errno) {
        qq_sys_msg_write(ac,LWQQ_MS_BUDDY_MSG, file->super.to,"发送离线文件失败",PURPLE_MESSAGE_ERROR,time(NULL));
        lwqq_msg_free((LwqqMsg*)file);
        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));
    }
}