summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-08-22 14:09:51 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-08-22 14:09:51 +0000
commit2234bcb0625bd4bb337b2fd08bfab0c10096b34e (patch)
treeffd5fa87aeecab87eb1d69a6693660e698566e36 /protocols
parent666032969fb65ccdea9fdbc85c43eadcb7ef754e (diff)
VK:
- nasty clutch to replace <br> with CRLF; - fix for sending long messages (patch by Elzor, edited); - version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@10294 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r--protocols/VKontakte/src/version.h2
-rw-r--r--protocols/VKontakte/src/vk_proto.cpp21
-rw-r--r--protocols/VKontakte/src/vk_proto.h11
-rw-r--r--protocols/VKontakte/src/vk_thread.cpp6
4 files changed, 30 insertions, 10 deletions
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h
index 8c62208741..d27d6162d7 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 0
-#define __BUILD_NUM 10
+#define __BUILD_NUM 11
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp
index 05a95e68b8..9adce546a5 100644
--- a/protocols/VKontakte/src/vk_proto.cpp
+++ b/protocols/VKontakte/src/vk_proto.cpp
@@ -171,15 +171,19 @@ int CVkProto::SendMsg(MCONTACT hContact, int flags, const char *msg)
if (flags & PREF_UTF)
szMsg = mir_strdup(msg);
else if (flags & PREF_UNICODE)
- msg = mir_utf8encodeW((wchar_t*)&msg[strlen(msg)+1]);
+ szMsg = mir_utf8encodeW((wchar_t*)&msg[strlen(msg)+1]);
else
- msg = mir_utf8encode(msg);
+ szMsg = mir_utf8encode(msg);
ULONG msgId = ::InterlockedIncrement(&m_msgId);
- AsyncHttpRequest *pReq = new AsyncHttpRequest(this, REQUEST_GET, "/method/messages.send.json", true, &CVkProto::OnSendMessage)
- << INT_PARAM("type", 0) << INT_PARAM("uid", userID) << CHAR_PARAM("message", msg);
- pReq->pData = (char*)hContact;
- pReq->pUserInfo = (void*)msgId;
+ AsyncHttpRequest *pReq = new AsyncHttpRequest(this, REQUEST_POST, "/method/messages.send.json", true, &CVkProto::OnSendMessage)
+ << INT_PARAM("type", 0) << INT_PARAM("uid", userID);
+ pReq->AddHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
+
+ CMStringA szBody(FORMAT, "message=%s", szMsg);
+ pReq->pData = mir_strdup(szBody);
+ pReq->dataLength = szBody.GetLength();
+ pReq->pUserInfo = new CVkSendMsgParam(hContact, msgId);
Push(pReq);
if (!m_bServerDelivery)
@@ -190,6 +194,7 @@ int CVkProto::SendMsg(MCONTACT hContact, int flags, const char *msg)
void CVkProto::OnSendMessage(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
{
int iResult = ACKRESULT_FAILED;
+ CVkSendMsgParam *param = (CVkSendMsgParam*)pReq->pUserInfo;
debugLogA("CVkProto::OnSendMessage %d", reply->resultCode);
if (reply->resultCode == 200) {
@@ -202,8 +207,8 @@ void CVkProto::OnSendMessage(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
}
if (m_bServerDelivery)
- ProtoBroadcastAck((MCONTACT)pReq->pData, ACKTYPE_MESSAGE, iResult, pReq->pUserInfo, 0);
- pReq->pData = NULL;
+ ProtoBroadcastAck(param->hContact, ACKTYPE_MESSAGE, iResult, HANDLE(param->iMsgID), 0);
+ delete param;
}
//////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h
index 8c06d8ee84..2ecdd0001b 100644
--- a/protocols/VKontakte/src/vk_proto.h
+++ b/protocols/VKontakte/src/vk_proto.h
@@ -71,6 +71,17 @@ struct TCHAR_PARAM : public PARAM
};
AsyncHttpRequest* operator<<(AsyncHttpRequest*, const TCHAR_PARAM&);
+struct CVkSendMsgParam
+{
+ CVkSendMsgParam(MCONTACT _p1, int _p2) :
+ hContact(_p1),
+ iMsgID(_p2)
+ {}
+
+ MCONTACT hContact;
+ int iMsgID;
+};
+
struct CVkChatMessage : public MZeroedObject
{
CVkChatMessage(int _id) : m_mid(_id) {}
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp
index ccb2c5e2fb..ebf5929b7a 100644
--- a/protocols/VKontakte/src/vk_thread.cpp
+++ b/protocols/VKontakte/src/vk_thread.cpp
@@ -477,7 +477,11 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
if (isOut)
recv.flags |= PREF_SENT;
recv.timestamp = datetime;
- recv.tszMessage = ptszBody;
+
+ CMStringW szBody = ptszBody;
+ szBody.Replace(_T("<br>"),_T("\n"));
+ recv.tszMessage = (TCHAR *) szBody.c_str();
+
recv.lParam = isOut;
recv.pCustomData = szMid;
recv.cbCustomDataSize = (int)strlen(szMid);