diff options
author | George Hazan <george.hazan@gmail.com> | 2024-10-14 16:43:53 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-10-14 16:43:53 +0300 |
commit | 64b53b1c28ffa353ff2f0c0a01405f9afc2b7bf1 (patch) | |
tree | 09f966d418bd50c8d63b52ec7896462803dc6294 | |
parent | 29af90eb23768e9eb2c29091fefaaa10c78ff8cd (diff) |
common group chat code moved to mir_app
-rw-r--r-- | include/m_chat_int.h | 7 | ||||
-rw-r--r-- | libs/win32/mir_app.lib | bin | 299690 -> 299976 bytes | |||
-rw-r--r-- | libs/win64/mir_app.lib | bin | 299726 -> 300016 bytes | |||
-rw-r--r-- | plugins/Scriver/src/msgdialog.cpp | 17 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat_tools.cpp | 3 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgdialog.cpp | 4 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgdlgother.cpp | 5 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgdialog.cpp | 6 | ||||
-rw-r--r-- | src/core/stdmsg/src/tabs.cpp | 12 | ||||
-rw-r--r-- | src/mir_app/src/chat.h | 2 | ||||
-rw-r--r-- | src/mir_app/src/chat_manager.cpp | 26 | ||||
-rw-r--r-- | src/mir_app/src/mir_app.def | 1 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 1 |
13 files changed, 35 insertions, 49 deletions
diff --git a/include/m_chat_int.h b/include/m_chat_int.h index c05b4599cc..99088b2c2f 100644 --- a/include/m_chat_int.h +++ b/include/m_chat_int.h @@ -43,8 +43,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define CHAT_MODULE "Chat"
#define CHATFONT_MODULE "ChatFonts"
-#define GC_FAKE_EVENT MEVENT(0xBABABEDA)
-
#define GCW_TABROOM 10
#define GCW_TABPRIVMSG 11
@@ -85,13 +83,13 @@ struct USERINFO : public MZeroedObject, public MNonCopyable wchar_t* pszUID;
wchar_t* pszNick;
- uint32_t iSignature = GC_FAKE_EVENT;
+ uint32_t iSignature = 0xDEADBEEF;
uint16_t Status;
uint16_t ContactStatus;
int iStatusEx;
bool isValid() const {
- return iSignature == GC_FAKE_EVENT;
+ return iSignature == 0xDEADBEEF;
}
};
@@ -196,6 +194,7 @@ struct MIR_APP_EXPORT SESSION_INFO : public MZeroedObject, public MNonCopyable }
const char* getSoundName(int iEventType) const;
+ void markRead(bool bForce = false);
};
struct GlobalLogSettingsBase
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib Binary files differindex 8997ca6142..2872634966 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 5371e0c5ca..31077d14f9 100644 --- a/libs/win64/mir_app.lib +++ b/libs/win64/mir_app.lib diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp index 602aeaeb0e..2477dcbfa6 100644 --- a/plugins/Scriver/src/msgdialog.cpp +++ b/plugins/Scriver/src/msgdialog.cpp @@ -855,17 +855,7 @@ INT_PTR CMsgDialog::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) case DM_ACTIVATE:
if (isChat()) {
- if (m_si->wState & STATE_TALK) {
- m_si->wState &= ~STATE_TALK;
- db_unset(m_hContact, m_si->pszModule, "ApparentMode");
- }
-
- if (m_si->wState & GC_EVENT_HIGHLIGHT) {
- m_si->wState &= ~GC_EVENT_HIGHLIGHT;
-
- if (Clist_GetEvent(m_hContact, 0))
- Clist_RemoveEvent(m_hContact, GC_FAKE_EVENT);
- }
+ m_si->markRead();
FixTabIcons();
if (!m_si->pDlg) {
@@ -882,10 +872,7 @@ INT_PTR CMsgDialog::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) SetFocus(m_message.GetHwnd());
if (isChat()) {
- if (db_get_w(m_hContact, m_si->pszModule, "ApparentMode") != 0)
- db_unset(m_hContact, m_si->pszModule, "ApparentMode");
- if (Clist_GetEvent(m_hContact, 0))
- Clist_RemoveEvent(m_hContact, GC_FAKE_EVENT);
+ m_si->markRead(true);
}
else {
if (m_hDbUnreadEventFirst != 0) {
diff --git a/plugins/TabSRMM/src/chat_tools.cpp b/plugins/TabSRMM/src/chat_tools.cpp index 31682a5f0e..166468ab11 100644 --- a/plugins/TabSRMM/src/chat_tools.cpp +++ b/plugins/TabSRMM/src/chat_tools.cpp @@ -40,8 +40,7 @@ static void __stdcall Chat_DismissPopup(void *pi) {
SESSION_INFO *si = (SESSION_INFO*)pi;
if (si->hContact)
- if (Clist_GetEvent(si->hContact, 0))
- Clist_RemoveEvent(si->hContact, GC_FAKE_EVENT);
+ si->markRead(true);
if (si->pDlg && si->pDlg->timerFlash.Stop())
FlashWindow(si->pDlg->GetHwnd(), FALSE);
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index d158902e32..a0fdd09f57 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -681,9 +681,7 @@ void CMsgDialog::OnDestroy() DestroyWindow(m_hwndPanelPicParent);
if (m_si) {
- if (Clist_GetEvent(m_si->hContact, 0))
- Clist_RemoveEvent(m_si->hContact, GC_FAKE_EVENT);
- m_si->wState &= ~STATE_TALK;
+ m_si->markRead(true);
m_si->pDlg = nullptr;
m_si = nullptr;
}
diff --git a/plugins/TabSRMM/src/msgdlgother.cpp b/plugins/TabSRMM/src/msgdlgother.cpp index 982ab1cdcb..f9d345a4d8 100644 --- a/plugins/TabSRMM/src/msgdlgother.cpp +++ b/plugins/TabSRMM/src/msgdlgother.cpp @@ -2590,10 +2590,7 @@ void CMsgDialog::UpdateWindowState(UINT msg) if (m_si) {
m_hTabIcon = m_hTabStatusIcon;
- if (db_get_w(m_si->hContact, m_si->pszModule, "ApparentMode") != 0)
- db_unset(m_si->hContact, m_si->pszModule, "ApparentMode");
- if (Clist_GetEvent(m_si->hContact, 0))
- Clist_RemoveEvent(m_si->hContact, GC_FAKE_EVENT);
+ m_si->markRead(true);
UpdateTitle();
m_hTabIcon = m_hTabStatusIcon;
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp index a57d9444a8..a549fae3e2 100644 --- a/src/core/stdmsg/src/msgdialog.cpp +++ b/src/core/stdmsg/src/msgdialog.cpp @@ -253,11 +253,7 @@ void CMsgDialog::OnActivate() if (isChat()) {
UpdateStatusBar();
-
- if (db_get_w(m_hContact, m_si->pszModule, "ApparentMode") != 0)
- db_unset(m_hContact, m_si->pszModule, "ApparentMode");
- if (Clist_GetEvent(m_hContact, 0))
- Clist_RemoveEvent(m_hContact, GC_FAKE_EVENT);
+ m_si->markRead(true);
}
else {
SetupStatusBar();
diff --git a/src/core/stdmsg/src/tabs.cpp b/src/core/stdmsg/src/tabs.cpp index 52e54f4cd1..b8c33d11ac 100644 --- a/src/core/stdmsg/src/tabs.cpp +++ b/src/core/stdmsg/src/tabs.cpp @@ -467,17 +467,7 @@ void CTabbedWindow::TabClicked() SESSION_INFO *si = pDlg->m_si;
if (si) {
- if (si->wState & STATE_TALK) {
- si->wState &= ~STATE_TALK;
- db_unset(si->hContact, si->pszModule, "ApparentMode");
- }
-
- if (si->wState & GC_EVENT_HIGHLIGHT) {
- si->wState &= ~GC_EVENT_HIGHLIGHT;
-
- if (Clist_GetEvent(si->hContact, 0))
- Clist_RemoveEvent(si->hContact, GC_FAKE_EVENT);
- }
+ si->markRead();
if (!si->pDlg) {
g_chatApi.ShowRoom(si);
diff --git a/src/mir_app/src/chat.h b/src/mir_app/src/chat.h index 2f620c2e56..60c4af86e0 100644 --- a/src/mir_app/src/chat.h +++ b/src/mir_app/src/chat.h @@ -25,6 +25,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <m_popup.h>
#include <m_fontservice.h>
+#define GC_FAKE_EVENT MEVENT(0xBABABEDA)
+
#define STREAMSTAGE_HEADER 0
#define STREAMSTAGE_EVENTS 1
#define STREAMSTAGE_TAIL 2
diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp index 700e48c14f..507c24895b 100644 --- a/src/mir_app/src/chat_manager.cpp +++ b/src/mir_app/src/chat_manager.cpp @@ -49,8 +49,7 @@ static int compareModules(const MODULEINFO *p1, const MODULEINFO *p2) static LIST<MODULEINFO> g_arModules(5, compareModules);
/////////////////////////////////////////////////////////////////////////////////////////
-// Session Manager functions
-// Keeps track of all sessions and its windows
+// SESSION_INFO class members
static int CompareEvents(const LOGINFO *p1, const LOGINFO *p2)
{
@@ -98,6 +97,25 @@ const char* SESSION_INFO::SESSION_INFO::getSoundName(int iEventType) const return nullptr;
}
+void SESSION_INFO::markRead(bool bForce)
+{
+ if ((wState & STATE_TALK) || bForce) {
+ wState &= ~STATE_TALK;
+ db_unset(hContact, pszModule, "ApparentMode");
+ }
+
+ if ((wState & GC_EVENT_HIGHLIGHT) || bForce) {
+ wState &= ~GC_EVENT_HIGHLIGHT;
+
+ if (Clist_GetEvent(hContact, 0))
+ Clist_RemoveEvent(hContact, GC_FAKE_EVENT);
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Session Manager functions
+// Keeps track of all sessions and its windows
+
static SESSION_INFO* SM_CreateSession(void)
{
return new SESSION_INFO();
@@ -105,9 +123,7 @@ static SESSION_INFO* SM_CreateSession(void) void SM_FreeSession(SESSION_INFO *si)
{
- if (Clist_GetEvent(si->hContact, 0))
- Clist_RemoveEvent(si->hContact, GC_FAKE_EVENT);
- si->wState &= ~STATE_TALK;
+ si->markRead(true);
db_unset(si->hContact, si->pszModule, "ApparentMode");
if (si->pDlg)
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 505eb60693..0aa5b1fe10 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -989,3 +989,4 @@ _Proto_CanDeleteHistory@8 @1124 NONAME ?bUseGroup@Chat@@3V?$CMOption@_N@@A @1127 NONAME
?isCustom@EventInfo@DB@@QBE_NH@Z @1128 NONAME
?InsertBbcodeString@CSrmmBaseDialog@@IAEXPB_W@Z @1129 NONAME
+?markRead@SESSION_INFO@@QAEX_N@Z @1130 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 990714d090..a5f99bcaf3 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -989,3 +989,4 @@ Proto_CanDeleteHistory @1118 NONAME ?bUseGroup@Chat@@3V?$CMOption@_N@@A @1121 NONAME
?isCustom@EventInfo@DB@@QEBA_NH@Z @1122 NONAME
?InsertBbcodeString@CSrmmBaseDialog@@IEAAXPEB_W@Z @1123 NONAME
+?markRead@SESSION_INFO@@QEAAX_N@Z @1124 NONAME
|