From 90c87cac6ad51642d1dd9d9a2400450e667e1da7 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 26 Mar 2022 15:41:27 +0300 Subject: =?UTF-8?q?fixes=20#3057=20(=D0=A3=D0=BD=D0=B8=D1=84=D0=B8=D1=86?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D1=82=D1=8C=20=D0=BD=D0=B0=D1=81?= =?UTF-8?q?=D1=82=D1=80=D0=BE=D0=B9=D0=BA=D1=83=20=D0=B3=D0=BE=D1=80=D1=8F?= =?UTF-8?q?=D1=87=D0=B8=D1=85=20=D0=BA=D0=BB=D0=B0=D0=B2=D0=B8=D1=88=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D0=BE=D1=82=D0=BF=D1=80=D0=B0=D0=B2=D0=BA?= =?UTF-8?q?=D0=B8=20=D1=81=D0=BE=D0=BE=D0=B1=D1=89=D0=B5=D0=BD=D0=B8=D0=B9?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/stdmsg/res/resource.rc | 4 -- src/core/stdmsg/src/chat_manager.cpp | 4 +- src/core/stdmsg/src/chat_window.cpp | 2 +- src/core/stdmsg/src/cmdlist.cpp | 2 +- src/core/stdmsg/src/globals.cpp | 53 +------------- src/core/stdmsg/src/globals.h | 74 -------------------- src/core/stdmsg/src/msgdialog.cpp | 110 ++++++++++------------------- src/core/stdmsg/src/msglog.cpp | 16 ++--- src/core/stdmsg/src/msgoptions.cpp | 124 ++++++++++++++++----------------- src/core/stdmsg/src/msgs.cpp | 14 ++-- src/core/stdmsg/src/msgs.h | 1 - src/core/stdmsg/src/resource.h | 3 - src/core/stdmsg/src/srmm.cpp | 42 ++++++++++- src/core/stdmsg/src/stdafx.h | 42 ++++++++++- src/core/stdmsg/src/tabs.cpp | 10 +-- src/core/stdmsg/stdmsg.vcxproj | 1 - src/core/stdmsg/stdmsg.vcxproj.filters | 3 - src/mir_app/src/chat.h | 2 + src/mir_app/src/hotkeys.cpp | 2 +- src/mir_app/src/miranda.h | 2 + src/mir_app/src/srmm_base.cpp | 12 ++++ src/mir_app/src/srmm_log.cpp | 2 +- src/mir_app/src/srmm_util.cpp | 24 +++++++ 23 files changed, 247 insertions(+), 302 deletions(-) delete mode 100644 src/core/stdmsg/src/globals.h (limited to 'src') diff --git a/src/core/stdmsg/res/resource.rc b/src/core/stdmsg/res/resource.rc index 752f5c20a8..44b399894c 100644 --- a/src/core/stdmsg/res/resource.rc +++ b/src/core/stdmsg/res/resource.rc @@ -60,10 +60,6 @@ BEGIN CONTROL "Show character count",IDC_CHARCOUNT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,179,135,10 CONTROL "Show toolbar buttons on top row",IDC_SHOWBUTTONLINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,192,139,10 - CONTROL "Send message on double 'Enter'",IDC_SENDONDBLENTER,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,150,166,150,10 - CONTROL "Send message on 'Enter'",IDC_SENDONENTER,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,150,179,150,10 - CONTROL "Send message on 'Ctrl+Enter'",IDC_SENDONCTRLENTER, "Button",BS_AUTORADIOBUTTON | WS_TABSTOP,150,192,150,10 - LTEXT "Show warning when message has not been received after",IDC_STATIC,8,208,211,8 EDITTEXT IDC_SECONDS,223,206,25,12,ES_AUTOHSCROLL LTEXT "seconds",IDC_STATIC,253,208,44,8 diff --git a/src/core/stdmsg/src/chat_manager.cpp b/src/core/stdmsg/src/chat_manager.cpp index 3bcb8a3296..4ee8d5be72 100644 --- a/src/core/stdmsg/src/chat_manager.cpp +++ b/src/core/stdmsg/src/chat_manager.cpp @@ -205,7 +205,7 @@ static void ShowRoom(SESSION_INFO *si) int OnCheckPlugins(WPARAM, LPARAM) { - g_dat.bSmileyInstalled = ServiceExists(MS_SMILEYADD_REPLACESMILEYS); + g_plugin.bSmileyInstalled = ServiceExists(MS_SMILEYADD_REPLACESMILEYS); return 0; } @@ -225,6 +225,8 @@ void Load_ChatModule() g_chatApi.OnFlashHighlight = OnFlashHighlight; g_chatApi.ShowRoom = ShowRoom; + Srmm_CreateHotkey(LPGEN("Messaging"), LPGEN("Send message")); + oldDoPopup = g_chatApi.DoPopup; g_chatApi.DoPopup = DoPopup; oldDoTrayIcon = g_chatApi.DoTrayIcon; g_chatApi.DoTrayIcon = DoTrayIcon; g_chatApi.ReloadSettings(); diff --git a/src/core/stdmsg/src/chat_window.cpp b/src/core/stdmsg/src/chat_window.cpp index 39dce9b2a4..39edc37781 100644 --- a/src/core/stdmsg/src/chat_window.cpp +++ b/src/core/stdmsg/src/chat_window.cpp @@ -174,7 +174,7 @@ void CLogWindow::LogEvents(LOGINFO *lin, bool bRedraw) m_rtf.SendMsg(EM_STREAMIN, wp, (LPARAM)&stream); // do smileys - 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))) { + if (g_plugin.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/cmdlist.cpp b/src/core/stdmsg/src/cmdlist.cpp index a82acfa495..7f8a420cbe 100644 --- a/src/core/stdmsg/src/cmdlist.cpp +++ b/src/core/stdmsg/src/cmdlist.cpp @@ -34,7 +34,7 @@ static VOID CALLBACK MsgTimer(HWND, UINT, UINT_PTR, DWORD dwTime) mir_cslock lck(csMsgQueue); for (auto &it : msgQueue.rev_iter()) - if (dwTime - it->ts > g_dat.msgTimeout) { + if (dwTime - it->ts > g_plugin.msgTimeout) { arTimedOut.insert(it); msgQueue.removeItem(&it); } diff --git a/src/core/stdmsg/src/globals.cpp b/src/core/stdmsg/src/globals.cpp index a2d6e175fe..de2ca11c6d 100644 --- a/src/core/stdmsg/src/globals.cpp +++ b/src/core/stdmsg/src/globals.cpp @@ -97,65 +97,14 @@ static int AvatarChanged(WPARAM hContact, LPARAM lParam) ///////////////////////////////////////////////////////////////////////////////////////// -GlobalMessageData g_dat; - -GlobalMessageData::GlobalMessageData() : - bShowDate(SRMMMOD, "ShowDate", false), - bShowTime(SRMMMOD, "ShowTime", true), - bShowSecs(SRMMMOD, "ShowSeconds", true), - bShowIcons(SRMMMOD, "ShowLogIcon", true), - bShowAvatar(SRMMMOD, "AvatarEnable", true), - bShowButtons(SRMMMOD, "ShowButtonLine", true), - - bTypingNew(SRMMMOD, "DefaultTyping", true), - bTypingUnknown(SRMMMOD, "UnknownTyping", false), - - bShowTyping(SRMMMOD, "ShowTyping", true), - bShowTypingWin(SRMMMOD, "ShowTypingWin", true), - bShowTypingTray(SRMMMOD, "ShowTypingTray", false), - bShowTypingClist(SRMMMOD, "ShowTypingClist", true), - - bCascade(SRMMMOD, "Cascade", true), - bAutoMin(SRMMMOD, "AutoMin", false), - bAutoClose(SRMMMOD, "AutoClose", false), - bShowNames(SRMMMOD, "ShowNames", false), - bShowFormat(SRMMMOD, "ShowFormatting", true), - bSendButton(SRMMMOD, "UseSendButton", false), - bSendOnEnter(SRMMMOD, "SendOnEnter", true), - bCtrlSupport(SRMMMOD, "SupportCtrlUpDn", true), - bShowReadChar(SRMMMOD, "ShowCharCount", false), - bSendOnDblEnter(SRMMMOD, "SendOnDblEnter", false), - bSendOnCtrlEnter(SRMMMOD, "SendOnCtrlEnter", false), - bDeleteTempCont(SRMMMOD, "DeleteTempCont", false), - bSavePerContact(SRMMMOD, "SavePerContact", false), - bDoNotStealFocus(SRMMMOD, "DoNotStealFocus", false), - bUseStatusWinIcon(SRMMMOD, "UseStatusWinIcon", true), - - bLimitAvatarHeight(SRMMMOD, "AvatarLimitHeight", true), - iAvatarHeight(SRMMMOD, "AvatarHeight", 60), - - popupFlags(SRMMMOD, "PopupFlags", 0), - nFlashMax(SRMMMOD, "FlashMax", 5), - - msgTimeout(SRMMMOD, "MessageTimeout", 65000), - - iLoadHistory(SRMMMOD, "LoadHistory", LOADHISTORY_UNREAD), - nLoadCount(SRMMMOD, "LoadCount", 10), - nLoadTime(SRMMMOD, "LoadTime", 10) -{ -} - void InitGlobals() { int iOldValue = g_plugin.getByte("HideNames", -1); if (iOldValue != -1) { - g_dat.bShowNames = !iOldValue; + g_plugin.bShowNames = !iOldValue; g_plugin.delSetting("HideNames"); } - if (!g_dat.bSendOnEnter && !g_dat.bSendOnDblEnter) - g_dat.bSendOnCtrlEnter = true; - HookEvent(ME_DB_EVENT_ADDED, dbaddedevent); HookEvent(ME_DB_EVENT_EDITED, dbaddedevent); HookEvent(ME_PROTO_ACK, ackevent); diff --git a/src/core/stdmsg/src/globals.h b/src/core/stdmsg/src/globals.h deleted file mode 100644 index 031357356b..0000000000 --- a/src/core/stdmsg/src/globals.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - -Copyright 2000-12 Miranda IM, 2012-22 Miranda NG team, -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef SRMM_GLOBALS_H -#define SRMM_GLOBALS_H - -struct GlobalMessageData -{ - GlobalMessageData(); - - CMOption bShowButtons; - CMOption bSendButton; - CMOption bShowTyping; - CMOption bShowTypingWin; - CMOption bShowTypingTray; - CMOption bShowTypingClist; - CMOption bShowIcons; - CMOption bShowTime; - CMOption bShowDate; - CMOption bShowAvatar; - CMOption bShowNames; - CMOption bShowSecs; - CMOption bShowReadChar; - CMOption bSendOnEnter; - CMOption bSendOnDblEnter; - CMOption bSendOnCtrlEnter; - CMOption bAutoClose; - CMOption bAutoMin; - CMOption bTypingNew; - CMOption bTypingUnknown; - CMOption bCtrlSupport; - CMOption bShowFormat; - CMOption bSavePerContact; - CMOption bDoNotStealFocus; - CMOption bCascade; - CMOption bDeleteTempCont; - CMOption bUseStatusWinIcon; - - CMOption bLimitAvatarHeight; - CMOption iAvatarHeight; - - CMOption popupFlags; - CMOption msgTimeout; - CMOption nFlashMax; - - CMOption iLoadHistory; - CMOption nLoadCount, nLoadTime; - - bool bSmileyInstalled = false; -}; - -void InitGlobals(); - -extern GlobalMessageData g_dat; - -#endif diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp index 24472cf153..a01dee62e3 100644 --- a/src/core/stdmsg/src/msgdialog.cpp +++ b/src/core/stdmsg/src/msgdialog.cpp @@ -37,7 +37,6 @@ LIST g_arDialogs(10, PtrKeySortT); CMsgDialog::CMsgDialog(CTabbedWindow *pOwner, MCONTACT hContact) : CSuper(g_plugin, IDD_MSG), - m_btnOk(this, IDOK), m_avatar(this, IDC_AVATAR), m_splitterX(this, IDC_SPLITTERX), m_splitterY(this, IDC_SPLITTERY), @@ -50,7 +49,6 @@ CMsgDialog::CMsgDialog(CTabbedWindow *pOwner, MCONTACT hContact) : CMsgDialog::CMsgDialog(CTabbedWindow *pOwner, SESSION_INFO *si) : CSuper(g_plugin, IDD_MSG, si), - m_btnOk(this, IDOK), m_avatar(this, IDC_AVATAR), m_splitterX(this, IDC_SPLITTERX), m_splitterY(this, IDC_SPLITTERY), @@ -77,7 +75,7 @@ void CMsgDialog::Init() m_szTabSave[0] = 0; m_autoClose = 0; m_forceResizable = true; - m_bNoActivate = g_dat.bDoNotStealFocus; + m_bNoActivate = g_plugin.bDoNotStealFocus; g_arDialogs.insert(this); @@ -112,7 +110,7 @@ bool CMsgDialog::OnInitDialog() } // avatar stuff - m_limitAvatarH = g_dat.bLimitAvatarHeight ? g_dat.iAvatarHeight : 0; + m_limitAvatarH = g_plugin.bLimitAvatarHeight ? g_plugin.iAvatarHeight : 0; if (m_hContact && m_szProto != nullptr) { m_wStatus = db_get_w(m_hContact, m_szProto, "Status", ID_STATUS_OFFLINE); @@ -128,7 +126,7 @@ bool CMsgDialog::OnInitDialog() timerType.Start(1000); GetWindowRect(m_message.GetHwnd(), &m_minEditInit); - m_iSplitterY = g_plugin.getDword(g_dat.bSavePerContact ? m_hContact : 0, "splitterPos", m_minEditInit.bottom - m_minEditInit.top); + m_iSplitterY = g_plugin.getDword(g_plugin.bSavePerContact ? m_hContact : 0, "splitterPos", m_minEditInit.bottom - m_minEditInit.top); UpdateSizeBar(); m_message.SendMsg(EM_SETEVENTMASK, 0, ENM_MOUSEEVENTS | ENM_CHANGE); @@ -154,9 +152,9 @@ bool CMsgDialog::OnInitDialog() { DB::ECPTR pCursor(DB::EventsRev(m_hContact, m_hDbEventFirst)); - switch (g_dat.iLoadHistory) { + switch (g_plugin.iLoadHistory) { case LOADHISTORY_COUNT: - for (int i = g_dat.nLoadCount; i--;) { + for (int i = g_plugin.nLoadCount; i--;) { MEVENT hPrevEvent = pCursor.FetchNext(); if (hPrevEvent == 0) break; @@ -176,7 +174,7 @@ bool CMsgDialog::OnInitDialog() else db_event_get(m_hDbEventFirst, &dbei); - uint32_t firstTime = dbei.timestamp - 60 * g_dat.nLoadTime; + uint32_t firstTime = dbei.timestamp - 60 * g_plugin.nLoadTime; while (MEVENT hPrevEvent = pCursor.FetchNext()) { dbei.cbBlob = 0; db_event_get(hPrevEvent, &dbei); @@ -258,7 +256,7 @@ void CMsgDialog::OnDestroy() mir_free(it); m_cmdList.destroy(); - MCONTACT hContact = (g_dat.bSavePerContact) ? m_hContact : 0; + MCONTACT hContact = (g_plugin.bSavePerContact) ? m_hContact : 0; g_plugin.setDword(hContact ? m_hContact : 0, "splitterPos", m_iSplitterY); if (m_hFont) { @@ -287,7 +285,7 @@ void CMsgDialog::OnDestroy() CSuper::OnDestroy(); // a temporary contact should be destroyed after removing window from the window list to prevent recursion - if (m_hContact && g_dat.bDeleteTempCont) + if (m_hContact && g_plugin.bDeleteTempCont) if (!Contact_OnList(m_hContact)) db_delete_contact(m_hContact); } @@ -385,9 +383,9 @@ void CMsgDialog::onClick_Ok(CCtrlButton *pButton) m_message.SetText(L""); if (!g_Settings.bTabsEnable) { - if (g_dat.bAutoClose) + if (g_plugin.bAutoClose) ::PostMessage(m_hwndParent, WM_CLOSE, 0, 0); - else if (g_dat.bAutoMin) + else if (g_plugin.bAutoMin) ::ShowWindow(m_hwndParent, SW_MINIMIZE); } } @@ -416,7 +414,7 @@ void CMsgDialog::onChange_Text(CCtrlEdit*) void CMsgDialog::OnFlash(CTimer *) { FixTabIcons(); - if (!g_dat.nFlashMax || m_nFlash < 2 * g_dat.nFlashMax) + if (!g_plugin.nFlashMax || m_nFlash < 2 * g_plugin.nFlashMax) FlashWindow(m_pOwner->GetHwnd(), TRUE); m_nFlash++; } @@ -435,7 +433,7 @@ void CMsgDialog::OnType(CTimer*) } else { UpdateLastMessage(); - if (g_dat.bShowTypingWin) + if (g_plugin.bShowTypingWin) FixTabIcons(); m_bShowTyping = false; } @@ -451,7 +449,7 @@ void CMsgDialog::OnType(CTimer*) SendMessage(m_pOwner->m_hwndStatus, SB_SETTEXT, 0, (LPARAM)szBuf); SendMessage(m_pOwner->m_hwndStatus, SB_SETICON, 0, (LPARAM)hTyping); - if (g_dat.bShowTypingWin && GetForegroundWindow() != m_pOwner->GetHwnd()) { + if (g_plugin.bShowTypingWin && GetForegroundWindow() != m_pOwner->GetHwnd()) { HICON hIcon = (HICON)SendMessage(m_hwnd, WM_GETICON, ICON_SMALL, 0); SendMessage(m_hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hTyping); IcoLib_ReleaseIcon(hIcon); @@ -466,8 +464,8 @@ void CMsgDialog::OnType(CTimer*) int CMsgDialog::Resizer(UTILRESIZECONTROL *urc) { if (isChat()) { - bool bToolbar = g_dat.bShowButtons; - bool bSend = g_dat.bSendButton; + bool bToolbar = g_plugin.bShowButtons; + bool bSend = g_plugin.bSendButton; bool bNick = m_si->iType != GCW_SERVER && m_bNicklistEnabled; switch (urc->wId) { @@ -520,7 +518,7 @@ LBL_CalcBottom: else { switch (urc->wId) { case IDC_SRMM_LOG: - if (!g_dat.bShowButtons) + if (!g_plugin.bShowButtons) urc->rcItem.top = 2; urc->rcItem.bottom = urc->dlgNewSize.cy - m_iSplitterY; m_rcLog = urc->rcItem; @@ -532,8 +530,8 @@ LBL_CalcBottom: return RD_ANCHORX_WIDTH | RD_ANCHORY_CUSTOM; case IDC_SRMM_MESSAGE: - urc->rcItem.right = (g_dat.bSendButton) ? urc->dlgNewSize.cx - 64 : urc->dlgNewSize.cx; - if (g_dat.bShowAvatar && m_avatarPic) + urc->rcItem.right = (g_plugin.bSendButton) ? urc->dlgNewSize.cx - 64 : urc->dlgNewSize.cx; + if (g_plugin.bShowAvatar && m_avatarPic) urc->rcItem.left = m_avatarWidth + 4; urc->rcItem.top = urc->dlgNewSize.cy - m_iSplitterY + 3; @@ -614,7 +612,7 @@ INT_PTR CMsgDialog::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) if (!IsIconic(m_hwnd)) { if (isChat()) { - bool bSend = g_dat.bSendButton; + bool bSend = g_plugin.bSendButton; bool bNick = m_si->iType != GCW_SERVER && m_bNicklistEnabled; m_btnOk.Show(bSend); @@ -647,7 +645,7 @@ INT_PTR CMsgDialog::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) InvalidateRect(m_pOwner->m_hwndStatus, nullptr, true); RedrawWindow(m_message.GetHwnd(), nullptr, nullptr, RDW_INVALIDATE); RedrawWindow(m_btnOk.GetHwnd(), nullptr, nullptr, RDW_INVALIDATE); - if (g_dat.bShowAvatar && m_avatarPic) + if (g_plugin.bShowAvatar && m_avatarPic) RedrawWindow(m_avatar.GetHwnd(), nullptr, nullptr, RDW_INVALIDATE); } return TRUE; @@ -722,7 +720,7 @@ INT_PTR CMsgDialog::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) if (dis->CtlType == ODT_MENU) return Menu_DrawItem(lParam); - if (dis->CtlID == IDC_AVATAR && m_avatarPic && g_dat.bShowAvatar) { + if (dis->CtlID == IDC_AVATAR && m_avatarPic && g_plugin.bShowAvatar) { HPEN hPen = CreatePen(PS_SOLID, 1, RGB(0, 0, 0)); HPEN hOldPen = (HPEN)SelectObject(dis->hDC, hPen); Rectangle(dis->hDC, 0, 0, m_avatarWidth, m_avatarHeight); @@ -949,16 +947,7 @@ LRESULT CMsgDialog::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) ProcessFileDrop((HDROP)wParam, m_hContact); return FALSE; - case WM_MOUSEWHEEL: - case WM_LBUTTONDOWN: - case WM_RBUTTONDOWN: - case WM_MBUTTONDOWN: - case WM_KILLFOCUS: - m_iLastEnterTime = 0; - break; - case WM_SYSCHAR: - m_iLastEnterTime = 0; if ((wParam == 's' || wParam == 'S') && GetKeyState(VK_MENU) & 0x8000) { m_btnOk.Click(); return 0; @@ -1080,28 +1069,6 @@ LRESULT CMsgDialog::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) bool isCtrl = (GetKeyState(VK_CONTROL) & 0x8000) != 0; bool isAlt = (GetKeyState(VK_MENU) & 0x8000) != 0; - if (wParam == VK_RETURN) { - if (!isShift && !isCtrl && g_dat.bSendOnEnter) { - m_btnOk.Click(); - return 0; - } - if (!isShift && isCtrl && g_dat.bSendOnCtrlEnter) { - m_btnOk.Click(); - return 0; - } - if (g_dat.bSendOnDblEnter) { - if (m_iLastEnterTime + ENTERCLICKTIME < GetTickCount()) - m_iLastEnterTime = GetTickCount(); - else { - m_message.SendMsg(WM_KEYDOWN, VK_BACK, 0); - m_message.SendMsg(WM_KEYUP, VK_BACK, 0); - m_btnOk.Click(); - return 0; - } - } - } - else m_iLastEnterTime = 0; - if (g_Settings.bTabsEnable) { if (wParam <= '9' && wParam >= '1' && isCtrl && !isAlt) { // CTRL + 1 -> 9 (switch tab) m_pOwner->SwitchTab(wParam - '1'); @@ -1164,12 +1131,11 @@ LRESULT CMsgDialog::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) if (wParam == VK_NEXT || wParam == VK_PRIOR) { ((CLogWindow *)m_pLog)->WndProc(msg, wParam, lParam); - m_iLastEnterTime = 0; return TRUE; } } - if (isCtrl && g_dat.bCtrlSupport && m_cmdList.getCount()) { + if (isCtrl && g_plugin.bCtrlSupport && m_cmdList.getCount()) { if (wParam == VK_UP && m_cmdListInd != 0) { if (m_cmdListInd < 0) m_cmdListInd = m_cmdList.getCount() - 1; @@ -1311,7 +1277,7 @@ void CMsgDialog::OnOptionsApplied(bool bUpdateAvatar) continue; bool bShow = false; - if (m_hContact && g_dat.bShowButtons) { + if (m_hContact && g_plugin.bShowButtons) { if (cbd->m_dwButtonCID == IDC_ADD) { bShow = !Contact_OnList(m_hContact); cbd->m_bHidden = !bShow; @@ -1324,10 +1290,10 @@ void CMsgDialog::OnOptionsApplied(bool bUpdateAvatar) ShowWindow(GetDlgItem(m_hwnd, IDCANCEL), SW_HIDE); m_splitterY.Show(); - m_btnOk.Show(g_dat.bSendButton); + m_btnOk.Show(g_plugin.bSendButton); m_btnOk.Enable(GetWindowTextLength(m_message.GetHwnd()) != 0); - if (m_avatarPic == nullptr || !g_dat.bShowAvatar) + if (m_avatarPic == nullptr || !g_plugin.bShowAvatar) m_avatar.Hide(); UpdateIcon(0); @@ -1341,7 +1307,7 @@ void CMsgDialog::OnOptionsApplied(bool bUpdateAvatar) m_avatarPic = nullptr; m_limitAvatarH = 0; if (CallProtoService(m_szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_AVATARS) - m_limitAvatarH = g_dat.bLimitAvatarHeight ? g_dat.iAvatarHeight : 0; + m_limitAvatarH = g_plugin.bLimitAvatarHeight ? g_plugin.iAvatarHeight : 0; if (bUpdateAvatar) UpdateAvatar(); @@ -1390,7 +1356,7 @@ void CMsgDialog::onSplitterY(CSplitter *pSplitter) m_iSplitterY = rc.bottom - pSplitter->GetPos() + 1; int toplimit = 63; - if (!g_dat.bShowButtons) + if (!g_plugin.bShowButtons) toplimit += 22; if (m_iSplitterY < m_minEditBoxSize.cy) @@ -1421,7 +1387,7 @@ void CMsgDialog::NotifyTyping(int mode) // Don't send to protocols that are offline // Don't send to users who are not visible and // Don't send to users who are not on the visible list when you are in invisible mode. - if (!g_plugin.getByte(m_hContact, SRMSGSET_TYPING, g_dat.bTypingNew)) + if (!g_plugin.getByte(m_hContact, SRMSGSET_TYPING, g_plugin.bTypingNew)) return; if (!m_szProto) @@ -1447,7 +1413,7 @@ void CMsgDialog::NotifyTyping(int mode) if (protoCaps & PF1_INVISLIST && protoStatus == ID_STATUS_INVISIBLE && db_get_w(m_hContact, m_szProto, "ApparentMode", 0) != ID_STATUS_ONLINE) return; - if (!g_dat.bTypingUnknown && !Contact_OnList(m_hContact)) + if (!g_plugin.bTypingUnknown && !Contact_OnList(m_hContact)) return; // End user check @@ -1463,7 +1429,7 @@ void CMsgDialog::RemakeLog() void CMsgDialog::ShowAvatar() { - if (g_dat.bShowAvatar) { + if (g_plugin.bShowAvatar) { AVATARCACHEENTRY *ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, getActiveContact(), 0); if (ace && (INT_PTR)ace != CALLSERVICE_NOTFOUND && (ace->dwFlags & AVS_BITMAP_VALID) && !(ace->dwFlags & AVS_HIDEONCLIST)) m_avatarPic = ace->hbmPic; @@ -1486,7 +1452,7 @@ void CMsgDialog::ShowTime(bool bForce) if (m_wMinute != st.wMinute || bForce) { if (m_pOwner->m_tab.GetActivePage() == this) { wchar_t buf[32]; - unsigned i = g_dat.bShowReadChar ? 2 : 1; + unsigned i = g_plugin.bShowReadChar ? 2 : 1; TimeZone_PrintDateTime(m_hTimeZone, L"t", buf, _countof(buf), 0); SendMessage(m_pOwner->m_hwndStatus, SB_SETTEXT, i, (LPARAM)buf); @@ -1505,11 +1471,11 @@ void CMsgDialog::SetupStatusBar() int cx = rc.right - rc.left; if (m_hTimeZone) { - if (g_dat.bShowReadChar) + if (g_plugin.bShowReadChar) statwidths[i++] = cx - SB_TIME_WIDTH - SB_CHAR_WIDTH - icons_width; statwidths[i++] = cx - SB_TIME_WIDTH - icons_width; } - else if (g_dat.bShowReadChar) + else if (g_plugin.bShowReadChar) statwidths[i++] = cx - SB_CHAR_WIDTH - icons_width; statwidths[i++] = cx - icons_width; @@ -1550,7 +1516,7 @@ void CMsgDialog::UpdateIcon(WPARAM wParam) } if (!cws || bIsStatus) - if (g_dat.bUseStatusWinIcon) + if (g_plugin.bUseStatusWinIcon) FixTabIcons(); } @@ -1571,7 +1537,7 @@ void CMsgDialog::UpdateLastMessage() void CMsgDialog::UpdateReadChars() { - if (g_dat.bShowReadChar) { + if (g_plugin.bShowReadChar) { wchar_t buf[32]; int len = GetWindowTextLength(m_message.GetHwnd()); @@ -1584,8 +1550,8 @@ void CMsgDialog::UpdateSizeBar() { m_minEditBoxSize.cx = m_minEditInit.right - m_minEditInit.left; m_minEditBoxSize.cy = m_minEditInit.bottom - m_minEditInit.top; - if (g_dat.bShowAvatar) { - if (m_avatarPic == nullptr || !g_dat.bShowAvatar) { + if (g_plugin.bShowAvatar) { + if (m_avatarPic == nullptr || !g_plugin.bShowAvatar) { m_avatarWidth = 50; m_avatarHeight = 50; m_avatar.Hide(); @@ -1640,7 +1606,7 @@ void CMsgDialog::UpdateTitle() m_wStatus = db_get_w(m_hContact, m_szProto, "Status", ID_STATUS_OFFLINE); wchar_t *contactName = Clist_GetContactDisplayName(m_hContact); - if (g_dat.bUseStatusWinIcon) + if (g_plugin.bUseStatusWinIcon) mir_snwprintf(newtitle, L"%s - %s", contactName, TranslateT("Message session")); else { wchar_t *szStatus = Clist_GetStatusModeDescription(m_szProto == nullptr ? ID_STATUS_OFFLINE : db_get_w(m_hContact, m_szProto, "Status", ID_STATUS_OFFLINE), 0); diff --git a/src/core/stdmsg/src/msglog.cpp b/src/core/stdmsg/src/msglog.cpp index 0524859361..228ec4ea53 100644 --- a/src/core/stdmsg/src/msglog.cpp +++ b/src/core/stdmsg/src/msglog.cpp @@ -83,7 +83,7 @@ static void AppendToBufferWithRTF(CMStringA &buf, const wchar_t *line) buf.AppendChar('\\'); buf.AppendChar(*line); } - else if (*line == '[' && (g_dat.bShowFormat)) { + else if (*line == '[' && (g_plugin.bShowFormat)) { int i, found = 0; for (i = 0; i < _countof(bbcodes); ++i) { if (line[1] == bbcodes[i][1]) { @@ -237,7 +237,7 @@ static bool CreateRTFFromDbEvent(LogStreamData *dat) buf.Append("\\rtlch\\ltrch"); } - if (g_dat.bShowIcons) { + if (g_plugin.bShowIcons) { int i = ((dbei.eventType == EVENTTYPE_MESSAGE) ? ((dbei.flags & DBEF_SENT) ? LOGICON_MSG_OUT : LOGICON_MSG_IN): LOGICON_MSG_NOTICE); buf.Append("\\f0\\fs14"); @@ -245,14 +245,14 @@ static bool CreateRTFFromDbEvent(LogStreamData *dat) } int showColon = 0; - if (g_dat.bShowTime) { + if (g_plugin.bShowTime) { const wchar_t* szFormat; wchar_t str[64]; - if (g_dat.bShowSecs) - szFormat = g_dat.bShowDate ? L"d s" : L"s"; + if (g_plugin.bShowSecs) + szFormat = g_plugin.bShowDate ? L"d s" : L"s"; else - szFormat = g_dat.bShowDate ? L"d t" : L"t"; + szFormat = g_plugin.bShowDate ? L"d t" : L"t"; TimeZone_PrintTimeStamp(nullptr, dbei.timestamp, szFormat, str, _countof(str), 0); @@ -261,7 +261,7 @@ static bool CreateRTFFromDbEvent(LogStreamData *dat) showColon = 1; } - if (g_dat.bShowNames && dbei.eventType != EVENTTYPE_JABBER_CHATSTATES && dbei.eventType != EVENTTYPE_JABBER_PRESENCE) { + if (g_plugin.bShowNames && dbei.eventType != EVENTTYPE_JABBER_CHATSTATES && dbei.eventType != EVENTTYPE_JABBER_PRESENCE) { wchar_t *szName; if (dbei.flags & DBEF_SENT) { @@ -516,7 +516,7 @@ void CLogWindow::LogEvents(MEVENT hDbEventFirst, int count, bool bAppend) m_rtf.SendMsg(EM_SETSCROLLPOS, 0, (LPARAM)&scrollPos); } - if (g_dat.bSmileyInstalled) { + if (g_plugin.bSmileyInstalled) { SMADD_RICHEDIT3 smre; smre.cbSize = sizeof(SMADD_RICHEDIT3); smre.hwndRichEditControl = m_rtf.GetHwnd(); diff --git a/src/core/stdmsg/src/msgoptions.cpp b/src/core/stdmsg/src/msgoptions.cpp index 3f5759b434..60a798bd72 100644 --- a/src/core/stdmsg/src/msgoptions.cpp +++ b/src/core/stdmsg/src/msgoptions.cpp @@ -25,15 +25,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. int ChatOptionsInitialize(WPARAM); -struct FontOptionsList +struct { - const wchar_t* szDescr; - COLORREF defColour; - const wchar_t* szDefFace; - uint8_t defStyle; - char defSize; + wchar_t* szDescr; + COLORREF defColour; + wchar_t* szDefFace; + uint8_t defStyle; + char defSize; } -static const fontOptionsList[] = +static fontOptionsList[] = { { LPGENW("Outgoing messages"), RGB(106, 106, 106), L"Arial", 0, -12}, { LPGENW("Incoming messages"), RGB(0, 0, 0), L"Arial", 0, -12}, @@ -126,20 +126,20 @@ void RegisterSRMMFonts(void) ///////////////////////////////////////////////////////////////////////////////////////// -struct CheckBoxValues_t +struct { - uint32_t style; + uint32_t style; wchar_t* szDescr; } -statusValues[] = +static statusValues[] = { { MODEF_OFFLINE, LPGENW("Offline") }, - { PF2_ONLINE, LPGENW("Online") }, + { PF2_ONLINE, LPGENW("Online") }, { PF2_SHORTAWAY, LPGENW("Away") }, - { PF2_LONGAWAY, LPGENW("Not available") }, - { PF2_LIGHTDND, LPGENW("Occupied") }, - { PF2_HEAVYDND, LPGENW("Do not disturb") }, - { PF2_FREECHAT, LPGENW("Free for chat") }, + { PF2_LONGAWAY, LPGENW("Not available") }, + { PF2_LIGHTDND, LPGENW("Occupied") }, + { PF2_HEAVYDND, LPGENW("Do not disturb") }, + { PF2_FREECHAT, LPGENW("Free for chat") }, { PF2_INVISIBLE, LPGENW("Invisible") } }; @@ -149,7 +149,7 @@ class COptionMainDlg : public CDlgBase CCtrlCheck chkAutoMin, chkAutoClose, chkSavePerContact, chkDoNotStealFocus, chkStatusWin; CCtrlCheck chkDelTemp, chkCascade, chkCharCount, chkCtrlSupport; CCtrlCheck chkAvatar, chkLimitAvatar; - CCtrlCheck chkSendOnEnter, chkSendOnDblEnter, chkSendOnCtrlEnter, chkShowSend, chkShowButtons; + CCtrlCheck chkShowSend, chkShowButtons; CCtrlTreeView tree; @@ -202,9 +202,6 @@ public: chkLimitAvatar(this, IDC_LIMITAVATARH), chkShowButtons(this, IDC_SHOWBUTTONLINE), chkCtrlSupport(this, IDC_CTRLSUPPORT), - chkSendOnEnter(this, IDC_SENDONENTER), - chkSendOnDblEnter(this, IDC_SENDONDBLENTER), - chkSendOnCtrlEnter(this, IDC_SENDONCTRLENTER), chkSavePerContact(this, IDC_SAVEPERCONTACT), chkDoNotStealFocus(this, IDC_DONOTSTEALFOCUS) { @@ -216,48 +213,45 @@ public: chkLimitAvatar.OnChange = Callback(this, &COptionMainDlg::onChange_LimitAvatar); chkSavePerContact.OnChange = Callback(this, &COptionMainDlg::onChange_SavePerContact); - CreateLink(edtNFlash, g_dat.nFlashMax); - CreateLink(edtAvatarH, g_dat.iAvatarHeight); + CreateLink(edtNFlash, g_plugin.nFlashMax); + CreateLink(edtAvatarH, g_plugin.iAvatarHeight); - CreateLink(chkAvatar, g_dat.bShowAvatar); - CreateLink(chkLimitAvatar, g_dat.bLimitAvatarHeight); + CreateLink(chkAvatar, g_plugin.bShowAvatar); + CreateLink(chkLimitAvatar, g_plugin.bLimitAvatarHeight); - CreateLink(chkDelTemp, g_dat.bDeleteTempCont); - CreateLink(chkCascade, g_dat.bCascade); - CreateLink(chkAutoMin, g_dat.bAutoMin); - CreateLink(chkAutoClose, g_dat.bAutoClose); - CreateLink(chkShowSend, g_dat.bSendButton); - CreateLink(chkCharCount, g_dat.bShowReadChar); - CreateLink(chkStatusWin, g_dat.bUseStatusWinIcon); - CreateLink(chkShowButtons, g_dat.bShowButtons); - CreateLink(chkCtrlSupport, g_dat.bCtrlSupport); - CreateLink(chkSendOnEnter, g_dat.bSendOnEnter); - CreateLink(chkSendOnDblEnter, g_dat.bSendOnDblEnter); - CreateLink(chkSendOnCtrlEnter, g_dat.bSendOnCtrlEnter); - CreateLink(chkSavePerContact, g_dat.bSavePerContact); - CreateLink(chkDoNotStealFocus, g_dat.bDoNotStealFocus); + CreateLink(chkDelTemp, g_plugin.bDeleteTempCont); + CreateLink(chkCascade, g_plugin.bCascade); + CreateLink(chkAutoMin, g_plugin.bAutoMin); + CreateLink(chkAutoClose, g_plugin.bAutoClose); + CreateLink(chkShowSend, g_plugin.bSendButton); + CreateLink(chkCharCount, g_plugin.bShowReadChar); + CreateLink(chkStatusWin, g_plugin.bUseStatusWinIcon); + CreateLink(chkShowButtons, g_plugin.bShowButtons); + CreateLink(chkCtrlSupport, g_plugin.bCtrlSupport); + CreateLink(chkSavePerContact, g_plugin.bSavePerContact); + CreateLink(chkDoNotStealFocus, g_plugin.bDoNotStealFocus); } bool OnInitDialog() override { - FillCheckBoxTree(g_dat.popupFlags); + FillCheckBoxTree(g_plugin.popupFlags); - uint32_t msgTimeout = g_dat.msgTimeout; + uint32_t msgTimeout = g_plugin.msgTimeout; edtSecs.SetInt((msgTimeout >= 5000) ? msgTimeout / 1000 : 5); - chkCascade.Enable(!g_dat.bSavePerContact); - chkCtrlSupport.Enable(!g_dat.bAutoClose); + chkCascade.Enable(!g_plugin.bSavePerContact); + chkCtrlSupport.Enable(!g_plugin.bAutoClose); return true; } bool OnApply() override { - g_dat.popupFlags = MakeCheckBoxTreeFlags(); + g_plugin.popupFlags = MakeCheckBoxTreeFlags(); uint32_t msgTimeout = edtSecs.GetInt() * 1000; if (msgTimeout < 5000) msgTimeout = 5000; - g_dat.msgTimeout = msgTimeout; + g_plugin.msgTimeout = msgTimeout; Srmm_Broadcast(DM_OPTIONSAPPLIED, TRUE, 0); return true; @@ -327,17 +321,17 @@ public: chkTime.OnChange = Callback(this, &COptionLogDlg::onChange_Time); chkLoadUnread.OnChange = chkLoadCount.OnChange = chkLoadTime.OnChange = Callback(this, &COptionLogDlg::onChange_Load); - CreateLink(chkSecs, g_dat.bShowSecs); - CreateLink(chkDate, g_dat.bShowDate); - CreateLink(chkTime, g_dat.bShowTime); - CreateLink(chkIcons, g_dat.bShowIcons); - CreateLink(chkFormat, g_dat.bShowFormat); - CreateLink(chkShowNames, g_dat.bShowNames); + CreateLink(chkSecs, g_plugin.bShowSecs); + CreateLink(chkDate, g_plugin.bShowDate); + CreateLink(chkTime, g_plugin.bShowTime); + CreateLink(chkIcons, g_plugin.bShowIcons); + CreateLink(chkFormat, g_plugin.bShowFormat); + CreateLink(chkShowNames, g_plugin.bShowNames); } bool OnInitDialog() override { - switch (g_dat.iLoadHistory) { + switch (g_plugin.iLoadHistory) { case LOADHISTORY_UNREAD: chkLoadUnread.SetState(true); break; @@ -354,21 +348,21 @@ public: break; } - spinCount.SetPosition(g_dat.nLoadCount); - spinTime.SetPosition(g_dat.nLoadTime); + spinCount.SetPosition(g_plugin.nLoadCount); + spinTime.SetPosition(g_plugin.nLoadTime); return true; } bool OnApply() override { if (chkLoadCount.GetState()) - g_dat.iLoadHistory = LOADHISTORY_COUNT; + g_plugin.iLoadHistory = LOADHISTORY_COUNT; else if (chkLoadTime.GetState()) - g_dat.iLoadHistory = LOADHISTORY_TIME; + g_plugin.iLoadHistory = LOADHISTORY_TIME; else - g_dat.iLoadHistory = LOADHISTORY_UNREAD; - g_dat.nLoadCount = spinCount.GetPosition(); - g_dat.nLoadTime = spinTime.GetPosition(); + g_plugin.iLoadHistory = LOADHISTORY_UNREAD; + g_plugin.nLoadCount = spinCount.GetPosition(); + g_plugin.nLoadTime = spinTime.GetPosition(); FreeMsgLogIcons(); LoadMsgLogIcons(); @@ -423,10 +417,10 @@ public: chkType.OnChange = Callback(this, &COptionTypingDlg::onChange_ShowNotify); chkTypeTray.OnChange = Callback(this, &COptionTypingDlg::onChange_Tray); - CreateLink(chkType, g_dat.bShowTyping); - CreateLink(chkTypeWin, g_dat.bShowTypingWin); - CreateLink(chkTypeTray, g_dat.bShowTypingTray); - CreateLink(chkTypeClist, g_dat.bShowTypingClist); + CreateLink(chkType, g_plugin.bShowTyping); + CreateLink(chkTypeWin, g_plugin.bShowTypingWin); + CreateLink(chkTypeTray, g_plugin.bShowTypingTray); + CreateLink(chkTypeClist, g_plugin.bShowTypingClist); } void ResetCList(CCtrlClc::TEventInfo* = nullptr) @@ -437,11 +431,11 @@ public: void RebuildList(CCtrlClc::TEventInfo* = nullptr) { - uint8_t defType = g_dat.bTypingNew; + uint8_t defType = g_plugin.bTypingNew; if (hItemNew && defType) clist.SetCheck(hItemNew, 1); - if (hItemUnknown && g_dat.bTypingUnknown) + if (hItemUnknown && g_plugin.bTypingUnknown) clist.SetCheck(hItemUnknown, 1); for (auto &hContact : Contacts()) { @@ -454,10 +448,10 @@ public: void SaveList() { if (hItemNew) - g_dat.bTypingNew = clist.GetCheck(hItemNew); + g_plugin.bTypingNew = clist.GetCheck(hItemNew); if (hItemUnknown) - g_dat.bTypingUnknown = clist.GetCheck(hItemUnknown); + g_plugin.bTypingUnknown = clist.GetCheck(hItemUnknown); for (auto &hContact : Contacts()) { HANDLE hItem = clist.FindContact(hContact); diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp index 23f9bf5702..a8bc6ca8db 100644 --- a/src/core/stdmsg/src/msgs.cpp +++ b/src/core/stdmsg/src/msgs.cpp @@ -77,7 +77,7 @@ static int MessageEventAdded(WPARAM hContact, LPARAM lParam) /* does a window for the contact exist? */ HWND hwnd = Srmm_FindWindow(hContact); if (hwnd) { - if (!g_dat.bDoNotStealFocus) { + if (!g_plugin.bDoNotStealFocus) { ShowWindow(hwnd, SW_RESTORE); SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); SetForegroundWindow(hwnd); @@ -94,9 +94,9 @@ static int MessageEventAdded(WPARAM hContact, LPARAM lParam) /* new message */ Skin_PlaySound("AlertMsg"); - if (!g_dat.bDoNotStealFocus) { + if (!g_plugin.bDoNotStealFocus) { char *szProto = Proto_GetBaseAccountName(hContact); - if (szProto && (g_dat.popupFlags & SRMMStatusToPf2(Proto_GetStatus(szProto)))) { + if (szProto && (g_plugin.popupFlags & SRMMStatusToPf2(Proto_GetStatus(szProto)))) { GetContainer()->AddPage(hContact); return 0; } @@ -170,7 +170,7 @@ static INT_PTR ReadMessageCommand(WPARAM, LPARAM lParam) static int TypingMessage(WPARAM hContact, LPARAM lParam) { - if (!g_dat.bShowTyping) + if (!g_plugin.bShowTyping) return 0; hContact = db_mc_tryMeta(hContact); @@ -180,11 +180,11 @@ static int TypingMessage(WPARAM hContact, LPARAM lParam) auto *pDlg = Srmm_FindDialog(hContact); if (pDlg) pDlg->UserTyping(lParam); - else if (lParam && g_dat.bShowTypingTray) { + else if (lParam && g_plugin.bShowTypingTray) { wchar_t szTip[256]; mir_snwprintf(szTip, TranslateT("%s is typing a message"), Clist_GetContactDisplayName(hContact)); - if (g_dat.bShowTypingClist) { + if (g_plugin.bShowTypingClist) { g_clistApi.pfnRemoveEvent(hContact, 1); CLISTEVENT cle = {}; @@ -269,7 +269,7 @@ static void RestoreUnreadMessageAlerts(void) if (szProto == nullptr) continue; - if (g_dat.popupFlags & SRMMStatusToPf2(Proto_GetStatus(szProto))) + if (g_plugin.popupFlags & SRMMStatusToPf2(Proto_GetStatus(szProto))) autoPopup = true; if (autoPopup && !windowAlreadyExists) diff --git a/src/core/stdmsg/src/msgs.h b/src/core/stdmsg/src/msgs.h index 82558a86e2..8438f529c1 100644 --- a/src/core/stdmsg/src/msgs.h +++ b/src/core/stdmsg/src/msgs.h @@ -67,7 +67,6 @@ class CMsgDialog : public CSrmmBaseDialog static INT_PTR CALLBACK FilterWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); CCtrlBase m_avatar; - CCtrlButton m_btnOk; void OnFlash(CTimer *); void OnType(CTimer *); diff --git a/src/core/stdmsg/src/resource.h b/src/core/stdmsg/src/resource.h index d3e1b94b91..dd65d2d386 100644 --- a/src/core/stdmsg/src/resource.h +++ b/src/core/stdmsg/src/resource.h @@ -75,12 +75,9 @@ #define IDC_LOADCOUNTSPIN 1040 #define IDC_SHOWBUTTONLINE 1042 #define IDC_LOADUNREAD 1043 -#define IDC_SENDONENTER 1043 #define IDC_LOADCOUNT 1044 -#define IDC_SENDONDBLENTER 1044 #define IDC_LOADTIMEN 1045 #define IDC_LOADTIMESPIN 1046 -#define IDC_SENDONCTRLENTER 1046 #define IDC_LOADTIME 1047 #define IDC_STMINSOLD 1048 #define IDC_SPIN1 1049 diff --git a/src/core/stdmsg/src/srmm.cpp b/src/core/stdmsg/src/srmm.cpp index c1be7a2113..69c350aad7 100644 --- a/src/core/stdmsg/src/srmm.cpp +++ b/src/core/stdmsg/src/srmm.cpp @@ -41,7 +41,47 @@ PLUGININFOEX pluginInfoEx = { }; CMPlugin::CMPlugin() : - PLUGIN(SRMMMOD, pluginInfoEx) + PLUGIN(SRMMMOD, pluginInfoEx), + + bShowDate(SRMMMOD, "ShowDate", false), + bShowTime(SRMMMOD, "ShowTime", true), + bShowSecs(SRMMMOD, "ShowSeconds", true), + bShowIcons(SRMMMOD, "ShowLogIcon", true), + bShowAvatar(SRMMMOD, "AvatarEnable", true), + bShowButtons(SRMMMOD, "ShowButtonLine", true), + + bTypingNew(SRMMMOD, "DefaultTyping", true), + bTypingUnknown(SRMMMOD, "UnknownTyping", false), + + bShowTyping(SRMMMOD, "ShowTyping", true), + bShowTypingWin(SRMMMOD, "ShowTypingWin", true), + bShowTypingTray(SRMMMOD, "ShowTypingTray", false), + bShowTypingClist(SRMMMOD, "ShowTypingClist", true), + + bCascade(SRMMMOD, "Cascade", true), + bAutoMin(SRMMMOD, "AutoMin", false), + bAutoClose(SRMMMOD, "AutoClose", false), + bShowNames(SRMMMOD, "ShowNames", false), + bShowFormat(SRMMMOD, "ShowFormatting", true), + bSendButton(SRMMMOD, "UseSendButton", false), + bCtrlSupport(SRMMMOD, "SupportCtrlUpDn", true), + bShowReadChar(SRMMMOD, "ShowCharCount", false), + bDeleteTempCont(SRMMMOD, "DeleteTempCont", false), + bSavePerContact(SRMMMOD, "SavePerContact", false), + bDoNotStealFocus(SRMMMOD, "DoNotStealFocus", false), + bUseStatusWinIcon(SRMMMOD, "UseStatusWinIcon", true), + + bLimitAvatarHeight(SRMMMOD, "AvatarLimitHeight", true), + iAvatarHeight(SRMMMOD, "AvatarHeight", 60), + + popupFlags(SRMMMOD, "PopupFlags", 0), + nFlashMax(SRMMMOD, "FlashMax", 5), + + msgTimeout(SRMMMOD, "MessageTimeout", 65000), + + iLoadHistory(SRMMMOD, "LoadHistory", LOADHISTORY_UNREAD), + nLoadCount(SRMMMOD, "LoadCount", 10), + nLoadTime(SRMMMOD, "LoadTime", 10) {} ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/core/stdmsg/src/stdafx.h b/src/core/stdmsg/src/stdafx.h index ca5b8ebd96..ef484f4f68 100644 --- a/src/core/stdmsg/src/stdafx.h +++ b/src/core/stdmsg/src/stdafx.h @@ -56,6 +56,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include #include +#include #include #include #include @@ -131,7 +132,6 @@ struct LOGSTREAMDATA : public GCLogStreamDataBase {}; #include "cmdlist.h" #include "msgs.h" -#include "globals.h" #include "version.h" #define EM_ACTIVATE (WM_USER+0x102) @@ -156,6 +156,43 @@ struct CMPlugin : public PLUGIN HANDLE hLogger; + CMOption bShowButtons; + CMOption bSendButton; + CMOption bShowTyping; + CMOption bShowTypingWin; + CMOption bShowTypingTray; + CMOption bShowTypingClist; + CMOption bShowIcons; + CMOption bShowTime; + CMOption bShowDate; + CMOption bShowAvatar; + CMOption bShowNames; + CMOption bShowSecs; + CMOption bShowReadChar; + CMOption bAutoClose; + CMOption bAutoMin; + CMOption bTypingNew; + CMOption bTypingUnknown; + CMOption bCtrlSupport; + CMOption bShowFormat; + CMOption bSavePerContact; + CMOption bDoNotStealFocus; + CMOption bCascade; + CMOption bDeleteTempCont; + CMOption bUseStatusWinIcon; + + CMOption bLimitAvatarHeight; + CMOption iAvatarHeight; + + CMOption popupFlags; + CMOption msgTimeout; + CMOption nFlashMax; + + CMOption iLoadHistory; + CMOption nLoadCount, nLoadTime; + + bool bSmileyInstalled = false; + int Load() override; int Unload() override; }; @@ -170,6 +207,9 @@ void LoadIcons(void); void Unload_ChatModule(void); void Load_ChatModule(void); +// globals.cpp +void InitGlobals(void); + // log.cpp char* Log_CreateRtfHeader(void); CSrmmLogWindow *logBuilder(CMsgDialog &pDlg); diff --git a/src/core/stdmsg/src/tabs.cpp b/src/core/stdmsg/src/tabs.cpp index a1f2a40181..ad11e2afa9 100644 --- a/src/core/stdmsg/src/tabs.cpp +++ b/src/core/stdmsg/src/tabs.cpp @@ -182,7 +182,7 @@ void CTabbedWindow::OnDestroy() SaveWindowPosition(true); - Utils_SaveWindowPosition(m_hwnd, g_dat.bSavePerContact ? ((m_pEmbed == nullptr) ? 0 : m_pEmbed->m_hContact) : 0, CHAT_MODULE, "room"); + Utils_SaveWindowPosition(m_hwnd, g_plugin.bSavePerContact ? ((m_pEmbed == nullptr) ? 0 : m_pEmbed->m_hContact) : 0, CHAT_MODULE, "room"); if (m_pEmbed == nullptr) g_pTabDialog = nullptr; @@ -305,7 +305,7 @@ void CTabbedWindow::FixTabIcons(CMsgDialog *pDlg) // set the container's icon only if we're processing the current page if (pDlg == CurrPage()) { Window_FreeIcon_IcoLib(m_hwnd); - if (g_dat.bUseStatusWinIcon) + if (g_plugin.bUseStatusWinIcon) Window_SetProtoIcon_IcoLib(m_hwnd, pDlg->m_szProto, pDlg->m_wStatus); else if (pDlg->isChat()) Window_SetIcon_IcoLib(m_hwnd, g_plugin.getIconHandle(IDI_CHANMGR)); @@ -392,15 +392,15 @@ void CTabbedWindow::SetWindowPosition() } int flag = m_pEmbed->m_bNoActivate ? RWPF_HIDDEN : 0; - if (Utils_RestoreWindowPosition(m_hwnd, g_dat.bSavePerContact ? m_pEmbed->m_hContact : 0, CHAT_MODULE, "room", flag)) { - if (g_dat.bSavePerContact) { + if (Utils_RestoreWindowPosition(m_hwnd, g_plugin.bSavePerContact ? m_pEmbed->m_hContact : 0, CHAT_MODULE, "room", flag)) { + if (g_plugin.bSavePerContact) { if (Utils_RestoreWindowPosition(m_hwnd, 0, CHAT_MODULE, "room", flag | RWPF_NOMOVE)) SetWindowPos(m_hwnd, nullptr, 0, 0, 550, 400, SWP_NOZORDER | SWP_NOMOVE | SWP_SHOWWINDOW); } else SetWindowPos(m_hwnd, nullptr, 0, 0, 550, 400, SWP_NOZORDER | SWP_NOMOVE | SWP_SHOWWINDOW); } - if (!g_dat.bSavePerContact && g_dat.bCascade) { + if (!g_plugin.bSavePerContact && g_plugin.bCascade) { RECT rc, rcMax = {}; CTabbedWindow *pMaxTab = nullptr; diff --git a/src/core/stdmsg/stdmsg.vcxproj b/src/core/stdmsg/stdmsg.vcxproj index c3b3d3353c..c083c48a66 100644 --- a/src/core/stdmsg/stdmsg.vcxproj +++ b/src/core/stdmsg/stdmsg.vcxproj @@ -43,7 +43,6 @@ - diff --git a/src/core/stdmsg/stdmsg.vcxproj.filters b/src/core/stdmsg/stdmsg.vcxproj.filters index 99782c4c1f..1996b04a19 100644 --- a/src/core/stdmsg/stdmsg.vcxproj.filters +++ b/src/core/stdmsg/stdmsg.vcxproj.filters @@ -49,9 +49,6 @@ Header Files - - Header Files - Header Files diff --git a/src/mir_app/src/chat.h b/src/mir_app/src/chat.h index 5020adcb92..8be9224d3d 100644 --- a/src/mir_app/src/chat.h +++ b/src/mir_app/src/chat.h @@ -47,6 +47,8 @@ extern GlobalLogSettingsBase *g_Settings; extern CMOption g_bChatTrayInactive, g_bChatPopupInactive; +extern const char *g_pszHotkeySection; + // log.c void LoadMsgLogBitmaps(void); void FreeMsgLogBitmaps(void); diff --git a/src/mir_app/src/hotkeys.cpp b/src/mir_app/src/hotkeys.cpp index 8400697910..da631b75ae 100644 --- a/src/mir_app/src/hotkeys.cpp +++ b/src/mir_app/src/hotkeys.cpp @@ -154,7 +154,7 @@ MIR_APP_DLL(int) Hotkey_Register(const HOTKEYDESC *desc, HPLUGIN pPlugin) p->Enabled = !db_get_b(0, DBMODULENAME "Off", p->pszName, 0); } - p->pszService = desc->pszService ? mir_strdup(desc->pszService) : nullptr; + p->pszService = mir_strdup(desc->pszService); p->DefHotkey = desc->DefHotKey & ~HKF_MIRANDA_LOCAL; p->Hotkey = db_get_w(0, DBMODULENAME, p->pszName, p->DefHotkey); p->type = p->pszService ? diff --git a/src/mir_app/src/miranda.h b/src/mir_app/src/miranda.h index e9ae1c1d2c..aadf1a35b6 100644 --- a/src/mir_app/src/miranda.h +++ b/src/mir_app/src/miranda.h @@ -65,6 +65,8 @@ void KillModulePopups(HPLUGIN); /**** srmm.cpp *************************************************************************/ +#define SRMM_MODULE "SRMsg" + void KillModuleSrmmIcons(HPLUGIN); void KillModuleToolbarIcons(HPLUGIN); diff --git a/src/mir_app/src/srmm_base.cpp b/src/mir_app/src/srmm_base.cpp index f93d075edc..b470676d1a 100644 --- a/src/mir_app/src/srmm_base.cpp +++ b/src/mir_app/src/srmm_base.cpp @@ -36,6 +36,7 @@ CSrmmBaseDialog::CSrmmBaseDialog(CMPluginBase &pPlugin, int idDialog, SESSION_IN m_message(this, IDC_SRMM_MESSAGE), m_nickList(this, IDC_SRMM_NICKLIST), + m_btnOk(this, IDOK), m_btnFilter(this, IDC_SRMM_FILTER), m_btnHistory(this, IDC_SRMM_HISTORY), m_btnNickList(this, IDC_SRMM_SHOWNICKLIST), @@ -202,6 +203,17 @@ LRESULT CSrmmBaseDialog::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) return 0; } } + + { + MSG tmp = { m_hwnd, msg, wParam, lParam }; + if (Hotkey_Check(&tmp, g_pszHotkeySection) == 100) { + if (!(GetWindowLongPtr(m_message.GetHwnd(), GWL_STYLE) & ES_READONLY)) { + m_btnOk.Click(); + return true; + } + } + } + __fallthrough; case WM_SYSKEYDOWN: diff --git a/src/mir_app/src/srmm_log.cpp b/src/mir_app/src/srmm_log.cpp index fe2770cd4e..bc97e37023 100644 --- a/src/mir_app/src/srmm_log.cpp +++ b/src/mir_app/src/srmm_log.cpp @@ -82,7 +82,7 @@ static bool sttEnableCustomLogs(CMsgDialog *pDlg) CSrmmLogWindow* Srmm_GetLogWindow(CMsgDialog *pDlg) { if (sttEnableCustomLogs(pDlg)) { - CMStringA szViewerName(db_get_sm(pDlg->m_hContact, "SRMsg", "Logger")); + CMStringA szViewerName(db_get_sm(pDlg->m_hContact, SRMM_MODULE, "Logger")); if (szViewerName.IsEmpty()) szViewerName = db_get_sm(0, "SRMM", "Logger", "built-in"); diff --git a/src/mir_app/src/srmm_util.cpp b/src/mir_app/src/srmm_util.cpp index 6281d0c024..7ca37c9eb9 100644 --- a/src/mir_app/src/srmm_util.cpp +++ b/src/mir_app/src/srmm_util.cpp @@ -24,6 +24,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" #include "chat.h" +const char *g_pszHotkeySection; + ///////////////////////////////////////////////////////////////////////////////////////// MIR_APP_DLL(DWORD) CALLBACK Srmm_LogStreamCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG * pcb) @@ -84,6 +86,28 @@ MIR_APP_DLL(void) Srmm_Broadcast(UINT msg, WPARAM wParam, LPARAM lParam) ///////////////////////////////////////////////////////////////////////////////////////// +MIR_APP_DLL(void) Srmm_CreateHotkey(const char *pszSection, const char *pszDescription) +{ + g_pszHotkeySection = pszSection; + + uint16_t wHotKey = HOTKEYCODE(0, VK_RETURN); + if (db_get_b(0, SRMM_MODULE, "SendOnCtrlEnter")) { + db_unset(0, SRMM_MODULE, "SendOnCtrlEnter"); + wHotKey = HOTKEYCODE(HOTKEYF_CONTROL, VK_RETURN); + } + + if (db_get_b(0, SRMM_MODULE, "SendOnEnter")) + db_unset(0, SRMM_MODULE, "SendOnEnter"); + + if (db_get_b(0, SRMM_MODULE, "SendOnDblEnter")) + db_unset(0, SRMM_MODULE, "SendOnDblEnter"); + + HOTKEYDESC hd = { "tabsrmm_send", pszDescription, pszSection, 0, wHotKey, 0, 100 }; + Hotkey_Register(&hd, g_pChatPlugin); +} + +///////////////////////////////////////////////////////////////////////////////////////// + MIR_APP_DLL(HWND) Srmm_FindWindow(MCONTACT hContact) { return WindowList_Find(g_hWindowList, hContact); -- cgit v1.2.3