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) {
static
char
buf
[
1000
];
int
l
=
0
;
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
);
l
+=
tsnprintf
(
buf
+
l
,
999
-
l
,
COLOR_RED
"%.*s "
COLOR_NORMAL
,
100
,
U
->
print_name
);
}
...
...
@@ -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
);
}
else
if
(
IS_WORD
(
"rename_contact"
))
{
GET_PEER_USER
;
peer_t
*
U
=
user_chat
_get
(
id
);
peer_t
*
U
=
peer
_get
(
id
);
if
(
!
U
)
{
printf
(
"No such user
\n
"
);
RET
;
...
...
@@ -1407,13 +1407,13 @@ void print_service_message (struct message *M) {
pop_color
();
printf
(
" "
);
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
{
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
(
" "
);
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
)
{
case
CODE_message_action_empty
:
...
...
@@ -1440,12 +1440,12 @@ void print_service_message (struct message *M) {
break
;
case
CODE_message_action_chat_add_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
"
);
break
;
case
CODE_message_action_chat_delete_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
"
);
break
;
case
CODE_decrypted_message_action_set_message_t_t_l
:
...
...
@@ -1504,7 +1504,7 @@ void print_message (struct message *M) {
print_date
(
M
->
date
);
pop_color
();
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
);
if
(
M
->
unread
)
{
printf
(
" <<< "
);
...
...
@@ -1519,7 +1519,7 @@ void print_message (struct message *M) {
print_date
(
M
->
date
);
pop_color
();
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
);
if
(
M
->
unread
)
{
printf
(
" >>> "
);
...
...
@@ -1531,7 +1531,7 @@ void print_message (struct message *M) {
}
}
}
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
);
if
(
M
->
out
)
{
push_color
(
COLOR_GREEN
);
...
...
@@ -1575,9 +1575,9 @@ void print_message (struct message *M) {
print_date
(
M
->
date
);
pop_color
();
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
(
" "
);
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
))
{
push_color
(
COLOR_GREEN
);
}
else
{
...
...
@@ -1591,7 +1591,7 @@ void print_message (struct message *M) {
}
if
(
get_peer_type
(
M
->
fwd_from_id
)
==
PEER_USER
)
{
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
(
"] "
);
}
if
(
M
->
message
&&
strlen
(
M
->
message
))
{
...
...
lua-tg.c
View file @
9959c058
...
...
@@ -82,7 +82,7 @@ void push_chat (peer_t *P) {
void
push_encr_chat
(
peer_t
*
P
)
{
my_lua_checkstack
(
luaState
,
4
);
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
);
}
...
...
@@ -188,18 +188,18 @@ void push_message (struct message *M) {
if
(
get_peer_type
(
M
->
fwd_from_id
))
{
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_add_num_field
(
"fwd_date"
,
M
->
fwd_date
);
}
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_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_pushstring
(
luaState
,
"out"
);
...
...
mtproto-client.c
View file @
9959c058
...
...
@@ -846,7 +846,7 @@ void work_update_binlog (void) {
case CODE_update_user_name:
{
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) {
struct user *U = &UC->user;
if (U->first_name) { tfree_str (U->first_name); }
...
...
@@ -868,7 +868,7 @@ void work_update_binlog (void) {
case CODE_update_user_photo:
{
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 ();
if (UC) {
struct user *U = &UC->user;
...
...
@@ -952,7 +952,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
case
CODE_update_user_typing
:
{
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
)
{
print_start
();
push_color
(
COLOR_YELLOW
);
...
...
@@ -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
id
=
MK_USER
(
fetch_int
());
peer_t
*
C
=
user_chat
_get
(
chat_id
);
peer_t
*
U
=
user_chat
_get
(
id
);
peer_t
*
C
=
peer
_get
(
chat_id
);
peer_t
*
U
=
peer
_get
(
id
);
if
(
log_level
>=
2
)
{
print_start
();
push_color
(
COLOR_YELLOW
);
...
...
@@ -988,7 +988,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
case
CODE_update_user_status
:
{
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
)
{
fetch_user_status
(
&
U
->
user
.
status
);
if
(
log_level
>=
3
)
{
...
...
@@ -1011,7 +1011,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
case
CODE_update_user_name
:
{
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
))
{
int
l1
=
prefetch_strlen
();
char
*
f
=
fetch_str
(
l1
);
...
...
@@ -1038,7 +1038,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
case
CODE_update_user_photo
:
{
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
();
if
(
UC
&&
(
UC
->
flags
&
FLAG_CREATED
))
{
struct
user
*
U
=
&
UC
->
user
;
...
...
@@ -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
);
peer_id_t
chat_id
=
MK_CHAT
(
fetch_int
());
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
(
x
==
CODE_chat_participants
)
{
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) {
case
CODE_update_contact_registered
:
{
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
print_start
();
push_color
(
COLOR_YELLOW
);
...
...
@@ -1174,7 +1174,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
case
CODE_update_contact_link
:
{
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
();
push_color
(
COLOR_YELLOW
);
print_date
(
time
(
0
));
...
...
@@ -1198,7 +1198,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
case
CODE_update_activation
:
{
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
();
push_color
(
COLOR_YELLOW
);
print_date
(
time
(
0
));
...
...
@@ -1290,14 +1290,14 @@ void work_update (struct connection *c UU, long long msg_id UU) {
case
CODE_update_encrypted_chat_typing
:
{
peer_id_t
id
=
MK_ENCR_CHAT
(
fetch_int
());
peer_t
*
P
=
user_chat
_get
(
id
);
peer_t
*
P
=
peer
_get
(
id
);
print_start
();
push_color
(
COLOR_YELLOW
);
print_date
(
time
(
0
));
if
(
P
)
{
printf
(
" User "
);
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 "
);
print_encr_chat_name
(
id
,
P
);
printf
(
"
\n
"
);
...
...
@@ -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
fetch_int
();
// max_date
fetch_int
();
// date
peer_t
*
P
=
user_chat
_get
(
id
);
peer_t
*
P
=
peer
_get
(
id
);
int
x
=
-
1
;
if
(
P
&&
P
->
last
)
{
x
=
0
;
...
...
@@ -1331,7 +1331,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
push_color
(
COLOR_YELLOW
);
print_date
(
time
(
0
));
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
);
pop_color
();
print_end
();
...
...
@@ -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
());
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
))
{
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) {
push_color
(
COLOR_YELLOW
);
print_date
(
time
(
0
));
printf
(
" Chat "
);
print_chat_name
(
chat_id
,
user_chat
_get
(
chat_id
));
print_chat_name
(
chat_id
,
peer
_get
(
chat_id
));
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 "
);
print_user_name
(
inviter_id
,
user_chat
_get
(
inviter_id
));
print_user_name
(
inviter_id
,
peer
_get
(
inviter_id
));
printf
(
"
\n
"
);
pop_color
();
print_end
();
...
...
@@ -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
());
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
))
{
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) {
push_color
(
COLOR_YELLOW
);
print_date
(
time
(
0
));
printf
(
" Chat "
);
print_chat_name
(
chat_id
,
user_chat
_get
(
chat_id
));
print_chat_name
(
chat_id
,
peer
_get
(
chat_id
));
printf
(
": user "
);
print_user_name
(
user_id
,
user_chat
_get
(
user_id
));
print_user_name
(
user_id
,
peer
_get
(
user_id
));
printf
(
" deleted
\n
"
);
pop_color
();
print_end
();
...
...
@@ -1402,7 +1402,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
{
int
id
=
fetch_int
();
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
))
{
bl_do_user_set_blocked
(
&
P
->
user
,
blocked
);
}
...
...
queries.c
View file @
9959c058
...
...
@@ -940,7 +940,7 @@ 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
);
peer_t
*
P
=
peer
_get
(
M
->
to_id
);
if
(
!
P
||
P
->
encr_chat
.
state
!=
sc_ok
)
{
return
;
}
clear_packet
();
...
...
@@ -974,7 +974,7 @@ void do_send_encr_msg (struct message *M) {
do_send_encr_msg_action
(
M
);
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
;
}
clear_packet
();
...
...
@@ -1011,7 +1011,7 @@ void do_send_msg (struct message *M) {
void
do_send_message
(
peer_id_t
id
,
const
char
*
msg
,
int
len
)
{
if
(
get_peer_type
(
id
)
==
PEER_ENCR_CHAT
)
{
peer_t
*
P
=
user_chat
_get
(
id
);
peer_t
*
P
=
peer
_get
(
id
);
if
(
!
P
)
{
logprintf
(
"Can not send to unknown encrypted chat
\n
"
);
return
;
...
...
@@ -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
)
{
peer_t
*
P
=
user_chat
_get
(
id
);
peer_t
*
P
=
peer
_get
(
id
);
if
(
!
P
)
{
rprintf
(
"Unknown peer
\n
"
);
return
;
...
...
@@ -1169,7 +1169,7 @@ struct query_methods get_history_methods = {
};
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
;
}
struct
message
*
M
=
P
->
last
;
int
count
=
1
;
...
...
@@ -1248,13 +1248,13 @@ int get_dialogs_on_answer (struct query *q UU) {
peer_t
*
UC
;
switch
(
get_peer_type
(
plist
[
i
]))
{
case
PEER_USER
:
UC
=
user_chat
_get
(
plist
[
i
]);
UC
=
peer
_get
(
plist
[
i
]);
printf
(
"User "
);
print_user_name
(
plist
[
i
],
UC
);
printf
(
": %d unread
\n
"
,
dlist
[
2
*
i
+
1
]);
break
;
case
PEER_CHAT
:
UC
=
user_chat
_get
(
plist
[
i
]);
UC
=
peer
_get
(
plist
[
i
]);
printf
(
"Chat "
);
print_chat_name
(
plist
[
i
],
UC
);
printf
(
": %d unread
\n
"
,
dlist
[
2
*
i
+
1
]);
...
...
@@ -1312,7 +1312,7 @@ void out_peer_id (peer_id_t id) {
out_int
(
get_peer_id
(
id
));
break
;
case
PEER_USER
:
U
=
user_chat
_get
(
id
);
U
=
peer
_get
(
id
);
if
(
U
&&
U
->
user
.
access_hash
)
{
out_int
(
CODE_input_peer_foreign
);
out_int
(
get_peer_id
(
id
));
...
...
@@ -1487,7 +1487,7 @@ void send_part (struct send_file *f) {
out_int
(
CODE_messages_send_encrypted_file
);
out_int
(
CODE_input_encrypted_chat
);
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
);
out_long
(
P
->
encr_chat
.
access_hash
);
long
long
r
=
-
lrand48
()
*
(
1ll
<<
32
)
-
lrand48
();
...
...
@@ -1737,9 +1737,9 @@ void print_chat_info (struct chat *C) {
int
i
;
for
(
i
=
0
;
i
<
C
->
user_list_size
;
i
++
)
{
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 "
);
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 "
);
print_date_full
(
C
->
user_list
[
i
].
date
);
if
(
C
->
user_list
[
i
].
user_id
==
C
->
admin_id
)
{
...
...
@@ -1764,7 +1764,7 @@ struct query_methods chat_info_methods = {
void
do_get_chat_info
(
peer_id_t
id
)
{
if
(
offline_mode
)
{
peer_t
*
C
=
user_chat
_get
(
id
);
peer_t
*
C
=
peer
_get
(
id
);
if
(
!
C
)
{
rprintf
(
"No such chat
\n
"
);
}
else
{
...
...
@@ -1815,7 +1815,7 @@ struct query_methods user_info_methods = {
void
do_get_user_info
(
peer_id_t
id
)
{
if
(
offline_mode
)
{
peer_t
*
C
=
user_chat
_get
(
id
);
peer_t
*
C
=
peer
_get
(
id
);
if
(
!
C
)
{
rprintf
(
"No such user
\n
"
);
}
else
{
...
...
@@ -1826,7 +1826,7 @@ void do_get_user_info (peer_id_t id) {
clear_packet
();
out_int
(
CODE_users_get_full_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
)
{
out_int
(
CODE_input_user_foreign
);
out_int
(
get_peer_id
(
id
));
...
...
@@ -2557,18 +2557,18 @@ void do_send_create_encr_chat (void *x, unsigned char *random) {
BN_bn2bin
(
r
,
(
void
*
)
g_a
);
int
t
=
lrand48
();
while
(
user_chat
_get
(
MK_ENCR_CHAT
(
t
)))
{
while
(
peer
_get
(
MK_ENCR_CHAT
(
t
)))
{
t
=
lrand48
();
}
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
);
struct
secret_chat
*
E
=
&
_E
->
encr_chat
;
clear_packet
();
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
);
if
(
U
&&
U
->
user
.
access_hash
)
{
out_int
(
CODE_input_user_foreign
);
...
...
@@ -2768,7 +2768,7 @@ char *colors[4] = {COLOR_GREY, COLOR_CYAN, COLOR_BLUE, COLOR_GREEN};
void
do_visualize_key
(
peer_id_t
id
)
{
assert
(
get_peer_type
(
id
)
==
PEER_ENCR_CHAT
);
peer_t
*
P
=
user_chat
_get
(
id
);
peer_t
*
P
=
peer
_get
(
id
);
assert
(
P
);
if
(
P
->
encr_chat
.
state
!=
sc_ok
)
{
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) {
out_int
(
get_peer_id
(
chat_id
));
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
)
{
out_int
(
CODE_input_user_foreign
);
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) {
out_int
(
get_peer_id
(
chat_id
));
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
)
{
out_int
(
CODE_input_user_foreign
);
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
void
do_create_secret_chat
(
peer_id_t
id
)
{
assert
(
get_peer_type
(
id
)
==
PEER_USER
);
peer_t
*
U
=
user_chat
_get
(
id
);
peer_t
*
U
=
peer
_get
(
id
);
if
(
!
U
)
{
rprintf
(
"Can not create chat with unknown user
\n
"
);
return
;
...
...
@@ -2906,7 +2906,7 @@ struct query_methods create_group_chat_methods = {
void
do_create_group_chat
(
peer_id_t
id
,
char
*
chat_topic
)
{
assert
(
get_peer_type
(
id
)
==
PEER_USER
);
peer_t
*
U
=
user_chat
_get
(
id
);
peer_t
*
U
=
peer
_get
(
id
);
if
(
!
U
)
{
rprintf
(
"Can not create chat with unknown user
\n
"
);
return
;
...
...
structures.c
View file @
9959c058
...
...
@@ -1108,7 +1108,7 @@ void fetch_encrypted_message (struct message *M) {
peer_id_t
chat
=
MK_ENCR_CHAT
(
to_id
);
int
date
=
fetch_int
();
peer_t
*
P
=
user_chat
_get
(
chat
);
peer_t
*
P
=
peer
_get
(
chat
);
if
(
!
P
)
{
logprintf
(
"Encrypted message to unknown chat. Dropping
\n
"
);
M
->
flags
|=
FLAG_MESSAGE_EMPTY
;
...
...
@@ -1218,7 +1218,7 @@ static int id_cmp (struct message *M1, struct message *M2) {
struct
user
*
fetch_alloc_user
(
void
)
{
int
data
[
2
];
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
)
{
users_allocated
++
;
U
=
talloc0
(
sizeof
(
*
U
));
...
...
@@ -1234,7 +1234,7 @@ struct user *fetch_alloc_user (void) {
struct
secret_chat
*
fetch_alloc_encrypted_chat
(
void
)
{
int
data
[
2
];
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
)
{
U
=
talloc0
(
sizeof
(
*
U
));
U
->
id
=
MK_ENCR_CHAT
(
data
[
1
]);
...
...
@@ -1271,7 +1271,7 @@ void insert_chat (peer_t *P) {
struct
user
*
fetch_alloc_user_full
(
void
)
{
int
data
[
3
];
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
)
{
fetch_user_full
(
&
U
->
user
);
return
&
U
->
user
;
...
...
@@ -1419,7 +1419,7 @@ void message_add_peer (struct message *M) {
}
else
{
id
=
M
->
to_id
;
}
peer_t
*
P
=
user_chat
_get
(
id
);
peer_t
*
P
=
peer
_get
(
id
);
if
(
!
P
)
{
P
=
talloc0
(
sizeof
(
*
P
));
P
->
id
=
id
;
...
...
@@ -1477,7 +1477,7 @@ void message_del_peer (struct message *M) {
}
else
{
id
=
M
->
to_id
;
}
peer_t
*
P
=
user_chat
_get
(
id
);
peer_t
*
P
=
peer
_get
(
id
);
if
(
M
->
prev
)
{
M
->
prev
->
next
=
M
->
next
;
}
...
...
@@ -1576,7 +1576,7 @@ struct message *fetch_alloc_message_short_chat (void) {
struct
chat
*
fetch_alloc_chat
(
void
)
{
int
data
[
2
];
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
)
{
chats_allocated
++
;
U
=
talloc0
(
sizeof
(
*
U
));
...
...
@@ -1592,7 +1592,7 @@ struct chat *fetch_alloc_chat (void) {
struct
chat
*
fetch_alloc_chat_full
(
void
)
{
int
data
[
3
];
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
)
{
fetch_chat_full
(
&
U
->
chat
);
return
&
U
->
chat
;
...
...
@@ -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
;
U
.
id
=
id
;
return
tree_lookup_peer
(
peer_tree
,
&
U
);
...
...
structures.h
View file @
9959c058
...
...
@@ -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
);
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
);
void
update_message_id
(
struct
message
*
M
,
long
long
id
);
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