From 57fb5a039ebb74fd276d7bd0224406f29f9d18b9 Mon Sep 17 00:00:00 2001 From: Sergey Bolhovskoy Date: Tue, 8 Sep 2015 04:22:07 +0000 Subject: VKontakte: PF4_GROUPCHATFILES support version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@15304 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/VKontakte/src/version.h | 2 +- protocols/VKontakte/src/vk_chats.cpp | 11 +++++++++ protocols/VKontakte/src/vk_files.cpp | 46 +++++++++++++++++++++++++++--------- protocols/VKontakte/src/vk_proto.cpp | 2 +- 4 files changed, 48 insertions(+), 13 deletions(-) diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h index 590fb86f7c..e9fb9515a4 100644 --- a/protocols/VKontakte/src/version.h +++ b/protocols/VKontakte/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 1 #define __RELEASE_NUM 1 -#define __BUILD_NUM 14 +#define __BUILD_NUM 15 #include diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp index 1d3c56d273..d5b58469e2 100644 --- a/protocols/VKontakte/src/vk_chats.cpp +++ b/protocols/VKontakte/src/vk_chats.cpp @@ -527,9 +527,20 @@ int CVkProto::OnChatEvent(WPARAM, LPARAM lParam) void CVkProto::OnSendChatMsg(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) { debugLogA("CVkProto::OnSendChatMsg %d", reply->resultCode); + int iResult = ACKRESULT_FAILED; if (reply->resultCode == 200) { JSONNode jnRoot; CheckJsonResponse(pReq, reply, jnRoot); + iResult = ACKRESULT_SUCCESS; + } + if (!pReq->pUserInfo) + return; + + CVkFileUploadParam *fup = (CVkFileUploadParam *)pReq->pUserInfo; + ProtoBroadcastAck(fup->hContact, ACKTYPE_FILE, iResult, (HANDLE)(fup)); + if (!pReq->bNeedsRestart || m_bTerminated) { + delete fup; + pReq->pUserInfo = NULL; } } diff --git a/protocols/VKontakte/src/vk_files.cpp b/protocols/VKontakte/src/vk_files.cpp index 932841f050..2423899ddb 100644 --- a/protocols/VKontakte/src/vk_files.cpp +++ b/protocols/VKontakte/src/vk_files.cpp @@ -20,8 +20,9 @@ along with this program. If not, see . HANDLE CVkProto::SendFile(MCONTACT hContact, const TCHAR *desc, TCHAR **files) { debugLogA("CVkProto::SendFile"); + isChatRoom(hContact); LONG userID = getDword(hContact, "ID", -1); - if (!IsOnline() || userID == -1 || userID == VK_FEED_USER) + if (!IsOnline() || ((userID == -1 || userID == VK_FEED_USER) && !isChatRoom(hContact))) return (HANDLE)0; CVkFileUploadParam *fup = new CVkFileUploadParam(hContact, desc, files); @@ -352,20 +353,43 @@ void CVkProto::OnReciveUploadFile(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pR SendFileFiled(fup, VKERR_FTYPE_NOT_SUPPORTED); return; } + + AsyncHttpRequest *pMsgReq; - LONG userID = getDword(fup->hContact, "ID", -1); - if (userID == -1 || userID == VK_FEED_USER) { - SendFileFiled(fup, VKERR_INVALID_USER); - return; + if (isChatRoom(fup->hContact)) { + + ptrT tszChatID(getTStringA(fup->hContact, "ChatRoomID")); + if (!tszChatID) { + SendFileFiled(fup, VKERR_INVALID_USER); + return; + } + + CVkChatInfo *cc = GetChatById(tszChatID); + if (cc == NULL) { + SendFileFiled(fup, VKERR_INVALID_USER); + return; + } + + pMsgReq = new AsyncHttpRequest(this, REQUEST_POST, "/method/messages.send.json", true, &CVkProto::OnSendChatMsg, AsyncHttpRequest::rpHigh) + << INT_PARAM("chat_id", cc->m_chatid); + pMsgReq->pUserInfo = pReq->pUserInfo; + + } + else { + LONG userID = getDword(fup->hContact, "ID", -1); + if (userID == -1 || userID == VK_FEED_USER) { + SendFileFiled(fup, VKERR_INVALID_USER); + return; + } + + pMsgReq = new AsyncHttpRequest(this, REQUEST_POST, "/method/messages.send.json", true, &CVkProto::OnSendMessage, AsyncHttpRequest::rpHigh) + << INT_PARAM("user_id", userID); + pMsgReq->pUserInfo = new CVkSendMsgParam(fup->hContact, fup); + } - AsyncHttpRequest *pMsgReq = new AsyncHttpRequest(this, REQUEST_POST, "/method/messages.send.json", true, &CVkProto::OnSendMessage, AsyncHttpRequest::rpHigh) - << INT_PARAM("user_id", userID) - << TCHAR_PARAM("message", fup->Desc) - << TCHAR_PARAM("attachment", Attachment) - << VER_API; + pMsgReq << TCHAR_PARAM("message", fup->Desc) << TCHAR_PARAM("attachment", Attachment) << VER_API; pMsgReq->AddHeader("Content-Type", "application/x-www-form-urlencoded"); - pMsgReq->pUserInfo = new CVkSendMsgParam(fup->hContact, fup); Push(pMsgReq); } \ No newline at end of file diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index d334c71cbc..c0ea47c99c 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -468,7 +468,7 @@ DWORD_PTR CVkProto::GetCaps(int type, MCONTACT) return PF2_ONLINE; case PFLAGNUM_4: - return PF4_AVATARS | PF4_SUPPORTTYPING | PF4_NOAUTHDENYREASON | PF4_IMSENDOFFLINE | PF4_OFFLINEFILES | PF4_READNOTIFY; + return PF4_AVATARS | PF4_SUPPORTTYPING | PF4_NOAUTHDENYREASON | PF4_IMSENDOFFLINE | PF4_OFFLINEFILES | PF4_READNOTIFY | PF4_GROUPCHATFILES; case PFLAGNUM_5: return PF2_ONTHEPHONE; -- cgit v1.2.3