Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tg
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
tg
Commits
d3780ebe
Commit
d3780ebe
authored
Aug 13, 2014
by
vysheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mant fixes. Sometimes work now
parent
8dd17ec6
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
276 additions
and
31 deletions
+276
-31
Makefile.in
Makefile.in
+1
-1
append.tl
append.tl
+2
-0
binlog.c
binlog.c
+62
-6
binlog.h
binlog.h
+1
-0
binlog.tl
binlog.tl
+3
-2
interface.c
interface.c
+45
-6
mtproto-client.c
mtproto-client.c
+19
-0
queries.c
queries.c
+64
-4
queries.h
queries.h
+1
-0
scheme.tl
scheme.tl
+1
-1
structures.c
structures.c
+67
-10
structures.h
structures.h
+10
-1
No files found.
Makefile.in
View file @
d3780ebe
...
...
@@ -62,7 +62,7 @@ ${EXE}/generate: ${GENERATE_OBJECTS} ${COMMON_OBJECTS}
${AUTO}/scheme.tlo
:
${AUTO}/scheme.tl ${EXE}/tlc
${
EXE
}
/tlc
-e
$@
${
AUTO
}
/scheme.tl
${AUTO}/scheme.tl
:
${srcdir}/scheme.tl ${srcdir}/binlog.tl
${AUTO}/scheme.tl
:
${srcdir}/scheme.tl ${srcdir}/binlog.tl
${srcdir}/append.tl
cat
$^
>
$@
${AUTO}/scheme2.tl
:
${AUTO}/scheme.tl ${EXE}/tlc
...
...
append.tl
0 → 100644
View file @
d3780ebe
decryptedMessageMediaVideoL12#4cee6ef3 thumb:bytes thumb_w:int thumb_h:int duration:int w:int h:int size:int key:bytes iv:bytes = DecryptedMessageMedia;
decryptedMessageMediaAudioL12#6080758f duration:int size:int key:bytes iv:bytes = DecryptedMessageMedia;
binlog.c
View file @
d3780ebe
...
...
@@ -159,7 +159,7 @@ int fetch_comb_binlog_set_pts (void *extra) {
int
fetch_comb_binlog_set_qts
(
void
*
extra
)
{
int
new_qts
=
fetch_int
();
assert
(
new_qts
>=
qts
);
//
assert (new_qts >= qts);
qts
=
new_qts
;
return
0
;
}
...
...
@@ -468,8 +468,8 @@ int fetch_comb_binlog_encr_chat_accepted (void *extra) {
U
->
nonce
=
talloc
(
256
);
}
fetch_ints
(
U
->
g_key
,
256
);
fetch_ints
(
U
->
nonce
,
256
);
fetch_ints
(
U
->
g_key
,
64
);
fetch_ints
(
U
->
nonce
,
64
);
U
->
key_fingerprint
=
fetch_long
();
if
(
U
->
state
==
sc_waiting
)
{
...
...
@@ -509,6 +509,7 @@ int fetch_comb_binlog_encr_chat_init (void *extra) {
P
->
print_name
=
create_print_name
(
P
->
id
,
"!"
,
Us
->
user
.
first_name
,
Us
->
user
.
last_name
,
0
);
peer_insert_name
(
P
);
P
->
encr_chat
.
g_key
=
talloc
(
256
);
fetch_ints
(
P
->
encr_chat
.
key
,
64
);
fetch_ints
(
P
->
encr_chat
.
g_key
,
64
);
P
->
flags
|=
FLAG_CREATED
;
...
...
@@ -810,6 +811,43 @@ int fetch_comb_binlog_send_message_text (void *extra) {
return
0
;
}
int
fetch_comb_binlog_send_message_action_encr
(
void
*
extra
)
{
long
long
id
=
fetch_long
();
struct
message
*
M
=
message_get
(
id
);
if
(
!
M
)
{
M
=
talloc0
(
sizeof
(
*
M
));
M
->
id
=
id
;
message_insert_tree
(
M
);
messages_allocated
++
;
}
else
{
assert
(
!
(
M
->
flags
&
FLAG_CREATED
));
}
M
->
flags
|=
FLAG_CREATED
|
FLAG_ENCRYPTED
;
M
->
from_id
=
MK_USER
(
fetch_int
());
int
t
=
fetch_int
();
M
->
to_id
=
set_peer_id
(
t
,
fetch_int
());
M
->
date
=
fetch_int
();
M
->
media
.
type
=
CODE_decrypted_message_media_empty
;
fetch_message_action_encrypted
((
void
*
)
user_chat_get
(
M
->
to_id
),
&
M
->
action
);
M
->
unread
=
1
;
M
->
out
=
get_peer_id
(
M
->
from_id
)
==
our_id
;
M
->
service
=
1
;
message_insert
(
M
);
message_insert_unsent
(
M
);
M
->
flags
|=
FLAG_PENDING
;
#ifdef USE_LUA
lua_new_msg
(
M
);
#endif
return
0
;
}
int
fetch_comb_binlog_create_message_text_fwd
(
void
*
extra
)
{
long
long
id
=
fetch_int
();
...
...
@@ -894,7 +932,7 @@ int fetch_comb_binlog_create_message_media (void *extra) {
}
int
fetch_comb_binlog_create_message_media_encr
(
void
*
extra
)
{
int
id
=
fetch_int
();
long
long
id
=
fetch_long
();
struct
message
*
M
=
message_get
(
id
);
if
(
!
M
)
{
M
=
talloc0
(
sizeof
(
*
M
));
...
...
@@ -995,7 +1033,7 @@ int fetch_comb_binlog_create_message_service (void *extra) {
}
int
fetch_comb_binlog_create_message_service_encr
(
void
*
extra
)
{
int
id
=
fetch_int
();
long
long
id
=
fetch_long
();
struct
message
*
M
=
message_get
(
id
);
if
(
!
M
)
{
M
=
talloc0
(
sizeof
(
*
M
));
...
...
@@ -1008,10 +1046,14 @@ int fetch_comb_binlog_create_message_service_encr (void *extra) {
M
->
flags
|=
FLAG_CREATED
|
FLAG_ENCRYPTED
;
M
->
from_id
=
MK_USER
(
fetch_int
());
int
t
=
fetch_int
();
assert
(
t
==
PEER_ENCR_CHAT
);
M
->
to_id
=
set_peer_id
(
t
,
fetch_int
());
M
->
date
=
fetch_int
();
fetch_message_action_encrypted
(
&
M
->
action
);
struct
secret_chat
*
E
=
(
void
*
)
user_chat_get
(
M
->
to_id
);
assert
(
E
);
fetch_message_action_encrypted
(
0
,
&
M
->
action
);
M
->
unread
=
1
;
M
->
out
=
get_peer_id
(
M
->
from_id
)
==
our_id
;
M
->
service
=
1
;
...
...
@@ -1187,6 +1229,7 @@ void replay_log_event (void) {
FETCH_COMBINATOR_FUNCTION
(
binlog_create_message_text
)
FETCH_COMBINATOR_FUNCTION
(
binlog_send_message_text
)
FETCH_COMBINATOR_FUNCTION
(
binlog_send_message_action_encr
)
FETCH_COMBINATOR_FUNCTION
(
binlog_create_message_text_fwd
)
FETCH_COMBINATOR_FUNCTION
(
binlog_create_message_media
)
FETCH_COMBINATOR_FUNCTION
(
binlog_create_message_media_encr
)
...
...
@@ -1775,6 +1818,18 @@ void bl_do_send_message_text (long long msg_id, int from_id, int to_type, int to
add_log_event
(
packet_buffer
,
4
*
(
packet_ptr
-
packet_buffer
));
}
void
bl_do_send_message_action_encr
(
long
long
msg_id
,
int
from_id
,
int
to_type
,
int
to_id
,
int
date
,
int
l
,
const
int
*
action
)
{
clear_packet
();
out_int
(
CODE_binlog_send_message_action_encr
);
out_long
(
msg_id
);
out_int
(
from_id
);
out_int
(
to_type
);
out_int
(
to_id
);
out_int
(
date
);
out_ints
(
action
,
l
);
add_log_event
(
packet_buffer
,
4
*
(
packet_ptr
-
packet_buffer
));
}
void
bl_do_create_message_text_fwd
(
int
msg_id
,
int
from_id
,
int
to_type
,
int
to_id
,
int
date
,
int
fwd
,
int
fwd_date
,
int
l
,
const
char
*
s
)
{
clear_packet
();
out_int
(
CODE_binlog_create_message_text_fwd
);
...
...
@@ -1842,6 +1897,7 @@ void bl_do_create_message_service (int msg_id, int from_id, int to_type, int to_
out_ints
(
data
,
len
);
add_log_event
(
packet_buffer
,
4
*
(
packet_ptr
-
packet_buffer
));
}
void
bl_do_create_message_service_encr
(
long
long
msg_id
,
int
from_id
,
int
to_type
,
int
to_id
,
int
date
,
const
int
*
data
,
int
len
)
{
clear_packet
();
out_int
(
CODE_binlog_create_message_service_encr
);
...
...
binlog.h
View file @
d3780ebe
...
...
@@ -81,6 +81,7 @@ void bl_do_create_message_media_fwd (int msg_id, int from_id, int to_type, int t
void
bl_do_create_message_media_encr
(
long
long
msg_id
,
int
from_id
,
int
to_type
,
int
to_id
,
int
date
,
int
l
,
const
char
*
s
,
const
int
*
data
,
int
len
,
const
int
*
data2
,
int
len2
);
void
bl_do_create_message_service_encr
(
long
long
msg_id
,
int
from_id
,
int
to_type
,
int
to_id
,
int
date
,
const
int
*
data
,
int
len
);
void
bl_do_send_message_text
(
long
long
msg_id
,
int
from_id
,
int
to_type
,
int
to_id
,
int
date
,
int
l
,
const
char
*
s
);
void
bl_do_send_message_action_encr
(
long
long
msg_id
,
int
from_id
,
int
to_type
,
int
to_id
,
int
date
,
int
l
,
const
int
*
s
);
void
bl_do_set_unread
(
struct
message
*
M
,
int
unread
);
void
bl_do_set_message_sent
(
struct
message
*
M
);
void
bl_do_set_msg_id
(
struct
message
*
M
,
int
id
);
...
...
binlog.tl
View file @
d3780ebe
...
...
@@ -52,12 +52,13 @@ binlog.chatDelParticipant id:int version:int user:int = binlog.Update;
binlog.createMessageText id:int from_id:int to_type:int to_id:int date:int text:string = binlog.Update;
binlog.sendMessageText id:long from_id:int to_type:int to_id:int date:int text:string = binlog.Update;
binlog.sendMessageActionEncr id:long from_id:int to_type:int to_id:int date:int action:DecryptedMessageAction = binlog.Update;
binlog.createMessageTextFwd id:int from_id:int to_type:int to_id:int date:int fwd_from_id:int fwd_date:int text:string = binlog.Update;
binlog.createMessageMedia id:int from_id:int to_type:int to_id:int date:int text:string media:MessageMedia = binlog.Update;
binlog.createMessageMediaEncr id:
int
from_id:int to_type:int to_id:int date:int text:string media:DecryptedMessageMedia file:EncryptedFile = binlog.Update;
binlog.createMessageMediaEncr id:
long
from_id:int to_type:int to_id:int date:int text:string media:DecryptedMessageMedia file:EncryptedFile = binlog.Update;
binlog.createMessageMediaFwd id:int from_id:int to_type:int to_id:int date:int fwd_from_id:int fwd_date:int text:string media:MessageMedia = binlog.Update;
binlog.createMessageService id:int from_id:int to_type:int to_id:int date:int action:MessageAction = binlog.Update;
binlog.createMessageServiceEncr id:
int
from_id:int to_type:int to_id:int date:int action:DecryptedMessageAction = binlog.Update;
binlog.createMessageServiceEncr id:
long
from_id:int to_type:int to_id:int date:int action:DecryptedMessageAction = binlog.Update;
binlog.createMessageServiceFwd id:int from_id:int to_type:int to_id:int date:int fwd_from_id:int fwd_date:int action:MessageAction = binlog.Update;
binlog.messageSetUnread id:int = binlog.Update;
binlog.setMessageSent id:long = binlog.Update;
...
...
interface.c
View file @
d3780ebe
...
...
@@ -77,6 +77,20 @@ int is_same_word (const char *s, size_t l, const char *word) {
return
s
&&
word
&&
strlen
(
word
)
==
l
&&
!
memcmp
(
s
,
word
,
l
);
}
char
*
end_string_token
(
int
*
l
)
{
while
(
*
line_ptr
==
' '
)
{
line_ptr
++
;
}
if
(
!*
line_ptr
)
{
*
l
=
0
;
return
0
;
}
char
*
s
=
line_ptr
;
while
(
*
line_ptr
)
{
line_ptr
++
;
}
while
(
*
line_ptr
==
' '
||
!*
line_ptr
)
{
line_ptr
--
;
}
line_ptr
++
;
*
l
=
line_ptr
-
s
;
return
s
;
}
char
*
next_token
(
int
*
l
)
{
while
(
*
line_ptr
==
' '
)
{
line_ptr
++
;
}
if
(
!*
line_ptr
)
{
...
...
@@ -683,7 +697,7 @@ void interpreter (char *line UU) {
}
else
if
(
IS_WORD
(
"send_photo"
))
{
GET_PEER
;
int
t
;
char
*
s
=
next
_token
(
&
t
);
char
*
s
=
end_string
_token
(
&
t
);
if
(
!
s
)
{
printf
(
"Empty file name
\n
"
);
RET
;
...
...
@@ -692,7 +706,7 @@ void interpreter (char *line UU) {
}
else
if
(
IS_WORD
(
"send_video"
))
{
GET_PEER
;
int
t
;
char
*
s
=
next
_token
(
&
t
);
char
*
s
=
end_string
_token
(
&
t
);
if
(
!
s
)
{
printf
(
"Empty file name
\n
"
);
RET
;
...
...
@@ -969,7 +983,7 @@ void interpreter (char *line UU) {
}
else
if
(
IS_WORD
(
"send_audio"
))
{
GET_PEER
;
int
t
;
char
*
s
=
next
_token
(
&
t
);
char
*
s
=
end_string
_token
(
&
t
);
if
(
!
s
)
{
printf
(
"Empty file name
\n
"
);
RET
;
...
...
@@ -978,7 +992,7 @@ void interpreter (char *line UU) {
}
else
if
(
IS_WORD
(
"send_document"
))
{
GET_PEER
;
int
t
;
char
*
s
=
next
_token
(
&
t
);
char
*
s
=
end_string
_token
(
&
t
);
if
(
!
s
)
{
printf
(
"Empty file name
\n
"
);
RET
;
...
...
@@ -1236,10 +1250,18 @@ void print_media (struct message_media *M) {
}
return
;
case
CODE_message_media_video
:
if
(
M
->
video
.
mime_type
)
{
printf
(
"[video: type %s]"
,
M
->
video
.
mime_type
);
}
else
{
printf
(
"[video]"
);
}
return
;
case
CODE_message_media_audio
:
if
(
M
->
audio
.
mime_type
)
{
printf
(
"[audio: type %s]"
,
M
->
audio
.
mime_type
);
}
else
{
printf
(
"[audio]"
);
}
return
;
case
CODE_message_media_document
:
if
(
M
->
document
.
mime_type
&&
M
->
document
.
caption
)
{
...
...
@@ -1252,9 +1274,11 @@ void print_media (struct message_media *M) {
printf
(
"[photo]"
);
return
;
case
CODE_decrypted_message_media_video
:
case
CODE_decrypted_message_media_video_l12
:
printf
(
"[video]"
);
return
;
case
CODE_decrypted_message_media_audio
:
case
CODE_decrypted_message_media_audio_l12
:
printf
(
"[audio]"
);
return
;
case
CODE_decrypted_message_media_document
:
...
...
@@ -1427,6 +1451,21 @@ void print_service_message (struct message *M) {
case
CODE_decrypted_message_action_set_message_t_t_l
:
printf
(
" set ttl to %d seconds. Unsupported yet
\n
"
,
M
->
action
.
ttl
);
break
;
case
CODE_decrypted_message_action_read_messages
:
printf
(
" %d messages marked read
\n
"
,
M
->
action
.
read_cnt
);
break
;
case
CODE_decrypted_message_action_delete_messages
:
printf
(
" %d messages deleted
\n
"
,
M
->
action
.
delete_cnt
);
break
;
case
CODE_decrypted_message_action_screenshot_messages
:
printf
(
" %d messages screenshoted
\n
"
,
M
->
action
.
screenshot_cnt
);
break
;
case
CODE_decrypted_message_action_flush_history
:
printf
(
" cleared history
\n
"
);
break
;
case
CODE_decrypted_message_action_notify_layer
:
printf
(
" updated layer to %d
\n
"
,
M
->
action
.
layer
);
break
;
default:
assert
(
0
);
}
...
...
mtproto-client.c
View file @
d3780ebe
...
...
@@ -1281,6 +1281,9 @@ void work_update (struct connection *c UU, long long msg_id UU) {
if
(
E
->
state
==
sc_request
&&
!
disable_auto_accept
)
{
do_accept_encr_chat_request
(
E
);
}
if
(
E
->
state
==
sc_ok
)
{
do_send_encr_chat_layer
(
E
);
}
fetch_int
();
// date
}
break
;
...
...
@@ -1395,6 +1398,22 @@ void work_update (struct connection *c UU, long long msg_id UU) {
}
}
break
;
case
CODE_update_user_blocked
:
{
int
id
=
fetch_int
();
int
blocked
=
fetch_bool
();
peer_t
*
P
=
user_chat_get
(
MK_USER
(
id
));
if
(
P
&&
(
P
->
flags
&
FLAG_CREATED
))
{
bl_do_user_set_blocked
(
&
P
->
user
,
blocked
);
}
}
break
;
case
CODE_update_notify_settings
:
{
assert
(
skip_type_any
(
TYPE_TO_PARAM
(
notify_peer
))
>=
0
);
assert
(
skip_type_any
(
TYPE_TO_PARAM
(
peer_notify_settings
))
>=
0
);
}
break
;
default:
logprintf
(
"Unknown update type %08x
\n
"
,
op
);
;
...
...
queries.c
View file @
d3780ebe
...
...
@@ -320,7 +320,7 @@ void out_random (int n) {
int
allow_send_linux_version
;
void
do_insert_header
(
void
)
{
out_int
(
CODE_invoke_with_layer1
2
);
out_int
(
CODE_invoke_with_layer1
5
);
out_int
(
CODE_init_connection
);
out_int
(
TG_APP_ID
);
if
(
allow_send_linux_version
)
{
...
...
@@ -840,6 +840,20 @@ void encr_finish (struct secret_chat *E) {
}
/* }}} */
void
do_send_encr_chat_layer
(
struct
secret_chat
*
E
)
{
long
long
t
;
secure_random
(
&
t
,
8
);
int
action
[
2
];
action
[
0
]
=
CODE_decrypted_message_action_notify_layer
;
action
[
1
]
=
15
;
bl_do_send_message_action_encr
(
t
,
our_id
,
get_peer_type
(
E
->
id
),
get_peer_id
(
E
->
id
),
time
(
0
),
2
,
action
);
struct
message
*
M
=
message_get
(
t
);
assert
(
M
);
do_send_msg
(
M
);
print_message
(
M
);
}
/* {{{ Seng msg (plain text) */
int
msg_send_encr_on_answer
(
struct
query
*
q
UU
)
{
assert
(
fetch_int
()
==
CODE_messages_sent_encrypted_message
);
...
...
@@ -925,7 +939,41 @@ struct query_methods msg_send_encr_methods = {
int
out_message_num
;
int
our_id
;
void
do_send_encr_msg_action
(
struct
message
*
M
)
{
peer_t
*
P
=
user_chat_get
(
M
->
to_id
);
if
(
!
P
||
P
->
encr_chat
.
state
!=
sc_ok
)
{
return
;
}
clear_packet
();
out_int
(
CODE_messages_send_encrypted_service
);
out_int
(
CODE_input_encrypted_chat
);
out_int
(
get_peer_id
(
M
->
to_id
));
out_long
(
P
->
encr_chat
.
access_hash
);
out_long
(
M
->
id
);
encr_start
();
out_int
(
CODE_decrypted_message_service
);
out_long
(
M
->
id
);
static
int
buf
[
4
];
secure_random
(
buf
,
16
);
out_cstring
((
void
*
)
buf
,
16
);
switch
(
M
->
action
.
type
)
{
case
CODE_decrypted_message_action_notify_layer
:
out_int
(
M
->
action
.
type
);
out_int
(
M
->
action
.
layer
);
break
;
default:
assert
(
0
);
}
encr_finish
(
&
P
->
encr_chat
);
send_query
(
DC_working
,
packet_ptr
-
packet_buffer
,
packet_buffer
,
&
msg_send_encr_methods
,
M
);
}
void
do_send_encr_msg
(
struct
message
*
M
)
{
if
(
M
->
service
)
{
do_send_encr_msg_action
(
M
);
return
;
}
peer_t
*
P
=
user_chat_get
(
M
->
to_id
);
if
(
!
P
||
P
->
encr_chat
.
state
!=
sc_ok
)
{
return
;
}
...
...
@@ -1167,7 +1215,7 @@ int get_dialogs_on_answer (struct query *q UU) {
static
peer_id_t
plist
[
100
];
int
dl_size
=
n
;
for
(
i
=
0
;
i
<
n
;
i
++
)
{
assert
(
fetch_int
()
==
CODE_dialog
);
assert
(
fetch_int
()
==
(
int
)
CODE_dialog
);
if
(
i
<
100
)
{
plist
[
i
]
=
fetch_peer_id
();
dlist
[
2
*
i
+
0
]
=
fetch_int
();
...
...
@@ -1177,6 +1225,7 @@ int get_dialogs_on_answer (struct query *q UU) {
fetch_int
();
fetch_int
();
}
assert
(
skip_type_any
(
TYPE_TO_PARAM
(
peer_notify_settings
))
>=
0
);
}
assert
(
fetch_int
()
==
CODE_vector
);
n
=
fetch_int
();
...
...
@@ -1419,6 +1468,7 @@ void send_part (struct send_file *f) {
out_int
(
100
);
out_int
(
100
);
out_int
(
100
);
out_string
(
"video"
);
}
if
(
f
->
media_type
==
CODE_input_media_uploaded_document
||
f
->
media_type
==
CODE_input_media_uploaded_thumb_document
)
{
out_string
(
s
+
1
);
...
...
@@ -1426,6 +1476,7 @@ void send_part (struct send_file *f) {
}
if
(
f
->
media_type
==
CODE_input_media_uploaded_audio
)
{
out_int
(
60
);
out_string
(
"audio"
);
}
out_long
(
-
lrand48
()
*
(
1ll
<<
32
)
-
lrand48
());
...
...
@@ -1468,6 +1519,7 @@ void send_part (struct send_file *f) {
}
if
(
f
->
media_type
==
CODE_input_media_uploaded_video
)
{
out_int
(
0
);
out_string
(
"video"
);
}
if
(
f
->
media_type
==
CODE_input_media_uploaded_document
)
{
out_string
(
f
->
file_name
);
...
...
@@ -1475,6 +1527,7 @@ void send_part (struct send_file *f) {
}
if
(
f
->
media_type
==
CODE_input_media_uploaded_audio
)
{
out_int
(
60
);
out_string
(
"audio"
);
}
if
(
f
->
media_type
==
CODE_input_media_uploaded_video
||
f
->
media_type
==
CODE_input_media_uploaded_photo
)
{
out_int
(
100
);
...
...
@@ -1584,7 +1637,7 @@ void do_send_photo (int type, peer_id_t to_id, char *file_name) {
f
->
key
=
talloc
(
32
);
secure_random
(
f
->
key
,
32
);
}
if
(
f
->
media_type
==
CODE_input_media_uploaded_video
&&
!
f
->
encr
)
{
/*
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 if (f->media_type == CODE_input_media_uploaded_document && !f->encr) {
...
...
@@ -1592,7 +1645,8 @@ void do_send_photo (int type, peer_id_t to_id, char *file_name) {
send_file_thumb (f);
} else {
send_part (f);
}
}*/
send_part
(
f
);
}
/* }}} */
...
...
@@ -2161,6 +2215,12 @@ int add_contact_on_answer (struct query *q UU) {
}
assert
(
fetch_int
()
==
CODE_vector
);
n
=
fetch_int
();
for
(
i
=
0
;
i
<
n
;
i
++
)
{
long
long
id
=
fetch_long
();
logprintf
(
"contact #%lld not added. Please retry
\n
"
,
id
);
}
assert
(
fetch_int
()
==
CODE_vector
);
n
=
fetch_int
();
for
(
i
=
0
;
i
<
n
;
i
++
)
{
struct
user
*
U
=
fetch_alloc_user
();
print_start
();
...
...
queries.h
View file @
d3780ebe
...
...
@@ -117,6 +117,7 @@ void do_contacts_search (int limit, const char *s);
void
do_send_msg
(
struct
message
*
M
);
void
do_delete_msg
(
long
long
id
);
void
do_restore_msg
(
long
long
id
);
void
do_send_encr_chat_layer
(
struct
secret_chat
*
E
);
// For binlog
...
...
scheme.tl
View file @
d3780ebe
scheme12.tl
\ No newline at end of file
scheme15.tl
\ No newline at end of file
structures.c
View file @
d3780ebe
...
...
@@ -557,6 +557,7 @@ void fetch_video (struct video *V) {
V
->
date
=
fetch_int
();
V
->
caption
=
fetch_str_dup
();
V
->
duration
=
fetch_int
();
V
->
mime_type
=
fetch_str_dup
();
V
->
size
=
fetch_int
();
fetch_photo_size
(
&
V
->
thumb
);
V
->
dc_id
=
fetch_int
();
...
...
@@ -573,6 +574,7 @@ void fetch_audio (struct audio *V) {
V
->
user_id
=
fetch_int
();
V
->
date
=
fetch_int
();
V
->
duration
=
fetch_int
();
V
->
mime_type
=
fetch_str_dup
();
V
->
size
=
fetch_int
();
V
->
dc_id
=
fetch_int
();
}
...
...
@@ -770,12 +772,16 @@ void fetch_message_media_encrypted (struct message_media *M) {
}
break
;
case
CODE_decrypted_message_media_video
:
M
->
type
=
x
;
case
CODE_decrypted_message_media_video_l12
:
M
->
type
=
CODE_decrypted_message_media_video
;
l
=
prefetch_strlen
();
fetch_str
(
l
);
// thumb
fetch_int
();
// thumb_w
fetch_int
();
// thumb_h
M
->
encr_video
.
duration
=
fetch_int
();
if
(
x
==
CODE_decrypted_message_media_video
)
{
M
->
encr_video
.
mime_type
=
fetch_str_dup
();
}
M
->
encr_video
.
w
=
fetch_int
();
M
->
encr_video
.
h
=
fetch_int
();
M
->
encr_video
.
size
=
fetch_int
();
...
...
@@ -799,8 +805,12 @@ void fetch_message_media_encrypted (struct message_media *M) {
}
break
;
case
CODE_decrypted_message_media_audio
:
M
->
type
=
x
;
case
CODE_decrypted_message_media_audio_l12
:
M
->
type
=
CODE_decrypted_message_media_audio
;
M
->
encr_audio
.
duration
=
fetch_int
();
if
(
x
==
CODE_decrypted_message_media_audio
)
{
M
->
encr_audio
.
mime_type
=
fetch_str_dup
();
}
M
->
encr_audio
.
size
=
fetch_int
();
l
=
prefetch_strlen
();
...
...
@@ -881,13 +891,60 @@ void fetch_message_media_encrypted (struct message_media *M) {
}
}
void
fetch_message_action_encrypted
(
struct
message_action
*
M
)
{
void
fetch_message_action_encrypted
(
struct
secret_chat
*
E
,
struct
message_action
*
M
)
{
unsigned
x
=
fetch_int
();
switch
(
x
)
{
case
CODE_decrypted_message_action_set_message_t_t_l
:
M
->
type
=
x
;
M
->
ttl
=
fetch_int
();
break
;
case
CODE_decrypted_message_action_read_messages
:
M
->
type
=
x
;
{
assert
(
fetch_int
()
==
CODE_vector
);
int
n
=
fetch_int
();
M
->
read_cnt
=
n
;
while
(
n
--
>
0
)
{
long
long
id
=
fetch_long
();
struct
message
*
N
=
message_get
(
id
);
if
(
N
)
{
N
->
unread
=
0
;
}
}
}
break
;
case
CODE_decrypted_message_action_delete_messages
:
M
->
type
=
x
;
{
assert
(
fetch_int
()
==
CODE_vector
);
int
n
=
fetch_int
();
M
->
delete_cnt
=
n
;
while
(
n
--
>
0
)
{
fetch_long
();
}
}
break
;
case
CODE_decrypted_message_action_screenshot_messages
:
M
->
type
=
x
;
{
assert
(
fetch_int
()
==
CODE_vector
);
int
n
=
fetch_int
();
M
->
screenshot_cnt
=
n
;
while
(
n
--
>
0
)
{
fetch_long
();
}
}
break
;
case
CODE_decrypted_message_action_notify_layer
:
M
->
type
=
x
;
M
->
layer
=
fetch_int
();
//if (M->from_id != our_id) {
// E->layer = M->layer;
//}
break
;
case
CODE_decrypted_message_action_flush_history
:
M
->
type
=
x
;
break
;
default:
logprintf
(
"x = 0x%08x
\n
"
,
x
);
assert
(
0
);
...
...
@@ -1106,6 +1163,10 @@ void fetch_encrypted_message (struct message *M) {
}
in_ptr
=
save_in_ptr
;
in_end
=
save_in_end
;
}
else
{
if
(
P
&&
new
)
{
assert
(
0
);
}
}
if
(
sx
==
CODE_encrypted_message
)
{
...
...
@@ -1114,14 +1175,11 @@ void fetch_encrypted_message (struct message *M) {
assert
(
skip_type_any
(
TYPE_TO_PARAM
(
encrypted_file
))
>=
0
);
if
(
x
==
CODE_decrypted_message
)
{
bl_do_create_message_media_encr
(
id
,
P
->
encr_chat
.
user_id
,
PEER_ENCR_CHAT
,
to_id
,
date
,
l
,
s
,
start
,
end
-
start
,
start_file
,
in_ptr
-
start_file
);
}
else
if
(
x
==
CODE_decrypted_message_service
)
{
bl_do_create_message_service_encr
(
id
,
P
->
encr_chat
.
user_id
,
PEER_ENCR_CHAT
,
to_id
,
date
,
start
,
end
-
start
);
}
}
else
{
x
=
fetch_int
();
if
(
x
==
CODE_encrypted_file
)
{
fetch_skip
(
7
);
}
else
{
assert
(
x
==
CODE_encrypted_file_empty
);
}
assert
(
skip_type_any
(
TYPE_TO_PARAM
(
encrypted_file
))
>=
0
);
M
->
media
.
type
=
CODE_message_media_empty
;
}
}
else
{
...
...
@@ -1480,7 +1538,6 @@ struct message *fetch_alloc_encrypted_message (void) {
message_insert_tree
(
M
);
messages_allocated
++
;
assert
(
message_get
(
M
->
id
)
==
M
);
logprintf
(
"id = %lld
\n
"
,
M
->
id
);
}
fetch_encrypted_message
(
M
);
return
M
;
...
...
structures.h
View file @
d3780ebe
...
...
@@ -98,6 +98,7 @@ struct encr_video {
int
w
;
int
h
;
int
duration
;
char
*
mime_type
;
};
struct
encr_audio
{
...
...
@@ -110,6 +111,7 @@ struct encr_audio {
unsigned
char
*
key
;
unsigned
char
*
iv
;
int
duration
;
char
*
mime_type
;
};
struct
encr_document
{
...
...
@@ -203,6 +205,7 @@ struct secret_chat {
int
admin_id
;
int
date
;
int
ttl
;
int
layer
;
long
long
access_hash
;
unsigned
char
*
g_key
;
unsigned
char
*
nonce
;
...
...
@@ -240,6 +243,7 @@ struct video {
int
duration
;
int
w
;
int
h
;
char
*
mime_type
;
};
struct
audio
{
...
...
@@ -250,6 +254,7 @@ struct audio {
int
size
;
int
dc_id
;
int
duration
;
char
*
mime_type
;
};
struct
document
{
...
...
@@ -276,6 +281,10 @@ struct message_action {
struct
photo
photo
;
int
user
;
int
ttl
;
int
layer
;
int
read_cnt
;
int
delete_cnt
;
int
screenshot_cnt
;
};
};
...
...
@@ -344,7 +353,7 @@ struct message *fetch_alloc_encrypted_message (void);
void
fetch_encrypted_message_file
(
struct
message_media
*
M
);
void
fetch_skip_encrypted_message_file
(
void
);
void
fetch_encrypted_message_file
(
struct
message_media
*
M
);
void
fetch_message_action_encrypted
(
struct
message_action
*
M
);
void
fetch_message_action_encrypted
(
struct
secret_chat
*
E
,
struct
message_action
*
M
);
peer_id_t
fetch_peer_id
(
void
);
void
fetch_message_media
(
struct
message_media
*
M
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment