Skip to content

Commit

Permalink
tgl: added possiblility to send custom keyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
vvaltman committed Jun 17, 2015
1 parent 73482c7 commit d976963
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
7 changes: 7 additions & 0 deletions auto-static-store.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions generate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
8 changes: 4 additions & 4 deletions queries.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
/* }}} */

Expand All @@ -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);
}
}

Expand Down
2 changes: 2 additions & 0 deletions tgl-inner.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 4 additions & 1 deletion tgl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d976963

Please sign in to comment.