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
f496648d
Commit
f496648d
authored
Sep 21, 2014
by
vvaltman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make get_state once per hour
parent
1831415f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
0 deletions
+36
-0
loop.c
loop.c
+5
-0
queries.c
queries.c
+30
-0
tgl.h
tgl.h
+1
-0
No files found.
loop.c
View file @
f496648d
...
...
@@ -164,6 +164,7 @@ void net_loop (int flags, int (*is_end)(void)) {
}
event_add
(
ev
,
0
);
}
int
last_get_state
=
time
(
0
);
while
(
!
is_end
||
!
is_end
())
{
event_base_loop
(
tgl_state
.
ev_base
,
EVLOOP_ONCE
);
...
...
@@ -183,6 +184,10 @@ void net_loop (int flags, int (*is_end)(void)) {
}
exit
(
0
);
}
if
(
time
(
0
)
-
last_get_state
>
3600
)
{
tgl_do_lookup_state
();
last_get_state
=
time
(
0
);
}
write_state_file
();
update_prompt
();
if
(
unknown_user_list_pos
)
{
...
...
queries.c
View file @
f496648d
...
...
@@ -3216,6 +3216,21 @@ static int get_state_on_answer (struct query *q UU) {
return
0
;
}
static
int
lookup_state_on_answer
(
struct
query
*
q
UU
)
{
assert
(
fetch_int
()
==
(
int
)
CODE_updates_state
);
int
pts
=
fetch_int
();
int
qts
=
fetch_int
();
fetch_int
();
int
seq
=
fetch_int
();
fetch_int
();
if
(
pts
>
tgl_state
.
pts
||
qts
>
tgl_state
.
qts
||
seq
>
tgl_state
.
seq
)
{
tgl_do_get_difference
(
0
,
0
,
0
);
}
return
0
;
}
//int get_difference_active;
static
int
get_difference_on_answer
(
struct
query
*
q
UU
)
{
//get_difference_active = 0;
...
...
@@ -3307,6 +3322,11 @@ static int get_difference_on_answer (struct query *q UU) {
return
0
;
}
static
struct
query_methods
lookup_state_methods
=
{
.
on_answer
=
lookup_state_on_answer
,
.
type
=
TYPE_TO_PARAM
(
updates_state
)
};
static
struct
query_methods
get_state_methods
=
{
.
on_answer
=
get_state_on_answer
,
.
type
=
TYPE_TO_PARAM
(
updates_state
)
...
...
@@ -3317,6 +3337,16 @@ static struct query_methods get_difference_methods = {
.
type
=
TYPE_TO_PARAM
(
updates_difference
)
};
void
tgl_do_lookup_state
(
void
)
{
if
(
tgl_state
.
locks
&
TGL_LOCK_DIFF
)
{
return
;
}
clear_packet
();
tgl_do_insert_header
();
out_int
(
CODE_updates_get_state
);
tglq_send_query
(
tgl_state
.
DC_working
,
packet_ptr
-
packet_buffer
,
packet_buffer
,
&
lookup_state_methods
,
0
,
0
,
0
);
}
void
tgl_do_get_difference
(
int
sync_from_start
,
void
(
*
callback
)(
void
*
callback_extra
,
int
success
),
void
*
callback_extra
)
{
//get_difference_active = 1;
//difference_got = 0;
...
...
tgl.h
View file @
f496648d
...
...
@@ -273,6 +273,7 @@ void tgl_do_create_encr_chat_request (int user_id, void (*callback)(void *callba
void
tgl_do_create_secret_chat
(
tgl_peer_id_t
id
,
void
(
*
callback
)(
void
*
callback_extra
,
int
success
,
struct
tgl_secret_chat
*
E
),
void
*
callback_extra
);
void
tgl_do_accept_encr_chat_request
(
struct
tgl_secret_chat
*
E
,
void
(
*
callback
)(
void
*
callback_extra
,
int
success
,
struct
tgl_secret_chat
*
E
),
void
*
callback_extra
);
void
tgl_do_get_difference
(
int
sync_from_start
,
void
(
*
callback
)(
void
*
callback_extra
,
int
success
),
void
*
callback_extra
);
void
tgl_do_lookup_state
(
void
);
void
tgl_do_add_user_to_chat
(
tgl_peer_id_t
chat_id
,
tgl_peer_id_t
id
,
int
limit
,
void
(
*
callback
)(
void
*
callback_extra
,
int
success
,
struct
tgl_message
*
M
),
void
*
callback_extra
);
void
tgl_do_del_user_from_chat
(
tgl_peer_id_t
chat_id
,
tgl_peer_id_t
id
,
void
(
*
callback
)(
void
*
callback_extra
,
int
success
,
struct
tgl_message
*
M
),
void
*
callback_extra
);
void
tgl_do_create_group_chat
(
tgl_peer_id_t
id
,
char
*
chat_topic
,
void
(
*
callback
)(
void
*
callback_extra
,
int
success
,
struct
tgl_message
*
M
),
void
*
callback_extra
);
...
...
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