diff options
28 files changed, 231 insertions, 479 deletions
diff --git a/include/m_chat.h b/include/m_chat.h index 8f08551931..93679fb1e1 100644 --- a/include/m_chat.h +++ b/include/m_chat.h @@ -415,8 +415,6 @@ EXTERN_C MIR_APP_DLL(int) Chat_SetStatusEx(const char *szModule, const wchar_t * #define WINDOW_VISIBLE 2 // make the room window visible
#define WINDOW_HIDDEN 3 // close the room window. Session is not terminated.
-#define WINDOW_MAXIMIZE 4 // make the room window maximized
-#define WINDOW_MINIMIZE 5 // make the room window minimized
#define WINDOW_CLEARLOG 6 // clear the log of the room window
// if wszId == NULL, this message is broadcasted to all windows of specified szModule
diff --git a/include/m_chat_int.h b/include/m_chat_int.h index 5ca6c8f021..7cf9a6e062 100644 --- a/include/m_chat_int.h +++ b/include/m_chat_int.h @@ -51,7 +51,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define GC_FILTERFIX (WM_USER+111)
#define GC_CHANGEFILTERFLAG (WM_USER+112)
#define GC_SHOWFILTERMENU (WM_USER+113)
-#define GC_CONTROL_MSG (WM_USER+116)
#define GC_REDRAWWINDOW (WM_USER+118)
#define GC_SHOWCOLORCHOOSER (WM_USER+119)
#define GC_ADDLOG (WM_USER+120)
@@ -287,8 +286,7 @@ struct CHAT_MANAGER {
CHAT_MANAGER();
- void (*SetActiveSession)(const wchar_t *pszID, const char *pszModule);
- void (*SetActiveSessionEx)(SESSION_INFO *si);
+ void (*SetActiveSession)(SESSION_INFO *si);
SESSION_INFO* (*GetActiveSession)(void);
SESSION_INFO* (*SM_FindSession)(const wchar_t *pszID, const char *pszModule);
HICON (*SM_GetStatusIcon)(SESSION_INFO *si, USERINFO * ui);
@@ -431,6 +429,8 @@ public: bool m_bFGSet, m_bBGSet;
COLORREF m_iFG, m_iBG;
+ void ClearLog();
+
__forceinline bool isChat() const { return m_si != nullptr; }
__inline void* operator new(size_t size){ return calloc(1, size); }
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib Binary files differindex 6d5435815a..a4b7c7c451 100644 --- a/libs/win32/mir_app.lib +++ b/libs/win32/mir_app.lib diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib Binary files differindex 3d8a67f831..ab94ce99cb 100644 --- a/libs/win64/mir_app.lib +++ b/libs/win64/mir_app.lib diff --git a/plugins/Scriver/src/chat/window.cpp b/plugins/Scriver/src/chat/window.cpp index 7b88b9ddf5..0db9074563 100644 --- a/plugins/Scriver/src/chat/window.cpp +++ b/plugins/Scriver/src/chat/window.cpp @@ -1378,7 +1378,7 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) }
else Log_StreamInEvent(m_si->pLogEnd, TRUE);
}
- else SendMessage(m_hwnd, GC_CONTROL_MSG, WINDOW_CLEARLOG, 0);
+ else ClearLog();
break;
case GC_REDRAWLOG2:
@@ -1391,7 +1391,7 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) if (m_si->pLogEnd)
Log_StreamInEvent(m_si->pLog, FALSE);
else
- SendMessage(m_hwnd, GC_CONTROL_MSG, WINDOW_CLEARLOG, 0);
+ ClearLog();
break;
case DM_UPDATETABCONTROL:
@@ -1541,60 +1541,6 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) SendMessage(m_hwnd, DM_UPDATETITLEBAR, 0, 0);
break;
- case GC_CONTROL_MSG:
- switch (wParam) {
- case SESSION_OFFLINE:
- SendMessage(m_hwnd, GC_UPDATESTATUSBAR, 0, 0);
- SendMessage(m_hwnd, GC_UPDATENICKLIST, 0, 0);
- return TRUE;
-
- case SESSION_ONLINE:
- SendMessage(m_hwnd, GC_UPDATESTATUSBAR, 0, 0);
- return TRUE;
-
- case WINDOW_HIDDEN:
- SendMessage(m_hwnd, GC_CLOSEWINDOW, 0, 0);
- return TRUE;
-
- case WINDOW_CLEARLOG:
- m_log.SetText(L"");
- return TRUE;
-
- case SESSION_TERMINATE:
- if (pcli->pfnGetEvent(m_hContact, 0))
- pcli->pfnRemoveEvent(m_hContact, GC_FAKE_EVENT);
- m_si->wState &= ~STATE_TALK;
- db_set_w(m_hContact, m_si->pszModule, "ApparentMode", 0);
- SendMessage(m_hwnd, GC_CLOSEWINDOW, 0, 0);
- return TRUE;
-
- case WINDOW_MINIMIZE:
- ShowWindow(m_hwnd, SW_MINIMIZE);
- goto LABEL_SHOWWINDOW;
-
- case WINDOW_MAXIMIZE:
- ShowWindow(m_hwnd, SW_MAXIMIZE);
- goto LABEL_SHOWWINDOW;
-
- case SESSION_INITDONE:
- if (db_get_b(0, CHAT_MODULE, "PopupOnJoin", 0) != 0)
- return TRUE;
- // fall through
- case WINDOW_VISIBLE:
- if (IsIconic(m_hwnd))
- ShowWindow(m_hwnd, SW_NORMAL);
- LABEL_SHOWWINDOW:
- SendMessage(m_hwnd, WM_SIZE, 0, 0);
- SendMessage(m_hwnd, GC_REDRAWLOG, 0, 0);
- SendMessage(m_hwnd, GC_UPDATENICKLIST, 0, 0);
- SendMessage(m_hwnd, GC_UPDATESTATUSBAR, 0, 0);
- ShowWindow(m_hwnd, SW_SHOW);
- SendMessage(m_hwnd, WM_SIZE, 0, 0);
- SetForegroundWindow(m_hwnd);
- return TRUE;
- }
- break;
-
case GC_CHANGEFILTERFLAG:
m_iLogFilterFlags = lParam;
break;
@@ -1634,12 +1580,12 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) if (LOWORD(wParam) != WA_ACTIVE)
break;
- //fall through
+ // fall through
case WM_MOUSEACTIVATE:
if (uMsg != WM_ACTIVATE)
SetFocus(m_message.GetHwnd());
- pci->SetActiveSession(m_si->ptszID, m_si->pszModule);
+ pci->SetActiveSession(m_si);
if (db_get_w(m_hContact, m_si->pszModule, "ApparentMode", 0) != 0)
db_set_w(m_hContact, m_si->pszModule, "ApparentMode", 0);
diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp index 037f1eef6d..e131d282ca 100644 --- a/plugins/Scriver/src/msgdialog.cpp +++ b/plugins/Scriver/src/msgdialog.cpp @@ -1239,7 +1239,7 @@ INT_PTR CSrmmWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) pf2.dwMask = PFM_OFFSET;
pf2.dxOffset = (g_dat.flags & SMF_INDENTTEXT) ? g_dat.indentSize * 1440 / g_dat.logPixelSX : 0;
- SetDlgItemText(m_hwnd, IDC_LOG, L"");
+ ClearLog();
m_log.SendMsg(EM_SETPARAFORMAT, 0, (LPARAM)&pf2);
m_log.SendMsg(EM_SETLANGOPTIONS, 0, (LPARAM)m_log.SendMsg(EM_GETLANGOPTIONS, 0, 0) & ~(IMF_AUTOKEYBOARD | IMF_AUTOFONTSIZEADJUST));
@@ -1523,7 +1523,7 @@ INT_PTR CSrmmWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) CallService(MS_IEVIEW_EVENT, 0, (LPARAM)&evt);
}
- SetDlgItemText(m_hwnd, IDC_LOG, L"");
+ ClearLog();
m_hDbEventFirst = 0;
m_lastEventType = -1;
break;
diff --git a/plugins/Scriver/src/msglog.cpp b/plugins/Scriver/src/msglog.cpp index 71fbab8539..cd340a7dc2 100644 --- a/plugins/Scriver/src/msglog.cpp +++ b/plugins/Scriver/src/msglog.cpp @@ -796,7 +796,7 @@ void CSrmmWindow::StreamInEvents(MEVENT hDbEventFirst, int count, int fAppend) }
else {
m_log.SendMsg(WM_SETREDRAW, FALSE, 0);
- m_log.SetText(L"");
+ ClearLog();
sel.cpMin = 0;
sel.cpMax = GetRichTextLength(m_log.GetHwnd(), 1200, FALSE);
m_log.SendMsg(EM_EXSETSEL, 0, (LPARAM)&sel);
diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp index ba4bd65404..fa0f0a6265 100644 --- a/plugins/Scriver/src/msgs.cpp +++ b/plugins/Scriver/src/msgs.cpp @@ -366,22 +366,6 @@ CScriverWindow::CScriverWindow(int iDialog, SESSION_INFO *si) m_autoClose = CLOSE_ON_CANCEL;
}
-INT_PTR CScriverWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- if (uMsg == WM_COMMAND) {
- if (!lParam && Clist_MenuProcessCommand(LOWORD(wParam), MPCF_CONTACTMENU, m_hContact))
- return 0;
-
- if (HIWORD(wParam) == BN_CLICKED)
- if (LOWORD(wParam) >= MIN_CBUTTONID && LOWORD(wParam) <= MAX_CBUTTONID) {
- Srmm_ClickToolbarIcon(m_hContact, LOWORD(wParam), GetDlgItem(m_hwnd, LOWORD(wParam)), 0);
- return 0;
- }
- }
-
- return CSrmmBaseDialog::DlgProc(uMsg, wParam, lParam);
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
// status icons processing
diff --git a/plugins/Scriver/src/msgs.h b/plugins/Scriver/src/msgs.h index 03ae1eee12..9bde19bcec 100644 --- a/plugins/Scriver/src/msgs.h +++ b/plugins/Scriver/src/msgs.h @@ -90,8 +90,6 @@ class CScriverWindow : public CSrmmBaseDialog protected:
CScriverWindow(int iDialog, SESSION_INFO* = nullptr);
- virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
-
public:
ParentWindowData *m_pParent;
int m_minLogBoxHeight, m_minEditBoxHeight;
diff --git a/plugins/TabSRMM/src/chat_log.cpp b/plugins/TabSRMM/src/chat_log.cpp index 26884a7ed8..bdcdadf887 100644 --- a/plugins/TabSRMM/src/chat_log.cpp +++ b/plugins/TabSRMM/src/chat_log.cpp @@ -633,8 +633,6 @@ static void AddEventToBuffer(CMStringA &str, LOGSTREAMDATA *streamData) char* Log_CreateRtfHeader(MODULEINFO *mi)
{
- int i = 0;
-
// get the number of pixels per logical inch
if (pci->logPixelSY == 0) {
HDC hdc = GetDC(nullptr);
@@ -647,19 +645,19 @@ char* Log_CreateRtfHeader(MODULEINFO *mi) // font table
CMStringA str("{\\rtf1\\ansi\\deff0{\\fonttbl");
- for (i = 0; i < OPTIONS_FONTCOUNT; i++)
+ for (int i = 0; i < OPTIONS_FONTCOUNT; i++)
str.AppendFormat("{\\f%u\\fnil\\fcharset%u%S;}", i, pci->aFonts[i].lf.lfCharSet, pci->aFonts[i].lf.lfFaceName);
// colour table
str.Append("}{\\colortbl ;");
- for (i = 0; i < OPTIONS_FONTCOUNT; i++)
+ for (int i = 0; i < OPTIONS_FONTCOUNT; i++)
str.AppendFormat("\\red%u\\green%u\\blue%u;", GetRValue(pci->aFonts[i].color), GetGValue(pci->aFonts[i].color), GetBValue(pci->aFonts[i].color));
- for (i = 0; i < mi->nColorCount; i++)
+ for (int i = 0; i < mi->nColorCount; i++)
str.AppendFormat("\\red%u\\green%u\\blue%u;", GetRValue(mi->crColors[i]), GetGValue(mi->crColors[i]), GetBValue(mi->crColors[i]));
- for (i = 0; i < STATUSICONCOUNT; i++)
+ for (int i = 0; i < STATUSICONCOUNT; i++)
str.AppendFormat("\\red%u\\green%u\\blue%u;", GetRValue(g_Settings.nickColors[i]), GetGValue(g_Settings.nickColors[i]), GetBValue(g_Settings.nickColors[i]));
// new paragraph
@@ -839,11 +837,9 @@ void CChatRoomDlg::StreamInEvents(LOGINFO *lin, SESSION_INFO *si, bool bRedraw) if (m_hwnd == 0 || lin == 0 || si == 0)
return;
- HWND hwndRich = GetDlgItem(m_hwnd, IDC_LOG);
-
LOGSTREAMDATA streamData;
memset(&streamData, 0, sizeof(streamData));
- streamData.hwnd = hwndRich;
+ streamData.hwnd = m_log.GetHwnd();
streamData.si = si;
streamData.lin = lin;
streamData.bStripFormat = FALSE;
@@ -854,24 +850,24 @@ void CChatRoomDlg::StreamInEvents(LOGINFO *lin, SESSION_INFO *si, bool bRedraw) bool bFlag = false, fDoReplace;
- EDITSTREAM stream = { 0 };
+ EDITSTREAM stream = {};
stream.pfnCallback = Srmm_LogStreamCallback;
stream.dwCookie = (DWORD_PTR)& streamData;
- SCROLLINFO scroll = { 0 };
+ SCROLLINFO scroll = {};
scroll.cbSize = sizeof(SCROLLINFO);
scroll.fMask = SIF_RANGE | SIF_POS | SIF_PAGE;
GetScrollInfo(GetDlgItem(m_hwnd, IDC_LOG), SB_VERT, &scroll);
- SendMessage(hwndRich, EM_GETSCROLLPOS, 0, (LPARAM)&point);
+ m_log.SendMsg(EM_GETSCROLLPOS, 0, (LPARAM)&point);
// do not scroll to bottom if there is a selection
- SendMessage(hwndRich, EM_EXGETSEL, 0, (LPARAM)&oldsel);
+ m_log.SendMsg(EM_EXGETSEL, 0, (LPARAM)&oldsel);
if (oldsel.cpMax != oldsel.cpMin)
- SendMessage(hwndRich, WM_SETREDRAW, FALSE, 0);
+ m_log.SendMsg(WM_SETREDRAW, FALSE, 0);
// set the insertion point at the bottom
- sel.cpMin = sel.cpMax = GetRichTextLength(hwndRich);
- SendMessage(hwndRich, EM_EXSETSEL, 0, (LPARAM)&sel);
+ sel.cpMin = sel.cpMax = GetRichTextLength(m_log.GetHwnd());
+ m_log.SendMsg(EM_EXSETSEL, 0, (LPARAM)&sel);
// fix for the indent... must be a M$ bug
if (sel.cpMax == 0)
@@ -886,14 +882,14 @@ void CChatRoomDlg::StreamInEvents(LOGINFO *lin, SESSION_INFO *si, bool bRedraw) pci->logPixelSY = GetDeviceCaps(hdc, LOGPIXELSY);
pci->logPixelSX = GetDeviceCaps(hdc, LOGPIXELSX);
ReleaseDC(nullptr, hdc);
- SendMessage(hwndRich, WM_SETREDRAW, FALSE, 0);
+ m_log.SendMsg(WM_SETREDRAW, FALSE, 0);
bFlag = true;
}
// stream in the event(s)
streamData.lin = lin;
streamData.bRedraw = bRedraw;
- SendMessage(hwndRich, EM_STREAMIN, wp, (LPARAM)&stream);
+ m_log.SendMsg(EM_STREAMIN, wp, (LPARAM)&stream);
// for new added events, only replace in message or action events.
// no need to replace smileys or math formulas elsewhere
@@ -912,29 +908,28 @@ void CChatRoomDlg::StreamInEvents(LOGINFO *lin, SESSION_INFO *si, bool bRedraw) fi.chrg.cpMax = -1;
fi.lpstrText = L"~~++#";
- while (SendMessage(hwndRich, EM_FINDTEXTEX, FR_DOWN, (LPARAM)&fi) > -1) {
+ while (m_log.SendMsg(EM_FINDTEXTEX, FR_DOWN, (LPARAM)&fi) > -1) {
fi2.chrg.cpMin = fi.chrgText.cpMin;
fi2.chrg.cpMax = -1;
- if (SendMessage(hwndRich, EM_FINDTEXTEX, FR_DOWN, (LPARAM)&fi2) > -1) {
-
- SendMessage(hwndRich, EM_EXSETSEL, 0, (LPARAM)&fi.chrgText);
- SendMessage(hwndRich, EM_REPLACESEL, TRUE, (LPARAM)L"");
+ if (m_log.SendMsg(EM_FINDTEXTEX, FR_DOWN, (LPARAM)&fi2) > -1) {
+ m_log.SendMsg(EM_EXSETSEL, 0, (LPARAM)&fi.chrgText);
+ m_log.SendMsg(EM_REPLACESEL, TRUE, (LPARAM)L"");
fi2.chrgText.cpMin -= fi.chrgText.cpMax - fi.chrgText.cpMin;
fi2.chrgText.cpMax -= fi.chrgText.cpMax - fi.chrgText.cpMin;
- SendMessage(hwndRich, EM_EXSETSEL, 0, (LPARAM)&fi2.chrgText);
- SendMessage(hwndRich, EM_REPLACESEL, TRUE, (LPARAM)L"");
+ m_log.SendMsg(EM_EXSETSEL, 0, (LPARAM)&fi2.chrgText);
+ m_log.SendMsg(EM_REPLACESEL, TRUE, (LPARAM)L"");
fi2.chrgText.cpMax = fi2.chrgText.cpMin;
fi2.chrgText.cpMin = fi.chrgText.cpMin;
- SendMessage(hwndRich, EM_EXSETSEL, 0, (LPARAM)&fi2.chrgText);
+ m_log.SendMsg(EM_EXSETSEL, 0, (LPARAM)&fi2.chrgText);
cf2.dwMask = CFM_PROTECTED;
cf2.dwEffects = CFE_PROTECTED;
- SendMessage(hwndRich, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2);
+ m_log.SendMsg(EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2);
}
fi.chrg.cpMin = fi.chrgText.cpMax;
}
- SendMessage(hwndRich, EM_SETSEL, -1, -1);
+ m_log.SendMsg(EM_SETSEL, -1, -1);
}
// run smileyadd
@@ -945,7 +940,7 @@ void CChatRoomDlg::StreamInEvents(LOGINFO *lin, SESSION_INFO *si, bool bRedraw) newsel.cpMin = 0;
SMADD_RICHEDIT3 sm = { sizeof(sm) };
- sm.hwndRichEditControl = hwndRich;
+ sm.hwndRichEditControl = m_log.GetHwnd();
sm.Protocolname = si->pszModule;
sm.rangeToReplace = bRedraw ? nullptr : &newsel;
sm.disableRedraw = TRUE;
@@ -963,34 +958,34 @@ void CChatRoomDlg::StreamInEvents(LOGINFO *lin, SESSION_INFO *si, bool bRedraw) fi.lpstrText = szPattern;
fi.chrg.cpMin = 0;
fi.chrg.cpMax = -1;
- if (SendMessage(hwndRich, EM_FINDTEXTEX, FR_DOWN, (LPARAM)&fi) != 0) {
+ if (m_log.SendMsg(EM_FINDTEXTEX, FR_DOWN, (LPARAM)&fi) != 0) {
CHARRANGE rng;
rng.cpMin = 0;
rng.cpMax = 20;
- SendMessage(hwndRich, EM_SETSEL, 0, fi.chrgText.cpMax + 1);
- SendMessage(hwndRich, EM_REPLACESEL, TRUE, (LPARAM)L"");
+ m_log.SendMsg(EM_SETSEL, 0, fi.chrgText.cpMax + 1);
+ m_log.SendMsg(EM_REPLACESEL, TRUE, (LPARAM)L"");
}
si->bTrimmed = false;
}
// scroll log to bottom if the log was previously scrolled to bottom, else restore old position
if ((bRedraw || (UINT)scroll.nPos >= (UINT)scroll.nMax - scroll.nPage - 5 || scroll.nMax - scroll.nMin - scroll.nPage < 50))
- SendMessage(GetParent(hwndRich), GC_SCROLLTOBOTTOM, 0, 0);
+ SendMessage(GetParent(m_log.GetHwnd()), GC_SCROLLTOBOTTOM, 0, 0);
else
- SendMessage(hwndRich, EM_SETSCROLLPOS, 0, (LPARAM)&point);
+ m_log.SendMsg(EM_SETSCROLLPOS, 0, (LPARAM)&point);
// do we need to restore the selection
if (oldsel.cpMax != oldsel.cpMin) {
- SendMessage(hwndRich, EM_EXSETSEL, 0, (LPARAM)&oldsel);
- SendMessage(hwndRich, WM_SETREDRAW, TRUE, 0);
- InvalidateRect(hwndRich, nullptr, TRUE);
+ m_log.SendMsg(EM_EXSETSEL, 0, (LPARAM)&oldsel);
+ m_log.SendMsg(WM_SETREDRAW, TRUE, 0);
+ InvalidateRect(m_log.GetHwnd(), nullptr, TRUE);
}
// need to invalidate the window
if (bFlag) {
- sel.cpMin = sel.cpMax = GetRichTextLength(hwndRich);
- SendMessage(hwndRich, EM_EXSETSEL, 0, (LPARAM)&sel);
- SendMessage(hwndRich, WM_SETREDRAW, TRUE, 0);
- InvalidateRect(hwndRich, nullptr, TRUE);
+ sel.cpMin = sel.cpMax = GetRichTextLength(m_log.GetHwnd());
+ m_log.SendMsg(EM_EXSETSEL, 0, (LPARAM)&sel);
+ m_log.SendMsg(WM_SETREDRAW, TRUE, 0);
+ InvalidateRect(m_log.GetHwnd(), nullptr, TRUE);
}
}
diff --git a/plugins/TabSRMM/src/chat_window.cpp b/plugins/TabSRMM/src/chat_window.cpp index 3869504ee2..127a7b4d60 100644 --- a/plugins/TabSRMM/src/chat_window.cpp +++ b/plugins/TabSRMM/src/chat_window.cpp @@ -183,12 +183,12 @@ void CChatRoomDlg::UpdateWindowState(UINT msg) m_pWnd->setOverlayIcon(0, true); } - if (m_pContainer->hwndSaved == m_hwnd || m_bWasDeleted) + if (m_pContainer->hwndSaved == m_hwnd) return; m_pContainer->hwndSaved = m_hwnd; - pci->SetActiveSession(m_si->ptszID, m_si->pszModule); + pci->SetActiveSession(m_si); m_hTabIcon = m_hTabStatusIcon; if (m_iTabID >= 0) { @@ -1552,16 +1552,16 @@ CChatRoomDlg::CChatRoomDlg(SESSION_INFO *si) m_list.OnDblClick = Callback(this, &CChatRoomDlg::OnDblClick_List); } -CThumbBase* CChatRoomDlg::CreateThumb(CProxyWindow *pProxy) const +CThumbBase* CChatRoomDlg::tabCreateThumb(CProxyWindow *pProxy) const { return new CThumbMUC(pProxy, m_si); } -void CChatRoomDlg::ClearLog() +void CChatRoomDlg::tabClearLog() { SESSION_INFO *s = pci->SM_FindSession(m_si->ptszID, m_si->pszModule); if (s) { - m_log.SetText(L""); + ClearLog(); pci->LM_RemoveAll(&s->pLog, &s->pLogEnd); s->iEventCount = 0; s->LastTime = 0; @@ -1998,9 +1998,8 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) case DM_UPDATETITLE: case GC_UPDATETITLE: - if (!m_bWasDeleted) { - m_wStatus = m_si->wStatus; - + m_wStatus = m_si->wStatus; + { const wchar_t *szNick = m_cache->getNick(); if (mir_wstrlen(szNick) > 0) { if (M.GetByte("cuttitle", 0)) @@ -2058,9 +2057,6 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) break; case GC_UPDATESTATUSBAR: - if (m_bWasDeleted) - return 0; - if (m_pContainer->hwndActive != m_hwnd || m_pContainer->hwndStatus == 0 || CMimAPI::m_shutDown || m_wszStatusBar[0]) break; @@ -2170,7 +2166,7 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) } else StreamInEvents(m_si->pLogEnd, m_si, TRUE); } - else SendMessage(m_hwnd, GC_CONTROL_MSG, WINDOW_CLEARLOG, 0); + else ClearLog(); break; case GC_REDRAWLOG2: @@ -2197,7 +2193,7 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) if (m_si->pLogEnd) StreamInEvents(m_si->pLog, m_si, FALSE); else - SendMessage(m_hwnd, GC_CONTROL_MSG, WINDOW_CLEARLOG, 0); + ClearLog(); break; case DM_TYPING: @@ -2350,107 +2346,49 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) } break; - case GC_CONTROL_MSG: - switch (wParam) { - case SESSION_OFFLINE: - SendMessage(m_hwnd, GC_UPDATESTATUSBAR, 0, 0); - SendMessage(m_si->pDlg->GetHwnd(), GC_UPDATENICKLIST, 0, 0); - return TRUE; - - case SESSION_ONLINE: - SendMessage(m_hwnd, GC_UPDATESTATUSBAR, 0, 0); - return TRUE; - - case WINDOW_HIDDEN: - SendMessage(m_hwnd, GC_CLOSEWINDOW, 0, 1); - return TRUE; - - case WINDOW_CLEARLOG: - SetDlgItemText(m_hwnd, IDC_LOG, L""); - return TRUE; - - case SESSION_TERMINATE: - if (pcli->pfnGetEvent(m_si->hContact, 0)) - pcli->pfnRemoveEvent(m_si->hContact, GC_FAKE_EVENT); - - m_si->wState &= ~STATE_TALK; - m_bWasDeleted = true; - db_set_w(m_si->hContact, m_si->pszModule, "ApparentMode", 0); - SendMessage(m_hwnd, GC_CLOSEWINDOW, 0, lParam == 2 ? lParam : 1); - return TRUE; + case DM_SPLITTERMOVED: + RECT rcLog; + GetWindowRect(m_log.GetHwnd(), &rcLog); - case WINDOW_MINIMIZE: - ShowWindow(m_hwnd, SW_MINIMIZE); -LABEL_SHOWWINDOW: + if ((HWND)lParam == GetDlgItem(m_hwnd, IDC_SPLITTERX)) { + GetClientRect(m_hwnd, &rc); + pt.x = wParam, pt.y = 0; + ScreenToClient(m_hwnd, &pt); + + int iSplitterX = rc.right - pt.x + 1; + if (iSplitterX < 35) + iSplitterX = 35; + if (iSplitterX > rc.right - rc.left - 35) + iSplitterX = rc.right - rc.left - 35; + m_pContainer->settings->iSplitterX = iSplitterX; SendMessage(m_hwnd, WM_SIZE, 0, 0); - SendMessage(m_hwnd, GC_REDRAWLOG, 0, 0); - SendMessage(m_hwnd, GC_UPDATENICKLIST, 0, 0); - SendMessage(m_hwnd, GC_UPDATESTATUSBAR, 0, 0); - ShowWindow(m_hwnd, SW_SHOW); + } + else if ((HWND)lParam == GetDlgItem(m_hwnd, IDC_SPLITTERY) || lParam == -1) { + GetClientRect(m_hwnd, &rc); + rc.top += (m_pPanel.isActive() ? m_pPanel.getHeight() + 40 : 30); + pt.x = 0, pt.y = wParam; + ScreenToClient(m_hwnd, &pt); + + m_iSplitterY = rc.bottom - pt.y + DPISCALEY_S(1); + if (m_iSplitterY < DPISCALEY_S(23)) + m_iSplitterY = DPISCALEY_S(23); + if (m_iSplitterY > rc.bottom - rc.top - DPISCALEY_S(40)) + m_iSplitterY = rc.bottom - rc.top - DPISCALEY_S(40); + m_pContainer->settings->iSplitterY = m_iSplitterY; + UpdateToolbarBG(); SendMessage(m_hwnd, WM_SIZE, 0, 0); - SetForegroundWindow(m_hwnd); - return TRUE; - - case WINDOW_MAXIMIZE: - ShowWindow(m_hwnd, SW_MAXIMIZE); - goto LABEL_SHOWWINDOW; - - case SESSION_INITDONE: - if (M.GetByte(CHAT_MODULE, "PopupOnJoin", 0) != 0) - return TRUE; - - // fall through - case WINDOW_VISIBLE: - if (IsIconic(m_hwnd)) - ShowWindow(m_hwnd, SW_NORMAL); - goto LABEL_SHOWWINDOW; } - break; - - case DM_SPLITTERMOVED: - RECT rcLog; - { - GetWindowRect(m_log.GetHwnd(), &rcLog); - if ((HWND)lParam == GetDlgItem(m_hwnd, IDC_SPLITTERX)) { - GetClientRect(m_hwnd, &rc); - pt.x = wParam, pt.y = 0; - ScreenToClient(m_hwnd, &pt); - - int iSplitterX = rc.right - pt.x + 1; - if (iSplitterX < 35) - iSplitterX = 35; - if (iSplitterX > rc.right - rc.left - 35) - iSplitterX = rc.right - rc.left - 35; - m_pContainer->settings->iSplitterX = iSplitterX; - SendMessage(m_hwnd, WM_SIZE, 0, 0); - } - else if ((HWND)lParam == GetDlgItem(m_hwnd, IDC_SPLITTERY) || lParam == -1) { - GetClientRect(m_hwnd, &rc); - rc.top += (m_pPanel.isActive() ? m_pPanel.getHeight() + 40 : 30); - pt.x = 0, pt.y = wParam; - ScreenToClient(m_hwnd, &pt); - - m_iSplitterY = rc.bottom - pt.y + DPISCALEY_S(1); - if (m_iSplitterY < DPISCALEY_S(23)) - m_iSplitterY = DPISCALEY_S(23); - if (m_iSplitterY > rc.bottom - rc.top - DPISCALEY_S(40)) - m_iSplitterY = rc.bottom - rc.top - DPISCALEY_S(40); - m_pContainer->settings->iSplitterY = m_iSplitterY; - UpdateToolbarBG(); - SendMessage(m_hwnd, WM_SIZE, 0, 0); - } - else if ((HWND)lParam == GetDlgItem(m_hwnd, IDC_PANELSPLITTER)) { - pt.x = 0, pt.y = wParam; - ScreenToClient(m_hwnd, &pt); - GetClientRect(m_log.GetHwnd(), &rc); - if ((pt.y + 2 >= MIN_PANELHEIGHT + 2) && (pt.y + 2 < 100) && (pt.y + 2 < rc.bottom - 30)) - m_pPanel.setHeight(pt.y + 2); - RedrawWindow(m_hwnd, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE); - if (M.isAero()) - InvalidateRect(m_hwndParent, nullptr, FALSE); - SendMessage(m_hwnd, WM_SIZE, DM_SPLITTERMOVED, 0); - break; - } + else if ((HWND)lParam == GetDlgItem(m_hwnd, IDC_PANELSPLITTER)) { + pt.x = 0, pt.y = wParam; + ScreenToClient(m_hwnd, &pt); + GetClientRect(m_log.GetHwnd(), &rc); + if ((pt.y + 2 >= MIN_PANELHEIGHT + 2) && (pt.y + 2 < 100) && (pt.y + 2 < rc.bottom - 30)) + m_pPanel.setHeight(pt.y + 2); + RedrawWindow(m_hwnd, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE); + if (M.isAero()) + InvalidateRect(m_hwndParent, nullptr, FALSE); + SendMessage(m_hwnd, WM_SIZE, DM_SPLITTERMOVED, 0); + break; } break; @@ -2643,7 +2581,7 @@ LABEL_SHOWWINDOW: break; case ID_CLEARLOG: - ClearLog(); + tabClearLog(); break; case ID_SEARCH_GOOGLE: @@ -2820,11 +2758,6 @@ LABEL_SHOWWINDOW: break; case WM_COMMAND: - if (LOWORD(wParam) >= MIN_CBUTTONID && LOWORD(wParam) <= MAX_CBUTTONID){ - Srmm_ClickToolbarIcon(m_hContact, LOWORD(wParam), GetDlgItem(m_hwnd, LOWORD(wParam)), 0); - break; - } - switch (LOWORD(wParam)) { case IDC_TOGGLESIDEBAR: SendMessage(m_pContainer->hwnd, WM_COMMAND, IDC_TOGGLESIDEBAR, 0); diff --git a/plugins/TabSRMM/src/generic_msghandlers.cpp b/plugins/TabSRMM/src/generic_msghandlers.cpp index 1f81e18ac1..88cc78091c 100644 --- a/plugins/TabSRMM/src/generic_msghandlers.cpp +++ b/plugins/TabSRMM/src/generic_msghandlers.cpp @@ -151,7 +151,7 @@ bool CTabBaseDlg::DM_GenericHotkeysCheck(MSG *message) return true; case TABSRMM_HK_CLEARLOG: - ClearLog(); + tabClearLog(); return true; case TABSRMM_HK_TOGGLESIDEBAR: @@ -479,7 +479,7 @@ LRESULT CTabBaseDlg::DM_MsgWindowCmdHandler(UINT cmd, WPARAM wParam, LPARAM lPar break; case IDM_CLEAR: - ClearLog(); + tabClearLog(); break; case IDC_PROTOCOL: @@ -612,7 +612,7 @@ void CTabBaseDlg::DM_InitRichEdit() pf2.dxOffset = m_pContainer->theme.left_indent + 30; if (!fIsChat) { - m_log.SetText(L""); + ClearLog(); m_log.SendMsg(EM_SETPARAFORMAT, 0, (LPARAM)&pf2); m_log.SendMsg(EM_SETLANGOPTIONS, 0, (LPARAM)SendDlgItemMessage(m_hwnd, IDC_LOG, EM_GETLANGOPTIONS, 0, 0) & ~IMF_AUTOKEYBOARD); // set the scrollbars etc to RTL/LTR (only for manual RTL mode) diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index 28231fa2b8..facf8f9345 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -154,7 +154,7 @@ static void ShowPopupMenu(CTabBaseDlg *dat, int idFrom, HWND hwndFrom, POINT pt) SendMessage(hwndFrom, EM_EXSETSEL, 0, (LPARAM)&all);
break;
case IDM_CLEAR:
- dat->ClearLog();
+ dat->tabClearLog();
break;
case ID_LOG_FREEZELOG:
SendDlgItemMessage(hwndDlg, IDC_LOG, WM_KEYDOWN, VK_F12, 0);
@@ -921,7 +921,7 @@ CSrmmWindow::CSrmmWindow() {
}
-void CSrmmWindow::ClearLog()
+void CSrmmWindow::tabClearLog()
{
if (m_hwndIEView || m_hwndHPP) {
IEVIEWEVENT event;
@@ -942,7 +942,7 @@ void CSrmmWindow::ClearLog() m_hDbEventFirst = 0;
}
-CThumbBase* CSrmmWindow::CreateThumb(CProxyWindow *pProxy) const
+CThumbBase* CSrmmWindow::tabCreateThumb(CProxyWindow *pProxy) const
{
return new CThumbIM(pProxy);
}
@@ -2512,15 +2512,6 @@ INT_PTR CSrmmWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) break;
case WM_COMMAND:
- if (!this)
- break;
-
- // custom button handling
- if (LOWORD(wParam) >= MIN_CBUTTONID && LOWORD(wParam) <= MAX_CBUTTONID) {
- Srmm_ClickToolbarIcon(m_hContact, LOWORD(wParam), GetDlgItem(m_hwnd, LOWORD(wParam)), 0);
- break;
- }
-
switch (LOWORD(wParam)) {
case IDOK:
if (m_bEditNotesActive) {
diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h index 879b9bd1eb..64e9779e0c 100644 --- a/plugins/TabSRMM/src/msgs.h +++ b/plugins/TabSRMM/src/msgs.h @@ -358,8 +358,8 @@ public: virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
- virtual CThumbBase* CreateThumb(CProxyWindow*) const = 0;
- virtual void ClearLog() = 0;
+ virtual CThumbBase* tabCreateThumb(CProxyWindow*) const = 0;
+ virtual void tabClearLog() = 0;
static LONG_PTR CALLBACK StatusBarSubclassProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
@@ -433,8 +433,8 @@ public: class CSrmmWindow : public CTabBaseDlg
{
- virtual CThumbBase* CreateThumb(CProxyWindow *pProxy) const override;
- virtual void ClearLog() override;
+ virtual CThumbBase* tabCreateThumb(CProxyWindow *pProxy) const override;
+ virtual void tabClearLog() override;
void MsgWindowUpdateState(UINT msg);
void ReplayQueue();
@@ -461,7 +461,6 @@ public: class CChatRoomDlg : public CTabBaseDlg
{
HWND m_hwndFilter;
- bool m_bWasDeleted;
CCtrlButton m_btnFilter, m_btnHistory, m_btnChannelMgr, m_btnNickList, m_btnOk;
CCtrlButton m_btnBold, m_btnItalic, m_btnUnderline, m_btnColor, m_btnBkColor;
CCtrlListBox m_list;
@@ -470,8 +469,8 @@ class CChatRoomDlg : public CTabBaseDlg static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
static INT_PTR CALLBACK FilterWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
- virtual CThumbBase* CreateThumb(CProxyWindow *pProxy) const override;
- virtual void ClearLog() override;
+ virtual CThumbBase* tabCreateThumb(CProxyWindow *pProxy) const override;
+ virtual void tabClearLog() override;
public:
int m_iSearchItem;
diff --git a/plugins/TabSRMM/src/taskbar.cpp b/plugins/TabSRMM/src/taskbar.cpp index 4d3f846610..f206631744 100644 --- a/plugins/TabSRMM/src/taskbar.cpp +++ b/plugins/TabSRMM/src/taskbar.cpp @@ -293,7 +293,7 @@ void CProxyWindow::sendThumb(LONG width, LONG height) if (0 == m_thumb) {
m_width = width;
m_height = height;
- m_thumb = m_dat->CreateThumb(this);
+ m_thumb = m_dat->tabCreateThumb(this);
}
else if (width != m_width || height != m_height || !m_thumb->isValid()) {
m_width = width;
diff --git a/protocols/Discord/src/utils.cpp b/protocols/Discord/src/utils.cpp index 6fc1e8b23a..bd21fbd48a 100644 --- a/protocols/Discord/src/utils.cpp +++ b/protocols/Discord/src/utils.cpp @@ -23,7 +23,7 @@ void CDiscordProto::SetAllContactStatuses(int status) if (!getByte(hContact, "ChatRoom")) setWord(hContact, "Status", (WORD)status); else if (status == ID_STATUS_OFFLINE) - Chat_Control(m_szModuleName, ptrW(getWStringA(hContact, "ChatRoomID")), SESSION_TERMINATE); + Chat_Terminate(m_szModuleName, ptrW(getWStringA(hContact, "ChatRoomID"))); } } diff --git a/protocols/IRCG/src/commandmonitor.cpp b/protocols/IRCG/src/commandmonitor.cpp index 45265b9d54..7c460538c1 100644 --- a/protocols/IRCG/src/commandmonitor.cpp +++ b/protocols/IRCG/src/commandmonitor.cpp @@ -1381,7 +1381,7 @@ bool CIrcProto::OnIrc_ENDNAMES(const CIrcMessage* pmsg) Chat_Control(m_szModuleName, sID, WINDOW_HIDDEN);
break;
case 'X':
- Chat_Control(m_szModuleName, sID, WINDOW_MAXIMIZE);
+ Chat_Control(m_szModuleName, sID, WINDOW_VISIBLE);
break;
default:
Chat_Control(m_szModuleName, sID, SESSION_INITDONE);
diff --git a/protocols/IRCG/src/services.cpp b/protocols/IRCG/src/services.cpp index 28b070caf3..6dae62da22 100644 --- a/protocols/IRCG/src/services.cpp +++ b/protocols/IRCG/src/services.cpp @@ -1045,7 +1045,7 @@ void CIrcProto::DisconnectFromServer(void) if (m_perform && IsConnected())
DoPerform("Event: Disconnect");
- Chat_Terminate(m_szModuleName, NULL);
+ Chat_Terminate(m_szModuleName, nullptr);
ForkThread(&CIrcProto::DisconnectServerThread, 0);
}
diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp index 6cb09aabc2..c431395078 100644 --- a/protocols/JabberG/src/jabber_chat.cpp +++ b/protocols/JabberG/src/jabber_chat.cpp @@ -327,7 +327,10 @@ void CJabberProto::GcQuit(JABBER_LIST_ITEM *item, int code, HXML reason) GcLogUpdateMemberStatus(item, myNick, myNick, NULL, GC_EVENT_KICK, reason);
}
- Chat_Control(m_szModuleName, item->jid, (code == 200) ? SESSION_TERMINATE : SESSION_OFFLINE);
+ if (code == 200)
+ Chat_Terminate(m_szModuleName, item->jid);
+ else
+ Chat_Control(m_szModuleName, item->jid, SESSION_OFFLINE);
db_unset(item->hContact, "CList", "Hidden");
item->bChatActive = false;
diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp index 975bcd9fdc..4cac5fb957 100644 --- a/protocols/VKontakte/src/vk_chats.cpp +++ b/protocols/VKontakte/src/vk_chats.cpp @@ -613,7 +613,10 @@ void CVkProto::LeaveChat(int chat_id, bool close_window, bool delete_chat) if (cc == NULL)
return;
- Chat_Control(m_szModuleName, cc->m_wszId, close_window ? SESSION_TERMINATE : SESSION_OFFLINE);
+ if (close_window)
+ Chat_Terminate(m_szModuleName, cc->m_wszId);
+ else
+ Chat_Control(m_szModuleName, cc->m_wszId, SESSION_OFFLINE);
if (delete_chat)
db_delete_contact(cc->m_hContact);
diff --git a/src/core/stdmsg/src/chat_window.cpp b/src/core/stdmsg/src/chat_window.cpp index 5e98c0f0f6..53123a88da 100644 --- a/src/core/stdmsg/src/chat_window.cpp +++ b/src/core/stdmsg/src/chat_window.cpp @@ -931,7 +931,16 @@ void CChatRoomDlg::OnInitDialog() void CChatRoomDlg::OnDestroy() { NotifyLocalWinEvent(m_hContact, m_hwnd, MSG_WINDOW_EVT_CLOSING); + SaveWindowPosition(true); + if (!g_Settings.bTabsEnable) { + if (db_get_b(0, CHAT_MODULE, "SavePosition", 0)) { + db_set_dw(m_hContact, CHAT_MODULE, "roomx", m_si->iX); + db_set_dw(m_hContact, CHAT_MODULE, "roomy", m_si->iY); + db_set_dw(m_hContact, CHAT_MODULE, "roomwidth", m_si->iWidth); + db_set_dw(m_hContact, CHAT_MODULE, "roomheight", m_si->iHeight); + } + } WindowList_Remove(pci->hWindowList, m_hwnd); @@ -1388,7 +1397,7 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) } else Log_StreamInEvent(m_si->pLogEnd, TRUE); } - else SendMessage(m_hwnd, GC_CONTROL_MSG, WINDOW_CLEARLOG, 0); + else ClearLog(); break; case GC_REDRAWLOG2: @@ -1401,7 +1410,7 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) if (m_si->pLogEnd) Log_StreamInEvent(m_si->pLog, FALSE); else - SendMessage(m_hwnd, GC_CONTROL_MSG, WINDOW_CLEARLOG, 0); + ClearLog(); break; case WM_CTLCOLORLISTBOX: @@ -1484,71 +1493,6 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) } break; - case GC_CONTROL_MSG: - switch (wParam) { - case SESSION_OFFLINE: - SendMessage(m_hwnd, GC_UPDATESTATUSBAR, 0, 0); - SendMessage(m_si->pDlg->GetHwnd(), GC_UPDATENICKLIST, 0, 0); - return TRUE; - - case SESSION_ONLINE: - SendMessage(m_hwnd, GC_UPDATESTATUSBAR, 0, 0); - return TRUE; - - case WINDOW_HIDDEN: - SendMessage(m_hwnd, GC_CLOSEWINDOW, 0, 0); - return TRUE; - - case WINDOW_CLEARLOG: - SetDlgItemText(m_hwnd, IDC_LOG, L""); - return TRUE; - - case SESSION_TERMINATE: - if (!g_Settings.bTabsEnable) { - SaveWindowPosition(true); - if (db_get_b(0, CHAT_MODULE, "SavePosition", 0)) { - db_set_dw(m_hContact, CHAT_MODULE, "roomx", m_si->iX); - db_set_dw(m_hContact, CHAT_MODULE, "roomy", m_si->iY); - db_set_dw(m_hContact, CHAT_MODULE, "roomwidth", m_si->iWidth); - db_set_dw(m_hContact, CHAT_MODULE, "roomheight", m_si->iHeight); - } - } - - if (pcli->pfnGetEvent(m_hContact, 0)) - pcli->pfnRemoveEvent(m_hContact, GC_FAKE_EVENT); - m_si->wState &= ~STATE_TALK; - db_set_w(m_hContact, m_si->pszModule, "ApparentMode", 0); - SendMessage(m_hwnd, GC_CLOSEWINDOW, 0, 0); - return TRUE; - - case WINDOW_MINIMIZE: - ShowWindow(m_hwnd, SW_MINIMIZE); - goto LABEL_SHOWWINDOW; - - case WINDOW_MAXIMIZE: - ShowWindow(m_hwnd, SW_MAXIMIZE); - goto LABEL_SHOWWINDOW; - - case SESSION_INITDONE: - if (db_get_b(0, CHAT_MODULE, "PopupOnJoin", 0) != 0) - return TRUE; - // fall through - case WINDOW_VISIBLE: - if (IsIconic(m_hwnd)) - ShowWindow(m_hwnd, SW_NORMAL); - -LABEL_SHOWWINDOW: - SendMessage(m_hwnd, WM_SIZE, 0, 0); - SendMessage(m_hwnd, GC_REDRAWLOG, 0, 0); - SendMessage(m_hwnd, GC_UPDATENICKLIST, 0, 0); - SendMessage(m_hwnd, GC_UPDATESTATUSBAR, 0, 0); - ShowWindow(m_hwnd, SW_SHOW); - SendMessage(m_hwnd, WM_SIZE, 0, 0); - SetForegroundWindow(m_hwnd); - return TRUE; - } - break; - case GC_CLOSEWINDOW: if (g_Settings.bTabsEnable) SendMessage(GetParent(m_hwndParent), GC_REMOVETAB, 0, (LPARAM)this); @@ -1620,7 +1564,7 @@ LABEL_SHOWWINDOW: if (uMsg != WM_ACTIVATE) SetFocus(m_message.GetHwnd()); - pci->SetActiveSession(m_si->ptszID, m_si->pszModule); + pci->SetActiveSession(m_si); if (KillTimer(m_hwnd, TIMERID_FLASHWND)) FlashWindow(m_hwnd, FALSE); @@ -1682,7 +1626,7 @@ LABEL_SHOWWINDOW: case ID_CLEARLOG: s = pci->SM_FindSession(m_si->ptszID, m_si->pszModule); if (s) { - SetDlgItemText(m_hwnd, IDC_LOG, L""); + ClearLog(); pci->LM_RemoveAll(&s->pLog, &s->pLogEnd); s->iEventCount = 0; s->LastTime = 0; @@ -1739,12 +1683,6 @@ LABEL_SHOWWINDOW: break; case WM_COMMAND: - if (HIWORD(wParam) == BN_CLICKED) - if (LOWORD(wParam) >= MIN_CBUTTONID && LOWORD(wParam) <= MAX_CBUTTONID) { - Srmm_ClickToolbarIcon(m_hContact, LOWORD(wParam), GetDlgItem(m_hwnd, LOWORD(wParam)), 0); - break; - } - switch (LOWORD(wParam)) { case IDC_MESSAGE: EnableWindow(m_btnOk.GetHwnd(), GetRichTextLength(m_message.GetHwnd()) != 0); diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp index 345107d711..3ded6a16c7 100644 --- a/src/core/stdmsg/src/msgdialog.cpp +++ b/src/core/stdmsg/src/msgdialog.cpp @@ -697,7 +697,7 @@ void CSrmmWindow::OnOptionsApplied(bool bUpdateAvatar) pf2.wEffects = PFE_RTLPARA;
pf2.dwMask = PFM_RTLPARA;
- m_log.SetText(L"");
+ ClearLog();
m_log.SendMsg(EM_SETPARAFORMAT, 0, (LPARAM)&pf2);
pf2.wEffects = 0;
m_log.SendMsg(EM_SETPARAFORMAT, 0, (LPARAM)&pf2);
@@ -1274,16 +1274,6 @@ INT_PTR CSrmmWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) break;
case WM_COMMAND:
- if (!lParam && Clist_MenuProcessCommand(LOWORD(wParam), MPCF_CONTACTMENU, m_hContact))
- break;
-
- // custom button handling
- if (HIWORD(wParam) == BN_CLICKED)
- if (LOWORD(wParam) >= MIN_CBUTTONID && LOWORD(wParam) <= MAX_CBUTTONID) {
- Srmm_ClickToolbarIcon(m_hContact, LOWORD(wParam), GetDlgItem(m_hwnd, LOWORD(wParam)), 0);
- break;
- }
-
switch (LOWORD(wParam)) {
case IDOK:
if (IsWindowEnabled(GetDlgItem(m_hwnd, IDOK))) {
@@ -1427,7 +1417,7 @@ INT_PTR CSrmmWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) SendMessage(pLink->nmhdr.hwndFrom, EM_EXSETSEL, 0, (LPARAM)&all);
break;
case IDM_CLEAR:
- m_log.SetText(L"");
+ ClearLog();
m_hDbEventFirst = NULL;
break;
}
diff --git a/src/mir_app/src/chat.h b/src/mir_app/src/chat.h index d081407ac6..dee0182b12 100644 --- a/src/mir_app/src/chat.h +++ b/src/mir_app/src/chat.h @@ -58,12 +58,11 @@ char* SM_GetUsers(SESSION_INFO *si); BOOL SM_GiveStatus(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID, const wchar_t *pszStatus);
BOOL SM_MoveUser(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID);
void SM_RemoveAll(void);
-int SM_RemoveSession(const wchar_t *pszID, const char *pszModule, BOOL removeContact);
+int SM_RemoveSession(const wchar_t *pszID, const char *pszModule, bool removeContact);
BOOL SM_RemoveUser(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID);
-LRESULT SM_SendMessage(const wchar_t *pszID, const char *pszModule, UINT msg, WPARAM wParam, LPARAM lParam);
BOOL SM_SetContactStatus(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID, WORD wStatus);
-BOOL SM_SetOffline(const wchar_t *pszID, const char *pszModule);
-BOOL SM_SetStatus(const wchar_t *pszID, const char *pszModule, int wStatus);
+BOOL SM_SetOffline(SESSION_INFO *si);
+BOOL SM_SetStatus(SESSION_INFO *si, int wStatus);
BOOL SM_TakeStatus(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID, const wchar_t *pszStatus);
SESSION_INFO* SM_FindSession(const wchar_t *pszID, const char *pszModule);
diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp index 2fa68a3f90..0f9024d306 100644 --- a/src/mir_app/src/chat_manager.cpp +++ b/src/mir_app/src/chat_manager.cpp @@ -42,7 +42,7 @@ CHAT_MANAGER chatApi; MODULEINFO *m_ModList = 0;
-static void SetActiveSessionEx(SESSION_INFO *si)
+static void SetActiveSession(SESSION_INFO *si)
{
if (si) {
replaceStrW(chatApi.szActiveWndID, si->ptszID);
@@ -50,13 +50,6 @@ static void SetActiveSessionEx(SESSION_INFO *si) }
}
-static void SetActiveSession(const wchar_t *pszID, const char *pszModule)
-{
- SESSION_INFO *si = SM_FindSession(pszID, pszModule);
- if (si)
- SetActiveSessionEx(si);
-}
-
static SESSION_INFO* GetActiveSession(void)
{
SESSION_INFO *si = SM_FindSession(chatApi.szActiveWndID, chatApi.szActiveWndModule);
@@ -72,8 +65,21 @@ static SESSION_INFO* GetActiveSession(void) // Keeps track of all sessions and its windows
//---------------------------------------------------
-static void SM_FreeSession(SESSION_INFO *si)
+static void SM_FreeSession(SESSION_INFO *si, bool bRemoveContact = false)
{
+ if (cli.pfnGetEvent(si->hContact, 0))
+ cli.pfnRemoveEvent(si->hContact, GC_FAKE_EVENT);
+ si->wState &= ~STATE_TALK;
+ db_set_w(si->hContact, si->pszModule, "ApparentMode", 0);
+
+ if (si->pDlg)
+ SendMessage(si->pDlg->GetHwnd(), GC_CLOSEWINDOW, 0, 1);
+
+ DoEventHook(si, GC_SESSION_TERMINATE, nullptr, nullptr, (INT_PTR)si->pItemData);
+
+ if (si->hContact && bRemoveContact)
+ db_delete_contact(si->hContact);
+
// contact may have been deleted here already, since function may be called after deleting
// contact so the handle may be invalid, therefore db_get_b shall return 0
if (si->hContact && db_get_b(si->hContact, si->pszModule, "ChatRoom", 0) != 0) {
@@ -106,32 +112,28 @@ static void SM_FreeSession(SESSION_INFO *si) mir_free(si);
}
-int SM_RemoveSession(const wchar_t *pszID, const char *pszModule, BOOL removeContact)
+int SM_RemoveSession(const wchar_t *pszID, const char *pszModule, bool removeContact)
{
- if (!pszModule)
+ if (pszModule == nullptr)
return FALSE;
- for (int i = g_arSessions.getCount() - 1; i >= 0; i--) {
- SESSION_INFO *si = g_arSessions[i];
- // match
- if ((!pszID && si->iType != GCW_SERVER || !mir_wstrcmpi(si->ptszID, pszID)) && !mir_strcmpi(si->pszModule, pszModule)) {
- if (si->pDlg)
- SendMessage(si->pDlg->GetHwnd(), GC_CONTROL_MSG, SESSION_TERMINATE, 0);
- DoEventHook(si, GC_SESSION_TERMINATE, nullptr, nullptr, (INT_PTR)si->pItemData);
+ if (pszID != nullptr) {
+ SESSION_INFO *si = SM_FindSession(pszID, pszModule);
+ if (si == nullptr)
+ return FALSE;
- // contact may have been deleted here already, since function may be called after deleting
- // contact so the handle may be invalid, therefore db_get_b shall return 0
- if (si->hContact && removeContact)
- db_delete_contact(si->hContact);
+ SM_FreeSession(si, removeContact);
+ return TRUE;
+ }
- SM_FreeSession(si);
+ for (int i = g_arSessions.getCount() - 1; i >= 0; i--) {
+ SESSION_INFO *si = g_arSessions[i];
+ if (si->iType != GCW_SERVER && !mir_strcmpi(si->pszModule, pszModule)) {
+ SM_FreeSession(si, removeContact);
g_arSessions.remove(i);
-
- if (pszID)
- return 1;
}
}
- return FALSE;
+ return TRUE;
}
SESSION_INFO* SM_FindSession(const wchar_t *pszID, const char *pszModule)
@@ -147,26 +149,18 @@ SESSION_INFO* SM_FindSession(const wchar_t *pszID, const char *pszModule) return g_arSessions.find(&tmp);
}
-BOOL SM_SetOffline(const wchar_t *pszID, const char *pszModule)
+BOOL SM_SetOffline(SESSION_INFO *si)
{
- if (!pszModule)
+ if (si == nullptr)
return FALSE;
- for (int i = 0; i < g_arSessions.getCount(); i++) {
- SESSION_INFO *si = g_arSessions[i];
- if ((pszID && mir_wstrcmpi(si->ptszID, pszID)) || mir_strcmpi(si->pszModule, pszModule))
- continue;
-
- chatApi.UM_RemoveAll(&si->pUsers);
- si->pMe = nullptr;
- si->nUsersInNicklist = 0;
- if (si->iType != GCW_SERVER)
- si->bInitDone = false;
- if (chatApi.OnOfflineSession)
- chatApi.OnOfflineSession(si);
- if (pszID)
- return TRUE;
- }
+ chatApi.UM_RemoveAll(&si->pUsers);
+ si->pMe = nullptr;
+ si->nUsersInNicklist = 0;
+ if (si->iType != GCW_SERVER)
+ si->bInitDone = false;
+ if (chatApi.OnOfflineSession)
+ chatApi.OnOfflineSession(si);
return TRUE;
}
@@ -308,27 +302,6 @@ BOOL SM_TakeStatus(const wchar_t *pszID, const char *pszModule, const wchar_t *p return TRUE;
}
-LRESULT SM_SendMessage(const wchar_t *pszID, const char *pszModule, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- if (pszModule == nullptr)
- return 0;
-
- for (int i = 0; i < g_arSessions.getCount(); i++) {
- SESSION_INFO *si = g_arSessions[i];
- if ((pszID && mir_wstrcmpi(si->ptszID, pszID)) || mir_strcmpi(si->pszModule, pszModule))
- continue;
-
- if (si->pDlg) {
- LRESULT res = SendMessage(si->pDlg->GetHwnd(), msg, wParam, lParam);
- if (pszID)
- return res;
- }
- if (pszID)
- return 0;
- }
- return 0;
-}
-
static BOOL SM_BroadcastMessage(const char *pszModule, UINT msg, WPARAM wParam, LPARAM lParam, BOOL bAsync)
{
for (int i = 0; i < g_arSessions.getCount(); i++) {
@@ -346,30 +319,19 @@ static BOOL SM_BroadcastMessage(const char *pszModule, UINT msg, WPARAM wParam, return TRUE;
}
-BOOL SM_SetStatus(const wchar_t *pszID, const char *pszModule, int wStatus)
+BOOL SM_SetStatus(SESSION_INFO *si, int wStatus)
{
- if (!pszModule)
- return FALSE;
-
- for (int i = 0; i < g_arSessions.getCount(); i++) {
- SESSION_INFO *si = g_arSessions[i];
- if ((pszID && mir_wstrcmpi(si->ptszID, pszID)) || mir_strcmpi(si->pszModule, pszModule))
- continue;
+ si->wStatus = wStatus;
+ if (si->hContact) {
+ if (si->iType != GCW_SERVER && wStatus != ID_STATUS_OFFLINE)
+ db_unset(si->hContact, "CList", "Hidden");
- si->wStatus = wStatus;
- if (si->hContact) {
- if (si->iType != GCW_SERVER && wStatus != ID_STATUS_OFFLINE)
- db_unset(si->hContact, "CList", "Hidden");
-
- db_set_w(si->hContact, si->pszModule, "Status", (WORD)wStatus);
- }
+ db_set_w(si->hContact, si->pszModule, "Status", (WORD)wStatus);
+ }
- if (chatApi.OnSetStatus)
- chatApi.OnSetStatus(si, wStatus);
+ if (chatApi.OnSetStatus)
+ chatApi.OnSetStatus(si, wStatus);
- if (pszID)
- return TRUE;
- }
return TRUE;
}
@@ -400,15 +362,9 @@ BOOL SM_ChangeNick(const wchar_t *pszID, const char *pszModule, GCEVENT *gce) void SM_RemoveAll(void)
{
- for (int i = 0; i < g_arSessions.getCount(); i++) {
- SESSION_INFO *si = g_arSessions[i];
-
- if (si->pDlg)
- SendMessage(si->pDlg->GetHwnd(), GC_CONTROL_MSG, SESSION_TERMINATE, 0);
- DoEventHook(si, GC_SESSION_TERMINATE, nullptr, nullptr, (INT_PTR)si->pItemData);
+ for (int i = 0; i < g_arSessions.getCount(); i++)
+ SM_FreeSession(g_arSessions[i], false);
- SM_FreeSession(si);
- }
g_arSessions.destroy();
}
@@ -1088,7 +1044,6 @@ MIR_APP_DLL(CHAT_MANAGER*) Chat_GetInterface(CHAT_MANAGER_INITDATA *pInit, int _ g_iChatLang = _hLangpack;
chatApi.SetActiveSession = SetActiveSession;
- chatApi.SetActiveSessionEx = SetActiveSessionEx;
chatApi.GetActiveSession = GetActiveSession;
chatApi.SM_FindSession = SM_FindSession;
chatApi.SM_GetStatusIcon = SM_GetStatusIcon;
diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp index 0446d8979d..8bfb9d684d 100644 --- a/src/mir_app/src/chat_svc.cpp +++ b/src/mir_app/src/chat_svc.cpp @@ -275,50 +275,52 @@ static INT_PTR __stdcall stubRoomControl(void *param) ChatConrolParam *p = (ChatConrolParam*)param;
mir_cslock lck(csChat);
+ SESSION_INFO *si = chatApi.SM_FindSession(p->wszId, p->szModule);
+ if (si == nullptr)
+ return GC_EVENT_ERROR;
+
switch (p->command) {
case WINDOW_HIDDEN:
- if (SESSION_INFO *si = chatApi.SM_FindSession(p->wszId, p->szModule)) {
- SetInitDone(si);
- chatApi.SetActiveSession(si->ptszID, si->pszModule);
- }
- return 0;
+ SetInitDone(si);
+ chatApi.SetActiveSession(si);
+ if (si->pDlg)
+ ::SendMessage(si->pDlg->GetHwnd(), GC_CLOSEWINDOW, 0, 0);
+ break;
- case WINDOW_MINIMIZE:
- case WINDOW_MAXIMIZE:
case WINDOW_VISIBLE:
case SESSION_INITDONE:
- if (SESSION_INFO *si = chatApi.SM_FindSession(p->wszId, p->szModule)) {
- SetInitDone(si);
- if (p->command != SESSION_INITDONE || db_get_b(0, CHAT_MODULE, "PopupOnJoin", 0) == 0)
- chatApi.ShowRoom(si);
- return 0;
- }
+ SetInitDone(si);
+ if (p->command != SESSION_INITDONE || db_get_b(0, CHAT_MODULE, "PopupOnJoin", 0) == 0)
+ chatApi.ShowRoom(si);
break;
case SESSION_OFFLINE:
- SM_SetOffline(p->wszId, p->szModule);
- // fall through
+ SM_SetOffline(si);
+ SM_SetStatus(si, ID_STATUS_OFFLINE);
+ if (si->pDlg) {
+ ::SendMessage(si->pDlg->GetHwnd(), GC_UPDATESTATUSBAR, 0, 0);
+ ::SendMessage(si->pDlg->GetHwnd(), GC_UPDATENICKLIST, 0, 0);
+ }
+ break;
case SESSION_ONLINE:
- SM_SetStatus(p->wszId, p->szModule, p->command == SESSION_ONLINE ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE);
+ SM_SetStatus(si, ID_STATUS_ONLINE);
+ if (si->pDlg)
+ ::SendMessage(si->pDlg->GetHwnd(), GC_UPDATESTATUSBAR, 0, 0);
break;
- case SESSION_TERMINATE:
- return SM_RemoveSession(p->wszId, p->szModule, false);
-
case WINDOW_CLEARLOG:
- if (SESSION_INFO *si = chatApi.SM_FindSession(p->wszId, p->szModule)) {
- chatApi.LM_RemoveAll(&si->pLog, &si->pLogEnd);
- si->iEventCount = 0;
- si->LastTime = 0;
- }
+ chatApi.LM_RemoveAll(&si->pLog, &si->pLogEnd);
+ si->iEventCount = 0;
+ si->LastTime = 0;
+ if (si->pDlg)
+ si->pDlg->ClearLog();
break;
default:
return GC_EVENT_ERROR;
}
- SM_SendMessage(p->wszId, p->szModule, GC_CONTROL_MSG, p->command, 0);
return 0;
}
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index c2562b7c58..1628ca17a9 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -411,3 +411,4 @@ ProtoGetAvatarMimeType @401 Srmm_LogStreamCallback @412
Srmm_MessageStreamCallback @413
?DoEventHook@CSrmmBaseDialog@@IAEXHPBUUSERINFO@@PB_WH@Z @414 NONAME
+?ClearLog@CSrmmBaseDialog@@QAEXXZ @415 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 8c86e46402..ad9ab48e67 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -411,3 +411,4 @@ ProtoGetAvatarMimeType @401 Srmm_LogStreamCallback @412
Srmm_MessageStreamCallback @413
?DoEventHook@CSrmmBaseDialog@@IEAAXHPEBUUSERINFO@@PEB_W_J@Z @414 NONAME
+?ClearLog@CSrmmBaseDialog@@QEAAXXZ @415 NONAME
diff --git a/src/mir_app/src/srmm_base.cpp b/src/mir_app/src/srmm_base.cpp index 03aa63c405..1f017289b4 100644 --- a/src/mir_app/src/srmm_base.cpp +++ b/src/mir_app/src/srmm_base.cpp @@ -58,6 +58,16 @@ CSrmmBaseDialog::CSrmmBaseDialog(HINSTANCE hInst, int idDialog, SESSION_INFO *si INT_PTR CSrmmBaseDialog::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { + case WM_COMMAND: + if (!lParam && Clist_MenuProcessCommand(LOWORD(wParam), MPCF_CONTACTMENU, m_hContact)) + return 0; + + if (wParam >= MIN_CBUTTONID && wParam <= MAX_CBUTTONID) { + Srmm_ClickToolbarIcon(m_hContact, wParam, GetDlgItem(m_hwnd, wParam), 0); + return 0; + } + break; + case WM_NOTIFY: if (m_pLog != nullptr) { LPNMHDR hdr = (LPNMHDR)lParam; @@ -128,6 +138,12 @@ INT_PTR CSrmmBaseDialog::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) return CDlgBase::DlgProc(msg, wParam, lParam); } +void CSrmmBaseDialog::ClearLog() +{ + if (m_pLog != nullptr) + m_pLog->SetText(L""); +} + void CSrmmBaseDialog::DoEventHook(int iType, const USERINFO *pUser, const wchar_t *pszText, INT_PTR dwItem) { GCDEST gcd = {}; |