about summary refs log tree commit diff stats
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/api.c6
-rw-r--r--src/plugins/api.h2
-rw-r--r--src/plugins/c_api.c7
-rw-r--r--src/plugins/profapi.c2
-rw-r--r--src/plugins/profapi.h2
-rw-r--r--src/plugins/python_api.c22
6 files changed, 41 insertions, 0 deletions
diff --git a/src/plugins/api.c b/src/plugins/api.c
index abec5300..a4a1f998 100644
--- a/src/plugins/api.c
+++ b/src/plugins/api.c
@@ -270,6 +270,12 @@ api_current_win_is_console(void)
     }
 }
 
+char*
+api_get_room_nick(const char *barejid)
+{
+    return muc_nick(barejid);
+}
+
 void
 api_log_debug(const char *message)
 {
diff --git a/src/plugins/api.h b/src/plugins/api.h
index 94788615..806de7f6 100644
--- a/src/plugins/api.h
+++ b/src/plugins/api.h
@@ -50,6 +50,8 @@ gboolean api_current_win_is_console(void);
 char* api_get_current_nick(void);
 char** api_get_current_occupants(void);
 
+char* api_get_room_nick(const char *barejid);
+
 void api_register_command(const char *const plugin_name, const char *command_name, int min_args, int max_args,
     char **synopsis, const char *description, char *arguments[][2], char **examples,
     void *callback, void(*callback_func)(PluginCommand *command, gchar **args), void(*callback_destroy)(void *callback));
diff --git a/src/plugins/c_api.c b/src/plugins/c_api.c
index 0b323268..1d3a73e9 100644
--- a/src/plugins/c_api.c
+++ b/src/plugins/c_api.c
@@ -195,6 +195,12 @@ c_api_get_current_occupants(void)
     return api_get_current_occupants();
 }
 
+static char*
+c_api_get_room_nick(const char *barejid)
+{
+    return api_get_room_nick(barejid);
+}
+
 static void
 c_api_log_debug(const char *message)
 {
@@ -380,6 +386,7 @@ c_api_init(void)
     prof_current_win_is_console = c_api_current_win_is_console;
     prof_get_current_nick = c_api_get_current_nick;
     prof_get_current_occupants = c_api_get_current_occupants;
+    prof_get_room_nick = c_api_get_room_nick;
     prof_log_debug = c_api_log_debug;
     prof_log_info = c_api_log_info;
     prof_log_warning = c_api_log_warning;
diff --git a/src/plugins/profapi.c b/src/plugins/profapi.c
index 4601d403..f3fd7e6f 100644
--- a/src/plugins/profapi.c
+++ b/src/plugins/profapi.c
@@ -63,6 +63,8 @@ int (*prof_current_win_is_console)(void) = NULL;
 char* (*prof_get_current_nick)(void) = NULL;
 char** (*prof_get_current_occupants)(void) = NULL;
 
+char* (*prof_get_room_nick)(const char *barejid) = NULL;
+
 void (*prof_log_debug)(const char *message) = NULL;
 void (*prof_log_info)(const char *message) = NULL;
 void (*prof_log_warning)(const char *message) = NULL;
diff --git a/src/plugins/profapi.h b/src/plugins/profapi.h
index 7bc2a9e9..d6fd78ed 100644
--- a/src/plugins/profapi.h
+++ b/src/plugins/profapi.h
@@ -75,6 +75,8 @@ int (*prof_current_win_is_console)(void);
 char* (*prof_get_current_nick)(void);
 char** (*prof_get_current_occupants)(void);
 
+char* (*prof_get_room_nick)(const char *barejid);
+
 void (*prof_log_debug)(const char *message);
 void (*prof_log_info)(const char *message);
 void (*prof_log_warning)(const char *message);
diff --git a/src/plugins/python_api.c b/src/plugins/python_api.c
index 0b78b055..b7145ecc 100644
--- a/src/plugins/python_api.c
+++ b/src/plugins/python_api.c
@@ -475,6 +475,27 @@ python_api_current_win_is_console(PyObject *self, PyObject *args)
     }
 }
 
+static PyObject*
+python_api_get_room_nick(PyObject *self, PyObject *args)
+{
+    PyObject *barejid = NULL;
+    if (!PyArg_ParseTuple(args, "O", &barejid)) {
+        Py_RETURN_NONE;
+    }
+
+    char *barejid_str = python_str_or_unicode_to_string(barejid);
+
+    allow_python_threads();
+    char *nick = api_get_room_nick(barejid_str);
+    free(barejid_str);
+    disable_python_threads();
+    if (nick) {
+        return Py_BuildValue("s", nick);
+    } else {
+        Py_RETURN_NONE;
+    }
+}
+
 static PyObject *
 python_api_log_debug(PyObject *self, PyObject *args)
 {
@@ -1095,6 +1116,7 @@ static PyMethodDef apiMethods[] = {
     { "get_current_nick", python_api_get_current_nick, METH_VARARGS, "Return nickname in current room." },
     { "get_current_occupants", python_api_get_current_occupants, METH_VARARGS, "Return list of occupants in current room." },
     { "current_win_is_console", python_api_current_win_is_console, METH_VARARGS, "Returns whether the current window is the console." },
+    { "get_room_nick", python_api_get_room_nick, METH_VARARGS, "Return the nickname used in the specified room, or None if not in the room." },
     { "log_debug", python_api_log_debug, METH_VARARGS, "Log a debug message" },
     { "log_info", python_api_log_info, METH_VARARGS, "Log an info message" },
     { "log_warning", python_api_log_warning, METH_VARARGS, "Log a warning message" },