Commit c9346a75 authored by Vysheng's avatar Vysheng

Fixed bug in document loading

parent 25922000
......@@ -43,7 +43,7 @@
#include "mtproto-common.h"
//#define ALLOW_MULT 1
#define ALLOW_MULT 1
char *default_prompt = "> ";
int unread_messages;
......@@ -994,7 +994,7 @@ void interpreter (char *line UU) {
}
struct message *M = message_get (num);
if (M && !M->service && M->media.type == (int)CODE_message_media_document) {
do_load_video_thumb (&M->media.video, 1);
do_load_document_thumb (&M->media.document, 1);
} else {
printf ("Bad msg id\n");
RET;
......@@ -1007,7 +1007,7 @@ void interpreter (char *line UU) {
}
struct message *M = message_get (num);
if (M && !M->service && M->media.type == (int)CODE_message_media_document) {
do_load_video_thumb (&M->media.video, 2);
do_load_document_thumb (&M->media.document, 2);
} else {
printf ("Bad msg id\n");
RET;
......@@ -1020,7 +1020,7 @@ void interpreter (char *line UU) {
}
struct message *M = message_get (num);
if (M && !M->service && M->media.type == (int)CODE_message_media_document) {
do_load_video (&M->media.video, 1);
do_load_document (&M->media.document, 1);
} else if (M && !M->service && M->media.type == (int)CODE_decrypted_message_media_document) {
do_load_encr_video (&M->media.encr_video, 1);
} else {
......@@ -1035,7 +1035,7 @@ void interpreter (char *line UU) {
}
struct message *M = message_get (num);
if (M && !M->service && M->media.type == (int)CODE_message_media_document) {
do_load_video (&M->media.video, 2);
do_load_document (&M->media.document, 2);
} else if (M && !M->service && M->media.type == (int)CODE_decrypted_message_media_document) {
do_load_encr_video (&M->media.encr_video, 2);
} else {
......
......@@ -1758,6 +1758,7 @@ struct download {
long long id;
unsigned char *iv;
unsigned char *key;
int type;
};
......@@ -1861,7 +1862,7 @@ void load_next_part (struct download *D) {
if (D->iv) {
out_int (CODE_input_encrypted_file_location);
} else {
out_int (CODE_input_video_file_location);
out_int (D->type);
}
out_long (D->id);
out_long (D->access_hash);
......@@ -1913,6 +1914,10 @@ void do_load_video_thumb (struct video *video, int next) {
do_load_photo_size (&video->thumb, next);
}
void do_load_document_thumb (struct document *video, int next) {
do_load_photo_size (&video->thumb, next);
}
void do_load_video (struct video *V, int next) {
assert (V);
assert (next);
......@@ -1926,6 +1931,24 @@ void do_load_video (struct video *V, int next) {
D->next = next;
D->name = 0;
D->fd = -1;
D->type = CODE_input_video_file_location;
load_next_part (D);
}
void do_load_document (struct document *V, int next) {
assert (V);
assert (next);
struct download *D = malloc (sizeof (*D));
memset (D, 0, sizeof (*D));
D->offset = 0;
D->size = V->size;
D->id = V->id;
D->access_hash = V->access_hash;
D->dc = V->dc_id;
D->next = next;
D->name = 0;
D->fd = -1;
D->type = CODE_input_document_file_location;
load_next_part (D);
}
......
......@@ -90,6 +90,8 @@ struct video;
void do_load_photo (struct photo *photo, int next);
void do_load_video_thumb (struct video *video, int next);
void do_load_video (struct video *V, int next);
void do_load_document (struct document *V, int next);
void do_load_document_thumb (struct document *video, int next);
void do_help_get_config (void);
int do_auth_check_phone (const char *user);
int do_get_nearest_dc (void);
......
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