about summary refs log tree commit diff stats
path: root/src/plugins/python_plugins.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2016-04-07 22:06:14 +0100
committerJames Booth <boothj5@gmail.com>2016-04-07 22:06:14 +0100
commit271278dd20d1decfcfc06493698dc72e9fc24891 (patch)
treef5dc20544978f7da9b560e3884c93c5469ece02a /src/plugins/python_plugins.c
parentbfdc3b88072e0231c026fa6ebadc942343a56e2c (diff)
downloadprofani-tty-271278dd20d1decfcfc06493698dc72e9fc24891.tar.gz
Plugins: Added on_chat_win_focus
Diffstat (limited to 'src/plugins/python_plugins.c')
-rw-r--r--src/plugins/python_plugins.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/plugins/python_plugins.c b/src/plugins/python_plugins.c
index e16fb521..cf492693 100644
--- a/src/plugins/python_plugins.c
+++ b/src/plugins/python_plugins.c
@@ -123,6 +123,7 @@ python_plugin_create(const char *const filename)
         plugin->on_iq_stanza_receive = python_on_iq_stanza_receive_hook;
         plugin->on_contact_offline = python_on_contact_offline_hook;
         plugin->on_contact_presence = python_on_contact_presence_hook;
+        plugin->on_chat_win_focus = python_on_chat_win_focus_hook;
         g_free(module_name);
 
         allow_python_threads();
@@ -819,6 +820,27 @@ python_on_contact_presence_hook(ProfPlugin *plugin, const char *const barejid, c
 }
 
 void
+python_on_chat_win_focus_hook(ProfPlugin *plugin, const char *const barejid)
+{
+    disable_python_threads();
+    PyObject *p_args = Py_BuildValue("(s)", barejid);
+    PyObject *p_function;
+
+    PyObject *p_module = plugin->module;
+    if (PyObject_HasAttrString(p_module, "prof_on_chat_win_focus")) {
+        p_function = PyObject_GetAttrString(p_module, "prof_on_chat_win_focus");
+        python_check_error();
+        if (p_function && PyCallable_Check(p_function)) {
+            PyObject_CallObject(p_function, p_args);
+            python_check_error();
+            Py_XDECREF(p_function);
+        }
+    }
+
+    allow_python_threads();
+}
+
+void
 python_check_error(void)
 {
     if (PyErr_Occurred()) {