summaryrefslogtreecommitdiff
path: root/plugins/BasicHistory/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-06-10 16:29:02 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-06-10 16:29:02 +0300
commitc6519db3afea05236cd41a144110a8a74f3daa96 (patch)
treea30afee305efb54be06a4b7bf1fafdbc6f2ce9ce /plugins/BasicHistory/src
parent2ad5c23a591fb5aa4c34f1148ee565cc015d1384 (diff)
fixes #2914 (unified empty history menu items)
Diffstat (limited to 'plugins/BasicHistory/src')
-rw-r--r--plugins/BasicHistory/src/BasicHistory.cpp17
-rw-r--r--plugins/BasicHistory/src/HistoryWindow.cpp53
-rw-r--r--plugins/BasicHistory/src/HistoryWindow.h1
3 files changed, 3 insertions, 68 deletions
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 <http://www.gnu.org/licenses/>.
#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<HGENMENU> 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();