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
9959c058
Commit
9959c058
authored
Aug 13, 2014
by
Vysheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
renamed user_chat_get to peer_get
parent
d3780ebe
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
106 additions
and
106 deletions
+106
-106
binlog.c
binlog.c
+33
-33
interface.c
interface.c
+13
-13
lua-tg.c
lua-tg.c
+4
-4
mtproto-client.c
mtproto-client.c
+24
-24
queries.c
queries.c
+22
-22
structures.c
structures.c
+9
-9
structures.h
structures.h
+1
-1
No files found.
binlog.c
View file @
9959c058
This diff is collapsed.
Click to expand it.
interface.c
View file @
9959c058
...
@@ -230,7 +230,7 @@ char *get_default_prompt (void) {
...
@@ -230,7 +230,7 @@ char *get_default_prompt (void) {
static
char
buf
[
1000
];
static
char
buf
[
1000
];
int
l
=
0
;
int
l
=
0
;
if
(
in_chat_mode
)
{
if
(
in_chat_mode
)
{
peer_t
*
U
=
user_chat
_get
(
chat_mode_id
);
peer_t
*
U
=
peer
_get
(
chat_mode_id
);
assert
(
U
&&
U
->
print_name
);
assert
(
U
&&
U
->
print_name
);
l
+=
tsnprintf
(
buf
+
l
,
999
-
l
,
COLOR_RED
"%.*s "
COLOR_NORMAL
,
100
,
U
->
print_name
);
l
+=
tsnprintf
(
buf
+
l
,
999
-
l
,
COLOR_RED
"%.*s "
COLOR_NORMAL
,
100
,
U
->
print_name
);
}
}
...
@@ -856,7 +856,7 @@ void interpreter (char *line UU) {
...
@@ -856,7 +856,7 @@ void interpreter (char *line UU) {
do_add_contact
(
phone
,
phone_len
,
first_name
,
first_name_len
,
last_name
,
last_name_len
,
0
);
do_add_contact
(
phone
,
phone_len
,
first_name
,
first_name_len
,
last_name
,
last_name_len
,
0
);
}
else
if
(
IS_WORD
(
"rename_contact"
))
{
}
else
if
(
IS_WORD
(
"rename_contact"
))
{
GET_PEER_USER
;
GET_PEER_USER
;
peer_t
*
U
=
user_chat
_get
(
id
);
peer_t
*
U
=
peer
_get
(
id
);
if
(
!
U
)
{
if
(
!
U
)
{
printf
(
"No such user
\n
"
);
printf
(
"No such user
\n
"
);
RET
;
RET
;
...
@@ -1407,13 +1407,13 @@ void print_service_message (struct message *M) {
...
@@ -1407,13 +1407,13 @@ void print_service_message (struct message *M) {
pop_color
();
pop_color
();
printf
(
" "
);
printf
(
" "
);
if
(
get_peer_type
(
M
->
to_id
)
==
PEER_CHAT
)
{
if
(
get_peer_type
(
M
->
to_id
)
==
PEER_CHAT
)
{
print_chat_name
(
M
->
to_id
,
user_chat
_get
(
M
->
to_id
));
print_chat_name
(
M
->
to_id
,
peer
_get
(
M
->
to_id
));
}
else
{
}
else
{
assert
(
get_peer_type
(
M
->
to_id
)
==
PEER_ENCR_CHAT
);
assert
(
get_peer_type
(
M
->
to_id
)
==
PEER_ENCR_CHAT
);
print_encr_chat_name
(
M
->
to_id
,
user_chat
_get
(
M
->
to_id
));
print_encr_chat_name
(
M
->
to_id
,
peer
_get
(
M
->
to_id
));
}
}
printf
(
" "
);
printf
(
" "
);
print_user_name
(
M
->
from_id
,
user_chat
_get
(
M
->
from_id
));
print_user_name
(
M
->
from_id
,
peer
_get
(
M
->
from_id
));
switch
(
M
->
action
.
type
)
{
switch
(
M
->
action
.
type
)
{
case
CODE_message_action_empty
:
case
CODE_message_action_empty
:
...
@@ -1440,12 +1440,12 @@ void print_service_message (struct message *M) {
...
@@ -1440,12 +1440,12 @@ void print_service_message (struct message *M) {
break
;
break
;
case
CODE_message_action_chat_add_user
:
case
CODE_message_action_chat_add_user
:
printf
(
" added user "
);
printf
(
" added user "
);
print_user_name
(
set_peer_id
(
PEER_USER
,
M
->
action
.
user
),
user_chat
_get
(
set_peer_id
(
PEER_USER
,
M
->
action
.
user
)));
print_user_name
(
set_peer_id
(
PEER_USER
,
M
->
action
.
user
),
peer
_get
(
set_peer_id
(
PEER_USER
,
M
->
action
.
user
)));
printf
(
"
\n
"
);
printf
(
"
\n
"
);
break
;
break
;
case
CODE_message_action_chat_delete_user
:
case
CODE_message_action_chat_delete_user
:
printf
(
" deleted user "
);
printf
(
" deleted user "
);
print_user_name
(
set_peer_id
(
PEER_USER
,
M
->
action
.
user
),
user_chat
_get
(
set_peer_id
(
PEER_USER
,
M
->
action
.
user
)));
print_user_name
(
set_peer_id
(
PEER_USER
,
M
->
action
.
user
),
peer
_get
(
set_peer_id
(
PEER_USER
,
M
->
action
.
user
)));
printf
(
"
\n
"
);
printf
(
"
\n
"
);
break
;
break
;
case
CODE_decrypted_message_action_set_message_t_t_l
:
case
CODE_decrypted_message_action_set_message_t_t_l
:
...
@@ -1504,7 +1504,7 @@ void print_message (struct message *M) {
...
@@ -1504,7 +1504,7 @@ void print_message (struct message *M) {
print_date
(
M
->
date
);
print_date
(
M
->
date
);
pop_color
();
pop_color
();
printf
(
" "
);
printf
(
" "
);
print_user_name
(
M
->
to_id
,
user_chat
_get
(
M
->
to_id
));
print_user_name
(
M
->
to_id
,
peer
_get
(
M
->
to_id
));
push_color
(
COLOR_GREEN
);
push_color
(
COLOR_GREEN
);
if
(
M
->
unread
)
{
if
(
M
->
unread
)
{
printf
(
" <<< "
);
printf
(
" <<< "
);
...
@@ -1519,7 +1519,7 @@ void print_message (struct message *M) {
...
@@ -1519,7 +1519,7 @@ void print_message (struct message *M) {
print_date
(
M
->
date
);
print_date
(
M
->
date
);
pop_color
();
pop_color
();
printf
(
" "
);
printf
(
" "
);
print_user_name
(
M
->
from_id
,
user_chat
_get
(
M
->
from_id
));
print_user_name
(
M
->
from_id
,
peer
_get
(
M
->
from_id
));
push_color
(
COLOR_BLUE
);
push_color
(
COLOR_BLUE
);
if
(
M
->
unread
)
{
if
(
M
->
unread
)
{
printf
(
" >>> "
);
printf
(
" >>> "
);
...
@@ -1531,7 +1531,7 @@ void print_message (struct message *M) {
...
@@ -1531,7 +1531,7 @@ void print_message (struct message *M) {
}
}
}
}
}
else
if
(
get_peer_type
(
M
->
to_id
)
==
PEER_ENCR_CHAT
)
{
}
else
if
(
get_peer_type
(
M
->
to_id
)
==
PEER_ENCR_CHAT
)
{
peer_t
*
P
=
user_chat
_get
(
M
->
to_id
);
peer_t
*
P
=
peer
_get
(
M
->
to_id
);
assert
(
P
);
assert
(
P
);
if
(
M
->
out
)
{
if
(
M
->
out
)
{
push_color
(
COLOR_GREEN
);
push_color
(
COLOR_GREEN
);
...
@@ -1575,9 +1575,9 @@ void print_message (struct message *M) {
...
@@ -1575,9 +1575,9 @@ void print_message (struct message *M) {
print_date
(
M
->
date
);
print_date
(
M
->
date
);
pop_color
();
pop_color
();
printf
(
" "
);
printf
(
" "
);
print_chat_name
(
M
->
to_id
,
user_chat
_get
(
M
->
to_id
));
print_chat_name
(
M
->
to_id
,
peer
_get
(
M
->
to_id
));
printf
(
" "
);
printf
(
" "
);
print_user_name
(
M
->
from_id
,
user_chat
_get
(
M
->
from_id
));
print_user_name
(
M
->
from_id
,
peer
_get
(
M
->
from_id
));
if
((
get_peer_type
(
M
->
from_id
)
==
PEER_USER
)
&&
(
get_peer_id
(
M
->
from_id
)
==
our_id
))
{
if
((
get_peer_type
(
M
->
from_id
)
==
PEER_USER
)
&&
(
get_peer_id
(
M
->
from_id
)
==
our_id
))
{
push_color
(
COLOR_GREEN
);
push_color
(
COLOR_GREEN
);
}
else
{
}
else
{
...
@@ -1591,7 +1591,7 @@ void print_message (struct message *M) {
...
@@ -1591,7 +1591,7 @@ void print_message (struct message *M) {
}
}
if
(
get_peer_type
(
M
->
fwd_from_id
)
==
PEER_USER
)
{
if
(
get_peer_type
(
M
->
fwd_from_id
)
==
PEER_USER
)
{
printf
(
"[fwd from "
);
printf
(
"[fwd from "
);
print_user_name
(
M
->
fwd_from_id
,
user_chat
_get
(
M
->
fwd_from_id
));
print_user_name
(
M
->
fwd_from_id
,
peer
_get
(
M
->
fwd_from_id
));
printf
(
"] "
);
printf
(
"] "
);
}
}
if
(
M
->
message
&&
strlen
(
M
->
message
))
{
if
(
M
->
message
&&
strlen
(
M
->
message
))
{
...
...
lua-tg.c
View file @
9959c058
...
@@ -82,7 +82,7 @@ void push_chat (peer_t *P) {
...
@@ -82,7 +82,7 @@ void push_chat (peer_t *P) {
void
push_encr_chat
(
peer_t
*
P
)
{
void
push_encr_chat
(
peer_t
*
P
)
{
my_lua_checkstack
(
luaState
,
4
);
my_lua_checkstack
(
luaState
,
4
);
lua_pushstring
(
luaState
,
"user"
);
lua_pushstring
(
luaState
,
"user"
);
push_peer
(
MK_USER
(
P
->
encr_chat
.
user_id
),
user_chat
_get
(
MK_USER
(
P
->
encr_chat
.
user_id
)));
push_peer
(
MK_USER
(
P
->
encr_chat
.
user_id
),
peer
_get
(
MK_USER
(
P
->
encr_chat
.
user_id
)));
lua_settable
(
luaState
,
-
3
);
lua_settable
(
luaState
,
-
3
);
}
}
...
@@ -188,18 +188,18 @@ void push_message (struct message *M) {
...
@@ -188,18 +188,18 @@ void push_message (struct message *M) {
if
(
get_peer_type
(
M
->
fwd_from_id
))
{
if
(
get_peer_type
(
M
->
fwd_from_id
))
{
lua_pushstring
(
luaState
,
"fwd_from"
);
lua_pushstring
(
luaState
,
"fwd_from"
);
push_peer
(
M
->
fwd_from_id
,
user_chat
_get
(
M
->
fwd_from_id
));
push_peer
(
M
->
fwd_from_id
,
peer
_get
(
M
->
fwd_from_id
));
lua_settable
(
luaState
,
-
3
);
// fwd_from
lua_settable
(
luaState
,
-
3
);
// fwd_from
lua_add_num_field
(
"fwd_date"
,
M
->
fwd_date
);
lua_add_num_field
(
"fwd_date"
,
M
->
fwd_date
);
}
}
lua_pushstring
(
luaState
,
"from"
);
lua_pushstring
(
luaState
,
"from"
);
push_peer
(
M
->
from_id
,
user_chat
_get
(
M
->
from_id
));
push_peer
(
M
->
from_id
,
peer
_get
(
M
->
from_id
));
lua_settable
(
luaState
,
-
3
);
lua_settable
(
luaState
,
-
3
);
lua_pushstring
(
luaState
,
"to"
);
lua_pushstring
(
luaState
,
"to"
);
push_peer
(
M
->
to_id
,
user_chat
_get
(
M
->
to_id
));
push_peer
(
M
->
to_id
,
peer
_get
(
M
->
to_id
));
lua_settable
(
luaState
,
-
3
);
lua_settable
(
luaState
,
-
3
);
lua_pushstring
(
luaState
,
"out"
);
lua_pushstring
(
luaState
,
"out"
);
...
...
mtproto-client.c
View file @
9959c058
...
@@ -846,7 +846,7 @@ void work_update_binlog (void) {
...
@@ -846,7 +846,7 @@ void work_update_binlog (void) {
case CODE_update_user_name:
case CODE_update_user_name:
{
{
peer_id_t user_id = MK_USER (fetch_int ());
peer_id_t user_id = MK_USER (fetch_int ());
peer_t *UC =
user_chat
_get (user_id);
peer_t *UC =
peer
_get (user_id);
if (UC) {
if (UC) {
struct user *U = &UC->user;
struct user *U = &UC->user;
if (U->first_name) { tfree_str (U->first_name); }
if (U->first_name) { tfree_str (U->first_name); }
...
@@ -868,7 +868,7 @@ void work_update_binlog (void) {
...
@@ -868,7 +868,7 @@ void work_update_binlog (void) {
case CODE_update_user_photo:
case CODE_update_user_photo:
{
{
peer_id_t user_id = MK_USER (fetch_int ());
peer_id_t user_id = MK_USER (fetch_int ());
peer_t *UC =
user_chat
_get (user_id);
peer_t *UC =
peer
_get (user_id);
fetch_date ();
fetch_date ();
if (UC) {
if (UC) {
struct user *U = &UC->user;
struct user *U = &UC->user;
...
@@ -952,7 +952,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
...
@@ -952,7 +952,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
case
CODE_update_user_typing
:
case
CODE_update_user_typing
:
{
{
peer_id_t
id
=
MK_USER
(
fetch_int
());
peer_id_t
id
=
MK_USER
(
fetch_int
());
peer_t
*
U
=
user_chat
_get
(
id
);
peer_t
*
U
=
peer
_get
(
id
);
if
(
log_level
>=
2
)
{
if
(
log_level
>=
2
)
{
print_start
();
print_start
();
push_color
(
COLOR_YELLOW
);
push_color
(
COLOR_YELLOW
);
...
@@ -969,8 +969,8 @@ void work_update (struct connection *c UU, long long msg_id UU) {
...
@@ -969,8 +969,8 @@ void work_update (struct connection *c UU, long long msg_id UU) {
{
{
peer_id_t
chat_id
=
MK_CHAT
(
fetch_int
());
peer_id_t
chat_id
=
MK_CHAT
(
fetch_int
());
peer_id_t
id
=
MK_USER
(
fetch_int
());
peer_id_t
id
=
MK_USER
(
fetch_int
());
peer_t
*
C
=
user_chat
_get
(
chat_id
);
peer_t
*
C
=
peer
_get
(
chat_id
);
peer_t
*
U
=
user_chat
_get
(
id
);
peer_t
*
U
=
peer
_get
(
id
);
if
(
log_level
>=
2
)
{
if
(
log_level
>=
2
)
{
print_start
();
print_start
();
push_color
(
COLOR_YELLOW
);
push_color
(
COLOR_YELLOW
);
...
@@ -988,7 +988,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
...
@@ -988,7 +988,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
case
CODE_update_user_status
:
case
CODE_update_user_status
:
{
{
peer_id_t
user_id
=
MK_USER
(
fetch_int
());
peer_id_t
user_id
=
MK_USER
(
fetch_int
());
peer_t
*
U
=
user_chat
_get
(
user_id
);
peer_t
*
U
=
peer
_get
(
user_id
);
if
(
U
)
{
if
(
U
)
{
fetch_user_status
(
&
U
->
user
.
status
);
fetch_user_status
(
&
U
->
user
.
status
);
if
(
log_level
>=
3
)
{
if
(
log_level
>=
3
)
{
...
@@ -1011,7 +1011,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
...
@@ -1011,7 +1011,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
case
CODE_update_user_name
:
case
CODE_update_user_name
:
{
{
peer_id_t
user_id
=
MK_USER
(
fetch_int
());
peer_id_t
user_id
=
MK_USER
(
fetch_int
());
peer_t
*
UC
=
user_chat
_get
(
user_id
);
peer_t
*
UC
=
peer
_get
(
user_id
);
if
(
UC
&&
(
UC
->
flags
&
FLAG_CREATED
))
{
if
(
UC
&&
(
UC
->
flags
&
FLAG_CREATED
))
{
int
l1
=
prefetch_strlen
();
int
l1
=
prefetch_strlen
();
char
*
f
=
fetch_str
(
l1
);
char
*
f
=
fetch_str
(
l1
);
...
@@ -1038,7 +1038,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
...
@@ -1038,7 +1038,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
case
CODE_update_user_photo
:
case
CODE_update_user_photo
:
{
{
peer_id_t
user_id
=
MK_USER
(
fetch_int
());
peer_id_t
user_id
=
MK_USER
(
fetch_int
());
peer_t
*
UC
=
user_chat
_get
(
user_id
);
peer_t
*
UC
=
peer
_get
(
user_id
);
fetch_date
();
fetch_date
();
if
(
UC
&&
(
UC
->
flags
&
FLAG_CREATED
))
{
if
(
UC
&&
(
UC
->
flags
&
FLAG_CREATED
))
{
struct
user
*
U
=
&
UC
->
user
;
struct
user
*
U
=
&
UC
->
user
;
...
@@ -1116,7 +1116,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
...
@@ -1116,7 +1116,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
assert
(
x
==
CODE_chat_participants
||
x
==
CODE_chat_participants_forbidden
);
assert
(
x
==
CODE_chat_participants
||
x
==
CODE_chat_participants_forbidden
);
peer_id_t
chat_id
=
MK_CHAT
(
fetch_int
());
peer_id_t
chat_id
=
MK_CHAT
(
fetch_int
());
int
n
=
0
;
int
n
=
0
;
peer_t
*
C
=
user_chat
_get
(
chat_id
);
peer_t
*
C
=
peer
_get
(
chat_id
);
if
(
C
&&
(
C
->
flags
&
FLAG_CREATED
))
{
if
(
C
&&
(
C
->
flags
&
FLAG_CREATED
))
{
if
(
x
==
CODE_chat_participants
)
{
if
(
x
==
CODE_chat_participants
)
{
bl_do_chat_set_admin
(
&
C
->
chat
,
fetch_int
());
bl_do_chat_set_admin
(
&
C
->
chat
,
fetch_int
());
...
@@ -1159,7 +1159,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
...
@@ -1159,7 +1159,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
case
CODE_update_contact_registered
:
case
CODE_update_contact_registered
:
{
{
peer_id_t
user_id
=
MK_USER
(
fetch_int
());
peer_id_t
user_id
=
MK_USER
(
fetch_int
());
peer_t
*
U
=
user_chat
_get
(
user_id
);
peer_t
*
U
=
peer
_get
(
user_id
);
fetch_int
();
// date
fetch_int
();
// date
print_start
();
print_start
();
push_color
(
COLOR_YELLOW
);
push_color
(
COLOR_YELLOW
);
...
@@ -1174,7 +1174,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
...
@@ -1174,7 +1174,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
case
CODE_update_contact_link
:
case
CODE_update_contact_link
:
{
{
peer_id_t
user_id
=
MK_USER
(
fetch_int
());
peer_id_t
user_id
=
MK_USER
(
fetch_int
());
peer_t
*
U
=
user_chat
_get
(
user_id
);
peer_t
*
U
=
peer
_get
(
user_id
);
print_start
();
print_start
();
push_color
(
COLOR_YELLOW
);
push_color
(
COLOR_YELLOW
);
print_date
(
time
(
0
));
print_date
(
time
(
0
));
...
@@ -1198,7 +1198,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
...
@@ -1198,7 +1198,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
case
CODE_update_activation
:
case
CODE_update_activation
:
{
{
peer_id_t
user_id
=
MK_USER
(
fetch_int
());
peer_id_t
user_id
=
MK_USER
(
fetch_int
());
peer_t
*
U
=
user_chat
_get
(
user_id
);
peer_t
*
U
=
peer
_get
(
user_id
);
print_start
();
print_start
();
push_color
(
COLOR_YELLOW
);
push_color
(
COLOR_YELLOW
);
print_date
(
time
(
0
));
print_date
(
time
(
0
));
...
@@ -1290,14 +1290,14 @@ void work_update (struct connection *c UU, long long msg_id UU) {
...
@@ -1290,14 +1290,14 @@ void work_update (struct connection *c UU, long long msg_id UU) {
case
CODE_update_encrypted_chat_typing
:
case
CODE_update_encrypted_chat_typing
:
{
{
peer_id_t
id
=
MK_ENCR_CHAT
(
fetch_int
());
peer_id_t
id
=
MK_ENCR_CHAT
(
fetch_int
());
peer_t
*
P
=
user_chat
_get
(
id
);
peer_t
*
P
=
peer
_get
(
id
);
print_start
();
print_start
();
push_color
(
COLOR_YELLOW
);
push_color
(
COLOR_YELLOW
);
print_date
(
time
(
0
));
print_date
(
time
(
0
));
if
(
P
)
{
if
(
P
)
{
printf
(
" User "
);
printf
(
" User "
);
peer_id_t
user_id
=
MK_USER
(
P
->
encr_chat
.
user_id
);
peer_id_t
user_id
=
MK_USER
(
P
->
encr_chat
.
user_id
);
print_user_name
(
user_id
,
user_chat
_get
(
user_id
));
print_user_name
(
user_id
,
peer
_get
(
user_id
));
printf
(
" typing in secret chat "
);
printf
(
" typing in secret chat "
);
print_encr_chat_name
(
id
,
P
);
print_encr_chat_name
(
id
,
P
);
printf
(
"
\n
"
);
printf
(
"
\n
"
);
...
@@ -1313,7 +1313,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
...
@@ -1313,7 +1313,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
peer_id_t
id
=
MK_ENCR_CHAT
(
fetch_int
());
// chat_id
peer_id_t
id
=
MK_ENCR_CHAT
(
fetch_int
());
// chat_id
fetch_int
();
// max_date
fetch_int
();
// max_date
fetch_int
();
// date
fetch_int
();
// date
peer_t
*
P
=
user_chat
_get
(
id
);
peer_t
*
P
=
peer
_get
(
id
);
int
x
=
-
1
;
int
x
=
-
1
;
if
(
P
&&
P
->
last
)
{
if
(
P
&&
P
->
last
)
{
x
=
0
;
x
=
0
;
...
@@ -1331,7 +1331,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
...
@@ -1331,7 +1331,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
push_color
(
COLOR_YELLOW
);
push_color
(
COLOR_YELLOW
);
print_date
(
time
(
0
));
print_date
(
time
(
0
));
printf
(
" Encrypted chat "
);
printf
(
" Encrypted chat "
);
print_encr_chat_name_full
(
id
,
user_chat
_get
(
id
));
print_encr_chat_name_full
(
id
,
peer
_get
(
id
));
printf
(
": %d messages marked read
\n
"
,
x
);
printf
(
": %d messages marked read
\n
"
,
x
);
pop_color
();
pop_color
();
print_end
();
print_end
();
...
@@ -1345,7 +1345,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
...
@@ -1345,7 +1345,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
peer_id_t
inviter_id
=
MK_USER
(
fetch_int
());
peer_id_t
inviter_id
=
MK_USER
(
fetch_int
());
int
version
=
fetch_int
();
int
version
=
fetch_int
();
peer_t
*
C
=
user_chat
_get
(
chat_id
);
peer_t
*
C
=
peer
_get
(
chat_id
);
if
(
C
&&
(
C
->
flags
&
FLAG_CREATED
))
{
if
(
C
&&
(
C
->
flags
&
FLAG_CREATED
))
{
bl_do_chat_add_user
(
&
C
->
chat
,
version
,
get_peer_id
(
user_id
),
get_peer_id
(
inviter_id
),
time
(
0
));
bl_do_chat_add_user
(
&
C
->
chat
,
version
,
get_peer_id
(
user_id
),
get_peer_id
(
inviter_id
),
time
(
0
));
}
}
...
@@ -1354,11 +1354,11 @@ void work_update (struct connection *c UU, long long msg_id UU) {
...
@@ -1354,11 +1354,11 @@ void work_update (struct connection *c UU, long long msg_id UU) {
push_color
(
COLOR_YELLOW
);
push_color
(
COLOR_YELLOW
);
print_date
(
time
(
0
));
print_date
(
time
(
0
));
printf
(
" Chat "
);
printf
(
" Chat "
);
print_chat_name
(
chat_id
,
user_chat
_get
(
chat_id
));
print_chat_name
(
chat_id
,
peer
_get
(
chat_id
));
printf
(
": user "
);
printf
(
": user "
);
print_user_name
(
user_id
,
user_chat
_get
(
user_id
));
print_user_name
(
user_id
,
peer
_get
(
user_id
));
printf
(
" added by user "
);
printf
(
" added by user "
);
print_user_name
(
inviter_id
,
user_chat
_get
(
inviter_id
));
print_user_name
(
inviter_id
,
peer
_get
(
inviter_id
));
printf
(
"
\n
"
);
printf
(
"
\n
"
);
pop_color
();
pop_color
();
print_end
();
print_end
();
...
@@ -1370,7 +1370,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
...
@@ -1370,7 +1370,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
peer_id_t
user_id
=
MK_USER
(
fetch_int
());
peer_id_t
user_id
=
MK_USER
(
fetch_int
());
int
version
=
fetch_int
();
int
version
=
fetch_int
();
peer_t
*
C
=
user_chat
_get
(
chat_id
);
peer_t
*
C
=
peer
_get
(
chat_id
);
if
(
C
&&
(
C
->
flags
&
FLAG_CREATED
))
{
if
(
C
&&
(
C
->
flags
&
FLAG_CREATED
))
{
bl_do_chat_del_user
(
&
C
->
chat
,
version
,
get_peer_id
(
user_id
));
bl_do_chat_del_user
(
&
C
->
chat
,
version
,
get_peer_id
(
user_id
));
}
}
...
@@ -1379,9 +1379,9 @@ void work_update (struct connection *c UU, long long msg_id UU) {
...
@@ -1379,9 +1379,9 @@ void work_update (struct connection *c UU, long long msg_id UU) {
push_color
(
COLOR_YELLOW
);
push_color
(
COLOR_YELLOW
);
print_date
(
time
(
0
));
print_date
(
time
(
0
));
printf
(
" Chat "
);
printf
(
" Chat "
);
print_chat_name
(
chat_id
,
user_chat
_get
(
chat_id
));
print_chat_name
(
chat_id
,
peer
_get
(
chat_id
));
printf
(
": user "
);
printf
(
": user "
);
print_user_name
(
user_id
,
user_chat
_get
(
user_id
));
print_user_name
(
user_id
,
peer
_get
(
user_id
));
printf
(
" deleted
\n
"
);
printf
(
" deleted
\n
"
);
pop_color
();
pop_color
();
print_end
();
print_end
();
...
@@ -1402,7 +1402,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
...
@@ -1402,7 +1402,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
{
{
int
id
=
fetch_int
();
int
id
=
fetch_int
();
int
blocked
=
fetch_bool
();
int
blocked
=
fetch_bool
();
peer_t
*
P
=
user_chat
_get
(
MK_USER
(
id
));
peer_t
*
P
=
peer
_get
(
MK_USER
(
id
));
if
(
P
&&
(
P
->
flags
&
FLAG_CREATED
))
{
if
(
P
&&
(
P
->
flags
&
FLAG_CREATED
))
{
bl_do_user_set_blocked
(
&
P
->
user
,
blocked
);
bl_do_user_set_blocked
(
&
P
->
user
,
blocked
);
}
}
...
...
queries.c
View file @
9959c058
...
@@ -940,7 +940,7 @@ int out_message_num;
...
@@ -940,7 +940,7 @@ int out_message_num;
int
our_id
;
int
our_id
;
void
do_send_encr_msg_action
(
struct
message
*
M
)
{
void
do_send_encr_msg_action
(
struct
message
*
M
)
{
peer_t
*
P
=
user_chat
_get
(
M
->
to_id
);
peer_t
*
P
=
peer
_get
(
M
->
to_id
);
if
(
!
P
||
P
->
encr_chat
.
state
!=
sc_ok
)
{
return
;
}
if
(
!
P
||
P
->
encr_chat
.
state
!=
sc_ok
)
{
return
;
}
clear_packet
();
clear_packet
();
...
@@ -974,7 +974,7 @@ void do_send_encr_msg (struct message *M) {
...
@@ -974,7 +974,7 @@ void do_send_encr_msg (struct message *M) {
do_send_encr_msg_action
(
M
);
do_send_encr_msg_action
(
M
);
return
;
return
;
}
}
peer_t
*
P
=
user_chat
_get
(
M
->
to_id
);
peer_t
*
P
=
peer
_get
(
M
->
to_id
);
if
(
!
P
||
P
->
encr_chat
.
state
!=
sc_ok
)
{
return
;
}
if
(
!
P
||
P
->
encr_chat
.
state
!=
sc_ok
)
{
return
;
}
clear_packet
();
clear_packet
();
...
@@ -1011,7 +1011,7 @@ void do_send_msg (struct message *M) {
...
@@ -1011,7 +1011,7 @@ void do_send_msg (struct message *M) {
void
do_send_message
(
peer_id_t
id
,
const
char
*
msg
,
int
len
)
{
void
do_send_message
(
peer_id_t
id
,
const
char
*
msg
,
int
len
)
{
if
(
get_peer_type
(
id
)
==
PEER_ENCR_CHAT
)
{
if
(
get_peer_type
(
id
)
==
PEER_ENCR_CHAT
)
{
peer_t
*
P
=
user_chat
_get
(
id
);
peer_t
*
P
=
peer
_get
(
id
);
if
(
!
P
)
{
if
(
!
P
)
{
logprintf
(
"Can not send to unknown encrypted chat
\n
"
);
logprintf
(
"Can not send to unknown encrypted chat
\n
"
);
return
;
return
;
...
@@ -1100,7 +1100,7 @@ void do_messages_mark_read_encr (peer_id_t id, long long access_hash, int last_t
...
@@ -1100,7 +1100,7 @@ void do_messages_mark_read_encr (peer_id_t id, long long access_hash, int last_t
}
}
void
do_mark_read
(
peer_id_t
id
)
{
void
do_mark_read
(
peer_id_t
id
)
{
peer_t
*
P
=
user_chat
_get
(
id
);
peer_t
*
P
=
peer
_get
(
id
);
if
(
!
P
)
{
if
(
!
P
)
{
rprintf
(
"Unknown peer
\n
"
);
rprintf
(
"Unknown peer
\n
"
);
return
;
return
;
...
@@ -1169,7 +1169,7 @@ struct query_methods get_history_methods = {
...
@@ -1169,7 +1169,7 @@ struct query_methods get_history_methods = {
};
};
void
do_get_local_history
(
peer_id_t
id
,
int
limit
)
{
void
do_get_local_history
(
peer_id_t
id
,
int
limit
)
{
peer_t
*
P
=
user_chat
_get
(
id
);
peer_t
*
P
=
peer
_get
(
id
);
if
(
!
P
||
!
P
->
last
)
{
return
;
}
if
(
!
P
||
!
P
->
last
)
{
return
;
}
struct
message
*
M
=
P
->
last
;
struct
message
*
M
=
P
->
last
;
int
count
=
1
;
int
count
=
1
;
...
@@ -1248,13 +1248,13 @@ int get_dialogs_on_answer (struct query *q UU) {
...
@@ -1248,13 +1248,13 @@ int get_dialogs_on_answer (struct query *q UU) {
peer_t
*
UC
;
peer_t
*
UC
;
switch
(
get_peer_type
(
plist
[
i
]))
{
switch
(
get_peer_type
(
plist
[
i
]))
{
case
PEER_USER
:
case
PEER_USER
:
UC
=
user_chat
_get
(
plist
[
i
]);
UC
=
peer
_get
(
plist
[
i
]);
printf
(
"User "
);
printf
(
"User "
);
print_user_name
(
plist
[
i
],
UC
);
print_user_name
(
plist
[
i
],
UC
);
printf
(
": %d unread
\n
"
,
dlist
[
2
*
i
+
1
]);
printf
(
": %d unread
\n
"
,
dlist
[
2
*
i
+
1
]);
break
;
break
;
case
PEER_CHAT
:
case
PEER_CHAT
:
UC
=
user_chat
_get
(
plist
[
i
]);
UC
=
peer
_get
(
plist
[
i
]);
printf
(
"Chat "
);
printf
(
"Chat "
);
print_chat_name
(
plist
[
i
],
UC
);
print_chat_name
(
plist
[
i
],
UC
);
printf
(
": %d unread
\n
"
,
dlist
[
2
*
i
+
1
]);
printf
(
": %d unread
\n
"
,
dlist
[
2
*
i
+
1
]);
...
@@ -1312,7 +1312,7 @@ void out_peer_id (peer_id_t id) {
...
@@ -1312,7 +1312,7 @@ void out_peer_id (peer_id_t id) {
out_int
(
get_peer_id
(
id
));
out_int
(
get_peer_id
(
id
));
break
;
break
;
case
PEER_USER
:
case
PEER_USER
:
U
=
user_chat
_get
(
id
);
U
=
peer
_get
(
id
);
if
(
U
&&
U
->
user
.
access_hash
)
{
if
(
U
&&
U
->
user
.
access_hash
)
{
out_int
(
CODE_input_peer_foreign
);
out_int
(
CODE_input_peer_foreign
);
out_int
(
get_peer_id
(
id
));
out_int
(
get_peer_id
(
id
));
...
@@ -1487,7 +1487,7 @@ void send_part (struct send_file *f) {
...
@@ -1487,7 +1487,7 @@ void send_part (struct send_file *f) {
out_int
(
CODE_messages_send_encrypted_file
);
out_int
(
CODE_messages_send_encrypted_file
);
out_int
(
CODE_input_encrypted_chat
);
out_int
(
CODE_input_encrypted_chat
);
out_int
(
get_peer_id
(
f
->
to_id
));
out_int
(
get_peer_id
(
f
->
to_id
));
peer_t
*
P
=
user_chat
_get
(
f
->
to_id
);
peer_t
*
P
=
peer
_get
(
f
->
to_id
);
assert
(
P
);
assert
(
P
);
out_long
(
P
->
encr_chat
.
access_hash
);
out_long
(
P
->
encr_chat
.
access_hash
);
long
long
r
=
-
lrand48
()
*
(
1ll
<<
32
)
-
lrand48
();
long
long
r
=
-
lrand48
()
*
(
1ll
<<
32
)
-
lrand48
();
...
@@ -1737,9 +1737,9 @@ void print_chat_info (struct chat *C) {
...
@@ -1737,9 +1737,9 @@ void print_chat_info (struct chat *C) {
int
i
;
int
i
;
for
(
i
=
0
;
i
<
C
->
user_list_size
;
i
++
)
{
for
(
i
=
0
;
i
<
C
->
user_list_size
;
i
++
)
{
printf
(
"
\t\t
"
);
printf
(
"
\t\t
"
);
print_user_name
(
MK_USER
(
C
->
user_list
[
i
].
user_id
),
user_chat
_get
(
MK_USER
(
C
->
user_list
[
i
].
user_id
)));
print_user_name
(
MK_USER
(
C
->
user_list
[
i
].
user_id
),
peer
_get
(
MK_USER
(
C
->
user_list
[
i
].
user_id
)));
printf
(
" invited by "
);
printf
(
" invited by "
);
print_user_name
(
MK_USER
(
C
->
user_list
[
i
].
inviter_id
),
user_chat
_get
(
MK_USER
(
C
->
user_list
[
i
].
inviter_id
)));
print_user_name
(
MK_USER
(
C
->
user_list
[
i
].
inviter_id
),
peer
_get
(
MK_USER
(
C
->
user_list
[
i
].
inviter_id
)));
printf
(
" at "
);
printf
(
" at "
);
print_date_full
(
C
->
user_list
[
i
].
date
);
print_date_full
(
C
->
user_list
[
i
].
date
);
if
(
C
->
user_list
[
i
].
user_id
==
C
->
admin_id
)
{
if
(
C
->
user_list
[
i
].
user_id
==
C
->
admin_id
)
{
...
@@ -1764,7 +1764,7 @@ struct query_methods chat_info_methods = {
...
@@ -1764,7 +1764,7 @@ struct query_methods chat_info_methods = {
void
do_get_chat_info
(
peer_id_t
id
)
{
void
do_get_chat_info
(
peer_id_t
id
)
{
if
(
offline_mode
)
{
if
(
offline_mode
)
{
peer_t
*
C
=
user_chat
_get
(
id
);
peer_t
*
C
=
peer
_get
(
id
);
if
(
!
C
)
{
if
(
!
C
)
{
rprintf
(
"No such chat
\n
"
);
rprintf
(
"No such chat
\n
"
);
}
else
{
}
else
{
...
@@ -1815,7 +1815,7 @@ struct query_methods user_info_methods = {
...
@@ -1815,7 +1815,7 @@ struct query_methods user_info_methods = {
void
do_get_user_info
(
peer_id_t
id
)
{
void
do_get_user_info
(
peer_id_t
id
)
{
if
(
offline_mode
)
{
if
(
offline_mode
)
{
peer_t
*
C
=
user_chat
_get
(
id
);
peer_t
*
C
=
peer
_get
(
id
);
if
(
!
C
)
{
if
(
!
C
)
{
rprintf
(
"No such user
\n
"
);
rprintf
(
"No such user
\n
"
);
}
else
{
}
else
{
...
@@ -1826,7 +1826,7 @@ void do_get_user_info (peer_id_t id) {
...
@@ -1826,7 +1826,7 @@ void do_get_user_info (peer_id_t id) {
clear_packet
();
clear_packet
();
out_int
(
CODE_users_get_full_user
);
out_int
(
CODE_users_get_full_user
);
assert
(
get_peer_type
(
id
)
==
PEER_USER
);
assert
(
get_peer_type
(
id
)
==
PEER_USER
);
peer_t
*
U
=
user_chat
_get
(
id
);
peer_t
*
U
=
peer
_get
(
id
);
if
(
U
&&
U
->
user
.
access_hash
)
{
if
(
U
&&
U
->
user
.
access_hash
)
{
out_int
(
CODE_input_user_foreign
);
out_int
(
CODE_input_user_foreign
);
out_int
(
get_peer_id
(
id
));
out_int
(
get_peer_id
(
id
));
...
@@ -2557,18 +2557,18 @@ void do_send_create_encr_chat (void *x, unsigned char *random) {
...
@@ -2557,18 +2557,18 @@ void do_send_create_encr_chat (void *x, unsigned char *random) {
BN_bn2bin
(
r
,
(
void
*
)
g_a
);
BN_bn2bin
(
r
,
(
void
*
)
g_a
);
int
t
=
lrand48
();
int
t
=
lrand48
();
while
(
user_chat
_get
(
MK_ENCR_CHAT
(
t
)))
{
while
(
peer
_get
(
MK_ENCR_CHAT
(
t
)))
{
t
=
lrand48
();
t
=
lrand48
();
}
}
bl_do_encr_chat_init
(
t
,
user_id
,
(
void
*
)
random
,
(
void
*
)
g_a
);
bl_do_encr_chat_init
(
t
,
user_id
,
(
void
*
)
random
,
(
void
*
)
g_a
);
peer_t
*
_E
=
user_chat
_get
(
MK_ENCR_CHAT
(
t
));
peer_t
*
_E
=
peer
_get
(
MK_ENCR_CHAT
(
t
));
assert
(
_E
);
assert
(
_E
);
struct
secret_chat
*
E
=
&
_E
->
encr_chat
;
struct
secret_chat
*
E
=
&
_E
->
encr_chat
;
clear_packet
();
clear_packet
();
out_int
(
CODE_messages_request_encryption
);
out_int
(
CODE_messages_request_encryption
);
peer_t
*
U
=
user_chat
_get
(
MK_USER
(
E
->
user_id
));
peer_t
*
U
=
peer
_get
(
MK_USER
(
E
->
user_id
));
assert
(
U
);
assert
(
U
);
if
(
U
&&
U
->
user
.
access_hash
)
{
if
(
U
&&
U
->
user
.
access_hash
)
{
out_int
(
CODE_input_user_foreign
);
out_int
(
CODE_input_user_foreign
);
...
@@ -2768,7 +2768,7 @@ char *colors[4] = {COLOR_GREY, COLOR_CYAN, COLOR_BLUE, COLOR_GREEN};
...
@@ -2768,7 +2768,7 @@ char *colors[4] = {COLOR_GREY, COLOR_CYAN, COLOR_BLUE, COLOR_GREEN};
void
do_visualize_key
(
peer_id_t
id
)
{
void
do_visualize_key
(
peer_id_t
id
)
{
assert
(
get_peer_type
(
id
)
==
PEER_ENCR_CHAT
);
assert
(
get_peer_type
(
id
)
==
PEER_ENCR_CHAT
);
peer_t
*
P
=
user_chat
_get
(
id
);
peer_t
*
P
=
peer
_get
(
id
);
assert
(
P
);
assert
(
P
);
if
(
P
->
encr_chat
.
state
!=
sc_ok
)
{
if
(
P
->
encr_chat
.
state
!=
sc_ok
)
{
rprintf
(
"Chat is not initialized yet
\n
"
);
rprintf
(
"Chat is not initialized yet
\n
"
);
...
@@ -2851,7 +2851,7 @@ void do_add_user_to_chat (peer_id_t chat_id, peer_id_t id, int limit) {
...
@@ -2851,7 +2851,7 @@ void do_add_user_to_chat (peer_id_t chat_id, peer_id_t id, int limit) {
out_int
(
get_peer_id
(
chat_id
));
out_int
(
get_peer_id
(
chat_id
));
assert
(
get_peer_type
(
id
)
==
PEER_USER
);
assert
(
get_peer_type
(
id
)
==
PEER_USER
);
peer_t
*
U
=
user_chat
_get
(
id
);
peer_t
*
U
=
peer
_get
(
id
);
if
(
U
&&
U
->
user
.
access_hash
)
{
if
(
U
&&
U
->
user
.
access_hash
)
{
out_int
(
CODE_input_user_foreign
);
out_int
(
CODE_input_user_foreign
);
out_int
(
get_peer_id
(
id
));
out_int
(
get_peer_id
(
id
));
...
@@ -2870,7 +2870,7 @@ void do_del_user_from_chat (peer_id_t chat_id, peer_id_t id) {
...
@@ -2870,7 +2870,7 @@ void do_del_user_from_chat (peer_id_t chat_id, peer_id_t id) {
out_int
(
get_peer_id
(
chat_id
));
out_int
(
get_peer_id
(
chat_id
));
assert
(
get_peer_type
(
id
)
==
PEER_USER
);
assert
(
get_peer_type
(
id
)
==
PEER_USER
);
peer_t
*
U
=
user_chat
_get
(
id
);
peer_t
*
U
=
peer
_get
(
id
);
if
(
U
&&
U
->
user
.
access_hash
)
{
if
(
U
&&
U
->
user
.
access_hash
)
{
out_int
(
CODE_input_user_foreign
);
out_int
(
CODE_input_user_foreign
);
out_int
(
get_peer_id
(
id
));
out_int
(
get_peer_id
(
id
));
...
@@ -2888,7 +2888,7 @@ char *create_print_name (peer_id_t id, const char *a1, const char *a2, const cha
...
@@ -2888,7 +2888,7 @@ char *create_print_name (peer_id_t id, const char *a1, const char *a2, const cha
void
do_create_secret_chat
(
peer_id_t
id
)
{
void
do_create_secret_chat
(
peer_id_t
id
)
{
assert
(
get_peer_type
(
id
)
==
PEER_USER
);
assert
(
get_peer_type
(
id
)
==
PEER_USER
);
peer_t
*
U
=
user_chat
_get
(
id
);
peer_t
*
U
=
peer
_get
(
id
);
if
(
!
U
)
{
if
(
!
U
)
{
rprintf
(
"Can not create chat with unknown user
\n
"
);
rprintf
(
"Can not create chat with unknown user
\n
"
);
return
;
return
;
...
@@ -2906,7 +2906,7 @@ struct query_methods create_group_chat_methods = {
...
@@ -2906,7 +2906,7 @@ struct query_methods create_group_chat_methods = {
void
do_create_group_chat
(
peer_id_t
id
,
char
*
chat_topic
)
{
void
do_create_group_chat
(
peer_id_t
id
,
char
*
chat_topic
)
{
assert
(
get_peer_type
(
id
)
==
PEER_USER
);
assert
(
get_peer_type
(
id
)
==
PEER_USER
);
peer_t
*
U
=
user_chat
_get
(
id
);
peer_t
*
U
=
peer
_get
(
id
);
if
(
!
U
)
{
if
(
!
U
)
{
rprintf
(
"Can not create chat with unknown user
\n
"
);
rprintf
(
"Can not create chat with unknown user
\n
"
);
return
;
return
;
...
...
structures.c
View file @
9959c058
...
@@ -1108,7 +1108,7 @@ void fetch_encrypted_message (struct message *M) {
...
@@ -1108,7 +1108,7 @@ void fetch_encrypted_message (struct message *M) {
peer_id_t
chat
=
MK_ENCR_CHAT
(
to_id
);
peer_id_t
chat
=
MK_ENCR_CHAT
(
to_id
);
int
date
=
fetch_int
();
int
date
=
fetch_int
();
peer_t
*
P
=
user_chat
_get
(
chat
);
peer_t
*
P
=
peer
_get
(
chat
);
if
(
!
P
)
{
if
(
!
P
)
{
logprintf
(
"Encrypted message to unknown chat. Dropping
\n
"
);
logprintf
(
"Encrypted message to unknown chat. Dropping
\n
"
);
M
->
flags
|=
FLAG_MESSAGE_EMPTY
;
M
->
flags
|=
FLAG_MESSAGE_EMPTY
;
...
@@ -1218,7 +1218,7 @@ static int id_cmp (struct message *M1, struct message *M2) {
...
@@ -1218,7 +1218,7 @@ static int id_cmp (struct message *M1, struct message *M2) {
struct
user
*
fetch_alloc_user
(
void
)
{
struct
user
*
fetch_alloc_user
(
void
)
{
int
data
[
2
];
int
data
[
2
];
prefetch_data
(
data
,
8
);
prefetch_data
(
data
,
8
);
peer_t
*
U
=
user_chat
_get
(
MK_USER
(
data
[
1
]));
peer_t
*
U
=
peer
_get
(
MK_USER
(
data
[
1
]));
if
(
!
U
)
{
if
(
!
U
)
{
users_allocated
++
;
users_allocated
++
;
U
=
talloc0
(
sizeof
(
*
U
));
U
=
talloc0
(
sizeof
(
*
U
));
...
@@ -1234,7 +1234,7 @@ struct user *fetch_alloc_user (void) {
...
@@ -1234,7 +1234,7 @@ struct user *fetch_alloc_user (void) {
struct
secret_chat
*
fetch_alloc_encrypted_chat
(
void
)
{
struct
secret_chat
*
fetch_alloc_encrypted_chat
(
void
)
{
int
data
[
2
];
int
data
[
2
];
prefetch_data
(
data
,
8
);
prefetch_data
(
data
,
8
);
peer_t
*
U
=
user_chat
_get
(
MK_ENCR_CHAT
(
data
[
1
]));
peer_t
*
U
=
peer
_get
(
MK_ENCR_CHAT
(
data
[
1
]));
if
(
!
U
)
{
if
(
!
U
)
{
U
=
talloc0
(
sizeof
(
*
U
));
U
=
talloc0
(
sizeof
(
*
U
));
U
->
id
=
MK_ENCR_CHAT
(
data
[
1
]);
U
->
id
=
MK_ENCR_CHAT
(
data
[
1
]);
...
@@ -1271,7 +1271,7 @@ void insert_chat (peer_t *P) {
...
@@ -1271,7 +1271,7 @@ void insert_chat (peer_t *P) {
struct
user
*
fetch_alloc_user_full
(
void
)
{
struct
user
*
fetch_alloc_user_full
(
void
)
{
int
data
[
3
];
int
data
[
3
];
prefetch_data
(
data
,
12
);
prefetch_data
(
data
,
12
);
peer_t
*
U
=
user_chat
_get
(
MK_USER
(
data
[
2
]));
peer_t
*
U
=
peer
_get
(
MK_USER
(
data
[
2
]));
if
(
U
)
{
if
(
U
)
{
fetch_user_full
(
&
U
->
user
);
fetch_user_full
(
&
U
->
user
);
return
&
U
->
user
;
return
&
U
->
user
;
...
@@ -1419,7 +1419,7 @@ void message_add_peer (struct message *M) {
...
@@ -1419,7 +1419,7 @@ void message_add_peer (struct message *M) {
}
else
{
}
else
{
id
=
M
->
to_id
;
id
=
M
->
to_id
;
}
}
peer_t
*
P
=
user_chat
_get
(
id
);
peer_t
*
P
=
peer
_get
(
id
);
if
(
!
P
)
{
if
(
!
P
)
{
P
=
talloc0
(
sizeof
(
*
P
));
P
=
talloc0
(
sizeof
(
*
P
));
P
->
id
=
id
;
P
->
id
=
id
;
...
@@ -1477,7 +1477,7 @@ void message_del_peer (struct message *M) {
...
@@ -1477,7 +1477,7 @@ void message_del_peer (struct message *M) {
}
else
{
}
else
{
id
=
M
->
to_id
;
id
=
M
->
to_id
;
}
}
peer_t
*
P
=
user_chat
_get
(
id
);
peer_t
*
P
=
peer
_get
(
id
);
if
(
M
->
prev
)
{
if
(
M
->
prev
)
{
M
->
prev
->
next
=
M
->
next
;
M
->
prev
->
next
=
M
->
next
;
}
}
...
@@ -1576,7 +1576,7 @@ struct message *fetch_alloc_message_short_chat (void) {
...
@@ -1576,7 +1576,7 @@ struct message *fetch_alloc_message_short_chat (void) {
struct
chat
*
fetch_alloc_chat
(
void
)
{
struct
chat
*
fetch_alloc_chat
(
void
)
{
int
data
[
2
];
int
data
[
2
];
prefetch_data
(
data
,
8
);
prefetch_data
(
data
,
8
);
peer_t
*
U
=
user_chat
_get
(
MK_CHAT
(
data
[
1
]));
peer_t
*
U
=
peer
_get
(
MK_CHAT
(
data
[
1
]));
if
(
!
U
)
{
if
(
!
U
)
{
chats_allocated
++
;
chats_allocated
++
;
U
=
talloc0
(
sizeof
(
*
U
));
U
=
talloc0
(
sizeof
(
*
U
));
...
@@ -1592,7 +1592,7 @@ struct chat *fetch_alloc_chat (void) {
...
@@ -1592,7 +1592,7 @@ struct chat *fetch_alloc_chat (void) {
struct
chat
*
fetch_alloc_chat_full
(
void
)
{
struct
chat
*
fetch_alloc_chat_full
(
void
)
{
int
data
[
3
];
int
data
[
3
];
prefetch_data
(
data
,
12
);
prefetch_data
(
data
,
12
);
peer_t
*
U
=
user_chat
_get
(
MK_CHAT
(
data
[
2
]));
peer_t
*
U
=
peer
_get
(
MK_CHAT
(
data
[
2
]));
if
(
U
)
{
if
(
U
)
{
fetch_chat_full
(
&
U
->
chat
);
fetch_chat_full
(
&
U
->
chat
);
return
&
U
->
chat
;
return
&
U
->
chat
;
...
@@ -1628,7 +1628,7 @@ int print_stat (char *s, int len) {
...
@@ -1628,7 +1628,7 @@ int print_stat (char *s, int len) {
);
);
}
}
peer_t
*
user_chat
_get
(
peer_id_t
id
)
{
peer_t
*
peer
_get
(
peer_id_t
id
)
{
static
peer_t
U
;
static
peer_t
U
;
U
.
id
=
id
;
U
.
id
=
id
;
return
tree_lookup_peer
(
peer_tree
,
&
U
);
return
tree_lookup_peer
(
peer_tree
,
&
U
);
...
...
structures.h
View file @
9959c058
...
@@ -367,7 +367,7 @@ void free_chat (struct chat *U);
...
@@ -367,7 +367,7 @@ void free_chat (struct chat *U);
char
*
create_print_name
(
peer_id_t
id
,
const
char
*
a1
,
const
char
*
a2
,
const
char
*
a3
,
const
char
*
a4
);
char
*
create_print_name
(
peer_id_t
id
,
const
char
*
a1
,
const
char
*
a2
,
const
char
*
a3
,
const
char
*
a4
);
int
print_stat
(
char
*
s
,
int
len
);
int
print_stat
(
char
*
s
,
int
len
);
peer_t
*
user_chat
_get
(
peer_id_t
id
);
peer_t
*
peer
_get
(
peer_id_t
id
);
struct
message
*
message_get
(
long
long
id
);
struct
message
*
message_get
(
long
long
id
);
void
update_message_id
(
struct
message
*
M
,
long
long
id
);
void
update_message_id
(
struct
message
*
M
,
long
long
id
);
void
message_insert
(
struct
message
*
M
);
void
message_insert
(
struct
message
*
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