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
fd8a13ec
Commit
fd8a13ec
authored
Oct 23, 2013
by
vysheng
Browse files
Options
Browse Files
Download
Plain Diff
Merge github.com:vysheng/tg
parents
9dacff9d
3755d426
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
387 additions
and
6 deletions
+387
-6
LICENSE
LICENSE
+339
-0
interface.c
interface.c
+2
-3
mtproto-client.c
mtproto-client.c
+3
-0
net.c
net.c
+2
-2
queries.c
queries.c
+41
-1
No files found.
LICENSE
0 → 100644
View file @
fd8a13ec
This diff is collapsed.
Click to expand it.
interface.c
View file @
fd8a13ec
...
...
@@ -454,7 +454,7 @@ const char *message_media_type_str (struct message_media *M) {
case
CODE_message_media_video
:
return
"[video]"
;
case
CODE_message_media_geo
:
sprintf
(
buf
,
"[geo]
%.6lf:
%.6lf"
,
M
->
geo
.
latitude
,
M
->
geo
.
longitude
);
sprintf
(
buf
,
"[geo]
https://maps.google.com/maps?ll=%.6lf,
%.6lf"
,
M
->
geo
.
latitude
,
M
->
geo
.
longitude
);
return
buf
;
case
CODE_message_media_contact
:
snprintf
(
buf
,
999
,
"[contact] "
COLOR_RED
"%s %s"
COLOR_NORMAL
" %s"
,
M
->
first_name
,
M
->
last_name
,
M
->
phone
);
...
...
@@ -502,8 +502,7 @@ void print_media (struct message_media *M) {
printf
(
"[video]"
);
return
;
case
CODE_message_media_geo
:
printf
(
"[geo] "
);
printf
(
"%.6lf:%.6lf"
,
M
->
geo
.
latitude
,
M
->
geo
.
longitude
);
printf
(
"[geo] https://maps.google.com/?q=%.6lf,%.6lf"
,
M
->
geo
.
latitude
,
M
->
geo
.
longitude
);
return
;
case
CODE_message_media_contact
:
printf
(
"[contact] "
);
...
...
mtproto-client.c
View file @
fd8a13ec
...
...
@@ -1153,6 +1153,9 @@ int rpc_execute (struct connection *c, int op, int len) {
int
Response_len
=
len
;
if
(
verbosity
>=
2
)
{
logprintf
(
"Response_len = %d
\n
"
,
Response_len
);
}
assert
(
read_in
(
c
,
Response
,
Response_len
)
==
Response_len
);
Response
[
Response_len
]
=
0
;
if
(
verbosity
>=
2
)
{
...
...
net.c
View file @
fd8a13ec
...
...
@@ -298,12 +298,12 @@ void try_rpc_read (struct connection *c) {
unsigned
t
=
0
;
assert
(
read_in_lookup
(
c
,
&
len
,
1
)
==
1
);
if
(
len
>=
1
&&
len
<=
0x7e
)
{
if
(
c
->
in_bytes
<
(
int
)(
4
*
len
))
{
return
;
}
if
(
c
->
in_bytes
<
(
int
)(
1
+
4
*
len
))
{
return
;
}
}
else
{
if
(
c
->
in_bytes
<
4
)
{
return
;
}
assert
(
read_in_lookup
(
c
,
&
len
,
4
)
==
4
);
len
=
(
len
>>
8
);
if
(
c
->
in_bytes
<
(
int
)(
4
*
len
))
{
return
;
}
if
(
c
->
in_bytes
<
(
int
)(
4
+
4
*
len
))
{
return
;
}
len
=
0x7f
;
}
...
...
queries.c
View file @
fd8a13ec
...
...
@@ -56,6 +56,9 @@ struct query *query_get (long long id) {
int
alarm_query
(
struct
query
*
q
)
{
assert
(
q
);
if
(
verbosity
)
{
logprintf
(
"Alarm query %lld
\n
"
,
q
->
msg_id
);
}
q
->
ev
.
timeout
=
get_double_time
()
+
QUERY_TIMEOUT
;
insert_event_timer
(
&
q
->
ev
);
return
0
;
...
...
@@ -541,6 +544,39 @@ void do_send_text (union user_chat *U, char *file_name) {
}
}
int
mark_read_on_receive
(
struct
query
*
q
UU
)
{
assert
(
fetch_int
()
==
(
int
)
CODE_messages_affected_history
);
fetch_int
();
// pts
fetch_int
();
// seq
fetch_int
();
// offset
return
0
;
}
struct
query_methods
mark_read_methods
=
{
.
on_answer
=
mark_read_on_receive
};
void
do_messages_mark_read
(
union
user_chat
*
U
,
int
max_id
)
{
clear_packet
();
out_int
(
CODE_messages_read_history
);
if
(
U
->
id
<
0
)
{
out_int
(
CODE_input_peer_chat
);
out_int
(
-
U
->
id
);
}
else
{
if
(
U
->
user
.
access_hash
)
{
out_int
(
CODE_input_peer_foreign
);
out_int
(
U
->
id
);
out_long
(
U
->
user
.
access_hash
);
}
else
{
out_int
(
CODE_input_peer_contact
);
out_int
(
U
->
id
);
}
}
out_int
(
max_id
);
out_int
(
0
);
send_query
(
DC_working
,
packet_ptr
-
packet_buffer
,
packet_buffer
,
&
mark_read_methods
,
0
);
}
int
get_history_on_answer
(
struct
query
*
q
UU
)
{
static
struct
message
*
ML
[
10000
];
int
i
;
...
...
@@ -560,6 +596,7 @@ int get_history_on_answer (struct query *q UU) {
}
}
if
(
n
>
10000
)
{
n
=
10000
;
}
int
sn
=
n
;
for
(
i
=
n
-
1
;
i
>=
0
;
i
--
)
{
print_message
(
ML
[
i
]);
}
...
...
@@ -573,6 +610,9 @@ int get_history_on_answer (struct query *q UU) {
for
(
i
=
0
;
i
<
n
;
i
++
)
{
fetch_alloc_user
();
}
if
(
sn
>
0
)
{
do_messages_mark_read
(
q
->
extra
,
ML
[
0
]
->
id
);
}
return
0
;
}
...
...
@@ -600,7 +640,7 @@ void do_get_history (union user_chat *U, int limit) {
out_int
(
0
);
out_int
(
0
);
out_int
(
limit
);
send_query
(
DC_working
,
packet_ptr
-
packet_buffer
,
packet_buffer
,
&
get_history_methods
,
0
);
send_query
(
DC_working
,
packet_ptr
-
packet_buffer
,
packet_buffer
,
&
get_history_methods
,
U
);
}
int
get_dialogs_on_answer
(
struct
query
*
q
UU
)
{
...
...
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