char* python_pre_room_message_display_hook(ProfPlugin *plugin, const char * const barejid, const char * const nick, const char *message) { disable_python_threads(); PyObject *p_args = Py_BuildValue("sss", barejid, nick, message); PyObject *p_function; PyObject *p_module = plugin->module; if (PyObject_HasAttrString(p_module, "prof_pre_room_message_display")) { p_function = PyObject_GetAttrString(p_module, "prof_pre_room_message_display"); python_check_error(); if (p_function && PyCallable_Check(p_function)) { PyObject *result = PyObject_CallObject(p_function, p_args); python_check_error(); Py_XDECREF(p_function); Py_XDECREF(p_args); return _handle_string_or_none_result(plugin, result, "prof_pre_room_message_display"); } } Py_XDECREF(p_args); allow_python_threads(); return NULL; }
static PyObject* python_api_incoming_message(PyObject *self, PyObject *args) { PyObject *barejid = NULL; PyObject *resource = NULL; PyObject *message = NULL; if (!PyArg_ParseTuple(args, "OOO", &barejid, &resource, &message)) { Py_RETURN_NONE; } char *barejid_str = python_str_or_unicode_to_string(barejid); char *resource_str = python_str_or_unicode_to_string(resource); char *message_str = python_str_or_unicode_to_string(message); allow_python_threads(); api_incoming_message(barejid_str, resource_str, message_str); free(barejid_str); free(resource_str); free(message_str); disable_python_threads(); Py_RETURN_NONE; }
static PyObject* python_api_settings_string_list_add(PyObject *self, PyObject *args) { PyObject *group = NULL; PyObject *key = NULL; PyObject *val = NULL; if (!PyArg_ParseTuple(args, "OOO", &group, &key, &val)) { Py_RETURN_NONE; } char *group_str = python_str_or_unicode_to_string(group); char *key_str = python_str_or_unicode_to_string(key); char *val_str = python_str_or_unicode_to_string(val); allow_python_threads(); api_settings_string_list_add(group_str, key_str, val_str); free(group_str); free(key_str); free(val_str); disable_python_threads(); Py_RETURN_NONE; }
static PyObject* python_api_room_show_themed(PyObject *self, PyObject *args) { PyObject *roomjid = NULL; PyObject *group = NULL; PyObject *key = NULL; PyObject *def = NULL; PyObject *ch = NULL; PyObject *message = NULL; if (!PyArg_ParseTuple(args, "OOOOOO", &roomjid, &group, &key, &def, &ch, &message)) { Py_RETURN_NONE; } char *roomjid_str = python_str_or_unicode_to_string(roomjid); char *group_str = python_str_or_unicode_to_string(group); char *key_str = python_str_or_unicode_to_string(key); char *def_str = python_str_or_unicode_to_string(def); char *ch_str = python_str_or_unicode_to_string(ch); char *message_str = python_str_or_unicode_to_string(message); allow_python_threads(); int res = api_room_show_themed(roomjid_str, group_str, key_str, def_str, ch_str, message_str); free(roomjid_str); free(group_str); free(key_str); free(def_str); free(ch_str); free(message_str); disable_python_threads(); if (res) { return Py_BuildValue("O", Py_True); } else { return Py_BuildValue("O", Py_False); } }
static PyObject* python_api_room_show(PyObject *self, PyObject *args) { PyObject *roomjid = NULL; PyObject *message = NULL; if (!PyArg_ParseTuple(args, "OO", &roomjid, &message)) { Py_RETURN_NONE; } char *roomjid_str = python_str_or_unicode_to_string(roomjid); char *message_str = python_str_or_unicode_to_string(message); allow_python_threads(); int res = api_room_show(roomjid_str, message_str); free(roomjid_str); free(message_str); disable_python_threads(); if (res) { return Py_BuildValue("O", Py_True); } else { return Py_BuildValue("O", Py_False); } }
static PyObject* python_api_room_set_titlebar_enctext(PyObject *self, PyObject *args) { PyObject *roomjid = NULL; PyObject *enctext = NULL; if (!PyArg_ParseTuple(args, "OO", &roomjid, &enctext)) { Py_RETURN_NONE; } char *roomjid_str = python_str_or_unicode_to_string(roomjid); char *enctext_str = python_str_or_unicode_to_string(enctext); allow_python_threads(); int res = api_room_set_titlebar_enctext(roomjid_str, enctext_str); free(roomjid_str); free(enctext_str); disable_python_threads(); if (res) { return Py_BuildValue("O", Py_True); } else { return Py_BuildValue("O", Py_False); } }
static PyObject* python_api_chat_set_outgoing_char(PyObject *self, PyObject *args) { PyObject *barejid = NULL; PyObject *ch = NULL; if (!PyArg_ParseTuple(args, "OO", &barejid, &ch)) { Py_RETURN_NONE; } char *barejid_str = python_str_or_unicode_to_string(barejid); char *ch_str = python_str_or_unicode_to_string(ch); allow_python_threads(); int res = api_chat_set_outgoing_char(barejid_str, ch_str); free(barejid_str); free(ch_str); disable_python_threads(); if (res) { return Py_BuildValue("O", Py_True); } else { return Py_BuildValue("O", Py_False); } }
static PyObject* python_api_register_command(PyObject *self, PyObject *args) { PyObject *command_name = NULL; int min_args = 0; int max_args = 0; PyObject *synopsis = NULL; PyObject *description = NULL; PyObject *arguments = NULL; PyObject *examples = NULL; PyObject *p_callback = NULL; if (!PyArg_ParseTuple(args, "OiiOOOOO", &command_name, &min_args, &max_args, &synopsis, &description, &arguments, &examples, &p_callback)) { Py_RETURN_NONE; } char *command_name_str = python_str_or_unicode_to_string(command_name); char *description_str = python_str_or_unicode_to_string(description); char *plugin_name = _python_plugin_name(); log_debug("Register command %s for %s", command_name_str, plugin_name); if (p_callback && PyCallable_Check(p_callback)) { Py_ssize_t len = PyList_Size(synopsis); char *c_synopsis[len == 0 ? 0 : len+1]; Py_ssize_t i = 0; for (i = 0; i < len; i++) { PyObject *item = PyList_GetItem(synopsis, i); char *c_item = python_str_or_unicode_to_string(item); c_synopsis[i] = c_item; } c_synopsis[len] = NULL; Py_ssize_t args_len = PyList_Size(arguments); char *c_arguments[args_len == 0 ? 0 : args_len+1][2]; i = 0; for (i = 0; i < args_len; i++) { PyObject *item = PyList_GetItem(arguments, i); Py_ssize_t len2 = PyList_Size(item); if (len2 != 2) { Py_RETURN_NONE; } PyObject *arg = PyList_GetItem(item, 0); char *c_arg = python_str_or_unicode_to_string(arg); c_arguments[i][0] = c_arg; PyObject *desc = PyList_GetItem(item, 1); char *c_desc = python_str_or_unicode_to_string(desc); c_arguments[i][1] = c_desc; } c_arguments[args_len][0] = NULL; c_arguments[args_len][1] = NULL; len = PyList_Size(examples); char *c_examples[len == 0 ? 0 : len+1]; i = 0; for (i = 0; i < len; i++) { PyObject *item = PyList_GetItem(examples, i); char *c_item = python_str_or_unicode_to_string(item); c_examples[i] = c_item; } c_examples[len] = NULL; allow_python_threads(); api_register_command(plugin_name, command_name_str, min_args, max_args, c_synopsis, description_str, c_arguments, c_examples, p_callback, python_command_callback, NULL); free(command_name_str); free(description_str); i = 0; while (c_synopsis[i] != NULL) { free(c_synopsis[i++]); } i = 0; while (c_arguments[i] != NULL && c_arguments[i][0] != NULL) { free(c_arguments[i][0]); free(c_arguments[i][1]); i++; } i = 0; while (c_examples[i] != NULL) { free(c_examples[i++]); } disable_python_threads(); } free(plugin_name); Py_RETURN_NONE; }