summaryrefslogtreecommitdiff
path: root/plugins/TabSRMM
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-11-28 17:34:41 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-11-28 17:34:51 +0300
commit1a5dc583b048727752b8f72df676ec408908041f (patch)
tree5204a5dbcbe84ed7cff02bff9e6ee32ff8598c3f /plugins/TabSRMM
parent4f961df4a3bb6577a0024e341adb9fed6d965edf (diff)
user typing notification for Discord group chats
Diffstat (limited to 'plugins/TabSRMM')
-rw-r--r--plugins/TabSRMM/src/controls.cpp6
-rw-r--r--plugins/TabSRMM/src/generic_msghandlers.cpp53
-rw-r--r--plugins/TabSRMM/src/globals.cpp9
-rw-r--r--plugins/TabSRMM/src/msgdialog.cpp10
-rw-r--r--plugins/TabSRMM/src/msgdlgother.cpp4
-rw-r--r--plugins/TabSRMM/src/msglog.cpp2
-rw-r--r--plugins/TabSRMM/src/msgs.h148
7 files changed, 121 insertions, 111 deletions
diff --git a/plugins/TabSRMM/src/controls.cpp b/plugins/TabSRMM/src/controls.cpp
index 4c426a9e1d..c9b04eb7c3 100644
--- a/plugins/TabSRMM/src/controls.cpp
+++ b/plugins/TabSRMM/src/controls.cpp
@@ -956,11 +956,11 @@ LONG_PTR CALLBACK CMsgDialog::StatusBarSubclassProc(HWND hWnd, UINT msg, WPARAM
break;
if (!mir_strcmp(sid->szModule, MSG_ICON_MODULE)) {
- if (sid->dwId == MSG_ICON_SOUND)
+ if (sid->dwId == MSG_ICON_SOUND) {
mir_snwprintf(wBuf, TranslateT("Sounds are %s. Click to toggle status, hold Shift and click to set for all open containers"),
pContainer->m_flags.m_bNoSound ? TranslateT("disabled") : TranslateT("enabled"));
-
- else if (sid->dwId == MSG_ICON_UTN && (!dat->isChat() || dat->m_si->iType == GCW_PRIVMESS)) {
+ }
+ else if (sid->dwId == MSG_ICON_UTN && dat->AllowTyping()) {
int mtnStatus = g_plugin.getByte(dat->m_hContact, SRMSGSET_TYPING, g_plugin.getByte(SRMSGSET_TYPINGNEW, SRMSGDEFSET_TYPINGNEW));
mir_snwprintf(wBuf, TranslateT("Sending typing notifications is %s."),
mtnStatus ? TranslateT("enabled") : TranslateT("disabled"));
diff --git a/plugins/TabSRMM/src/generic_msghandlers.cpp b/plugins/TabSRMM/src/generic_msghandlers.cpp
index a856dbfcad..b34ab7f6e6 100644
--- a/plugins/TabSRMM/src/generic_msghandlers.cpp
+++ b/plugins/TabSRMM/src/generic_msghandlers.cpp
@@ -474,7 +474,7 @@ LRESULT CMsgDialog::DM_MsgWindowCmdHandler(UINT cmd, WPARAM wParam, LPARAM lPara
break;
case IDC_SELFTYPING:
- if (m_si == nullptr || m_si->iType == GCW_PRIVMESS) {
+ if (AllowTyping()) {
int iCurrentTypingMode = g_plugin.getByte(m_hContact, SRMSGSET_TYPING, g_plugin.getByte(SRMSGSET_TYPINGNEW, SRMSGDEFSET_TYPINGNEW));
if (m_nTypeMode == PROTOTYPE_SELFTYPING_ON && iCurrentTypingMode) {
DM_NotifyTyping(PROTOTYPE_SELFTYPING_OFF);
@@ -822,27 +822,33 @@ void CMsgDialog::DM_NotifyTyping(int mode)
if (!(typeCaps & PF4_SUPPORTTYPING))
return;
- DWORD protoStatus = Proto_GetStatus(szProto);
- if (protoStatus < ID_STATUS_ONLINE)
- return;
+ if (isChat()) {
+ m_nTypeMode = mode;
+ Chat_DoEventHook(m_si, GC_USER_TYPNOTIFY, 0, 0, m_nTypeMode);
+ }
+ else {
+ DWORD protoStatus = Proto_GetStatus(szProto);
+ if (protoStatus < ID_STATUS_ONLINE)
+ return;
- // check visibility/invisibility lists to not "accidentially" send MTN to contacts who
- // should not see them (privacy issue)
- DWORD protoCaps = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0);
- if (protoCaps & PF1_VISLIST && db_get_w(hContact, szProto, "ApparentMode", 0) == ID_STATUS_OFFLINE)
- return;
+ // check visibility/invisibility lists to not "accidentially" send MTN to contacts who
+ // should not see them (privacy issue)
+ DWORD protoCaps = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0);
+ if (protoCaps & PF1_VISLIST && db_get_w(hContact, szProto, "ApparentMode", 0) == ID_STATUS_OFFLINE)
+ return;
- if (protoCaps & PF1_INVISLIST && protoStatus == ID_STATUS_INVISIBLE && db_get_w(hContact, szProto, "ApparentMode", 0) != ID_STATUS_ONLINE)
- return;
+ if (protoCaps & PF1_INVISLIST && protoStatus == ID_STATUS_INVISIBLE && db_get_w(hContact, szProto, "ApparentMode", 0) != ID_STATUS_ONLINE)
+ return;
- // don't send to contacts which are not permanently added to the contact list,
- // unless the option to ignore added status is set.
- if (!Contact_OnList(m_hContact) && !g_plugin.getByte(SRMSGSET_TYPINGUNKNOWN, SRMSGDEFSET_TYPINGUNKNOWN))
- return;
+ // don't send to contacts which are not permanently added to the contact list,
+ // unless the option to ignore added status is set.
+ if (!Contact_OnList(m_hContact) && !g_plugin.getByte(SRMSGSET_TYPINGUNKNOWN, SRMSGDEFSET_TYPINGUNKNOWN))
+ return;
- // End user check
- m_nTypeMode = mode;
- CallService(MS_PROTO_SELFISTYPING, hContact, m_nTypeMode);
+ // End user check
+ m_nTypeMode = mode;
+ CallService(MS_PROTO_SELFISTYPING, hContact, m_nTypeMode);
+ }
}
void CMsgDialog::DM_OptionsApplied(bool bRemakeLog)
@@ -905,7 +911,9 @@ void CMsgDialog::DM_Typing(bool fForceOff)
m_bShowTyping = 2;
m_nTypeSecs = 86400;
- mir_snwprintf(m_wszStatusBar, TranslateT("%s has entered text."), m_cache->getNick());
+ if (!isChat())
+ mir_snwprintf(m_wszStatusBar, TranslateT("%s has entered text."), m_cache->getNick());
+
if (hwndStatus && m_pContainer->m_hwndActive == m_hwnd)
SendMessage(hwndStatus, SB_SETTEXT, 0, (LPARAM)m_wszStatusBar);
}
@@ -930,7 +938,8 @@ void CMsgDialog::DM_Typing(bool fForceOff)
tabUpdateStatusBar();
}
else if (m_nTypeSecs > 0) {
- mir_snwprintf(m_wszStatusBar, TranslateT("%s is typing a message"), m_cache->getNick());
+ mir_snwprintf(m_wszStatusBar, TranslateT("%s is typing a message"),
+ (m_pUserTyping) ? m_pUserTyping->pszNick : m_cache->getNick());
m_nTypeSecs--;
if (hwndStatus && m_pContainer->m_hwndActive == m_hwnd) {
@@ -1221,7 +1230,7 @@ void CMsgDialog::DrawStatusIcons(HDC hDC, const RECT &rc, int gap)
PluginConfig.m_smcxicon, PluginConfig.m_smcyicon, 0, nullptr, DI_NORMAL);
}
else if (sid->dwId == MSG_ICON_UTN) {
- if (!isChat() || m_si->iType == GCW_PRIVMESS) {
+ if (AllowTyping()) {
DrawIconEx(hDC, x, y, PluginConfig.g_buttonBarIcons[ICON_DEFAULT_TYPING], PluginConfig.m_smcxicon, PluginConfig.m_smcyicon, 0, nullptr, DI_NORMAL);
DrawIconEx(hDC, x, y, g_plugin.getByte(m_hContact, SRMSGSET_TYPING, g_plugin.getByte(SRMSGSET_TYPINGNEW, SRMSGDEFSET_TYPINGNEW)) ?
@@ -1275,7 +1284,7 @@ void CMsgDialog::CheckStatusIconClick(POINT pt, const RECT &rc, int gap, int cod
InvalidateRect(m_pContainer->m_hwndStatus, nullptr, TRUE);
}
}
- else if (sid->dwId == MSG_ICON_UTN && code != NM_RCLICK && (!isChat() || m_si->iType == GCW_PRIVMESS)) {
+ else if (sid->dwId == MSG_ICON_UTN && code != NM_RCLICK && AllowTyping()) {
SendMessage(m_pContainer->m_hwndActive, WM_COMMAND, IDC_SELFTYPING, 0);
InvalidateRect(m_pContainer->m_hwndStatus, nullptr, TRUE);
}
diff --git a/plugins/TabSRMM/src/globals.cpp b/plugins/TabSRMM/src/globals.cpp
index 7a3ce34dc9..e9b8777437 100644
--- a/plugins/TabSRMM/src/globals.cpp
+++ b/plugins/TabSRMM/src/globals.cpp
@@ -365,12 +365,9 @@ int CGlobals::DBSettingChanged(WPARAM hContact, LPARAM lParam)
PostMessage(hwnd, DM_UPDATESTATUSMSG, 0, 0);
if (fChanged) {
- if (dat && c->getStatus() == ID_STATUS_OFFLINE) { // clear typing notification in the status bar when contact goes offline
- dat->m_nTypeSecs = 0;
- dat->m_bShowTyping = 0;
- dat->m_wszStatusBar[0] = 0;
- PostMessage(dat->GetHwnd(), DM_UPDATELASTMESSAGE, 0, 0);
- }
+ if (dat && c->getStatus() == ID_STATUS_OFFLINE) // clear typing notification in the status bar when contact goes offline
+ dat->ClearTyping();
+
PostMessage(PluginConfig.g_hwndHotkeyHandler, DM_LOGSTATUSCHANGE, MAKELONG(c->getStatus(), c->getOldStatus()), (LPARAM)c);
}
}
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp
index c872c9c44a..a2100c9fcb 100644
--- a/plugins/TabSRMM/src/msgdialog.cpp
+++ b/plugins/TabSRMM/src/msgdialog.cpp
@@ -478,7 +478,7 @@ bool CMsgDialog::OnInitDialog()
GetMyNick();
m_iMultiSplit = g_plugin.getDword("multisplit", 150);
- if (m_si == nullptr || m_si->iType == GCW_PRIVMESS) {
+ if (AllowTyping()) {
m_nTypeMode = PROTOTYPE_SELFTYPING_OFF;
timerType.Start(1000);
}
@@ -718,7 +718,7 @@ void CMsgDialog::OnDestroy()
else SendMessage(m_hwnd, WM_COMMAND, IDC_PIC, 0);
}
- if (m_si == nullptr || m_si->iType == GCW_PRIVMESS)
+ if (AllowTyping())
if (m_nTypeMode == PROTOTYPE_SELFTYPING_ON)
DM_NotifyTyping(PROTOTYPE_SELFTYPING_OFF);
@@ -817,7 +817,7 @@ void CMsgDialog::onClick_Ok(CCtrlButton *)
Utils::enableDlgControl(m_hwnd, IDOK, false);
// Typing support for GCW_PRIVMESS sessions
- if (m_si->iType == GCW_PRIVMESS)
+ if (AllowTyping())
if (m_nTypeMode == PROTOTYPE_SELFTYPING_ON)
DM_NotifyTyping(PROTOTYPE_SELFTYPING_OFF);
@@ -1069,7 +1069,7 @@ void CMsgDialog::onChange_Message(CCtrlEdit*)
m_btnOk.Enable(m_message.GetRichTextLength() != 0);
// Typing support for GCW_PRIVMESS sessions
- if (m_si == nullptr || m_si->iType == GCW_PRIVMESS) {
+ if (AllowTyping()) {
if (!(GetKeyState(VK_CONTROL) & 0x8000)) {
m_nLastTyping = GetTickCount();
if (GetWindowTextLength(m_message.GetHwnd())) {
@@ -1086,7 +1086,7 @@ void CMsgDialog::onChange_Message(CCtrlEdit*)
void CMsgDialog::onType(CTimer *)
{
- if (m_si == nullptr || m_si->iType == GCW_PRIVMESS)
+ if (AllowTyping())
DM_Typing(false);
}
diff --git a/plugins/TabSRMM/src/msgdlgother.cpp b/plugins/TabSRMM/src/msgdlgother.cpp
index 3be7d4eb8b..36012b25f3 100644
--- a/plugins/TabSRMM/src/msgdlgother.cpp
+++ b/plugins/TabSRMM/src/msgdlgother.cpp
@@ -2009,12 +2009,12 @@ void CMsgDialog::tabUpdateStatusBar() const
int CMsgDialog::Typing(int secs)
{
- if (m_si != nullptr && m_si->iType != GCW_PRIVMESS)
+ if (!AllowTyping())
return 0;
int preTyping = m_nTypeSecs != 0;
- m_nTypeSecs = (secs > 0) ? secs : 0;
+ setTyping(m_nTypeSecs = (secs > 0) ? secs : 0);
if (m_nTypeSecs)
m_bShowTyping = 0;
diff --git a/plugins/TabSRMM/src/msglog.cpp b/plugins/TabSRMM/src/msglog.cpp
index 18e33c596e..db83a7d661 100644
--- a/plugins/TabSRMM/src/msglog.cpp
+++ b/plugins/TabSRMM/src/msglog.cpp
@@ -1322,7 +1322,7 @@ void CLogWindow::LogEvents(LOGINFO *lin, bool bRedraw)
if (m_rtf.GetHwnd() == nullptr || lin == nullptr || si == nullptr)
return;
- if (!bRedraw && (si->iType == GCW_CHATROOM || si->iType == GCW_PRIVMESS) && m_pDlg.m_bFilterEnabled && (m_pDlg.m_iLogFilterFlags & lin->iType) == 0)
+ if (!bRedraw && m_pDlg.AllowTyping() && m_pDlg.m_bFilterEnabled && (m_pDlg.m_iLogFilterFlags & lin->iType) == 0)
return;
bool bFlag = false, bDoReplace, bAtBottom = AtBottom();
diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h
index 9e262e132d..78fb6bfda9 100644
--- a/plugins/TabSRMM/src/msgs.h
+++ b/plugins/TabSRMM/src/msgs.h
@@ -58,6 +58,74 @@
#define MWF_LOG_INOUTICONS 0x10000000
#define MWF_LOG_GROUPMODE 0x80000000
+ /*
+ * custom dialog window messages
+ */
+
+#define TM_USER (WM_USER+300)
+
+#define EM_SEARCHSCROLLER (TM_USER+0x103)
+#define EM_VALIDATEBOTTOM (TM_USER+0x104)
+#define EM_THEMECHANGED (TM_USER+0x105)
+#define EM_REFRESHWITHOUTCLIP (TM_USER+0x106)
+
+#define HM_EVENTSENT (TM_USER+10)
+#define HM_DBEVENTADDED (TM_USER+12)
+#define DM_SETINFOPANEL (TM_USER+13)
+#define DM_OPTIONSAPPLIED (TM_USER+14)
+#define DM_SPLITSENDACK (TM_USER+19)
+#define DM_UPDATEWINICON (TM_USER+21)
+#define DM_UPDATELASTMESSAGE (TM_USER+22)
+
+#define DM_STATUSICONCHANGE (TM_USER+25)
+#define DM_CREATECONTAINER (TM_USER+26)
+#define DM_QUERYLASTUNREAD (TM_USER+28)
+#define DM_UPDATEPICLAYOUT (TM_USER+30)
+#define DM_APPENDMCEVENT (TM_USER+34)
+#define DM_CHECKINFOTIP (TM_USER+35)
+#define DM_SAVESIZE (TM_USER+36)
+#define DM_CHECKSIZE (TM_USER+37)
+#define DM_FORCEREDRAW (TM_USER+38)
+#define DM_QUERYHCONTACT (TM_USER+41)
+#define DM_STATUSMASKSET (TM_USER+51)
+#define DM_UPDATESTATUSMSG (TM_USER+53)
+#define DM_OWNNICKCHANGED (TM_USER+55)
+#define DM_CONFIGURETOOLBAR (TM_USER+56)
+#define DM_FORCEDREMAKELOG (TM_USER+62)
+#define DM_STATUSBARCHANGED (TM_USER+64)
+#define DM_CHECKQUEUEFORCLOSE (TM_USER+70)
+#define DM_CHECKAUTOHIDE (TM_USER+71)
+#define DM_HANDLECLISTEVENT (TM_USER+73)
+#define DM_REMOVECLISTEVENT (TM_USER+75)
+#define DM_DOCREATETAB (TM_USER+77)
+#define DM_SMILEYOPTIONSCHANGED (TM_USER+85)
+#define DM_MYAVATARCHANGED (TM_USER+86)
+#define DM_IEVIEWOPTIONSCHANGED (TM_USER+88)
+#define DM_SPLITTERGLOBALEVENT (TM_USER+89)
+#define DM_CLIENTCHANGED (TM_USER+91)
+#define DM_SENDMESSAGECOMMANDW (TM_USER+93)
+#define DM_LOGSTATUSCHANGE (TM_USER+98)
+#define DM_SC_BUILDLIST (TM_USER+100)
+#define DM_SC_INITDIALOG (TM_USER+101)
+#define DM_SC_CONFIG (TM_USER+104)
+#define DM_UPDATEUIN (TM_USER+103)
+
+#define MINSPLITTERX 60
+#define MINSPLITTERY 42
+#define MINLOGHEIGHT 30
+#define ERRORPANEL_HEIGHT 51
+
+// wParam values for DM_SELECTTAB
+
+#define DM_SELECT_NEXT 1
+#define DM_SELECT_PREV 2
+
+#define DM_SELECT_BY_HWND 3 // lParam specifies hwnd
+#define DM_SELECT_BY_INDEX 4 // lParam specifies tab index
+
+#define DM_QUERY_NEXT 1
+#define DM_QUERY_MOSTRECENT 2
+
#define SMODE_DEFAULT 0
#define SMODE_MULTIPLE 1
#define SMODE_CONTAINER 2
@@ -420,8 +488,6 @@ class CMsgDialog : public CSrmmBaseDialog
RECT m_rcNick, m_rcUIN, m_rcStatus, m_rcPic;
int m_originalSplitterY;
SIZE m_minEditBoxSize;
- int m_nTypeMode;
- DWORD m_nLastTyping;
DWORD m_lastMessage;
DWORD m_dwTickLastEvent;
HBITMAP m_hOwnPic;
@@ -468,7 +534,7 @@ public:
char *m_szProto;
int m_iTabID;
int m_iLogMode;
- BYTE m_bShowTyping;
+
bool m_bIsHistory, m_bNotOnList, m_bIsIdle;
bool m_bActualHistory;
bool m_bIsAutosizingInput;
@@ -495,7 +561,6 @@ public:
MEVENT *m_hHistoryEvents;
time_t m_lastEventTime;
int m_iLastEventType;
- int m_nTypeSecs;
int m_iOpenJobs;
int m_iInputAreaHeight = -1;
int m_maxHistory, m_curHistory;
@@ -589,6 +654,13 @@ public:
m_pContainer->ActivateExistingTab(this);
}
+ __forceinline void ClearTyping() {
+ m_nTypeSecs = 0;
+ m_bShowTyping = 0;
+ m_wszStatusBar[0] = 0;
+ PostMessage(m_hwnd, DM_UPDATELASTMESSAGE, 0, 0);
+ }
+
__forceinline CLogWindow* LOG() {
return ((CLogWindow *)m_pLog);
}
@@ -704,74 +776,6 @@ struct TIconDescW
#define MWF_LOG_DEFAULT (MWF_LOG_GROUPMODE | MWF_LOG_SHOWTIME | MWF_LOG_NORMALTEMPLATES | MWF_LOG_SHOWDATES | MWF_LOG_SYMBOLS | MWF_LOG_GRID | MWF_LOG_INOUTICONS)
-/*
- * custom dialog window messages
- */
-
-#define TM_USER (WM_USER+300)
-
-#define EM_SEARCHSCROLLER (TM_USER+0x103)
-#define EM_VALIDATEBOTTOM (TM_USER+0x104)
-#define EM_THEMECHANGED (TM_USER+0x105)
-#define EM_REFRESHWITHOUTCLIP (TM_USER+0x106)
-
-#define HM_EVENTSENT (TM_USER+10)
-#define HM_DBEVENTADDED (TM_USER+12)
-#define DM_SETINFOPANEL (TM_USER+13)
-#define DM_OPTIONSAPPLIED (TM_USER+14)
-#define DM_SPLITSENDACK (TM_USER+19)
-#define DM_UPDATEWINICON (TM_USER+21)
-#define DM_UPDATELASTMESSAGE (TM_USER+22)
-
-#define DM_STATUSICONCHANGE (TM_USER+25)
-#define DM_CREATECONTAINER (TM_USER+26)
-#define DM_QUERYLASTUNREAD (TM_USER+28)
-#define DM_UPDATEPICLAYOUT (TM_USER+30)
-#define DM_APPENDMCEVENT (TM_USER+34)
-#define DM_CHECKINFOTIP (TM_USER+35)
-#define DM_SAVESIZE (TM_USER+36)
-#define DM_CHECKSIZE (TM_USER+37)
-#define DM_FORCEREDRAW (TM_USER+38)
-#define DM_QUERYHCONTACT (TM_USER+41)
-#define DM_STATUSMASKSET (TM_USER+51)
-#define DM_UPDATESTATUSMSG (TM_USER+53)
-#define DM_OWNNICKCHANGED (TM_USER+55)
-#define DM_CONFIGURETOOLBAR (TM_USER+56)
-#define DM_FORCEDREMAKELOG (TM_USER+62)
-#define DM_STATUSBARCHANGED (TM_USER+64)
-#define DM_CHECKQUEUEFORCLOSE (TM_USER+70)
-#define DM_CHECKAUTOHIDE (TM_USER+71)
-#define DM_HANDLECLISTEVENT (TM_USER+73)
-#define DM_REMOVECLISTEVENT (TM_USER+75)
-#define DM_DOCREATETAB (TM_USER+77)
-#define DM_SMILEYOPTIONSCHANGED (TM_USER+85)
-#define DM_MYAVATARCHANGED (TM_USER+86)
-#define DM_IEVIEWOPTIONSCHANGED (TM_USER+88)
-#define DM_SPLITTERGLOBALEVENT (TM_USER+89)
-#define DM_CLIENTCHANGED (TM_USER+91)
-#define DM_SENDMESSAGECOMMANDW (TM_USER+93)
-#define DM_LOGSTATUSCHANGE (TM_USER+98)
-#define DM_SC_BUILDLIST (TM_USER+100)
-#define DM_SC_INITDIALOG (TM_USER+101)
-#define DM_SC_CONFIG (TM_USER+104)
-#define DM_UPDATEUIN (TM_USER+103)
-
-#define MINSPLITTERX 60
-#define MINSPLITTERY 42
-#define MINLOGHEIGHT 30
-#define ERRORPANEL_HEIGHT 51
-
-// wParam values for DM_SELECTTAB
-
-#define DM_SELECT_NEXT 1
-#define DM_SELECT_PREV 2
-
-#define DM_SELECT_BY_HWND 3 // lParam specifies hwnd
-#define DM_SELECT_BY_INDEX 4 // lParam specifies tab index
-
-#define DM_QUERY_NEXT 1
-#define DM_QUERY_MOSTRECENT 2
-
// implement a callback for the rich edit. Without it, no bitmaps
// can be added to the richedit control.
// this class has to implement the GetNewStorage() method