From f531ff887729783a7fe7a3e12ad12f658eefc7b0 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 4 Jun 2020 17:03:28 +0300 Subject: UI classes: - CDlgBase::m_bSucceeded variable introduced to check whether IDOK was pressed or not; - unused/useless buttons with id=IDOK or IDCANCEL removed; - brnOk.OnClick replaced with OnApply calls; - unused/useless calls of EndDialog/EndModal removed; - minor code cleaning --- protocols/SkypeWeb/src/skype_chatrooms.cpp | 29 ++++------------- protocols/SkypeWeb/src/skype_dialogs.cpp | 51 +++++++++++++++++++----------- protocols/SkypeWeb/src/skype_dialogs.h | 37 ++++++++-------------- protocols/SkypeWeb/src/skype_proto.h | 7 ++-- 4 files changed, 57 insertions(+), 67 deletions(-) (limited to 'protocols/SkypeWeb/src') diff --git a/protocols/SkypeWeb/src/skype_chatrooms.cpp b/protocols/SkypeWeb/src/skype_chatrooms.cpp index 6aeea2bab4..137d6b8475 100644 --- a/protocols/SkypeWeb/src/skype_chatrooms.cpp +++ b/protocols/SkypeWeb/src/skype_chatrooms.cpp @@ -117,20 +117,10 @@ int CSkypeProto::OnGroupChatEventHook(WPARAM, LPARAM lParam) case 10: { CSkypeInviteDlg dlg(this); - { - mir_cslock lck(m_InviteDialogsLock); - m_InviteDialogs.insert(&dlg); + if (dlg.DoModal()) { + if (dlg.m_hContact != NULL) + SendRequest(new InviteUserToChatRequest(chat_id, getId(dlg.m_hContact), "User")); } - - if (!dlg.DoModal()) - break; - - MCONTACT hContact = dlg.m_hContact; - if (hContact != NULL) - SendRequest(new InviteUserToChatRequest(chat_id, getId(hContact), "User")); - - mir_cslock lck(m_InviteDialogsLock); - m_InviteDialogs.remove(&dlg); } break; @@ -475,15 +465,10 @@ INT_PTR CSkypeProto::SvcCreateChat(WPARAM, LPARAM) { if (IsOnline()) { CSkypeGCCreateDlg dlg(this); - - { mir_cslock lck(m_GCCreateDialogsLock); m_GCCreateDialogs.insert(&dlg); } - - if (!dlg.DoModal()) { return 1; } - - SendRequest(new CreateChatroomRequest(dlg.m_ContactsList, this)); - - { mir_cslock lck(m_GCCreateDialogsLock); m_GCCreateDialogs.remove(&dlg); } - return 0; + if (dlg.DoModal()) { + SendRequest(new CreateChatroomRequest(dlg.m_ContactsList, this)); + return 0; + } } return 1; } diff --git a/protocols/SkypeWeb/src/skype_dialogs.cpp b/protocols/SkypeWeb/src/skype_dialogs.cpp index d0f3ba18a9..d64e20c81f 100644 --- a/protocols/SkypeWeb/src/skype_dialogs.cpp +++ b/protocols/SkypeWeb/src/skype_dialogs.cpp @@ -19,43 +19,51 @@ along with this program. If not, see . void CSkypeProto::CloseDialogs() { - { mir_cslock lck(m_GCCreateDialogsLock); - for (auto &it : m_GCCreateDialogs) - it->Close(); - } + for (auto &it : m_GCCreateDialogs) + it->Close(); - { mir_cslock lck(m_InviteDialogsLock); - for (auto &it : m_InviteDialogs) - it->Close(); - } + for (auto &it : m_InviteDialogs) + it->Close(); } -//CSkypeInvideDlg +///////////////////////////////////////////////////////////////////////////////////////// +// CSkypeInvideDlg + CSkypeInviteDlg::CSkypeInviteDlg(CSkypeProto *proto) : - CSkypeDlgBase(proto, IDD_GC_INVITE), m_ok(this, IDOK), m_cancel(this, IDCANCEL), m_combo(this, IDC_CONTACT), m_hContact(NULL) + CSkypeDlgBase(proto, IDD_GC_INVITE), + m_combo(this, IDC_CONTACT) { - m_ok.OnClick = Callback(this, &CSkypeInviteDlg::btnOk_OnOk); } bool CSkypeInviteDlg::OnInitDialog() { + m_proto->m_InviteDialogs.insert(this); + for (auto &hContact : m_proto->AccContacts()) if (!m_proto->isChatRoom(hContact)) m_combo.AddString(Clist_GetContactDisplayName(hContact), hContact); return true; } -void CSkypeInviteDlg::btnOk_OnOk(CCtrlButton*) +bool CSkypeInviteDlg::OnApply() { m_hContact = m_combo.GetItemData(m_combo.GetCurSel()); - EndDialog(m_hwnd, 1); + return true; +} + +void CSkypeInviteDlg::OnDestroy() +{ + m_proto->m_InviteDialogs.remove(this); } -//CSkypeGCCreateDlg +///////////////////////////////////////////////////////////////////////////////////////// +// CSkypeGCCreateDlg + CSkypeGCCreateDlg::CSkypeGCCreateDlg(CSkypeProto *proto) : - CSkypeDlgBase(proto, IDD_GC_CREATE), m_ok(this, IDOK), m_cancel(this, IDCANCEL), m_clc(this, IDC_CLIST), m_ContactsList(1) + CSkypeDlgBase(proto, IDD_GC_CREATE), + m_clc(this, IDC_CLIST), + m_ContactsList(1) { - m_ok.OnClick = Callback(this, &CSkypeGCCreateDlg::btnOk_OnOk); m_clc.OnListRebuilt = Callback(this, &CSkypeGCCreateDlg::FilterList); } @@ -67,6 +75,8 @@ CSkypeGCCreateDlg::~CSkypeGCCreateDlg() bool CSkypeGCCreateDlg::OnInitDialog() { + m_proto->m_GCCreateDialogs.insert(this); + SetWindowLongPtr(m_clc.GetHwnd(), GWL_STYLE, GetWindowLongPtr(m_clc.GetHwnd(), GWL_STYLE) | CLS_CHECKBOXES | CLS_HIDEEMPTYGROUPS | CLS_USEGROUPS | CLS_GREYALTERNATE); m_clc.SendMsg(CLM_SETEXSTYLE, CLS_EX_DISABLEDRAGDROP | CLS_EX_TRACKSELECT, 0); @@ -75,7 +85,7 @@ bool CSkypeGCCreateDlg::OnInitDialog() return true; } -void CSkypeGCCreateDlg::btnOk_OnOk(CCtrlButton*) +bool CSkypeGCCreateDlg::OnApply() { for (auto &hContact : m_proto->AccContacts()) { if (!m_proto->isChatRoom(hContact)) @@ -85,7 +95,12 @@ void CSkypeGCCreateDlg::btnOk_OnOk(CCtrlButton*) } m_ContactsList.insert(m_proto->m_szSkypename.GetBuffer()); - EndDialog(m_hwnd, m_ContactsList.getCount()); + return true; +} + +void CSkypeGCCreateDlg::OnDestroy() +{ + m_proto->m_GCCreateDialogs.remove(this); } void CSkypeGCCreateDlg::FilterList(CCtrlClc *) diff --git a/protocols/SkypeWeb/src/skype_dialogs.h b/protocols/SkypeWeb/src/skype_dialogs.h index 6c653d9fd5..942128d692 100644 --- a/protocols/SkypeWeb/src/skype_dialogs.h +++ b/protocols/SkypeWeb/src/skype_dialogs.h @@ -22,43 +22,34 @@ typedef CProtoDlgBase CSkypeDlgBase; class CSkypeInviteDlg : public CSkypeDlgBase { -private: - typedef CSkypeDlgBase CSuper; - CCtrlButton m_ok; - CCtrlButton m_cancel; - CCtrlCombo m_combo; - -protected: - bool OnInitDialog() override; - - void btnOk_OnOk(CCtrlButton*); + CCtrlCombo m_combo; public: - MCONTACT m_hContact; - CSkypeInviteDlg(CSkypeProto *proto); + + bool OnInitDialog() override; + bool OnApply() override; + void OnDestroy() override; + + MCONTACT m_hContact = 0; }; class CSkypeGCCreateDlg : public CSkypeDlgBase { -private: - typedef CSkypeDlgBase CSuper; - CCtrlButton m_ok; - CCtrlButton m_cancel; - CCtrlClc m_clc; + CCtrlClc m_clc; + +public: + CSkypeGCCreateDlg(CSkypeProto *proto); + ~CSkypeGCCreateDlg(); -protected: bool OnInitDialog() override; + bool OnApply() override; + void OnDestroy() override; - void btnOk_OnOk(CCtrlButton*); void FilterList(CCtrlClc*); void ResetListOptions(CCtrlClc*); -public: LIST m_ContactsList; - - CSkypeGCCreateDlg(CSkypeProto *proto); - ~CSkypeGCCreateDlg(); }; diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h index 5279bc6c4d..99392ad332 100644 --- a/protocols/SkypeWeb/src/skype_proto.h +++ b/protocols/SkypeWeb/src/skype_proto.h @@ -20,8 +20,9 @@ along with this program. If not, see . struct CSkypeProto : public PROTO { - friend CSkypeOptionsMain; - friend CSkypeGCCreateDlg; + friend class CSkypeOptionsMain; + friend class CSkypeGCCreateDlg; + friend class CSkypeInviteDlg; class CSkypeProtoImpl { @@ -158,8 +159,6 @@ private: // locks mir_cs m_lckOutMessagesList; - mir_cs m_InviteDialogsLock; - mir_cs m_GCCreateDialogsLock; mir_cs messageSyncLock; mir_cs m_StatusLock; mir_cs m_AppendMessageLock; -- cgit v1.2.3