From 48266e479d1fcf5153b29c612866845990fccad8 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 21 May 2015 16:11:58 +0000 Subject: war against atavisms continues - everything that goes to PSS_MESSAGE should be sent as utf8 string; - thus PREF_UNICODE & PREF_UTF support discontinued, these constants are removed; - support for PREF_UNICODE & PREF_UTF in protocols also removed; - PREF_UNICODE used in file transfers (PROTOFILERECVT) replaced with PRFF_UNICODE / PRFF_TCHAR git-svn-id: http://svn.miranda-ng.org/main/trunk@13734 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/VKontakte/src/vk_feed.cpp | 8 +++----- protocols/VKontakte/src/vk_history.cpp | 5 +++-- protocols/VKontakte/src/vk_messages.cpp | 18 +++++------------- protocols/VKontakte/src/vk_proto.cpp | 2 +- protocols/VKontakte/src/vk_proto.h | 2 +- 5 files changed, 13 insertions(+), 22 deletions(-) (limited to 'protocols/VKontakte/src') diff --git a/protocols/VKontakte/src/vk_feed.cpp b/protocols/VKontakte/src/vk_feed.cpp index 78d1d71d04..cd84677cc8 100644 --- a/protocols/VKontakte/src/vk_feed.cpp +++ b/protocols/VKontakte/src/vk_feed.cpp @@ -54,16 +54,14 @@ void CVkProto::AddFeedEvent(CMString& tszBody, time_t tTime) } MCONTACT hContact = FindUser(VK_FEED_USER, true); - ptrT ptszBody(mir_tstrdup(tszBody.GetBuffer())); - PROTORECVEVENT recv = { 0 }; + ptrA pszBody(mir_utf8encodeT(tszBody)); - recv.flags = PREF_TCHAR; + PROTORECVEVENT recv = { 0 }; recv.timestamp = tTime; - recv.tszMessage = ptszBody; + recv.szMessage = pszBody; recv.lParam = 0; recv.pCustomData = NULL; recv.cbCustomDataSize = 0; - ProtoChainRecvMsg(hContact, &recv); } diff --git a/protocols/VKontakte/src/vk_history.cpp b/protocols/VKontakte/src/vk_history.cpp index fdca4b00db..fb10ae9c05 100644 --- a/protocols/VKontakte/src/vk_history.cpp +++ b/protocols/VKontakte/src/vk_history.cpp @@ -218,18 +218,19 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque MCONTACT hContact = FindUser(uid, true); PROTORECVEVENT recv = { 0 }; - recv.flags = PREF_TCHAR; if (isRead) recv.flags |= PREF_CREATEREAD; if (isOut) recv.flags |= PREF_SENT; recv.timestamp = datetime; - recv.tszMessage = ptszBody; + recv.szMessage = mir_utf8encodeT(ptszBody); recv.lParam = isOut; recv.pCustomData = szMid; recv.cbCustomDataSize = (int)mir_strlen(szMid); ProtoChainRecvMsg(hContact, &recv); + count++; + mir_free((char*)recv.szMessage); } setDword(param->hContact, "lastmsgid", iLastMsgId); diff --git a/protocols/VKontakte/src/vk_messages.cpp b/protocols/VKontakte/src/vk_messages.cpp index 57f25817af..6a9d6825ed 100644 --- a/protocols/VKontakte/src/vk_messages.cpp +++ b/protocols/VKontakte/src/vk_messages.cpp @@ -37,7 +37,7 @@ void CVkProto::SendMsgAck(void *param) delete ack; } -int CVkProto::SendMsg(MCONTACT hContact, int flags, const char *msg) +int CVkProto::SendMsg(MCONTACT hContact, int, const char *szMsg) { debugLogA("CVkProto::SendMsg"); if (!IsOnline()) @@ -48,14 +48,6 @@ int CVkProto::SendMsg(MCONTACT hContact, int flags, const char *msg) return 0; } - ptrA szMsg; - if (flags & PREF_UTF) - szMsg = mir_strdup(msg); - else if (flags & PREF_UNICODE) - szMsg = mir_utf8encodeW((wchar_t*)&msg[mir_strlen(msg) + 1]); - else - szMsg = mir_utf8encode(msg); - int StickerId = 0; ptrA retMsg(GetStickerId(szMsg, StickerId)); @@ -77,9 +69,8 @@ int CVkProto::SendMsg(MCONTACT hContact, int flags, const char *msg) ForkThread(&CVkProto::SendMsgAck, new TFakeAckParams(hContact, msgId)); if (retMsg) { - int _flags = flags | PREF_UTF; Sleep(330); - SendMsg(hContact, _flags, retMsg); + SendMsg(hContact, 0, retMsg); } return msgId; } @@ -255,7 +246,6 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe } PROTORECVEVENT recv = { 0 }; - recv.flags = PREF_TCHAR; if (isRead && !m_bMesAsUnread) recv.flags |= PREF_CREATEREAD; if (isOut) @@ -264,7 +254,7 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe SetInvisible(hContact); recv.timestamp = m_bUseLocalTime ? time(NULL) : datetime; - recv.tszMessage = ptszBody; + recv.szMessage = mir_utf8encodeT(ptszBody); recv.lParam = isOut; recv.pCustomData = szMid; recv.cbCustomDataSize = (int)mir_strlen(szMid); @@ -280,6 +270,8 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe if (!isOut) m_incIds.insert((HANDLE)mid); } + + mir_free((char*)recv.szMessage); } if (!mids.IsEmpty()) diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index d5649f806d..bc6198c5b5 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -461,7 +461,7 @@ DWORD_PTR CVkProto::GetCaps(int type, MCONTACT) return PF2_ONLINE; case PFLAGNUM_4: - return PF4_IMSENDUTF | PF4_AVATARS | PF4_SUPPORTTYPING | PF4_NOAUTHDENYREASON | PF4_IMSENDOFFLINE | PF4_OFFLINEFILES; + return PF4_AVATARS | PF4_SUPPORTTYPING | PF4_NOAUTHDENYREASON | PF4_IMSENDOFFLINE | PF4_OFFLINEFILES; case PFLAGNUM_5: return PF2_ONTHEPHONE; diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index a00a08466e..0468fd7802 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -268,7 +268,7 @@ struct CVkProto : public PROTO virtual HANDLE __cdecl SearchByName(const TCHAR *nick, const TCHAR *firstName, const TCHAR *lastName); virtual int __cdecl RecvMsg(MCONTACT hContact, PROTORECVEVENT*); - virtual int __cdecl SendMsg(MCONTACT hContact, int flags, const char* msg); + virtual int __cdecl SendMsg(MCONTACT hContact, int flags, const char *msg); virtual HANDLE __cdecl SendFile(MCONTACT hContact, const TCHAR *szDescription, TCHAR **ppszFiles); -- cgit v1.2.3