From 93545c9575e94cb9015827525a8737437f80166a Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 2 Aug 2023 21:40:08 +0300 Subject: =?UTF-8?q?fixes=20#3605=20(NewsAggregator:=20=D0=BF=D1=80=D0=B8?= =?UTF-8?q?=20=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D0=B8=20=D0=B2=D1=81=D1=82=D1=80=D0=BE=D0=B5=D0=BD?= =?UTF-8?q?=D0=BD=D0=BE=D0=B3=D0=BE=20=D0=B6=D1=83=D1=80=D0=BD=D0=B0=D0=BB?= =?UTF-8?q?=D0=B0=20StdMsg=20=D0=B8=D0=BB=D0=B8=20Scriver=20=D0=BE=D1=82?= =?UTF-8?q?=D0=BA=D1=80=D1=8B=D1=82=D1=8B=D0=B9=20=D0=B8=D0=B7=20=D1=81?= =?UTF-8?q?=D0=BF=D0=B8=D1=81=D0=BA=D0=B0=20=D0=BA=D0=BE=D0=BD=D1=82=D0=B0?= =?UTF-8?q?=D0=BA=D1=82=D0=BE=D0=B2=20=D1=84=D0=B8=D0=B4=20=D0=BF=D1=83?= =?UTF-8?q?=D1=81=D1=82)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes #3523 (NewsAggregator и история сообщений.) --- src/core/stdmsg/src/msgs.cpp | 119 +++++++++++++++++++++++++------------------ 1 file changed, 69 insertions(+), 50 deletions(-) (limited to 'src/core/stdmsg') diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp index 0e9287aca7..e9c3b0df20 100644 --- a/src/core/stdmsg/src/msgs.cpp +++ b/src/core/stdmsg/src/msgs.cpp @@ -50,75 +50,94 @@ int SendMessageDirect(const wchar_t *szMsg, MCONTACT hContact) return sendId; } +///////////////////////////////////////////////////////////////////////////////////////// + static int SRMMStatusToPf2(int status) { switch (status) { - case ID_STATUS_ONLINE: return PF2_ONLINE; - case ID_STATUS_AWAY: return PF2_SHORTAWAY; - case ID_STATUS_DND: return PF2_HEAVYDND; - case ID_STATUS_NA: return PF2_LONGAWAY; - case ID_STATUS_OCCUPIED: return PF2_LIGHTDND; - case ID_STATUS_FREECHAT: return PF2_FREECHAT; - case ID_STATUS_INVISIBLE: return PF2_INVISIBLE; - case ID_STATUS_OFFLINE: return MODEF_OFFLINE; + case ID_STATUS_ONLINE: return PF2_ONLINE; + case ID_STATUS_AWAY: return PF2_SHORTAWAY; + case ID_STATUS_DND: return PF2_HEAVYDND; + case ID_STATUS_NA: return PF2_LONGAWAY; + case ID_STATUS_OCCUPIED: return PF2_LIGHTDND; + case ID_STATUS_FREECHAT: return PF2_FREECHAT; + case ID_STATUS_INVISIBLE: return PF2_INVISIBLE; + case ID_STATUS_OFFLINE: return MODEF_OFFLINE; } return 0; } -static int MessageEventAdded(WPARAM hContact, LPARAM hDbEvent) +struct CAutoPopup : public MAsyncObject { - if (hContact == 0 || Contact::IsGroupChat(hContact)) - return 0; - - DB::EventInfo dbei(hDbEvent, false); - if (!dbei) - return 0; + MCONTACT hContact; + MEVENT hDbEvent; - if (dbei.markedRead() || !DbEventIsShown(dbei)) - return 0; + CAutoPopup(MCONTACT _1, MEVENT _2) : + hContact(_1), + hDbEvent(_2) + {} - bool bPopup = false; - char *szProto = Proto_GetBaseAccountName(hContact); - if (szProto && (g_plugin.popupFlags & SRMMStatusToPf2(Proto_GetStatus(szProto)))) - bPopup = true; + void Invoke() override + { + bool bPopup = false; + char *szProto = Proto_GetBaseAccountName(hContact); + if (szProto && (g_plugin.popupFlags & SRMMStatusToPf2(Proto_GetStatus(szProto)))) + bPopup = true; + + /* does a window for the contact exist? */ + CTabbedWindow *pContainer = nullptr; + auto *pDlg = Srmm_FindDialog(hContact); + if (!pDlg) { + if (bPopup) { + pDlg = GetContainer()->AddPage(hContact, nullptr, true); + pContainer = pDlg->getOwner(); + } - /* does a window for the contact exist? */ - CTabbedWindow *pContainer = nullptr; - auto *pDlg = Srmm_FindDialog(hContact); - if (!pDlg) { - if (bPopup) { - pDlg = GetContainer()->AddPage(hContact, nullptr, true); + Skin_PlaySound("AlertMsg"); + Srmm_AddEvent(hContact, hDbEvent); + } + else { pContainer = pDlg->getOwner(); + if (bPopup) + ShowWindow(pContainer->GetHwnd(), SW_RESTORE); + + if (pContainer->CurrPage() != pDlg) + Srmm_AddEvent(hContact, hDbEvent); } - - Skin_PlaySound("AlertMsg"); - Srmm_AddEvent(hContact, hDbEvent); - } - else { - pContainer = pDlg->getOwner(); - if (bPopup) - ShowWindow(pContainer->GetHwnd(), SW_RESTORE); - if (pContainer->CurrPage() != pDlg) - Srmm_AddEvent(hContact, hDbEvent); + if (pContainer) { + if (bPopup && g_Settings.bTabsEnable && GetForegroundWindow() != pContainer->GetHwnd()) + g_pTabDialog->m_tab.ActivatePage(g_pTabDialog->m_tab.GetDlgIndex(pDlg)); + + if (!g_plugin.bDoNotStealFocus) { + SetForegroundWindow(pContainer->GetHwnd()); + Skin_PlaySound("RecvMsgActive"); + } + else { + if (GetForegroundWindow() == GetParent(pContainer->GetHwnd())) + Skin_PlaySound("RecvMsgActive"); + else + Skin_PlaySound("RecvMsgInactive"); + } + } } +}; + +///////////////////////////////////////////////////////////////////////////////////////// + +static int MessageEventAdded(WPARAM hContact, LPARAM hDbEvent) +{ + if (hContact == 0 || Contact::IsGroupChat(hContact)) + return 0; - if (!pContainer) + DB::EventInfo dbei(hDbEvent, false); + if (!dbei) return 0; - if (bPopup && g_Settings.bTabsEnable && GetForegroundWindow() != pContainer->GetHwnd()) - g_pTabDialog->m_tab.ActivatePage(g_pTabDialog->m_tab.GetDlgIndex(pDlg)); + if (dbei.markedRead() || !DbEventIsShown(dbei)) + return 0; - if (!g_plugin.bDoNotStealFocus) { - SetForegroundWindow(pContainer->GetHwnd()); - Skin_PlaySound("RecvMsgActive"); - } - else { - if (GetForegroundWindow() == GetParent(pContainer->GetHwnd())) - Skin_PlaySound("RecvMsgActive"); - else - Skin_PlaySound("RecvMsgInactive"); - } + Utils_InvokeAsync(new CAutoPopup(hContact, hDbEvent)); return 0; } -- cgit v1.2.3