summaryrefslogtreecommitdiff
path: root/protocols/VKontakte/src/vk_proto.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-12-09 17:41:17 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-12-09 17:41:17 +0000
commit8ffc24f829fa99cc1c089193aa4b1e67e4f69dfd (patch)
tree38519dc251389923a1716ecf118b2d8172bcf464 /protocols/VKontakte/src/vk_proto.cpp
parentf73390e506d9a67fe4026221816f02fb1bf6234d (diff)
VKontakte:
- option added to support server message delivery confirmations; - separate dialog procedure for options; - version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@7110 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte/src/vk_proto.cpp')
-rw-r--r--protocols/VKontakte/src/vk_proto.cpp29
1 files changed, 21 insertions, 8 deletions
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp
index 12f160d169..1ca293af8f 100644
--- a/protocols/VKontakte/src/vk_proto.cpp
+++ b/protocols/VKontakte/src/vk_proto.cpp
@@ -49,6 +49,8 @@ CVkProto::CVkProto(const char *szModuleName, const TCHAR *ptszUserName) :
db_set_resident(m_szModuleName, "Status");
+ m_bServerDelivery = getBool("ServerDelivery", true);
+
// Set all contacts offline -- in case we crashed
SetAllContactStatuses(ID_STATUS_OFFLINE);
}
@@ -153,23 +155,34 @@ int CVkProto::SendMsg(HANDLE hContact, int flags, const char *msg)
{ "message", szMsg },
{ "access_token", m_szAccessToken }
};
- PushAsyncHttpRequest(REQUEST_GET, "/method/messages.send.json", true, &CVkProto::OnSendMessage, SIZEOF(params), params);
ULONG msgId = ::InterlockedIncrement(&m_msgId);
- ForkThread(&CVkProto::SendMsgAck, new TFakeAckParams(hContact, msgId));
+ AsyncHttpRequest *pReq = PushAsyncHttpRequest(REQUEST_GET, "/method/messages.send.json", true, &CVkProto::OnSendMessage, SIZEOF(params), params);
+ pReq->pData = (char*)hContact;
+ pReq->pUserInfo = (void*)msgId;
+
+ if (!m_bServerDelivery)
+ ForkThread(&CVkProto::SendMsgAck, new TFakeAckParams(hContact, msgId));
return msgId;
}
void CVkProto::OnSendMessage(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
{
+ int iResult = ACKRESULT_FAILED;
+
debugLogA("CVkProto::OnSendMessage %d", reply->resultCode);
- if (reply->resultCode != 200)
- return;
+ if (reply->resultCode == 200) {
+ JSONROOT pRoot;
+ JSONNODE *pResponse = CheckJsonResponse(pReq, reply, pRoot);
+ if (pResponse != NULL) {
+ m_sendIds.insert((HANDLE)json_as_int(pResponse));
+ iResult = ACKRESULT_SUCCESS;
+ }
+ }
- JSONROOT pRoot;
- JSONNODE *pResponse = CheckJsonResponse(pReq, reply, pRoot);
- if (pResponse != NULL)
- m_sendIds.insert((HANDLE)json_as_int(pResponse));
+ if (m_bServerDelivery)
+ ProtoBroadcastAck(pReq->pData, ACKTYPE_MESSAGE, iResult, pReq->pUserInfo, 0);
+ pReq->pData = NULL;
}
//////////////////////////////////////////////////////////////////////////////