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;
|
int neg = 0;
|
||||||
char *s = line_ptr;
|
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 == '\\') {
|
if (*line_ptr == '\\') {
|
||||||
neg = 1 - neg;
|
neg = 1 - neg;
|
||||||
} else {
|
} else {
|
||||||
|
if (*line_ptr == '"' && !neg) {
|
||||||
|
in_str = !in_str;
|
||||||
|
}
|
||||||
neg = 0;
|
neg = 0;
|
||||||
}
|
}
|
||||||
line_ptr++;
|
line_ptr++;
|
||||||
@ -756,28 +760,12 @@ void interpreter (char *line UU) {
|
|||||||
|
|
||||||
int readline_active;
|
int readline_active;
|
||||||
void rprintf (const char *format, ...) {
|
void rprintf (const char *format, ...) {
|
||||||
int saved_point = 0;
|
print_start ();
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start (ap, format);
|
va_start (ap, format);
|
||||||
vfprintf (stdout, format, ap);
|
vfprintf (stdout, format, ap);
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
|
print_end();
|
||||||
if (readline_active) {
|
|
||||||
rl_restore_prompt();
|
|
||||||
rl_replace_line(saved_line, 0);
|
|
||||||
rl_point = saved_point;
|
|
||||||
rl_redisplay();
|
|
||||||
free(saved_line);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int saved_point;
|
int saved_point;
|
||||||
@ -833,30 +821,14 @@ void hexdump (int *in_ptr, int *in_end) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void logprintf (const char *format, ...) {
|
void logprintf (const char *format, ...) {
|
||||||
int saved_point = 0;
|
print_start ();
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
printf (COLOR_GREY " *** ");
|
printf (COLOR_GREY " *** ");
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start (ap, format);
|
va_start (ap, format);
|
||||||
vfprintf (stdout, format, ap);
|
vfprintf (stdout, format, ap);
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
printf (COLOR_NORMAL);
|
printf (COLOR_NORMAL);
|
||||||
|
print_end ();
|
||||||
if (readline_active) {
|
|
||||||
rl_restore_prompt();
|
|
||||||
rl_replace_line(saved_line, 0);
|
|
||||||
rl_point = saved_point;
|
|
||||||
rl_redisplay();
|
|
||||||
free(saved_line);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int color_stack_pos;
|
int color_stack_pos;
|
||||||
|
@ -708,7 +708,9 @@ void work_update (struct connection *c UU, long long msg_id UU) {
|
|||||||
int id = fetch_int (); // id
|
int id = fetch_int (); // id
|
||||||
int new = fetch_long (); // random_id
|
int new = fetch_long (); // random_id
|
||||||
struct message *M = message_get (new);
|
struct message *M = message_get (new);
|
||||||
update_message_id (M, id);
|
if (M) {
|
||||||
|
update_message_id (M, id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CODE_update_read_messages:
|
case CODE_update_read_messages:
|
||||||
|
46
queries.c
46
queries.c
@ -1094,8 +1094,9 @@ struct send_file {
|
|||||||
int part_num;
|
int part_num;
|
||||||
int part_size;
|
int part_size;
|
||||||
long long id;
|
long long id;
|
||||||
|
long long thumb_id;
|
||||||
peer_id_t to_id;
|
peer_id_t to_id;
|
||||||
int media_type;
|
unsigned media_type;
|
||||||
char *file_name;
|
char *file_name;
|
||||||
int encr;
|
int encr;
|
||||||
unsigned char *iv;
|
unsigned char *iv;
|
||||||
@ -1225,12 +1226,14 @@ void send_part (struct send_file *f) {
|
|||||||
} else {
|
} else {
|
||||||
assert (f->part_size == x);
|
assert (f->part_size == x);
|
||||||
}
|
}
|
||||||
|
update_prompt ();
|
||||||
send_query (DC_working, packet_ptr - packet_buffer, packet_buffer, &send_file_part_methods, f);
|
send_query (DC_working, packet_ptr - packet_buffer, packet_buffer, &send_file_part_methods, f);
|
||||||
} else {
|
} else {
|
||||||
cur_uploaded_bytes -= f->size;
|
cur_uploaded_bytes -= f->size;
|
||||||
cur_uploading_bytes -= f->size;
|
cur_uploading_bytes -= f->size;
|
||||||
|
update_prompt ();
|
||||||
clear_packet ();
|
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) {
|
if (!f->encr) {
|
||||||
out_int (CODE_messages_send_media);
|
out_int (CODE_messages_send_media);
|
||||||
out_peer_id (f->to_id);
|
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);
|
char *s = f->file_name + strlen (f->file_name);
|
||||||
while (s >= f->file_name && *s != '/') { s --;}
|
while (s >= f->file_name && *s != '/') { s --;}
|
||||||
out_string (s + 1);
|
out_string (s + 1);
|
||||||
out_string ("");
|
if (f->size < (16 << 20)) {
|
||||||
if (f->media_type == CODE_input_media_uploaded_video) {
|
out_string ("");
|
||||||
|
}
|
||||||
|
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);
|
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_long (f->id);
|
||||||
out_int (f->part_num);
|
out_int (f->part_num);
|
||||||
out_string ("");
|
if (f->size < (16 << 20)) {
|
||||||
|
out_string ("");
|
||||||
|
}
|
||||||
|
|
||||||
unsigned char md5[16];
|
unsigned char md5[16];
|
||||||
unsigned char str[64];
|
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) {
|
void do_send_photo (int type, peer_id_t to_id, char *file_name) {
|
||||||
int fd = open (file_name, O_RDONLY);
|
int fd = open (file_name, O_RDONLY);
|
||||||
if (fd < 0) {
|
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);
|
rprintf ("Too big file. Maximal supported size is %d", (512 << 10) * 1000);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
send_part (f);
|
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) {
|
void do_load_photo_size (struct photo_size *P, int next) {
|
||||||
|
if (!P->loc.dc) {
|
||||||
|
rprintf ("Bad video thumb\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
assert (P);
|
assert (P);
|
||||||
assert (next);
|
assert (next);
|
||||||
struct download *D = malloc (sizeof (*D));
|
struct download *D = malloc (sizeof (*D));
|
||||||
|
Loading…
Reference in New Issue
Block a user