From 254e19a638bebc4bc468f0415eddf7e4ccff7e02 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 10 Mar 2023 20:47:00 +0300 Subject: Chat_Mute / Chat_IsMuted: helpers for group chats' muting --- src/mir_app/src/chat_svc.cpp | 18 +++++++++++++----- src/mir_app/src/chat_tools.cpp | 4 ++-- src/mir_app/src/ei_defaulticons.cpp | 2 +- src/mir_app/src/mir_app.def | 1 + src/mir_app/src/mir_app64.def | 1 + 5 files changed, 18 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp index 8c72074600..d893a2c754 100644 --- a/src/mir_app/src/chat_svc.cpp +++ b/src/mir_app/src/chat_svc.cpp @@ -750,16 +750,24 @@ MIR_APP_DLL(int) Chat_SetUserInfo(SESSION_INFO *si, void *pItemData) return GC_EVENT_ERROR; } -EXTERN_C MIR_APP_DLL(void) Chat_UpdateOptions() +MIR_APP_DLL(void) Chat_UpdateOptions() { for (auto &si : g_arSessions) if (si->pDlg) si->pDlg->UpdateOptions(); } -EXTERN_C MIR_APP_DLL(void) Chat_Mute(SESSION_INFO *si, int mode) +MIR_APP_DLL(int) Chat_IsMuted(MCONTACT hContact) { - db_set_b(si->hContact, "SRMM", "MuteMode", mode); + return db_get_b(hContact, "SRMM", "MuteMode", CHATMODE_NORMAL); +} + +MIR_APP_DLL(void) Chat_Mute(MCONTACT hContact, int mode) +{ + if (mode != CHATMODE_NORMAL) + db_set_b(hContact, "SRMM", "MuteMode", mode); + else + db_unset(hContact, "SRMM", "MuteMode"); } ///////////////////////////////////////////////////////////////////////////////////////// @@ -830,7 +838,7 @@ static int OnContactDeleted(WPARAM hContact, LPARAM) static INT_PTR MuteChat(WPARAM hContact, LPARAM param) { - db_set_b(hContact, "SRMM", "MuteMode", param); + Chat_Mute(hContact, param); return 0; } @@ -839,7 +847,7 @@ static int PrebuildContactMenu(WPARAM hContact, LPARAM) if (hContact == 0) return 0; - int iMuteMode = db_get_b(hContact, "SRMM", "MuteMode", CHATMODE_NORMAL); + int iMuteMode = Chat_IsMuted(hContact); bool bEnabledJoin = false, bEnabledLeave = false, bIsChat = false; char *szProto = Proto_GetBaseAccountName(hContact); if (szProto) { diff --git a/src/mir_app/src/chat_tools.cpp b/src/mir_app/src/chat_tools.cpp index cb962183de..382f2f2dcf 100644 --- a/src/mir_app/src/chat_tools.cpp +++ b/src/mir_app/src/chat_tools.cpp @@ -158,7 +158,7 @@ static void AddEvent(MCONTACT hContact, HICON hIcon, int type, const wchar_t *pw BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce) { - int iMuteMode = db_get_b(si->hContact, "SRMM", "MuteMode", CHATMODE_NORMAL); + int iMuteMode = Chat_IsMuted(si->hContact); switch (iMuteMode) { case CHATMODE_MUTE: iMuteMode = CLEF_ONLYAFEW; break; case CHATMODE_UNMUTE: iMuteMode = 0; break; @@ -375,7 +375,7 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight return FALSE; BOOL bInactive = si->pDlg == nullptr || !si->pDlg->IsActive(); - int iMuteMode = db_get_b(si->hContact, "SRMM", "MuteMode", CHATMODE_NORMAL); + int iMuteMode = Chat_IsMuted(si->hContact); if (bHighlight) { gce->iType |= GC_EVENT_HIGHLIGHT; diff --git a/src/mir_app/src/ei_defaulticons.cpp b/src/mir_app/src/ei_defaulticons.cpp index e2eb20cbf0..763150027c 100644 --- a/src/mir_app/src/ei_defaulticons.cpp +++ b/src/mir_app/src/ei_defaulticons.cpp @@ -95,7 +95,7 @@ static void SetChatMute(MCONTACT hContact, int mode) return; if (mode == -1) - mode = db_get_b(hContact, "SRMM", "MuteMode", CHATMODE_NORMAL); + mode = Chat_IsMuted(hContact); HANDLE hIcon; switch (mode) { diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 022ce9a37b..e994cf236b 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -823,3 +823,4 @@ Srmm_CreateHotkey @886 NONAME ?getMStringU@PROTO_INTERFACE@@QAE?AV?$CMStringT@DV?$ChTraitsCRT@D@@@@IPBD0@Z @938 NONAME ?getMStringU@PROTO_INTERFACE@@QAE?AV?$CMStringT@DV?$ChTraitsCRT@D@@@@PBD0@Z @939 NONAME ?OnEventDeleted@PROTO_INTERFACE@@UAEXII@Z @940 NONAME +Chat_IsMuted @941 NONAME diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 196c8cba39..c953a52884 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -823,3 +823,4 @@ Srmm_CreateHotkey @886 NONAME ?getMStringU@PROTO_INTERFACE@@QEAA?AV?$CMStringT@DV?$ChTraitsCRT@D@@@@IPEBD0@Z @938 NONAME ?getMStringU@PROTO_INTERFACE@@QEAA?AV?$CMStringT@DV?$ChTraitsCRT@D@@@@PEBD0@Z @939 NONAME ?OnEventDeleted@PROTO_INTERFACE@@UEAAXII@Z @940 NONAME +Chat_IsMuted @941 NONAME -- cgit v1.2.3