From 17944741957b032d6ab360d78ab4fc26a0467706 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 15 Jan 2024 12:53:52 +0300 Subject: =?UTF-8?q?fixes=20#4120=20(Discord:=20=D0=B2=D1=82=D0=BE=D1=80?= =?UTF-8?q?=D0=BE=D0=B9=20=D1=84=D0=B0=D0=BA=D1=82=D0=BE=D1=80=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=BF=D1=80=D0=B0=D1=88=D0=B8=D0=B2=D0=B0=D0=B5=D1=82?= =?UTF-8?q?=D1=81=D1=8F=20=D0=BF=D1=80=D0=B8=20=D0=BA=D0=B0=D0=B6=D0=B4?= =?UTF-8?q?=D0=BE=D0=BC=20=D0=B2=D1=8B=D1=85=D0=BE=D0=B4=D0=B5=20=D0=B2=20?= =?UTF-8?q?=D0=BE=D0=BD=D0=BB=D0=B0=D0=B9=D0=BD)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/Discord/discord.vcxproj | 6 ++++++ protocols/Discord/discord.vcxproj.filters | 14 ++++++++++++++ protocols/Discord/res/discord.rc | 3 ++- protocols/Discord/src/gateway.cpp | 13 ++++--------- protocols/Discord/src/options.cpp | 16 ++++++++++++++-- protocols/Discord/src/resource.h | 4 +++- protocols/Discord/src/server.cpp | 8 ++++++++ 7 files changed, 51 insertions(+), 13 deletions(-) (limited to 'protocols') diff --git a/protocols/Discord/discord.vcxproj b/protocols/Discord/discord.vcxproj index dc4a3679bc..371ffd6c19 100644 --- a/protocols/Discord/discord.vcxproj +++ b/protocols/Discord/discord.vcxproj @@ -61,4 +61,10 @@ + + + + + + \ No newline at end of file diff --git a/protocols/Discord/discord.vcxproj.filters b/protocols/Discord/discord.vcxproj.filters index 61ee857295..b9c097d534 100644 --- a/protocols/Discord/discord.vcxproj.filters +++ b/protocols/Discord/discord.vcxproj.filters @@ -73,4 +73,18 @@ Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + \ No newline at end of file diff --git a/protocols/Discord/res/discord.rc b/protocols/Discord/res/discord.rc index ce433c060f..73a238be61 100644 --- a/protocols/Discord/res/discord.rc +++ b/protocols/Discord/res/discord.rc @@ -66,7 +66,7 @@ IDI_VOICE_ENDED ICON "voiceEnded.ico" // Dialog // -IDD_OPTIONS_ACCOUNT DIALOGEX 0, 0, 305, 144 +IDD_OPTIONS_ACCOUNT DIALOGEX 0, 0, 305, 228 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD EXSTYLE WS_EX_CONTROLPARENT FONT 8, "MS Shell Dlg", 0, 0, 0x1 @@ -86,6 +86,7 @@ BEGIN "Button",BS_AUTOCHECKBOX | WS_TABSTOP,23,114,248,10 CONTROL "Delete messages in Miranda when they are deleted from server",IDC_DELETE_MSGS, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,126,275,10 + PUSHBUTTON "Log out",IDC_LOGOUT,211,18,81,13 END IDD_OPTIONS_ACCMGR DIALOGEX 0, 0, 200, 88 diff --git a/protocols/Discord/src/gateway.cpp b/protocols/Discord/src/gateway.cpp index 30a32bb5f6..8367462159 100644 --- a/protocols/Discord/src/gateway.cpp +++ b/protocols/Discord/src/gateway.cpp @@ -305,17 +305,10 @@ void CDiscordProto::GatewaySendResume() ///////////////////////////////////////////////////////////////////////////////////////// -void CDiscordProto::OnReceiveLogout(MHttpResponse *, AsyncHttpRequest *) -{ - delSetting(DB_KEY_TOKEN); -} - bool CDiscordProto::GatewaySendStatus(int iStatus, const wchar_t *pwszStatusText) { - if (iStatus == ID_STATUS_OFFLINE) { - Push(new AsyncHttpRequest(this, REQUEST_POST, "/auth/logout", &CDiscordProto::OnReceiveLogout)); - return true; - } + // if (iStatus == ID_STATUS_OFFLINE) + // return true; const char *pszStatus; switch (iStatus) { @@ -326,6 +319,8 @@ bool CDiscordProto::GatewaySendStatus(int iStatus, const wchar_t *pwszStatusText pszStatus = "dnd"; break; case ID_STATUS_INVISIBLE: pszStatus = "invisible"; break; + case ID_STATUS_OFFLINE: + pszStatus = "offline"; break; default: pszStatus = "online"; break; } diff --git a/protocols/Discord/src/options.cpp b/protocols/Discord/src/options.cpp index dc4a6d60b5..11c73c64d0 100644 --- a/protocols/Discord/src/options.cpp +++ b/protocols/Discord/src/options.cpp @@ -21,13 +21,15 @@ along with this program. If not, see . class CDiscardAccountOptions : public CDiscordDlgBase { - CCtrlCheck chkUseChats, chkHideChats, chkUseGroups, chkDeleteMsgs; - CCtrlEdit m_edGroup, m_edUserName, m_edPassword; ptrW m_wszOldGroup; + CCtrlEdit m_edGroup, m_edUserName, m_edPassword; + CCtrlCheck chkUseChats, chkHideChats, chkUseGroups, chkDeleteMsgs; + CCtrlButton btnLogout; public: CDiscardAccountOptions(CDiscordProto *ppro, int iDlgID, bool bFullDlg) : CDiscordDlgBase(ppro, iDlgID), + btnLogout(this, IDC_LOGOUT), m_edGroup(this, IDC_GROUP), m_edUserName(this, IDC_USERNAME), m_edPassword(this, IDC_PASSWORD), @@ -37,6 +39,8 @@ public: chkDeleteMsgs(this, IDC_DELETE_MSGS), m_wszOldGroup(mir_wstrdup(ppro->m_wszDefaultGroup)) { + btnLogout.OnClick = Callback(this, &CDiscardAccountOptions::onClick_Logout); + CreateLink(m_edGroup, ppro->m_wszDefaultGroup); CreateLink(m_edUserName, ppro->m_wszEmail); if (bFullDlg) { @@ -51,6 +55,9 @@ public: bool OnInitDialog() override { + if (m_proto->getMStringA(DB_KEY_TOKEN).IsEmpty()) + btnLogout.Disable(); + ptrW buf(m_proto->getWStringA(DB_KEY_PASSWORD)); if (buf) m_edPassword.SetText(buf); @@ -67,6 +74,11 @@ public: return true; } + void onClick_Logout(CCtrlButton *) + { + m_proto->Push(new AsyncHttpRequest(m_proto, REQUEST_POST, "/auth/logout", &CDiscordProto::OnReceiveLogout)); + } + void onChange_GroupChats(CCtrlCheck*) { bool bEnabled = chkUseChats.GetState(); diff --git a/protocols/Discord/src/resource.h b/protocols/Discord/src/resource.h index dc1c9706f1..00f55d2886 100644 --- a/protocols/Discord/src/resource.h +++ b/protocols/Discord/src/resource.h @@ -21,6 +21,8 @@ #define IDC_DELETE_MSGS 1009 #define IDC_ANOTHER 1009 #define IDC_LABEL 1010 +#define IDC_BUTTON1 1011 +#define IDC_LOGOUT 1011 // Next default values for new objects // @@ -28,7 +30,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 108 #define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1011 +#define _APS_NEXT_CONTROL_VALUE 1012 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/protocols/Discord/src/server.cpp b/protocols/Discord/src/server.cpp index 7bc887edef..d06e307539 100644 --- a/protocols/Discord/src/server.cpp +++ b/protocols/Discord/src/server.cpp @@ -214,6 +214,14 @@ void CDiscordProto::OnReceiveCreateChannel(MHttpResponse *pReply, AsyncHttpReque ///////////////////////////////////////////////////////////////////////////////////////// +void CDiscordProto::OnReceiveLogout(MHttpResponse *, AsyncHttpRequest *) +{ + delSetting(DB_KEY_TOKEN); + ShutdownSession(); +} + +///////////////////////////////////////////////////////////////////////////////////////// + void CDiscordProto::OnReceiveMessageAck(MHttpResponse *pReply, AsyncHttpRequest*) { JsonReply root(pReply); -- cgit v1.2.3