summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-03-07 19:51:59 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-03-07 19:51:59 +0300
commit9852392895d7c94c84ff3b4ff8966676a493f87c (patch)
tree7b6216e6bf0f51792b4971bd30521b42d5ccd874
parenta64964a329edfeb8c6fafb1265163015d4a579ce (diff)
common chats sound & icon processing code moved to the core
-rw-r--r--include/m_chat_int.h5
-rw-r--r--libs/win32/mir_app.libbin218748 -> 219414 bytes
-rw-r--r--libs/win64/mir_app.libbin214560 -> 215246 bytes
-rw-r--r--plugins/TabSRMM/src/chat.h11
-rw-r--r--plugins/TabSRMM/src/chat_tools.cpp319
-rw-r--r--plugins/TabSRMM/src/hotkeyhandler.cpp18
-rw-r--r--plugins/TabSRMM/src/msgs.h1
-rw-r--r--src/mir_app/src/chat_manager.cpp29
-rw-r--r--src/mir_app/src/chat_tools.cpp96
-rw-r--r--src/mir_app/src/mir_app.def2
-rw-r--r--src/mir_app/src/mir_app64.def2
11 files changed, 199 insertions, 284 deletions
diff --git a/include/m_chat_int.h b/include/m_chat_int.h
index c62a649b75..8318ba2371 100644
--- a/include/m_chat_int.h
+++ b/include/m_chat_int.h
@@ -191,6 +191,8 @@ struct MIR_APP_EXPORT GCSessionInfoBase : public MZeroedObject, public MNonCopya
__forceinline LIST<USERINFO>& getKeyList()
{ return (pParent != nullptr) ? pParent->arKeys : arKeys;
}
+
+ const char* getSoundName(int iEventType) const;
};
struct GCLogStreamDataBase
@@ -347,6 +349,9 @@ struct CHAT_MANAGER
char **pLogIconBmpBits;
CMOption<bool> bRightClickFilter;
+ // public API
+ MIR_APP_DLL(HICON) getIcon(int iEventType) const;
+
// user-defined custom callbacks
void (*OnCreateModule)(MODULEINFO*);
void (*OnDestroyModule)(MODULEINFO*);
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib
index cb9e0f8b74..ecc006eed5 100644
--- a/libs/win32/mir_app.lib
+++ b/libs/win32/mir_app.lib
Binary files differ
diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib
index aad0cf2b19..bccf85997a 100644
--- a/libs/win64/mir_app.lib
+++ b/libs/win64/mir_app.lib
Binary files differ
diff --git a/plugins/TabSRMM/src/chat.h b/plugins/TabSRMM/src/chat.h
index 1917ace7e7..2c9e762908 100644
--- a/plugins/TabSRMM/src/chat.h
+++ b/plugins/TabSRMM/src/chat.h
@@ -80,16 +80,6 @@ struct TMUCSettings : public GlobalLogSettingsBase
CMUCHighlight *Highlight;
};
-struct FLASH_PARAMS : public MZeroedObject
-{
- MCONTACT hContact;
- const char* sound;
- int iEvent;
- HICON hNotifyIcon;
- bool bActiveTab, bInactive, bMustFlash, bMustAutoswitch;
- HWND hWnd;
-};
-
extern TMUCSettings g_Settings;
#pragma comment(lib,"comctl32.lib")
@@ -127,7 +117,6 @@ wchar_t* my_strstri(const wchar_t* s1, const wchar_t* s2);
bool IsHighlighted(SESSION_INFO *si, GCEVENT *pszText);
char GetIndicator(SESSION_INFO *si, LPCTSTR ptszNick, int *iNickIndex);
void Chat_SetFilters(SESSION_INFO *si);
-void DoFlashAndSoundWorker(FLASH_PARAMS* p);
BOOL DoPopup(SESSION_INFO *si, GCEVENT* gce);
int ShowPopup(MCONTACT hContact, SESSION_INFO *si, HICON hIcon, char* pszProtoName, wchar_t* pszRoomName, COLORREF crBkg, const wchar_t* fmt, ...);
diff --git a/plugins/TabSRMM/src/chat_tools.cpp b/plugins/TabSRMM/src/chat_tools.cpp
index a759a085ea..56c23a72c5 100644
--- a/plugins/TabSRMM/src/chat_tools.cpp
+++ b/plugins/TabSRMM/src/chat_tools.cpp
@@ -202,115 +202,32 @@ passed:
return TRUE;
}
-void DoFlashAndSoundWorker(FLASH_PARAMS *p)
-{
- SESSION_INFO *si = SM_FindSessionByHCONTACT(p->hContact);
- if (si == nullptr)
- return;
-
- CMsgDialog *dat = nullptr;
- if (si->pDlg) {
- dat = si->pDlg;
- if (dat) {
- p->bInactive = dat->m_pContainer->m_hwnd != GetForegroundWindow();
- p->bActiveTab = (dat->m_pContainer->m_hwndActive == si->pDlg->GetHwnd());
- if (p->sound && dat->MustPlaySound())
- Skin_PlaySound(p->sound);
- }
- }
- else if (p->sound)
- Skin_PlaySound(p->sound);
-
- if (dat) {
- BOOL bForcedIcon = (p->hNotifyIcon == g_chatApi.hIcons[ICON_HIGHLIGHT] || p->hNotifyIcon == g_chatApi.hIcons[ICON_MESSAGE]);
-
- if ((p->iEvent & si->iLogTrayFlags) || bForcedIcon) {
- if (!p->bActiveTab) {
- if (p->hNotifyIcon == g_chatApi.hIcons[ICON_HIGHLIGHT])
- dat->m_iFlashIcon = p->hNotifyIcon;
- else {
- if (dat->m_iFlashIcon != g_chatApi.hIcons[ICON_HIGHLIGHT] && dat->m_iFlashIcon != g_chatApi.hIcons[ICON_MESSAGE])
- dat->m_iFlashIcon = p->hNotifyIcon;
- }
- dat->m_bCanFlashTab = TRUE;
- si->pDlg->timerFlash.Start(TIMEOUT_FLASHWND);
- }
- }
- if (dat->m_pWnd) {
- dat->m_pWnd->updateIcon(p->hNotifyIcon);
- dat->m_pWnd->setOverlayIcon(p->hNotifyIcon, true);
- }
-
- // autoswitch tab..
- if (p->bMustAutoswitch) {
- if ((IsIconic(dat->m_pContainer->m_hwnd)) && !IsZoomed(dat->m_pContainer->m_hwnd) && PluginConfig.m_bAutoSwitchTabs && dat->m_pContainer->m_hwndActive != si->pDlg->GetHwnd()) {
- int iItem = GetTabIndexFromHWND(dat->m_pContainer->m_hwndTabs, si->pDlg->GetHwnd());
- if (iItem >= 0) {
- TabCtrl_SetCurSel(dat->m_pContainer->m_hwndTabs, iItem);
- ShowWindow(dat->m_pContainer->m_hwndActive, SW_HIDE);
- dat->m_pContainer->m_hwndActive = si->pDlg->GetHwnd();
- dat->m_pContainer->UpdateTitle(dat->m_hContact);
- dat->m_pContainer->m_flags.m_bDeferredTabSelect = true;
- }
- }
- }
-
- // flash window if it is not focused
- if (p->bMustFlash && p->bInactive)
- if (!dat->m_pContainer->m_flags.m_bNoFlash)
- dat->m_pContainer->FlashContainer(1, 0);
-
- if (p->hNotifyIcon && p->bInactive && ((p->iEvent & si->iLogTrayFlags) || bForcedIcon)) {
- if (p->bMustFlash)
- dat->m_hTabIcon = p->hNotifyIcon;
- else if (dat->m_iFlashIcon) {
- dat->m_hTabIcon = dat->m_iFlashIcon;
-
- TCITEM item = {};
- item.mask = TCIF_IMAGE;
- item.iImage = 0;
- TabCtrl_SetItem(GetParent(si->pDlg->GetHwnd()), dat->m_iTabID, &item);
- }
-
- HICON hIcon = (HICON)SendMessage(dat->m_pContainer->m_hwnd, WM_GETICON, ICON_BIG, 0);
- if (p->hNotifyIcon == g_chatApi.hIcons[ICON_HIGHLIGHT] || (hIcon != g_chatApi.hIcons[ICON_MESSAGE] && hIcon != g_chatApi.hIcons[ICON_HIGHLIGHT])) {
- dat->m_pContainer->SetIcon(dat, p->hNotifyIcon);
- dat->m_pContainer->m_flags.m_bNeedsUpdateTitle = true;
- }
- }
-
- if (p->bMustFlash && p->bInactive)
- AddUnreadContact(dat->m_hContact);
- }
-
- delete p;
-}
-
BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight, int bManyFix)
{
if (gce == nullptr || si == nullptr || gce->bIsMe || si->iType == GCW_SERVER)
return FALSE;
- CMsgDialog *dat = nullptr;
- auto *params = new FLASH_PARAMS();
- params->hContact = si->hContact;
- params->bInactive = true;
- if (si->pDlg) {
- dat = si->pDlg;
- if ((si->pDlg->GetHwnd() == si->pDlg->m_pContainer->m_hwndActive) && GetForegroundWindow() == si->pDlg->m_pContainer->m_hwnd)
- params->bInactive = false;
+ CMsgDialog *dat = si->pDlg;
+
+ MCONTACT hContact = si->hContact;
+ bool bInactive = true;
+ if (dat) {
+ if ((dat->GetHwnd() == dat->m_pContainer->m_hwndActive) && GetForegroundWindow() == dat->m_pContainer->m_hwnd)
+ bInactive = false;
}
- params->bActiveTab = params->bMustFlash = params->bMustAutoswitch = false;
- params->iEvent = gce->iType;
+ bool bActiveTab = false;
+ bool bMustFlash = false;
+ bool bMustAutoswitch = false;
+ int iEvent = gce->iType;
+ HWND hWnd = nullptr;
WPARAM wParamForHighLight = 0;
bool bFlagUnread = false;
if (bHighlight) {
gce->iType |= GC_EVENT_HIGHLIGHT;
- params->sound = "ChatHighlight";
if (Contact_IsHidden(si->hContact) != 0)
Contact_Hide(si->hContact, false);
- if (params->bInactive) {
+ if (bInactive) {
bFlagUnread = true;
DoTrayIcon(si, gce);
}
@@ -318,23 +235,22 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight
if (g_Settings.bCreateWindowOnHighlight && dat == nullptr)
wParamForHighLight = 1;
- if (dat && g_Settings.bAnnoyingHighlight && params->bInactive && dat->m_pContainer->m_hwnd != GetForegroundWindow()) {
+ if (dat && g_Settings.bAnnoyingHighlight && bInactive && dat->m_pContainer->m_hwnd != GetForegroundWindow()) {
wParamForHighLight = 2;
- params->hWnd = dat->GetHwnd();
+ hWnd = dat->GetHwnd();
}
if (dat || !nen_options.iMUCDisable)
DoPopup(si, gce);
- if (g_Settings.bFlashWindowHighlight && params->bInactive)
- params->bMustFlash = true;
- params->bMustAutoswitch = true;
- params->hNotifyIcon = g_chatApi.hIcons[ICON_HIGHLIGHT];
+ if (g_Settings.bFlashWindowHighlight && bInactive)
+ bMustFlash = true;
+ bMustAutoswitch = true;
}
else {
// do blinking icons in tray
- if (params->bInactive || !g_Settings.bTrayIconInactiveOnly) {
+ if (bInactive || !g_Settings.bTrayIconInactiveOnly) {
DoTrayIcon(si, gce);
- if (params->iEvent == GC_EVENT_MESSAGE)
+ if (iEvent == GC_EVENT_MESSAGE)
bFlagUnread = true;
}
// stupid thing to not create multiple popups for a QUIT event for instance
@@ -344,120 +260,115 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight
DoPopup(si, gce);
// do sounds and flashing
- switch (params->iEvent) {
- case GC_EVENT_JOIN:
- params->sound = "ChatJoin";
- if (params->bInactive)
- params->hNotifyIcon = g_chatApi.hIcons[ICON_JOIN];
- break;
- case GC_EVENT_PART:
- params->sound = "ChatPart";
- if (params->bInactive)
- params->hNotifyIcon = g_chatApi.hIcons[ICON_PART];
- break;
- case GC_EVENT_QUIT:
- params->sound = "ChatQuit";
- if (params->bInactive)
- params->hNotifyIcon = g_chatApi.hIcons[ICON_QUIT];
- break;
- case GC_EVENT_ADDSTATUS:
- case GC_EVENT_REMOVESTATUS:
- params->sound = "ChatMode";
- if (params->bInactive)
- params->hNotifyIcon = g_chatApi.hIcons[params->iEvent == GC_EVENT_ADDSTATUS ? ICON_ADDSTATUS : ICON_REMSTATUS];
- break;
- case GC_EVENT_KICK:
- params->sound = "ChatKick";
- if (params->bInactive)
- params->hNotifyIcon = g_chatApi.hIcons[ICON_KICK];
- break;
- case GC_EVENT_MESSAGE:
- if (params->bInactive)
- params->sound = "RecvMsgInactive";
- else
- params->sound = "RecvMsgActive";
-
- if (params->bInactive && !(si->wState & STATE_TALK)) {
+ if (iEvent == GC_EVENT_MESSAGE) {
+ if (bInactive && !(si->wState & STATE_TALK)) {
si->wState |= STATE_TALK;
db_set_w(si->hContact, si->pszModule, "ApparentMode", ID_STATUS_OFFLINE);
}
- break;
- case GC_EVENT_ACTION:
- params->sound = "ChatAction";
- if (params->bInactive)
- params->hNotifyIcon = g_chatApi.hIcons[ICON_ACTION];
- break;
- case GC_EVENT_NICK:
- params->sound = "ChatNick";
- if (params->bInactive)
- params->hNotifyIcon = g_chatApi.hIcons[ICON_NICK];
- break;
- case GC_EVENT_NOTICE:
- params->sound = "ChatNotice";
- if (params->bInactive)
- params->hNotifyIcon = g_chatApi.hIcons[ICON_NOTICE];
- break;
- case GC_EVENT_TOPIC:
- params->sound = "ChatTopic";
- if (params->bInactive)
- params->hNotifyIcon = g_chatApi.hIcons[ICON_TOPIC];
- break;
- }
-
- if (!(db_get_dw(0, CHAT_MODULE, "SoundFlags", GC_EVENT_HIGHLIGHT) & params->iEvent))
- params->sound = nullptr;
- else if (CHATMODE_MUTE == db_get_b(si->hContact, "SRMM", "MuteMode", CHATMODE_NORMAL))
- params->sound = nullptr;
- }
- else {
- switch (params->iEvent) {
- case GC_EVENT_JOIN:
- params->hNotifyIcon = g_chatApi.hIcons[ICON_JOIN];
- break;
- case GC_EVENT_PART:
- params->hNotifyIcon = g_chatApi.hIcons[ICON_PART];
- break;
- case GC_EVENT_QUIT:
- params->hNotifyIcon = g_chatApi.hIcons[ICON_QUIT];
- break;
- case GC_EVENT_KICK:
- params->hNotifyIcon = g_chatApi.hIcons[ICON_KICK];
- break;
- case GC_EVENT_ACTION:
- params->hNotifyIcon = g_chatApi.hIcons[ICON_ACTION];
- break;
- case GC_EVENT_NICK:
- params->hNotifyIcon = g_chatApi.hIcons[ICON_NICK];
- break;
- case GC_EVENT_NOTICE:
- params->hNotifyIcon = g_chatApi.hIcons[ICON_NOTICE];
- break;
- case GC_EVENT_TOPIC:
- params->hNotifyIcon = g_chatApi.hIcons[ICON_TOPIC];
- break;
- case GC_EVENT_ADDSTATUS:
- params->hNotifyIcon = g_chatApi.hIcons[ICON_ADDSTATUS];
- break;
- case GC_EVENT_REMOVESTATUS:
- params->hNotifyIcon = g_chatApi.hIcons[ICON_REMSTATUS];
- break;
}
}
- if (params->iEvent == GC_EVENT_MESSAGE) {
- params->bMustAutoswitch = true;
+ if (iEvent == GC_EVENT_MESSAGE) {
+ bMustAutoswitch = true;
if (g_Settings.bFlashWindow)
- params->bMustFlash = true;
- params->hNotifyIcon = g_chatApi.hIcons[ICON_MESSAGE];
+ bMustFlash = true;
}
}
+
if (dat && bFlagUnread) {
dat->m_dwUnread++;
if (dat->m_pWnd)
dat->m_pWnd->Invalidate();
}
- PostMessage(PluginConfig.g_hwndHotkeyHandler, DM_MUCFLASHWORKER, wParamForHighLight, (LPARAM)params);
- return TRUE;
+
+ if (1 == wParamForHighLight) {
+ Clist_ContactDoubleClicked(hContact);
+ bActiveTab = true;
+ bInactive = bMustAutoswitch = bMustFlash = false;
+ }
+
+ if (2 == wParamForHighLight) {
+ bActiveTab = true;
+ bInactive = bMustAutoswitch = bMustFlash = false;
+ SendMessage(hWnd, DM_ACTIVATEME, 0, 0);
+ }
+
+ auto sound = si->getSoundName(iEvent);
+ if (dat) {
+ bInactive = dat->m_pContainer->m_hwnd != GetForegroundWindow();
+ bActiveTab = (dat->m_pContainer->m_hwndActive == dat->GetHwnd());
+ if (sound && dat->MustPlaySound())
+ Skin_PlaySound(sound);
+ }
+ else if (sound)
+ Skin_PlaySound(sound);
+
+ // dialog event processing
+ if (dat == nullptr)
+ return true;
+
+ HICON hNotifyIcon = (bManyFix && !bInactive) ? 0 : g_chatApi.getIcon(iEvent);
+ BOOL bForcedIcon = (hNotifyIcon == g_chatApi.hIcons[ICON_HIGHLIGHT] || hNotifyIcon == g_chatApi.hIcons[ICON_MESSAGE]);
+
+ if ((iEvent & si->iLogTrayFlags) || bForcedIcon) {
+ if (!bActiveTab) {
+ if (hNotifyIcon == g_chatApi.hIcons[ICON_HIGHLIGHT])
+ dat->m_iFlashIcon = hNotifyIcon;
+ else {
+ if (dat->m_iFlashIcon != g_chatApi.hIcons[ICON_HIGHLIGHT] && dat->m_iFlashIcon != g_chatApi.hIcons[ICON_MESSAGE])
+ dat->m_iFlashIcon = hNotifyIcon;
+ }
+ dat->m_bCanFlashTab = TRUE;
+ dat->timerFlash.Start(TIMEOUT_FLASHWND);
+ }
+ }
+ if (dat->m_pWnd) {
+ dat->m_pWnd->updateIcon(hNotifyIcon);
+ dat->m_pWnd->setOverlayIcon(hNotifyIcon, true);
+ }
+
+ // autoswitch tab..
+ if (bMustAutoswitch) {
+ if ((IsIconic(dat->m_pContainer->m_hwnd)) && !IsZoomed(dat->m_pContainer->m_hwnd) && PluginConfig.m_bAutoSwitchTabs && dat->m_pContainer->m_hwndActive != dat->GetHwnd()) {
+ int iItem = GetTabIndexFromHWND(dat->m_pContainer->m_hwndTabs, dat->GetHwnd());
+ if (iItem >= 0) {
+ TabCtrl_SetCurSel(dat->m_pContainer->m_hwndTabs, iItem);
+ ShowWindow(dat->m_pContainer->m_hwndActive, SW_HIDE);
+ dat->m_pContainer->m_hwndActive = dat->GetHwnd();
+ dat->m_pContainer->UpdateTitle(dat->m_hContact);
+ dat->m_pContainer->m_flags.m_bDeferredTabSelect = true;
+ }
+ }
+ }
+
+ // flash window if it is not focused
+ if (bMustFlash && bInactive)
+ if (!dat->m_pContainer->m_flags.m_bNoFlash)
+ dat->m_pContainer->FlashContainer(1, 0);
+
+ if (hNotifyIcon && bInactive && ((iEvent & si->iLogTrayFlags) || bForcedIcon)) {
+ if (bMustFlash)
+ dat->m_hTabIcon = hNotifyIcon;
+ else if (dat->m_iFlashIcon) {
+ dat->m_hTabIcon = dat->m_iFlashIcon;
+
+ TCITEM item = {};
+ item.mask = TCIF_IMAGE;
+ item.iImage = 0;
+ TabCtrl_SetItem(GetParent(dat->GetHwnd()), dat->m_iTabID, &item);
+ }
+
+ HICON hIcon = (HICON)SendMessage(dat->m_pContainer->m_hwnd, WM_GETICON, ICON_BIG, 0);
+ if (hNotifyIcon == g_chatApi.hIcons[ICON_HIGHLIGHT] || (hIcon != g_chatApi.hIcons[ICON_MESSAGE] && hIcon != g_chatApi.hIcons[ICON_HIGHLIGHT])) {
+ dat->m_pContainer->SetIcon(dat, hNotifyIcon);
+ dat->m_pContainer->m_flags.m_bNeedsUpdateTitle = true;
+ }
+ }
+
+ if (bMustFlash && bInactive)
+ AddUnreadContact(dat->m_hContact);
+
+ return true;
}
wchar_t* my_strstri(const wchar_t* s1, const wchar_t* s2)
diff --git a/plugins/TabSRMM/src/hotkeyhandler.cpp b/plugins/TabSRMM/src/hotkeyhandler.cpp
index a2358b2b03..36c712279d 100644
--- a/plugins/TabSRMM/src/hotkeyhandler.cpp
+++ b/plugins/TabSRMM/src/hotkeyhandler.cpp
@@ -346,24 +346,6 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
CGlobals::logStatusChange(wParam, reinterpret_cast<CContactCache *>(lParam));
return 0;
- case DM_MUCFLASHWORKER:
- {
- FLASH_PARAMS *p = reinterpret_cast<FLASH_PARAMS*>(lParam);
- if (1 == wParam) {
- Clist_ContactDoubleClicked(p->hContact);
- p->bActiveTab = true;
- p->bInactive = p->bMustAutoswitch = p->bMustFlash = false;
- }
-
- if (2 == wParam) {
- p->bActiveTab = true;
- p->bInactive = p->bMustAutoswitch = p->bMustFlash = false;
- SendMessage(p->hWnd, DM_ACTIVATEME, 0, 0);
- }
- DoFlashAndSoundWorker(p);
- }
- return 0;
-
case WM_POWERBROADCAST:
case WM_DISPLAYCHANGE:
for (TContainerData *pCont = pFirstContainer; pCont; pCont = pCont->pNext)
diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h
index c1388281cb..a67ae4935d 100644
--- a/plugins/TabSRMM/src/msgs.h
+++ b/plugins/TabSRMM/src/msgs.h
@@ -722,7 +722,6 @@ struct TIconDescW
#define DM_CREATECONTAINER (TM_USER+26)
#define DM_QUERYLASTUNREAD (TM_USER+28)
#define DM_UPDATEPICLAYOUT (TM_USER+30)
-#define DM_MUCFLASHWORKER (TM_USER+32)
#define DM_APPENDMCEVENT (TM_USER+34)
#define DM_CHECKINFOTIP (TM_USER+35)
#define DM_SAVESIZE (TM_USER+36)
diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp
index 38744f5f3b..56418a4393 100644
--- a/src/mir_app/src/chat_manager.cpp
+++ b/src/mir_app/src/chat_manager.cpp
@@ -149,6 +149,35 @@ GCSessionInfoBase::GCSessionInfoBase() :
GCSessionInfoBase::~GCSessionInfoBase()
{}
+const char *GCSessionInfoBase::getSoundName(int iEventType) const
+{
+ // if sounds are filtered out for this event type, do nothing;
+ if (!(db_get_dw(0, CHAT_MODULE, "SoundFlags", GC_EVENT_HIGHLIGHT) & iEventType))
+ return nullptr;
+
+ // no sounds in the Mute mode
+ if (db_get_b(hContact, "SRMM", "MuteMode", CHATMODE_NORMAL) == CHATMODE_MUTE)
+ return nullptr;
+
+ switch (iEventType) {
+ case GC_EVENT_JOIN: return "ChatJoin";
+ case GC_EVENT_PART: return "ChatPart";
+ case GC_EVENT_QUIT: return "ChatQuit";
+ case GC_EVENT_ADDSTATUS:
+ case GC_EVENT_REMOVESTATUS: return "ChatMode";
+ case GC_EVENT_KICK: return "ChatKick";
+ case GC_EVENT_ACTION: return "ChatAction";
+ case GC_EVENT_NICK: return "ChatNick";
+ case GC_EVENT_NOTICE: return "ChatNotice";
+ case GC_EVENT_TOPIC: return "ChatTopic";
+ case GC_EVENT_MESSAGE:
+ bool bInactive = pDlg == nullptr || !pDlg->IsActive();
+ return (bInactive) ? "RecvMsgInactive" : "RecvMsgActive";
+ }
+
+ return nullptr;
+}
+
static SESSION_INFO* SM_CreateSession(void)
{
return new SESSION_INFO();
diff --git a/src/mir_app/src/chat_tools.cpp b/src/mir_app/src/chat_tools.cpp
index ffb7f3b62c..ae9fec2d5f 100644
--- a/src/mir_app/src/chat_tools.cpp
+++ b/src/mir_app/src/chat_tools.cpp
@@ -99,6 +99,32 @@ wchar_t* RemoveFormatting(const wchar_t *pszWord)
/////////////////////////////////////////////////////////////////////////////////////////
+HICON CHAT_MANAGER::getIcon(int iEventType) const
+{
+ switch (iEventType) {
+ case GC_EVENT_MESSAGE | GC_EVENT_HIGHLIGHT:
+ case GC_EVENT_ACTION | GC_EVENT_HIGHLIGHT:
+ return hIcons[ICON_HIGHLIGHT];
+
+ case GC_EVENT_MESSAGE: return g_chatApi.hIcons[ICON_MESSAGE];
+ case GC_EVENT_ACTION: return g_chatApi.hIcons[ICON_ACTION];
+ case GC_EVENT_JOIN: return g_chatApi.hIcons[ICON_JOIN];
+ case GC_EVENT_PART: return g_chatApi.hIcons[ICON_PART];
+ case GC_EVENT_QUIT: return g_chatApi.hIcons[ICON_QUIT];
+ case GC_EVENT_NICK: return g_chatApi.hIcons[ICON_NICK];
+ case GC_EVENT_KICK: return g_chatApi.hIcons[ICON_KICK];
+ case GC_EVENT_NOTICE: return g_chatApi.hIcons[ICON_NOTICE];
+ case GC_EVENT_TOPIC: return g_chatApi.hIcons[ICON_TOPIC];
+ case GC_EVENT_INFORMATION: return g_chatApi.hIcons[ICON_INFO];
+ case GC_EVENT_ADDSTATUS: return g_chatApi.hIcons[ICON_ADDSTATUS];
+ case GC_EVENT_REMOVESTATUS: return g_chatApi.hIcons[ICON_REMSTATUS];
+ default:
+ return nullptr;
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
static INT_PTR EventDoubleclicked(WPARAM, LPARAM lParam)
{
return RoomDoubleclicked((WPARAM)((CLISTEVENT *)lParam)->hContact, 0);
@@ -133,8 +159,6 @@ static void AddEvent(MCONTACT hContact, HICON hIcon, int type, const wchar_t *pw
BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce)
{
- HICON hIcon;
- CMStringW wszText;
int iMuteMode = db_get_b(si->hContact, "SRMM", "MuteMode", CHATMODE_NORMAL);
switch (iMuteMode) {
case CHATMODE_MUTE: iMuteMode = CLEF_ONLYAFEW; break;
@@ -143,65 +167,53 @@ BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce)
iMuteMode = (gce->iType & GC_EVENT_HIGHLIGHT) ? 0 : CLEF_ONLYAFEW;
}
+ CMStringW wszText;
switch (gce->iType) {
case GC_EVENT_MESSAGE | GC_EVENT_HIGHLIGHT:
case GC_EVENT_ACTION | GC_EVENT_HIGHLIGHT:
- hIcon = Skin_LoadIcon(SKINICON_EVENT_MESSAGE);
wszText.Format(TranslateT("%s wants your attention in %s"), gce->pszNick.w, si->ptszName);
break;
case GC_EVENT_MESSAGE:
- hIcon = g_chatApi.hIcons[ICON_MESSAGE];
wszText.Format(TranslateT("%s speaks in %s"), gce->pszNick.w, si->ptszName);
break;
case GC_EVENT_ACTION:
- hIcon = g_chatApi.hIcons[ICON_ACTION];
wszText.Format(TranslateT("%s speaks in %s"), gce->pszNick.w, si->ptszName);
break;
case GC_EVENT_JOIN:
- hIcon = g_chatApi.hIcons[ICON_JOIN];
wszText.Format(TranslateT("%s has joined %s"), gce->pszNick.w, si->ptszName);
break;
case GC_EVENT_PART:
- hIcon = g_chatApi.hIcons[ICON_PART];
wszText.Format(TranslateT("%s has left %s"), gce->pszNick.w, si->ptszName);
break;
case GC_EVENT_QUIT:
- hIcon = g_chatApi.hIcons[ICON_QUIT];
wszText.Format(TranslateT("%s has disconnected"), gce->pszNick.w);
break;
case GC_EVENT_NICK:
- hIcon = g_chatApi.hIcons[ICON_NICK];
wszText.Format(TranslateT("%s is now known as %s"), gce->pszNick.w, gce->pszText.w);
break;
case GC_EVENT_KICK:
- hIcon = g_chatApi.hIcons[ICON_KICK];
wszText.Format(TranslateT("%s kicked %s from %s"), gce->pszStatus.w, gce->pszNick.w, si->ptszName);
break;
case GC_EVENT_NOTICE:
- hIcon = g_chatApi.hIcons[ICON_NOTICE];
wszText.Format(TranslateT("Notice from %s"), gce->pszNick.w);
break;
case GC_EVENT_TOPIC:
- hIcon = g_chatApi.hIcons[ICON_TOPIC];
wszText.Format(TranslateT("Topic change in %s"), si->ptszName);
break;
case GC_EVENT_INFORMATION:
- hIcon = g_chatApi.hIcons[ICON_INFO];
wszText.Format(TranslateT("Information in %s"), si->ptszName);
break;
case GC_EVENT_ADDSTATUS:
- hIcon = g_chatApi.hIcons[ICON_ADDSTATUS];
wszText.Format(TranslateT("%s enables '%s' status for %s in %s"), gce->pszText.w, gce->pszStatus.w, gce->pszNick.w, si->ptszName);
break;
case GC_EVENT_REMOVESTATUS:
- hIcon = g_chatApi.hIcons[ICON_REMSTATUS];
wszText.Format(TranslateT("%s disables '%s' status for %s in %s"), gce->pszText.w, gce->pszStatus.w, gce->pszNick.w, si->ptszName);
break;
default:
return FALSE;
}
- AddEvent(si->hContact, hIcon, iMuteMode, wszText);
+ AddEvent(si->hContact, g_chatApi.getIcon(gce->iType), iMuteMode, wszText);
return TRUE;
}
@@ -290,51 +302,50 @@ BOOL DoPopup(SESSION_INFO *si, GCEVENT *gce)
g_chatApi.CreateNick(si, &lin, wszNick);
bool bTextUsed = Chat_GetDefaultEventDescr(si, &lin, wszText);
- HICON hIcon = nullptr;
COLORREF dwColor = 0;
switch (gce->iType) {
case GC_EVENT_MESSAGE | GC_EVENT_HIGHLIGHT:
- hIcon = Skin_LoadIcon(SKINICON_EVENT_MESSAGE); dwColor = g_chatApi.aFonts[16].color; wszText.Format(TranslateT("%s says"), wszNick.c_str());
+ dwColor = g_chatApi.aFonts[16].color; wszText.Format(TranslateT("%s says"), wszNick.c_str());
break;
case GC_EVENT_ACTION | GC_EVENT_HIGHLIGHT:
- hIcon = Skin_LoadIcon(SKINICON_EVENT_MESSAGE); dwColor = g_chatApi.aFonts[16].color;
+ dwColor = g_chatApi.aFonts[16].color;
break;
case GC_EVENT_MESSAGE:
- hIcon = g_chatApi.hIcons[ICON_MESSAGE]; dwColor = g_chatApi.aFonts[9].color; wszText.Format(TranslateT("%s says"), wszNick.c_str());
+ dwColor = g_chatApi.aFonts[9].color; wszText.Format(TranslateT("%s says"), wszNick.c_str());
break;
case GC_EVENT_ACTION:
- hIcon = g_chatApi.hIcons[ICON_ACTION]; dwColor = g_chatApi.aFonts[15].color;
+ dwColor = g_chatApi.aFonts[15].color;
break;
case GC_EVENT_JOIN:
- hIcon = g_chatApi.hIcons[ICON_JOIN]; dwColor = g_chatApi.aFonts[3].color;
+ dwColor = g_chatApi.aFonts[3].color;
break;
case GC_EVENT_PART:
- hIcon = g_chatApi.hIcons[ICON_PART]; dwColor = g_chatApi.aFonts[4].color;
+ dwColor = g_chatApi.aFonts[4].color;
break;
case GC_EVENT_QUIT:
- hIcon = g_chatApi.hIcons[ICON_QUIT]; dwColor = g_chatApi.aFonts[5].color;
+ dwColor = g_chatApi.aFonts[5].color;
break;
case GC_EVENT_NICK:
- hIcon = g_chatApi.hIcons[ICON_NICK]; dwColor = g_chatApi.aFonts[7].color;
+ dwColor = g_chatApi.aFonts[7].color;
break;
case GC_EVENT_KICK:
- hIcon = g_chatApi.hIcons[ICON_KICK]; dwColor = g_chatApi.aFonts[6].color;
+ dwColor = g_chatApi.aFonts[6].color;
break;
case GC_EVENT_NOTICE:
- hIcon = g_chatApi.hIcons[ICON_NOTICE]; dwColor = g_chatApi.aFonts[8].color;
+ dwColor = g_chatApi.aFonts[8].color;
break;
case GC_EVENT_TOPIC:
- hIcon = g_chatApi.hIcons[ICON_TOPIC]; dwColor = g_chatApi.aFonts[11].color;
+ dwColor = g_chatApi.aFonts[11].color;
break;
case GC_EVENT_INFORMATION:
- hIcon = g_chatApi.hIcons[ICON_INFO]; dwColor = g_chatApi.aFonts[12].color;
+ dwColor = g_chatApi.aFonts[12].color;
break;
case GC_EVENT_ADDSTATUS:
- hIcon = g_chatApi.hIcons[ICON_ADDSTATUS]; dwColor = g_chatApi.aFonts[13].color;
+ dwColor = g_chatApi.aFonts[13].color;
break;
case GC_EVENT_REMOVESTATUS:
- hIcon = g_chatApi.hIcons[ICON_REMSTATUS]; dwColor = g_chatApi.aFonts[14].color;
+ dwColor = g_chatApi.aFonts[14].color;
break;
}
@@ -344,7 +355,7 @@ BOOL DoPopup(SESSION_INFO *si, GCEVENT *gce)
wszText.Append(RemoveFormatting(gce->pszText.w));
}
- g_chatApi.ShowPopup(si->hContact, si, hIcon, si->pszModule, si->ptszName, dwColor, L"%s", wszText.c_str());
+ g_chatApi.ShowPopup(si->hContact, si, g_chatApi.getIcon(gce->iType), si->pszModule, si->ptszName, dwColor, L"%s", wszText.c_str());
return TRUE;
}
@@ -395,32 +406,17 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight
g_chatApi.DoPopup(si, gce);
// do sounds and flashing
- const char *szSound = nullptr;
- switch (iEvent) {
- case GC_EVENT_JOIN: szSound = "ChatJoin"; break;
- case GC_EVENT_PART: szSound = "ChatPart"; break;
- case GC_EVENT_QUIT: szSound = "ChatQuit"; break;
- case GC_EVENT_ADDSTATUS:
- case GC_EVENT_REMOVESTATUS: szSound = "ChatMode"; break;
- case GC_EVENT_KICK: szSound = "ChatKick"; break;
- case GC_EVENT_ACTION: szSound = "ChatAction"; break;
- case GC_EVENT_NICK: szSound = "ChatNick"; break;
- case GC_EVENT_NOTICE: szSound = "ChatNotice"; break;
- case GC_EVENT_TOPIC: szSound = "ChatTopic"; break;
- case GC_EVENT_MESSAGE:
- szSound = (bInactive) ? "RecvMsgInactive" : "RecvMsgActive";
-
+ if (iEvent == GC_EVENT_MESSAGE) {
if (bInactive && !(si->wState & STATE_TALK)) {
si->wState |= STATE_TALK;
db_set_w(si->hContact, si->pszModule, "ApparentMode", ID_STATUS_OFFLINE);
}
if (g_chatApi.OnFlashWindow)
g_chatApi.OnFlashWindow(si, bInactive);
- break;
}
- if (db_get_dw(0, CHAT_MODULE, "SoundFlags", GC_EVENT_HIGHLIGHT) & iEvent)
- if (!bMute && szSound && (bInactive || !g_Settings->bSoundsFocus))
+ if (bInactive || !g_Settings->bSoundsFocus)
+ if (auto szSound = si->getSoundName(iEvent))
Skin_PlaySound(szSound);
}
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index 61a832b972..4b96d291ad 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -772,3 +772,5 @@ _Netlib_GetTlsUnique@8 @831 NONAME
?Tray1Click@Clist@@3V?$CMOption@_N@@A @860 NONAME
?TrayAlwaysStatus@Clist@@3V?$CMOption@_N@@A @861 NONAME
?Flush@MDatabaseCommon@@UAGHXZ @862 NONAME
+?getIcon@CHAT_MANAGER@@QBGPAUHICON__@@H@Z @863 NONAME
+?getSoundName@GCSessionInfoBase@@QBEPBDH@Z @864 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index b0b9a06846..bc23f0f01b 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -772,3 +772,5 @@ Netlib_GetTlsUnique @831 NONAME
?Tray1Click@Clist@@3V?$CMOption@_N@@A @860 NONAME
?TrayAlwaysStatus@Clist@@3V?$CMOption@_N@@A @861 NONAME
?Flush@MDatabaseCommon@@UEAAHXZ @862 NONAME
+?getIcon@CHAT_MANAGER@@QEBAPEAUHICON__@@H@Z @863 NONAME
+?getSoundName@GCSessionInfoBase@@QEBAPEBDH@Z @864 NONAME