summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/Telegram/res/resource.rc20
-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
7 files changed, 42 insertions, 12 deletions
diff --git a/protocols/Telegram/res/resource.rc b/protocols/Telegram/res/resource.rc
index fcbf34361b..1fff0c80ce 100644
--- a/protocols/Telegram/res/resource.rc
+++ b/protocols/Telegram/res/resource.rc
@@ -65,14 +65,16 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 400, 0, 0x0
BEGIN
- LTEXT "Phone number:",IDC_STATIC,0,6,89,10
- EDITTEXT IDC_PHONE,96,4,86,12,ES_AUTOHSCROLL
- LTEXT "Default group:",IDC_STATIC,0,23,89,10
- EDITTEXT IDC_DEFGROUP,96,21,86,12,ES_AUTOHSCROLL
- LTEXT "Device name:",IDC_STATIC,0,39,89,10
- EDITTEXT IDC_DEVICE_NAME,96,38,86,12,ES_AUTOHSCROLL
+ LTEXT "Country",IDC_STATIC,0,8,89,8
+ COMBOBOX IDC_COUNTRY,96,5,86,12,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP
+ LTEXT "Phone number:",IDC_STATIC,0,25,89,10
+ EDITTEXT IDC_PHONE,96,22,86,12,ES_AUTOHSCROLL
+ LTEXT "Default group:",IDC_STATIC,0,42,89,10
+ EDITTEXT IDC_DEFGROUP,96,39,86,12,ES_AUTOHSCROLL
+ LTEXT "Device name:",IDC_STATIC,0,59,89,10
+ 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,57,182,10
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,0,75,182,10
END
IDD_OPTIONS DIALOGEX 0, 0, 305, 188
@@ -81,7 +83,8 @@ EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
LTEXT "Phone number:",IDC_STATIC,5,6,79,10
- EDITTEXT IDC_PHONE,87,5,211,12,ES_AUTOHSCROLL
+ COMBOBOX IDC_COUNTRY,88,5,103,12,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP
+ EDITTEXT IDC_PHONE,195,5,103,12,ES_AUTOHSCROLL
LTEXT "Default group:",IDC_STATIC,5,24,79,10
EDITTEXT IDC_DEFGROUP,87,23,211,12,ES_AUTOHSCROLL
LTEXT "Device name:",IDC_STATIC,5,43,79,10
@@ -105,6 +108,7 @@ BEGIN
COMBOBOX IDC_STATUS2,221,61,81,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
END
+
/////////////////////////////////////////////////////////////////////////////
//
// Icon
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_))