diff options
author | ElzorFox <elzorfox@ya.ru> | 2024-04-23 10:47:14 +0500 |
---|---|---|
committer | ElzorFox <elzorfox@ya.ru> | 2024-04-23 10:47:29 +0500 |
commit | 2aa8617e367926437f8bbddc967843c37f4b508e (patch) | |
tree | 293c00e31403e35018bf4d42c46f41d15d4abfc1 /protocols/VKontakte/src/misc.cpp | |
parent | 6e2bc32e078c4e91071ad15d98e48a487b937d39 (diff) |
VKontakte:
add options for load 300px preview img
small code optimization
version bump
Diffstat (limited to 'protocols/VKontakte/src/misc.cpp')
-rw-r--r-- | protocols/VKontakte/src/misc.cpp | 52 |
1 files changed, 24 insertions, 28 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index ba44870766..4f5b359f7e 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -1109,8 +1109,8 @@ CMStringW CVkProto::GetVkPhotoItem(const JSONNode &jnPhoto, BBCSupport iBBC, MCO if (!jnPhoto)
return wszRes;
- CVKImageSizeItem vkSizes[6];
- CMStringW wszPriorSize = L"smxyzw", wszPreviewLink;
+ CVKImageSizeItem vkSizes[9];
+ CMStringW wszPriorSize = L"smpqrxyzw", wszPreviewLink;
int iMaxSize = 0;
for (auto& it : jnPhoto["sizes"]) {
@@ -1130,6 +1130,9 @@ CMStringW CVkProto::GetVkPhotoItem(const JSONNode &jnPhoto, BBCSupport iBBC, MCO case imgNo:
wszPreviewLink = L"";
break;
+ case imgPreview300:
+ wszPreviewLink = vkSizes[wszPriorSize.Find(L"q")].wszUrl.IsEmpty() ? (vkSizes[wszPriorSize.Find(L"x")].wszUrl.IsEmpty() ? vkSizes[wszPriorSize.Find(L"o")].wszUrl : vkSizes[wszPriorSize.Find(L"x")].wszUrl) : vkSizes[wszPriorSize.Find(L"q")].wszUrl;
+ break;
case imgFullSize:
wszPreviewLink = vkSizes[iMaxSize].wszUrl;
break;
@@ -1141,32 +1144,28 @@ CMStringW CVkProto::GetVkPhotoItem(const JSONNode &jnPhoto, BBCSupport iBBC, MCO break;
}
- if (m_vkOptions.bBBCNewStorySupport) {
- wszRes.AppendFormat(L"%s (%dx%d)",
- TranslateT("Photo"),
- vkSizes[iMaxSize].iSizeW,
- vkSizes[iMaxSize].iSizeH
- );
- wszPreviewLink = GetVkFileItem(vkSizes[iMaxSize].wszUrl, hContact, iMessageId);
- wszRes = SetBBCString(wszRes, bbcAdvanced, vkbbcImgE, (!wszPreviewLink.IsEmpty() ? wszPreviewLink : L""));
- }
- else {
- wszRes.AppendFormat(L"%s (%dx%d)",
- SetBBCString(TranslateT("Photo"), iBBC, vkbbcUrl, vkSizes[iMaxSize].wszUrl).c_str(),
- vkSizes[iMaxSize].iSizeW,
- vkSizes[iMaxSize].iSizeH
- );
- if (m_vkOptions.iIMGBBCSupport && iBBC != bbcNo)
- wszRes.AppendFormat(L"\n\t%s",
- SetBBCString((!wszPreviewLink.IsEmpty() ? wszPreviewLink : (!vkSizes[iMaxSize].wszUrl.IsEmpty() ? vkSizes[iMaxSize].wszUrl : L"")),
- bbcBasic,
- vkbbcImg).c_str()
- );
- }
+ wszRes.AppendFormat(L"%s (%dx%d)",
+ TranslateT("Photo"),
+ vkSizes[iMaxSize].iSizeW,
+ vkSizes[iMaxSize].iSizeH
+ );
+
+
+ if (m_vkOptions.bBBCNewStorySupport)
+ wszPreviewLink = GetVkFileItem(wszPreviewLink, hContact, iMessageId);
+
+ CMStringW wszImg;
+
+ if (m_vkOptions.iIMGBBCSupport && iBBC != bbcNo)
+ wszImg = m_vkOptions.bBBCNewStorySupport ?
+ SetBBCString(wszRes, bbcAdvanced, vkbbcImgE, (!wszPreviewLink.IsEmpty() ? wszPreviewLink : L"")) :
+ SetBBCString((!wszPreviewLink.IsEmpty() ? wszPreviewLink : (!vkSizes[iMaxSize].wszUrl.IsEmpty() ? vkSizes[iMaxSize].wszUrl : L"")), bbcBasic, vkbbcImg);
+ wszRes = wszImg + SetBBCString(wszRes, iBBC, vkbbcUrl, vkSizes[iMaxSize].wszUrl) + L"\n";
+
CMStringW wszText(jnPhoto["text"].as_mstring());
if (!wszText.IsEmpty())
- wszRes += L"\n" + wszText;
+ wszRes += wszText + L"\n";
return wszRes;
}
@@ -1250,9 +1249,6 @@ CMStringW CVkProto::SetBBCString(LPCWSTR pwszString, BBCSupport iBBC, VKBBCType else
res.AppendFormat(pwszFormat, pwszString);
- if (bbcType == vkbbcImgE && iBBC == bbcAdvanced)
- res += SetBBCString(pwszString, bbcAdvanced, vkbbcUrl, wszAddString) + L"\n";
-
return res;
}
|