From 290518a76e3dbed5f3452f9e210c90246c8875d4 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 8 Jun 2018 19:44:51 +0300 Subject: merge of recent SRMM-related fixes --- src/core/stdmsg/src/chat_manager.cpp | 6 ++---- src/core/stdmsg/src/chat_options.cpp | 10 +++++----- src/core/stdmsg/src/chat_window.cpp | 5 +++-- src/core/stdmsg/src/globals.h | 2 ++ src/core/stdmsg/src/msgdialog.cpp | 8 +------- src/core/stdmsg/src/msglog.cpp | 33 +++++++++++++++++++++++++++++++++ src/core/stdmsg/src/msgs.cpp | 3 ++- src/core/stdmsg/src/stdafx.h | 1 - 8 files changed, 48 insertions(+), 20 deletions(-) (limited to 'src/core') diff --git a/src/core/stdmsg/src/chat_manager.cpp b/src/core/stdmsg/src/chat_manager.cpp index 288c306ec3..3a79ce73b2 100644 --- a/src/core/stdmsg/src/chat_manager.cpp +++ b/src/core/stdmsg/src/chat_manager.cpp @@ -59,8 +59,6 @@ CHAT_MANAGER *pci; HMENU g_hMenu = nullptr; -BOOL SmileyAddInstalled = FALSE, PopupInstalled = FALSE; - GlobalLogSettings g_Settings; static void OnDestroyModule(MODULEINFO *mi) @@ -222,8 +220,8 @@ static void ShowRoom(SESSION_INFO *si) int OnCheckPlugins(WPARAM, LPARAM) { - SmileyAddInstalled = ServiceExists(MS_SMILEYADD_REPLACESMILEYS); - PopupInstalled = ServiceExists(MS_POPUP_ADDPOPUPT); + g_dat.bSmileyInstalled = ServiceExists(MS_SMILEYADD_REPLACESMILEYS); + g_dat.bPopupInstalled = ServiceExists(MS_POPUP_ADDPOPUPT); return 0; } diff --git a/src/core/stdmsg/src/chat_options.cpp b/src/core/stdmsg/src/chat_options.cpp index 9d7080484b..4b396581f9 100644 --- a/src/core/stdmsg/src/chat_options.cpp +++ b/src/core/stdmsg/src/chat_options.cpp @@ -327,7 +327,7 @@ class COptMainDlg : public CDlgBase CheckHeading(hListHeading3); CheckHeading(hListHeading4); CheckHeading(hListHeading5); - if (PopupInstalled) + if (g_dat.bPopupInstalled) CheckHeading(hListHeading6); } @@ -355,7 +355,7 @@ public: FillBranch(hListHeading4, branch4, _countof(branch4), 0x0000); FillBranch(hListHeading5, branch5, _countof(branch5), 0x1000); - if (PopupInstalled) { + if (g_dat.bPopupInstalled) { hListHeading6 = InsertBranch(LPGEN("Popups to display"), db_get_b(0, CHAT_MODULE, "Branch6Exp", 0) ? TRUE : FALSE); FillBranch(hListHeading6, branch6, _countof(branch6), 0x0000); } @@ -369,7 +369,7 @@ public: SaveBranch(branch3, _countof(branch3)); SaveBranch(branch4, _countof(branch4)); SaveBranch(branch5, _countof(branch5)); - if (PopupInstalled) + if (g_dat.bPopupInstalled) SaveBranch(branch6, _countof(branch6)); pci->ReloadSettings(); @@ -389,7 +389,7 @@ public: b = checkBoxes.GetItemState(hListHeading5, TVIS_EXPANDED) & TVIS_EXPANDED ? 1 : 0; db_set_b(0, CHAT_MODULE, "Branch5Exp", b); - if (PopupInstalled) { + if (g_dat.bPopupInstalled) { b = checkBoxes.GetItemState(hListHeading6, TVIS_EXPANDED) & TVIS_EXPANDED ? 1 : 0; db_set_b(0, CHAT_MODULE, "Branch6Exp", b); } @@ -676,7 +676,7 @@ int ChatOptionsInitialize(WPARAM wParam) odp.pDialog = new COptLogDlg(); Options_AddPage(wParam, &odp); - if (PopupInstalled) { + if (g_dat.bPopupInstalled) { odp.position = 910000002; odp.szTitle.a = LPGEN("Chat"); odp.szGroup.a = LPGEN("Popups"); diff --git a/src/core/stdmsg/src/chat_window.cpp b/src/core/stdmsg/src/chat_window.cpp index 5df7a4fb4f..8083576333 100644 --- a/src/core/stdmsg/src/chat_window.cpp +++ b/src/core/stdmsg/src/chat_window.cpp @@ -369,7 +369,8 @@ void CChatRoomDlg::UpdateTitle() break; } - SetWindowText(m_pOwner->GetHwnd(), szTemp); + if (this == m_pOwner->CurrPage()) + SetWindowText(m_pOwner->GetHwnd(), szTemp); } ///////////////////////////////////////////////////////////////////////////////////////// @@ -436,7 +437,7 @@ void CChatRoomDlg::StreamInEvents(LOGINFO *lin, bool bRedraw) m_log.SendMsg(EM_STREAMIN, wp, (LPARAM)&stream); // do smileys - if (SmileyAddInstalled && (bRedraw || (lin->ptszText && lin->iType != GC_EVENT_JOIN && lin->iType != GC_EVENT_NICK && lin->iType != GC_EVENT_ADDSTATUS && lin->iType != GC_EVENT_REMOVESTATUS))) { + if (g_dat.bSmileyInstalled && (bRedraw || (lin->ptszText && lin->iType != GC_EVENT_JOIN && lin->iType != GC_EVENT_NICK && lin->iType != GC_EVENT_ADDSTATUS && lin->iType != GC_EVENT_REMOVESTATUS))) { CHARRANGE newsel; newsel.cpMax = -1; newsel.cpMin = sel.cpMin; diff --git a/src/core/stdmsg/src/globals.h b/src/core/stdmsg/src/globals.h index 78148da5cd..0c4d9d3205 100644 --- a/src/core/stdmsg/src/globals.h +++ b/src/core/stdmsg/src/globals.h @@ -64,6 +64,8 @@ struct GlobalMessageData CMOption iLoadHistory; CMOption nLoadCount, nLoadTime; + + bool bSmileyInstalled = false, bPopupInstalled = false; }; void InitGlobals(); diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp index 90029de1c6..3fb5a62086 100644 --- a/src/core/stdmsg/src/msgdialog.cpp +++ b/src/core/stdmsg/src/msgdialog.cpp @@ -1195,13 +1195,7 @@ INT_PTR CSrmmWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) break; case WM_TIMER: - if (wParam == TIMERID_FLASHWND) { - if (m_nFlash > 2 * g_dat.nFlashMax) { - StopFlash(); - return 0; - } - } - else if (wParam == TIMERID_TYPE) { + if (wParam == TIMERID_TYPE) { ShowTime(false); if (m_nTypeMode == PROTOTYPE_SELFTYPING_ON && GetTickCount() - m_nLastTyping > TIMEOUT_TYPEOFF) NotifyTyping(PROTOTYPE_SELFTYPING_OFF); diff --git a/src/core/stdmsg/src/msglog.cpp b/src/core/stdmsg/src/msglog.cpp index b06bdb9b64..c3527c5660 100644 --- a/src/core/stdmsg/src/msglog.cpp +++ b/src/core/stdmsg/src/msglog.cpp @@ -425,9 +425,21 @@ void CSrmmWindow::StreamInEvents(MEVENT hDbEventFirst, int count, bool bAppend) if (!bottomScroll) m_log.SendMsg(EM_GETSCROLLPOS, 0, (LPARAM)&scrollPos); } + + FINDTEXTEXA fi; if (bAppend) { sel.cpMin = sel.cpMax = -1; m_log.SendMsg(EM_EXSETSEL, 0, (LPARAM)&sel); + fi.chrg.cpMin = 0; + } + else { + GETTEXTLENGTHEX gtxl = { 0 }; + gtxl.flags = GTL_DEFAULT | GTL_PRECISE | GTL_NUMCHARS; + gtxl.codepage = 1200; + fi.chrg.cpMin = m_log.SendMsg(EM_GETTEXTLENGTHEX, (WPARAM)>xl, 0); + + sel.cpMin = sel.cpMax = m_log.GetRichTextLength(); + m_log.SendMsg(EM_EXSETSEL, 0, (LPARAM)&sel); } mir_strcpy(szSep2, bAppend ? "\\par\\sl0" : "\\sl1000"); @@ -444,6 +456,27 @@ void CSrmmWindow::StreamInEvents(MEVENT hDbEventFirst, int count, bool bAppend) m_log.SendMsg(EM_SETSCROLLPOS, 0, (LPARAM)&scrollPos); } + if (g_dat.bSmileyInstalled) { + SMADD_RICHEDIT3 smre; + smre.cbSize = sizeof(SMADD_RICHEDIT3); + smre.hwndRichEditControl = m_log.GetHwnd(); + + MCONTACT hContact = db_mc_getSrmmSub(m_hContact); + smre.Protocolname = (hContact != 0) ? GetContactProto(hContact) : m_szProto; + + if (fi.chrg.cpMin > 0) { + sel.cpMin = fi.chrg.cpMin; + sel.cpMax = -1; + smre.rangeToReplace = &sel; + } + else smre.rangeToReplace = nullptr; + + smre.disableRedraw = TRUE; + smre.hContact = m_hContact; + smre.flags = 0; + CallService(MS_SMILEYADD_REPLACESMILEYS, 0, (LPARAM)&smre); + } + m_log.SendMsg(WM_SETREDRAW, TRUE, 0); if (bottomScroll) RedrawWindow(m_log.GetHwnd(), nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW); diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp index e94b2386b5..6e08f26fc2 100644 --- a/src/core/stdmsg/src/msgs.cpp +++ b/src/core/stdmsg/src/msgs.cpp @@ -53,7 +53,8 @@ INT_PTR CMsgDialog::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) case WM_TIMER: if (wParam == TIMERID_FLASHWND) { m_pOwner->FixTabIcons(this); - FlashWindow(m_pOwner->GetHwnd(), TRUE); + if (m_nFlash < 2 * g_dat.nFlashMax) + FlashWindow(m_pOwner->GetHwnd(), TRUE); m_nFlash++; } break; diff --git a/src/core/stdmsg/src/stdafx.h b/src/core/stdmsg/src/stdafx.h index 3baa9a50a5..9cfeb98d6d 100644 --- a/src/core/stdmsg/src/stdafx.h +++ b/src/core/stdmsg/src/stdafx.h @@ -113,7 +113,6 @@ extern GlobalLogSettings g_Settings; extern HMENU g_hMenu; extern HINSTANCE g_hInst; -extern BOOL SmileyAddInstalled, PopupInstalled; // main.cpp void LoadIcons(void); -- cgit v1.2.3