From 71f29fec24a26a89daab816566a4ae114593e340 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 30 Jan 2023 18:47:45 +0300 Subject: fixes #3317 (Telegram: email address verification support) --- protocols/Telegram/src/auth.cpp | 23 +++++++++++++++++++++-- protocols/Telegram/src/proto.h | 3 ++- 2 files changed, 23 insertions(+), 3 deletions(-) (limited to 'protocols') diff --git a/protocols/Telegram/src/auth.cpp b/protocols/Telegram/src/auth.cpp index 674d91d6a4..f992704e92 100644 --- a/protocols/Telegram/src/auth.cpp +++ b/protocols/Telegram/src/auth.cpp @@ -21,6 +21,21 @@ along with this program. If not, see . /////////////////////////////////////////////////////////////////////////////// +INT_PTR CALLBACK CTelegramProto::EnterEmail(void *param) +{ + auto *ppro = (CTelegramProto *)param; + + ENTER_STRING es = {}; + es.szModuleName = ppro->m_szModuleName; + es.caption = TranslateT("Enter email address for account verification"); + if (EnterString(&es)) { + ppro->SendQuery(new TD::checkEmailAddressVerificationCode(T2Utf(es.ptszResult).get()), &CTelegramProto::OnUpdateAuth); + mir_free(es.ptszResult); + } + else ppro->LogOut(); + return 0; +} + INT_PTR CALLBACK CTelegramProto::EnterPhoneCode(void *param) { auto *ppro = (CTelegramProto *)param; @@ -29,7 +44,7 @@ INT_PTR CALLBACK CTelegramProto::EnterPhoneCode(void *param) es.szModuleName = ppro->m_szModuleName; es.caption = TranslateT("Enter secret code sent to your phone"); if (EnterString(&es)) { - ppro->SendQuery(new TD::checkAuthenticationCode(_T2A(es.ptszResult).get()), &CTelegramProto::OnUpdateAuth); + ppro->SendQuery(new TD::checkAuthenticationCode(T2Utf(es.ptszResult).get()), &CTelegramProto::OnUpdateAuth); mir_free(es.ptszResult); } else ppro->LogOut(); @@ -50,7 +65,7 @@ INT_PTR CALLBACK CTelegramProto::EnterPassword(void *param) es.caption = wszTitle; es.type = ESF_PASSWORD; if (EnterString(&es)) { - ppro->SendQuery(new TD::checkAuthenticationPassword(_T2A(es.ptszResult).get()), &CTelegramProto::OnUpdateAuth); + ppro->SendQuery(new TD::checkAuthenticationPassword(T2Utf(es.ptszResult).get()), &CTelegramProto::OnUpdateAuth); mir_free(es.ptszResult); } else ppro->LogOut(); @@ -96,6 +111,10 @@ void CTelegramProto::ProcessAuth(TD::updateAuthorizationState *pObj) CallFunctionSync(EnterPassword, this); break; + case TD::authorizationStateWaitEmailAddress::ID: + CallFunctionSync(EnterEmail, this); + break; + case TD::authorizationStateReady::ID: OnLoggedIn(); break; diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h index 77c9da70d7..c88c6c9666 100644 --- a/protocols/Telegram/src/proto.h +++ b/protocols/Telegram/src/proto.h @@ -133,8 +133,9 @@ class CTelegramProto : public PROTO OBJLIST m_arRequests; OBJLIST m_arFiles; - static INT_PTR CALLBACK EnterPhoneCode(void *param); + static INT_PTR CALLBACK EnterEmail(void *param); static INT_PTR CALLBACK EnterPassword(void *param); + static INT_PTR CALLBACK EnterPhoneCode(void *param); CMStringW GetProtoFolder() const { return CMStringW(VARSW(L"%miranda_userdata%")) + L"\\" + _A2T(m_szModuleName); -- cgit v1.2.3