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
a06507d4
Commit
a06507d4
authored
May 28, 2015
by
Vincent Castellano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optionally ping the python script every time we do a loop update in tg.
parent
7c9f0978
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
0 deletions
+28
-0
python-tg.c
python-tg.c
+28
-0
No files found.
python-tg.c
View file @
a06507d4
...
@@ -105,6 +105,7 @@ PyObject *_py_new_msg;
...
@@ -105,6 +105,7 @@ PyObject *_py_new_msg;
PyObject
*
_py_secret_chat_update
;
PyObject
*
_py_secret_chat_update
;
PyObject
*
_py_user_update
;
PyObject
*
_py_user_update
;
PyObject
*
_py_chat_update
;
PyObject
*
_py_chat_update
;
PyObject
*
_py_on_loop
;
PyObject
*
get_peer
(
tgl_peer_id_t
id
,
tgl_peer_t
*
P
);
PyObject
*
get_peer
(
tgl_peer_id_t
id
,
tgl_peer_t
*
P
);
...
@@ -390,6 +391,27 @@ void py_chat_update (struct tgl_chat *C, unsigned flags) {
...
@@ -390,6 +391,27 @@ void py_chat_update (struct tgl_chat *C, unsigned flags) {
Py_XDECREF
(
result
);
Py_XDECREF
(
result
);
}
}
void
py_on_loop
()
{
if
(
!
python_loaded
)
{
return
;
}
PyObject
*
result
;
if
(
_py_on_loop
==
NULL
)
{
logprintf
(
"Callback not set for on_chat_update"
);
return
;
}
result
=
PyEval_CallObject
(
_py_on_loop
,
Py_None
);
if
(
result
==
NULL
)
PyErr_Print
();
else
if
(
PyUnicode_Check
(
result
))
logprintf
(
"python: %s
\n
"
,
PyBytes_AsString
(
PyUnicode_AsASCIIString
(
result
)));
Py_XDECREF
(
result
);
}
////extern tgl_peer_t *Peers[];
////extern tgl_peer_t *Peers[];
////extern int peer_num;
////extern int peer_num;
//
//
...
@@ -737,6 +759,10 @@ void py_str_cb (struct tgl_state *TLSR, void *cb_extra, int success, const char
...
@@ -737,6 +759,10 @@ void py_str_cb (struct tgl_state *TLSR, void *cb_extra, int success, const char
void
py_do_all
(
void
)
{
void
py_do_all
(
void
)
{
int
p
=
0
;
int
p
=
0
;
// ping the python thread that we're doing the loop
py_on_loop
();
while
(
p
<
pos
)
{
while
(
p
<
pos
)
{
assert
(
p
+
2
<=
pos
);
assert
(
p
+
2
<=
pos
);
...
@@ -1116,6 +1142,7 @@ TGL_PYTHON_CALLBACK("on_msg_receive", _py_new_msg);
...
@@ -1116,6 +1142,7 @@ TGL_PYTHON_CALLBACK("on_msg_receive", _py_new_msg);
TGL_PYTHON_CALLBACK
(
"on_secret_chat_update"
,
_py_secret_chat_update
);
TGL_PYTHON_CALLBACK
(
"on_secret_chat_update"
,
_py_secret_chat_update
);
TGL_PYTHON_CALLBACK
(
"on_user_update"
,
_py_user_update
);
TGL_PYTHON_CALLBACK
(
"on_user_update"
,
_py_user_update
);
TGL_PYTHON_CALLBACK
(
"on_chat_update"
,
_py_chat_update
);
TGL_PYTHON_CALLBACK
(
"on_chat_update"
,
_py_chat_update
);
TGL_PYTHON_CALLBACK
(
"on_loop"
,
_py_on_loop
);
static
PyMethodDef
py_tgl_methods
[]
=
{
static
PyMethodDef
py_tgl_methods
[]
=
{
{
"get_contact_list"
,
py_contact_list
,
METH_VARARGS
,
"retrieve contact list"
},
{
"get_contact_list"
,
py_contact_list
,
METH_VARARGS
,
"retrieve contact list"
},
...
@@ -1169,6 +1196,7 @@ static PyMethodDef py_tgl_methods[] = {
...
@@ -1169,6 +1196,7 @@ static PyMethodDef py_tgl_methods[] = {
{
"set_on_secret_chat_update"
,
set_py_secret_chat_update
,
METH_VARARGS
,
""
},
{
"set_on_secret_chat_update"
,
set_py_secret_chat_update
,
METH_VARARGS
,
""
},
{
"set_on_user_update"
,
set_py_user_update
,
METH_VARARGS
,
""
},
{
"set_on_user_update"
,
set_py_user_update
,
METH_VARARGS
,
""
},
{
"set_on_chat_update"
,
set_py_chat_update
,
METH_VARARGS
,
""
},
{
"set_on_chat_update"
,
set_py_chat_update
,
METH_VARARGS
,
""
},
{
"set_on_loop"
,
set_py_on_loop
,
METH_VARARGS
,
""
},
{
NULL
,
NULL
,
0
,
NULL
}
{
NULL
,
NULL
,
0
,
NULL
}
};
};
...
...
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