diff options
author | George Hazan <george.hazan@gmail.com> | 2024-03-10 17:09:27 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-03-10 17:09:27 +0300 |
commit | 75e084b3950dc3bdba33e6b611b4c4a3f370dc72 (patch) | |
tree | 959eb8ca7bb5eac10a0ea291b3e250e5516760cd /protocols | |
parent | 420da4e31280e87980178893e8b0ed8f9e90cf7a (diff) |
fixes #4255 completely ("Log out" button for Telegram)
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Telegram/res/resource.rc | 2 | ||||
-rw-r--r-- | protocols/Telegram/src/options.cpp | 10 | ||||
-rw-r--r-- | protocols/Telegram/src/proto.cpp | 5 | ||||
-rw-r--r-- | protocols/Telegram/src/proto.h | 3 | ||||
-rw-r--r-- | protocols/Telegram/src/resource.h | 3 | ||||
-rw-r--r-- | protocols/Telegram/src/server.cpp | 8 |
6 files changed, 25 insertions, 6 deletions
diff --git a/protocols/Telegram/res/resource.rc b/protocols/Telegram/res/resource.rc index c94e9e9123..2e29723530 100644 --- a/protocols/Telegram/res/resource.rc +++ b/protocols/Telegram/res/resource.rc @@ -76,6 +76,7 @@ BEGIN EDITTEXT IDC_DEVICE_NAME,96,56,86,12,ES_AUTOHSCROLL
CONTROL "Do not open chat windows on creation",IDC_HIDECHATS,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,0,75,182,10
+ PUSHBUTTON "Log out",IDC_LOGOUT,108,124,74,14
END
IDD_OPTIONS DIALOGEX 0, 0, 305, 188
@@ -95,6 +96,7 @@ BEGIN CONTROL "Do not open chat windows on creation",IDC_HIDECHATS,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,83,294,10
CONTROL "Compress files on send",IDC_COMPRESS_FILES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,97,294,10
+ PUSHBUTTON "Log out",IDC_LOGOUT,212,168,86,14
END
IDD_OPTIONS_ADV DIALOGEX 0, 0, 310, 86
diff --git a/protocols/Telegram/src/options.cpp b/protocols/Telegram/src/options.cpp index e9d5f83b9b..ed9f331f54 100644 --- a/protocols/Telegram/src/options.cpp +++ b/protocols/Telegram/src/options.cpp @@ -21,6 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. class COptionsDlg : public CTelegramDlgBase
{
+ CCtrlButton btnLogout;
CCtrlCheck chkHideChats, chkUsePopups, chkCompressFiles;
CCtrlCombo cmbCountry;
CCtrlEdit edtGroup, edtPhone, edtDeviceName;
@@ -29,6 +30,7 @@ class COptionsDlg : public CTelegramDlgBase public:
COptionsDlg(CTelegramProto *ppro, int iDlgID, bool bFullDlg) :
CTelegramDlgBase(ppro, iDlgID),
+ btnLogout(this, IDC_LOGOUT),
cmbCountry(this, IDC_COUNTRY),
chkUsePopups(this, IDC_POPUPS),
chkHideChats(this, IDC_HIDECHATS),
@@ -48,6 +50,9 @@ public: CreateLink(chkCompressFiles, ppro->m_bCompressFiles);
}
+ btnLogout.Enable(m_proto->getByte(DBKEY_AUTHORIZED));
+ btnLogout.OnClick = Callback(this, &COptionsDlg::onClick_Logout);
+
cmbCountry.OnChange = Callback(this, &COptionsDlg::onChange_Country);
}
@@ -83,6 +88,11 @@ public: return true;
}
+ void onClick_Logout(CCtrlButton *)
+ {
+ m_proto->UnregisterSession();
+ }
+
void onChange_Country(CCtrlCombo *)
{
CMStringA buf;
diff --git a/protocols/Telegram/src/proto.cpp b/protocols/Telegram/src/proto.cpp index 7817d7e4ff..94c26a3d62 100644 --- a/protocols/Telegram/src/proto.cpp +++ b/protocols/Telegram/src/proto.cpp @@ -208,11 +208,6 @@ void CTelegramProto::OnBuildProtoMenu() void CTelegramProto::OnErase() { - if (getByte(DBKEY_AUTHORIZED)) { - m_bUnregister = true; - ServerThread(0); - } - DeleteDirectoryTreeW(GetProtoFolder(), false); } diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h index c0bb072248..b4df98a636 100644 --- a/protocols/Telegram/src/proto.h +++ b/protocols/Telegram/src/proto.h @@ -152,6 +152,7 @@ class CTelegramProto : public PROTO<CTelegramProto> friend class CReplyDlg; friend class CForwardDlg; friend class CReactionsDlg; + friend class COptionsDlg; friend class COptSessionsDlg; friend class CAddPhoneContactDlg; @@ -276,6 +277,8 @@ class CTelegramProto : public PROTO<CTelegramProto> void ProcessSuperGroup(TD::updateSupergroup *pObj); void ProcessUser(TD::updateUser *pObj); + void UnregisterSession(); + bool GetMessageFile(TG_FILE_REQUEST::Type, TG_USER *pUser, const TD::file *pFile, const char *pszFileName, const std::string &caption, const char *szId, const char *szUser, const TD::message *pMsg); CMStringA GetMessageSticker(const TD::file *pFile, const char *pwszExtension); CMStringA GetMessageText(TG_USER *pUser, const TD::message *pMsg, bool bSkipJoin = false); diff --git a/protocols/Telegram/src/resource.h b/protocols/Telegram/src/resource.h index dd6b5a8f0f..4253f350a8 100644 --- a/protocols/Telegram/src/resource.h +++ b/protocols/Telegram/src/resource.h @@ -37,6 +37,7 @@ #define IDC_SESSIONS 1023
#define IDC_IPADDRESS 1024
#define IDC_SOFTWARE 1025
+#define IDC_LOGOUT 1025
// Next default values for new objects
//
@@ -44,7 +45,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 116
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1025
+#define _APS_NEXT_CONTROL_VALUE 1027
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp index 828d8e19dd..1460fb63b1 100644 --- a/protocols/Telegram/src/server.cpp +++ b/protocols/Telegram/src/server.cpp @@ -58,6 +58,14 @@ void __cdecl CTelegramProto::ServerThread(void *) m_pClientManager = std::move(nullptr);
}
+void CTelegramProto::UnregisterSession()
+{
+ if (getByte(DBKEY_AUTHORIZED)) {
+ m_bUnregister = true;
+ ForkThread(&CTelegramProto::ServerThread);
+ }
+}
+
void CTelegramProto::LogOut()
{
if (m_bTerminated)
|