From cd6fcef67cdf3c72afc98ed149f82af7f6860487 Mon Sep 17 00:00:00 2001 From: ElzorFox Date: Sat, 6 Apr 2024 16:50:31 +0500 Subject: =?UTF-8?q?VKontakte:=20async=20mode=20download=20images=20as=20de?= =?UTF-8?q?fault=20add=20=E2=80=98LoadFilesAsync=E2=80=99=20hiden=20option?= =?UTF-8?q?=20(default=20true)=20add=20dynamic=20show=20image=20in=20NewSt?= =?UTF-8?q?ory=20on=20finish=20download=20add=20option=20for=20bbc=20in=20?= =?UTF-8?q?NewStory=20support=20add=20option=20for=20show=20original=20ver?= =?UTF-8?q?sion=20message=20in=20edited=20message=20version=20bump?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/VKontakte/res/resource.rc | 45 ++++++++++++++++++--------------- protocols/VKontakte/src/misc.cpp | 30 +++++++++++----------- protocols/VKontakte/src/resource.h | 16 +++++++----- protocols/VKontakte/src/version.h | 2 +- protocols/VKontakte/src/vk_chats.cpp | 18 +++++++------ protocols/VKontakte/src/vk_feed.cpp | 8 +++--- protocols/VKontakte/src/vk_files.cpp | 39 +++++++++++++++++++--------- protocols/VKontakte/src/vk_history.cpp | 6 ++--- protocols/VKontakte/src/vk_messages.cpp | 17 +++++++------ protocols/VKontakte/src/vk_options.cpp | 43 ++++++++++++++++++++++++++++++- protocols/VKontakte/src/vk_options.h | 3 +++ protocols/VKontakte/src/vk_proto.h | 10 ++++---- protocols/VKontakte/src/vk_struct.cpp | 9 +++++++ protocols/VKontakte/src/vk_struct.h | 17 +++++++++++++ 14 files changed, 178 insertions(+), 85 deletions(-) (limited to 'protocols/VKontakte') diff --git a/protocols/VKontakte/res/resource.rc b/protocols/VKontakte/res/resource.rc index 655702ad66..c57615afb4 100644 --- a/protocols/VKontakte/res/resource.rc +++ b/protocols/VKontakte/res/resource.rc @@ -73,7 +73,7 @@ BEGIN LEFTMARGIN, 4 RIGHTMARGIN, 298 TOPMARGIN, 7 - BOTTOMMARGIN, 202 + BOTTOMMARGIN, 219 END IDD_OPT_FEEDS, DIALOG @@ -176,37 +176,40 @@ BEGIN CONTROL "Visit profile",IDC_SHOW_MENU6,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,85,280,10 END -IDD_OPT_VIEW DIALOGEX 0, 0, 304, 209 +IDD_OPT_VIEW DIALOGEX 0, 0, 304, 220 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD EXSTYLE WS_EX_CONTROLPARENT FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN - GROUPBOX "[img] BBCode support for image",IDC_STATIC,4,8,293,39,WS_GROUP - CONTROL "off",IDC_IMG_OFF,"Button",BS_AUTORADIOBUTTON,12,19,129,10 - CONTROL "for original size images",IDC_IMG_FULLSIZE,"Button",BS_AUTORADIOBUTTON,12,30,129,10 - CONTROL "for preview max 130*130 px",IDC_IMG_130,"Button",BS_AUTORADIOBUTTON,154,19,132,10 - CONTROL "for preview max 604*604 px",IDC_IMG_604,"Button",BS_AUTORADIOBUTTON,154,30,132,10 - GROUPBOX "BBCode support on news and event notifications",IDC_STATIC,4,50,294,48,WS_GROUP - CONTROL "off",IDC_NEWSBBC_OFF,"Button",BS_AUTORADIOBUTTON,12,61,129,10 - CONTROL "basic ([b], [i], [u], [s])",IDC_NEWSBBC_BASIC,"Button",BS_AUTORADIOBUTTON,12,72,129,10 + CONTROL "Support BBC for NewStory",IDC_BBC_NEWSTORY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,10,278,10 + GROUPBOX "[img] BBCode support for image",IDC_STATIC,13,20,280,33,WS_GROUP + CONTROL "off",IDC_IMG_OFF,"Button",BS_AUTORADIOBUTTON,21,29,129,10 + CONTROL "for original size images",IDC_IMG_FULLSIZE,"Button",BS_AUTORADIOBUTTON,21,40,129,10 + CONTROL "for preview max 130*130 px",IDC_IMG_130,"Button",BS_AUTORADIOBUTTON,163,29,127,10 + CONTROL "for preview max 604*604 px",IDC_IMG_604,"Button",BS_AUTORADIOBUTTON,163,40,128,10 + GROUPBOX "BBCode support on news and event notifications",IDC_STATIC,13,56,280,48,WS_GROUP + CONTROL "off",IDC_NEWSBBC_OFF,"Button",BS_AUTORADIOBUTTON,21,67,129,10 + CONTROL "basic ([b], [i], [u], [s])",IDC_NEWSBBC_BASIC,"Button",BS_AUTORADIOBUTTON,21,78,129,10 CONTROL "advanced (+[url], [size], [color], [code])",IDC_NEWSBBC_ADV, - "Button",BS_AUTORADIOBUTTON,154,61,149,10 + "Button",BS_AUTORADIOBUTTON,140,67,149,10 CONTROL "Use this setting also for attachments on news and notifications",IDC_BBC_ATT_NEWS, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,83,278,10 - GROUPBOX "BBCode support on attachments",IDC_STATIC,4,99,294,38,WS_GROUP - CONTROL "off",IDC_ATTBBC_OFF,"Button",BS_AUTORADIOBUTTON,12,110,129,10 - CONTROL "basic ([b], [i], [u], [s])",IDC_ATTBBC_BASIC,"Button",BS_AUTORADIOBUTTON,12,121,129,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,21,89,269,10 + GROUPBOX "BBCode support on attachments",IDC_STATIC,13,105,280,36,WS_GROUP + CONTROL "off",IDC_ATTBBC_OFF,"Button",BS_AUTORADIOBUTTON,21,116,129,10 + CONTROL "basic ([b], [i], [u], [s])",IDC_ATTBBC_BASIC,"Button",BS_AUTORADIOBUTTON,21,127,129,10 CONTROL "advanced (+[url], [size], [color], [code])",IDC_ATTBBC_ADV, - "Button",BS_AUTORADIOBUTTON,154,110,149,10 - GROUPBOX "Other",IDC_STATIC,4,138,294,57 + "Button",BS_AUTORADIOBUTTON,134,116,149,10 + GROUPBOX "Other",IDC_STATIC,4,144,294,69 CONTROL "Process stickers as smileys",IDC_STICKERS_AS_SMYLES, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,149,278,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,153,278,10 CONTROL "Shorten links for audio attachments",IDC_SHOTEN_LINKS_FOR_AUDIO, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,160,278,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,164,278,10 CONTROL "Use non-standard popups for news and event notifications",IDC_USENOSTDPOPUPS, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,171,278,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,175,278,10 CONTROL "Add message link to messages with attachments",IDC_ADD_MES_LINK_MES_ATT, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,182,278,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,186,278,10 + CONTROL "Add original message version in edited message",IDC_ADD_ORIG_VER_IN_EDITED_MES, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,197,278,10 END IDD_OPT_FEEDS DIALOGEX 0, 0, 304, 232 diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index 1d2f67b693..faa534d1ef 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -1101,7 +1101,7 @@ CMStringW CVkProto::SpanVKNotificationType(CMStringW& wszType, VKObjType& vkFeed return wszRes; } -CMStringW CVkProto::GetVkPhotoItem(const JSONNode &jnPhoto, BBCSupport iBBC, MCONTACT hContact, VKMessageID_t iMessageId, bool bAsync) +CMStringW CVkProto::GetVkPhotoItem(const JSONNode &jnPhoto, BBCSupport iBBC, MCONTACT hContact, VKMessageID_t iMessageId) { CMStringW wszRes; @@ -1146,7 +1146,7 @@ CMStringW CVkProto::GetVkPhotoItem(const JSONNode &jnPhoto, BBCSupport iBBC, MCO vkSizes[iMaxSize].iSizeW, vkSizes[iMaxSize].iSizeH ); - wszPreviewLink = GetVkFileItem(vkSizes[iMaxSize].wszUrl, hContact, iMessageId, bAsync); + wszPreviewLink = GetVkFileItem(vkSizes[iMaxSize].wszUrl, hContact, iMessageId); wszRes = SetBBCString(wszRes, bbcAdvanced, vkbbcImgE, (!wszPreviewLink.IsEmpty() ? wszPreviewLink : L"")); } else { @@ -1247,7 +1247,7 @@ CMStringW& CVkProto::ClearFormatNick(CMStringW& wszText) ///////////////////////////////////////////////////////////////////////////////////////// -CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport iBBC, MCONTACT hContact, VKMessageID_t iMessageId, bool bAsync) +CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport iBBC, MCONTACT hContact, VKMessageID_t iMessageId) { debugLogA("CVkProto::GetAttachmentDescr"); CMStringW res; @@ -1267,7 +1267,7 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport if (!jnPhoto) continue; - res += GetVkPhotoItem(jnPhoto, iBBC, hContact, iMessageId, bAsync); + res += GetVkPhotoItem(jnPhoto, iBBC, hContact, iMessageId); } else if (wszType == L"audio") { const JSONNode& jnAudio = jnAttach["audio"]; @@ -1370,7 +1370,7 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport const JSONNode& jnSubAttachments = jnCopyHystoryItem["attachments"]; if (jnSubAttachments) { debugLogA("CVkProto::GetAttachmentDescr SubAttachments"); - CMStringW wszAttachmentDescr = GetAttachmentDescr(jnSubAttachments, iBBC, hContact, iMessageId, bAsync); + CMStringW wszAttachmentDescr = GetAttachmentDescr(jnSubAttachments, iBBC, hContact, iMessageId); wszAttachmentDescr.Replace(L"\n", L"\n\t\t"); wszAttachmentDescr.Replace(L"== FilterAudioMessages ==", L""); res += L"\n\t\t" + wszAttachmentDescr; @@ -1381,7 +1381,7 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport const JSONNode& jnSubAttachments = jnWall["attachments"]; if (jnSubAttachments) { debugLogA("CVkProto::GetAttachmentDescr SubAttachments"); - CMStringW wszAttachmentDescr = GetAttachmentDescr(jnSubAttachments, iBBC, hContact, iMessageId, bAsync); + CMStringW wszAttachmentDescr = GetAttachmentDescr(jnSubAttachments, iBBC, hContact, iMessageId); wszAttachmentDescr.Replace(L"\n", L"\n\t"); wszAttachmentDescr.Replace(L"== FilterAudioMessages ==", L""); res += L"\n\t" + wszAttachmentDescr; @@ -1418,7 +1418,7 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport const JSONNode& jnSubAttachments = jnWallReply["attachments"]; if (jnSubAttachments) { debugLogA("CVkProto::GetAttachmentDescr SubAttachments"); - CMStringW wszAttachmentDescr = GetAttachmentDescr(jnSubAttachments, iBBC, hContact, iMessageId, bAsync); + CMStringW wszAttachmentDescr = GetAttachmentDescr(jnSubAttachments, iBBC, hContact, iMessageId); wszAttachmentDescr.Replace(L"\n", L"\n\t"); wszAttachmentDescr.Replace(L"== FilterAudioMessages ==", L""); res += L"\n\t" + wszAttachmentDescr; @@ -1443,7 +1443,7 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport continue; res += L"\n\t"; - res += GetVkPhotoItem(jnPhoto, iBBC, hContact, iMessageId, bAsync); + res += GetVkPhotoItem(jnPhoto, iBBC, hContact, iMessageId); } else if (wszStoryType == L"video") { const JSONNode& jnVideo = jnStory["video"]; @@ -1545,7 +1545,7 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport res.AppendFormat(L"\n\t%s", SetBBCString(wszCaption, iBBC, vkbbcI).c_str()); if (jnLink["photo"]) - res.AppendFormat(L"\n\t%s", GetVkPhotoItem(jnLink["photo"], iBBC, hContact, iMessageId, bAsync).c_str()); + res.AppendFormat(L"\n\t%s", GetVkPhotoItem(jnLink["photo"], iBBC, hContact, iMessageId).c_str()); if (!wszDescription.IsEmpty()) res.AppendFormat(L"\n\t%s", wszDescription.c_str()); @@ -1615,7 +1615,7 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport return res; } -CMStringW CVkProto::GetFwdMessage(const JSONNode& jnMsg, const JSONNode& jnFUsers, OBJLIST& vkUsers, BBCSupport iBBC, bool bAsync) +CMStringW CVkProto::GetFwdMessage(const JSONNode& jnMsg, const JSONNode& jnFUsers, OBJLIST& vkUsers, BBCSupport iBBC) { VKUserID_t iUserId = jnMsg["from_id"].as_int(); CMStringW wszBody(jnMsg["text"].as_mstring()); @@ -1646,7 +1646,7 @@ CMStringW CVkProto::GetFwdMessage(const JSONNode& jnMsg, const JSONNode& jnFUser const JSONNode& jnFwdMessages = jnMsg["fwd_messages"]; if (jnFwdMessages && !jnFwdMessages.empty()) { - CMStringW wszFwdMessages = GetFwdMessages(jnFwdMessages, jnFUsers, iBBC == bbcNo ? iBBC : m_vkOptions.BBCForAttachments(), bAsync); + CMStringW wszFwdMessages = GetFwdMessages(jnFwdMessages, jnFUsers, iBBC == bbcNo ? iBBC : m_vkOptions.BBCForAttachments()); if (!wszBody.IsEmpty()) wszFwdMessages = L"\n" + wszFwdMessages; wszBody += wszFwdMessages; @@ -1654,7 +1654,7 @@ CMStringW CVkProto::GetFwdMessage(const JSONNode& jnMsg, const JSONNode& jnFUser const JSONNode& jnAttachments = jnMsg["attachments"]; if (jnAttachments && !jnAttachments.empty()) { - CMStringW wszAttachmentDescr = GetAttachmentDescr(jnAttachments, iBBC == bbcNo ? iBBC : m_vkOptions.BBCForAttachments(), hContact, iMessageId, bAsync); + CMStringW wszAttachmentDescr = GetAttachmentDescr(jnAttachments, iBBC == bbcNo ? iBBC : m_vkOptions.BBCForAttachments(), hContact, iMessageId); if (wszAttachmentDescr != L"== FilterAudioMessages ==") { if (!wszBody.IsEmpty()) wszAttachmentDescr = L"\n" + wszAttachmentDescr; @@ -1677,7 +1677,7 @@ CMStringW CVkProto::GetFwdMessage(const JSONNode& jnMsg, const JSONNode& jnFUser } -CMStringW CVkProto::GetFwdMessages(const JSONNode &jnMessages, const JSONNode &jnFUsers, BBCSupport iBBC, bool bAsync) +CMStringW CVkProto::GetFwdMessages(const JSONNode &jnMessages, const JSONNode &jnFUsers, BBCSupport iBBC) { CMStringW res; debugLogA("CVkProto::GetFwdMessages"); @@ -1705,10 +1705,10 @@ CMStringW CVkProto::GetFwdMessages(const JSONNode &jnMessages, const JSONNode &j for (auto& jnMsg : jnMessages.as_array()) { if (!res.IsEmpty()) res.AppendChar('\n'); - res += GetFwdMessage(jnMsg, jnFUsers, vkUsers, iBBC, bAsync); + res += GetFwdMessage(jnMsg, jnFUsers, vkUsers, iBBC); } else - res = GetFwdMessage(jnMessages, jnFUsers, vkUsers, iBBC, bAsync); + res = GetFwdMessage(jnMessages, jnFUsers, vkUsers, iBBC); res.AppendChar('\n'); vkUsers.destroy(); diff --git a/protocols/VKontakte/src/resource.h b/protocols/VKontakte/src/resource.h index a5f53ada9d..3d2a2211d0 100644 --- a/protocols/VKontakte/src/resource.h +++ b/protocols/VKontakte/src/resource.h @@ -126,14 +126,16 @@ #define IDC_N_FRIENDACCEPTED 1110 #define IDC_SENDVKURLSASATTACH 1111 #define IDC_LOADSENTATTACH 1112 -#define IDC_ADD_MES_LINK_MES_ATT 1113 -#define IDC_STATIC_TXT 1114 -#define IDC_CH_REMOVE_FROM_FRIEND 1115 -#define IDC_CH_CLEARHISTORY 1116 -#define IDC_CONTACTLIST 1117 -#define IDC_MESSAGE 1118 -#define IDC_STATIC_MARKCONTAKTS 1119 +#define IDC_STATIC_TXT 1113 +#define IDC_BBC_NEWSTORY 1114 +#define IDC_CH_CLEARHISTORY 1115 +#define IDC_CONTACTLIST 1116 +#define IDC_MESSAGE 1117 +#define IDC_STATIC_MARKCONTAKTS 1118 +#define IDC_CH_REMOVE_FROM_FRIEND 1119 #define IDC_STATIC_MESSAGE 1120 +#define IDC_ADD_MES_LINK_MES_ATT 1121 +#define IDC_ADD_ORIG_VER_IN_EDITED_MES 1122 // Next default values for new objects // diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h index bed1b164f1..e7ce682c2a 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 2 +#define __BUILD_NUM 3 #include diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp index be646621a4..ce8af5ae93 100644 --- a/protocols/VKontakte/src/vk_chats.cpp +++ b/protocols/VKontakte/src/vk_chats.cpp @@ -376,7 +376,7 @@ void CVkProto::AppendChatConversationMessage(VKUserID_t iChatId, const JSONNode& const JSONNode& jnFwdMessages = jnMsg["fwd_messages"]; if (jnFwdMessages && !jnFwdMessages.empty()) { - CMStringW wszFwdMessages = GetFwdMessages(jnFwdMessages, jnFUsers, bbcNo, vkChatInfo->m_bHistoryRead); + CMStringW wszFwdMessages = GetFwdMessages(jnFwdMessages, jnFUsers, bbcNo); if (!wszBody.IsEmpty()) wszFwdMessages = L"\n" + wszFwdMessages; wszBody += wszFwdMessages; @@ -385,7 +385,7 @@ void CVkProto::AppendChatConversationMessage(VKUserID_t iChatId, const JSONNode& const JSONNode& jnReplyMessages = jnMsg["reply_message"]; if (jnReplyMessages && !jnReplyMessages.empty()) { if (m_vkOptions.bShowReplyInMessage) { - CMStringW wszReplyMessages = GetFwdMessages(jnReplyMessages, jnFUsers, bbcNo, vkChatInfo->m_bHistoryRead); + CMStringW wszReplyMessages = GetFwdMessages(jnReplyMessages, jnFUsers, bbcNo); if (!wszBody.IsEmpty()) wszReplyMessages = L"\n" + wszReplyMessages; wszBody += wszReplyMessages; @@ -396,7 +396,7 @@ void CVkProto::AppendChatConversationMessage(VKUserID_t iChatId, const JSONNode& const JSONNode& jnAttachments = jnMsg["attachments"]; if (jnAttachments && !jnAttachments.empty()) { - CMStringW wszAttachmentDescr = GetAttachmentDescr(jnAttachments, bbcNo, vkChatInfo->m_si->hContact, iMessageId, vkChatInfo->m_bHistoryRead); + CMStringW wszAttachmentDescr = GetAttachmentDescr(jnAttachments, bbcNo, vkChatInfo->m_si->hContact, iMessageId); if (wszAttachmentDescr == L"== FilterAudioMessages ==") return; @@ -422,11 +422,13 @@ void CVkProto::AppendChatConversationMessage(VKUserID_t iChatId, const JSONNode& CMStringW(FORMAT, TranslateT("Edited message (updated %s):\n"), ttime), m_vkOptions.BBCForAttachments(), vkbbcB) + wszBody; - - CMStringW wszOldMsg; - if (GetMessageFromDb(iMessageId, tMsgTime, wszOldMsg)) - wszBody += SetBBCString(TranslateT("\nOriginal message:\n"), m_vkOptions.BBCForAttachments(), vkbbcB) + - wszOldMsg; + + if (m_vkOptions.bShowBeforeEditedPostVersion) { + CMStringW wszOldMsg; + if (GetMessageFromDb(iMessageId, tMsgTime, wszOldMsg)) + wszBody += SetBBCString(TranslateT("\nOriginal message:\n"), m_vkOptions.BBCForAttachments(), vkbbcB) + + wszOldMsg; + } } if (m_vkOptions.bAddMessageLinkToMesWAtt && ((jnAttachments && !jnAttachments.empty()) || (jnFwdMessages && !jnFwdMessages.empty()) || (jnReplyMessages && !jnReplyMessages.empty() && m_vkOptions.bShowReplyInMessage))) diff --git a/protocols/VKontakte/src/vk_feed.cpp b/protocols/VKontakte/src/vk_feed.cpp index 5260774e7a..c45519c54b 100644 --- a/protocols/VKontakte/src/vk_feed.cpp +++ b/protocols/VKontakte/src/vk_feed.cpp @@ -188,7 +188,7 @@ CVKNewsItem* CVkProto::GetVkNewsItem(const JSONNode &jnItem, OBJLISTwszType == L"wall_photo") { if (jnPhotoItem["post_id"]) { bPostLink = true; @@ -240,7 +240,7 @@ CVKNewsItem* CVkProto::GetVkNewsItem(const JSONNode &jnItem, OBJLISTwszId.AppendFormat(L"%d_%d", iOwnerId, iId); diff --git a/protocols/VKontakte/src/vk_files.cpp b/protocols/VKontakte/src/vk_files.cpp index ecf3cd164f..301507ec2e 100644 --- a/protocols/VKontakte/src/vk_files.cpp +++ b/protocols/VKontakte/src/vk_files.cpp @@ -17,7 +17,7 @@ along with this program. If not, see . #include "stdafx.h" -CMStringW CVkProto::GetVkFileItem(CMStringW& _wszUrl, MCONTACT hContact, VKMessageID_t /*iMessageId*/, bool bAsync) +CMStringW CVkProto::GetVkFileItem(CMStringW& _wszUrl, MCONTACT hContact, VKMessageID_t iMessageId) { wchar_t buf[MAX_PATH]; @@ -44,11 +44,11 @@ CMStringW CVkProto::GetVkFileItem(CMStringW& _wszUrl, MCONTACT hContact, VKMessa wszUrl.Insert(0, buf); if (::_waccess(wszUrl.c_str(), 0) && IsOnline()) - if (bAsync) { + if (iMessageId != -1 && m_vkOptions.bLoadFilesAsync) { AsyncHttpRequest* pReq = new AsyncHttpRequest(); pReq->flags = NLHRF_NODUMP | NLHRF_REDIRECT; pReq->m_szUrl = CMStringA(_wszUrl); - pReq->pUserInfo = mir_wstrdup(wszUrl.c_str()); + pReq->pUserInfo = new CVkFileDownloadParam(hContact, iMessageId, wszUrl.c_str()); pReq->m_pFunc = &CVkProto::OnGetVkFileItem; pReq->requestType = REQUEST_GET; pReq->m_bApiReq = false; @@ -89,25 +89,40 @@ CMStringW CVkProto::GetVkFileItem(CMStringW& _wszUrl, MCONTACT hContact, VKMessa void CVkProto::OnGetVkFileItem(MHttpResponse* reply, AsyncHttpRequest* pReq) { - ptrW pwszFileName((wchar_t*)pReq->pUserInfo); - - if (reply->resultCode != 200 || !pReq->pUserInfo) { - debugLogW(L"CVkProto::OnGetVkFileItem error load file %s", pwszFileName); + + CVkFileDownloadParam* param = (CVkFileDownloadParam*)pReq->pUserInfo; + + if (reply->resultCode != 200 || !param) { + debugLogW(L"CVkProto::OnGetVkFileItem error load file %s", param && param->wszFileName ? param->wszFileName : L"NULL"); + delete param; return; } + debugLogW(L"CVkProto::OnGetVkFileItem %s", param->wszFileName); - debugLogW(L"CVkProto::OnGetVkFileItem %s", pwszFileName); - - FILE* out = _wfopen(pwszFileName, L"wb"); + FILE* out = _wfopen(param->wszFileName, L"wb"); if (out) { fwrite(reply->body, 1, reply->body.GetLength(), out); fclose(out); - debugLogW(L"CVkProto::OnGetVkFileItem file %s saved", pwszFileName); + debugLogW(L"CVkProto::OnGetVkFileItem file %s saved", param->wszFileName); + + MessageWindowData mwd = {}; + if (!Srmm_GetWindowData(param->hContact, mwd) && mwd.uState) { + char szMid[40]; + _itoa(param->iMsgID, szMid, 10); + MEVENT hDbEvent = db_event_getById(m_szModuleName, szMid); + + DBEVENTINFO dbei = {}; + if (db_event_get(hDbEvent, &dbei)) { + int i = db_event_edit(hDbEvent, &dbei, true); + debugLogW(L"CVkProto::OnGetVkFileItem file %s even edit %d", param->wszFileName, i); + } + } } else - debugLogW(L"CVkProto::OnGetVkFileItem error open file %s", pwszFileName); + debugLogW(L"CVkProto::OnGetVkFileItem error open file %s", param->wszFileName); + delete param; return; } diff --git a/protocols/VKontakte/src/vk_history.cpp b/protocols/VKontakte/src/vk_history.cpp index aa8d9c8a3f..b9e4a56967 100644 --- a/protocols/VKontakte/src/vk_history.cpp +++ b/protocols/VKontakte/src/vk_history.cpp @@ -251,7 +251,7 @@ void CVkProto::OnReceiveHistoryMessages(MHttpResponse *reply, AsyncHttpRequest * const JSONNode &jnFwdMessages = jnMsg["fwd_messages"]; if (jnFwdMessages && !jnFwdMessages.empty()) { - CMStringW wszFwdMessages = GetFwdMessages(jnFwdMessages, jnFUsers, m_vkOptions.BBCForAttachments(), true); + CMStringW wszFwdMessages = GetFwdMessages(jnFwdMessages, jnFUsers, m_vkOptions.BBCForAttachments()); if (!wszBody.IsEmpty()) wszFwdMessages = L"\n" + wszFwdMessages; wszBody += wszFwdMessages; @@ -260,7 +260,7 @@ void CVkProto::OnReceiveHistoryMessages(MHttpResponse *reply, AsyncHttpRequest * const JSONNode& jnReplyMessages = jnMsg["reply_message"]; if (jnReplyMessages && !jnReplyMessages.empty()) if (m_vkOptions.bShowReplyInMessage) { - CMStringW wszReplyMessages = GetFwdMessages(jnReplyMessages, jnFUsers, m_vkOptions.BBCForAttachments(), true); + CMStringW wszReplyMessages = GetFwdMessages(jnReplyMessages, jnFUsers, m_vkOptions.BBCForAttachments()); if (!wszBody.IsEmpty()) wszReplyMessages = L"\n" + wszReplyMessages; wszBody += wszReplyMessages; @@ -270,7 +270,7 @@ void CVkProto::OnReceiveHistoryMessages(MHttpResponse *reply, AsyncHttpRequest * const JSONNode &jnAttachments = jnMsg["attachments"]; if (jnAttachments && !jnAttachments.empty()) { - CMStringW wszAttachmentDescr = GetAttachmentDescr(jnAttachments, m_vkOptions.BBCForAttachments(), hContact, iMessageId, true); + CMStringW wszAttachmentDescr = GetAttachmentDescr(jnAttachments, m_vkOptions.BBCForAttachments(), hContact, iMessageId); if (wszAttachmentDescr == L"== FilterAudioMessages ==") { count++; diff --git a/protocols/VKontakte/src/vk_messages.cpp b/protocols/VKontakte/src/vk_messages.cpp index 5f1a2e55dd..b77cc65629 100644 --- a/protocols/VKontakte/src/vk_messages.cpp +++ b/protocols/VKontakte/src/vk_messages.cpp @@ -382,7 +382,7 @@ void CVkProto::OnReceiveMessages(MHttpResponse *reply, AsyncHttpRequest *pReq) const JSONNode& jnFwdMessages = jnMsg["fwd_messages"]; if (jnFwdMessages && !jnFwdMessages.empty()) { - CMStringW wszFwdMessages = GetFwdMessages(jnFwdMessages, jnFUsers, m_vkOptions.BBCForAttachments(), false); + CMStringW wszFwdMessages = GetFwdMessages(jnFwdMessages, jnFUsers, m_vkOptions.BBCForAttachments()); if (!wszBody.IsEmpty()) wszFwdMessages = L"\n" + wszFwdMessages; wszBody += wszFwdMessages; @@ -391,7 +391,7 @@ void CVkProto::OnReceiveMessages(MHttpResponse *reply, AsyncHttpRequest *pReq) const JSONNode& jnReplyMessages = jnMsg["reply_message"]; if (jnReplyMessages && !jnReplyMessages.empty()) if (m_vkOptions.bShowReplyInMessage) { - CMStringW wszReplyMessages = GetFwdMessages(jnReplyMessages, jnFUsers, m_vkOptions.BBCForAttachments(), false); + CMStringW wszReplyMessages = GetFwdMessages(jnReplyMessages, jnFUsers, m_vkOptions.BBCForAttachments()); if (!wszBody.IsEmpty()) wszReplyMessages = L"\n" + wszReplyMessages; wszBody += wszReplyMessages; @@ -404,7 +404,7 @@ void CVkProto::OnReceiveMessages(MHttpResponse *reply, AsyncHttpRequest *pReq) CMStringW wszAttachmentDescr; const JSONNode& jnAttachments = jnMsg["attachments"]; if (jnAttachments && !jnAttachments.empty()) { - wszAttachmentDescr = GetAttachmentDescr(jnAttachments, m_vkOptions.BBCForAttachments(), hContact, iMessageId, false); + wszAttachmentDescr = GetAttachmentDescr(jnAttachments, m_vkOptions.BBCForAttachments(), hContact, iMessageId); if (wszAttachmentDescr == L"== FilterAudioMessages ==") { if (hContact && (iMessageId > ReadQSWord(hContact, "lastmsgid", -1))) @@ -437,11 +437,12 @@ void CVkProto::OnReceiveMessages(MHttpResponse *reply, AsyncHttpRequest *pReq) CMStringW(FORMAT, TranslateT("Edited message (updated %s):\n"), ttime), m_vkOptions.BBCForAttachments(), vkbbcB) + wszBody; - - CMStringW wszOldMsg; - if (GetMessageFromDb(iMessageId, tDateTime, wszOldMsg)) - wszBody += SetBBCString(TranslateT("\nOriginal message:\n"), m_vkOptions.BBCForAttachments(), vkbbcB) + - wszOldMsg; + if (m_vkOptions.bShowBeforeEditedPostVersion) { + CMStringW wszOldMsg; + if (GetMessageFromDb(iMessageId, tDateTime, wszOldMsg)) + wszBody += SetBBCString(TranslateT("\nOriginal message:\n"), m_vkOptions.BBCForAttachments(), vkbbcB) + + wszOldMsg; + } } DB::EventInfo dbei; diff --git a/protocols/VKontakte/src/vk_options.cpp b/protocols/VKontakte/src/vk_options.cpp index 61940b9094..3192865af3 100644 --- a/protocols/VKontakte/src/vk_options.cpp +++ b/protocols/VKontakte/src/vk_options.cpp @@ -433,6 +433,7 @@ void CVkOptionFeedsForm::On_cbNotificationsEnabledChange(CCtrlCheck*) CVkOptionViewForm::CVkOptionViewForm(CVkProto *proto) : CVkDlgBase(proto, IDD_OPT_VIEW), + m_cbBBCSupportForNewStory(this, IDC_BBC_NEWSTORY), m_cbIMGBBCSupportOff(this, IDC_IMG_OFF), m_cbIMGBBCSupportFullSize(this, IDC_IMG_FULLSIZE), m_cbIMGBBCSupport130(this, IDC_IMG_130), @@ -447,17 +448,25 @@ CVkOptionViewForm::CVkOptionViewForm(CVkProto *proto) : m_cbStikersAsSmyles(this, IDC_STICKERS_AS_SMYLES), m_cbShortenLinksForAudio(this, IDC_SHOTEN_LINKS_FOR_AUDIO), m_cbAddMessageLinkToMesWAtt(this, IDC_ADD_MES_LINK_MES_ATT), - m_cbUseNonStandardNotifications(this, IDC_USENOSTDPOPUPS) + m_cbUseNonStandardNotifications(this, IDC_USENOSTDPOPUPS), + m_cbShowBeforeEditedPostVersion(this, IDC_ADD_ORIG_VER_IN_EDITED_MES) { + CreateLink(m_cbBBCSupportForNewStory, m_proto->m_vkOptions.bBBCNewStorySupport); CreateLink(m_cbUseBBCOnAttacmentsAsNews, m_proto->m_vkOptions.bUseBBCOnAttacmentsAsNews); CreateLink(m_cbStikersAsSmyles, m_proto->m_vkOptions.bStikersAsSmileys); CreateLink(m_cbShortenLinksForAudio, m_proto->m_vkOptions.bShortenLinksForAudio); CreateLink(m_cbAddMessageLinkToMesWAtt, m_proto->m_vkOptions.bAddMessageLinkToMesWAtt); CreateLink(m_cbUseNonStandardNotifications, m_proto->m_vkOptions.bUseNonStandardNotifications); + CreateLink(m_cbShowBeforeEditedPostVersion, m_proto->m_vkOptions.bShowBeforeEditedPostVersion); + + m_cbBBCSupportForNewStory.OnChange = Callback(this, &CVkOptionViewForm::On_cbBBCSupportForNewStory); } + bool CVkOptionViewForm::OnInitDialog() { + On_cbBBCSupportForNewStory(&m_cbBBCSupportForNewStory); + 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); @@ -500,6 +509,38 @@ bool CVkOptionViewForm::OnApply() return true; } +void CVkOptionViewForm::On_cbBBCSupportForNewStory(CCtrlCheck*) +{ + bool bState = m_cbBBCSupportForNewStory.GetState() != 0; + + if (bState) { + m_cbIMGBBCSupportOff.SetState(false); + m_cbIMGBBCSupportFullSize.SetState(true); + m_cbIMGBBCSupport130.SetState(false); + m_cbIMGBBCSupport604.SetState(false); + m_cbBBCForNewsOff.SetState(false); + m_cbBBCForNewsBasic.SetState(false); + m_cbBBCForNewsAdvanced.SetState(true); + m_cbBBCForAttachmentsOff.SetState(false); + m_cbBBCForAttachmentsBasic.SetState(false); + m_cbBBCForAttachmentsAdvanced.SetState(true); + m_cbUseBBCOnAttacmentsAsNews.SetState(true); + } + + m_cbIMGBBCSupportOff.Enable(!bState); + m_cbIMGBBCSupportFullSize.Enable(!bState); + m_cbIMGBBCSupport130.Enable(!bState); + m_cbIMGBBCSupport604.Enable(!bState); + m_cbBBCForNewsOff.Enable(!bState); + m_cbBBCForNewsBasic.Enable(!bState); + m_cbBBCForNewsAdvanced.Enable(!bState); + m_cbBBCForAttachmentsOff.Enable(!bState); + m_cbBBCForAttachmentsBasic.Enable(!bState); + m_cbBBCForAttachmentsAdvanced.Enable(!bState); + m_cbUseBBCOnAttacmentsAsNews.Enable(!bState); + +} + ////////////////////// Menu page ///////////////////////////////////////////// CVkOptionMenuForm::CVkOptionMenuForm(CVkProto *proto) : diff --git a/protocols/VKontakte/src/vk_options.h b/protocols/VKontakte/src/vk_options.h index f3ac894fd2..e78f9503a8 100644 --- a/protocols/VKontakte/src/vk_options.h +++ b/protocols/VKontakte/src/vk_options.h @@ -130,6 +130,7 @@ public: class CVkOptionViewForm : public CVkDlgBase { + CCtrlCheck m_cbBBCSupportForNewStory; CCtrlCheck m_cbIMGBBCSupportOff; CCtrlCheck m_cbIMGBBCSupportFullSize; CCtrlCheck m_cbIMGBBCSupport130; @@ -149,11 +150,13 @@ class CVkOptionViewForm : public CVkDlgBase CCtrlCheck m_cbShortenLinksForAudio; CCtrlCheck m_cbAddMessageLinkToMesWAtt; CCtrlCheck m_cbUseNonStandardNotifications; + CCtrlCheck m_cbShowBeforeEditedPostVersion; public: CVkOptionViewForm(CVkProto *proto); bool OnInitDialog() override; bool OnApply() override; + void On_cbBBCSupportForNewStory(CCtrlCheck*); }; ////////////////////// Menu page ///////////////////////////////////////////// diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index e728621b22..5ef9bba4d4 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -289,7 +289,7 @@ private: //==== Files Download ================================================================ - CMStringW CVkProto::GetVkFileItem(CMStringW& wszUrl, MCONTACT hContact, VKMessageID_t iMessageId, bool bAsync); + CMStringW CVkProto::GetVkFileItem(CMStringW& wszUrl, MCONTACT hContact, VKMessageID_t iMessageId); void OnGetVkFileItem(MHttpResponse* reply, AsyncHttpRequest* pReq); //==== Files Upload ================================================================== @@ -389,12 +389,12 @@ private: char* GetStickerId(const char *szMsg, int& iStickerid); 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, bool bAsync); + CMStringW GetVkPhotoItem(const JSONNode &jnPhoto, BBCSupport iBBC, 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, bool bAsync); - CMStringW GetFwdMessage(const JSONNode& jnMsg, const JSONNode& jnFUsers, OBJLIST& vkUsers, BBCSupport iBBC, bool bAsync); - CMStringW GetFwdMessages(const JSONNode &jnMessages, const JSONNode &jnFUsers, BBCSupport iBBC, bool bAsync); + CMStringW GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport iBBC, MCONTACT hContact, VKMessageID_t iMessageId); + CMStringW GetFwdMessage(const JSONNode& jnMsg, const JSONNode& jnFUsers, OBJLIST& vkUsers, BBCSupport iBBC); + CMStringW GetFwdMessages(const JSONNode &jnMessages, const JSONNode &jnFUsers, BBCSupport iBBC); void SetInvisible(MCONTACT hContact); CMStringW RemoveBBC(CMStringW& wszSrc); void AddVkDeactivateEvent(MCONTACT hContact, CMStringW & wszType); diff --git a/protocols/VKontakte/src/vk_struct.cpp b/protocols/VKontakte/src/vk_struct.cpp index d0386bbe3e..803c465b5e 100644 --- a/protocols/VKontakte/src/vk_struct.cpp +++ b/protocols/VKontakte/src/vk_struct.cpp @@ -136,6 +136,13 @@ CVkFileUploadParam::VKFileType CVkFileUploadParam::GetType() ///////////////////////////////////////////////////////////////////////////////////////// +CVkFileDownloadParam::~CVkFileDownloadParam() +{ + mir_free(wszFileName); +} + +///////////////////////////////////////////////////////////////////////////////////////// + CVkChatUser* CVkChatInfo::GetUserById(LPCWSTR pwszId) { VKUserID_t iUserId = _wtol(pwszId); @@ -213,6 +220,8 @@ CVKOptions::CVKOptions(PROTO_INTERFACE* proto) : iMusicSendMetod(proto, "MusicSendMetod", MusicSendMetod::sendBroadcastOnly), bPopupContactsMusic(proto, "PopupContactsMusic", false), iSyncHistoryMetod(proto, "SyncHistoryMetod", SyncHistoryMetod::syncOff), + bShowBeforeEditedPostVersion(proto, "ShowBeforeEditedPostVersion", true), + bLoadFilesAsync(proto, "LoadFilesAsync", true), bBBCNewStorySupport(proto, "BBCNewStorySupport", false), iIMGBBCSupport(proto, "IMGBBCSupport", IMGBBCSypport::imgNo), iBBCForNews(proto, "BBCForNews", BBCSupport::bbcBasic), diff --git a/protocols/VKontakte/src/vk_struct.h b/protocols/VKontakte/src/vk_struct.h index 6bd59031db..dfcfd994d6 100644 --- a/protocols/VKontakte/src/vk_struct.h +++ b/protocols/VKontakte/src/vk_struct.h @@ -53,6 +53,21 @@ struct CVkFileUploadParam : public MZeroedObject { __forceinline char* fileName() { GetType(); return szFname; } }; +struct CVkFileDownloadParam : public MZeroedObject +{ + CVkFileDownloadParam(MCONTACT _hContact, VKMessageID_t _iMsgID, const wchar_t* _wszFileName) : + hContact(_hContact), + iMsgID(_iMsgID), + wszFileName(mir_wstrdup(_wszFileName)) + {} + + ~CVkFileDownloadParam(); + + MCONTACT hContact; + VKMessageID_t iMsgID; + wchar_t* wszFileName; +}; + struct CVkSendMsgParam : public MZeroedObject { CVkSendMsgParam(MCONTACT _hContact, VKMessageID_t _iMsgID = 0, int _iCount = 0) : @@ -260,6 +275,8 @@ struct CVKOptions { CMOption bNotificationsEnabled; CMOption bNotificationsMarkAsViewed; CMOption bSpecialContactAlwaysEnabled; + CMOption bShowBeforeEditedPostVersion; + CMOption bLoadFilesAsync; CMOption bBBCNewStorySupport; CMOption iIMGBBCSupport; CMOption iBBCForNews; -- cgit v1.2.3