From cd4272ca22d47cdf673bfb0e5ec353acca3d9569 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 16 Jul 2022 21:23:06 +0300 Subject: Contact_IsGroupChat - a helper to detect chat rooms --- plugins/NoHistory/src/dllmain.cpp | 10 +++------- plugins/NoHistory/src/options.cpp | 10 ++-------- plugins/NoHistory/src/stdafx.h | 1 + 3 files changed, 6 insertions(+), 15 deletions(-) (limited to 'plugins/NoHistory') diff --git a/plugins/NoHistory/src/dllmain.cpp b/plugins/NoHistory/src/dllmain.cpp index a4b580fa84..8ac0519b22 100644 --- a/plugins/NoHistory/src/dllmain.cpp +++ b/plugins/NoHistory/src/dllmain.cpp @@ -137,8 +137,7 @@ INT_PTR ServiceClear(WPARAM hContact, LPARAM) int PrebuildContactMenu(WPARAM hContact, LPARAM) { bool remove = g_plugin.getByte(hContact, DBSETTING_REMOVE) != 0; - char *proto = Proto_GetBaseAccountName(hContact); - bool chat_room = (proto && db_get_b(hContact, proto, "ChatRoom", 0) != 0); + bool chat_room = Contact_IsGroupChat(hContact); if (chat_room) Menu_ShowItem(hMenuToggle, false); @@ -175,8 +174,7 @@ int WindowEvent(WPARAM, LPARAM lParam) break; case MSG_WINDOW_EVT_OPEN: - char *proto = Proto_GetBaseAccountName(hContact); - bool chat_room = (proto && db_get_b(hContact, proto, "ChatRoom", 0) != 0); + bool chat_room = Contact_IsGroupChat(hContact); int remove = g_plugin.getByte(hContact, DBSETTING_REMOVE) != 0; for (int i = 0; i < 2; ++i) @@ -195,9 +193,7 @@ int IconPressed(WPARAM hContact, LPARAM lParam) if (sicd->flags & MBCF_RIGHTBUTTON) return 0; // ignore right-clicks if (mir_strcmp(sicd->szModule, MODULENAME) != 0) return 0; // not our event - char *proto = Proto_GetBaseAccountName(hContact); - bool chat_room = (proto && db_get_b(hContact, proto, "ChatRoom", 0) != 0); - if (!chat_room) + if (!Contact_IsGroupChat(hContact)) ServiceToggle(hContact, 0); return 0; diff --git a/plugins/NoHistory/src/options.cpp b/plugins/NoHistory/src/options.cpp index dd613dc0ae..43b81ea040 100644 --- a/plugins/NoHistory/src/options.cpp +++ b/plugins/NoHistory/src/options.cpp @@ -64,10 +64,7 @@ class CDlgOptionsDlg : public CDlgBase void SetAllContactIcons() { for (auto &hContact : Contacts()) { - char *proto = Proto_GetBaseAccountName(hContact); - bool chat_room = (proto && db_get_b(hContact, proto, "ChatRoom", 0) != 0); - - if (!chat_room) { + if (!Contact_IsGroupChat(hContact)) { HANDLE hItem = clist.FindContact(hContact); if (hItem) { bool disabled = (g_plugin.getByte(hContact, DBSETTING_REMOVE) == 1); @@ -129,10 +126,7 @@ public: g_plugin.bEnabledForNew = clist.GetExtraImage(hItemNew, 0); for (auto &hContact : Contacts()) { - char *proto = Proto_GetBaseAccountName(hContact); - bool chat_room = (proto && db_get_b(hContact, proto, "ChatRoom", 0) != 0); - - if (!chat_room) { + if (!Contact_IsGroupChat(hContact)) { HANDLE hItem = clist.FindContact(hContact); if (hItem) { int iImage = clist.GetExtraImage(hItem, 0); diff --git a/plugins/NoHistory/src/stdafx.h b/plugins/NoHistory/src/stdafx.h index 3810ddfb6c..5290f2e7ed 100644 --- a/plugins/NoHistory/src/stdafx.h +++ b/plugins/NoHistory/src/stdafx.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include -- cgit v1.2.3