diff options
author | ElzorFox <elzorfox@ya.ru> | 2017-02-06 09:10:52 +0500 |
---|---|---|
committer | ElzorFox <elzorfox@ya.ru> | 2017-02-06 09:11:28 +0500 |
commit | 3470645d1e1af2b6db6defcac8580ebb929b9c3a (patch) | |
tree | 513afd61aa6693fd3eb348a8b44b941b53b45495 /protocols/VKontakte | |
parent | 428f4fe793688a84c0bc70f8a6d35e5f802698ae (diff) |
VKontakte: remove unneeded thread
Diffstat (limited to 'protocols/VKontakte')
-rw-r--r-- | protocols/VKontakte/src/vk_files.cpp | 59 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.h | 1 |
2 files changed, 25 insertions, 35 deletions
diff --git a/protocols/VKontakte/src/vk_files.cpp b/protocols/VKontakte/src/vk_files.cpp index 1123a59d83..86aff9fb94 100644 --- a/protocols/VKontakte/src/vk_files.cpp +++ b/protocols/VKontakte/src/vk_files.cpp @@ -26,7 +26,31 @@ HANDLE CVkProto::SendFile(MCONTACT hContact, const wchar_t *desc, wchar_t **file return (HANDLE)0;
CVkFileUploadParam *fup = new CVkFileUploadParam(hContact, desc, files);
- ForkThread(&CVkProto::SendFileThread, (void *)fup);
+
+ ProtoBroadcastAck(fup->hContact, ACKTYPE_FILE, ACKRESULT_INITIALISING, (HANDLE)fup);
+
+ if (!fup->IsAccess()) {
+ SendFileFiled(fup, VKERR_FILE_NOT_EXIST);
+ return (HANDLE)0;
+ }
+
+ AsyncHttpRequest *pReq;
+ switch (fup->GetType()) {
+ case CVkFileUploadParam::typeImg:
+ pReq = new AsyncHttpRequest(this, REQUEST_GET, "/method/photos.getMessagesUploadServer.json", true, &CVkProto::OnReciveUploadServer);
+ break;
+ case CVkFileUploadParam::typeAudio:
+ pReq = new AsyncHttpRequest(this, REQUEST_GET, "/method/audio.getUploadServer.json", true, &CVkProto::OnReciveUploadServer);
+ break;
+ case CVkFileUploadParam::typeDoc:
+ pReq = new AsyncHttpRequest(this, REQUEST_GET, "/method/docs.getUploadServer.json", true, &CVkProto::OnReciveUploadServer);
+ break;
+ default:
+ SendFileFiled(fup, VKERR_FTYPE_NOT_SUPPORTED);
+ return (HANDLE)0;
+ }
+ pReq->pUserInfo = fup;
+ Push(pReq);
return (HANDLE)fup;
}
@@ -94,39 +118,6 @@ void CVkProto::SendFileFiled(CVkFileUploadParam *fup, int ErrorCode) delete fup;
}
-void CVkProto::SendFileThread(void *p)
-{
- CVkFileUploadParam *fup = (CVkFileUploadParam *)p;
- debugLogW(L"CVkProto::SendFileThread %d %s", fup->GetType(), fup->fileName());
- if (!IsOnline()) {
- SendFileFiled(fup, VKERR_OFFLINE);
- return;
- }
- if (!fup->IsAccess()) {
- SendFileFiled(fup, VKERR_FILE_NOT_EXIST);
- return;
- }
-
- ProtoBroadcastAck(fup->hContact, ACKTYPE_FILE, ACKRESULT_INITIALISING, (HANDLE)fup);
-
- AsyncHttpRequest *pReq;
- switch (fup->GetType()) {
- case CVkFileUploadParam::typeImg:
- pReq = new AsyncHttpRequest(this, REQUEST_GET, "/method/photos.getMessagesUploadServer.json", true, &CVkProto::OnReciveUploadServer);
- break;
- case CVkFileUploadParam::typeAudio:
- pReq = new AsyncHttpRequest(this, REQUEST_GET, "/method/audio.getUploadServer.json", true, &CVkProto::OnReciveUploadServer);
- break;
- case CVkFileUploadParam::typeDoc:
- pReq = new AsyncHttpRequest(this, REQUEST_GET, "/method/docs.getUploadServer.json", true, &CVkProto::OnReciveUploadServer);
- break;
- default:
- SendFileFiled(fup, VKERR_FTYPE_NOT_SUPPORTED);
- return;
- }
- pReq->pUserInfo = p;
- Push(pReq);
-}
void CVkProto::OnReciveUploadServer(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
{
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index 9845c1487f..2213a6ff6c 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -255,7 +255,6 @@ private: //==== Files Upload ==================================================================
- void __cdecl SendFileThread(void *p);
void SendFileFiled(CVkFileUploadParam *fup, int ErrorCode);
void OnReciveUploadServer(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
void OnReciveUpload(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
|