From c6519db3afea05236cd41a144110a8a74f3daa96 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 10 Jun 2021 16:29:02 +0300 Subject: fixes #2914 (unified empty history menu items) --- plugins/BasicHistory/src/BasicHistory.cpp | 17 ++-------- plugins/BasicHistory/src/HistoryWindow.cpp | 53 +----------------------------- plugins/BasicHistory/src/HistoryWindow.h | 1 - 3 files changed, 3 insertions(+), 68 deletions(-) (limited to 'plugins/BasicHistory/src') diff --git a/plugins/BasicHistory/src/BasicHistory.cpp b/plugins/BasicHistory/src/BasicHistory.cpp index 091d9b15d9..5639b63c86 100644 --- a/plugins/BasicHistory/src/BasicHistory.cpp +++ b/plugins/BasicHistory/src/BasicHistory.cpp @@ -18,7 +18,6 @@ along with this program. If not, see . #include "stdafx.h" -#define MS_HISTORY_DELETEALLCONTACTHISTORY "BasicHistory/DeleteAllContactHistory" #define MS_HISTORY_EXECUTE_TASK "BasicHistory/ExecuteTask" HCURSOR hCurSplitNS, hCurSplitWE; @@ -26,7 +25,7 @@ HCURSOR hCurSplitNS, hCurSplitWE; HANDLE *hEventIcons = nullptr; int iconsNum = 3; HANDLE hToolbarButton; -HGENMENU hContactMenu, hDeleteContactMenu; +HGENMENU hContactMenu; HGENMENU hTaskMainMenu; std::vector taskMenus; bool g_SmileyAddAvail = false; @@ -67,11 +66,7 @@ INT_PTR ExecuteTaskService(WPARAM wParam, LPARAM lParam); int PrebuildContactMenu(WPARAM hContact, LPARAM) { - bool bHasHistory = db_event_last(hContact) != NULL; - bool isInList = HistoryWindow::IsInList(GetForegroundWindow()); - - Menu_ShowItem(hContactMenu, bHasHistory); - Menu_ShowItem(hDeleteContactMenu, bHasHistory && isInList); + Menu_ShowItem(hContactMenu, db_event_last(hContact) != NULL); return 0; } @@ -101,13 +96,6 @@ void InitMenuItems() mi.pszService = MS_HISTORY_SHOWCONTACTHISTORY; Menu_AddMainMenuItem(&mi); - SET_UID(mi, 0x63929694, 0x2d3d, 0x4c5d, 0xa5, 0x2b, 0x64, 0x59, 0x72, 0x23, 0xe, 0x66); - mi.position = 1000090001; - mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_DELETE); - mi.name.a = LPGEN("Delete all user history"); - mi.pszService = MS_HISTORY_DELETEALLCONTACTHISTORY; - hDeleteContactMenu = Menu_AddContactMenuItem(&mi); - HookEvent(ME_CLIST_PREBUILDCONTACTMENU, PrebuildContactMenu); } @@ -241,7 +229,6 @@ int CMPlugin::Load() hCurSplitWE = LoadCursor(nullptr, IDC_SIZEWE); CreateServiceFunction(MS_HISTORY_SHOWCONTACTHISTORY, ShowContactHistory); - CreateServiceFunction(MS_HISTORY_DELETEALLCONTACTHISTORY, HistoryWindow::DeleteAllUserHistory); CreateServiceFunction(MS_HISTORY_EXECUTE_TASK, ExecuteTaskService); Options::instance = new Options(); diff --git a/plugins/BasicHistory/src/HistoryWindow.cpp b/plugins/BasicHistory/src/HistoryWindow.cpp index 353de121b9..97471870c4 100644 --- a/plugins/BasicHistory/src/HistoryWindow.cpp +++ b/plugins/BasicHistory/src/HistoryWindow.cpp @@ -355,57 +355,6 @@ void HistoryWindow::OptionsSearchingChanged() } } -INT_PTR HistoryWindow::DeleteAllUserHistory(WPARAM hContact, LPARAM) -{ - HWND hWnd = nullptr; - int count = HistoryEventList::GetContactMessageNumber(hContact); - if (!count) - return FALSE; - - for (auto it = windows.begin(); it != windows.end(); ++it) { - if (!it->second->isDestroyed) { - if (it->second->m_hContact == hContact) { - if (hWnd == nullptr) { - hWnd = it->second->m_hWnd; - } - else if (GetForegroundWindow() == it->second->m_hWnd) { - hWnd = it->second->m_hWnd; - } - } - } - } - - for (auto it = freeWindows.begin(); it != freeWindows.end(); ++it) { - if (!(*it)->isDestroyed) { - if ((*it)->m_hContact == hContact) { - if (hWnd == nullptr) - hWnd = (*it)->m_hWnd; - else if (GetForegroundWindow() == (*it)->m_hWnd) - hWnd = (*it)->m_hWnd; - } - } - } - - wchar_t *message = TranslateT("This operation will PERMANENTLY REMOVE all history for this contact.\nAre you sure you want to do this?"); - if (MessageBox(hWnd, message, TranslateT("Are you sure?"), MB_OKCANCEL | MB_ICONERROR) != IDOK) - return FALSE; - - db_set_safety_mode(FALSE); - DB::ECPTR cursor(DB::Events(hContact)); - while (cursor.FetchNext()) - cursor.DeleteEvent(); - db_set_safety_mode(TRUE); - - if (HistoryEventList::IsImportedHistory(hContact)) { - message = TranslateT("Do you want to delete all imported messages for this contact?\nNote that next scheduler task import this messages again."); - if (MessageBox(hWnd, message, TranslateT("Are you sure?"), MB_YESNO | MB_ICONERROR) == IDYES) - HistoryEventList::DeleteImporter(hContact); - } - - RebuildEvents(hContact); - return TRUE; -} - bool HistoryWindow::IsInList(HWND hWnd) { for (auto it = windows.begin(); it != windows.end(); ++it) @@ -1917,7 +1866,7 @@ void HistoryWindow::Delete(int what) toDelete = (int)end; } else { - DeleteAllUserHistory(m_hContact, 0); + CallService(MS_HISTORY_EMPTY, m_hContact, 0); return; } diff --git a/plugins/BasicHistory/src/HistoryWindow.h b/plugins/BasicHistory/src/HistoryWindow.h index 8b19d2f439..e7e85d9e7d 100644 --- a/plugins/BasicHistory/src/HistoryWindow.h +++ b/plugins/BasicHistory/src/HistoryWindow.h @@ -80,7 +80,6 @@ public: static void RebuildEvents(MCONTACT hContact); static bool IsInList(HWND hWnd); static int FontsChanged(WPARAM wParam, LPARAM lParam); - static INT_PTR DeleteAllUserHistory(WPARAM wParam, LPARAM lParam); static void OptionsMainChanged(); static void OptionsGroupChanged(); static void OptionsSearchingChanged(); -- cgit v1.2.3