summaryrefslogtreecommitdiff
path: root/protocols/Telegram/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2023-02-03 18:48:11 +0300
committerGeorge Hazan <ghazan@miranda.im>2023-02-03 18:48:11 +0300
commit97aaa26b16121281291acf58c26e1032a24d85bf (patch)
tree5a08a3766ac9d046f181b80bb55a73b00b4b2c32 /protocols/Telegram/src
parent47b61b0cdaa95adf2543523da00f134276eff8c3 (diff)
fixes #3324 (Telegram: phone number)
Diffstat (limited to 'protocols/Telegram/src')
-rw-r--r--protocols/Telegram/src/auth.cpp2
-rw-r--r--protocols/Telegram/src/options.cpp23
-rw-r--r--protocols/Telegram/src/proto.cpp1
-rw-r--r--protocols/Telegram/src/proto.h2
-rw-r--r--protocols/Telegram/src/resource.h3
-rw-r--r--protocols/Telegram/src/server.cpp3
6 files changed, 30 insertions, 4 deletions
diff --git a/protocols/Telegram/src/auth.cpp b/protocols/Telegram/src/auth.cpp
index d1cfb85211..b6af34a657 100644
--- a/protocols/Telegram/src/auth.cpp
+++ b/protocols/Telegram/src/auth.cpp
@@ -117,7 +117,7 @@ void CTelegramProto::ProcessAuth(TD::updateAuthorizationState *pObj)
break;
case TD::authorizationStateWaitPhoneNumber::ID:
- SendQuery(new TD::setAuthenticationPhoneNumber(_T2A(m_szOwnPhone).get(), nullptr), &CTelegramProto::OnUpdateAuth);
+ SendQuery(new TD::setAuthenticationPhoneNumber(m_szFullPhone.c_str(), nullptr), &CTelegramProto::OnUpdateAuth);
break;
case TD::authorizationStateWaitCode::ID:
diff --git a/protocols/Telegram/src/options.cpp b/protocols/Telegram/src/options.cpp
index 9986ba7c45..e66da19f0c 100644
--- a/protocols/Telegram/src/options.cpp
+++ b/protocols/Telegram/src/options.cpp
@@ -22,12 +22,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
class COptionsDlg : public CProtoDlgBase<CTelegramProto>
{
CCtrlCheck chkHideChats, chkUsePopups;
+ CCtrlCombo cmbCountry;
CCtrlEdit edtGroup, edtPhone, edtDeviceName;
ptrW m_wszOldGroup;
public:
COptionsDlg(CTelegramProto *ppro, int iDlgID, bool bFullDlg) :
CProtoDlgBase<CTelegramProto>(ppro, iDlgID),
+ cmbCountry(this, IDC_COUNTRY),
chkUsePopups(this, IDC_POPUPS),
chkHideChats(this, IDC_HIDECHATS),
edtPhone(this, IDC_PHONE),
@@ -44,13 +46,32 @@ public:
CreateLink(chkUsePopups, ppro->m_bUsePopups);
}
+ bool OnInitDialog() override
+ {
+ int iCount;
+ CountryListEntry *pList;
+ CallService(MS_UTILS_GETCOUNTRYLIST, (WPARAM)&iCount, (LPARAM)&pList);
+
+ for (int i = 0; i < iCount; i++) {
+ int countryCode = pList[i].id;
+ int idx = cmbCountry.AddString(TranslateW(_A2T(pList[i].szName).get()), countryCode);
+ if (countryCode == m_proto->m_iCountry)
+ cmbCountry.SetCurSel(idx);
+ }
+
+ return true;
+ }
+
bool OnApply() override
{
- if (!mir_wstrlen(m_proto->m_szOwnPhone)) {
+ int iCountry = cmbCountry.GetCurData();
+ if (iCountry == 9999 || mir_wstrlen(m_proto->m_szOwnPhone)) {
SetFocus(edtPhone.GetHwnd());
return false;
}
+ m_proto->m_iCountry = iCountry;
+
if (mir_wstrcmp(m_proto->m_wszDefaultGroup, m_wszOldGroup))
Clist_GroupCreate(0, m_proto->m_wszDefaultGroup);
return true;
diff --git a/protocols/Telegram/src/proto.cpp b/protocols/Telegram/src/proto.cpp
index 2044462846..06ac895087 100644
--- a/protocols/Telegram/src/proto.cpp
+++ b/protocols/Telegram/src/proto.cpp
@@ -37,6 +37,7 @@ CTelegramProto::CTelegramProto(const char* protoName, const wchar_t* userName) :
m_arBasicGroups(10, CompareBasicGroups),
m_arSuperGroups(10, CompareSuperGroups),
m_szOwnPhone(this, "Phone"),
+ m_iCountry(this, "Country", 9999),
m_iStatus1(this, "Status1", ID_STATUS_AWAY),
m_iStatus2(this, "Status2", ID_STATUS_NA),
m_iTimeDiff1(this, "TimeDiff1", 600),
diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h
index d77c5d04fc..476deea871 100644
--- a/protocols/Telegram/src/proto.h
+++ b/protocols/Telegram/src/proto.h
@@ -153,6 +153,7 @@ class CTelegramProto : public PROTO<CTelegramProto>
bool m_bAuthorized, m_bTerminated, m_bUnregister = false, m_bSmileyAdd = false;
int32_t m_iClientId, m_iMsgId;
int64_t m_iQueryId;
+ CMStringA m_szFullPhone;
OBJLIST<TG_REQUEST_BASE> m_arRequests;
OBJLIST<TG_FILE_REQUEST> m_arFiles;
@@ -255,6 +256,7 @@ public:
// Options ///////////////////////////////////////////////////////////////////////////
+ CMOption<uint32_t> m_iCountry; // set this status to m_iStatus1 after this interval of secs
CMOption<wchar_t*> m_szOwnPhone; // our own phone number
CMOption<wchar_t*> m_wszDefaultGroup; // clist group to store contacts
CMOption<wchar_t*> m_wszDeviceName; // how do you see this session in Device List
diff --git a/protocols/Telegram/src/resource.h b/protocols/Telegram/src/resource.h
index 5bd28839a5..4c8deb0dcd 100644
--- a/protocols/Telegram/src/resource.h
+++ b/protocols/Telegram/src/resource.h
@@ -19,6 +19,7 @@
#define IDC_SPIN2 1009
#define IDC_STATUS1 1010
#define IDC_STATUS2 1011
+#define IDC_COUNTRY 1012
// Next default values for new objects
//
@@ -26,7 +27,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 106
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1006
+#define _APS_NEXT_CONTROL_VALUE 1013
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp
index e039628284..aab8a3a49e 100644
--- a/protocols/Telegram/src/server.cpp
+++ b/protocols/Telegram/src/server.cpp
@@ -25,6 +25,7 @@ void CTelegramProto::OnEndSession(td::ClientManager::Response&)
void __cdecl CTelegramProto::ServerThread(void *)
{
m_bTerminated = m_bAuthorized = false;
+ m_szFullPhone.Format("%d%S", (int)m_iCountry, (wchar_t *)m_szOwnPhone);
m_pClientMmanager = std::make_unique<td::ClientManager>();
m_iClientId = m_pClientMmanager->create_client_id();
@@ -457,7 +458,7 @@ void CTelegramProto::ProcessUser(TD::updateUser *pObj)
{
auto *pUser = pObj->user_.get();
- if (pUser->phone_number_ == _T2A(m_szOwnPhone).get()) {
+ if (pUser->phone_number_ == m_szFullPhone.c_str()) {
m_iOwnId = pUser->id_;
if (!FindUser(pUser->id_))