summaryrefslogtreecommitdiff
path: root/protocols/Telegram
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2023-01-30 18:47:45 +0300
committerGeorge Hazan <ghazan@miranda.im>2023-01-30 18:47:45 +0300
commit71f29fec24a26a89daab816566a4ae114593e340 (patch)
tree8f75a07fe6c52a5fa4ce553b5ff9d64653b7d70d /protocols/Telegram
parentb4e07458c21379f604aca4d4fb23086b4129c113 (diff)
fixes #3317 (Telegram: email address verification support)
Diffstat (limited to 'protocols/Telegram')
-rw-r--r--protocols/Telegram/src/auth.cpp23
-rw-r--r--protocols/Telegram/src/proto.h3
2 files changed, 23 insertions, 3 deletions
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 <http://www.gnu.org/licenses/>.
///////////////////////////////////////////////////////////////////////////////
+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<CTelegramProto>
OBJLIST<TG_REQUEST_BASE> m_arRequests;
OBJLIST<TG_FILE_REQUEST> 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);