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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
#ifndef _EASY_TG_H
#define _EASY_TG_H
#define TG_IGNORE -1 /* Invalid update received. Just ignore it. */
#define TG_RUN 0 /* Normal update received. */
#define TG_CLOSED 1 /* TDLib closed. */
#define TG_CLOSING 2 /* TDLib is closing. */
#define TG_LOGGING_OUT 3 /* Logging out. */
#define TG_LOGGED_IN 4 /* Login ready. */
#define TG_LOGIN_PHONE 5 /* Need to input phone number. */
#define TG_LOGIN_CODE 6 /* Need to input verification code. */
#define TG_LOGIN_ENC 7 /* Need to provide encryption key. */
#define TG_LOGIN_QR 8 /* Need to scan the QR code. r1 = link. */
#define TG_LOGIN_PW 9 /* Need to input the password. */
#define TG_LOGIN_REG 10 /* Need to register. */
#define TG_PARAMS 11 /* Need to provide TDLib parameters. */
#define TG_ERROR 12 /* TDLib returns an error. tg_errno = code, r1 = extra, r2 = msg. */
#define TG_SYSERR 13 /* EasyTD encounters an error. */
#define TG_CONNECTION 14 /* Telegram connection state update. tg_errno = code, r1 = raw type */
#define TG_REQ_SET_PARAMS "set_params"
#define TG_REQ_LOGIN_PHONE "login_phone"
#define TG_REQ_LOGIN_CODE "login_code"
#define TG_REQ_LOGIN_PASS "login_pass"
#define TG_CONNECTION_CONNECTING 1
#define TG_CONNECTION_CONNECTING_PROXY 2
#define TG_CONNECTION_READY 3
#define TG_CONNECTION_UPDATING 4
#define TG_CONNECTION_WAITING_NETWORK 5
#include <json-c/json_object.h>
#include <stdint.h>
#include <stdbool.h>
extern void *td;
extern const char *tg_update_type;
extern json_object *tg_update;
extern int tg_errno;
extern const void *tg_reg1;
extern const void *tg_reg2;
extern const void *tg_reg3;
extern const void *tg_reg4;
extern const void *tg_reg5;
extern const void *tg_reg6;
/* MT-Unsafe */
int tg_init();
/* MT-Unsafe */
int tg_destroy();
/* MT-Unsafe */
int tg_loop();
/* MT-Safe */
int tg_close();
/* MT-Safe */
int tg_logout();
/* MT-Safe */
int tg_set_params(
const bool use_test_dc,
const char *database_directory,
const char *files_directory,
const bool use_file_database,
const bool use_message_database,
const bool use_chat_info_database,
const bool use_secret_chats,
const int32_t api_id,
const char *api_hash,
const char *system_language_code,
const char *device_model,
const char *system_version,
const char *application_version,
const bool enable_storage_optimizer,
const bool ignore_file_names
);
/* MT-Safe */
int tg_login_phone(
const char *phone_number
);
/* MT-Safe */
int tg_login_code(
const char *code
);
/* MT-Safe */
int tg_login_pass(
const char *password
);
/* MT-Safe */
int tg_login_enc_key(
const char *encryption_key
);
/* MT-Safe */
json_object *tg_mkreq(
const char *extra,
const char *type,
const char *args_key,
json_object *args
);
/* MT-Safe */
int tg_send(
bool execute,
json_object *req,
const bool dispose
);
/* MT-Safe */
int tg_send_raw(
bool execute,
const char *req
);
#endif /* _EASY_TG_H */
|