From 60628b4face0c7715a8dd9f271a7a806b82fc08f Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 27 Feb 2021 18:41:35 +0300 Subject: fixes #2713 (NoHistory: add option to remove histories on startup) --- plugins/NoHistory/res/NoHistory.rc | 45 +++++++++++++++++++++++--------------- plugins/NoHistory/src/dllmain.cpp | 15 +++++++++---- plugins/NoHistory/src/options.cpp | 10 ++++++--- plugins/NoHistory/src/resource.h | 5 +++-- plugins/NoHistory/src/stdafx.h | 1 + plugins/NoHistory/src/version.h | 2 +- 6 files changed, 50 insertions(+), 28 deletions(-) (limited to 'plugins') diff --git a/plugins/NoHistory/res/NoHistory.rc b/plugins/NoHistory/res/NoHistory.rc index 788c948596..87231b8a02 100644 --- a/plugins/NoHistory/res/NoHistory.rc +++ b/plugins/NoHistory/res/NoHistory.rc @@ -1,4 +1,4 @@ -//Microsoft Developer Studio generated resource script. +// Microsoft Visual C++ generated resource script. // #include "..\src\resource.h" @@ -15,10 +15,8 @@ // Neutral (Default) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEUD) -#ifdef _WIN32 LANGUAGE LANG_NEUTRAL, SUBLANG_DEFAULT #pragma code_page(1251) -#endif //_WIN32 ///////////////////////////////////////////////////////////////////////////// // @@ -27,9 +25,11 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_DEFAULT // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. -IDI_HKEEP ICON "history_enabled.ico" -IDI_HREMOVE ICON "history_disabled.ico" -IDI_HCLEAR ICON "history_clear.ico" +IDI_HKEEP ICON "history_enabled.ico" + +IDI_HREMOVE ICON "history_disabled.ico" + +IDI_HCLEAR ICON "history_clear.ico" #ifdef APSTUDIO_INVOKED @@ -38,17 +38,17 @@ IDI_HCLEAR ICON "history_clear.ico" // TEXTINCLUDE // -1 TEXTINCLUDE +1 TEXTINCLUDE BEGIN "..\\src\\resource.h\0" END -2 TEXTINCLUDE +2 TEXTINCLUDE BEGIN "#include ""afxres.h""\r\0" END -3 TEXTINCLUDE +3 TEXTINCLUDE BEGIN "\r\0" END @@ -61,19 +61,17 @@ END // Dialog // -IDD_OPT DIALOGEX 0, 0, 312, 235 +IDD_OPT DIALOGEX 0, 0, 312, 251 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD EXSTYLE WS_EX_CONTROLPARENT FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN - CONTROL "Custom1",IDC_LIST,"CListControl",WS_TABSTOP | 0x1d0,7,7, - 298,192,WS_EX_CLIENTEDGE + CONTROL "Custom1",IDC_LIST,"CListControl",WS_TABSTOP | 0x1d0,7,7,298,192,WS_EX_CLIENTEDGE ICON IDI_HKEEP,IDC_PIC_KEEP,8,203,21,20 - LTEXT "Keep history for this contact",IDC_STATIC,42,203,263,8, - SS_NOPREFIX | SS_CENTERIMAGE - ICON IDI_HREMOVE,IDC_PIC_REMOVE,8,218,21,20 - LTEXT "Disable history for this contact",IDC_STATIC,42,220,263, - 8,SS_NOPREFIX | SS_CENTERIMAGE + LTEXT "Keep history for this contact",IDC_STATIC,34,203,263,8,SS_NOPREFIX | SS_CENTERIMAGE + ICON IDI_HREMOVE,IDC_PIC_REMOVE,8,216,21,20 + LTEXT "Disable history for this contact",IDC_STATIC,34,218,263,8,SS_NOPREFIX | SS_CENTERIMAGE + CONTROL "Remove history on startup",IDC_ONSTARTUP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,234,298,10 END @@ -91,12 +89,23 @@ BEGIN RIGHTMARGIN, 305 VERTGUIDE, 42 TOPMARGIN, 7 - BOTTOMMARGIN, 228 + BOTTOMMARGIN, 244 HORZGUIDE, 211 END END #endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// +// +// AFX_DIALOG_LAYOUT +// + +IDD_OPT AFX_DIALOG_LAYOUT +BEGIN + 0 +END + #endif // Neutral (Default) resources ///////////////////////////////////////////////////////////////////////////// diff --git a/plugins/NoHistory/src/dllmain.cpp b/plugins/NoHistory/src/dllmain.cpp index c0e80b7676..a4b580fa84 100644 --- a/plugins/NoHistory/src/dllmain.cpp +++ b/plugins/NoHistory/src/dllmain.cpp @@ -42,8 +42,10 @@ PLUGININFOEX pluginInfoEx = CMPlugin::CMPlugin() : PLUGIN(MODULENAME, pluginInfoEx), - bEnabledForNew(MODULENAME, "EnabledForNew", true) -{} + bEnabledForNew(MODULENAME, "EnabledForNew", true), + bWipeOnStartup(MODULENAME, "WipeOnStartup", false) +{ +} ///////////////////////////////////////////////////////////////////////////////////////// @@ -95,9 +97,11 @@ void RemoveAllEvents(MCONTACT hContact) pCursor.DeleteEvent(); } -void CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD) +static void CALLBACK WipeOnStart() { - RemoveReadEvents(); + for (auto &cc : Contacts()) + if (g_plugin.getByte(cc, DBSETTING_REMOVE)) + RemoveAllEvents(cc); } int OnDatabaseEventAdd(WPARAM hContact, LPARAM hDBEvent) @@ -266,6 +270,9 @@ int CMPlugin::Load() InitIcons(); + if (bWipeOnStartup) + Miranda_WaitOnHandle(WipeOnStart); + HookEvent(ME_CLIST_PREBUILDCONTACTMENU, PrebuildContactMenu); HookEvent(ME_DB_CONTACT_ADDED, OnContactAdded); HookEvent(ME_DB_EVENT_ADDED, OnDatabaseEventAdd); diff --git a/plugins/NoHistory/src/options.cpp b/plugins/NoHistory/src/options.cpp index f34b580395..f6ec5a1fda 100644 --- a/plugins/NoHistory/src/options.cpp +++ b/plugins/NoHistory/src/options.cpp @@ -4,8 +4,6 @@ class CDlgOptionsDlg : public CDlgBase { HANDLE hItemAll, hItemNew; - CCtrlClc clist; - void SetListGroupIcons(HANDLE hFirstItem, HANDLE hParentItem, int *groupChildCount = nullptr) { int iconOn = 1; @@ -79,11 +77,17 @@ class CDlgOptionsDlg : public CDlgBase } } + CCtrlClc clist; + CCtrlCheck chkOnStartup; + public: CDlgOptionsDlg() : CDlgBase(g_plugin, IDD_OPT), - clist(this, IDC_LIST) + clist(this, IDC_LIST), + chkOnStartup(this, IDC_ONSTARTUP) { + CreateLink(chkOnStartup, g_plugin.bWipeOnStartup); + clist.OnNewContact = clist.OnListRebuilt = Callback(this, &CDlgOptionsDlg::onListRebuilt); clist.OnOptionsChanged = Callback(this, &CDlgOptionsDlg::onOptionsChanged); clist.OnContactMoved = Callback(this, &CDlgOptionsDlg::onContactMoved); diff --git a/plugins/NoHistory/src/resource.h b/plugins/NoHistory/src/resource.h index 5640d91b59..ec1fc8a07d 100644 --- a/plugins/NoHistory/src/resource.h +++ b/plugins/NoHistory/src/resource.h @@ -13,14 +13,15 @@ #define IDC_ED_TIMEOUT 1004 #define IDC_SPIN1 1005 #define IDC_SPN_TIMEOUT 1005 +#define IDC_ONSTARTUP 1006 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 104 +#define _APS_NEXT_RESOURCE_VALUE 105 #define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1006 +#define _APS_NEXT_CONTROL_VALUE 1007 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/plugins/NoHistory/src/stdafx.h b/plugins/NoHistory/src/stdafx.h index 82ca708c8a..612f2e2aea 100644 --- a/plugins/NoHistory/src/stdafx.h +++ b/plugins/NoHistory/src/stdafx.h @@ -31,6 +31,7 @@ struct CMPlugin : public PLUGIN CMPlugin(); CMOption bEnabledForNew; + CMOption bWipeOnStartup; int Load() override; int Unload() override; diff --git a/plugins/NoHistory/src/version.h b/plugins/NoHistory/src/version.h index 177425eeaa..df6f3084da 100644 --- a/plugins/NoHistory/src/version.h +++ b/plugins/NoHistory/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 2 #define __RELEASE_NUM 3 -#define __BUILD_NUM 1 +#define __BUILD_NUM 2 #include -- cgit v1.2.3