summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElzorFox <elzorfox@ya.ru>2018-04-06 15:07:47 +0500
committerElzorFox <elzorfox@ya.ru>2018-04-06 15:07:47 +0500
commitf740ad4b8b46887219b7487f02df29d83e5773fc (patch)
tree6a640c50134db4038149e0cf1b5a0d88bdcae750
parentb87e5b22328c98ea82146c0ea6f724d7275f0c32 (diff)
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
-rw-r--r--protocols/VKontakte/src/misc.cpp21
-rw-r--r--protocols/VKontakte/src/version.h2
-rw-r--r--protocols/VKontakte/src/vk.h2
-rw-r--r--protocols/VKontakte/src/vk_chats.cpp4
-rw-r--r--protocols/VKontakte/src/vk_proto.cpp6
-rw-r--r--protocols/VKontakte/src/vk_struct.cpp2
-rw-r--r--protocols/VKontakte/src/vk_struct.h2
-rw-r--r--protocols/VKontakte/src/vk_thread.cpp2
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 <stdver.h>
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 <http://www.gnu.org/licenses/>.
#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<BYTE> bSendVKLinksAsAttachments;
CMOption<BYTE> bLoadSentAttachments;
CMOption<BYTE> bShowVkDeactivateEvents;
+ CMOption<BYTE> bStickerBackground;
CMOption<BYTE> bShowProtoMenuItem0;
CMOption<BYTE> bShowProtoMenuItem1;
@@ -324,6 +325,7 @@ struct CVKOptions {
CMOption<DWORD> iNewsAutoClearHistoryInterval;
CMOption<DWORD> iInvisibleInterval;
CMOption<DWORD> iMaxFriendsCount;
+ CMOption<DWORD> iStickerSize;
CMOption<wchar_t*> pwszDefaultGroup;
CMOption<wchar_t*> 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);