diff options
author | George Hazan <george.hazan@gmail.com> | 2024-01-15 12:53:52 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-01-15 12:53:52 +0300 |
commit | 17944741957b032d6ab360d78ab4fc26a0467706 (patch) | |
tree | 9744d465c83e56cfab8439f3e414ed89b108794b /protocols | |
parent | ad952090c27086537f8c407a228e8d609a22b0fc (diff) |
fixes #4120 (Discord: второй фактор запрашивается при каждом выходе в онлайн)
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Discord/discord.vcxproj | 6 | ||||
-rw-r--r-- | protocols/Discord/discord.vcxproj.filters | 14 | ||||
-rw-r--r-- | protocols/Discord/res/discord.rc | 3 | ||||
-rw-r--r-- | protocols/Discord/src/gateway.cpp | 13 | ||||
-rw-r--r-- | protocols/Discord/src/options.cpp | 16 | ||||
-rw-r--r-- | protocols/Discord/src/resource.h | 4 | ||||
-rw-r--r-- | protocols/Discord/src/server.cpp | 8 |
7 files changed, 51 insertions, 13 deletions
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 @@ <ResourceCompile Include="res\discord.rc" />
<ResourceCompile Include="res\version.rc" />
</ItemGroup>
+ <ItemGroup>
+ <Image Include="res\discord.ico" />
+ <Image Include="res\groupchat.ico" />
+ <Image Include="res\voiceCall.ico" />
+ <Image Include="res\voiceEnded.ico" />
+ </ItemGroup>
</Project>
\ 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 @@ <Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
+ <ItemGroup>
+ <Image Include="res\discord.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\groupchat.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\voiceCall.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\voiceEnded.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ </ItemGroup>
</Project>
\ 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 <http://www.gnu.org/licenses/>. 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);
|