summaryrefslogtreecommitdiff
path: root/protocols/Telegram/src/t_callback.cpp
blob: 97d7eb0d1af4197f87a3022f75812bfa64f24329 (plain)
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
#include "stdafx.h"

static void update_message_handler(tgl_state *TLS, tgl_message *msg)
{
	((MirTLS*)TLS)->m_proto->OnMessage(msg);
}

static void logprintf(const char *fmt, ...)
{
	CMStringA str("[Telegram]: ");
	va_list args;
	va_start(fmt, args);
	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;

	tgl_set_callback(TLS, &cb);

}