From 02bb82c1c0a4031e7b2f5578370fa5acd620f8e1 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 11 Sep 2024 19:52:52 +0300 Subject: =?UTF-8?q?fixes=20#4653=20(=D0=9F=D0=BB=D0=B0=D0=B3=D0=B8=D0=BD?= =?UTF-8?q?=D1=8B=20=D1=81=D0=BE=D0=BE=D0=B1=D1=89=D0=B5=D0=BD=D0=B8=D0=B9?= =?UTF-8?q?:=20=D0=BD=D0=B5=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD?= =?UTF-8?q?=D0=BE=20=D1=83=D0=B4=D0=B0=D0=BB=D0=B8=D1=82=D1=8C=20=D0=B8?= =?UTF-8?q?=D0=BC=D1=8F=20=D0=B3=D1=80=D1=83=D0=BF=D0=BF=D1=8B=20=D1=87?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D0=B2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/m_chat.h | 2 +- include/m_chat_int.h | 1 + libs/win32/mir_app.lib | Bin 298356 -> 298748 bytes libs/win64/mir_app.lib | Bin 298382 -> 298770 bytes plugins/Scriver/res/resource.rc | 2 +- plugins/Scriver/src/chat_options.cpp | 18 +++++++++----- plugins/Scriver/src/resource.h | 1 + plugins/TabSRMM/res/chat.rc | 2 +- plugins/TabSRMM/src/chat_options.cpp | 12 +++++++++- plugins/TabSRMM/src/resource.h | 1 + protocols/Discord/src/guilds.cpp | 2 +- protocols/Telegram/src/server.cpp | 2 +- src/core/stdmsg/res/resource.rc | 44 +++++++++++------------------------ src/core/stdmsg/src/chat_options.cpp | 30 +++++++++++++++++------- src/core/stdmsg/src/resource.h | 1 + src/mir_app/src/chat_clist.cpp | 28 ++++++++++++---------- src/mir_app/src/chat_svc.cpp | 2 ++ src/mir_app/src/chat_tools.cpp | 4 ++-- 18 files changed, 88 insertions(+), 64 deletions(-) diff --git a/include/m_chat.h b/include/m_chat.h index 49c3a41dfa..9ce9a83f4e 100644 --- a/include/m_chat.h +++ b/include/m_chat.h @@ -395,7 +395,7 @@ MIR_APP_DLL(int) Chat_SendUserMessage(const char *szModule, const wchar_t *wszTe MIR_APP_DLL(int) Chat_SendUserMessage(SESSION_INFO *si, const wchar_t *wszText); MIR_APP_DLL(int) Chat_SetStatusbarText(SESSION_INFO *si, const wchar_t *wszText); -MIR_APP_DLL(wchar_t*) Chat_GetGroup(void); +MIR_APP_DLL(CMStringW) Chat_GetGroup(void); MIR_APP_DLL(void) Chat_SetGroup(const wchar_t*); MIR_APP_DLL(wchar_t*) Chat_UnescapeTags(wchar_t *str_in); diff --git a/include/m_chat_int.h b/include/m_chat_int.h index bd9f340d41..f8fc7ce950 100644 --- a/include/m_chat_int.h +++ b/include/m_chat_int.h @@ -396,6 +396,7 @@ namespace Chat bFilterEnabled, bTopicOnClist, bPopupOnJoin, + bUseGroup, bDoubleClick4Privat, bShowContactStatus, bContactStatusFirst, diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib index 0345088c10..bb7eeee9c7 100644 Binary files a/libs/win32/mir_app.lib and b/libs/win32/mir_app.lib differ diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib index 5757c6d60b..9573a660d4 100644 Binary files a/libs/win64/mir_app.lib and b/libs/win64/mir_app.lib differ diff --git a/plugins/Scriver/res/resource.rc b/plugins/Scriver/res/resource.rc index fa5c9b1fd7..aba7df9289 100644 --- a/plugins/Scriver/res/resource.rc +++ b/plugins/Scriver/res/resource.rc @@ -269,7 +269,7 @@ BEGIN GROUPBOX "Options",IDC_STATIC,0,0,304,184 CONTROL "Tree1",IDC_CHAT_CHECKBOXES,"SysTreeView32",TVS_DISABLEDRAGDROP | WS_BORDER | WS_TABSTOP,8,12,288,164 GROUPBOX "Other",IDC_STATIC,0,184,304,47 - LTEXT "Add new rooms to group:",IDC_STATIC,8,198,132,8 + CONTROL "Add new rooms to group:",IDC_CHAT_USEGROUP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,198,132,8 EDITTEXT IDC_CHAT_GROUP,153,195,49,12,ES_AUTOHSCROLL LTEXT "Nick list row height",IDC_STATIC,8,213,138,8 EDITTEXT IDC_CHAT_NICKROW,153,211,29,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER diff --git a/plugins/Scriver/src/chat_options.cpp b/plugins/Scriver/src/chat_options.cpp index d1fb83a817..594c2a8e20 100644 --- a/plugins/Scriver/src/chat_options.cpp +++ b/plugins/Scriver/src/chat_options.cpp @@ -49,6 +49,7 @@ class CGeneralOptsDlg : public CChatOptionsBaseDlg CCtrlSpin spin2; CCtrlEdit m_group; + CCtrlCheck m_useGroup; CCtrlTreeOpts m_opts; public: @@ -56,8 +57,12 @@ public: CChatOptionsBaseDlg(IDD_OPTIONS1), m_opts(this, IDC_CHAT_CHECKBOXES), m_group(this, IDC_CHAT_GROUP), + m_useGroup(this, IDC_CHAT_USEGROUP), spin2(this, IDC_CHAT_SPIN2, 255, 10) { + CreateLink(m_useGroup, Chat::bUseGroup); + m_useGroup.OnChange = Callback(this, &CGeneralOptsDlg::onChange_UseGroup); + auto *pwszSection = TranslateT("Appearance and functionality of chat windows"); m_opts.AddOption(pwszSection, TranslateT("Flash when someone speaks"), Chat::bFlashWindow); m_opts.AddOption(pwszSection, TranslateT("Flash when a word is highlighted"), Chat::bFlashWindowHighlight); @@ -88,17 +93,13 @@ public: bool OnInitDialog() override { spin2.SetPosition(db_get_b(0, CHAT_MODULE, "NicklistRowDist", 12)); - m_group.SetText(ptrW(Chat_GetGroup())); + m_group.SetText(Chat_GetGroup()); return true; } bool OnApply() override { - ptrW wszGroup(m_group.GetText()); - if (mir_wstrlen(wszGroup) > 0) - Chat_SetGroup(wszGroup); - else - Chat_SetGroup(nullptr); + Chat_SetGroup(ptrW(m_group.GetText())); int iPos = spin2.GetPosition(); if (iPos > 0) @@ -109,6 +110,11 @@ public: db_set_dw(0, CHAT_MODULE, "IconFlags", g_Settings.dwIconFlags = m_dwFlags); return true; } + + void onChange_UseGroup(CCtrlCheck *) + { + m_group.Enable(m_useGroup.IsChecked()); + } }; ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/plugins/Scriver/src/resource.h b/plugins/Scriver/src/resource.h index 997cb99440..2f97993ce5 100644 --- a/plugins/Scriver/src/resource.h +++ b/plugins/Scriver/src/resource.h @@ -186,6 +186,7 @@ #define IDC_CHAT_LOGDIRECTORY 5048 #define IDC_CHAT_LIMIT 5050 #define IDC_CHAT_LOGTIMESTAMP 5051 +#define IDC_CHAT_USEGROUP 5052 #define IDC_CHAT_GROUP 5057 #define IDC_CHAT_HIGHLIGHT 5068 #define IDC_CHAT_TEXTO 5069 diff --git a/plugins/TabSRMM/res/chat.rc b/plugins/TabSRMM/res/chat.rc index 9d9e96f991..cae7e4d74b 100644 --- a/plugins/TabSRMM/res/chat.rc +++ b/plugins/TabSRMM/res/chat.rc @@ -92,7 +92,7 @@ BEGIN CONTROL "",IDC_CHECKBOXES,"SysTreeView32",TVS_DISABLEDRAGDROP | TVS_FULLROWSELECT | WS_BORDER | WS_HSCROLL | WS_TABSTOP,6,9,289,177 LTEXT "Text for autocomplete:",IDC_STATIC,10,210,177,10 EDITTEXT IDC_GROUP,191,192,102,14,ES_AUTOHSCROLL - LTEXT "Add new rooms to group:",IDC_STATIC,10,193,179,10 + CONTROL "Add new rooms to group:",IDC_CHAT_USEGROUP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,193,179,10 EDITTEXT IDC_AUTOCOMPLETE,191,208,102,14,ES_AUTOHSCROLL END diff --git a/plugins/TabSRMM/src/chat_options.cpp b/plugins/TabSRMM/src/chat_options.cpp index bc19086e3e..df55931612 100644 --- a/plugins/TabSRMM/src/chat_options.cpp +++ b/plugins/TabSRMM/src/chat_options.cpp @@ -488,14 +488,19 @@ class CChatSettingsDlg : public CChatBaseOptionDlg CCtrlTreeOpts treeCheck; CCtrlEdit edtGroup, edtAutocomplete; + CCtrlCheck chkUseGroup; public: CChatSettingsDlg() : CChatBaseOptionDlg(IDD_OPTIONS1), + chkUseGroup(this, IDC_CHAT_USEGROUP), edtGroup(this, IDC_GROUP), edtAutocomplete(this, IDC_AUTOCOMPLETE), treeCheck(this, IDC_CHECKBOXES) { + CreateLink(chkUseGroup, Chat::bUseGroup); + chkUseGroup.OnChange = Callback(this, &CChatSettingsDlg::onChange_UseGroup); + auto *pwszSection = LPGENW("Appearance and functionality of chat room windows"); treeCheck.AddOption(pwszSection, LPGENW("Open new chat rooms in the default container"), g_plugin.bOpenInDefault); treeCheck.AddOption(pwszSection, LPGENW("Flash window when someone speaks"), Chat::bFlashWindow); @@ -534,7 +539,7 @@ public: if (mir_wstrlen(g_Settings.pwszAutoText)) edtAutocomplete.SetText(g_Settings.pwszAutoText); - edtGroup.SetText(ptrW(Chat_GetGroup())); + edtGroup.SetText(Chat_GetGroup()); return true; } @@ -555,6 +560,11 @@ public: b = treeCheck.GetItemState(hListHeading2, TVIS_EXPANDED) & TVIS_EXPANDED ? 1 : 0; db_set_b(0, CHAT_MODULE, "Branch2Exp", b); } + + void onChange_UseGroup(CCtrlCheck *) + { + edtGroup.Enable(chkUseGroup.IsChecked()); + } }; ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/plugins/TabSRMM/src/resource.h b/plugins/TabSRMM/src/resource.h index 6482a1bb08..b9eb8f84a4 100644 --- a/plugins/TabSRMM/src/resource.h +++ b/plugins/TabSRMM/src/resource.h @@ -101,6 +101,7 @@ #define IDC_LOGLIMIT 1024 #define IDC_CLOSE 1025 #define IDC_CHKACTR_DISMISS 1026 +#define IDC_CHAT_USEGROUP 1027 #define IDC_CHKACTR_OPEN 1028 #define IDC_CONTACTPIC 1029 #define IDC_CHAT_SPIN2 1029 diff --git a/protocols/Discord/src/guilds.cpp b/protocols/Discord/src/guilds.cpp index 59bcdb0649..19210b4cbc 100644 --- a/protocols/Discord/src/guilds.cpp +++ b/protocols/Discord/src/guilds.cpp @@ -58,7 +58,7 @@ static void sttSetGroupName(MCONTACT hContact, const wchar_t *pwszGroupName) { ptrW wszOldName(Clist_GetGroup(hContact)); if (wszOldName != nullptr) { - ptrW wszChatGroup(Chat_GetGroup()); + CMStringW wszChatGroup(Chat_GetGroup()); if (mir_wstrcmpi(wszOldName, wszChatGroup)) return; // custom group, don't touch it } diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp index f1bf7abb25..b8450f98c1 100644 --- a/protocols/Telegram/src/server.cpp +++ b/protocols/Telegram/src/server.cpp @@ -723,7 +723,7 @@ void CTelegramProto::ProcessChatPosition(TD::updateChatPosition *pObj) wchar_t *pwszDefaultGroup = m_wszDefaultGroup; if (!pwszExistingGroup || pUser->isForum || !mir_wstrncmp(pwszExistingGroup, pwszDefaultGroup, mir_wstrlen(pwszDefaultGroup)) - || (pUser->isGroupChat && !mir_wstrcmp(pwszExistingGroup, ptrW(Chat_GetGroup())))) + || (pUser->isGroupChat && !mir_wstrcmp(pwszExistingGroup, Chat_GetGroup()))) { CMStringW wszNewGroup(pwszDefaultGroup); if (!wszGroup.IsEmpty()) diff --git a/src/core/stdmsg/res/resource.rc b/src/core/stdmsg/res/resource.rc index 52d4c4731e..fc41cbb773 100644 --- a/src/core/stdmsg/res/resource.rc +++ b/src/core/stdmsg/res/resource.rc @@ -88,8 +88,8 @@ BEGIN CONTROL "",IDC_SPLITTERY,"Static",SS_ENHMETAFILE,0,108,251,1 LISTBOX IDC_SRMM_NICKLIST,182,2,69,94,LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | NOT WS_BORDER | WS_VSCROLL | WS_TABSTOP,WS_EX_STATICEDGE CONTROL "",IDC_AVATAR,"Button",BS_OWNERDRAW | NOT WS_VISIBLE,1,127,6,13 - CONTROL "",IDC_SRMM_QUOTE,"RichEdit50W",ES_AUTOHSCROLL | WS_DISABLED | WS_BORDER | WS_TABSTOP,0,95,235,16 - CONTROL "",IDC_SRMM_CLOSEQUOTE,"MButtonClass", WS_TABSTOP,237,97,16,16 + CONTROL "",IDC_SRMM_QUOTE,"RichEdit50W",WS_DISABLED | WS_BORDER | WS_TABSTOP | 0x80,0,95,235,16 + CONTROL "",IDC_SRMM_CLOSEQUOTE,"MButtonClass",WS_TABSTOP,237,97,16,16 END IDD_OPT_MSGHIST DIALOGEX 0, 0, 311, 171 @@ -192,8 +192,10 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD EXSTYLE WS_EX_CONTROLPARENT FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN - CONTROL "",IDC_CHECKBOXES,"SysTreeView32",TVS_DISABLEDRAGDROP | WS_HSCROLL | WS_TABSTOP,10,12,280,205 - GROUPBOX "Options",IDC_STATIC,0,0,300,227 + CONTROL "",IDC_CHECKBOXES,"SysTreeView32",TVS_DISABLEDRAGDROP | WS_HSCROLL | WS_TABSTOP,6,11,287,188 + GROUPBOX "Options",IDC_STATIC,0,0,300,206 + CONTROL "Add new rooms to group:",IDC_CHAT_USEGROUP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,213,186,8 + EDITTEXT IDC_GROUP,202,211,93,12,ES_AUTOHSCROLL END IDD_OPTIONS2 DIALOGEX 0, 0, 300, 200 @@ -225,11 +227,9 @@ BEGIN EDITTEXT IDC_LIMIT,248,114,38,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER CONTROL "Spin1",IDC_SPIN3,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,275,114,11,14 GROUPBOX "Other",IDC_STATIC,1,145,294,53 - LTEXT "Add new rooms to group:",IDC_STATIC,11,159,132,8 - EDITTEXT IDC_GROUP,158,158,49,14,ES_AUTOHSCROLL - LTEXT "Nick list row distance (pixels):",IDC_STATIC,11,180,140,8 - EDITTEXT IDC_NICKROW2,158,178,29,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER - CONTROL "",IDC_SPIN4,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,183,178,11,14 + LTEXT "Nick list row distance (pixels):",IDC_STATIC,11,158,140,8 + EDITTEXT IDC_NICKROW2,158,156,29,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER + CONTROL "",IDC_SPIN4,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,183,156,11,14 END @@ -297,35 +297,14 @@ BEGIN IDD_OPTIONS1, DIALOG BEGIN - VERTGUIDE, 10 - VERTGUIDE, 153 - VERTGUIDE, 181 - VERTGUIDE, 202 - VERTGUIDE, 290 - HORZGUIDE, 12 - HORZGUIDE, 174 - HORZGUIDE, 192 - HORZGUIDE, 213 END IDD_OPTIONS2, DIALOG BEGIN LEFTMARGIN, 1 RIGHTMARGIN, 295 - VERTGUIDE, 10 - VERTGUIDE, 60 - VERTGUIDE, 144 - VERTGUIDE, 158 - VERTGUIDE, 183 - VERTGUIDE, 221 - VERTGUIDE, 286 TOPMARGIN, 1 BOTTOMMARGIN, 198 - HORZGUIDE, 108 - HORZGUIDE, 126 - HORZGUIDE, 146 - HORZGUIDE, 158 - HORZGUIDE, 174 END END #endif // APSTUDIO_INVOKED @@ -535,6 +514,11 @@ BEGIN 0 END +IDD_OPTIONS1 AFX_DIALOG_LAYOUT +BEGIN + 0 +END + #endif // English (United States) resources ///////////////////////////////////////////////////////////////////////////// diff --git a/src/core/stdmsg/src/chat_options.cpp b/src/core/stdmsg/src/chat_options.cpp index 2518807485..9755a3218c 100644 --- a/src/core/stdmsg/src/chat_options.cpp +++ b/src/core/stdmsg/src/chat_options.cpp @@ -91,13 +91,20 @@ class COptMainDlg : public CChatOptionsBaseDlg { uint32_t m_dwFlags; + CCtrlEdit edtGroup; + CCtrlCheck chkUseGroup; CCtrlTreeOpts checkBoxes; public: COptMainDlg() : CChatOptionsBaseDlg(IDD_OPTIONS1), - checkBoxes(this, IDC_CHECKBOXES) + edtGroup(this, IDC_GROUP), + checkBoxes(this, IDC_CHECKBOXES), + chkUseGroup(this, IDC_CHAT_USEGROUP) { + CreateLink(chkUseGroup, Chat::bUseGroup); + chkUseGroup.OnChange = Callback(this, &COptMainDlg::onChange_UseGroup); + m_dwFlags = db_get_dw(0, CHAT_MODULE, "IconFlags"); auto *pwszSection = TranslateT("Appearance and functionality of chat room windows"); @@ -135,11 +142,23 @@ public: checkBoxes.AddOption(pwszSection, TranslateT("Show icon for status changes"), m_dwFlags, GC_EVENT_ADDSTATUS); } + bool OnInitDialog() override + { + edtGroup.SetText(Chat_GetGroup()); + return true; + } + bool OnApply() override { + Chat_SetGroup(ptrW(rtrimw(edtGroup.GetText()))); db_set_dw(0, CHAT_MODULE, "IconFlags", m_dwFlags); return true; } + + void onChange_UseGroup(CCtrlCheck *) + { + edtGroup.Enable(chkUseGroup.IsChecked()); + } }; ///////////////////////////////////////////////////////////////////////////////////////// @@ -163,7 +182,7 @@ static INT CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM p class COptLogDlg : public CChatOptionsBaseDlg { - CCtrlEdit edtGroup, edtLogDir, edtLogTimestamp, edtTimestamp, edtHighlight, edtInStamp, edtOutStamp, edtLimit; + CCtrlEdit edtLogDir, edtLogTimestamp, edtTimestamp, edtHighlight, edtInStamp, edtOutStamp, edtLimit; CCtrlSpin spin2, spin3, spin4; CCtrlCheck chkLogging, chkHighlight; CCtrlButton btnFontChoose; @@ -175,7 +194,6 @@ public: spin3(this, IDC_SPIN3, 10000), spin4(this, IDC_SPIN4, 255, 10), - edtGroup(this, IDC_GROUP), edtLimit(this, IDC_LIMIT), edtLogDir(this, IDC_LOGDIRECTORY), edtInStamp(this, IDC_INSTAMP), @@ -186,7 +204,7 @@ public: chkLogging(this, IDC_LOGGING), chkHighlight(this, IDC_HIGHLIGHT), - + btnFontChoose(this, IDC_FONTCHOOSE) { chkLogging.OnChange = Callback(this, &COptLogDlg::onChange_Logging); @@ -201,8 +219,6 @@ public: spin3.SetPosition(db_get_w(0, CHAT_MODULE, "LoggingLimit", 100)); spin4.SetPosition(db_get_b(0, CHAT_MODULE, "NicklistRowDist", 12)); - edtGroup.SetText(ptrW(Chat_GetGroup())); - wchar_t szTemp[MAX_PATH]; PathToRelativeW(g_Settings.pszLogDir, szTemp); edtLogDir.SetText(szTemp); @@ -261,8 +277,6 @@ public: else db_unset(0, CHAT_MODULE, "HeaderOutgoing"); - Chat_SetGroup(ptrW(rtrimw(edtGroup.GetText()))); - g_Settings.bHighlightEnabled = chkHighlight.GetState(); db_set_b(0, CHAT_MODULE, "HighlightEnabled", g_Settings.bHighlightEnabled); diff --git a/src/core/stdmsg/src/resource.h b/src/core/stdmsg/src/resource.h index aaefd5ce20..dbdb870663 100644 --- a/src/core/stdmsg/src/resource.h +++ b/src/core/stdmsg/src/resource.h @@ -106,6 +106,7 @@ #define IDC_RADIO2 1068 #define IDC_RADIO3 1069 #define IDC_ADD 1070 +#define IDC_CHAT_USEGROUP 1071 #define IDC_TAB 1074 #define IDC_1 1075 #define IDC_2 1076 diff --git a/src/mir_app/src/chat_clist.cpp b/src/mir_app/src/chat_clist.cpp index 37e32e0d95..e01f1291ff 100644 --- a/src/mir_app/src/chat_clist.cpp +++ b/src/mir_app/src/chat_clist.cpp @@ -38,23 +38,16 @@ static MCONTACT FindRoom(const char *pszModule, const wchar_t *pszRoom) MCONTACT AddRoom(const char *pszModule, const wchar_t *pszRoom, const wchar_t *pszDisplayName, int iType) { - ptrW pwszGroup(Chat_GetGroup()); - if (mir_wstrlen(pwszGroup)) { - MGROUP hGroup = Clist_GroupExists(pwszGroup); - if (hGroup == 0) { - hGroup = Clist_GroupCreate(0, pwszGroup); - if (hGroup) - Clist_GroupSetExpanded(hGroup, 1); - } - } + auto wszGroup(Chat_GetGroup()); + bool bNeedGroup = Chat::bUseGroup && !wszGroup.IsEmpty(); MCONTACT hContact = FindRoom(pszModule, pszRoom); if (hContact) { // contact exists, let's assign the standard group name if it's missing - if (mir_wstrlen(pwszGroup)) { + if (bNeedGroup) { ptrW pwszOldGroup(Clist_GetGroup(hContact)); if (!mir_wstrlen(pwszOldGroup)) - Clist_SetGroup(hContact, pwszGroup); + Clist_SetGroup(hContact, wszGroup); } db_set_w(hContact, pszModule, "Status", ID_STATUS_OFFLINE); @@ -67,7 +60,18 @@ MCONTACT AddRoom(const char *pszModule, const wchar_t *pszRoom, const wchar_t *p return 0; Proto_AddToContact(hContact, pszModule); - Clist_SetGroup(hContact, pwszGroup); + + // create the 'Chat rooms' group only if needed + if (bNeedGroup) { + MGROUP hGroup = Clist_GroupExists(wszGroup); + if (hGroup == 0) { + hGroup = Clist_GroupCreate(0, wszGroup); + if (hGroup) + Clist_GroupSetExpanded(hGroup, 1); + } + + Clist_SetGroup(hContact, wszGroup); + } if (auto *pa = Proto_GetAccount(pszModule)) { if (MBaseProto *pd = g_arProtos.find((MBaseProto *)&pa->szProtoName)) { diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp index 368cdd51e0..2bf0745e90 100644 --- a/src/mir_app/src/chat_svc.cpp +++ b/src/mir_app/src/chat_svc.cpp @@ -26,6 +26,8 @@ CMOption Chat::bShowNicklist(CHAT_MODULE, "ShowNicklist", true); CMOption Chat::bFilterEnabled(CHAT_MODULE, "FilterEnabled", false); CMOption Chat::bTopicOnClist(CHAT_MODULE, "TopicOnClist", false); CMOption Chat::bPopupOnJoin(CHAT_MODULE, "PopupOnJoin", false); +CMOption Chat::bUseGroup(CHAT_MODULE, "UseGroup", true); + CMOption Chat::bDoubleClick4Privat(CHAT_MODULE, "DoubleClick4Privat", false); CMOption Chat::bShowContactStatus(CHAT_MODULE, "ShowContactStatus", true); CMOption Chat::bContactStatusFirst(CHAT_MODULE, "ContactStatusFirst", false); diff --git a/src/mir_app/src/chat_tools.cpp b/src/mir_app/src/chat_tools.cpp index b9d2016103..66e8acbc6b 100644 --- a/src/mir_app/src/chat_tools.cpp +++ b/src/mir_app/src/chat_tools.cpp @@ -757,9 +757,9 @@ void Chat_EventToGC(SESSION_INFO *si, MEVENT hDbEvent) ///////////////////////////////////////////////////////////////////////////////////////// -MIR_APP_DLL(wchar_t*) Chat_GetGroup() +MIR_APP_DLL(CMStringW) Chat_GetGroup() { - return db_get_wsa(0, CHAT_MODULE, "AddToGroup", TranslateT("Chat rooms")); + return db_get_wsm(0, CHAT_MODULE, "AddToGroup", TranslateT("Chat rooms")); } MIR_APP_DLL(void) Chat_SetGroup(const wchar_t *pwszGroupName) -- cgit v1.2.3