diff options
author | George Hazan <ghazan@miranda.im> | 2023-01-01 18:05:00 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2023-01-01 18:05:00 +0300 |
commit | c4a542557cb47af428d1397b97f652a65cffd6c6 (patch) | |
tree | 4ad0b5e31d57f9dce5a26e96721e2a5638a87ebe /protocols | |
parent | f828d2569303fa4b26bee503dc9f438fd1fe0c7d (diff) |
fixes #3286 (Telegram: ability to identify Miranda's session)
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Telegram/Telegram.vcxproj | 4 | ||||
-rw-r--r-- | protocols/Telegram/Telegram.vcxproj.filters | 8 | ||||
-rw-r--r-- | protocols/Telegram/res/resource.rc | 44 | ||||
-rw-r--r-- | protocols/Telegram/src/auth.cpp | 12 | ||||
-rw-r--r-- | protocols/Telegram/src/mt_proto.cpp | 1 | ||||
-rw-r--r-- | protocols/Telegram/src/mt_proto.h | 1 | ||||
-rw-r--r-- | protocols/Telegram/src/options.cpp | 4 | ||||
-rw-r--r-- | protocols/Telegram/src/resource.h | 9 |
8 files changed, 64 insertions, 19 deletions
diff --git a/protocols/Telegram/Telegram.vcxproj b/protocols/Telegram/Telegram.vcxproj index d1db70ba72..eed1b057f3 100644 --- a/protocols/Telegram/Telegram.vcxproj +++ b/protocols/Telegram/Telegram.vcxproj @@ -47,10 +47,8 @@ </Link> </ItemDefinitionGroup> <ItemGroup> - <Image Include="telegram.ico" /> - </ItemGroup> - <ItemGroup> <ClInclude Include="src\mt_proto.h" /> + <ClInclude Include="src\resource.h" /> <ClInclude Include="src\stdafx.h" /> <ClInclude Include="src\version.h" /> </ItemGroup> diff --git a/protocols/Telegram/Telegram.vcxproj.filters b/protocols/Telegram/Telegram.vcxproj.filters index 6c83ece5dd..ffd20c351c 100644 --- a/protocols/Telegram/Telegram.vcxproj.filters +++ b/protocols/Telegram/Telegram.vcxproj.filters @@ -33,11 +33,6 @@ </ClCompile> </ItemGroup> <ItemGroup> - <Image Include="telegram.ico"> - <Filter>Resource Files</Filter> - </Image> - </ItemGroup> - <ItemGroup> <ClInclude Include="src\mt_proto.h"> <Filter>Header Files</Filter> </ClInclude> @@ -47,6 +42,9 @@ <ClInclude Include="src\version.h"> <Filter>Header Files</Filter> </ClInclude> + <ClInclude Include="src\resource.h"> + <Filter>Header Files</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <ResourceCompile Include="res\version.rc"> diff --git a/protocols/Telegram/res/resource.rc b/protocols/Telegram/res/resource.rc index c7e451b53c..0aacaa94c4 100644 --- a/protocols/Telegram/res/resource.rc +++ b/protocols/Telegram/res/resource.rc @@ -49,7 +49,7 @@ END ///////////////////////////////////////////////////////////////////////////// -// English resources +// English (Neutral) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL @@ -69,6 +69,8 @@ BEGIN 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 CONTROL "Do not open chat windows on creation",IDC_HIDECHATS, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,0,57,182,10 END @@ -82,10 +84,13 @@ BEGIN EDITTEXT IDC_PHONE,87,5,211,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 + EDITTEXT IDC_DEVICE_NAME,87,41,211,12,ES_AUTOHSCROLL CONTROL "Do not open chat windows on creation",IDC_HIDECHATS, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,64,294,10 END + ///////////////////////////////////////////////////////////////////////////// // // Icon @@ -97,7 +102,42 @@ IDI_TELEGRAM ICON "telegram.ico" IDI_PREMIUM ICON "premium.ico" -#endif // English resources + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_ACCMGRUI, DIALOG + BEGIN + END + + IDD_OPTIONS, DIALOG + BEGIN + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// AFX_DIALOG_LAYOUT +// + +IDD_ACCMGRUI AFX_DIALOG_LAYOUT +BEGIN + 0 +END + +IDD_OPTIONS AFX_DIALOG_LAYOUT +BEGIN + 0 +END + +#endif // English (Neutral) resources ///////////////////////////////////////////////////////////////////////////// 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 |