Revert "Apply coding style"

This reverts commit 9b55f2dec0.

Sorting the includes creates some problems.
This commit is contained in:
Michael Vetter
2020-07-07 13:53:30 +02:00
parent 28fde3cd01
commit a4cadf78fa
214 changed files with 17576 additions and 19566 deletions

View File

@@ -36,10 +36,10 @@
#undef _XOPEN_SOURCE
#include <Python.h>
#include "config.h"
#include "config/files.h"
#include "config/preferences.h"
#include "log.h"
#include "config.h"
#include "config/preferences.h"
#include "config/files.h"
#include "plugins/api.h"
#include "plugins/callbacks.h"
#include "plugins/disco.h"
@@ -48,14 +48,14 @@
#include "plugins/python_plugins.h"
#include "ui/ui.h"
static PyThreadState* thread_state;
static GHashTable* loaded_modules;
static PyThreadState *thread_state;
static GHashTable *loaded_modules;
static void _python_undefined_error(ProfPlugin* plugin, char* hook, char* type);
static void _python_type_error(ProfPlugin* plugin, char* hook, char* type);
static void _python_undefined_error(ProfPlugin *plugin, char *hook, char *type);
static void _python_type_error(ProfPlugin *plugin, char *hook, char *type);
static char* _handle_string_or_none_result(ProfPlugin* plugin, PyObject* result, char* hook);
static gboolean _handle_boolean_result(ProfPlugin* plugin, PyObject* result, char* hook);
static char* _handle_string_or_none_result(ProfPlugin *plugin, PyObject *result, char *hook);
static gboolean _handle_boolean_result(ProfPlugin *plugin, PyObject *result, char *hook);
void
allow_python_threads()
@@ -70,7 +70,7 @@ disable_python_threads()
}
static void
_unref_module(PyObject* module)
_unref_module(PyObject *module)
{
Py_XDECREF(module);
}
@@ -84,9 +84,9 @@ python_get_version_string(void)
gchar*
python_get_version_number(void)
{
const char* version_str = Py_GetVersion();
gchar** split = g_strsplit(version_str, " ", 0);
gchar* version_number = g_strdup(split[0]);
const char *version_str = Py_GetVersion();
gchar **split = g_strsplit(version_str, " ", 0);
gchar *version_number = g_strdup(split[0]);
g_strfreev(split);
return version_number;
@@ -99,8 +99,8 @@ python_env_init(void)
python_init_prof();
char* plugins_dir = files_get_data_path(DIR_PLUGINS);
GString* path = g_string_new("import sys\n");
char *plugins_dir = files_get_data_path(DIR_PLUGINS);
GString *path = g_string_new("import sys\n");
g_string_append(path, "sys.path.append(\"");
g_string_append(path, plugins_dir);
g_string_append(path, "/\")\n");
@@ -115,15 +115,15 @@ python_env_init(void)
}
ProfPlugin*
python_plugin_create(const char* const filename)
python_plugin_create(const char *const filename)
{
disable_python_threads();
PyObject* p_module = g_hash_table_lookup(loaded_modules, filename);
PyObject *p_module = g_hash_table_lookup(loaded_modules, filename);
if (p_module) {
p_module = PyImport_ReloadModule(p_module);
} else {
gchar* module_name = g_strndup(filename, strlen(filename) - 3);
gchar *module_name = g_strndup(filename, strlen(filename) - 3);
p_module = PyImport_ImportModule(module_name);
if (p_module) {
g_hash_table_insert(loaded_modules, strdup(filename), p_module);
@@ -133,7 +133,7 @@ python_plugin_create(const char* const filename)
python_check_error();
if (p_module) {
ProfPlugin* plugin = malloc(sizeof(ProfPlugin));
ProfPlugin *plugin = malloc(sizeof(ProfPlugin));
plugin->name = strdup(filename);
plugin->lang = LANG_PYTHON;
plugin->module = p_module;
@@ -177,14 +177,14 @@ python_plugin_create(const char* const filename)
}
void
python_init_hook(ProfPlugin* plugin, const char* const version, const char* const status, const char* const account_name,
const char* const fulljid)
python_init_hook(ProfPlugin *plugin, const char *const version, const char *const status, const char *const account_name,
const char *const fulljid)
{
disable_python_threads();
PyObject* p_args = Py_BuildValue("ssss", version, status, account_name, fulljid);
PyObject* p_function;
PyObject *p_args = Py_BuildValue("ssss", version, status, account_name, fulljid);
PyObject *p_function;
PyObject* p_module = plugin->module;
PyObject *p_module = plugin->module;
if (PyObject_HasAttrString(p_module, "prof_init")) {
p_function = PyObject_GetAttrString(p_module, "prof_init");
python_check_error();
@@ -199,12 +199,12 @@ python_init_hook(ProfPlugin* plugin, const char* const version, const char* cons
}
gboolean
python_contains_hook(ProfPlugin* plugin, const char* const hook)
python_contains_hook(ProfPlugin *plugin, const char *const hook)
{
disable_python_threads();
gboolean res = FALSE;
PyObject* p_module = plugin->module;
PyObject *p_module = plugin->module;
if (PyObject_HasAttrString(p_module, hook)) {
res = TRUE;
}
@@ -215,12 +215,12 @@ python_contains_hook(ProfPlugin* plugin, const char* const hook)
}
void
python_on_start_hook(ProfPlugin* plugin)
python_on_start_hook(ProfPlugin *plugin)
{
disable_python_threads();
PyObject* p_function;
PyObject *p_function;
PyObject* p_module = plugin->module;
PyObject *p_module = plugin->module;
if (PyObject_HasAttrString(p_module, "prof_on_start")) {
p_function = PyObject_GetAttrString(p_module, "prof_on_start");
python_check_error();
@@ -228,18 +228,19 @@ python_on_start_hook(ProfPlugin* plugin)
PyObject_CallObject(p_function, NULL);
python_check_error();
Py_XDECREF(p_function);
}
}
allow_python_threads();
}
void
python_on_shutdown_hook(ProfPlugin* plugin)
python_on_shutdown_hook(ProfPlugin *plugin)
{
disable_python_threads();
PyObject* p_function;
PyObject *p_function;
PyObject* p_module = plugin->module;
PyObject *p_module = plugin->module;
if (PyObject_HasAttrString(p_module, "prof_on_shutdown")) {
p_function = PyObject_GetAttrString(p_module, "prof_on_shutdown");
python_check_error();
@@ -253,12 +254,12 @@ python_on_shutdown_hook(ProfPlugin* plugin)
}
void
python_on_unload_hook(ProfPlugin* plugin)
python_on_unload_hook(ProfPlugin *plugin)
{
disable_python_threads();
PyObject* p_function;
PyObject *p_function;
PyObject* p_module = plugin->module;
PyObject *p_module = plugin->module;
if (PyObject_HasAttrString(p_module, "prof_on_unload")) {
p_function = PyObject_GetAttrString(p_module, "prof_on_unload");
python_check_error();
@@ -272,13 +273,13 @@ python_on_unload_hook(ProfPlugin* plugin)
}
void
python_on_connect_hook(ProfPlugin* plugin, const char* const account_name, const char* const fulljid)
python_on_connect_hook(ProfPlugin *plugin, const char *const account_name, const char *const fulljid)
{
disable_python_threads();
PyObject* p_args = Py_BuildValue("ss", account_name, fulljid);
PyObject* p_function;
PyObject *p_args = Py_BuildValue("ss", account_name, fulljid);
PyObject *p_function;
PyObject* p_module = plugin->module;
PyObject *p_module = plugin->module;
if (PyObject_HasAttrString(p_module, "prof_on_connect")) {
p_function = PyObject_GetAttrString(p_module, "prof_on_connect");
python_check_error();
@@ -293,13 +294,13 @@ python_on_connect_hook(ProfPlugin* plugin, const char* const account_name, const
}
void
python_on_disconnect_hook(ProfPlugin* plugin, const char* const account_name, const char* const fulljid)
python_on_disconnect_hook(ProfPlugin *plugin, const char *const account_name, const char *const fulljid)
{
disable_python_threads();
PyObject* p_args = Py_BuildValue("ss", account_name, fulljid);
PyObject* p_function;
PyObject *p_args = Py_BuildValue("ss", account_name, fulljid);
PyObject *p_function;
PyObject* p_module = plugin->module;
PyObject *p_module = plugin->module;
if (PyObject_HasAttrString(p_module, "prof_on_disconnect")) {
p_function = PyObject_GetAttrString(p_module, "prof_on_disconnect");
python_check_error();
@@ -314,19 +315,19 @@ python_on_disconnect_hook(ProfPlugin* plugin, const char* const account_name, co
}
char*
python_pre_chat_message_display_hook(ProfPlugin* plugin, const char* const barejid, const char* const resource,
const char* message)
python_pre_chat_message_display_hook(ProfPlugin *plugin, const char *const barejid, const char *const resource,
const char *message)
{
disable_python_threads();
PyObject* p_args = Py_BuildValue("sss", barejid, resource, message);
PyObject* p_function;
PyObject *p_args = Py_BuildValue("sss", barejid, resource, message);
PyObject *p_function;
PyObject* p_module = plugin->module;
PyObject *p_module = plugin->module;
if (PyObject_HasAttrString(p_module, "prof_pre_chat_message_display")) {
p_function = PyObject_GetAttrString(p_module, "prof_pre_chat_message_display");
python_check_error();
if (p_function && PyCallable_Check(p_function)) {
PyObject* result = PyObject_CallObject(p_function, p_args);
PyObject *result = PyObject_CallObject(p_function, p_args);
python_check_error();
Py_XDECREF(p_function);
Py_XDECREF(p_args);
@@ -339,13 +340,13 @@ python_pre_chat_message_display_hook(ProfPlugin* plugin, const char* const barej
}
void
python_post_chat_message_display_hook(ProfPlugin* plugin, const char* const barejid, const char* const resource, const char* message)
python_post_chat_message_display_hook(ProfPlugin *plugin, const char *const barejid, const char *const resource, const char *message)
{
disable_python_threads();
PyObject* p_args = Py_BuildValue("sss", barejid, resource, message);
PyObject* p_function;
PyObject *p_args = Py_BuildValue("sss", barejid, resource, message);
PyObject *p_function;
PyObject* p_module = plugin->module;
PyObject *p_module = plugin->module;
if (PyObject_HasAttrString(p_module, "prof_post_chat_message_display")) {
p_function = PyObject_GetAttrString(p_module, "prof_post_chat_message_display");
python_check_error();
@@ -360,18 +361,18 @@ python_post_chat_message_display_hook(ProfPlugin* plugin, const char* const bare
}
char*
python_pre_chat_message_send_hook(ProfPlugin* plugin, const char* const barejid, const char* message)
python_pre_chat_message_send_hook(ProfPlugin *plugin, const char * const barejid, const char *message)
{
disable_python_threads();
PyObject* p_args = Py_BuildValue("ss", barejid, message);
PyObject* p_function;
PyObject *p_args = Py_BuildValue("ss", barejid, message);
PyObject *p_function;
PyObject* p_module = plugin->module;
PyObject *p_module = plugin->module;
if (PyObject_HasAttrString(p_module, "prof_pre_chat_message_send")) {
p_function = PyObject_GetAttrString(p_module, "prof_pre_chat_message_send");
python_check_error();
if (p_function && PyCallable_Check(p_function)) {
PyObject* result = PyObject_CallObject(p_function, p_args);
PyObject *result = PyObject_CallObject(p_function, p_args);
python_check_error();
Py_XDECREF(p_function);
Py_XDECREF(p_args);
@@ -384,13 +385,13 @@ python_pre_chat_message_send_hook(ProfPlugin* plugin, const char* const barejid,
}
void
python_post_chat_message_send_hook(ProfPlugin* plugin, const char* const barejid, const char* message)
python_post_chat_message_send_hook(ProfPlugin *plugin, const char *const barejid, const char *message)
{
disable_python_threads();
PyObject* p_args = Py_BuildValue("ss", barejid, message);
PyObject* p_function;
PyObject *p_args = Py_BuildValue("ss", barejid, message);
PyObject *p_function;
PyObject* p_module = plugin->module;
PyObject *p_module = plugin->module;
if (PyObject_HasAttrString(p_module, "prof_post_chat_message_send")) {
p_function = PyObject_GetAttrString(p_module, "prof_post_chat_message_send");
python_check_error();
@@ -405,18 +406,18 @@ python_post_chat_message_send_hook(ProfPlugin* plugin, const char* const barejid
}
char*
python_pre_room_message_display_hook(ProfPlugin* plugin, const char* const barejid, const char* const nick, const char* message)
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_args = Py_BuildValue("sss", barejid, nick, message);
PyObject *p_function;
PyObject* p_module = plugin->module;
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);
PyObject *result = PyObject_CallObject(p_function, p_args);
python_check_error();
Py_XDECREF(p_function);
Py_XDECREF(p_args);
@@ -429,14 +430,14 @@ python_pre_room_message_display_hook(ProfPlugin* plugin, const char* const barej
}
void
python_post_room_message_display_hook(ProfPlugin* plugin, const char* const barejid, const char* const nick,
const char* message)
python_post_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_args = Py_BuildValue("sss", barejid, nick, message);
PyObject *p_function;
PyObject* p_module = plugin->module;
PyObject *p_module = plugin->module;
if (PyObject_HasAttrString(p_module, "prof_post_room_message_display")) {
p_function = PyObject_GetAttrString(p_module, "prof_post_room_message_display");
python_check_error();
@@ -451,18 +452,18 @@ python_post_room_message_display_hook(ProfPlugin* plugin, const char* const bare
}
char*
python_pre_room_message_send_hook(ProfPlugin* plugin, const char* const barejid, const char* message)
python_pre_room_message_send_hook(ProfPlugin *plugin, const char *const barejid, const char *message)
{
disable_python_threads();
PyObject* p_args = Py_BuildValue("ss", barejid, message);
PyObject* p_function;
PyObject *p_args = Py_BuildValue("ss", barejid, message);
PyObject *p_function;
PyObject* p_module = plugin->module;
PyObject *p_module = plugin->module;
if (PyObject_HasAttrString(p_module, "prof_pre_room_message_send")) {
p_function = PyObject_GetAttrString(p_module, "prof_pre_room_message_send");
python_check_error();
if (p_function && PyCallable_Check(p_function)) {
PyObject* result = PyObject_CallObject(p_function, p_args);
PyObject *result = PyObject_CallObject(p_function, p_args);
python_check_error();
Py_XDECREF(p_function);
Py_XDECREF(p_args);
@@ -475,13 +476,13 @@ python_pre_room_message_send_hook(ProfPlugin* plugin, const char* const barejid,
}
void
python_post_room_message_send_hook(ProfPlugin* plugin, const char* const barejid, const char* message)
python_post_room_message_send_hook(ProfPlugin *plugin, const char *const barejid, const char *message)
{
disable_python_threads();
PyObject* p_args = Py_BuildValue("ss", barejid, message);
PyObject* p_function;
PyObject *p_args = Py_BuildValue("ss", barejid, message);
PyObject *p_function;
PyObject* p_module = plugin->module;
PyObject *p_module = plugin->module;
if (PyObject_HasAttrString(p_module, "prof_post_room_message_send")) {
p_function = PyObject_GetAttrString(p_module, "prof_post_room_message_send");
python_check_error();
@@ -496,14 +497,14 @@ python_post_room_message_send_hook(ProfPlugin* plugin, const char* const barejid
}
void
python_on_room_history_message_hook(ProfPlugin* plugin, const char* const barejid, const char* const nick,
const char* const message, const char* const timestamp)
python_on_room_history_message_hook(ProfPlugin *plugin, const char *const barejid, const char *const nick,
const char *const message, const char *const timestamp)
{
disable_python_threads();
PyObject* p_args = Py_BuildValue("ssss", barejid, nick, message, timestamp);
PyObject* p_function;
PyObject *p_args = Py_BuildValue("ssss", barejid, nick, message, timestamp);
PyObject *p_function;
PyObject* p_module = plugin->module;
PyObject *p_module = plugin->module;
if (PyObject_HasAttrString(p_module, "prof_on_room_history_message")) {
p_function = PyObject_GetAttrString(p_module, "prof_on_room_history_message");
python_check_error();
@@ -518,19 +519,19 @@ python_on_room_history_message_hook(ProfPlugin* plugin, const char* const bareji
}
char*
python_pre_priv_message_display_hook(ProfPlugin* plugin, const char* const barejid, const char* const nick,
const char* message)
python_pre_priv_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_args = Py_BuildValue("sss", barejid, nick, message);
PyObject *p_function;
PyObject* p_module = plugin->module;
PyObject *p_module = plugin->module;
if (PyObject_HasAttrString(p_module, "prof_pre_priv_message_display")) {
p_function = PyObject_GetAttrString(p_module, "prof_pre_priv_message_display");
python_check_error();
if (p_function && PyCallable_Check(p_function)) {
PyObject* result = PyObject_CallObject(p_function, p_args);
PyObject *result = PyObject_CallObject(p_function, p_args);
python_check_error();
Py_XDECREF(p_function);
Py_XDECREF(p_args);
@@ -543,14 +544,14 @@ python_pre_priv_message_display_hook(ProfPlugin* plugin, const char* const barej
}
void
python_post_priv_message_display_hook(ProfPlugin* plugin, const char* const barejid, const char* const nick,
const char* message)
python_post_priv_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_args = Py_BuildValue("sss", barejid, nick, message);
PyObject *p_function;
PyObject* p_module = plugin->module;
PyObject *p_module = plugin->module;
if (PyObject_HasAttrString(p_module, "prof_post_priv_message_display")) {
p_function = PyObject_GetAttrString(p_module, "prof_post_priv_message_display");
python_check_error();
@@ -565,19 +566,19 @@ python_post_priv_message_display_hook(ProfPlugin* plugin, const char* const bare
}
char*
python_pre_priv_message_send_hook(ProfPlugin* plugin, const char* const barejid, const char* const nick,
const char* const message)
python_pre_priv_message_send_hook(ProfPlugin *plugin, const char *const barejid, const char *const nick,
const char *const message)
{
disable_python_threads();
PyObject* p_args = Py_BuildValue("sss", barejid, nick, message);
PyObject* p_function;
PyObject *p_args = Py_BuildValue("sss", barejid, nick, message);
PyObject *p_function;
PyObject* p_module = plugin->module;
PyObject *p_module = plugin->module;
if (PyObject_HasAttrString(p_module, "prof_pre_priv_message_send")) {
p_function = PyObject_GetAttrString(p_module, "prof_pre_priv_message_send");
python_check_error();
if (p_function && PyCallable_Check(p_function)) {
PyObject* result = PyObject_CallObject(p_function, p_args);
PyObject *result = PyObject_CallObject(p_function, p_args);
python_check_error();
Py_XDECREF(p_function);
Py_XDECREF(p_args);
@@ -590,14 +591,14 @@ python_pre_priv_message_send_hook(ProfPlugin* plugin, const char* const barejid,
}
void
python_post_priv_message_send_hook(ProfPlugin* plugin, const char* const barejid, const char* const nick,
const char* const message)
python_post_priv_message_send_hook(ProfPlugin *plugin, const char *const barejid, const char *const nick,
const char *const message)
{
disable_python_threads();
PyObject* p_args = Py_BuildValue("sss", barejid, nick, message);
PyObject* p_function;
PyObject *p_args = Py_BuildValue("sss", barejid, nick, message);
PyObject *p_function;
PyObject* p_module = plugin->module;
PyObject *p_module = plugin->module;
if (PyObject_HasAttrString(p_module, "prof_post_priv_message_send")) {
p_function = PyObject_GetAttrString(p_module, "prof_post_priv_message_send");
python_check_error();
@@ -612,18 +613,18 @@ python_post_priv_message_send_hook(ProfPlugin* plugin, const char* const barejid
}
char*
python_on_message_stanza_send_hook(ProfPlugin* plugin, const char* const text)
python_on_message_stanza_send_hook(ProfPlugin *plugin, const char *const text)
{
disable_python_threads();
PyObject* p_args = Py_BuildValue("(s)", text);
PyObject* p_function;
PyObject *p_args = Py_BuildValue("(s)", text);
PyObject *p_function;
PyObject* p_module = plugin->module;
PyObject *p_module = plugin->module;
if (PyObject_HasAttrString(p_module, "prof_on_message_stanza_send")) {
p_function = PyObject_GetAttrString(p_module, "prof_on_message_stanza_send");
python_check_error();
if (p_function && PyCallable_Check(p_function)) {
PyObject* result = PyObject_CallObject(p_function, p_args);
PyObject *result = PyObject_CallObject(p_function, p_args);
python_check_error();
Py_XDECREF(p_function);
Py_XDECREF(p_args);
@@ -636,18 +637,18 @@ python_on_message_stanza_send_hook(ProfPlugin* plugin, const char* const text)
}
gboolean
python_on_message_stanza_receive_hook(ProfPlugin* plugin, const char* const text)
python_on_message_stanza_receive_hook(ProfPlugin *plugin, const char *const text)
{
disable_python_threads();
PyObject* p_args = Py_BuildValue("(s)", text);
PyObject* p_function;
PyObject *p_args = Py_BuildValue("(s)", text);
PyObject *p_function;
PyObject* p_module = plugin->module;
PyObject *p_module = plugin->module;
if (PyObject_HasAttrString(p_module, "prof_on_message_stanza_receive")) {
p_function = PyObject_GetAttrString(p_module, "prof_on_message_stanza_receive");
python_check_error();
if (p_function && PyCallable_Check(p_function)) {
PyObject* result = PyObject_CallObject(p_function, p_args);
PyObject *result = PyObject_CallObject(p_function, p_args);
python_check_error();
Py_XDECREF(p_function);
Py_XDECREF(p_args);
@@ -660,18 +661,18 @@ python_on_message_stanza_receive_hook(ProfPlugin* plugin, const char* const text
}
char*
python_on_presence_stanza_send_hook(ProfPlugin* plugin, const char* const text)
python_on_presence_stanza_send_hook(ProfPlugin *plugin, const char *const text)
{
disable_python_threads();
PyObject* p_args = Py_BuildValue("(s)", text);
PyObject* p_function;
PyObject *p_args = Py_BuildValue("(s)", text);
PyObject *p_function;
PyObject* p_module = plugin->module;
PyObject *p_module = plugin->module;
if (PyObject_HasAttrString(p_module, "prof_on_presence_stanza_send")) {
p_function = PyObject_GetAttrString(p_module, "prof_on_presence_stanza_send");
python_check_error();
if (p_function && PyCallable_Check(p_function)) {
PyObject* result = PyObject_CallObject(p_function, p_args);
PyObject *result = PyObject_CallObject(p_function, p_args);
python_check_error();
Py_XDECREF(p_function);
Py_XDECREF(p_args);
@@ -684,18 +685,18 @@ python_on_presence_stanza_send_hook(ProfPlugin* plugin, const char* const text)
}
gboolean
python_on_presence_stanza_receive_hook(ProfPlugin* plugin, const char* const text)
python_on_presence_stanza_receive_hook(ProfPlugin *plugin, const char *const text)
{
disable_python_threads();
PyObject* p_args = Py_BuildValue("(s)", text);
PyObject* p_function;
PyObject *p_args = Py_BuildValue("(s)", text);
PyObject *p_function;
PyObject* p_module = plugin->module;
PyObject *p_module = plugin->module;
if (PyObject_HasAttrString(p_module, "prof_on_presence_stanza_receive")) {
p_function = PyObject_GetAttrString(p_module, "prof_on_presence_stanza_receive");
python_check_error();
if (p_function && PyCallable_Check(p_function)) {
PyObject* result = PyObject_CallObject(p_function, p_args);
PyObject *result = PyObject_CallObject(p_function, p_args);
python_check_error();
Py_XDECREF(p_function);
Py_XDECREF(p_args);
@@ -708,18 +709,18 @@ python_on_presence_stanza_receive_hook(ProfPlugin* plugin, const char* const tex
}
char*
python_on_iq_stanza_send_hook(ProfPlugin* plugin, const char* const text)
python_on_iq_stanza_send_hook(ProfPlugin *plugin, const char *const text)
{
disable_python_threads();
PyObject* p_args = Py_BuildValue("(s)", text);
PyObject* p_function;
PyObject *p_args = Py_BuildValue("(s)", text);
PyObject *p_function;
PyObject* p_module = plugin->module;
PyObject *p_module = plugin->module;
if (PyObject_HasAttrString(p_module, "prof_on_iq_stanza_send")) {
p_function = PyObject_GetAttrString(p_module, "prof_on_iq_stanza_send");
python_check_error();
if (p_function && PyCallable_Check(p_function)) {
PyObject* result = PyObject_CallObject(p_function, p_args);
PyObject *result = PyObject_CallObject(p_function, p_args);
python_check_error();
Py_XDECREF(p_function);
Py_XDECREF(p_args);
@@ -732,18 +733,18 @@ python_on_iq_stanza_send_hook(ProfPlugin* plugin, const char* const text)
}
gboolean
python_on_iq_stanza_receive_hook(ProfPlugin* plugin, const char* const text)
python_on_iq_stanza_receive_hook(ProfPlugin *plugin, const char *const text)
{
disable_python_threads();
PyObject* p_args = Py_BuildValue("(s)", text);
PyObject* p_function;
PyObject *p_args = Py_BuildValue("(s)", text);
PyObject *p_function;
PyObject* p_module = plugin->module;
PyObject *p_module = plugin->module;
if (PyObject_HasAttrString(p_module, "prof_on_iq_stanza_receive")) {
p_function = PyObject_GetAttrString(p_module, "prof_on_iq_stanza_receive");
python_check_error();
if (p_function && PyCallable_Check(p_function)) {
PyObject* result = PyObject_CallObject(p_function, p_args);
PyObject *result = PyObject_CallObject(p_function, p_args);
python_check_error();
Py_XDECREF(p_function);
Py_XDECREF(p_args);
@@ -756,14 +757,14 @@ python_on_iq_stanza_receive_hook(ProfPlugin* plugin, const char* const text)
}
void
python_on_contact_offline_hook(ProfPlugin* plugin, const char* const barejid, const char* const resource,
const char* const status)
python_on_contact_offline_hook(ProfPlugin *plugin, const char *const barejid, const char *const resource,
const char *const status)
{
disable_python_threads();
PyObject* p_args = Py_BuildValue("sss", barejid, resource, status);
PyObject* p_function;
PyObject *p_args = Py_BuildValue("sss", barejid, resource, status);
PyObject *p_function;
PyObject* p_module = plugin->module;
PyObject *p_module = plugin->module;
if (PyObject_HasAttrString(p_module, "prof_on_contact_offline")) {
p_function = PyObject_GetAttrString(p_module, "prof_on_contact_offline");
python_check_error();
@@ -778,14 +779,14 @@ python_on_contact_offline_hook(ProfPlugin* plugin, const char* const barejid, co
}
void
python_on_contact_presence_hook(ProfPlugin* plugin, const char* const barejid, const char* const resource,
const char* const presence, const char* const status, const int priority)
python_on_contact_presence_hook(ProfPlugin *plugin, const char *const barejid, const char *const resource,
const char *const presence, const char *const status, const int priority)
{
disable_python_threads();
PyObject* p_args = Py_BuildValue("ssssi", barejid, resource, presence, status, priority);
PyObject* p_function;
PyObject *p_args = Py_BuildValue("ssssi", barejid, resource, presence, status, priority);
PyObject *p_function;
PyObject* p_module = plugin->module;
PyObject *p_module = plugin->module;
if (PyObject_HasAttrString(p_module, "prof_on_contact_presence")) {
p_function = PyObject_GetAttrString(p_module, "prof_on_contact_presence");
python_check_error();
@@ -800,13 +801,13 @@ 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)
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_args = Py_BuildValue("(s)", barejid);
PyObject *p_function;
PyObject* p_module = plugin->module;
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();
@@ -821,13 +822,13 @@ python_on_chat_win_focus_hook(ProfPlugin* plugin, const char* const barejid)
}
void
python_on_room_win_focus_hook(ProfPlugin* plugin, const char* const barejid)
python_on_room_win_focus_hook(ProfPlugin *plugin, const char *const barejid)
{
disable_python_threads();
PyObject* p_args = Py_BuildValue("(s)", barejid);
PyObject* p_function;
PyObject *p_args = Py_BuildValue("(s)", barejid);
PyObject *p_function;
PyObject* p_module = plugin->module;
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();
@@ -852,7 +853,7 @@ python_check_error(void)
}
void
python_plugin_destroy(ProfPlugin* plugin)
python_plugin_destroy(ProfPlugin *plugin)
{
disable_python_threads();
callbacks_remove(plugin->name);
@@ -871,10 +872,10 @@ python_shutdown(void)
}
static void
_python_undefined_error(ProfPlugin* plugin, char* hook, char* type)
_python_undefined_error(ProfPlugin *plugin, char *hook, char *type)
{
GString* err_msg = g_string_new("Plugin error - ");
char* module_name = g_strndup(plugin->name, strlen(plugin->name) - 2);
GString *err_msg = g_string_new("Plugin error - ");
char *module_name = g_strndup(plugin->name, strlen(plugin->name) - 2);
g_string_append(err_msg, module_name);
free(module_name);
g_string_append(err_msg, hook);
@@ -886,10 +887,10 @@ _python_undefined_error(ProfPlugin* plugin, char* hook, char* type)
}
static void
_python_type_error(ProfPlugin* plugin, char* hook, char* type)
_python_type_error(ProfPlugin *plugin, char *hook, char *type)
{
GString* err_msg = g_string_new("Plugin error - ");
char* module_name = g_strndup(plugin->name, strlen(plugin->name) - 2);
GString *err_msg = g_string_new("Plugin error - ");
char *module_name = g_strndup(plugin->name, strlen(plugin->name) - 2);
g_string_append(err_msg, module_name);
free(module_name);
g_string_append(err_msg, hook);
@@ -901,7 +902,7 @@ _python_type_error(ProfPlugin* plugin, char* hook, char* type)
}
static char*
_handle_string_or_none_result(ProfPlugin* plugin, PyObject* result, char* hook)
_handle_string_or_none_result(ProfPlugin *plugin, PyObject *result, char *hook)
{
if (result == NULL) {
allow_python_threads();
@@ -921,13 +922,13 @@ _handle_string_or_none_result(ProfPlugin* plugin, PyObject* result, char* hook)
return NULL;
}
#endif
char* result_str = python_str_or_unicode_to_string(result);
char *result_str = python_str_or_unicode_to_string(result);
allow_python_threads();
return result_str;
}
static gboolean
_handle_boolean_result(ProfPlugin* plugin, PyObject* result, char* hook)
_handle_boolean_result(ProfPlugin *plugin, PyObject *result, char *hook)
{
if (result == NULL) {
allow_python_threads();