about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/c_plugins.c15
-rw-r--r--src/plugins/c_plugins.h1
-rw-r--r--src/plugins/plugins.c11
-rw-r--r--src/plugins/plugins.h2
-rw-r--r--src/plugins/python_plugins.c22
-rw-r--r--src/plugins/python_plugins.h1
-rw-r--r--src/window_list.c1
7 files changed, 53 insertions, 0 deletions
diff --git a/src/plugins/c_plugins.c b/src/plugins/c_plugins.c
index fb99765f..7caa742e 100644
--- a/src/plugins/c_plugins.c
+++ b/src/plugins/c_plugins.c
@@ -106,6 +106,7 @@ c_plugin_create(const char *const filename)
     plugin->on_contact_offline = c_on_contact_offline_hook;
     plugin->on_contact_presence = c_on_contact_presence_hook;
     plugin->on_chat_win_focus = c_on_chat_win_focus_hook;
+    plugin->on_room_win_focus = c_on_room_win_focus_hook;
 
     g_string_free(path, TRUE);
     g_free(module_name);
@@ -488,6 +489,20 @@ c_on_chat_win_focus_hook(ProfPlugin *plugin, const char *const barejid)
 }
 
 void
+c_on_room_win_focus_hook(ProfPlugin *plugin, const char *const roomjid)
+{
+    void *f = NULL;
+    void (*func)(const char *const __roomjid);
+    assert(plugin && plugin->module);
+
+    if (NULL == (f = dlsym(plugin->module, "prof_on_room_win_focus")))
+        return;
+
+    func = (void (*)(const char *const))f;
+    func(roomjid);
+}
+
+void
 c_plugin_destroy(ProfPlugin *plugin)
 {
     assert (plugin && plugin->module);
diff --git a/src/plugins/c_plugins.h b/src/plugins/c_plugins.h
index e9ae0c04..b8725b3b 100644
--- a/src/plugins/c_plugins.h
+++ b/src/plugins/c_plugins.h
@@ -85,5 +85,6 @@ void c_on_contact_presence_hook(ProfPlugin *plugin, const char *const barejid, c
     const char *const presence, const char *const status, const int priority);
 
 void c_on_chat_win_focus_hook(ProfPlugin *plugin, const char *const barejid);
+void c_on_room_win_focus_hook(ProfPlugin *plugin, const char *const roomjid);
 
 #endif
diff --git a/src/plugins/plugins.c b/src/plugins/plugins.c
index 910484a9..f0c3de01 100644
--- a/src/plugins/plugins.c
+++ b/src/plugins/plugins.c
@@ -560,6 +560,17 @@ plugins_on_chat_win_focus(const char *const barejid)
 }
 
 void
+plugins_on_room_win_focus(const char *const roomjid)
+{
+    GSList *curr = plugins;
+    while (curr) {
+        ProfPlugin *plugin = curr->data;
+        plugin->on_room_win_focus(plugin, roomjid);
+        curr = g_slist_next(curr);
+    }
+}
+
+void
 plugins_shutdown(void)
 {
     GSList *curr = plugins;
diff --git a/src/plugins/plugins.h b/src/plugins/plugins.h
index df9293eb..aa3040ab 100644
--- a/src/plugins/plugins.h
+++ b/src/plugins/plugins.h
@@ -92,6 +92,7 @@ typedef struct prof_plugin_t {
         const char *const presence, const char *const status, const int priority);
 
     void (*on_chat_win_focus)(struct prof_plugin_t* plugin, const char *const barejid);
+    void (*on_room_win_focus)(struct prof_plugin_t* plugin, const char *const roomjid);
 } ProfPlugin;
 
 void plugins_init(void);
@@ -138,6 +139,7 @@ void plugins_on_contact_presence(const char *const barejid, const char *const re
     const char *const status, const int priority);
 
 void plugins_on_chat_win_focus(const char *const barejid);
+void plugins_on_room_win_focus(const char *const roomjid);
 
 gboolean plugins_run_command(const char * const cmd);
 void plugins_run_timed(void);
diff --git a/src/plugins/python_plugins.c b/src/plugins/python_plugins.c
index cf492693..67afc551 100644
--- a/src/plugins/python_plugins.c
+++ b/src/plugins/python_plugins.c
@@ -124,6 +124,7 @@ python_plugin_create(const char *const filename)
         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;
+        plugin->on_room_win_focus = python_on_room_win_focus_hook;
         g_free(module_name);
 
         allow_python_threads();
@@ -841,6 +842,27 @@ python_on_chat_win_focus_hook(ProfPlugin *plugin, const char *const barejid)
 }
 
 void
+python_on_room_win_focus_hook(ProfPlugin *plugin, const char *const roomjid)
+{
+    disable_python_threads();
+    PyObject *p_args = Py_BuildValue("(s)", roomjid);
+    PyObject *p_function;
+
+    PyObject *p_module = plugin->module;
+    if (PyObject_HasAttrString(p_module, "prof_on_room_win_focus")) {
+        p_function = PyObject_GetAttrString(p_module, "prof_on_room_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()) {
diff --git a/src/plugins/python_plugins.h b/src/plugins/python_plugins.h
index f50a649b..2e914b53 100644
--- a/src/plugins/python_plugins.h
+++ b/src/plugins/python_plugins.h
@@ -83,5 +83,6 @@ void python_on_contact_presence_hook(ProfPlugin *plugin, const char *const barej
     const char *const presence, const char *const status, const int priority);
 
 void python_on_chat_win_focus_hook(ProfPlugin *plugin, const char *const barejid);
+void python_on_room_win_focus_hook(ProfPlugin *plugin, const char *const roomjid);
 
 #endif
diff --git a/src/window_list.c b/src/window_list.c
index de057a66..7fcc0172 100644
--- a/src/window_list.c
+++ b/src/window_list.c
@@ -333,6 +333,7 @@ wins_set_current_by_num(int i)
             mucwin->unread = 0;
             mucwin->unread_mentions = FALSE;
             mucwin->unread_triggers = FALSE;
+            plugins_on_room_win_focus(mucwin->roomjid);
         } else if (window->type == WIN_PRIVATE) {
             ProfPrivateWin *privatewin = (ProfPrivateWin*) window;
             privatewin->unread = 0;