1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
#include "stdafx.h"
static void update_message_handler(tgl_state *TLS, tgl_message *msg)
{
((MirTLS*)TLS)->m_proto->OnMessage(msg);
}
static void user_typing(tgl_state *TLS, tgl_user *U, enum tgl_typing_status status)
{
((MirTLS*)TLS)->m_proto->OnUserTyping(U, status);
}
static void on_login_success(tgl_state *TLS)
{
// write_auth_file(TLS);
}
static void on_login_failed(tgl_state *TLS)
{
}
static void on_ready(tgl_state *TLS)
{
tgl_do_update_contact_list(TLS, 0, 0);
}
void request_value(struct tgl_state *TLS, enum tgl_value_type type, const char *prompt, int num_values,
void(*callback) (struct tgl_state *TLS, const char *string[], void *arg), void *arg)
{
char *result = nullptr;
((MirTLS*)TLS)->m_proto->TGLGetValue(type, prompt, num_values, &result);
callback(TLS, (const char**)&result, arg);
}
static void logprintf(const char *fmt, ...)
{
CMStringA str("[Telegram]: ");
va_list args;
va_start(args, fmt);
str.AppendFormatV(fmt, args);
va_end(args);
CallService(MS_NETLIB_LOG, 0, (LPARAM)str.GetString());
}
void CTelegramProto::InitCallbacks()
{
tgl_update_callback cb = { 0 };
cb.new_msg = update_message_handler;
cb.msg_receive = update_message_handler;
cb.logprintf = logprintf;
cb.type_notification = user_typing;
cb.logged_in = on_login_success;
cb.started = on_ready;
cb.get_values = request_value;
tgl_set_callback(TLS, &cb);
}
|