diff options
author | George Hazan <ghazan@miranda.im> | 2019-09-02 17:19:25 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-09-02 17:19:25 +0300 |
commit | d39ba175b0e193525f140622a6a241408c2062dd (patch) | |
tree | 0c9aa9db4e20c5f3cb3332a4c66642a100dce7bb /src/core/stdmsg | |
parent | 45caea294147479a0708ca270d3978c20dfe166f (diff) |
StdMsg: merge began
Diffstat (limited to 'src/core/stdmsg')
-rw-r--r-- | src/core/stdmsg/src/chat_manager.cpp | 21 | ||||
-rw-r--r-- | src/core/stdmsg/src/chat_window.cpp | 38 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgdialog.cpp | 156 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgs.cpp | 86 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgs.h | 14 | ||||
-rw-r--r-- | src/core/stdmsg/src/stdafx.h | 7 | ||||
-rw-r--r-- | src/core/stdmsg/src/tabs.cpp | 2 |
7 files changed, 135 insertions, 189 deletions
diff --git a/src/core/stdmsg/src/chat_manager.cpp b/src/core/stdmsg/src/chat_manager.cpp index 86dc4aa572..56f2e5aa28 100644 --- a/src/core/stdmsg/src/chat_manager.cpp +++ b/src/core/stdmsg/src/chat_manager.cpp @@ -64,25 +64,6 @@ static MODULEINFO* MM_CreateModule() return new MODULEINFO(); } -static void OnDestroyModule(MODULEINFO *mi) -{ - if (mi->hOnlineIcon) - DestroyIcon(mi->hOnlineIcon); - if (mi->hOfflineIcon) - DestroyIcon(mi->hOfflineIcon); -} - -static void OnCreateModule(MODULEINFO *mi) -{ - OnDestroyModule(mi); - - mi->OnlineIconIndex = g_clistApi.pfnIconFromStatusMode(mi->pszModule, ID_STATUS_ONLINE, 0); - mi->hOnlineIcon = ImageList_GetIcon(Clist_GetImageList(), mi->OnlineIconIndex, ILD_TRANSPARENT); - - mi->OfflineIconIndex = g_clistApi.pfnIconFromStatusMode(mi->pszModule, ID_STATUS_OFFLINE, 0); - mi->hOfflineIcon = ImageList_GetIcon(Clist_GetImageList(), mi->OfflineIconIndex, ILD_TRANSPARENT); -} - static void OnReplaceSession(SESSION_INFO *si) { if (si->pDlg) @@ -236,8 +217,6 @@ void Load_ChatModule() Chat_CustomizeApi(&data); g_chatApi.MM_CreateModule = MM_CreateModule; - g_chatApi.OnCreateModule = OnCreateModule; - g_chatApi.OnDestroyModule = OnDestroyModule; g_chatApi.OnReplaceSession = OnReplaceSession; g_chatApi.OnLoadSettings = OnLoadSettings; diff --git a/src/core/stdmsg/src/chat_window.cpp b/src/core/stdmsg/src/chat_window.cpp index 02662b6d9a..f7aac47d3c 100644 --- a/src/core/stdmsg/src/chat_window.cpp +++ b/src/core/stdmsg/src/chat_window.cpp @@ -35,6 +35,8 @@ CChatRoomDlg::CChatRoomDlg(CTabbedWindow *pOwner, SESSION_INFO *si) : m_splitterX(this, IDC_SPLITTERX), m_splitterY(this, IDC_SPLITTERY) { + m_szProto = si->pszModule; + m_btnOk.OnClick = Callback(this, &CChatRoomDlg::onClick_Ok); m_btnFilter.OnClick = Callback(this, &CChatRoomDlg::onClick_Filter); @@ -192,14 +194,6 @@ void CChatRoomDlg::onSplitterY(CSplitter *pSplitter) ///////////////////////////////////////////////////////////////////////////////////////// -int CChatRoomDlg::GetImageId() const -{ - if ((m_si->wState & GC_EVENT_HIGHLIGHT) && (m_nFlash & 1)) - return 0; - - return (m_si->wStatus == ID_STATUS_ONLINE) ? m_si->pMI->OnlineIconIndex : m_si->pMI->OfflineIconIndex; -} - void CChatRoomDlg::LoadSettings() { m_clrInputBG = db_get_dw(0, CHAT_MODULE, "ColorMessageBG", GetSysColor(COLOR_WINDOW)); @@ -240,16 +234,6 @@ void CChatRoomDlg::RedrawLog() ///////////////////////////////////////////////////////////////////////////////////////// -void CChatRoomDlg::ScrollToBottom() -{ - if (GetWindowLongPtr(m_log.GetHwnd(), GWL_STYLE) & WS_VSCROLL) { - int len = GetWindowTextLength(m_log.GetHwnd()) - 1; - m_log.SendMsg(EM_SETSEL, len, len); - - PostMessage(m_log.GetHwnd(), WM_VSCROLL, MAKEWPARAM(SB_BOTTOM, 0), 0); - } -} - void CChatRoomDlg::ShowFilterMenu() { HWND hwnd = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_FILTER), m_hwnd, FilterWndProc, (LPARAM)this); @@ -283,13 +267,9 @@ void CChatRoomDlg::UpdateOptions() if (m_si->iType == GCW_CHATROOM) EnableWindow(m_btnChannelMgr.GetHwnd(), mi->bChanMgr); - HICON hIcon = (m_si->wStatus == ID_STATUS_ONLINE) ? mi->hOnlineIcon : mi->hOfflineIcon; - if (!hIcon) { - g_chatApi.MM_IconsChanged(); - hIcon = (m_si->wStatus == ID_STATUS_ONLINE) ? mi->hOnlineIcon : mi->hOfflineIcon; - } - + HICON hIcon = ImageList_GetIcon(Clist_GetImageList(), GetImageId(), ILD_TRANSPARENT); SendMessage(m_pOwner->m_hwndStatus, SB_SETICON, 0, (LPARAM)hIcon); + DestroyIcon(hIcon); Window_SetIcon_IcoLib(m_pOwner->GetHwnd(), g_plugin.getIconHandle(IDI_CHANMGR)); @@ -332,14 +312,10 @@ void CChatRoomDlg::UpdateStatusBar() int iStatusbarParts[2] = { x, -1 }; SendMessage(m_pOwner->m_hwndStatus, SB_SETPARTS, 2, (LPARAM)&iStatusbarParts); - // stupid hack to make icons show. I dunno why this is needed currently - HICON hIcon = m_si->wStatus == ID_STATUS_ONLINE ? m_si->pMI->hOnlineIcon : m_si->pMI->hOfflineIcon; - if (!hIcon) { - g_chatApi.MM_IconsChanged(); - hIcon = m_si->wStatus == ID_STATUS_ONLINE ? m_si->pMI->hOnlineIcon : m_si->pMI->hOfflineIcon; - } - + HICON hIcon = ImageList_GetIcon(Clist_GetImageList(), GetImageId(), ILD_TRANSPARENT); SendMessage(m_pOwner->m_hwndStatus, SB_SETICON, 0, (LPARAM)hIcon); + DestroyIcon(hIcon); + SendMessage(m_pOwner->m_hwndStatus, SB_SETTEXT, 0, (LPARAM)ptszDispName); SendMessage(m_pOwner->m_hwndStatus, SB_SETTEXT, 1, (LPARAM)(m_si->ptszStatusbarText ? m_si->ptszStatusbarText : L"")); SendMessage(m_pOwner->m_hwndStatus, SB_SETTIPTEXT, 1, (LPARAM)(m_si->ptszStatusbarText ? m_si->ptszStatusbarText : L"")); diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp index 3702f21c0c..396c0aa422 100644 --- a/src/core/stdmsg/src/msgdialog.cpp +++ b/src/core/stdmsg/src/msgdialog.cpp @@ -33,30 +33,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define ENTERCLICKTIME 1000 //max time in ms during which a double-tap on enter will cause a send
-int SendMessageDirect(const wchar_t *szMsg, MCONTACT hContact)
-{
- if (hContact == 0)
- return 0;
-
- int flags = 0;
- if (Utils_IsRtl(szMsg))
- flags |= PREF_RTL;
-
- T2Utf sendBuffer(szMsg);
- if (!mir_strlen(sendBuffer))
- return 0;
-
- if (db_mc_isMeta(hContact))
- hContact = db_mc_getSrmmSub(hContact);
-
- int sendId = ProtoChainSend(hContact, PSS_MESSAGE, flags, (LPARAM)sendBuffer);
- msgQueue_add(hContact, sendId, sendBuffer.detach(), flags);
- return sendId;
-}
+/////////////////////////////////////////////////////////////////////////////////////////
-static void AddToFileList(wchar_t ***pppFiles, int *totalCount, const wchar_t* szFilename)
+static void AddToFileList(wchar_t ***pppFiles, int *totalCount, const wchar_t *szFilename)
{
- *pppFiles = (wchar_t**)mir_realloc(*pppFiles, (++*totalCount + 1)*sizeof(wchar_t*));
+ *pppFiles = (wchar_t **)mir_realloc(*pppFiles, (++ * totalCount + 1) * sizeof(wchar_t *));
(*pppFiles)[*totalCount] = nullptr;
(*pppFiles)[*totalCount - 1] = mir_wstrdup(szFilename);
@@ -76,7 +57,7 @@ static void AddToFileList(wchar_t ***pppFiles, int *totalCount, const wchar_t* s }
}
-static void SetEditorText(HWND hwnd, const wchar_t* txt)
+static void SetEditorText(HWND hwnd, const wchar_t *txt)
{
SetWindowText(hwnd, txt);
SendMessage(hwnd, EM_SETSEL, -1, -1);
@@ -84,6 +65,100 @@ static void SetEditorText(HWND hwnd, const wchar_t* txt) /////////////////////////////////////////////////////////////////////////////////////////
+CMsgDialog::CMsgDialog(CTabbedWindow *pOwner, int iDialogId, SESSION_INFO *si) :
+ CSuper(g_plugin, iDialogId, si),
+ m_btnOk(this, IDOK),
+ m_pOwner(pOwner)
+{
+ m_autoClose = 0;
+ m_forceResizable = true;
+}
+
+void CMsgDialog::CloseTab()
+{
+ if (g_Settings.bTabsEnable) {
+ SendMessage(GetParent(m_hwndParent), GC_REMOVETAB, 0, (LPARAM)this);
+ Close();
+ }
+ else SendMessage(m_hwndParent, WM_CLOSE, 0, 0);
+}
+
+INT_PTR CMsgDialog::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ switch (uMsg) {
+ case WM_ACTIVATE:
+ if (LOWORD(wParam) != WA_ACTIVE)
+ break;
+
+ SetFocus(m_message.GetHwnd());
+ __fallthrough;
+
+ case WM_MOUSEACTIVATE:
+ OnActivate();
+ break;
+
+ case WM_TIMER:
+ if (wParam == TIMERID_FLASHWND) {
+ m_pOwner->FixTabIcons(this);
+ if (!g_dat.nFlashMax || m_nFlash < 2 * g_dat.nFlashMax)
+ FlashWindow(m_pOwner->GetHwnd(), TRUE);
+ m_nFlash++;
+ }
+ break;
+ }
+
+ return CSuper::DlgProc(uMsg, wParam, lParam);
+}
+
+int CMsgDialog::GetImageId() const
+{
+ if (m_nFlash & 1)
+ return 0;
+
+ return g_clistApi.pfnIconFromStatusMode(m_szProto, GetStatus(), m_hContact);
+}
+
+bool CMsgDialog::IsActive() const
+{
+ bool bRes = m_pOwner->IsActive();
+ if (g_Settings.bTabsEnable && bRes)
+ bRes &= m_pOwner->m_tab.GetActivePage() == this;
+
+ return bRes;
+}
+
+void CMsgDialog::ScrollToBottom()
+{
+ if (GetWindowLongPtr(m_log.GetHwnd(), GWL_STYLE) & WS_VSCROLL) {
+ SCROLLINFO si = {};
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_PAGE | SIF_RANGE;
+ GetScrollInfo(m_log.GetHwnd(), SB_VERT, &si);
+
+ si.fMask = SIF_POS;
+ si.nPos = si.nMax - si.nPage;
+ SetScrollInfo(m_log.GetHwnd(), SB_VERT, &si, TRUE);
+ m_log.SendMsg(WM_VSCROLL, MAKEWPARAM(SB_BOTTOM, 0), 0);
+ }
+}
+
+void CMsgDialog::StartFlash()
+{
+ ::SetTimer(m_hwnd, TIMERID_FLASHWND, 900, nullptr);
+}
+
+void CMsgDialog::StopFlash()
+{
+ if (::KillTimer(m_hwnd, TIMERID_FLASHWND)) {
+ ::FlashWindow(m_pOwner->GetHwnd(), FALSE);
+
+ m_nFlash = 0;
+ m_pOwner->FixTabIcons(this);
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
CSrmmWindow::CSrmmWindow(CTabbedWindow *pOwner, MCONTACT hContact) :
CSuper(pOwner, IDD_MSG),
m_splitter(this, IDC_SPLITTERY),
@@ -451,14 +526,6 @@ void CSrmmWindow::OnSplitterMoved(CSplitter *pSplitter) /////////////////////////////////////////////////////////////////////////////////////////
-int CSrmmWindow::GetImageId() const
-{
- if (m_nFlash & 1)
- return 0;
-
- return (WORD)g_clistApi.pfnIconFromStatusMode(m_szProto, m_wStatus, m_hContact);
-}
-
void CSrmmWindow::NotifyTyping(int mode)
{
if (!m_hContact)
@@ -506,34 +573,21 @@ void CSrmmWindow::ProcessFileDrop(HDROP hDrop) if (m_wStatus == ID_STATUS_OFFLINE) return;
if (m_hContact != 0) {
wchar_t szFilename[MAX_PATH];
- int fileCount = DragQueryFile(hDrop, -1, nullptr, 0), totalCount = 0, i;
+ int fileCount = DragQueryFile(hDrop, -1, nullptr, 0), totalCount = 0;
wchar_t **ppFiles = nullptr;
- for (i = 0; i < fileCount; i++) {
+ for (int i = 0; i < fileCount; i++) {
DragQueryFile(hDrop, i, szFilename, _countof(szFilename));
AddToFileList(&ppFiles, &totalCount, szFilename);
}
CallServiceSync(MS_FILE_SENDSPECIFICFILEST, m_hContact, (LPARAM)ppFiles);
- for (i = 0; ppFiles[i]; i++)
- mir_free(ppFiles[i]);
- mir_free(ppFiles);
+ if (ppFiles) {
+ for (int i = 0; ppFiles[i]; i++)
+ mir_free(ppFiles[i]);
+ mir_free(ppFiles);
+ }
}
}
-void CSrmmWindow::ScrollToBottom()
-{
- if (!(GetWindowLongPtr(m_log.GetHwnd(), GWL_STYLE) & WS_VSCROLL))
- return;
-
- SCROLLINFO si = {};
- si.cbSize = sizeof(si);
- si.fMask = SIF_PAGE | SIF_RANGE;
- GetScrollInfo(m_log.GetHwnd(), SB_VERT, &si);
- si.fMask = SIF_POS;
- si.nPos = si.nMax - si.nPage;
- SetScrollInfo(m_log.GetHwnd(), SB_VERT, &si, TRUE);
- m_log.SendMsg(WM_VSCROLL, MAKEWPARAM(SB_BOTTOM, 0), 0);
-}
-
void CSrmmWindow::ShowAvatar()
{
if (g_dat.bShowAvatar) {
diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp index 3647e86176..e58a812e6b 100644 --- a/src/core/stdmsg/src/msgs.cpp +++ b/src/core/stdmsg/src/msgs.cpp @@ -22,84 +22,34 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
#include "statusicon.h"
-/////////////////////////////////////////////////////////////////////////////////////////
-
-CMsgDialog::CMsgDialog(CTabbedWindow *pOwner, int iDialogId, SESSION_INFO *si) :
- CSuper(g_plugin, iDialogId, si),
- m_btnOk(this, IDOK),
- m_pOwner(pOwner)
-{
- m_autoClose = 0;
- m_forceResizable = true;
-}
+static HGENMENU hMsgMenuItem;
+static HMODULE hMsftEdit;
-void CMsgDialog::CloseTab()
-{
- if (g_Settings.bTabsEnable) {
- SendMessage(GetParent(m_hwndParent), GC_REMOVETAB, 0, (LPARAM)this);
- Close();
- }
- else SendMessage(m_hwndParent, WM_CLOSE, 0, 0);
-}
-
-INT_PTR CMsgDialog::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- switch (uMsg) {
- case WM_ACTIVATE:
- if (LOWORD(wParam) != WA_ACTIVE)
- break;
-
- SetFocus(m_message.GetHwnd());
- __fallthrough;
-
- case WM_MOUSEACTIVATE:
- OnActivate();
- break;
-
- case WM_TIMER:
- if (wParam == TIMERID_FLASHWND) {
- m_pOwner->FixTabIcons(this);
- if (!g_dat.nFlashMax || m_nFlash < 2 * g_dat.nFlashMax)
- FlashWindow(m_pOwner->GetHwnd(), TRUE);
- m_nFlash++;
- }
- break;
- }
+int OnCheckPlugins(WPARAM, LPARAM);
- return CSuper::DlgProc(uMsg, wParam, lParam);
-}
+/////////////////////////////////////////////////////////////////////////////////////////
-bool CMsgDialog::IsActive() const
+int SendMessageDirect(const wchar_t *szMsg, MCONTACT hContact)
{
- bool bRes = m_pOwner->IsActive();
- if (g_Settings.bTabsEnable && bRes)
- bRes &= m_pOwner->m_tab.GetActivePage() == this;
+ if (hContact == 0)
+ return 0;
- return bRes;
-}
+ int flags = 0;
+ if (Utils_IsRtl(szMsg))
+ flags |= PREF_RTL;
-void CMsgDialog::StartFlash()
-{
- ::SetTimer(m_hwnd, TIMERID_FLASHWND, 900, nullptr);
-}
+ T2Utf sendBuffer(szMsg);
+ if (!mir_strlen(sendBuffer))
+ return 0;
-void CMsgDialog::StopFlash()
-{
- if (::KillTimer(m_hwnd, TIMERID_FLASHWND)) {
- ::FlashWindow(m_pOwner->GetHwnd(), FALSE);
+ if (db_mc_isMeta(hContact))
+ hContact = db_mc_getSrmmSub(hContact);
- m_nFlash = 0;
- m_pOwner->FixTabIcons(this);
- }
+ int sendId = ProtoChainSend(hContact, PSS_MESSAGE, flags, (LPARAM)sendBuffer);
+ msgQueue_add(hContact, sendId, sendBuffer.detach(), flags);
+ return sendId;
}
-/////////////////////////////////////////////////////////////////////////////////////////
-
-int OnCheckPlugins(WPARAM, LPARAM);
-
-HGENMENU hMsgMenuItem;
-HMODULE hMsftEdit;
-
static int SRMMStatusToPf2(int status)
{
switch (status) {
diff --git a/src/core/stdmsg/src/msgs.h b/src/core/stdmsg/src/msgs.h index a5a5afed36..ef724a153c 100644 --- a/src/core/stdmsg/src/msgs.h +++ b/src/core/stdmsg/src/msgs.h @@ -51,10 +51,10 @@ protected: CCtrlButton m_btnOk;
CTabbedWindow *m_pOwner;
DWORD m_nFlash = 0;
+ char *m_szProto;
CMsgDialog(CTabbedWindow *pOwner, int idDialog, SESSION_INFO *si = nullptr);
- virtual const char* GetProto() const PURE;
virtual int GetStatus() const PURE;
virtual void OnActivate() PURE;
@@ -62,15 +62,14 @@ protected: INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
public:
- virtual int GetImageId() const PURE;
+ int GetImageId() const;
void CloseTab() override;
bool IsActive() const override;
+ void ScrollToBottom() override;
void StartFlash();
void StopFlash();
-
- __forceinline SESSION_INFO* getChat() const { return m_si; }
};
class CSrmmWindow : public CMsgDialog
@@ -92,7 +91,6 @@ class CSrmmWindow : public CMsgDialog void UpdateIcon(WPARAM wParam);
void UpdateLastMessage(void);
- char *m_szProto;
HICON m_hStatusIcon = nullptr;
HFONT m_hFont = nullptr;
HBRUSH m_hBkgBrush = nullptr;
@@ -133,12 +131,9 @@ public: INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
int Resizer(UTILRESIZECONTROL *urc) override;
- virtual const char* GetProto() const { return m_szProto; }
virtual int GetStatus() const { return m_wStatus; }
- int GetImageId() const override;
void LoadSettings() override {}
- void ScrollToBottom() override;
void SetStatusText(const wchar_t*, HICON) override;
void UpdateTitle() override;
@@ -190,14 +185,11 @@ public: INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
int Resizer(UTILRESIZECONTROL *urc) override;
- virtual const char* GetProto() const { return m_si->pszModule; }
virtual int GetStatus() const { return m_si->wStatus; }
- int GetImageId() const override;
void LoadSettings() override;
void RedrawLog() override;
void StreamInEvents(LOGINFO *lin, bool bRedraw) override;
- void ScrollToBottom() override;
void ShowFilterMenu() override;
void UpdateNickList() override;
void UpdateOptions() override;
diff --git a/src/core/stdmsg/src/stdafx.h b/src/core/stdmsg/src/stdafx.h index 2801630482..fcd2edc8d0 100644 --- a/src/core/stdmsg/src/stdafx.h +++ b/src/core/stdmsg/src/stdafx.h @@ -72,12 +72,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////////////////////////
-struct MODULEINFO : public GCModuleInfoBase
-{
- HICON hOnlineIcon, hOfflineIcon;
- int OnlineIconIndex, OfflineIconIndex;
-};
-
+struct MODULEINFO : public GCModuleInfoBase {};
struct SESSION_INFO : public GCSessionInfoBase {};
struct LOGSTREAMDATA : public GCLogStreamDataBase {};
diff --git a/src/core/stdmsg/src/tabs.cpp b/src/core/stdmsg/src/tabs.cpp index 008f51d506..d743ce5243 100644 --- a/src/core/stdmsg/src/tabs.cpp +++ b/src/core/stdmsg/src/tabs.cpp @@ -280,7 +280,7 @@ void CTabbedWindow::FixTabIcons(CMsgDialog *pDlg) if (pDlg == CurrPage()) { Window_FreeIcon_IcoLib(m_hwnd); if (g_dat.bUseStatusWinIcon) - Window_SetProtoIcon_IcoLib(m_hwnd, pDlg->GetProto(), pDlg->GetStatus()); + Window_SetProtoIcon_IcoLib(m_hwnd, pDlg->m_szProto, pDlg->GetStatus()); else if (pDlg->isChat()) Window_SetIcon_IcoLib(m_hwnd, g_plugin.getIconHandle(IDI_CHANMGR)); else |