From bc577693d6c669690d44433e7036340d77f35b99 Mon Sep 17 00:00:00 2001 From: ElzorFox Date: Mon, 4 Dec 2023 13:57:44 +0500 Subject: VKontakte: add reply to message support version bump --- protocols/VKontakte/res/reply.ico | Bin 0 -> 4286 bytes protocols/VKontakte/res/resource.rc | 2 ++ protocols/VKontakte/src/misc.cpp | 3 +- protocols/VKontakte/src/resource.h | 9 +++--- protocols/VKontakte/src/stdafx.h | 1 + protocols/VKontakte/src/version.h | 2 +- protocols/VKontakte/src/vk.h | 2 +- protocols/VKontakte/src/vk_messages.cpp | 11 ++++++-- protocols/VKontakte/src/vk_proto.cpp | 39 ++++++++++++++++++++++++++ protocols/VKontakte/src/vk_proto.h | 12 ++++++-- protocols/VKontakte/vk.vcxproj | 17 ++++++++++++ protocols/VKontakte/vk.vcxproj.filters | 47 ++++++++++++++++++++++++++++++++ 12 files changed, 134 insertions(+), 11 deletions(-) create mode 100644 protocols/VKontakte/res/reply.ico (limited to 'protocols/VKontakte') diff --git a/protocols/VKontakte/res/reply.ico b/protocols/VKontakte/res/reply.ico new file mode 100644 index 0000000000..b3fa558b6f Binary files /dev/null and b/protocols/VKontakte/res/reply.ico differ diff --git a/protocols/VKontakte/res/resource.rc b/protocols/VKontakte/res/resource.rc index 6c5f7ecdd1..521d06721e 100644 --- a/protocols/VKontakte/res/resource.rc +++ b/protocols/VKontakte/res/resource.rc @@ -49,6 +49,8 @@ IDI_WALL ICON "wall.ico" IDI_MARKMESSAGESASREAD ICON "markread.ico" +IDI_REPLY ICON "reply.ico" + ///////////////////////////////////////////////////////////////////////////// // diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index f6b6aff3ce..d0d092c6ae 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -61,7 +61,8 @@ static IconItem iconList[] = { LPGEN("Broadcast icon"), "broadcast", IDI_BROADCAST }, { LPGEN("Status icon"), "status", IDI_STATUS }, { LPGEN("Wall message icon"), "wall", IDI_WALL }, - { LPGEN("Mark messages as read icon"), "markread", IDI_MARKMESSAGESASREAD } + { LPGEN("Mark messages as read icon"), "markread", IDI_MARKMESSAGESASREAD }, + { LPGEN("Reply icon"), "reply", IDI_REPLY } }; void InitIcons() diff --git a/protocols/VKontakte/src/resource.h b/protocols/VKontakte/src/resource.h index c160ca0e2a..fc8fbfd354 100644 --- a/protocols/VKontakte/src/resource.h +++ b/protocols/VKontakte/src/resource.h @@ -1,6 +1,6 @@ //{{NO_DEPENDENCIES}} -// Включаемый файл, созданный в Microsoft Visual C++. -// Используется d:\github\miranda-ng\protocols\VKontakte\res\resource.rc +// , Microsoft Visual C++. +// e:\github\miranda-ng\protocols\VKontakte\res\resource.rc // #define IDOPENBROWSER 3 #define IDD_ACCMGRUI 101 @@ -26,6 +26,7 @@ #define IDI_MARKMESSAGESASREAD 122 #define IDD_OPT_MENU 122 #define IDD_CONTACTDELETE 123 +#define IDI_REPLY 125 #define IDC_LOGIN 1001 #define IDC_PASSWORD 1002 #define IDC_URL 1003 @@ -132,11 +133,11 @@ #define IDC_CH_CLEARHISTORY 1116 // Next default values for new objects -// +// #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NO_MFC 1 -#define _APS_NEXT_RESOURCE_VALUE 124 +#define _APS_NEXT_RESOURCE_VALUE 126 #define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_CONTROL_VALUE 1116 #define _APS_NEXT_SYMED_VALUE 101 diff --git a/protocols/VKontakte/src/stdafx.h b/protocols/VKontakte/src/stdafx.h index 04c0aae0c4..de273fd377 100644 --- a/protocols/VKontakte/src/stdafx.h +++ b/protocols/VKontakte/src/stdafx.h @@ -54,6 +54,7 @@ along with this program. If not, see . #include #include #include +#include #include "resource.h" #include "vk.h" diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h index 1af511c2ae..dbd5b70c91 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 15 -#define __BUILD_NUM 2 +#define __BUILD_NUM 3 #include diff --git a/protocols/VKontakte/src/vk.h b/protocols/VKontakte/src/vk.h index 56f24f8c99..f0b1b0a97d 100644 --- a/protocols/VKontakte/src/vk.h +++ b/protocols/VKontakte/src/vk.h @@ -121,4 +121,4 @@ bool IsEmpty(LPCWSTR str); bool IsEmpty(LPCSTR str); typedef long VKUserID_t; -typedef long VKMessageID_t; +typedef long VKMessageID_t; \ No newline at end of file diff --git a/protocols/VKontakte/src/vk_messages.cpp b/protocols/VKontakte/src/vk_messages.cpp index 23b332be39..4220deb3f1 100644 --- a/protocols/VKontakte/src/vk_messages.cpp +++ b/protocols/VKontakte/src/vk_messages.cpp @@ -19,9 +19,9 @@ along with this program. If not, see . ////////////////////////////////////////////////////////////////////////////// -int CVkProto::SendMsg(MCONTACT hContact, MEVENT, const char *szMsg) +int CVkProto::SendMsg(MCONTACT hContact, MEVENT hReplyEvent, const char *szMsg) { - debugLogA("CVkProto::SendMsg"); + debugLogA("CVkProto::SendMsg hReplyEvent = %d", hReplyEvent); if (!IsOnline()) return -1; @@ -42,6 +42,13 @@ int CVkProto::SendMsg(MCONTACT hContact, MEVENT, const char *szMsg) pReq << INT_PARAM(bIsChat ? "chat_id" : "peer_id", iUserId) << INT_PARAM("random_id", ((long)time(0)) * 100 + uMsgId % 100); pReq->AddHeader("Content-Type", "application/x-www-form-urlencoded"); + + if (hReplyEvent) { + DB::EventInfo dbei(hReplyEvent, false); + if (dbei && mir_strlen(dbei.szId)) + pReq << CHAR_PARAM("reply_to", dbei.szId); + } + if (StickerId) pReq << INT_PARAM("sticker_id", StickerId); else { diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index a90c60e564..a56e7697d1 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -209,6 +209,20 @@ void CVkProto::OnBuildProtoMenu() void CVkProto::InitMenus() { HookProtoEvent(ME_CLIST_PREBUILDCONTACTMENU, &CVkProto::OnPreBuildContactMenu); + + if(HookProtoEvent(ME_NS_PREBUILDMENU, &CVkProto::OnPrebuildNSMenu)) { + CreateProtoService(PS_NSEXECMENU, &CVkProto::SvcNSExecMenu); + + CMStringA szServiceName(FORMAT, "%s%s", m_szModuleName, PS_NSEXECMENU); + CMenuItem mi(&g_plugin); + + mi.pszService = szServiceName; + mi.hIcolibItem = g_plugin.getIconHandle(IDI_REPLY); + + mi.position = 10000000 + NSMI_REPLY; + mi.name.a = LPGEN("Reply"); + m_hNewStoryReply = Menu_AddNewStoryMenuItem(&mi, NSMI_REPLY); + }; //Contact Menu Services CreateProtoService(PS_GETSERVERHISTORYLAST1DAY, &CVkProto::SvcGetServerHistoryLastNDay<1>); @@ -401,6 +415,31 @@ int CVkProto::OnPreBuildContactMenu(WPARAM hContact, LPARAM) return 0; } +int CVkProto::OnPrebuildNSMenu(WPARAM hContact, LPARAM lParam) +{ + if (!Proto_IsProtoOnContact(hContact, m_szModuleName)) + Menu_ShowItem(m_hNewStoryReply, false); + else { + auto* pDbei = (DB::EventInfo *)lParam; + Menu_ShowItem(m_hNewStoryReply, mir_strlen(pDbei->szId) > 0 && !Contact::IsReadonly(hContact)); + } + return 0; +} + +INT_PTR CVkProto::SvcNSExecMenu(WPARAM iCommand, LPARAM pHandle) +{ + MEVENT hCurrentEvent = NS_GetCurrent((HANDLE)pHandle); + + switch (iCommand) { + case NSMI_REPLY: // reply + if (hCurrentEvent != -1) + if (auto* pDlg = NS_GetSrmm((HANDLE)pHandle)) + pDlg->SetQuoteEvent(hCurrentEvent); + break; + } + return 0; +} + void CVkProto::UnInitMenus() { debugLogA("CVkProto::UnInitMenus"); diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index 74f164838b..a86bb39e28 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -40,6 +40,7 @@ along with this program. If not, see . #define PS_CHATCHANGETOPIC "/ChatChangeTopic" #define PS_CHATINVITEUSER "/ChatInviteUser" #define PS_CHATDESTROY "/ChatDestroy" +#define PS_NSEXECMENU "/NSExecMenu" @@ -66,7 +67,7 @@ struct CVkProto : public PROTO HANDLE SearchBasic(const wchar_t *id) override; HANDLE SearchByEmail(const wchar_t *email) override; HANDLE SearchByName(const wchar_t *nick, const wchar_t *firstName, const wchar_t *lastName) override; - int SendMsg(MCONTACT hContact, MEVENT, const char *msg) override; + int SendMsg(MCONTACT hContact, MEVENT hReplyEvent, const char *msg) override; HANDLE SendFile(MCONTACT hContact, const wchar_t *szDescription, wchar_t **ppszFiles) override; int SetStatus(int iNewStatus) override; int UserIsTyping(MCONTACT hContact, int type) override; @@ -106,6 +107,7 @@ struct CVkProto : public PROTO INT_PTR __cdecl SvcChatChangeTopic(WPARAM hContact, LPARAM); INT_PTR __cdecl SvcChatInviteUser(WPARAM hContact, LPARAM); INT_PTR __cdecl SvcChatDestroy(WPARAM hContact, LPARAM); + INT_PTR __cdecl SvcNSExecMenu(WPARAM iCommand, LPARAM pHandle); //==== History Menus ================================================================== @@ -188,6 +190,10 @@ private: PMI_COUNT }; + enum NewStoryMenuIndexes { + NSMI_REPLY = 1 + }; + //==================================================================================== bool @@ -245,7 +251,8 @@ private: HGENMENU m_hContactMenuItems[CMI_COUNT], m_hContactHistoryMenuItems[CHMI_COUNT], - m_hProtoMenuItems[PMI_COUNT]; + m_hProtoMenuItems[PMI_COUNT], + m_hNewStoryReply; void InitSmileys(); @@ -255,6 +262,7 @@ private: void InitMenus(); void UnInitMenus(); int __cdecl OnPreBuildContactMenu(WPARAM hContact, LPARAM); + int __cdecl OnPrebuildNSMenu(WPARAM hContact, LPARAM); //==== PopUps ======================================================================== diff --git a/protocols/VKontakte/vk.vcxproj b/protocols/VKontakte/vk.vcxproj index e7fb2c7410..39a96a72d8 100644 --- a/protocols/VKontakte/vk.vcxproj +++ b/protocols/VKontakte/vk.vcxproj @@ -69,4 +69,21 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/protocols/VKontakte/vk.vcxproj.filters b/protocols/VKontakte/vk.vcxproj.filters index d3161d831c..facbd0fb86 100644 --- a/protocols/VKontakte/vk.vcxproj.filters +++ b/protocols/VKontakte/vk.vcxproj.filters @@ -97,4 +97,51 @@ Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + \ No newline at end of file -- cgit v1.2.3