aboutsummaryrefslogtreecommitdiff
path: root/easy-tg.h
diff options
context:
space:
mode:
authorTrumeet <yuuta@yuuta.moe>2021-10-11 00:31:10 -0700
committerTrumeet <yuuta@yuuta.moe>2021-10-11 00:31:10 -0700
commit8e1fcfd0dd7dc8fa9f5450253d12e89dfafdd855 (patch)
tree2abe9bc29104bc518ba2c17afbe880ca1b6cb944 /easy-tg.h
downloadeasy-tg-8e1fcfd0dd7dc8fa9f5450253d12e89dfafdd855.tar
easy-tg-8e1fcfd0dd7dc8fa9f5450253d12e89dfafdd855.tar.gz
easy-tg-8e1fcfd0dd7dc8fa9f5450253d12e89dfafdd855.tar.bz2
easy-tg-8e1fcfd0dd7dc8fa9f5450253d12e89dfafdd855.zip
First Commit
Diffstat (limited to 'easy-tg.h')
-rw-r--r--easy-tg.h103
1 files changed, 103 insertions, 0 deletions
diff --git a/easy-tg.h b/easy-tg.h
new file mode 100644
index 0000000..fd66314
--- /dev/null
+++ b/easy-tg.h
@@ -0,0 +1,103 @@
+#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. td_errno = code, r1 = extra, r2 = msg. */
+#define TG_SYSERR 13 /* EasyTD encounters an error. */
+
+#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"
+
+#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 */