summaryrefslogtreecommitdiff
path: root/protocols/Telegram/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2023-01-01 18:05:00 +0300
committerGeorge Hazan <ghazan@miranda.im>2023-01-01 18:05:00 +0300
commitc4a542557cb47af428d1397b97f652a65cffd6c6 (patch)
tree4ad0b5e31d57f9dce5a26e96721e2a5638a87ebe /protocols/Telegram/src
parentf828d2569303fa4b26bee503dc9f438fd1fe0c7d (diff)
fixes #3286 (Telegram: ability to identify Miranda's session)
Diffstat (limited to 'protocols/Telegram/src')
-rw-r--r--protocols/Telegram/src/auth.cpp12
-rw-r--r--protocols/Telegram/src/mt_proto.cpp1
-rw-r--r--protocols/Telegram/src/mt_proto.h1
-rw-r--r--protocols/Telegram/src/options.cpp4
-rw-r--r--protocols/Telegram/src/resource.h9
5 files changed, 18 insertions, 9 deletions
diff --git a/protocols/Telegram/src/auth.cpp b/protocols/Telegram/src/auth.cpp
index c29053af18..9591f5fc98 100644
--- a/protocols/Telegram/src/auth.cpp
+++ b/protocols/Telegram/src/auth.cpp
@@ -17,6 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
+#include "../../../../miranda-private-keys/Telegram/api.h"
+
///////////////////////////////////////////////////////////////////////////////
INT_PTR CALLBACK CMTProto::EnterPhoneCode(void *param)
@@ -61,8 +63,10 @@ void CMTProto::ProcessAuth(TD::updateAuthorizationState *pObj)
switch (pAuthState->get_id()) {
case TD::authorizationStateWaitTdlibParameters::ID:
{
+ MFileVersion v;
char text[100];
- Miranda_GetVersionText(text, sizeof(text));
+ Miranda_GetFileVersion(&v);
+ mir_snprintf(text, "%d.%d.%d.%d", v[0], v[1], v[2], v[3]);
CMStringW wszPath(GetProtoFolder());
@@ -70,10 +74,10 @@ void CMTProto::ProcessAuth(TD::updateAuthorizationState *pObj)
request->database_directory_ = T2Utf(wszPath).get();
request->use_message_database_ = false;
request->use_secret_chats_ = true;
- request->api_id_ = 94575;
- request->api_hash_ = "a3406de8d171bb422bb6ddf3bbd800e2";
+ request->api_id_ = MIRANDA_API_ID;
+ request->api_hash_ = MIRANDA_API_HASH;
request->system_language_code_ = "en";
- request->device_model_ = "Miranda NG";
+ request->device_model_ = T2Utf(m_wszDeviceName).get();
request->application_version_ = text;
request->enable_storage_optimizer_ = true;
SendQuery(request, &CMTProto::OnUpdateAuth);
diff --git a/protocols/Telegram/src/mt_proto.cpp b/protocols/Telegram/src/mt_proto.cpp
index eeed67745c..a0e90d8573 100644
--- a/protocols/Telegram/src/mt_proto.cpp
+++ b/protocols/Telegram/src/mt_proto.cpp
@@ -23,6 +23,7 @@ CMTProto::CMTProto(const char* protoName, const wchar_t* userName) :
m_arUsers(10, CompareUsers),
m_arRequests(10, CompareRequests),
m_szOwnPhone(this, "Phone"),
+ m_wszDeviceName(this, "DeviceName", L"Miranda"),
m_wszDefaultGroup(this, "DefaultGroup", L"Telegram"),
m_bUsePopups(this, "UsePopups", true),
m_bHideGroupchats(this, "HideChats", true)
diff --git a/protocols/Telegram/src/mt_proto.h b/protocols/Telegram/src/mt_proto.h
index f3232592ce..7f1011e996 100644
--- a/protocols/Telegram/src/mt_proto.h
+++ b/protocols/Telegram/src/mt_proto.h
@@ -172,6 +172,7 @@ public:
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
CMOption<bool> m_bHideGroupchats; // do not open chat windows on creation
CMOption<bool> m_bUsePopups;
diff --git a/protocols/Telegram/src/options.cpp b/protocols/Telegram/src/options.cpp
index 58a86ac374..d830c2122a 100644
--- a/protocols/Telegram/src/options.cpp
+++ b/protocols/Telegram/src/options.cpp
@@ -22,7 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
class COptionsDlg : public CProtoDlgBase<CMTProto>
{
CCtrlCheck chkHideChats, chkUsePopups;
- CCtrlEdit edtGroup, edtPhone;
+ CCtrlEdit edtGroup, edtPhone, edtDeviceName;
ptrW m_wszOldGroup;
public:
@@ -32,10 +32,12 @@ public:
chkHideChats(this, IDC_HIDECHATS),
edtPhone(this, IDC_PHONE),
edtGroup(this, IDC_DEFGROUP),
+ edtDeviceName(this, IDC_DEVICE_NAME),
m_wszOldGroup(mir_wstrdup(ppro->m_wszDefaultGroup))
{
CreateLink(edtPhone, ppro->m_szOwnPhone);
CreateLink(edtGroup, ppro->m_wszDefaultGroup);
+ CreateLink(edtDeviceName, ppro->m_wszDeviceName);
CreateLink(chkHideChats, ppro->m_bHideGroupchats);
if (bFullDlg)
diff --git a/protocols/Telegram/src/resource.h b/protocols/Telegram/src/resource.h
index a52902e8c7..87a094b2bc 100644
--- a/protocols/Telegram/src/resource.h
+++ b/protocols/Telegram/src/resource.h
@@ -1,24 +1,25 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
-// Used by D:\Projects\miranda-ng\miranda-ng\protocols\Telegram\res\resource.rc
+// Used by W:\miranda-ng\protocols\Telegram\res\resource.rc
//
#define IDI_TELEGRAM 100
#define IDD_ACCMGRUI 101
#define IDD_OPTIONS 102
#define IDI_PREMIUM 103
-
#define IDC_PHONE 1001
#define IDC_DEFGROUP 1002
#define IDC_HIDECHATS 1003
#define IDC_POPUPS 1004
+#define IDC_DEFGROUP2 1004
+#define IDC_DEVICE_NAME 1005
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 104
+#define _APS_NEXT_RESOURCE_VALUE 106
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1001
+#define _APS_NEXT_CONTROL_VALUE 1006
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif