Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
cTapuk committed Oct 12, 2017
1 parent 8462dc8 commit 970e6ca
Showing 1 changed file with 41 additions and 41 deletions.
82 changes: 41 additions & 41 deletions queries.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ struct query *tglq_send_query_ex (struct tgl_state *TLS, struct tgl_dc *DC, int
TLS->queries_tree = tree_insert_query (TLS->queries_tree, q, rand ());

q->ev = TLS->timer_methods->alloc (TLS, alarm_query_gateway, q);
TLS->timer_methods->insert (q->ev, q->methods->timeout ? q->methods->timeout : QUERY_TIMEOUT);
TLS->timer_methods->insert (q->ev, q->methods->timeout ? q->methods->timeout : QUERY_TIMEOUT);

q->extra = extra;
q->callback = callback;
Expand Down Expand Up @@ -1191,7 +1191,7 @@ void tgl_do_send_message (struct tgl_state *TLS, tgl_peer_id_t peer_id, const ch
if (callback) {
callback (TLS, callback_extra, 0, 0);
}
return;
return;
}
text_len = strlen (new_text);
int *save_ptr = in_ptr;
Expand All @@ -1207,9 +1207,9 @@ void tgl_do_send_message (struct tgl_state *TLS, tgl_peer_id_t peer_id, const ch
tfree (ent, 4 * ent_size);
}


bl_do_edit_message (TLS, &id, &from_id, &peer_id, NULL, NULL, &date, text, text_len, &TDSM, NULL, reply ? &reply : NULL, reply_markup, EN, TGLMF_UNREAD | TGLMF_OUT | TGLMF_PENDING | TGLMF_CREATE | TGLMF_CREATED | TGLMF_SESSION_OUTBOUND | disable_preview);

if (flags & TGLMF_HTML) {
tfree_str (new_text);
free_ds_type_any (EN, TYPE_TO_PARAM_1 (vector, TYPE_TO_PARAM (message_entity)));
Expand Down Expand Up @@ -1326,7 +1326,7 @@ static int mark_read_channels_on_receive (struct tgl_state *TLS, struct query *q

bl_do_channel (TLS, tgl_get_peer_id (E->id), NULL, NULL, NULL, 0, NULL, 0, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL,
&E->max_id, TGL_FLAGS_UNCHANGED);

if (q->callback) {
((void (*)(struct tgl_state *, void *, int))q->callback)(TLS, q->callback_extra, 1);
}
Expand Down Expand Up @@ -1354,7 +1354,7 @@ static int mark_read_on_receive (struct tgl_state *TLS, struct query *q, void *D
if (q->callback) {
((void (*)(struct tgl_state *, void *, int))q->callback)(TLS, q->callback_extra, 1);
}

tfree (E, sizeof (*E));
return 0;
}
Expand Down Expand Up @@ -1408,13 +1408,13 @@ void tgl_do_messages_mark_read (struct tgl_state *TLS, tgl_peer_id_t id, int max
out_int (CODE_input_channel);
out_int (tgl_get_peer_id (id));
out_long (id.access_hash);

out_int (max_id);

struct mark_read_extra *E = talloc (sizeof (*E));
E->id = id;
E->max_id = max_id;

tglq_send_query (TLS, TLS->DC_working, packet_ptr - packet_buffer, packet_buffer, &mark_read_channels_methods, E, callback, callback_extra);
}
}
Expand Down Expand Up @@ -1576,17 +1576,17 @@ void tgl_do_get_local_history (struct tgl_state *TLS, tgl_peer_id_t id, int offs

static void _tgl_do_get_history (struct tgl_state *TLS, struct get_history_extra *E, void (*callback)(struct tgl_state *TLS,void *callback_extra, int success, int size, struct tgl_message *list[]), void *callback_extra) {
clear_packet ();
tgl_peer_t *C = tgl_peer_get (TLS, E->id);
if (tgl_get_peer_type (E->id) != TGL_PEER_CHANNEL || (C && (C->flags & TGLCHF_MEGAGROUP))) {
//tgl_peer_t *C = tgl_peer_get (TLS, E->id);
//if (tgl_get_peer_type (E->id) != TGL_PEER_CHANNEL || (C && (C->flags & TGLCHF_MEGAGROUP))) {
out_int (CODE_messages_get_history);
out_peer_id (TLS, E->id);
} else {
out_int (CODE_channels_get_important_history);
out_int (CODE_input_channel);
out_int (tgl_get_peer_id (E->id));
out_long (E->id.access_hash);
}
//} else {
// out_int (CODE_channels_get_important_history);

// out_int (CODE_input_channel);
// out_int (tgl_get_peer_id (E->id));
// out_long (E->id.access_hash);
//}
out_int (E->max_id);
out_int (E->offset);
out_int (E->limit);
Expand Down Expand Up @@ -1692,7 +1692,7 @@ static int get_dialogs_on_answer (struct tgl_state *TLS, struct query *q, void *
E->offset += dl_size;
if (E->list_offset > 0) {
E->offset_peer = E->PL[E->list_offset - 1];

int p = E->list_offset - 1;
while (p >= 0) {
struct tgl_message *M = tgl_message_get (TLS, E->LM[p]);
Expand Down Expand Up @@ -1984,7 +1984,7 @@ static void send_file_unencrypted_end (struct tgl_state *TLS, struct send_file *
out_string ("thumb.jpg");
out_string ("");
}

out_string (f->caption ? f->caption : "");
} else {
out_string (f->caption ? f->caption : "");
Expand Down Expand Up @@ -2275,7 +2275,7 @@ int contact_search_on_answer (struct tgl_state *TLS, struct query *q, void *D) {
for (i = 0; i < DS_LVAL (DS_CRU->users->cnt); i++) {
tglf_fetch_alloc_user (TLS, DS_CRU->users->data[i]);
}

for (i = 0; i < DS_LVAL (DS_CRU->chats->cnt); i++) {
tglf_fetch_alloc_chat (TLS, DS_CRU->chats->data[i]);
}
Expand Down Expand Up @@ -2414,7 +2414,7 @@ void tgl_do_forward_messages (struct tgl_state *TLS, tgl_peer_id_t id, int n, co

ids[i] = msg_id;

if (i == 0) {
if (i == 0) {
from_id = tgl_msg_id_to_peer_id (msg_id);
} else {
if (tgl_cmp_peer_id (from_id, tgl_msg_id_to_peer_id (msg_id))) {
Expand All @@ -2427,8 +2427,8 @@ void tgl_do_forward_messages (struct tgl_state *TLS, tgl_peer_id_t id, int n, co
}
}
}


clear_packet ();
out_int (CODE_messages_forward_messages);

Expand Down Expand Up @@ -2461,7 +2461,7 @@ void tgl_do_forward_messages (struct tgl_state *TLS, tgl_peer_id_t id, int n, co
out_peer_id (TLS, id);

tglq_send_query (TLS, TLS->DC_working, packet_ptr - packet_buffer, packet_buffer, &send_msgs_methods, E, callback, callback_extra);

tfree (ids, n * sizeof (tgl_message_id_t));
}

Expand Down Expand Up @@ -2491,7 +2491,7 @@ void tgl_do_forward_message (struct tgl_state *TLS, tgl_peer_id_t peer_id, tgl_m
}
return;
}

clear_packet ();
out_int (CODE_messages_forward_message);
tgl_peer_id_t from_peer = tgl_msg_id_to_peer_id (msg_id);
Expand Down Expand Up @@ -2834,7 +2834,7 @@ void _tgl_do_channel_get_members (struct tgl_state *TLS, struct channel_get_mem

static int channels_get_members_on_answer (struct tgl_state *TLS, struct query *q, void *D) {
struct tl_ds_channels_channel_participants *DS_CP = D;

int count = DS_LVAL (DS_CP->participants->cnt);

struct channel_get_members_extra *E = q->extra;
Expand All @@ -2852,11 +2852,11 @@ static int channels_get_members_on_answer (struct tgl_state *TLS, struct query *
E->UL[E->count ++] = (void *)tgl_peer_get (TLS, TGL_MK_USER (DS_LVAL (DS_CP->participants->data[i]->user_id)));
}
E->offset += count;

if (!count || E->count == E->limit) {
((void (*)(struct tgl_state *, void *, int, int, struct tgl_user **))q->callback)(TLS, q->callback_extra, 1, E->count, E->UL);
tfree (E->UL, E->size * sizeof (void *));
tfree (E, sizeof (*E));
tfree (E, sizeof (*E));
return 0;
}
_tgl_do_channel_get_members (TLS, E, q->callback, q->callback_extra);
Expand All @@ -2868,10 +2868,10 @@ static int channels_get_members_on_error (struct tgl_state *TLS, struct query *q
if (q->callback) {
((void (*)(struct tgl_state *,void *, int, int, void *))(q->callback))(TLS, q->callback_extra, 0, 0, NULL);
}

struct channel_get_members_extra *E = q->extra;
tfree (E->UL, E->size * sizeof (void *));
tfree (E, sizeof (*E));
tfree (E, sizeof (*E));

return 0;
}
Expand Down Expand Up @@ -2905,7 +2905,7 @@ void _tgl_do_channel_get_members (struct tgl_state *TLS, struct channel_get_mem
}
out_int (E->offset);
out_int (E->limit);

tglq_send_query (TLS, TLS->DC_working, packet_ptr - packet_buffer, packet_buffer, &channels_get_members_methods, E, callback, callback_extra);
}

Expand Down Expand Up @@ -3333,7 +3333,7 @@ static void _tgl_do_load_document (struct tgl_state *TLS, struct tgl_document *V
D->dc = V->dc_id;
D->name = 0;
D->fd = -1;

if (V->mime_type) {
char *r = tg_extension_by_mime (V->mime_type);
if (r) {
Expand All @@ -3344,23 +3344,23 @@ static void _tgl_do_load_document (struct tgl_state *TLS, struct tgl_document *V
}

void tgl_do_load_document (struct tgl_state *TLS, struct tgl_document *V, void (*callback)(struct tgl_state *TLS, void *callback_extra, int success, const char *filename), void *callback_extra) {

struct download *D = talloc0 (sizeof (*D));
D->type = CODE_input_document_file_location;

_tgl_do_load_document (TLS, V, D, callback, callback_extra);
}

void tgl_do_load_video (struct tgl_state *TLS, struct tgl_document *V, void (*callback)(struct tgl_state *TLS, void *callback_extra, int success, const char *filename), void *callback_extra) {

struct download *D = talloc0 (sizeof (*D));
D->type = CODE_input_video_file_location;

_tgl_do_load_document (TLS, V, D, callback, callback_extra);
}

void tgl_do_load_audio (struct tgl_state *TLS, struct tgl_document *V, void (*callback)(struct tgl_state *TLS, void *callback_extra, int success, const char *filename), void *callback_extra) {

struct download *D = talloc0 (sizeof (*D));
D->type = CODE_input_audio_file_location;

Expand Down Expand Up @@ -3549,7 +3549,7 @@ static void _tgl_do_msg_search (struct tgl_state *TLS, struct msg_search_extra *

static int msg_search_on_answer (struct tgl_state *TLS, struct query *q, void *D) {
struct tl_ds_messages_messages *DS_MM = D;

int i;
for (i = 0; i < DS_LVAL (DS_MM->chats->cnt); i++) {
tglf_fetch_alloc_chat (TLS, DS_MM->chats->data[i]);
Expand Down Expand Up @@ -3904,7 +3904,7 @@ static struct query_methods get_channel_difference_methods = {
void tgl_do_get_channel_difference (struct tgl_state *TLS, int id, void (*callback)(struct tgl_state *tls, void *callback_extra, int success), void *callback_extra) {
tgl_peer_t *E = tgl_peer_get (TLS, TGL_MK_CHANNEL (id));

if (!E || !(E->flags & TGLPF_CREATED) || !E->channel.pts) {
if (!E || !(E->flags & TGLPF_CREATED) || !E->channel.pts) {
if (callback) {
callback (TLS, callback_extra, 0);
}
Expand All @@ -3930,7 +3930,7 @@ void tgl_do_get_channel_difference (struct tgl_state *TLS, int id, void (*callba
out_int (CODE_channel_messages_filter_empty);
out_int (E->channel.pts);
out_int (100);

tglq_send_query (TLS, TLS->DC_working, packet_ptr - packet_buffer, packet_buffer, &get_channel_difference_methods, E, callback, callback_extra);
}
/* }}} */
Expand Down Expand Up @@ -4067,7 +4067,7 @@ void tgl_do_create_channel (struct tgl_state *TLS, int users_num, tgl_peer_id_t
out_cstring (chat_topic, chat_topic_len);
out_cstring (about, about_len);
//out_int (CODE_vector);
//out_int (users_num);
//out_int (users_num);
int i;
for (i = 0; i < users_num; i++) {
tgl_peer_id_t id = ids[i];
Expand Down Expand Up @@ -4919,7 +4919,7 @@ void tgl_do_unblock_user (struct tgl_state *TLS, tgl_peer_id_t id, void (*callba
clear_packet ();

out_int (CODE_contacts_unblock);

out_int (CODE_input_user);
out_int (tgl_get_peer_id (id));
out_long (id.access_hash);
Expand Down

0 comments on commit 970e6ca

Please sign in to comment.