]> jfr.im git - irc/evilnet/x3.git/commitdiff
mod-python: add emb_timeq_del function
authorhstuart <redacted>
Fri, 9 Oct 2009 14:24:32 +0000 (14:24 +0000)
committerhstuart <redacted>
Fri, 9 Oct 2009 14:24:32 +0000 (14:24 +0000)
ChangeLog
src/mod-python.c

index eb58351afc4b6c087f23015b63ef41399de86b2b..975f56f14a222552e0b6ec2879ac5c81c29c4ea6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,10 @@
 /***********************************************************************
 X3 ChangeLog
 
 /***********************************************************************
 X3 ChangeLog
 
+2009-10-09  Henrik Stuart <evilnet@hstuart.dk>
+
+       * src/mod-python.c: add emb_timeq_del function.
+
 2009-10-09  Henrik Stuart <evilnet@hstuart.dk>
 
        * src/mod-python.c: add emb_timeq_add function.
 2009-10-09  Henrik Stuart <evilnet@hstuart.dk>
 
        * src/mod-python.c: add emb_timeq_add function.
index 231a9b17c694c58a45bc77d6265a6cc6bc041a72..5548cc625193b42f58fecb4e40949f03339c2721 100644 (file)
@@ -721,6 +721,24 @@ emb_timeq_add(UNUSED_ARG(PyObject* self), PyObject* args) {
     return Py_None;
 }
 
     return Py_None;
 }
 
+static PyObject*
+emb_timeq_del(UNUSED_ARG(PyObject* self), PyObject* args) {
+    /* NOTE:
+     * This function will delete all python-added callbacks registered
+     * to run at the given time, regardless of their data. This is due to
+     * the unnecessary extra burden it would require to get the same data for
+     * multiple runs.
+     */
+    time_t when;
+
+    if (!PyArg_ParseTuple(args, "l", &when))
+        return NULL;
+
+    timeq_del(when, py_timeq_callback, NULL, TIMEQ_IGNORE_DATA);
+
+    return Py_None;
+}
+
 static PyMethodDef EmbMethods[] = {
     /* Communication methods */
     {"dump", emb_dump, METH_VARARGS, "Dump raw P10 line to server"},
 static PyMethodDef EmbMethods[] = {
     /* Communication methods */
     {"dump", emb_dump, METH_VARARGS, "Dump raw P10 line to server"},
@@ -742,7 +760,8 @@ static PyMethodDef EmbMethods[] = {
 //TODO:    {"config_set", emb_config_set, METH_VARARGS, "change a config setting 'on-the-fly'."},
 //
     {"timeq_add", emb_timeq_add, METH_VARARGS, "add function to callback to the event system"},
 //TODO:    {"config_set", emb_config_set, METH_VARARGS, "change a config setting 'on-the-fly'."},
 //
     {"timeq_add", emb_timeq_add, METH_VARARGS, "add function to callback to the event system"},
-//TODO:    {"timeq_del", emb_timeq_new, METH_VARARGS, "some kind of interface to the timed event system."},
+    {"timeq_del", emb_timeq_del, METH_VARARGS, "remove function to callback from the event system"},
+
     /* Information gathering methods */
     {"get_user", emb_get_user, METH_VARARGS, "Get details about a nickname"},
     {"get_users", emb_get_users, METH_VARARGS, "Get all connected users"},
     /* Information gathering methods */
     {"get_user", emb_get_user, METH_VARARGS, "Get details about a nickname"},
     {"get_users", emb_get_users, METH_VARARGS, "Get all connected users"},