//the entrience for recv file messages void file_message(LwqqClient* lc,LwqqMsgFileMessage* file) { qq_account* ac = lwqq_client_userdata(lc); if(file->mode == MODE_RECV) { PurpleAccount* account = ac->account; LwqqClient* lc = ac->qq; LwqqBuddy* buddy = lc->find_buddy_by_uin(lc,file->super.from); if(buddy == NULL ) return; const char* key = try_get(buddy->qqnumber,buddy->uin); PurpleXfer* xfer = purple_xfer_new(account,PURPLE_XFER_RECEIVE,key); purple_xfer_set_filename(xfer,file->recv.name); purple_xfer_set_init_fnc(xfer,recv_file_init); purple_xfer_set_request_denied_fnc(xfer,recv_file_request_denied); purple_xfer_set_cancel_recv_fnc(xfer,recv_file_cancel); LwqqMsgFileMessage* fdup = s_malloc0(sizeof(*fdup)); lwqq_msg_move(fdup,file); xfer->data = fdup; purple_xfer_request(xfer); } else if(file->mode == MODE_REFUSE) { if(file->refuse.cancel_type == CANCEL_BY_USER) qq_sys_msg_write(ac, LWQQ_MS_BUDDY_MSG, file->super.from, _("Other canceled file transport"), PURPLE_MESSAGE_SYSTEM, time(NULL)); else if(file->refuse.cancel_type == CANCEL_BY_OVERTIME) qq_sys_msg_write(ac, LWQQ_MS_BUDDY_MSG, file->super.from, _("File transport timeout"), PURPLE_MESSAGE_SYSTEM, time(NULL)); } }
void file_message(LwqqClient* lc,LwqqMsgFileMessage* file) { qq_account* ac = lwqq_client_userdata(lc); if(file->mode == MODE_RECV) { PurpleAccount* account = ac->account; LwqqClient* lc = ac->qq; //for(i=0;i<file->file_count;i++){ LwqqBuddy* buddy = lc->find_buddy_by_uin(lc,file->from); if(buddy == NULL ) return; const char* key = try_get(buddy->qqnumber,buddy->uin); PurpleXfer* xfer = purple_xfer_new(account,PURPLE_XFER_RECEIVE,key); purple_xfer_set_filename(xfer,file->recv.name); purple_xfer_set_init_fnc(xfer,recv_file_init); purple_xfer_set_request_denied_fnc(xfer,recv_file_request_denied); purple_xfer_set_cancel_recv_fnc(xfer,recv_file_cancel); LwqqMsgFileMessage* fdup = s_malloc(sizeof(*fdup)); memcpy(fdup,file,sizeof(*fdup)); file->from = file->to = file->reply_ip = file->recv.name = NULL; xfer->data = fdup; purple_xfer_request(xfer); } else if(file->mode == MODE_REFUSE) { if(file->refuse.cancel_type == CANCEL_BY_USER) { qq_sys_msg_write(ac, LWQQ_MT_BUDDY_MSG, file->from, "对方取消文件传输", PURPLE_MESSAGE_SYSTEM, time(NULL)); } else if(file->refuse.cancel_type == CANCEL_BY_OVERTIME) { qq_sys_msg_write(ac, LWQQ_MT_BUDDY_MSG, file->from, "文件传输超时", PURPLE_MESSAGE_SYSTEM, time(NULL)); } } }
static void* _background_login(void* data) { qq_account* ac=(qq_account*)data; if(!qq_account_valid(ac)) return NULL; LwqqClient* lc = ac->qq; LwqqErrorCode err; //it would raise a invalid ac when wake up from sleep. //it would login twice,why? //so what i can do is disable the invalid one. if(!lwqq_client_valid(lc)) return NULL; const char* status = purple_status_get_id(purple_account_get_active_status(ac->account)); lwqq_login(lc,lwqq_status_from_str(status), &err); if (err == LWQQ_EC_LOGIN_NEED_VC) { lc->dispatch(vp_func_pi,(CALLBACK_FUNC)extra_async_opt.need_verify,lc,err); }else{ lc->dispatch(vp_func_pi,(CALLBACK_FUNC)extra_async_opt.login_complete,lc,err); } return NULL; }