summaryrefslogtreecommitdiff
path: root/protocols/VKontakte/src
diff options
context:
space:
mode:
authorElzorFox <elzorfox@ya.ru>2024-04-18 11:53:05 +0500
committerElzorFox <elzorfox@ya.ru>2024-04-18 11:53:05 +0500
commitad5fadc258cf79991721ac2a6b8266412703bd78 (patch)
tree17ae5239a6f0fd113cdd6b87ee4b39bf5f0c8868 /protocols/VKontakte/src
parent366b12a36bf052025bce085d2859486e0318231c (diff)
VKontakte:
add [code] bbc for NewStory formatting style add loading preview image for attached videos fix loading images without ‘?’ in url version bump
Diffstat (limited to 'protocols/VKontakte/src')
-rw-r--r--protocols/VKontakte/src/misc.cpp31
-rw-r--r--protocols/VKontakte/src/version.h2
-rw-r--r--protocols/VKontakte/src/vk_files.cpp10
-rw-r--r--protocols/VKontakte/src/vk_proto.h1
4 files changed, 38 insertions, 6 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
index a032ba71a1..64845d352f 100644
--- a/protocols/VKontakte/src/misc.cpp
+++ b/protocols/VKontakte/src/misc.cpp
@@ -1170,6 +1170,29 @@ CMStringW CVkProto::GetVkPhotoItem(const JSONNode &jnPhoto, BBCSupport iBBC, MCO
return wszRes;
}
+CMStringW CVkProto::GetVkPhotoForVideoItem(const JSONNode& Images, MCONTACT hContact, VKMessageID_t iMessageId)
+{
+ CMStringW wszRes;
+
+ if (!Images || !m_vkOptions.bBBCNewStorySupport)
+ return wszRes;
+
+ int iMaxSize = 0;
+
+ for (auto& it : Images) {
+ int iSize = it["width"].as_int();
+ if (iMaxSize < iSize)
+ wszRes = it["url"].as_mstring();
+
+ if (iMaxSize > 300)
+ break;
+ }
+
+ wszRes = GetVkFileItem(wszRes, hContact, iMessageId);
+ return wszRes.IsEmpty() ? wszRes : SetBBCString(wszRes, bbcAdvanced, vkbbcImg, wszRes);
+}
+
+
CMStringW CVkProto::SetBBCString(LPCWSTR pwszString, BBCSupport iBBC, VKBBCType bbcType, LPCWSTR wszAddString)
{
CVKBBCItem bbcItem[] = {
@@ -1187,7 +1210,7 @@ CMStringW CVkProto::SetBBCString(LPCWSTR pwszString, BBCSupport iBBC, VKBBCType
{ vkbbcU, bbcAdvanced, L"[u]%s[/u]" },
{ vkbbcCode, bbcNo, L"%s" },
{ vkbbcCode, bbcBasic, L"%s" },
- { vkbbcCode, bbcAdvanced, m_vkOptions.bBBCNewStorySupport ? L"%s" : L"[code]%s[/code]"},
+ { vkbbcCode, bbcAdvanced, L"[code]%s[/code]"},
{ vkbbcImg, bbcNo, L"%s" },
{ vkbbcImg, bbcBasic, L"[img]%s[/img]" },
{ vkbbcImg, bbcAdvanced, L"[img]%s[/img]" },
@@ -1324,6 +1347,12 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport
VKUserID_t iOwnerId = jnVideo["owner_id"].as_int();
CMStringW wszUrl(FORMAT, L"https://vk.com/video%d_%d", iOwnerId, iVideoId);
+ if (jnVideo["image"]) {
+ CMStringW wszPreviewImage = GetVkPhotoForVideoItem(jnVideo["image"], hContact, iMessageId);
+ if (!wszPreviewImage.IsEmpty())
+ res.AppendFormat(L"%s\n", wszPreviewImage.c_str());
+ }
+
res.AppendFormat(L"%s: %s",
SetBBCString(TranslateT("Video"), iBBC, vkbbcB).c_str(),
SetBBCString(wszTitle.IsEmpty() ? TranslateT("Link") : wszTitle, iBBC, vkbbcUrl, wszUrl).c_str());
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h
index 6d40a99daf..28f3eb1c43 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 16
-#define __BUILD_NUM 4
+#define __BUILD_NUM 5
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk_files.cpp b/protocols/VKontakte/src/vk_files.cpp
index 441d5ecf90..c742ec78cd 100644
--- a/protocols/VKontakte/src/vk_files.cpp
+++ b/protocols/VKontakte/src/vk_files.cpp
@@ -34,11 +34,13 @@ CMStringW CVkProto::GetVkFileItem(CMStringW& _wszUrl, MCONTACT hContact, VKMessa
CMStringW wszUrl = _wszUrl;
wszUrl.Replace(L"\\", L"/");
-
- if (int i = wszUrl.Find('?'))
+
+ int i = wszUrl.Find('?');
+ if (i > -1)
wszUrl.Truncate(i);
-
- if (int i = wszUrl.ReverseFind('/'))
+
+ i = wszUrl.ReverseFind('/');
+ if (i > -1)
wszUrl = wszUrl.Mid(i + 1);
wszUrl.Insert(0, buf);
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h
index 9cc682425d..901408c1b9 100644
--- a/protocols/VKontakte/src/vk_proto.h
+++ b/protocols/VKontakte/src/vk_proto.h
@@ -390,6 +390,7 @@ private:
CMStringA GetAttachmentsFromMessage(const char * szMsg);
CMStringW SpanVKNotificationType(CMStringW& wszType, VKObjType& vkFeedback, VKObjType& vkParent);
CMStringW GetVkPhotoItem(const JSONNode &jnPhoto, BBCSupport iBBC, MCONTACT hContact, VKMessageID_t iMessageId);
+ CMStringW GetVkPhotoForVideoItem(const JSONNode& jnPhoto, MCONTACT hContact, VKMessageID_t iMessageId);
CMStringW SetBBCString(LPCWSTR wszString, BBCSupport iBBC, VKBBCType bbcType, LPCWSTR wszAddString = nullptr);
CMStringW& ClearFormatNick(CMStringW& wszText);
CMStringW GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport iBBC, MCONTACT hContact, VKMessageID_t iMessageId);