Commit fd8a13ec authored by vysheng's avatar vysheng

Merge github.com:vysheng/tg

parents 9dacff9d 3755d426
This diff is collapsed.
......@@ -454,7 +454,7 @@ const char *message_media_type_str (struct message_media *M) {
case CODE_message_media_video:
return "[video]";
case CODE_message_media_geo:
sprintf (buf, "[geo] %.6lf:%.6lf", M->geo.latitude, M->geo.longitude);
sprintf (buf, "[geo] https://maps.google.com/maps?ll=%.6lf,%.6lf", M->geo.latitude, M->geo.longitude);
return buf;
case CODE_message_media_contact:
snprintf (buf, 999, "[contact] " COLOR_RED "%s %s" COLOR_NORMAL " %s", M->first_name, M->last_name, M->phone);
......@@ -502,8 +502,7 @@ void print_media (struct message_media *M) {
printf ("[video]");
return;
case CODE_message_media_geo:
printf ("[geo] ");
printf ("%.6lf:%.6lf", M->geo.latitude, M->geo.longitude);
printf ("[geo] https://maps.google.com/?q=%.6lf,%.6lf", M->geo.latitude, M->geo.longitude);
return;
case CODE_message_media_contact:
printf ("[contact] ");
......
......@@ -1153,6 +1153,9 @@ int rpc_execute (struct connection *c, int op, int len) {
int Response_len = len;
if (verbosity >= 2) {
logprintf ("Response_len = %d\n", Response_len);
}
assert (read_in (c, Response, Response_len) == Response_len);
Response[Response_len] = 0;
if (verbosity >= 2) {
......
......@@ -298,12 +298,12 @@ void try_rpc_read (struct connection *c) {
unsigned t = 0;
assert (read_in_lookup (c, &len, 1) == 1);
if (len >= 1 && len <= 0x7e) {
if (c->in_bytes < (int)(4 * len)) { return; }
if (c->in_bytes < (int)(1 + 4 * len)) { return; }
} else {
if (c->in_bytes < 4) { return; }
assert (read_in_lookup (c, &len, 4) == 4);
len = (len >> 8);
if (c->in_bytes < (int)(4 * len)) { return; }
if (c->in_bytes < (int)(4 + 4 * len)) { return; }
len = 0x7f;
}
......
......@@ -56,6 +56,9 @@ struct query *query_get (long long id) {
int alarm_query (struct query *q) {
assert (q);
if (verbosity) {
logprintf ("Alarm query %lld\n", q->msg_id);
}
q->ev.timeout = get_double_time () + QUERY_TIMEOUT;
insert_event_timer (&q->ev);
return 0;
......@@ -541,6 +544,39 @@ void do_send_text (union user_chat *U, char *file_name) {
}
}
int mark_read_on_receive (struct query *q UU) {
assert (fetch_int () == (int)CODE_messages_affected_history);
fetch_int (); // pts
fetch_int (); // seq
fetch_int (); // offset
return 0;
}
struct query_methods mark_read_methods = {
.on_answer = mark_read_on_receive
};
void do_messages_mark_read (union user_chat *U, int max_id) {
clear_packet ();
out_int (CODE_messages_read_history);
if (U->id < 0) {
out_int (CODE_input_peer_chat);
out_int (-U->id);
} else {
if (U->user.access_hash) {
out_int (CODE_input_peer_foreign);
out_int (U->id);
out_long (U->user.access_hash);
} else {
out_int (CODE_input_peer_contact);
out_int (U->id);
}
}
out_int (max_id);
out_int (0);
send_query (DC_working, packet_ptr - packet_buffer, packet_buffer, &mark_read_methods, 0);
}
int get_history_on_answer (struct query *q UU) {
static struct message *ML[10000];
int i;
......@@ -560,6 +596,7 @@ int get_history_on_answer (struct query *q UU) {
}
}
if (n > 10000) { n = 10000; }
int sn = n;
for (i = n - 1; i >= 0; i--) {
print_message (ML[i]);
}
......@@ -573,6 +610,9 @@ int get_history_on_answer (struct query *q UU) {
for (i = 0; i < n; i++) {
fetch_alloc_user ();
}
if (sn > 0) {
do_messages_mark_read (q->extra, ML[0]->id);
}
return 0;
}
......@@ -600,7 +640,7 @@ void do_get_history (union user_chat *U, int limit) {
out_int (0);
out_int (0);
out_int (limit);
send_query (DC_working, packet_ptr - packet_buffer, packet_buffer, &get_history_methods, 0);
send_query (DC_working, packet_ptr - packet_buffer, packet_buffer, &get_history_methods, U);
}
int get_dialogs_on_answer (struct query *q UU) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment