diff options
author | Sergey Bolhovskoy <elzorfox@ya.ru> | 2014-10-14 08:28:52 +0000 |
---|---|---|
committer | Sergey Bolhovskoy <elzorfox@ya.ru> | 2014-10-14 08:28:52 +0000 |
commit | dc1aa5930ea3ef174f1e47385e301c2415bea259 (patch) | |
tree | 8be84ab91b85ac3a3ce000c1261270bbd68df9be /protocols | |
parent | 840091c772b27f97043bede8ee6416cb6c157f0d (diff) |
VKontakte:
sticker support part 2 (sending stickers) – complete
git-svn-id: http://svn.miranda-ng.org/main/trunk@10779 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/VKontakte/src/misc.cpp | 17 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.cpp | 16 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.h | 1 |
3 files changed, 33 insertions, 1 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index e5f3b42194..8c15e75c20 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -545,4 +545,21 @@ void CVkProto::SetSrmmReadStatus(MCONTACT hContact) st.hIcon = Skin_GetIconByHandle(GetIconHandle(IDI_READMSG)); mir_sntprintf(st.tszText, SIZEOF(st.tszText), TranslateT("Message read: %s"), ttime); CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)hContact, (LPARAM)&st);
+}
+
+char* CVkProto::GetStickerId (const char* Msg, int &stickerid)
+{
+ int iRes = 0;
+ char HeadMsg[32] = { 0 };
+ char* retMsg = NULL;
+ iRes = sscanf(Msg, "[sticker:%d]", &stickerid);
+ if (iRes == 1){
+ mir_snprintf(HeadMsg, 32, "[sticker:%d]", stickerid);
+ int retLen = strlen(HeadMsg);
+ if (retLen<strlen(Msg))
+ retMsg = mir_strdup(&Msg[retLen]);
+ return retMsg;
+ }
+ stickerid = 0;
+ return NULL;
}
\ No newline at end of file diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index 47edff6722..5270c99f2e 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -343,17 +343,31 @@ int CVkProto::SendMsg(MCONTACT hContact, int flags, const char *msg) else
szMsg = mir_utf8encode(msg);
+ int StickerId = 0;
+ ptrA retMsg(GetStickerId(szMsg, StickerId));
+
ULONG msgId = ::InterlockedIncrement(&m_msgId);
AsyncHttpRequest *pReq = new AsyncHttpRequest(this, REQUEST_POST, "/method/messages.send.json", true, &CVkProto::OnSendMessage)
<< INT_PARAM("user_id", userID)
- << CHAR_PARAM("message", szMsg)
<< VER_API;
+
+ if (StickerId != 0)
+ pReq << INT_PARAM("sticker_id", StickerId);
+ else
+ pReq << CHAR_PARAM("message", szMsg);
+
pReq->AddHeader("Content-Type", "application/x-www-form-urlencoded");
pReq->pUserInfo = new CVkSendMsgParam(hContact, msgId);
Push(pReq);
if (!m_bServerDelivery)
ForkThread(&CVkProto::SendMsgAck, new TFakeAckParams(hContact, msgId));
+
+ if (retMsg){
+ int _flags = flags | PREF_UTF;
+ Sleep(330);
+ SendMsg(hContact, _flags, retMsg);
+ }
return msgId;
}
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index df52642791..8659df0a07 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -322,6 +322,7 @@ struct CVkProto : public PROTO<CVkProto> void SetMirVer(MCONTACT hContact, int platform);
void SetSrmmReadStatus(MCONTACT hContact);
void __cdecl ContactTypingThread(void *p);
+ char* GetStickerId(const char* Msg, int& stickerid);
static UINT_PTR m_timer;
|