From 4b9e39a3ea97bfb34fab1803df542f766b730e9b Mon Sep 17 00:00:00 2001 From: Sergey Bolhovskoy Date: Thu, 7 Apr 2016 10:37:53 +0000 Subject: VKontakte: add settings for show/hide proto menu items git-svn-id: http://svn.miranda-ng.org/main/trunk@16602 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/VKontakte/res/resource.rc | 25 +++++++- protocols/VKontakte/src/resource.h | 13 +++- protocols/VKontakte/src/vk_options.cpp | 36 +++++++++++ protocols/VKontakte/src/vk_options.h | 19 ++++++ protocols/VKontakte/src/vk_proto.cpp | 107 +++++++++++++++++++-------------- protocols/VKontakte/src/vk_struct.cpp | 9 +++ protocols/VKontakte/src/vk_struct.h | 10 ++- 7 files changed, 170 insertions(+), 49 deletions(-) (limited to 'protocols') diff --git a/protocols/VKontakte/res/resource.rc b/protocols/VKontakte/res/resource.rc index 8a3a99abc7..981d623c7d 100644 --- a/protocols/VKontakte/res/resource.rc +++ b/protocols/VKontakte/res/resource.rc @@ -60,6 +60,14 @@ IDI_MARKMESSAGESASREAD ICON "markread.ico" #ifdef APSTUDIO_INVOKED GUIDELINES DESIGNINFO BEGIN + IDD_OPT_MENU, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 302 + TOPMARGIN, 7 + BOTTOMMARGIN, 105 + END + IDD_OPT_VIEW, DIALOG BEGIN LEFTMARGIN, 4 @@ -137,6 +145,21 @@ END // Dialog // +IDD_OPT_MENU DIALOGEX 0, 0, 309, 112 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + GROUPBOX "Show in protocol menu ",IDC_STATIC,7,8,295,93 + CONTROL "Create new chat",IDC_SHOW_MENU0,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,19,280,10 + CONTROL "Status message",IDC_SHOW_MENU1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,30,280,10 + CONTROL "Send message to my wall",IDC_SHOW_MENU2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,41,280,10 + CONTROL "Load news from VK",IDC_SHOW_MENU3,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,52,280,10 + CONTROL "Load history for all contacts from VK",IDC_SHOW_MENU4,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,63,280,10 + CONTROL "Wipe contacts missing in friend list",IDC_SHOW_MENU5,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,74,280,10 + CONTROL "Visit profile",IDC_SHOW_MENU6,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,85,280,10 +END + IDD_OPT_VIEW DIALOGEX 0, 0, 304, 184 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD EXSTYLE WS_EX_CONTROLPARENT @@ -153,7 +176,7 @@ BEGIN CONTROL "advanced (+[url], [size], [color], [code])",IDC_NEWSBBC_ADV, "Button",BS_AUTORADIOBUTTON,154,61,129,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 + "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 diff --git a/protocols/VKontakte/src/resource.h b/protocols/VKontakte/src/resource.h index c56f5cce12..1a4dfb007a 100644 --- a/protocols/VKontakte/src/resource.h +++ b/protocols/VKontakte/src/resource.h @@ -2,7 +2,6 @@ // Включаемый файл, созданный в Microsoft Visual C++. // Используется d:\svn\protocols\VKontakte\res\resource.rc // - #define IDOPENBROWSER 3 #define IDD_ACCMGRUI 101 #define IDD_CAPTCHAFORM 102 @@ -25,6 +24,7 @@ #define IDD_WALLPOST 120 #define IDI_WALL 121 #define IDI_MARKMESSAGESASREAD 122 +#define IDD_OPT_MENU 122 #define IDI_KEYS 203 #define IDC_LOGIN 1001 #define IDC_PASSWORD 1002 @@ -114,15 +114,22 @@ #define IDC_USENOSTDPOPUPS 1098 #define IDC_RET_CHAT_MES 1099 #define IDC_COMBO_LANGUAGE 1100 +#define IDC_SHOW_MENU0 1101 +#define IDC_SHOW_MENU1 1102 +#define IDC_SHOW_MENU2 1103 +#define IDC_SHOW_MENU3 1104 +#define IDC_SHOW_MENU4 1105 +#define IDC_SHOW_MENU5 1106 +#define IDC_SHOW_MENU6 1107 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NO_MFC 1 -#define _APS_NEXT_RESOURCE_VALUE 122 +#define _APS_NEXT_RESOURCE_VALUE 123 #define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1101 +#define _APS_NEXT_CONTROL_VALUE 1108 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/protocols/VKontakte/src/vk_options.cpp b/protocols/VKontakte/src/vk_options.cpp index 178a9e37c9..abbb3e8387 100644 --- a/protocols/VKontakte/src/vk_options.cpp +++ b/protocols/VKontakte/src/vk_options.cpp @@ -101,6 +101,11 @@ int CVkProto::OnOptionsInit(WPARAM wParam, LPARAM) odp.pDialog = new CVkOptionViewForm(this); Options_AddPage(wParam, &odp); + odp.ptszTab = LPGENT("Menu"); + odp.position = 5; + odp.pDialog = new CVkOptionMenuForm(this); + Options_AddPage(wParam, &odp); + return 0; } @@ -455,3 +460,34 @@ void CVkOptionViewForm::OnApply() m_proto->m_vkOptions.iBBCForAttachments = BBCSupport::bbcAdvanced; } +////////////////////// Menu page ///////////////////////////////////////////// + +CVkOptionMenuForm::CVkOptionMenuForm(CVkProto *proto): + CVkDlgBase(proto, IDD_OPT_MENU, false), + m_cbMenuEnabled0(this, IDC_SHOW_MENU0), + m_cbMenuEnabled1(this, IDC_SHOW_MENU1), + m_cbMenuEnabled2(this, IDC_SHOW_MENU2), + m_cbMenuEnabled3(this, IDC_SHOW_MENU3), + m_cbMenuEnabled4(this, IDC_SHOW_MENU4), + m_cbMenuEnabled5(this, IDC_SHOW_MENU5), + m_cbMenuEnabled6(this, IDC_SHOW_MENU6), + m_proto(proto) +{ + CreateLink(m_cbMenuEnabled0, m_proto->m_vkOptions.bShowProtoMenuItem0); + CreateLink(m_cbMenuEnabled1, m_proto->m_vkOptions.bShowProtoMenuItem1); + CreateLink(m_cbMenuEnabled2, m_proto->m_vkOptions.bShowProtoMenuItem2); + CreateLink(m_cbMenuEnabled3, m_proto->m_vkOptions.bShowProtoMenuItem3); + CreateLink(m_cbMenuEnabled4, m_proto->m_vkOptions.bShowProtoMenuItem4); + CreateLink(m_cbMenuEnabled5, m_proto->m_vkOptions.bShowProtoMenuItem5); + CreateLink(m_cbMenuEnabled6, m_proto->m_vkOptions.bShowProtoMenuItem6); +} + +void CVkOptionMenuForm::OnApply() +{ + if (MessageBox(NULL, + TranslateT("These changes will take effect after Miranda NG restart.\nWould you like to restart it now?"), + TranslateT("VKontakte protocol"), MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2) == IDYES) + CallServiceSync(MS_SYSTEM_RESTART, 1, 0); +} + + diff --git a/protocols/VKontakte/src/vk_options.h b/protocols/VKontakte/src/vk_options.h index 1d024b0137..5ce09c91a4 100644 --- a/protocols/VKontakte/src/vk_options.h +++ b/protocols/VKontakte/src/vk_options.h @@ -180,4 +180,23 @@ public: CVkOptionViewForm(CVkProto *proto); void OnInitDialog(); void OnApply(); +}; + +////////////////////// Menu page ///////////////////////////////////////////// + +class CVkOptionMenuForm : public CVkDlgBase +{ + CCtrlCheck m_cbMenuEnabled0; + CCtrlCheck m_cbMenuEnabled1; + CCtrlCheck m_cbMenuEnabled2; + CCtrlCheck m_cbMenuEnabled3; + CCtrlCheck m_cbMenuEnabled4; + CCtrlCheck m_cbMenuEnabled5; + CCtrlCheck m_cbMenuEnabled6; + + CVkProto *m_proto; + +public: + CVkOptionMenuForm(CVkProto *proto); + void OnApply(); }; \ No newline at end of file diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index f4b87918d7..5f015cde7b 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -156,65 +156,83 @@ void CVkProto::InitMenus() CreateProtoService(PS_WALLPOST, &CVkProto::SvcWallPost); CreateProtoService(PS_MARKMESSAGESASREAD, &CVkProto::SvcMarkMessagesAsRead); + for (int i = 0; i < PMI_COUNT; i++) + m_hProtoMenuItems[i] = 0; + CMenuItem mi; mi.root = Menu_GetProtocolRoot(this); // Proto menu - mi.pszService = PS_CREATECHAT; - mi.position = 10009 + PMI_CREATECHAT; - mi.hIcolibItem = Skin_GetIconHandle(SKINICON_CHAT_JOIN); - mi.name.a = LPGEN("Create new chat"); - SET_UID(mi, 0xc217748d, 0x7218, 0x4a62, 0xab, 0x37, 0x9, 0x58, 0x6a, 0x88, 0x71, 0x3e); - m_hProtoMenuItems[PMI_CREATECHAT] = Menu_AddProtoMenuItem(&mi, m_szModuleName); - - mi.pszService = PS_SETSTATUSMSG; - mi.position = 10009 + PMI_SETSTATUSMSG; - mi.hIcolibItem = IcoLib_GetIconByHandle(GetIconHandle(IDI_STATUS)); - mi.name.a = LPGEN("Status message"); - SET_UID(mi, 0x696bd932, 0xeee4, 0x4c4c, 0xa6, 0xf8, 0xb3, 0x72, 0xdf, 0xc6, 0xfa, 0xd1); - m_hProtoMenuItems[PMI_SETSTATUSMSG] = Menu_AddProtoMenuItem(&mi, m_szModuleName); + if (m_vkOptions.bShowProtoMenuItem0) { + mi.pszService = PS_CREATECHAT; + mi.position = 10009 + PMI_CREATECHAT; + mi.hIcolibItem = Skin_GetIconHandle(SKINICON_CHAT_JOIN); + mi.name.a = LPGEN("Create new chat"); + SET_UID(mi, 0xc217748d, 0x7218, 0x4a62, 0xab, 0x37, 0x9, 0x58, 0x6a, 0x88, 0x71, 0x3e); + m_hProtoMenuItems[PMI_CREATECHAT] = Menu_AddProtoMenuItem(&mi, m_szModuleName); + } - mi.pszService = PS_WALLPOST; - mi.position = 10009 + PMI_WALLPOST; - mi.hIcolibItem = IcoLib_GetIconByHandle(GetIconHandle(IDI_WALL)); - mi.name.a = LPGEN("Send message to my wall"); - SET_UID(mi, 0x50a80044, 0xdddd, 0x47e6, 0x9e, 0x90, 0x32, 0x7b, 0x88, 0x13, 0x21, 0x4e); - m_hProtoMenuItems[PMI_WALLPOST] = Menu_AddProtoMenuItem(&mi, m_szModuleName); + if (m_vkOptions.bShowProtoMenuItem1) { + mi.pszService = PS_SETSTATUSMSG; + mi.position = 10009 + PMI_SETSTATUSMSG; + mi.hIcolibItem = IcoLib_GetIconByHandle(GetIconHandle(IDI_STATUS)); + mi.name.a = LPGEN("Status message"); + SET_UID(mi, 0x696bd932, 0xeee4, 0x4c4c, 0xa6, 0xf8, 0xb3, 0x72, 0xdf, 0xc6, 0xfa, 0xd1); + m_hProtoMenuItems[PMI_SETSTATUSMSG] = Menu_AddProtoMenuItem(&mi, m_szModuleName); + } - mi.pszService = PS_LOADVKNEWS; - mi.position = 10009 + PMI_LOADVKNEWS; - mi.hIcolibItem = IcoLib_GetIconByHandle(GetIconHandle(IDI_NOTIFICATION)); - mi.name.a = LPGEN("Load news from VK"); - SET_UID(mi, 0x7c449456, 0xb731, 0x48cc, 0x9c, 0x4e, 0x20, 0xe4, 0x66, 0x7a, 0x16, 0x23); - m_hProtoMenuItems[PMI_LOADVKNEWS] = Menu_AddProtoMenuItem(&mi, m_szModuleName); + if (m_vkOptions.bShowProtoMenuItem2) { + mi.pszService = PS_WALLPOST; + mi.position = 10009 + PMI_WALLPOST; + mi.hIcolibItem = IcoLib_GetIconByHandle(GetIconHandle(IDI_WALL)); + mi.name.a = LPGEN("Send message to my wall"); + SET_UID(mi, 0x50a80044, 0xdddd, 0x47e6, 0x9e, 0x90, 0x32, 0x7b, 0x88, 0x13, 0x21, 0x4e); + m_hProtoMenuItems[PMI_WALLPOST] = Menu_AddProtoMenuItem(&mi, m_szModuleName); + } - mi.pszService = PS_GETALLSERVERHISTORY; - mi.position = 10009 + PMI_GETALLSERVERHISTORY; - mi.hIcolibItem = IcoLib_GetIconByHandle(GetIconHandle(IDI_HISTORY)); - mi.name.a = LPGEN("Load history for all contacts from VK"); - SET_UID(mi, 0xe5028605, 0x92eb, 0x4956, 0xa0, 0xd0, 0x53, 0xb, 0x11, 0x44, 0x8f, 0x14); - m_hProtoMenuItems[PMI_GETALLSERVERHISTORY] = Menu_AddProtoMenuItem(&mi, m_szModuleName); + if (m_vkOptions.bShowProtoMenuItem3) { + mi.pszService = PS_LOADVKNEWS; + mi.position = 10009 + PMI_LOADVKNEWS; + mi.hIcolibItem = IcoLib_GetIconByHandle(GetIconHandle(IDI_NOTIFICATION)); + mi.name.a = LPGEN("Load news from VK"); + SET_UID(mi, 0x7c449456, 0xb731, 0x48cc, 0x9c, 0x4e, 0x20, 0xe4, 0x66, 0x7a, 0x16, 0x23); + m_hProtoMenuItems[PMI_LOADVKNEWS] = Menu_AddProtoMenuItem(&mi, m_szModuleName); + } - mi.pszService = PS_WIPENONFRIENDS; - mi.position = 10009 + PMI_WIPENONFRIENDS; - mi.hIcolibItem = IcoLib_GetIconByHandle(GetIconHandle(IDI_FRIENDDEL)); - mi.name.a = LPGEN("Wipe contacts missing in friend list"); - SET_UID(mi, 0xcfe99159, 0xf237, 0x4546, 0x80, 0x3e, 0x51, 0x88, 0x26, 0x55, 0xdc, 0x5f); - m_hProtoMenuItems[PMI_WIPENONFRIENDS] = Menu_AddProtoMenuItem(&mi, m_szModuleName); + if (m_vkOptions.bShowProtoMenuItem4) { + mi.pszService = PS_GETALLSERVERHISTORY; + mi.position = 10009 + PMI_GETALLSERVERHISTORY; + mi.hIcolibItem = IcoLib_GetIconByHandle(GetIconHandle(IDI_HISTORY)); + mi.name.a = LPGEN("Load history for all contacts from VK"); + SET_UID(mi, 0xe5028605, 0x92eb, 0x4956, 0xa0, 0xd0, 0x53, 0xb, 0x11, 0x44, 0x8f, 0x14); + m_hProtoMenuItems[PMI_GETALLSERVERHISTORY] = Menu_AddProtoMenuItem(&mi, m_szModuleName); + } - mi.pszService = PS_VISITPROFILE; - mi.position = 10009 + PMI_VISITPROFILE; - mi.hIcolibItem = IcoLib_GetIconByHandle(GetIconHandle(IDI_VISITPROFILE)); - mi.name.a = LPGEN("Visit profile"); - SET_UID(mi, 0x9550515e, 0x2a45, 0x4913, 0x95, 0x1a, 0x1e, 0xfa, 0x7, 0xc6, 0x2d, 0x60); - m_hProtoMenuItems[PMI_VISITPROFILE] = Menu_AddProtoMenuItem(&mi, m_szModuleName); + if (m_vkOptions.bShowProtoMenuItem5) { + mi.pszService = PS_WIPENONFRIENDS; + mi.position = 10009 + PMI_WIPENONFRIENDS; + mi.hIcolibItem = IcoLib_GetIconByHandle(GetIconHandle(IDI_FRIENDDEL)); + mi.name.a = LPGEN("Wipe contacts missing in friend list"); + SET_UID(mi, 0xcfe99159, 0xf237, 0x4546, 0x80, 0x3e, 0x51, 0x88, 0x26, 0x55, 0xdc, 0x5f); + m_hProtoMenuItems[PMI_WIPENONFRIENDS] = Menu_AddProtoMenuItem(&mi, m_szModuleName); + } + if (m_vkOptions.bShowProtoMenuItem6) { + mi.pszService = PS_VISITPROFILE; + mi.position = 10009 + PMI_VISITPROFILE; + mi.hIcolibItem = IcoLib_GetIconByHandle(GetIconHandle(IDI_VISITPROFILE)); + mi.name.a = LPGEN("Visit profile"); + SET_UID(mi, 0x9550515e, 0x2a45, 0x4913, 0x95, 0x1a, 0x1e, 0xfa, 0x7, 0xc6, 0x2d, 0x60); + m_hProtoMenuItems[PMI_VISITPROFILE] = Menu_AddProtoMenuItem(&mi, m_szModuleName); + } + // Contact Menu Items mi.root = NULL; mi.flags = CMIF_TCHAR; mi.pszService = PS_VISITPROFILE; mi.position = -200001000 + CMI_VISITPROFILE; + mi.hIcolibItem = IcoLib_GetIconByHandle(GetIconHandle(IDI_VISITPROFILE)); mi.name.t = LPGENT("Visit profile"); SET_UID(mi, 0x828cc50e, 0x398d, 0x43a2, 0xbf, 0xd3, 0xa9, 0x96, 0x47, 0x9d, 0x52, 0xff); m_hContactMenuItems[CMI_VISITPROFILE] = Menu_AddContactMenuItem(&mi, m_szModuleName); @@ -360,7 +378,8 @@ void CVkProto::UnInitMenus() { debugLogA("CVkProto::UnInitMenus"); for (int i = 0; i < PMI_COUNT; i++) - Menu_RemoveItem(m_hProtoMenuItems[i]); + if (m_hProtoMenuItems[i]) + Menu_RemoveItem(m_hProtoMenuItems[i]); for (int i = 0; i < CHMI_COUNT; i++) Menu_RemoveItem(m_hContactHistoryMenuItems[i]); diff --git a/protocols/VKontakte/src/vk_struct.cpp b/protocols/VKontakte/src/vk_struct.cpp index e01fb08b6a..779aab9641 100644 --- a/protocols/VKontakte/src/vk_struct.cpp +++ b/protocols/VKontakte/src/vk_struct.cpp @@ -209,6 +209,14 @@ CVKOptions::CVKOptions(PROTO_INTERFACE *proto) : bSyncReadMessageStatusFromServer(proto, "SyncReadMessageStatusFromServer", false), bLoadFullCList(proto, "LoadFullCList", false), + bShowProtoMenuItem0(proto, "ShowProtoMenuItem0", true), + bShowProtoMenuItem1(proto, "ShowProtoMenuItem1", true), + bShowProtoMenuItem2(proto, "ShowProtoMenuItem2", true), + bShowProtoMenuItem3(proto, "ShowProtoMenuItem3", true), + bShowProtoMenuItem4(proto, "ShowProtoMenuItem4", true), + bShowProtoMenuItem5(proto, "ShowProtoMenuItem5", true), + bShowProtoMenuItem6(proto, "ShowProtoMenuItem6", true), + iMusicSendMetod(proto, "MusicSendMetod", MusicSendMetod::sendBroadcastOnly), iSyncHistoryMetod(proto, "SyncHistoryMetod", SyncHistoryMetod::syncOff), iIMGBBCSupport(proto, "IMGBBCSupport", IMGBBCSypport::imgNo), @@ -231,6 +239,7 @@ CVKOptions::CVKOptions(PROTO_INTERFACE *proto) : ReloadStrings(); } + void CVKOptions::ReloadStrings() { if (!m_proto) diff --git a/protocols/VKontakte/src/vk_struct.h b/protocols/VKontakte/src/vk_struct.h index e3ce079250..60c25fb5de 100644 --- a/protocols/VKontakte/src/vk_struct.h +++ b/protocols/VKontakte/src/vk_struct.h @@ -313,6 +313,14 @@ struct CVKOptions { CMOption bSyncReadMessageStatusFromServer; CMOption bLoadFullCList; + CMOption bShowProtoMenuItem0; + CMOption bShowProtoMenuItem1; + CMOption bShowProtoMenuItem2; + CMOption bShowProtoMenuItem3; + CMOption bShowProtoMenuItem4; + CMOption bShowProtoMenuItem5; + CMOption bShowProtoMenuItem6; + CMOption iNewsInterval; CMOption iNotificationsInterval; CMOption iNewsAutoClearHistoryInterval; @@ -327,7 +335,7 @@ struct CVKOptions { CVKOptions(PROTO_INTERFACE *proto); void ReloadStrings(); - + __forceinline BBCSupport BBCForNews() { return (BBCSupport)(int)iBBCForNews; }; __forceinline BBCSupport BBCForAttachments() { return (BBCSupport)(int)iBBCForAttachments; }; -- cgit v1.2.3