Some bugfixes. Add small thumb file to sent video
This commit is contained in:
parent
143fda9e58
commit
c713d80ded
46
interface.c
46
interface.c
@ -63,10 +63,14 @@ char *next_token (int *l) {
|
||||
}
|
||||
int neg = 0;
|
||||
char *s = line_ptr;
|
||||
while (*line_ptr && (*line_ptr != ' ' || neg)) {
|
||||
int in_str = 0;
|
||||
while (*line_ptr && (*line_ptr != ' ' || neg || in_str)) {
|
||||
if (*line_ptr == '\\') {
|
||||
neg = 1 - neg;
|
||||
} else {
|
||||
if (*line_ptr == '"' && !neg) {
|
||||
in_str = !in_str;
|
||||
}
|
||||
neg = 0;
|
||||
}
|
||||
line_ptr++;
|
||||
@ -756,28 +760,12 @@ void interpreter (char *line UU) {
|
||||
|
||||
int readline_active;
|
||||
void rprintf (const char *format, ...) {
|
||||
int saved_point = 0;
|
||||
char *saved_line = 0;
|
||||
if (readline_active) {
|
||||
saved_point = rl_point;
|
||||
saved_line = rl_copy_text(0, rl_end);
|
||||
rl_save_prompt();
|
||||
rl_replace_line("", 0);
|
||||
rl_redisplay();
|
||||
}
|
||||
|
||||
print_start ();
|
||||
va_list ap;
|
||||
va_start (ap, format);
|
||||
vfprintf (stdout, format, ap);
|
||||
va_end (ap);
|
||||
|
||||
if (readline_active) {
|
||||
rl_restore_prompt();
|
||||
rl_replace_line(saved_line, 0);
|
||||
rl_point = saved_point;
|
||||
rl_redisplay();
|
||||
free(saved_line);
|
||||
}
|
||||
print_end();
|
||||
}
|
||||
|
||||
int saved_point;
|
||||
@ -833,30 +821,14 @@ void hexdump (int *in_ptr, int *in_end) {
|
||||
}
|
||||
|
||||
void logprintf (const char *format, ...) {
|
||||
int saved_point = 0;
|
||||
char *saved_line = 0;
|
||||
if (readline_active) {
|
||||
saved_point = rl_point;
|
||||
saved_line = rl_copy_text(0, rl_end);
|
||||
rl_save_prompt();
|
||||
rl_replace_line("", 0);
|
||||
rl_redisplay();
|
||||
}
|
||||
|
||||
print_start ();
|
||||
printf (COLOR_GREY " *** ");
|
||||
va_list ap;
|
||||
va_start (ap, format);
|
||||
vfprintf (stdout, format, ap);
|
||||
va_end (ap);
|
||||
printf (COLOR_NORMAL);
|
||||
|
||||
if (readline_active) {
|
||||
rl_restore_prompt();
|
||||
rl_replace_line(saved_line, 0);
|
||||
rl_point = saved_point;
|
||||
rl_redisplay();
|
||||
free(saved_line);
|
||||
}
|
||||
print_end ();
|
||||
}
|
||||
|
||||
int color_stack_pos;
|
||||
|
@ -708,8 +708,10 @@ void work_update (struct connection *c UU, long long msg_id UU) {
|
||||
int id = fetch_int (); // id
|
||||
int new = fetch_long (); // random_id
|
||||
struct message *M = message_get (new);
|
||||
if (M) {
|
||||
update_message_id (M, id);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CODE_update_read_messages:
|
||||
{
|
||||
|
40
queries.c
40
queries.c
@ -1094,8 +1094,9 @@ struct send_file {
|
||||
int part_num;
|
||||
int part_size;
|
||||
long long id;
|
||||
long long thumb_id;
|
||||
peer_id_t to_id;
|
||||
int media_type;
|
||||
unsigned media_type;
|
||||
char *file_name;
|
||||
int encr;
|
||||
unsigned char *iv;
|
||||
@ -1225,12 +1226,14 @@ void send_part (struct send_file *f) {
|
||||
} else {
|
||||
assert (f->part_size == x);
|
||||
}
|
||||
update_prompt ();
|
||||
send_query (DC_working, packet_ptr - packet_buffer, packet_buffer, &send_file_part_methods, f);
|
||||
} else {
|
||||
cur_uploaded_bytes -= f->size;
|
||||
cur_uploading_bytes -= f->size;
|
||||
update_prompt ();
|
||||
clear_packet ();
|
||||
assert (f->media_type == CODE_input_media_uploaded_photo || f->media_type == CODE_input_media_uploaded_video);
|
||||
assert (f->media_type == CODE_input_media_uploaded_photo || f->media_type == CODE_input_media_uploaded_video || f->media_type == CODE_input_media_uploaded_thumb_video);
|
||||
if (!f->encr) {
|
||||
out_int (CODE_messages_send_media);
|
||||
out_peer_id (f->to_id);
|
||||
@ -1245,8 +1248,17 @@ void send_part (struct send_file *f) {
|
||||
char *s = f->file_name + strlen (f->file_name);
|
||||
while (s >= f->file_name && *s != '/') { s --;}
|
||||
out_string (s + 1);
|
||||
if (f->size < (16 << 20)) {
|
||||
out_string ("");
|
||||
if (f->media_type == CODE_input_media_uploaded_video) {
|
||||
}
|
||||
if (f->media_type == CODE_input_media_uploaded_thumb_video) {
|
||||
out_int (CODE_input_file);
|
||||
out_long (f->thumb_id);
|
||||
out_int (1);
|
||||
out_string ("thumb.jpg");
|
||||
out_string ("");
|
||||
}
|
||||
if (f->media_type == CODE_input_media_uploaded_video || f->media_type == CODE_input_media_uploaded_thumb_video) {
|
||||
out_int (100);
|
||||
out_int (100);
|
||||
out_int (100);
|
||||
@ -1296,7 +1308,9 @@ void send_part (struct send_file *f) {
|
||||
}
|
||||
out_long (f->id);
|
||||
out_int (f->part_num);
|
||||
if (f->size < (16 << 20)) {
|
||||
out_string ("");
|
||||
}
|
||||
|
||||
unsigned char md5[16];
|
||||
unsigned char str[64];
|
||||
@ -1329,6 +1343,16 @@ void send_part (struct send_file *f) {
|
||||
}
|
||||
}
|
||||
|
||||
void send_file_thumb (struct send_file *f) {
|
||||
clear_packet ();
|
||||
f->thumb_id = lrand48 () * (1ll << 32) + lrand48 ();
|
||||
out_int (CODE_upload_save_file_part);
|
||||
out_long (f->thumb_id);
|
||||
out_int (0);
|
||||
out_cstring ((void *)thumb_file, thumb_file_size);
|
||||
send_query (DC_working, packet_ptr - packet_buffer, packet_buffer, &send_file_part_methods, f);
|
||||
}
|
||||
|
||||
void do_send_photo (int type, peer_id_t to_id, char *file_name) {
|
||||
int fd = open (file_name, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
@ -1379,7 +1403,12 @@ void do_send_photo (int type, peer_id_t to_id, char *file_name) {
|
||||
rprintf ("Too big file. Maximal supported size is %d", (512 << 10) * 1000);
|
||||
return;
|
||||
}
|
||||
if (f->media_type == CODE_input_media_uploaded_video && !f->encr) {
|
||||
f->media_type = CODE_input_media_uploaded_thumb_video;
|
||||
send_file_thumb (f);
|
||||
} else {
|
||||
send_part (f);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -1713,6 +1742,11 @@ void load_next_part (struct download *D) {
|
||||
}
|
||||
|
||||
void do_load_photo_size (struct photo_size *P, int next) {
|
||||
if (!P->loc.dc) {
|
||||
rprintf ("Bad video thumb\n");
|
||||
return;
|
||||
}
|
||||
|
||||
assert (P);
|
||||
assert (next);
|
||||
struct download *D = malloc (sizeof (*D));
|
||||
|
Loading…
Reference in New Issue
Block a user