From f740ad4b8b46887219b7487f02df29d83e5773fc Mon Sep 17 00:00:00 2001 From: ElzorFox Date: Fri, 6 Apr 2018 15:07:47 +0500 Subject: VKontakte: update VK_API to 5.74 add hidden option StickerSize (DWORD, default 128) add hidden option StickerBackground (BYTE, default false) add chat action pin/unpin message (no text pinned message from api) version bump --- protocols/VKontakte/src/misc.cpp | 21 +++++++++++++-------- protocols/VKontakte/src/version.h | 2 +- protocols/VKontakte/src/vk.h | 2 +- protocols/VKontakte/src/vk_chats.cpp | 4 ++++ protocols/VKontakte/src/vk_proto.cpp | 6 +++--- protocols/VKontakte/src/vk_struct.cpp | 2 ++ protocols/VKontakte/src/vk_struct.h | 2 ++ protocols/VKontakte/src/vk_thread.cpp | 2 +- 8 files changed, 27 insertions(+), 14 deletions(-) diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index 959fe799fe..2f3aeca9c7 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -1172,23 +1172,28 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport res.Empty(); // sticker is not really an attachment, so we don't want all that heading info if (m_vkOptions.bStikersAsSmyles) { - int id = jnSticker["id"].as_int(); + int id = jnSticker["sticker_id"].as_int(); res.AppendFormat(L"[sticker:%d]", id); } else { - CMStringW wszLink; - for (auto &it : szImageTypes) { - const JSONNode &n = jnSticker[it]; - if (n) { - wszLink = n.as_mstring(); + CMStringW wszLink, wszLink128, wszLinkLast; + const JSONNode &jnImages = jnSticker[m_vkOptions.bStickerBackground ? "images_with_background" : "images"]; + for (auto & jnImage : jnImages) { + if (jnImage["width"].as_int() == (int) m_vkOptions.iStickerSize) { + wszLink = jnImage["url"].as_mstring(); break; } + + if (jnImage["width"].as_int() == 128) // default size + wszLink128 = jnImage["url"].as_mstring(); + + wszLinkLast = jnImage["url"].as_mstring(); } - res.AppendFormat(L"%s", wszLink.c_str()); if (m_vkOptions.iIMGBBCSupport && iBBC != bbcNo) - res += SetBBCString(wszLink, iBBC, vkbbcImg); + res += SetBBCString(wszLink.IsEmpty() ? (wszLink128.IsEmpty() ? wszLinkLast : wszLink128) : wszLink, iBBC, vkbbcImg); } + } else if (wszType == L"link") { const JSONNode &jnLink = jnAttach["link"]; diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h index 373caf19ac..2e72242b00 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 4 -#define __BUILD_NUM 4 +#define __BUILD_NUM 5 #include diff --git a/protocols/VKontakte/src/vk.h b/protocols/VKontakte/src/vk.h index 6dd88d8528..4fd3060912 100644 --- a/protocols/VKontakte/src/vk.h +++ b/protocols/VKontakte/src/vk.h @@ -88,7 +88,7 @@ along with this program. If not, see . #define VK_USER_DEACTIVATE_ACTION 9321 -#define VK_API_VER "5.73" +#define VK_API_VER "5.74" #define VER_API CHAR_PARAM("v", VK_API_VER) #define VK_FEED_USER 2147483647L diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp index 55460df3d5..08d89269d6 100644 --- a/protocols/VKontakte/src/vk_chats.cpp +++ b/protocols/VKontakte/src/vk_chats.cpp @@ -348,6 +348,10 @@ void CVkProto::AppendChatMessage(int id, const JSONNode &jnMsg, const JSONNode & if (!bIsHistory) SetChatTitle(cc, wszTitle); } + else if (wszAction == L"chat_pin_message") + wszBody = TranslateT("pin message"); + else if (wszAction == L"chat_unpin_message") + wszBody = TranslateT("unpin message"); else if (wszAction == L"chat_photo_update") wszBody.Replace(TranslateT("Attachments:"), TranslateT("changed chat cover:")); else if (wszAction == L"chat_photo_remove") diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index 8838d98b94..0253c96d6d 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -110,17 +110,17 @@ int CVkProto::OnModulesLoaded(WPARAM, LPARAM) gcr.ptszDispName = m_tszUserName; gcr.pszModule = m_szModuleName; Chat_Register(&gcr); - + CreateProtoService(PS_LEAVECHAT, &CVkProto::OnLeaveChat); CreateProtoService(PS_JOINCHAT, &CVkProto::OnJoinChat); HookProtoEvent(ME_GC_EVENT, &CVkProto::OnChatEvent); HookProtoEvent(ME_GC_BUILDMENU, &CVkProto::OnGcMenuHook); - + // Other hooks HookProtoEvent(ME_MSG_WINDOWEVENT, &CVkProto::OnProcessSrmmEvent); HookProtoEvent(ME_DB_EVENT_MARKED_READ, &CVkProto::OnDbEventRead); HookProtoEvent(ME_DB_CONTACT_SETTINGCHANGED, &CVkProto::OnDbSettingChanged); - + //Sounds Skin_AddSound("VKNewsFeed", m_tszUserName, LPGENW("VKontakte newsfeed & notification event")); diff --git a/protocols/VKontakte/src/vk_struct.cpp b/protocols/VKontakte/src/vk_struct.cpp index 6b8838d1d9..4f7a58001a 100644 --- a/protocols/VKontakte/src/vk_struct.cpp +++ b/protocols/VKontakte/src/vk_struct.cpp @@ -215,6 +215,7 @@ CVKOptions::CVKOptions(PROTO_INTERFACE *proto) : bSyncReadMessageStatusFromServer(proto, "SyncReadMessageStatusFromServer", false), bLoadFullCList(proto, "LoadFullCList", false), bShowVkDeactivateEvents(proto, "ShowVkDeactivateEvents", true), + bStickerBackground(proto, "StickerBackground", false), bShowProtoMenuItem0(proto, "ShowProtoMenuItem0", true), bShowProtoMenuItem1(proto, "ShowProtoMenuItem1", true), @@ -236,6 +237,7 @@ CVKOptions::CVKOptions(PROTO_INTERFACE *proto) : iNewsAutoClearHistoryInterval(proto, "NewsAutoClearHistoryInterval", 60 * 60 * 24 * 3), iInvisibleInterval(proto, "InvisibleInterval", 10), iMaxFriendsCount(proto, "MaxFriendsCount", 1000), + iStickerSize(proto, "StickerSize", 128), pwszDefaultGroup(proto, "ProtoGroup", L"VKontakte"), pwszReturnChatMessage(proto, "ReturnChatMessage", TranslateT("I'm back")), diff --git a/protocols/VKontakte/src/vk_struct.h b/protocols/VKontakte/src/vk_struct.h index 487c9a59e3..ad359cc992 100644 --- a/protocols/VKontakte/src/vk_struct.h +++ b/protocols/VKontakte/src/vk_struct.h @@ -310,6 +310,7 @@ struct CVKOptions { CMOption bSendVKLinksAsAttachments; CMOption bLoadSentAttachments; CMOption bShowVkDeactivateEvents; + CMOption bStickerBackground; CMOption bShowProtoMenuItem0; CMOption bShowProtoMenuItem1; @@ -324,6 +325,7 @@ struct CVKOptions { CMOption iNewsAutoClearHistoryInterval; CMOption iInvisibleInterval; CMOption iMaxFriendsCount; + CMOption iStickerSize; CMOption pwszDefaultGroup; CMOption pwszReturnChatMessage; diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index 0a4d0aa464..dc434c5606 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -645,7 +645,7 @@ void CVkProto::OnReceiveUserInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe LONG userid = it.as_int(); if (userid == 0) break; - + MCONTACT hContact = FindUser(userid, true); if (!getBool(hContact, "ReqAuth")) { RetrieveUserInfo(userid); -- cgit v1.2.3