summaryrefslogtreecommitdiff
path: root/protocols/VKontakte/src
diff options
context:
space:
mode:
authorElzorFox <elzorfox@ya.ru>2024-04-23 10:47:14 +0500
committerElzorFox <elzorfox@ya.ru>2024-04-23 10:47:29 +0500
commit2aa8617e367926437f8bbddc967843c37f4b508e (patch)
tree293c00e31403e35018bf4d42c46f41d15d4abfc1 /protocols/VKontakte/src
parent6e2bc32e078c4e91071ad15d98e48a487b937d39 (diff)
VKontakte:
add options for load 300px preview img small code optimization version bump
Diffstat (limited to 'protocols/VKontakte/src')
-rw-r--r--protocols/VKontakte/src/misc.cpp52
-rw-r--r--protocols/VKontakte/src/resource.h3
-rw-r--r--protocols/VKontakte/src/version.h2
-rw-r--r--protocols/VKontakte/src/vk_options.cpp10
-rw-r--r--protocols/VKontakte/src/vk_options.h1
-rw-r--r--protocols/VKontakte/src/vk_struct.h2
6 files changed, 37 insertions, 33 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;
}
diff --git a/protocols/VKontakte/src/resource.h b/protocols/VKontakte/src/resource.h
index a846e8968d..1d8cd98a68 100644
--- a/protocols/VKontakte/src/resource.h
+++ b/protocols/VKontakte/src/resource.h
@@ -137,6 +137,7 @@
#define IDC_STATIC_MESSAGE 1120
#define IDC_ADD_MES_LINK_MES_ATT 1121
#define IDC_ADD_ORIG_VER_IN_EDITED_MES 1122
+#define IDC_IMG_300 1123
// Next default values for new objects
//
@@ -145,7 +146,7 @@
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 131
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1121
+#define _APS_NEXT_CONTROL_VALUE 1124
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h
index 30c7a10457..926781be19 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 6
+#define __BUILD_NUM 7
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk_options.cpp b/protocols/VKontakte/src/vk_options.cpp
index 3192865af3..3f993f2b64 100644
--- a/protocols/VKontakte/src/vk_options.cpp
+++ b/protocols/VKontakte/src/vk_options.cpp
@@ -437,6 +437,7 @@ CVkOptionViewForm::CVkOptionViewForm(CVkProto *proto) :
m_cbIMGBBCSupportOff(this, IDC_IMG_OFF),
m_cbIMGBBCSupportFullSize(this, IDC_IMG_FULLSIZE),
m_cbIMGBBCSupport130(this, IDC_IMG_130),
+ m_cbIMGBBCSupport300(this, IDC_IMG_300),
m_cbIMGBBCSupport604(this, IDC_IMG_604),
m_cbBBCForNewsOff(this, IDC_NEWSBBC_OFF),
m_cbBBCForNewsBasic(this, IDC_NEWSBBC_BASIC),
@@ -470,6 +471,7 @@ bool CVkOptionViewForm::OnInitDialog()
m_cbIMGBBCSupportOff.SetState(m_proto->m_vkOptions.iIMGBBCSupport == IMGBBCSypport::imgNo);
m_cbIMGBBCSupportFullSize.SetState(m_proto->m_vkOptions.iIMGBBCSupport == IMGBBCSypport::imgFullSize);
m_cbIMGBBCSupport130.SetState(m_proto->m_vkOptions.iIMGBBCSupport == IMGBBCSypport::imgPreview130);
+ m_cbIMGBBCSupport300.SetState(m_proto->m_vkOptions.iIMGBBCSupport == IMGBBCSypport::imgPreview300);
m_cbIMGBBCSupport604.SetState(m_proto->m_vkOptions.iIMGBBCSupport == IMGBBCSypport::imgPreview604);
m_cbBBCForNewsOff.SetState(m_proto->m_vkOptions.iBBCForNews == BBCSupport::bbcNo);
@@ -490,6 +492,8 @@ bool CVkOptionViewForm::OnApply()
m_proto->m_vkOptions.iIMGBBCSupport = IMGBBCSypport::imgFullSize;
if (m_cbIMGBBCSupport130.GetState())
m_proto->m_vkOptions.iIMGBBCSupport = IMGBBCSypport::imgPreview130;
+ if (m_cbIMGBBCSupport300.GetState())
+ m_proto->m_vkOptions.iIMGBBCSupport = IMGBBCSypport::imgPreview300;
if (m_cbIMGBBCSupport604.GetState())
m_proto->m_vkOptions.iIMGBBCSupport = IMGBBCSypport::imgPreview604;
@@ -515,8 +519,9 @@ void CVkOptionViewForm::On_cbBBCSupportForNewStory(CCtrlCheck*)
if (bState) {
m_cbIMGBBCSupportOff.SetState(false);
- m_cbIMGBBCSupportFullSize.SetState(true);
+ m_cbIMGBBCSupportFullSize.SetState(m_proto->m_vkOptions.iIMGBBCSupport == IMGBBCSypport::imgFullSize);
m_cbIMGBBCSupport130.SetState(false);
+ m_cbIMGBBCSupport300.SetState(m_proto->m_vkOptions.iIMGBBCSupport != IMGBBCSypport::imgFullSize);
m_cbIMGBBCSupport604.SetState(false);
m_cbBBCForNewsOff.SetState(false);
m_cbBBCForNewsBasic.SetState(false);
@@ -528,8 +533,9 @@ void CVkOptionViewForm::On_cbBBCSupportForNewStory(CCtrlCheck*)
}
m_cbIMGBBCSupportOff.Enable(!bState);
- m_cbIMGBBCSupportFullSize.Enable(!bState);
+ m_cbIMGBBCSupportFullSize.Enable(true);
m_cbIMGBBCSupport130.Enable(!bState);
+ m_cbIMGBBCSupport300.Enable(true);
m_cbIMGBBCSupport604.Enable(!bState);
m_cbBBCForNewsOff.Enable(!bState);
m_cbBBCForNewsBasic.Enable(!bState);
diff --git a/protocols/VKontakte/src/vk_options.h b/protocols/VKontakte/src/vk_options.h
index e78f9503a8..7ffb0c1be0 100644
--- a/protocols/VKontakte/src/vk_options.h
+++ b/protocols/VKontakte/src/vk_options.h
@@ -135,6 +135,7 @@ class CVkOptionViewForm : public CVkDlgBase
CCtrlCheck m_cbIMGBBCSupportFullSize;
CCtrlCheck m_cbIMGBBCSupport130;
CCtrlCheck m_cbIMGBBCSupport604;
+ CCtrlCheck m_cbIMGBBCSupport300;
CCtrlCheck m_cbBBCForNewsOff;
CCtrlCheck m_cbBBCForNewsBasic;
diff --git a/protocols/VKontakte/src/vk_struct.h b/protocols/VKontakte/src/vk_struct.h
index 03045fff21..9337b61001 100644
--- a/protocols/VKontakte/src/vk_struct.h
+++ b/protocols/VKontakte/src/vk_struct.h
@@ -238,7 +238,7 @@ struct CVKLang {
enum MarkMsgReadOn : uint8_t { markOnRead, markOnReceive, markOnReply, markOnTyping };
enum SyncHistoryMetod : uint8_t { syncOff, syncAuto, sync1Days, sync3Days };
enum MusicSendMetod : uint8_t { sendNone, sendStatusOnly, sendBroadcastOnly, sendBroadcastAndStatus };
-enum IMGBBCSypport : uint8_t { imgNo, imgFullSize, imgPreview130, imgPreview604 };
+enum IMGBBCSypport : uint8_t { imgNo, imgFullSize, imgPreview130, imgPreview604, imgPreview300 };
struct CVkCookie
{