From 1cba3f74c9607b7b03c85f23969cbdd4163b52d5 Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Thu, 24 Mar 2016 10:22:48 +0000 Subject: Telegram: attempt to implement login git-svn-id: http://svn.miranda-ng.org/main/trunk@16534 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Telegram/src/t_proto.cpp | 52 ++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 5 deletions(-) (limited to 'protocols/Telegram/src/t_proto.cpp') diff --git a/protocols/Telegram/src/t_proto.cpp b/protocols/Telegram/src/t_proto.cpp index fd495a7f5f..ee99a0caa9 100644 --- a/protocols/Telegram/src/t_proto.cpp +++ b/protocols/Telegram/src/t_proto.cpp @@ -19,26 +19,56 @@ along with this program. If not, see . CTelegramProto::CTelegramProto(const char* protoName, const TCHAR* userName) : PROTO(protoName, userName) { - TLS = new MirTLS; + TLS = new MirTLS(this); + + tgl_set_verbosity(TLS, 4); InitNetwork(); + InitCallbacks(); + tgl_set_timer_methods(TLS, &tgl_libevent_timers); - tgl_set_rsa_key(TLS, TELEGRAM_PUBLIC_KEY); + tgl_set_rsa_key(TLS, "tgl.pub"); + + + TLS->base_path = Utils_ReplaceVars("%miranda_profilesdir%\\%miranda_profilename%\\TGL_Data\\"); + CreateDirectoryTree(TLS->base_path); + + tgl_set_download_directory(TLS, CMStringA(FORMAT, "%s\\Downloads\\", TLS->base_path)); + CreateDirectoryTree(TLS->downloads_directory); + - tgl_register_app_id(TLS, TELEGRAM_API_ID, TELEGRAM_API_HASH); - tgl_set_app_version(TLS, g_szMirVer); +// tgl_register_app_id(TLS, TELEGRAM_API_ID, TELEGRAM_API_HASH); +// tgl_set_app_version(TLS, g_szMirVer); - tgl_init(TLS); + + ReadState(); + ReadAuth(); + } CTelegramProto::~CTelegramProto() { + SaveState(); } DWORD_PTR CTelegramProto::GetCaps(int type, MCONTACT) { + switch (type) + { + case PFLAGNUM_1: + return PF1_IM | PF1_AUTHREQ | PF1_CHAT | PF1_BASICSEARCH | PF1_MODEMSG | PF1_FILE; + case PFLAGNUM_2: + return PF2_ONLINE; + case PFLAGNUM_3: + return PF2_ONLINE; + case PFLAGNUM_4: + return PF4_FORCEADDED | PF4_NOAUTHDENYREASON | PF4_SUPPORTTYPING | PF4_AVATARS | PF4_IMSENDOFFLINE | PF4_OFFLINEFILES; + case PFLAG_UNIQUEIDTEXT: + case PFLAG_UNIQUEIDSETTING: + return (DWORD_PTR)"ID"; + } return 0; } @@ -90,6 +120,7 @@ int CTelegramProto::SendMsg(MCONTACT hContact, int flags, const char *msg) int CTelegramProto::SetStatus(int iNewStatus) { + if (iNewStatus == ID_STATUS_ONLINE) tgl_login(TLS); return 0; } @@ -105,5 +136,16 @@ int CTelegramProto::OnEvent(PROTOEVENTTYPE iEventType, WPARAM wParam, LPARAM lPa int CTelegramProto::OnPreShutdown(WPARAM, LPARAM) { + SaveState(); return 0; } + + +void CTelegramProto::TGLGetValue(tgl_value_type type, const char *prompt, int num_values, char **result) +{ + switch (type) + { + case tgl_phone_number: + *result = getStringA("ID"); + }; +} \ No newline at end of file -- cgit v1.2.3