From d9769636bcd5d2b209c956e15eca4a81f9e677e9 Mon Sep 17 00:00:00 2001 From: vvaltman Date: Wed, 17 Jun 2015 16:47:23 +0300 Subject: [PATCH] tgl: added possiblility to send custom keyboard --- auto-static-store.c | 7 +++++++ generate.c | 1 + queries.c | 8 ++++---- tgl-inner.h | 2 ++ tgl.h | 5 ++++- 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/auto-static-store.c b/auto-static-store.c index 34b8a31c..bff0cb5f 100644 --- a/auto-static-store.c +++ b/auto-static-store.c @@ -252,4 +252,11 @@ struct paramed_type *tglf_extf_store (struct tgl_state *TLS, const char *data, i local_next_token (); return store_function_any (); } + +int tglf_store_type (struct tgl_state *TLS, const char *data, int data_len, struct paramed_type *P) { + buffer_pos = (char *)data; + buffer_end = (char *)(data + data_len); + local_next_token (); + return store_type_any (P); +} #endif diff --git a/generate.c b/generate.c index 0dc102e1..f6923c97 100644 --- a/generate.c +++ b/generate.c @@ -2355,6 +2355,7 @@ void gen_store_header (void) { printf ("struct paramed_type *tglf_extf_store (struct tgl_state *TLS, const char *data, int data_len);\n"); + printf ("int tglf_store_type (struct tgl_state *TLS, const char *work, int work_len, struct paramed_type *P);\n"); int i, j; for (i = 0; i < tn; i++) { diff --git a/queries.c b/queries.c index a5516d72..7657568e 100644 --- a/queries.c +++ b/queries.c @@ -841,7 +841,7 @@ void tgl_do_send_msg (struct tgl_state *TLS, struct tgl_message *M, void (*callb tglq_send_query (TLS, TLS->DC_working, packet_ptr - packet_buffer, packet_buffer, &msg_send_methods, x, callback, callback_extra); } -void tgl_do_send_message (struct tgl_state *TLS, tgl_peer_id_t id, const char *text, int text_len, unsigned long long flags, void (*callback)(struct tgl_state *TLS, void *callback_extra, int success, struct tgl_message *M), void *callback_extra) { +void tgl_do_send_message (struct tgl_state *TLS, tgl_peer_id_t id, const char *text, int text_len, unsigned long long flags, struct tl_ds_reply_markup *reply_markup, void (*callback)(struct tgl_state *TLS, void *callback_extra, int success, struct tgl_message *M), void *callback_extra) { if (tgl_get_peer_type (id) == TGL_PEER_ENCR_CHAT) { tgl_peer_t *P = tgl_peer_get (TLS, id); if (!P) { @@ -878,7 +878,7 @@ void tgl_do_send_message (struct tgl_state *TLS, tgl_peer_id_t id, const char *t struct tl_ds_message_media TDSM; TDSM.magic = CODE_message_media_empty; - bl_do_create_message_new (TLS, t, &TLS->our_id, &peer_type, &peer_id, NULL, NULL, &date, text, text_len, &TDSM, NULL, reply ? &reply : NULL, NULL, TGLMF_UNREAD | TGLMF_OUT | TGLMF_PENDING | TGLMF_CREATE | TGLMF_CREATED | TGLMF_SESSION_OUTBOUND | disable_preview); + bl_do_create_message_new (TLS, t, &TLS->our_id, &peer_type, &peer_id, NULL, NULL, &date, text, text_len, &TDSM, NULL, reply ? &reply : NULL, reply_markup, TGLMF_UNREAD | TGLMF_OUT | TGLMF_PENDING | TGLMF_CREATE | TGLMF_CREATED | TGLMF_SESSION_OUTBOUND | disable_preview); } else { struct tl_ds_decrypted_message_media TDSM; TDSM.magic = CODE_decrypted_message_media_empty; @@ -910,7 +910,7 @@ void tgl_do_reply_message (struct tgl_state *TLS, int reply_id, const char *text id = M->from_id; } - tgl_do_send_message (TLS, id, text, text_len, flags | TGL_SEND_MSG_FLAG_REPLY (reply_id), callback, callback_extra); + tgl_do_send_message (TLS, id, text, text_len, flags | TGL_SEND_MSG_FLAG_REPLY (reply_id), NULL, callback, callback_extra); } /* }}} */ @@ -934,7 +934,7 @@ void tgl_do_send_text (struct tgl_state *TLS, tgl_peer_id_t id, const char *file callback (TLS, callback_extra, 0, NULL); } } else { - tgl_do_send_message (TLS, id, buf, x, flags, callback, callback_extra); + tgl_do_send_message (TLS, id, buf, x, flags, NULL, callback, callback_extra); } } diff --git a/tgl-inner.h b/tgl-inner.h index c98f09aa..2ffa9327 100644 --- a/tgl-inner.h +++ b/tgl-inner.h @@ -21,11 +21,13 @@ #ifndef __TGL_INNER_H__ #define __TGL_INNER_H__ +#ifndef vlogprintf #define vlogprintf(verbosity_level,...) \ do { \ if (TLS->verbosity >= verbosity_level) { \ TLS->callback.logprintf (__VA_ARGS__); \ } \ } while (0) +#endif #endif diff --git a/tgl.h b/tgl.h index f0bb3b34..e1d9b889 100644 --- a/tgl.h +++ b/tgl.h @@ -362,9 +362,12 @@ void tgl_do_set_password (struct tgl_state *TLS, const char *hint, int hint_len, /* {{{ SENDING MESSAGES */ +struct tl_ds_reply_markup; + // send plain text message to peer id // flags is combination of TGL_SEND_MSG_FLAG_* -void tgl_do_send_message (struct tgl_state *TLS, tgl_peer_id_t id, const char *text, int text_len, unsigned long long flags, void (*callback)(struct tgl_state *TLS, void *callback_extra, int success, struct tgl_message *M), void *callback_extra); +// reply markup can be NULL +void tgl_do_send_message (struct tgl_state *TLS, tgl_peer_id_t id, const char *text, int text_len, unsigned long long flags, struct tl_ds_reply_markup *reply_markup, void (*callback)(struct tgl_state *TLS, void *callback_extra, int success, struct tgl_message *M), void *callback_extra); // sends plain text reply on message *reply_id* // message *reply_id* should be cached