summaryrefslogtreecommitdiff
path: root/protocols/Telegram/src/t_proto.cpp
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2016-03-24 10:22:48 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2016-03-24 10:22:48 +0000
commit1cba3f74c9607b7b03c85f23969cbdd4163b52d5 (patch)
treef7f505863d8a1ff0354111b2efb6fe76c187906f /protocols/Telegram/src/t_proto.cpp
parent5f3997157e81d4910bcc4659bee7124a9c744d2f (diff)
Telegram: attempt to implement login
git-svn-id: http://svn.miranda-ng.org/main/trunk@16534 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Telegram/src/t_proto.cpp')
-rw-r--r--protocols/Telegram/src/t_proto.cpp52
1 files changed, 47 insertions, 5 deletions
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 <http://www.gnu.org/licenses/>.
CTelegramProto::CTelegramProto(const char* protoName, const TCHAR* userName) : PROTO<CTelegramProto>(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