Apply coding style

This commit is contained in:
Michael Vetter
2020-07-07 14:18:57 +02:00
parent 95015cec56
commit a2726b6a7d
213 changed files with 19064 additions and 17062 deletions

View File

@@ -61,14 +61,14 @@ api_cons_alert(void)
}
int
api_cons_show(const char * const message)
api_cons_show(const char* const message)
{
if (message == NULL) {
log_warning("%s", "prof_cons_show failed, message is NULL");
return 0;
}
char *parsed = str_replace(message, "\r\n", "\n");
char* parsed = str_replace(message, "\r\n", "\n");
cons_show("%s", parsed);
free(parsed);
@@ -76,16 +76,16 @@ api_cons_show(const char * const message)
}
int
api_cons_show_themed(const char *const group, const char *const key, const char *const def, const char *const message)
api_cons_show_themed(const char* const group, const char* const key, const char* const def, const char* const message)
{
if (message == NULL) {
log_warning("%s", "prof_cons_show_themed failed, message is NULL");
return 0;
}
char *parsed = str_replace(message, "\r\n", "\n");
char* parsed = str_replace(message, "\r\n", "\n");
theme_item_t themeitem = plugin_themes_get(group, key, def);
ProfWin *console = wins_get_console();
ProfWin* console = wins_get_console();
win_println(console, themeitem, "-", "%s", parsed);
free(parsed);
@@ -94,7 +94,7 @@ api_cons_show_themed(const char *const group, const char *const key, const char
}
int
api_cons_bad_cmd_usage(const char *const cmd)
api_cons_bad_cmd_usage(const char* const cmd)
{
if (cmd == NULL) {
log_warning("%s", "prof_cons_bad_cmd_usage failed, cmd is NULL");
@@ -107,11 +107,11 @@ api_cons_bad_cmd_usage(const char *const cmd)
}
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_exec)(PluginCommand *command, gchar **args), void(*callback_destroy)(void *callback))
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_exec)(PluginCommand* command, gchar** args), void (*callback_destroy)(void* callback))
{
PluginCommand *command = malloc(sizeof(PluginCommand));
PluginCommand* command = malloc(sizeof(PluginCommand));
command->command_name = strdup(command_name);
command->min_args = min_args;
command->max_args = max_args;
@@ -119,7 +119,7 @@ api_register_command(const char *const plugin_name, const char *command_name, in
command->callback_exec = callback_exec;
command->callback_destroy = callback_destroy;
CommandHelp *help = malloc(sizeof(CommandHelp));
CommandHelp* help = malloc(sizeof(CommandHelp));
help->tags[0] = NULL;
@@ -148,10 +148,10 @@ api_register_command(const char *const plugin_name, const char *command_name, in
}
void
api_register_timed(const char *const plugin_name, void *callback, int interval_seconds,
void (*callback_exec)(PluginTimedFunction *timed_function), void(*callback_destroy)(void *callback))
api_register_timed(const char* const plugin_name, void* callback, int interval_seconds,
void (*callback_exec)(PluginTimedFunction* timed_function), void (*callback_destroy)(void* callback))
{
PluginTimedFunction *timed_function = malloc(sizeof(PluginTimedFunction));
PluginTimedFunction* timed_function = malloc(sizeof(PluginTimedFunction));
timed_function->callback = callback;
timed_function->callback_exec = callback_exec;
timed_function->callback_destroy = callback_destroy;
@@ -162,48 +162,48 @@ api_register_timed(const char *const plugin_name, void *callback, int interval_s
}
void
api_completer_add(const char *const plugin_name, const char *key, char **items)
api_completer_add(const char* const plugin_name, const char* key, char** items)
{
autocompleters_add(plugin_name, key, items);
}
void
api_completer_remove(const char *const plugin_name, const char *key, char **items)
api_completer_remove(const char* const plugin_name, const char* key, char** items)
{
autocompleters_remove(plugin_name, key, items);
}
void
api_completer_clear(const char *const plugin_name, const char *key)
api_completer_clear(const char* const plugin_name, const char* key)
{
autocompleters_clear(plugin_name, key);
}
void
api_filepath_completer_add(const char *const plugin_name, const char *prefix)
api_filepath_completer_add(const char* const plugin_name, const char* prefix)
{
autocompleters_filepath_add(plugin_name, prefix);
}
void
api_notify(const char *message, const char *category, int timeout_ms)
api_notify(const char* message, const char* category, int timeout_ms)
{
notify(message, timeout_ms, category);
}
void
api_send_line(char *line)
api_send_line(char* line)
{
ProfWin *current = wins_get_current();
ProfWin* current = wins_get_current();
cmd_process_input(current, line);
}
char *
char*
api_get_current_recipient(void)
{
ProfWin *current = wins_get_current();
ProfWin* current = wins_get_current();
if (current->type == WIN_CHAT) {
ProfChatWin *chatwin = (ProfChatWin*)current;
ProfChatWin* chatwin = (ProfChatWin*)current;
assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
return chatwin->barejid;
} else {
@@ -211,12 +211,12 @@ api_get_current_recipient(void)
}
}
char *
char*
api_get_current_muc(void)
{
ProfWin *current = wins_get_current();
ProfWin* current = wins_get_current();
if (current->type == WIN_MUC) {
ProfMucWin *mucwin = (ProfMucWin*)current;
ProfMucWin* mucwin = (ProfMucWin*)current;
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
return mucwin->roomjid;
} else {
@@ -224,12 +224,12 @@ api_get_current_muc(void)
}
}
char *
char*
api_get_current_nick(void)
{
ProfWin *current = wins_get_current();
ProfWin* current = wins_get_current();
if (current->type == WIN_MUC) {
ProfMucWin *mucwin = (ProfMucWin*)current;
ProfMucWin* mucwin = (ProfMucWin*)current;
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
return muc_nick(mucwin->roomjid);
} else {
@@ -240,16 +240,16 @@ api_get_current_nick(void)
char**
api_get_current_occupants(void)
{
ProfWin *current = wins_get_current();
ProfWin* current = wins_get_current();
if (current->type == WIN_MUC) {
ProfMucWin *mucwin = (ProfMucWin*)current;
ProfMucWin* mucwin = (ProfMucWin*)current;
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
GList *occupants_list = muc_roster(mucwin->roomjid);
char **result = malloc((g_list_length(occupants_list) + 1) * sizeof(char*));
GList *curr = occupants_list;
GList* occupants_list = muc_roster(mucwin->roomjid);
char** result = malloc((g_list_length(occupants_list) + 1) * sizeof(char*));
GList* curr = occupants_list;
int i = 0;
while (curr) {
Occupant *occupant = curr->data;
Occupant* occupant = curr->data;
result[i++] = strdup(occupant->nick);
curr = g_list_next(curr);
}
@@ -263,7 +263,7 @@ api_get_current_occupants(void)
int
api_current_win_is_console(void)
{
ProfWin *current = wins_get_current();
ProfWin* current = wins_get_current();
if (current && current->type == WIN_CONSOLE) {
return 1;
} else {
@@ -272,48 +272,48 @@ api_current_win_is_console(void)
}
char*
api_get_room_nick(const char *barejid)
api_get_room_nick(const char* barejid)
{
return muc_nick(barejid);
}
void
api_log_debug(const char *message)
api_log_debug(const char* message)
{
log_debug("%s", message);
}
void
api_log_info(const char *message)
api_log_info(const char* message)
{
log_info("%s", message);
}
void
api_log_warning(const char *message)
api_log_warning(const char* message)
{
log_warning("%s", message);
}
void
api_log_error(const char *message)
api_log_error(const char* message)
{
log_error("%s", message);
}
int
api_win_exists(const char *tag)
api_win_exists(const char* tag)
{
return (wins_get_plugin(tag) != NULL);
}
void
api_win_create(
const char *const plugin_name,
const char *tag,
void *callback,
void(*callback_exec)(PluginWindowCallback *window_callback, const char *tag, const char * const line),
void(*callback_destroy)(void *callback))
const char* const plugin_name,
const char* tag,
void* callback,
void (*callback_exec)(PluginWindowCallback* window_callback, const char* tag, const char* const line),
void (*callback_destroy)(void* callback))
{
if (callbacks_win_exists(plugin_name, tag)) {
if (callback_destroy) {
@@ -322,7 +322,7 @@ api_win_create(
return;
}
PluginWindowCallback *window = malloc(sizeof(PluginWindowCallback));
PluginWindowCallback* window = malloc(sizeof(PluginWindowCallback));
window->callback = callback;
window->callback_exec = callback_exec;
window->callback_destroy = callback_destroy;
@@ -332,20 +332,20 @@ api_win_create(
wins_new_plugin(plugin_name, tag);
// set status bar active
ProfPluginWin *pluginwin = wins_get_plugin(tag);
ProfPluginWin* pluginwin = wins_get_plugin(tag);
int num = wins_get_num((ProfWin*)pluginwin);
status_bar_active(num, WIN_PLUGIN, pluginwin->tag);
}
int
api_win_focus(const char *tag)
api_win_focus(const char* tag)
{
if (tag == NULL) {
log_warning("%s", "prof_win_focus failed, tag is NULL");
return 0;
}
ProfPluginWin *pluginwin = wins_get_plugin(tag);
ProfPluginWin* pluginwin = wins_get_plugin(tag);
if (pluginwin == NULL) {
log_warning("prof_win_focus failed, no window with tag: %s", tag);
return 0;
@@ -357,7 +357,7 @@ api_win_focus(const char *tag)
}
int
api_win_show(const char *tag, const char *line)
api_win_show(const char* tag, const char* line)
{
if (tag == NULL) {
log_warning("%s", "prof_win_show failed, tag is NULL");
@@ -368,20 +368,20 @@ api_win_show(const char *tag, const char *line)
return 0;
}
ProfPluginWin *pluginwin = wins_get_plugin(tag);
ProfPluginWin* pluginwin = wins_get_plugin(tag);
if (pluginwin == NULL) {
log_warning("prof_win_show failed, no window with tag: %s", tag);
return 0;
}
ProfWin *window = (ProfWin*)pluginwin;
ProfWin* window = (ProfWin*)pluginwin;
win_println(window, THEME_DEFAULT, "!", "%s", line);
return 1;
}
int
api_win_show_themed(const char *tag, const char *const group, const char *const key, const char *const def, const char *line)
api_win_show_themed(const char* tag, const char* const group, const char* const key, const char* const def, const char* line)
{
if (tag == NULL) {
log_warning("%s", "prof_win_show_themed failed, tag is NULL");
@@ -392,89 +392,89 @@ api_win_show_themed(const char *tag, const char *const group, const char *const
return 0;
}
ProfPluginWin *pluginwin = wins_get_plugin(tag);
ProfPluginWin* pluginwin = wins_get_plugin(tag);
if (pluginwin == NULL) {
log_warning("prof_win_show_themed failed, no window with tag: %s", tag);
return 0;
}
theme_item_t themeitem = plugin_themes_get(group, key, def);
ProfWin *window = (ProfWin*)pluginwin;
ProfWin* window = (ProfWin*)pluginwin;
win_println(window, themeitem, "!", "%s", line);
return 1;
}
int
api_send_stanza(const char *const stanza)
api_send_stanza(const char* const stanza)
{
return connection_send_stanza(stanza);
}
gboolean
api_settings_boolean_get(const char *const group, const char *const key, gboolean def)
api_settings_boolean_get(const char* const group, const char* const key, gboolean def)
{
return plugin_settings_boolean_get(group, key, def);
}
void
api_settings_boolean_set(const char *const group, const char *const key, gboolean value)
api_settings_boolean_set(const char* const group, const char* const key, gboolean value)
{
plugin_settings_boolean_set(group, key, value);
}
char*
api_settings_string_get(const char *const group, const char *const key, const char *const def)
api_settings_string_get(const char* const group, const char* const key, const char* const def)
{
return plugin_settings_string_get(group, key, def);
}
void
api_settings_string_set(const char *const group, const char *const key, const char *const value)
api_settings_string_set(const char* const group, const char* const key, const char* const value)
{
plugin_settings_string_set(group, key, value);
}
char**
api_settings_string_list_get(const char *const group, const char *const key)
api_settings_string_list_get(const char* const group, const char* const key)
{
return plugin_settings_string_list_get(group, key);
}
void
api_settings_string_list_add(const char *const group, const char *const key, const char *const value)
api_settings_string_list_add(const char* const group, const char* const key, const char* const value)
{
plugin_settings_string_list_add(group, key, value);
}
int
api_settings_string_list_remove(const char *const group, const char *const key, const char *const value)
api_settings_string_list_remove(const char* const group, const char* const key, const char* const value)
{
return plugin_settings_string_list_remove(group, key, value);
}
int
api_settings_string_list_clear(const char *const group, const char *const key)
api_settings_string_list_clear(const char* const group, const char* const key)
{
return plugin_settings_string_list_clear(group, key);
}
int
api_settings_int_get(const char *const group, const char *const key, int def)
api_settings_int_get(const char* const group, const char* const key, int def)
{
return plugin_settings_int_get(group, key, def);
}
void
api_settings_int_set(const char *const group, const char *const key, int value)
api_settings_int_set(const char* const group, const char* const key, int value)
{
plugin_settings_int_set(group, key, value);
}
void
api_incoming_message(const char *const barejid, const char *const resource, const char *const plain)
api_incoming_message(const char* const barejid, const char* const resource, const char* const plain)
{
ProfMessage *message = message_init();
ProfMessage* message = message_init();
message->from_jid = jid_create_from_bare_and_resource(barejid, resource);
message->plain = strdup(plain);
@@ -487,7 +487,7 @@ api_incoming_message(const char *const barejid, const char *const resource, cons
}
void
api_disco_add_feature(char *plugin_name, char *feature)
api_disco_add_feature(char* plugin_name, char* feature)
{
if (feature == NULL) {
log_warning("%s", "api_disco_add_feature failed, feature is NULL");
@@ -506,14 +506,14 @@ api_disco_add_feature(char *plugin_name, char *feature)
}
void
api_encryption_reset(const char *const barejid)
api_encryption_reset(const char* const barejid)
{
if (barejid == NULL) {
log_warning("%s", "api_encryption_reset failed, barejid is NULL");
return;
}
ProfChatWin *chatwin = wins_get_chat(barejid);
ProfChatWin* chatwin = wins_get_chat(barejid);
if (chatwin == NULL) {
log_warning("%s", "api_encryption_reset failed, could not find chat window for %s", barejid);
return;
@@ -535,7 +535,7 @@ api_encryption_reset(const char *const barejid)
}
int
api_chat_set_titlebar_enctext(const char *const barejid, const char *const enctext)
api_chat_set_titlebar_enctext(const char* const barejid, const char* const enctext)
{
if (enctext == NULL) {
log_warning("%s", "api_chat_set_titlebar_enctext failed, enctext is NULL");
@@ -547,7 +547,7 @@ api_chat_set_titlebar_enctext(const char *const barejid, const char *const encte
return 0;
}
ProfChatWin *chatwin = wins_get_chat(barejid);
ProfChatWin* chatwin = wins_get_chat(barejid);
if (chatwin == NULL) {
log_warning("%s", "api_chat_set_titlebar_enctext failed, could not find chat window for %s", barejid);
return 0;
@@ -559,14 +559,14 @@ api_chat_set_titlebar_enctext(const char *const barejid, const char *const encte
}
int
api_chat_unset_titlebar_enctext(const char *const barejid)
api_chat_unset_titlebar_enctext(const char* const barejid)
{
if (barejid == NULL) {
log_warning("%s", "api_chat_unset_titlebar_enctext failed, barejid is NULL");
return 0;
}
ProfChatWin *chatwin = wins_get_chat(barejid);
ProfChatWin* chatwin = wins_get_chat(barejid);
if (chatwin == NULL) {
log_warning("%s", "api_chat_unset_titlebar_enctext failed, could not find chat window for %s", barejid);
return 0;
@@ -578,7 +578,7 @@ api_chat_unset_titlebar_enctext(const char *const barejid)
}
int
api_chat_set_incoming_char(const char *const barejid, const char *const ch)
api_chat_set_incoming_char(const char* const barejid, const char* const ch)
{
if (ch == NULL) {
log_warning("%s", "api_chat_set_incoming_char failed, ch is NULL");
@@ -595,7 +595,7 @@ api_chat_set_incoming_char(const char *const barejid, const char *const ch)
return 0;
}
ProfChatWin *chatwin = wins_get_chat(barejid);
ProfChatWin* chatwin = wins_get_chat(barejid);
if (chatwin == NULL) {
log_warning("%s", "api_chat_set_incoming_char failed, could not find chat window for %s", barejid);
return 0;
@@ -607,14 +607,14 @@ api_chat_set_incoming_char(const char *const barejid, const char *const ch)
}
int
api_chat_unset_incoming_char(const char *const barejid)
api_chat_unset_incoming_char(const char* const barejid)
{
if (barejid == NULL) {
log_warning("%s", "api_chat_unset_incoming_char failed, barejid is NULL");
return 0;
}
ProfChatWin *chatwin = wins_get_chat(barejid);
ProfChatWin* chatwin = wins_get_chat(barejid);
if (chatwin == NULL) {
log_warning("%s", "api_chat_unset_incoming_char failed, could not find chat window for %s", barejid);
return 0;
@@ -626,7 +626,7 @@ api_chat_unset_incoming_char(const char *const barejid)
}
int
api_chat_set_outgoing_char(const char *const barejid, const char *const ch)
api_chat_set_outgoing_char(const char* const barejid, const char* const ch)
{
if (ch == NULL) {
log_warning("%s", "api_chat_set_outgoing_char failed, ch is NULL");
@@ -643,7 +643,7 @@ api_chat_set_outgoing_char(const char *const barejid, const char *const ch)
return 0;
}
ProfChatWin *chatwin = wins_get_chat(barejid);
ProfChatWin* chatwin = wins_get_chat(barejid);
if (chatwin == NULL) {
log_warning("%s", "api_chat_set_outgoing_char failed, could not find chat window for %s", barejid);
return 0;
@@ -655,14 +655,14 @@ api_chat_set_outgoing_char(const char *const barejid, const char *const ch)
}
int
api_chat_unset_outgoing_char(const char *const barejid)
api_chat_unset_outgoing_char(const char* const barejid)
{
if (barejid == NULL) {
log_warning("%s", "api_chat_unset_outgoing_char failed, barejid is NULL");
return 0;
}
ProfChatWin *chatwin = wins_get_chat(barejid);
ProfChatWin* chatwin = wins_get_chat(barejid);
if (chatwin == NULL) {
log_warning("%s", "api_chat_unset_outgoing_char failed, could not find chat window for %s", barejid);
return 0;
@@ -674,7 +674,7 @@ api_chat_unset_outgoing_char(const char *const barejid)
}
int
api_room_set_titlebar_enctext(const char *const roomjid, const char *const enctext)
api_room_set_titlebar_enctext(const char* const roomjid, const char* const enctext)
{
if (enctext == NULL) {
log_warning("%s", "api_room_set_titlebar_enctext failed, enctext is NULL");
@@ -686,7 +686,7 @@ api_room_set_titlebar_enctext(const char *const roomjid, const char *const encte
return 0;
}
ProfMucWin *mucwin = wins_get_muc(roomjid);
ProfMucWin* mucwin = wins_get_muc(roomjid);
if (mucwin == NULL) {
log_warning("%s", "api_room_set_titlebar_enctext failed, coudl not find room window for %s", roomjid);
return 0;
@@ -698,14 +698,14 @@ api_room_set_titlebar_enctext(const char *const roomjid, const char *const encte
}
int
api_room_unset_titlebar_enctext(const char *const roomjid)
api_room_unset_titlebar_enctext(const char* const roomjid)
{
if (roomjid == NULL) {
log_warning("%s", "api_room_unset_titlebar_enctext failed, roomjid is NULL");
return 0;
}
ProfMucWin *mucwin = wins_get_muc(roomjid);
ProfMucWin* mucwin = wins_get_muc(roomjid);
if (mucwin == NULL) {
log_warning("%s", "api_room_unset_titlebar_enctext failed, coudl not find room window for %s", roomjid);
return 0;
@@ -717,7 +717,7 @@ api_room_unset_titlebar_enctext(const char *const roomjid)
}
int
api_room_set_message_char(const char *const roomjid, const char *const ch)
api_room_set_message_char(const char* const roomjid, const char* const ch)
{
if (ch == NULL) {
log_warning("%s", "api_room_set_message_char failed, ch is NULL");
@@ -734,7 +734,7 @@ api_room_set_message_char(const char *const roomjid, const char *const ch)
return 0;
}
ProfMucWin *mucwin = wins_get_muc(roomjid);
ProfMucWin* mucwin = wins_get_muc(roomjid);
if (mucwin == NULL) {
log_warning("%s", "api_room_set_message_char failed, could not find room window for %s", roomjid);
return 0;
@@ -746,14 +746,14 @@ api_room_set_message_char(const char *const roomjid, const char *const ch)
}
int
api_room_unset_message_char(const char *const roomjid)
api_room_unset_message_char(const char* const roomjid)
{
if (roomjid == NULL) {
log_warning("%s", "api_room_unset_message_char failed, roomjid is NULL");
return 0;
}
ProfMucWin *mucwin = wins_get_muc(roomjid);
ProfMucWin* mucwin = wins_get_muc(roomjid);
if (mucwin == NULL) {
log_warning("%s", "api_room_unset_message_char failed, could not find room window for %s", roomjid);
return 0;
@@ -765,7 +765,7 @@ api_room_unset_message_char(const char *const roomjid)
}
int
api_chat_show(const char *const barejid, const char *message)
api_chat_show(const char* const barejid, const char* message)
{
if (message == NULL) {
log_warning("%s", "api_chat_show failed, message is NULL");
@@ -777,13 +777,13 @@ api_chat_show(const char *const barejid, const char *message)
return 0;
}
ProfChatWin *chatwin = wins_get_chat(barejid);
ProfChatWin* chatwin = wins_get_chat(barejid);
if (chatwin == NULL) {
log_warning("%s", "api_chat_show failed, could not find chat window for %s", barejid);
return 0;
}
char *parsed = str_replace(message, "\r\n", "\n");
char* parsed = str_replace(message, "\r\n", "\n");
win_println((ProfWin*)chatwin, THEME_TEXT, "-", "%s", parsed);
free(parsed);
@@ -791,8 +791,8 @@ api_chat_show(const char *const barejid, const char *message)
}
int
api_chat_show_themed(const char *const barejid, const char *const group, const char *const key, const char *const def,
const char *const ch, const char *const message)
api_chat_show_themed(const char* const barejid, const char* const group, const char* const key, const char* const def,
const char* const ch, const char* const message)
{
if (message == NULL) {
log_warning("%s", "api_chat_show_themed failed, message is NULL");
@@ -804,7 +804,7 @@ api_chat_show_themed(const char *const barejid, const char *const group, const c
return 0;
}
char *show_ch = "-";
char* show_ch = "-";
if (ch) {
if (g_utf8_strlen(ch, 4) != 1) {
log_warning("%s", "api_chat_show_themed failed, ch must be a string of length 1");
@@ -814,13 +814,13 @@ api_chat_show_themed(const char *const barejid, const char *const group, const c
}
}
ProfChatWin *chatwin = wins_get_chat(barejid);
ProfChatWin* chatwin = wins_get_chat(barejid);
if (chatwin == NULL) {
log_warning("%s", "api_chat_show_themed failed, could not find chat window for %s", barejid);
return 0;
}
char *parsed = str_replace(message, "\r\n", "\n");
char* parsed = str_replace(message, "\r\n", "\n");
theme_item_t themeitem = plugin_themes_get(group, key, def);
win_println((ProfWin*)chatwin, themeitem, show_ch, "%s", parsed);
@@ -830,7 +830,7 @@ api_chat_show_themed(const char *const barejid, const char *const group, const c
}
int
api_room_show(const char *const roomjid, const char *message)
api_room_show(const char* const roomjid, const char* message)
{
if (message == NULL) {
log_warning("%s", "api_room_show failed, message is NULL");
@@ -842,13 +842,13 @@ api_room_show(const char *const roomjid, const char *message)
return 0;
}
ProfMucWin *mucwin = wins_get_muc(roomjid);
ProfMucWin* mucwin = wins_get_muc(roomjid);
if (mucwin == NULL) {
log_warning("%s", "api_room_show failed, could not find room window for %s", roomjid);
return 0;
}
char *parsed = str_replace(message, "\r\n", "\n");
char* parsed = str_replace(message, "\r\n", "\n");
win_println((ProfWin*)mucwin, THEME_TEXT, "-", "%s", parsed);
free(parsed);
@@ -856,8 +856,8 @@ api_room_show(const char *const roomjid, const char *message)
}
int
api_room_show_themed(const char *const roomjid, const char *const group, const char *const key, const char *const def,
const char *const ch, const char *const message)
api_room_show_themed(const char* const roomjid, const char* const group, const char* const key, const char* const def,
const char* const ch, const char* const message)
{
if (message == NULL) {
log_warning("%s", "api_room_show_themed failed, message is NULL");
@@ -869,7 +869,7 @@ api_room_show_themed(const char *const roomjid, const char *const group, const c
return 0;
}
char *show_ch = "-";
char* show_ch = "-";
if (ch) {
if (g_utf8_strlen(ch, 4) != 1) {
log_warning("%s", "api_room_show_themed failed, ch must be a string of length 1");
@@ -879,13 +879,13 @@ api_room_show_themed(const char *const roomjid, const char *const group, const c
}
}
ProfMucWin *mucwin = wins_get_muc(roomjid);
ProfMucWin* mucwin = wins_get_muc(roomjid);
if (mucwin == NULL) {
log_warning("%s", "api_room_show_themed failed, could not find room window for %s", roomjid);
return 0;
}
char *parsed = str_replace(message, "\r\n", "\n");
char* parsed = str_replace(message, "\r\n", "\n");
theme_item_t themeitem = plugin_themes_get(group, key, def);
win_println((ProfWin*)mucwin, themeitem, show_ch, "%s", parsed);

View File

@@ -39,83 +39,83 @@
#include "plugins/callbacks.h"
void api_cons_alert(void);
int api_cons_show(const char * const message);
int api_cons_show_themed(const char *const group, const char *const item, const char *const def, const char *const message);
int api_cons_bad_cmd_usage(const char *const cmd);
void api_notify(const char *message, const char *category, int timeout_ms);
void api_send_line(char *line);
int api_cons_show(const char* const message);
int api_cons_show_themed(const char* const group, const char* const item, const char* const def, const char* const message);
int api_cons_bad_cmd_usage(const char* const cmd);
void api_notify(const char* message, const char* category, int timeout_ms);
void api_send_line(char* line);
char * api_get_current_recipient(void);
char * api_get_current_muc(void);
char* api_get_current_recipient(void);
char* api_get_current_muc(void);
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);
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));
void api_register_timed(const char *const plugin_name, void *callback, int interval_seconds,
void (*callback_func)(PluginTimedFunction *timed_function), void(*callback_destroy)(void *callback));
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));
void api_register_timed(const char* const plugin_name, void* callback, int interval_seconds,
void (*callback_func)(PluginTimedFunction* timed_function), void (*callback_destroy)(void* callback));
void api_completer_add(const char *const plugin_name, const char *key, char **items);
void api_completer_remove(const char *const plugin_name, const char *key, char **items);
void api_completer_clear(const char *const plugin_name, const char *key);
void api_filepath_completer_add(const char *const plugin_name, const char *prefix);
void api_completer_add(const char* const plugin_name, const char* key, char** items);
void api_completer_remove(const char* const plugin_name, const char* key, char** items);
void api_completer_clear(const char* const plugin_name, const char* key);
void api_filepath_completer_add(const char* const plugin_name, const char* prefix);
void api_log_debug(const char *message);
void api_log_info(const char *message);
void api_log_warning(const char *message);
void api_log_error(const char *message);
void api_log_debug(const char* message);
void api_log_info(const char* message);
void api_log_warning(const char* message);
void api_log_error(const char* message);
int api_win_exists(const char *tag);
int api_win_exists(const char* tag);
void api_win_create(
const char *const plugin_name,
const char *tag,
void *callback,
void(*callback_func)(PluginWindowCallback *window_callback, char *tag, char *line),
void(*destroy)(void *callback));
int api_win_focus(const char *tag);
int api_win_show(const char *tag, const char *line);
int api_win_show_themed(const char *tag, const char *const group, const char *const key, const char *const def, const char *line);
const char* const plugin_name,
const char* tag,
void* callback,
void (*callback_func)(PluginWindowCallback* window_callback, char* tag, char* line),
void (*destroy)(void* callback));
int api_win_focus(const char* tag);
int api_win_show(const char* tag, const char* line);
int api_win_show_themed(const char* tag, const char* const group, const char* const key, const char* const def, const char* line);
int api_send_stanza(const char *const stanza);
int api_send_stanza(const char* const stanza);
gboolean api_settings_boolean_get(const char *const group, const char *const key, gboolean def);
void api_settings_boolean_set(const char *const group, const char *const key, gboolean value);
char* api_settings_string_get(const char *const group, const char *const key, const char *const def);
void api_settings_string_set(const char *const group, const char *const key, const char *const value);
int api_settings_int_get(const char *const group, const char *const key, int def);
void api_settings_int_set(const char *const group, const char *const key, int value);
char** api_settings_string_list_get(const char *const group, const char *const key);
void api_settings_string_list_add(const char *const group, const char *const key, const char *const value);
int api_settings_string_list_remove(const char *const group, const char *const key, const char *const value);
int api_settings_string_list_clear(const char *const group, const char *const key);
gboolean api_settings_boolean_get(const char* const group, const char* const key, gboolean def);
void api_settings_boolean_set(const char* const group, const char* const key, gboolean value);
char* api_settings_string_get(const char* const group, const char* const key, const char* const def);
void api_settings_string_set(const char* const group, const char* const key, const char* const value);
int api_settings_int_get(const char* const group, const char* const key, int def);
void api_settings_int_set(const char* const group, const char* const key, int value);
char** api_settings_string_list_get(const char* const group, const char* const key);
void api_settings_string_list_add(const char* const group, const char* const key, const char* const value);
int api_settings_string_list_remove(const char* const group, const char* const key, const char* const value);
int api_settings_string_list_clear(const char* const group, const char* const key);
void api_incoming_message(const char *const barejid, const char *const resource, const char *const message);
void api_incoming_message(const char* const barejid, const char* const resource, const char* const message);
void api_disco_add_feature(char *plugin_name, char *feature);
void api_disco_add_feature(char* plugin_name, char* feature);
void api_encryption_reset(const char *const barejid);
void api_encryption_reset(const char* const barejid);
int api_chat_set_titlebar_enctext(const char *const barejid, const char *const enctext);
int api_chat_unset_titlebar_enctext(const char *const barejid);
int api_chat_set_incoming_char(const char *const barejid, const char *const ch);
int api_chat_unset_incoming_char(const char *const barejid);
int api_chat_set_outgoing_char(const char *const barejid, const char *const ch);
int api_chat_unset_outgoing_char(const char *const barejid);
int api_room_set_titlebar_enctext(const char *const roomjid, const char *const enctext);
int api_room_unset_titlebar_enctext(const char *const roomjid);
int api_room_set_message_char(const char *const roomjid, const char *const ch);
int api_room_unset_message_char(const char *const roomjid);
int api_chat_set_titlebar_enctext(const char* const barejid, const char* const enctext);
int api_chat_unset_titlebar_enctext(const char* const barejid);
int api_chat_set_incoming_char(const char* const barejid, const char* const ch);
int api_chat_unset_incoming_char(const char* const barejid);
int api_chat_set_outgoing_char(const char* const barejid, const char* const ch);
int api_chat_unset_outgoing_char(const char* const barejid);
int api_room_set_titlebar_enctext(const char* const roomjid, const char* const enctext);
int api_room_unset_titlebar_enctext(const char* const roomjid);
int api_room_set_message_char(const char* const roomjid, const char* const ch);
int api_room_unset_message_char(const char* const roomjid);
int api_chat_show(const char *const barejid, const char *const message);
int api_chat_show_themed(const char *const barejid, const char *const group, const char *const key, const char *const def,
const char *const ch, const char *const message);
int api_chat_show(const char* const barejid, const char* const message);
int api_chat_show_themed(const char* const barejid, const char* const group, const char* const key, const char* const def,
const char* const ch, const char* const message);
int api_room_show(const char *const roomjid, const char *message);
int api_room_show_themed(const char *const roomjid, const char *const group, const char *const key, const char *const def,
const char *const ch, const char *const message);
int api_room_show(const char* const roomjid, const char* message);
int api_room_show_themed(const char* const roomjid, const char* const group, const char* const key, const char* const def,
const char* const ch, const char* const message);
#endif

View File

@@ -40,17 +40,17 @@
#include "tools/autocomplete.h"
#include "command/cmd_ac.h"
static GHashTable *plugin_to_acs;
static GHashTable *plugin_to_filepath_acs;
static GHashTable* plugin_to_acs;
static GHashTable* plugin_to_filepath_acs;
static void
_free_autocompleters(GHashTable *key_to_ac)
_free_autocompleters(GHashTable* key_to_ac)
{
g_hash_table_destroy(key_to_ac);
}
static void
_free_filepath_autocompleters(GHashTable *prefixes)
_free_filepath_autocompleters(GHashTable* prefixes)
{
g_hash_table_destroy(prefixes);
}
@@ -63,9 +63,9 @@ autocompleters_init(void)
}
void
autocompleters_add(const char *const plugin_name, const char *key, char **items)
autocompleters_add(const char* const plugin_name, const char* key, char** items)
{
GHashTable *key_to_ac = g_hash_table_lookup(plugin_to_acs, plugin_name);
GHashTable* key_to_ac = g_hash_table_lookup(plugin_to_acs, plugin_name);
if (key_to_ac) {
if (g_hash_table_contains(key_to_ac, key)) {
Autocomplete existing_ac = g_hash_table_lookup(key_to_ac, key);
@@ -85,9 +85,9 @@ autocompleters_add(const char *const plugin_name, const char *key, char **items)
}
void
autocompleters_remove(const char *const plugin_name, const char *key, char **items)
autocompleters_remove(const char* const plugin_name, const char* key, char** items)
{
GHashTable *key_to_ac = g_hash_table_lookup(plugin_to_acs, plugin_name);
GHashTable* key_to_ac = g_hash_table_lookup(plugin_to_acs, plugin_name);
if (!key_to_ac) {
return;
}
@@ -101,9 +101,9 @@ autocompleters_remove(const char *const plugin_name, const char *key, char **ite
}
void
autocompleters_clear(const char *const plugin_name, const char *key)
autocompleters_clear(const char* const plugin_name, const char* key)
{
GHashTable *key_to_ac = g_hash_table_lookup(plugin_to_acs, plugin_name);
GHashTable* key_to_ac = g_hash_table_lookup(plugin_to_acs, plugin_name);
if (!key_to_ac) {
return;
}
@@ -117,9 +117,9 @@ autocompleters_clear(const char *const plugin_name, const char *key)
}
void
autocompleters_filepath_add(const char *const plugin_name, const char *prefix)
autocompleters_filepath_add(const char* const plugin_name, const char* prefix)
{
GHashTable *prefixes = g_hash_table_lookup(plugin_to_filepath_acs, plugin_name);
GHashTable* prefixes = g_hash_table_lookup(plugin_to_filepath_acs, plugin_name);
if (prefixes) {
g_hash_table_add(prefixes, strdup(prefix));
} else {
@@ -130,17 +130,17 @@ autocompleters_filepath_add(const char *const plugin_name, const char *prefix)
}
char*
autocompleters_complete(const char * const input, gboolean previous)
autocompleters_complete(const char* const input, gboolean previous)
{
char *result = NULL;
char* result = NULL;
GList *ac_hashes = g_hash_table_get_values(plugin_to_acs);
GList *curr_hash = ac_hashes;
GList* ac_hashes = g_hash_table_get_values(plugin_to_acs);
GList* curr_hash = ac_hashes;
while (curr_hash) {
GHashTable *key_to_ac = curr_hash->data;
GHashTable* key_to_ac = curr_hash->data;
GList *keys = g_hash_table_get_keys(key_to_ac);
GList *curr = keys;
GList* keys = g_hash_table_get_keys(key_to_ac);
GList* curr = keys;
while (curr) {
result = autocomplete_param_with_ac(input, curr->data, g_hash_table_lookup(key_to_ac, curr->data), TRUE, previous);
if (result) {
@@ -156,14 +156,14 @@ autocompleters_complete(const char * const input, gboolean previous)
}
g_list_free(ac_hashes);
GList *filepath_hashes = g_hash_table_get_values(plugin_to_filepath_acs);
GList* filepath_hashes = g_hash_table_get_values(plugin_to_filepath_acs);
curr_hash = filepath_hashes;
while (curr_hash) {
GHashTable *prefixes_hash = curr_hash->data;
GList *prefixes = g_hash_table_get_keys(prefixes_hash);
GList *curr_prefix = prefixes;
GHashTable* prefixes_hash = curr_hash->data;
GList* prefixes = g_hash_table_get_keys(prefixes_hash);
GList* curr_prefix = prefixes;
while (curr_prefix) {
char *prefix = curr_prefix->data;
char* prefix = curr_prefix->data;
if (g_str_has_prefix(input, prefix)) {
result = cmd_ac_complete_filepath(input, prefix, previous);
if (result) {
@@ -187,11 +187,11 @@ autocompleters_complete(const char * const input, gboolean previous)
void
autocompleters_reset(void)
{
GList *ac_hashes = g_hash_table_get_values(plugin_to_acs);
GList *curr_hash = ac_hashes;
GList* ac_hashes = g_hash_table_get_values(plugin_to_acs);
GList* curr_hash = ac_hashes;
while (curr_hash) {
GList *acs = g_hash_table_get_values(curr_hash->data);
GList *curr = acs;
GList* acs = g_hash_table_get_values(curr_hash->data);
GList* curr = acs;
while (curr) {
autocomplete_reset(curr->data);
curr = g_list_next(curr);
@@ -204,7 +204,8 @@ autocompleters_reset(void)
g_list_free(ac_hashes);
}
void autocompleters_destroy(void)
void
autocompleters_destroy(void)
{
g_hash_table_destroy(plugin_to_acs);
g_hash_table_destroy(plugin_to_filepath_acs);

View File

@@ -39,11 +39,11 @@
#include <glib.h>
void autocompleters_init(void);
void autocompleters_add(const char *const plugin_name, const char *key, char **items);
void autocompleters_remove(const char *const plugin_name, const char *key, char **items);
void autocompleters_clear(const char *const plugin_name, const char *key);
void autocompleters_filepath_add(const char *const plugin_name, const char *prefix);
char* autocompleters_complete(const char * const input, gboolean previous);
void autocompleters_add(const char* const plugin_name, const char* key, char** items);
void autocompleters_remove(const char* const plugin_name, const char* key, char** items);
void autocompleters_clear(const char* const plugin_name, const char* key);
void autocompleters_filepath_add(const char* const plugin_name, const char* prefix);
char* autocompleters_complete(const char* const input, gboolean previous);
void autocompleters_reset(void);
void autocompleters_destroy(void);

View File

@@ -43,19 +43,22 @@
#include "plugins/callbacks.h"
#include "plugins/profapi.h"
typedef struct command_wrapper_t {
void(*func)(char **args);
typedef struct command_wrapper_t
{
void (*func)(char** args);
} CommandWrapper;
typedef struct timed_wrapper_t {
void(*func)(void);
typedef struct timed_wrapper_t
{
void (*func)(void);
} TimedWrapper;
typedef struct window_wrapper_t {
void(*func)(char *tag, char *line);
typedef struct window_wrapper_t
{
void (*func)(char* tag, char* line);
} WindowWrapper;
static char* _c_plugin_name(const char *filename);
static char* _c_plugin_name(const char* filename);
static void
c_api_cons_alert(void)
@@ -64,46 +67,46 @@ c_api_cons_alert(void)
}
static int
c_api_cons_show(const char * const message)
c_api_cons_show(const char* const message)
{
return api_cons_show(message);
}
static int
c_api_cons_show_themed(const char *const group, const char *const item, const char *const def, const char *const message)
c_api_cons_show_themed(const char* const group, const char* const item, const char* const def, const char* const message)
{
return api_cons_show_themed(group, item, def, message);
}
static int
c_api_cons_bad_cmd_usage(const char *const cmd)
c_api_cons_bad_cmd_usage(const char* const cmd)
{
return api_cons_bad_cmd_usage(cmd);
}
static void
c_api_register_command(const char *filename, const char *command_name, int min_args, int max_args,
char **synopsis, const char *description, char *arguments[][2], char **examples,
void(*callback)(char **args))
c_api_register_command(const char* filename, const char* command_name, int min_args, int max_args,
char** synopsis, const char* description, char* arguments[][2], char** examples,
void (*callback)(char** args))
{
char *plugin_name = _c_plugin_name(filename);
char* plugin_name = _c_plugin_name(filename);
log_debug("Register command %s for %s", command_name, plugin_name);
CommandWrapper *wrapper = malloc(sizeof(CommandWrapper));
CommandWrapper* wrapper = malloc(sizeof(CommandWrapper));
wrapper->func = callback;
api_register_command(plugin_name, command_name, min_args, max_args, synopsis,
description, arguments, examples, wrapper, c_command_callback, free);
description, arguments, examples, wrapper, c_command_callback, free);
free(plugin_name);
}
static void
c_api_register_timed(const char *filename, void(*callback)(void), int interval_seconds)
c_api_register_timed(const char* filename, void (*callback)(void), int interval_seconds)
{
char *plugin_name = _c_plugin_name(filename);
char* plugin_name = _c_plugin_name(filename);
log_debug("Register timed for %s", plugin_name);
TimedWrapper *wrapper = malloc(sizeof(TimedWrapper));
TimedWrapper* wrapper = malloc(sizeof(TimedWrapper));
wrapper->func = callback;
api_register_timed(plugin_name, wrapper, interval_seconds, c_timed_callback, free);
@@ -111,9 +114,9 @@ c_api_register_timed(const char *filename, void(*callback)(void), int interval_s
}
static void
c_api_completer_add(const char *filename, const char *key, char **items)
c_api_completer_add(const char* filename, const char* key, char** items)
{
char *plugin_name = _c_plugin_name(filename);
char* plugin_name = _c_plugin_name(filename);
log_debug("Autocomplete add %s for %s", key, plugin_name);
api_completer_add(plugin_name, key, items);
@@ -122,9 +125,9 @@ c_api_completer_add(const char *filename, const char *key, char **items)
}
static void
c_api_completer_remove(const char *filename, const char *key, char **items)
c_api_completer_remove(const char* filename, const char* key, char** items)
{
char *plugin_name = _c_plugin_name(filename);
char* plugin_name = _c_plugin_name(filename);
log_debug("Autocomplete remove %s for %s", key, plugin_name);
api_completer_remove(plugin_name, key, items);
@@ -133,9 +136,9 @@ c_api_completer_remove(const char *filename, const char *key, char **items)
}
static void
c_api_completer_clear(const char *filename, const char *key)
c_api_completer_clear(const char* filename, const char* key)
{
char *plugin_name = _c_plugin_name(filename);
char* plugin_name = _c_plugin_name(filename);
log_debug("Autocomplete clear %s for %s", key, plugin_name);
api_completer_clear(plugin_name, key);
@@ -144,9 +147,9 @@ c_api_completer_clear(const char *filename, const char *key)
}
static void
c_api_filepath_completer_add(const char *filename, const char *prefix)
c_api_filepath_completer_add(const char* filename, const char* prefix)
{
char *plugin_name = _c_plugin_name(filename);
char* plugin_name = _c_plugin_name(filename);
log_debug("Filepath autocomplete added '%s' for %s", prefix, plugin_name);
api_filepath_completer_add(plugin_name, prefix);
@@ -155,24 +158,24 @@ c_api_filepath_completer_add(const char *filename, const char *prefix)
}
static void
c_api_notify(const char *message, int timeout_ms, const char *category)
c_api_notify(const char* message, int timeout_ms, const char* category)
{
api_notify(message, category, timeout_ms);
}
static void
c_api_send_line(char *line)
c_api_send_line(char* line)
{
api_send_line(line);
}
static char *
static char*
c_api_get_current_recipient(void)
{
return api_get_current_recipient();
}
static char *
static char*
c_api_get_current_muc(void)
{
return api_get_current_muc();
@@ -197,47 +200,47 @@ c_api_get_current_occupants(void)
}
static char*
c_api_get_room_nick(const char *barejid)
c_api_get_room_nick(const char* barejid)
{
return api_get_room_nick(barejid);
}
static void
c_api_log_debug(const char *message)
c_api_log_debug(const char* message)
{
api_log_debug(message);
}
static void
c_api_log_info(const char *message)
c_api_log_info(const char* message)
{
api_log_info(message);
}
static void
c_api_log_warning(const char *message)
c_api_log_warning(const char* message)
{
api_log_warning(message);
}
static void
c_api_log_error(const char *message)
c_api_log_error(const char* message)
{
api_log_error(message);
}
static int
c_api_win_exists(char *tag)
c_api_win_exists(char* tag)
{
return api_win_exists(tag);
}
static void
c_api_win_create(const char *filename, char *tag, void(*callback)(char *tag, char *line))
c_api_win_create(const char* filename, char* tag, void (*callback)(char* tag, char* line))
{
char *plugin_name = _c_plugin_name(filename);
char* plugin_name = _c_plugin_name(filename);
WindowWrapper *wrapper = malloc(sizeof(WindowWrapper));
WindowWrapper* wrapper = malloc(sizeof(WindowWrapper));
wrapper->func = callback;
api_win_create(plugin_name, tag, wrapper, c_window_callback, free);
@@ -245,216 +248,216 @@ c_api_win_create(const char *filename, char *tag, void(*callback)(char *tag, cha
}
static int
c_api_win_focus(char *tag)
c_api_win_focus(char* tag)
{
return api_win_focus(tag);
}
static int
c_api_win_show(char *tag, char *line)
c_api_win_show(char* tag, char* line)
{
return api_win_show(tag, line);
}
static int
c_api_win_show_themed(char *tag, char *group, char *key, char *def, char *line)
c_api_win_show_themed(char* tag, char* group, char* key, char* def, char* line)
{
return api_win_show_themed(tag, group, key, def, line);
}
static int
c_api_send_stanza(char *stanza)
c_api_send_stanza(char* stanza)
{
return api_send_stanza(stanza);
}
static int
c_api_settings_boolean_get(char *group, char *key, int def)
c_api_settings_boolean_get(char* group, char* key, int def)
{
return api_settings_boolean_get(group, key, def);
}
static void
c_api_settings_boolean_set(char *group, char *key, int value)
c_api_settings_boolean_set(char* group, char* key, int value)
{
api_settings_boolean_set(group, key, value);
}
static char*
c_api_settings_string_get(char *group, char *key, char *def)
c_api_settings_string_get(char* group, char* key, char* def)
{
return api_settings_string_get(group, key, def);
}
static void
c_api_settings_string_set(char *group, char *key, char *value)
c_api_settings_string_set(char* group, char* key, char* value)
{
api_settings_string_set(group, key, value);
}
static char**
c_api_settings_string_list_get(char *group, char *key)
c_api_settings_string_list_get(char* group, char* key)
{
return api_settings_string_list_get(group, key);
}
static void
c_api_settings_string_list_add(char *group, char *key, char* value)
c_api_settings_string_list_add(char* group, char* key, char* value)
{
api_settings_string_list_add(group, key, value);
}
static int
c_api_settings_string_list_remove(char *group, char *key, char *value)
c_api_settings_string_list_remove(char* group, char* key, char* value)
{
return api_settings_string_list_remove(group, key, value);
}
static int
c_api_settings_string_list_clear(char *group, char *key)
c_api_settings_string_list_clear(char* group, char* key)
{
return api_settings_string_list_clear(group, key);
}
static int
c_api_settings_int_get(char *group, char *key, int def)
c_api_settings_int_get(char* group, char* key, int def)
{
return api_settings_int_get(group, key, def);
}
static void
c_api_settings_int_set(char *group, char *key, int value)
c_api_settings_int_set(char* group, char* key, int value)
{
api_settings_int_set(group, key, value);
}
static void
c_api_incoming_message(char *barejid, char *resource, char *message)
c_api_incoming_message(char* barejid, char* resource, char* message)
{
api_incoming_message(barejid, resource, message);
}
static void
c_api_disco_add_feature(const char *filename, char *feature)
c_api_disco_add_feature(const char* filename, char* feature)
{
char *plugin_name = _c_plugin_name(filename);
char* plugin_name = _c_plugin_name(filename);
api_disco_add_feature(plugin_name, feature);
free(plugin_name);
}
static void
c_api_encryption_reset(const char *barejid)
c_api_encryption_reset(const char* barejid)
{
api_encryption_reset(barejid);
}
static int
c_api_chat_set_titlebar_enctext(const char *barejid, const char *enctext)
c_api_chat_set_titlebar_enctext(const char* barejid, const char* enctext)
{
return api_chat_set_titlebar_enctext(barejid, enctext);
}
static int
c_api_chat_unset_titlebar_enctext(const char *barejid)
c_api_chat_unset_titlebar_enctext(const char* barejid)
{
return api_chat_unset_titlebar_enctext(barejid);
}
static int
c_api_chat_set_incoming_char(const char *barejid, const char *ch)
c_api_chat_set_incoming_char(const char* barejid, const char* ch)
{
return api_chat_set_incoming_char(barejid, ch);
}
static int
c_api_chat_unset_incoming_char(const char *barejid)
c_api_chat_unset_incoming_char(const char* barejid)
{
return api_chat_unset_incoming_char(barejid);
}
static int
c_api_chat_set_outgoing_char(const char *barejid, const char *ch)
c_api_chat_set_outgoing_char(const char* barejid, const char* ch)
{
return api_chat_set_outgoing_char(barejid, ch);
}
static int
c_api_chat_unset_outgoing_char(const char *barejid)
c_api_chat_unset_outgoing_char(const char* barejid)
{
return api_chat_unset_outgoing_char(barejid);
}
static int
c_api_room_set_titlebar_enctext(const char *roomjid, const char *enctext)
c_api_room_set_titlebar_enctext(const char* roomjid, const char* enctext)
{
return api_room_set_titlebar_enctext(roomjid, enctext);
}
static int
c_api_room_unset_titlebar_enctext(const char *roomjid)
c_api_room_unset_titlebar_enctext(const char* roomjid)
{
return api_room_unset_titlebar_enctext(roomjid);
}
static int
c_api_room_set_message_char(const char *roomjid, const char *ch)
c_api_room_set_message_char(const char* roomjid, const char* ch)
{
return api_room_set_message_char(roomjid, ch);
}
static int
c_api_room_unset_message_char(const char *roomjid)
c_api_room_unset_message_char(const char* roomjid)
{
return api_room_unset_message_char(roomjid);
}
static int
c_api_chat_show(const char *const barejid, const char *const message)
c_api_chat_show(const char* const barejid, const char* const message)
{
return api_chat_show(barejid, message);
}
static int
c_api_chat_show_themed(const char *const barejid, const char *const group, const char *const item, const char *const def,
const char *const ch, const char *const message)
c_api_chat_show_themed(const char* const barejid, const char* const group, const char* const item, const char* const def,
const char* const ch, const char* const message)
{
return api_chat_show_themed(barejid, group, item, def, ch, message);
}
static int
c_api_room_show(const char *const roomjid, const char *const message)
c_api_room_show(const char* const roomjid, const char* const message)
{
return api_room_show(roomjid, message);
}
static int
c_api_room_show_themed(const char *const roomjid, const char *const group, const char *const item, const char *const def,
const char *const ch, const char *const message)
c_api_room_show_themed(const char* const roomjid, const char* const group, const char* const item, const char* const def,
const char* const ch, const char* const message)
{
return api_room_show_themed(roomjid, group, item, def, ch, message);
}
void
c_command_callback(PluginCommand *command, gchar **args)
c_command_callback(PluginCommand* command, gchar** args)
{
CommandWrapper *wrapper = command->callback;
void(*f)(gchar **args) = wrapper->func;
CommandWrapper* wrapper = command->callback;
void (*f)(gchar * *args) = wrapper->func;
f(args);
}
void
c_timed_callback(PluginTimedFunction *timed_function)
c_timed_callback(PluginTimedFunction* timed_function)
{
TimedWrapper *wrapper = timed_function->callback;
void(*f)(void) = wrapper->func;
TimedWrapper* wrapper = timed_function->callback;
void (*f)(void) = wrapper->func;
f();
}
void
c_window_callback(PluginWindowCallback *window_callback, char *tag, char *line)
c_window_callback(PluginWindowCallback* window_callback, char* tag, char* line)
{
WindowWrapper *wrapper = window_callback->callback;
void(*f)(char *tag, char *line) = wrapper->func;
WindowWrapper* wrapper = window_callback->callback;
void (*f)(char* tag, char* line) = wrapper->func;
f(tag, line);
}
@@ -518,15 +521,15 @@ c_api_init(void)
prof_room_show_themed = c_api_room_show_themed;
}
static char *
_c_plugin_name(const char *filename)
static char*
_c_plugin_name(const char* filename)
{
GString *plugin_name_str = g_string_new("");
gchar *name = g_strndup(filename, strlen(filename)-1);
GString* plugin_name_str = g_string_new("");
gchar* name = g_strndup(filename, strlen(filename) - 1);
g_string_append(plugin_name_str, name);
g_free(name);
g_string_append(plugin_name_str, "so");
char *result = plugin_name_str->str;
char* result = plugin_name_str->str;
g_string_free(plugin_name_str, FALSE);
return result;

View File

@@ -40,8 +40,8 @@
void c_api_init(void);
void c_command_callback(PluginCommand *command, gchar **args);
void c_timed_callback(PluginTimedFunction *timed_function);
void c_window_callback(PluginWindowCallback *window_callback, char *tag, char *line);
void c_command_callback(PluginCommand* command, gchar** args);
void c_timed_callback(PluginTimedFunction* timed_function);
void c_window_callback(PluginWindowCallback* window_callback, char* tag, char* line);
#endif

View File

@@ -58,21 +58,21 @@ c_env_init(void)
}
ProfPlugin*
c_plugin_create(const char *const filename)
c_plugin_create(const char* const filename)
{
ProfPlugin *plugin;
void *handle = NULL;
ProfPlugin* plugin;
void* handle = NULL;
char *plugins_dir = files_get_data_path(DIR_PLUGINS);
GString *path = g_string_new(plugins_dir);
char* plugins_dir = files_get_data_path(DIR_PLUGINS);
GString* path = g_string_new(plugins_dir);
free(plugins_dir);
g_string_append(path, "/");
g_string_append(path, filename);
handle = dlopen (path->str, RTLD_NOW | RTLD_GLOBAL);
handle = dlopen(path->str, RTLD_NOW | RTLD_GLOBAL);
if (!handle) {
log_warning("dlopen failed to open `%s', %s", filename, dlerror ());
log_warning("dlopen failed to open `%s', %s", filename, dlerror());
g_string_free(path, TRUE);
return NULL;
}
@@ -118,28 +118,28 @@ c_plugin_create(const char *const filename)
}
void
c_init_hook(ProfPlugin *plugin, const char *const version, const char *const status, const char *const account_name,
const char *const fulljid)
c_init_hook(ProfPlugin* plugin, const char* const version, const char* const status, const char* const account_name,
const char* const fulljid)
{
void *f = NULL;
void (*func)(const char *const __version, const char *const __status, const char *const __account_name,
const char *const __fulljid);
void* f = NULL;
void (*func)(const char* const __version, const char* const __status, const char* const __account_name,
const char* const __fulljid);
assert(plugin && plugin->module);
if (NULL == (f = dlsym(plugin->module, "prof_init"))) {
log_warning ("warning: %s does not have init function", plugin->name);
log_warning("warning: %s does not have init function", plugin->name);
return;
}
func = (void (*)(const char *const, const char *const, const char *const, const char *const))f;
func = (void (*)(const char* const, const char* const, const char* const, const char* const))f;
// FIXME maybe we want to make it boolean to see if it succeeded or not?
func(version, status, account_name, fulljid);
}
gboolean
c_contains_hook(ProfPlugin *plugin, const char *const hook)
c_contains_hook(ProfPlugin* plugin, const char* const hook)
{
if (dlsym(plugin->module, hook)) {
return TRUE;
@@ -149,9 +149,9 @@ c_contains_hook(ProfPlugin *plugin, const char *const hook)
}
void
c_on_start_hook(ProfPlugin *plugin)
c_on_start_hook(ProfPlugin* plugin)
{
void *f = NULL;
void* f = NULL;
void (*func)(void);
assert(plugin && plugin->module);
@@ -163,9 +163,9 @@ c_on_start_hook(ProfPlugin *plugin)
}
void
c_on_shutdown_hook(ProfPlugin *plugin)
c_on_shutdown_hook(ProfPlugin* plugin)
{
void *f = NULL;
void* f = NULL;
void (*func)(void);
assert(plugin && plugin->module);
@@ -177,9 +177,9 @@ c_on_shutdown_hook(ProfPlugin *plugin)
}
void
c_on_unload_hook(ProfPlugin *plugin)
c_on_unload_hook(ProfPlugin* plugin)
{
void *f = NULL;
void* f = NULL;
void (*func)(void);
assert(plugin && plugin->module);
@@ -191,373 +191,373 @@ c_on_unload_hook(ProfPlugin *plugin)
}
void
c_on_connect_hook(ProfPlugin *plugin, const char *const account_name, const char *const fulljid)
c_on_connect_hook(ProfPlugin* plugin, const char* const account_name, const char* const fulljid)
{
void *f = NULL;
void (*func)(const char *const __account_name, const char *const __fulljid);
void* f = NULL;
void (*func)(const char* const __account_name, const char* const __fulljid);
assert(plugin && plugin->module);
if (NULL == (f = dlsym(plugin->module, "prof_on_connect")))
return;
func = (void (*)(const char *const, const char *const))f;
func = (void (*)(const char* const, const char* const))f;
func(account_name, fulljid);
}
void
c_on_disconnect_hook(ProfPlugin *plugin, const char *const account_name, const char *const fulljid)
c_on_disconnect_hook(ProfPlugin* plugin, const char* const account_name, const char* const fulljid)
{
void *f = NULL;
void (*func)(const char *const __account_name, const char *const __fulljid);
void* f = NULL;
void (*func)(const char* const __account_name, const char* const __fulljid);
assert(plugin && plugin->module);
if (NULL == (f = dlsym(plugin->module, "prof_on_disconnect")))
return;
func = (void (*)(const char *const, const char *const))f;
func = (void (*)(const char* const, const char* const))f;
func(account_name, fulljid);
}
char*
c_pre_chat_message_display_hook(ProfPlugin *plugin, const char *const barejid, const char *const resource, const char *message)
c_pre_chat_message_display_hook(ProfPlugin* plugin, const char* const barejid, const char* const resource, const char* message)
{
void *f = NULL;
char* (*func)(const char *const __barejid, const char *const __resource, const char *__message);
void* f = NULL;
char* (*func)(const char* const __barejid, const char* const __resource, const char* __message);
assert(plugin && plugin->module);
if (NULL == (f = dlsym(plugin->module, "prof_pre_chat_message_display")))
return NULL;
func = (char* (*)(const char *const, const char *const, const char *))f;
func = (char* (*)(const char* const, const char* const, const char*))f;
return func(barejid, resource, message);
}
void
c_post_chat_message_display_hook(ProfPlugin *plugin, const char *const barejid, const char *const resource, const char *message)
c_post_chat_message_display_hook(ProfPlugin* plugin, const char* const barejid, const char* const resource, const char* message)
{
void *f = NULL;
void (*func)(const char *const __barejid, const char *const __resource, const char *__message);
void* f = NULL;
void (*func)(const char* const __barejid, const char* const __resource, const char* __message);
assert(plugin && plugin->module);
if (NULL == (f = dlsym(plugin->module, "prof_post_chat_message_display")))
return;
func = (void (*)(const char *const, const char *const, const char *))f;
func = (void (*)(const char* const, const char* const, const char*))f;
func(barejid, resource, message);
}
char*
c_pre_chat_message_send_hook(ProfPlugin *plugin, const char *const barejid, const char *message)
c_pre_chat_message_send_hook(ProfPlugin* plugin, const char* const barejid, const char* message)
{
void *f = NULL;
char* (*func)(const char *const __barejid, const char *__message);
void* f = NULL;
char* (*func)(const char* const __barejid, const char* __message);
assert(plugin && plugin->module);
if (NULL == (f = dlsym(plugin->module, "prof_pre_chat_message_send")))
return NULL;
func = (char* (*)(const char *const, const char *))f;
func = (char* (*)(const char* const, const char*))f;
return func(barejid, message);
}
void
c_post_chat_message_send_hook(ProfPlugin *plugin, const char *const barejid, const char *message)
c_post_chat_message_send_hook(ProfPlugin* plugin, const char* const barejid, const char* message)
{
void *f = NULL;
void (*func)(const char *const __barejid, const char *__message);
void* f = NULL;
void (*func)(const char* const __barejid, const char* __message);
assert(plugin && plugin->module);
if (NULL == (f = dlsym(plugin->module, "prof_post_chat_message_send")))
return;
func = (void (*)(const char *const, const char *))f;
func = (void (*)(const char* const, const char*))f;
func(barejid, message);
}
char*
c_pre_room_message_display_hook(ProfPlugin *plugin, const char *const barejid, const char *const nick, const char *message)
c_pre_room_message_display_hook(ProfPlugin* plugin, const char* const barejid, const char* const nick, const char* message)
{
void *f = NULL;
char* (*func)(const char *const __barejid, const char *const __nick, const char *__message);
void* f = NULL;
char* (*func)(const char* const __barejid, const char* const __nick, const char* __message);
assert(plugin && plugin->module);
if (NULL == (f = dlsym(plugin->module, "prof_pre_room_message_display")))
return NULL;
func = (char* (*)(const char *const, const char *const, const char *))f;
func = (char* (*)(const char* const, const char* const, const char*))f;
return func(barejid, nick, message);
}
void
c_post_room_message_display_hook(ProfPlugin *plugin, const char *const barejid, const char *const nick,
const char *message)
c_post_room_message_display_hook(ProfPlugin* plugin, const char* const barejid, const char* const nick,
const char* message)
{
void *f = NULL;
void (*func)(const char *const __barejid, const char *const __nick, const char *__message);
void* f = NULL;
void (*func)(const char* const __barejid, const char* const __nick, const char* __message);
assert(plugin && plugin->module);
if (NULL == (f = dlsym(plugin->module, "prof_post_room_message_display")))
return;
func = (void (*)(const char *const, const char *const, const char *))f;
func = (void (*)(const char* const, const char* const, const char*))f;
func(barejid, nick, message);
}
char*
c_pre_room_message_send_hook(ProfPlugin *plugin, const char *const barejid, const char *message)
c_pre_room_message_send_hook(ProfPlugin* plugin, const char* const barejid, const char* message)
{
void *f = NULL;
char* (*func)(const char *const __barejid, const char *__message);
void* f = NULL;
char* (*func)(const char* const __barejid, const char* __message);
assert(plugin && plugin->module);
if (NULL == (f = dlsym(plugin->module, "prof_pre_room_message_send")))
return NULL;
func = (char* (*)(const char *const, const char *))f;
func = (char* (*)(const char* const, const char*))f;
return func(barejid, message);
}
void
c_post_room_message_send_hook(ProfPlugin *plugin, const char *const barejid, const char *message)
c_post_room_message_send_hook(ProfPlugin* plugin, const char* const barejid, const char* message)
{
void *f = NULL;
void (*func)(const char *const __barejid, const char *__message);
void* f = NULL;
void (*func)(const char* const __barejid, const char* __message);
assert(plugin && plugin->module);
if (NULL == (f = dlsym(plugin->module, "prof_post_room_message_send")))
return;
func = (void (*)(const char *const, const char *))f;
func = (void (*)(const char* const, const char*))f;
func(barejid, message);
}
void
c_on_room_history_message_hook(ProfPlugin *plugin, const char *const barejid, const char *const nick,
const char *const message, const char *const timestamp)
c_on_room_history_message_hook(ProfPlugin* plugin, const char* const barejid, const char* const nick,
const char* const message, const char* const timestamp)
{
void *f = NULL;
void (*func)(const char *const __barejid, const char *const __nick, const char *const __message,
const char *const __timestamp);
void* f = NULL;
void (*func)(const char* const __barejid, const char* const __nick, const char* const __message,
const char* const __timestamp);
assert(plugin && plugin->module);
if (NULL == (f = dlsym(plugin->module, "prof_on_room_history_message")))
return;
func = (void (*)(const char *const, const char *const, const char *const, const char *const))f;
func = (void (*)(const char* const, const char* const, const char* const, const char* const))f;
func(barejid, nick, message, timestamp);
}
char*
c_pre_priv_message_display_hook(ProfPlugin *plugin, const char *const barejid, const char *const nick, const char *message)
c_pre_priv_message_display_hook(ProfPlugin* plugin, const char* const barejid, const char* const nick, const char* message)
{
void *f = NULL;
char* (*func)(const char *const __barejid, const char *const __nick, const char *__message);
void* f = NULL;
char* (*func)(const char* const __barejid, const char* const __nick, const char* __message);
assert(plugin && plugin->module);
if (NULL == (f = dlsym(plugin->module, "prof_pre_priv_message_display")))
return NULL;
func = (char* (*)(const char *const, const char *const, const char *))f;
func = (char* (*)(const char* const, const char* const, const char*))f;
return func(barejid, nick, message);
}
void
c_post_priv_message_display_hook(ProfPlugin *plugin, const char *const barejid, const char *const nick,
const char *message)
c_post_priv_message_display_hook(ProfPlugin* plugin, const char* const barejid, const char* const nick,
const char* message)
{
void *f = NULL;
void (*func)(const char *const __barejid, const char *const __nick, const char *__message);
void* f = NULL;
void (*func)(const char* const __barejid, const char* const __nick, const char* __message);
assert(plugin && plugin->module);
if (NULL == (f = dlsym(plugin->module, "prof_post_priv_message_display")))
return;
func = (void (*)(const char *const, const char *const, const char *))f;
func = (void (*)(const char* const, const char* const, const char*))f;
func(barejid, nick, message);
}
char*
c_pre_priv_message_send_hook(ProfPlugin *plugin, const char *const barejid, const char *const nick, const char *message)
c_pre_priv_message_send_hook(ProfPlugin* plugin, const char* const barejid, const char* const nick, const char* message)
{
void *f = NULL;
char* (*func)(const char *const __barejid, const char *const __nick, const char *__message);
void* f = NULL;
char* (*func)(const char* const __barejid, const char* const __nick, const char* __message);
assert(plugin && plugin->module);
if (NULL == (f = dlsym(plugin->module, "prof_pre_priv_message_send")))
return NULL;
func = (char* (*)(const char *const, const char *const, const char *))f;
func = (char* (*)(const char* const, const char* const, const char*))f;
return func(barejid, nick, message);
}
void
c_post_priv_message_send_hook(ProfPlugin *plugin, const char *const barejid, const char *const nick, const char *message)
c_post_priv_message_send_hook(ProfPlugin* plugin, const char* const barejid, const char* const nick, const char* message)
{
void *f = NULL;
void (*func)(const char *const __barejid, const char *const __nick, const char *__message);
void* f = NULL;
void (*func)(const char* const __barejid, const char* const __nick, const char* __message);
assert(plugin && plugin->module);
if (NULL == (f = dlsym(plugin->module, "prof_post_priv_message_send")))
return;
func = (void (*)(const char *const, const char *const, const char *))f;
func = (void (*)(const char* const, const char* const, const char*))f;
func(barejid, nick, message);
}
char*
c_on_message_stanza_send_hook(ProfPlugin *plugin, const char *const text)
c_on_message_stanza_send_hook(ProfPlugin* plugin, const char* const text)
{
void *f = NULL;
char* (*func)(const char *const __text);
void* f = NULL;
char* (*func)(const char* const __text);
assert(plugin && plugin->module);
if (NULL == (f = dlsym(plugin->module, "prof_on_message_stanza_send")))
return NULL;
func = (char* (*)(const char *const))f;
func = (char* (*)(const char* const))f;
return func(text);
}
gboolean
c_on_message_stanza_receive_hook(ProfPlugin *plugin, const char *const text)
c_on_message_stanza_receive_hook(ProfPlugin* plugin, const char* const text)
{
void *f = NULL;
int (*func)(const char *const __text);
void* f = NULL;
int (*func)(const char* const __text);
assert(plugin && plugin->module);
if (NULL == (f = dlsym(plugin->module, "prof_on_message_stanza_receive")))
return TRUE;
func = (int (*)(const char *const))f;
func = (int (*)(const char* const))f;
return func(text);
}
char*
c_on_presence_stanza_send_hook(ProfPlugin *plugin, const char *const text)
c_on_presence_stanza_send_hook(ProfPlugin* plugin, const char* const text)
{
void *f = NULL;
char* (*func)(const char *const __text);
void* f = NULL;
char* (*func)(const char* const __text);
assert(plugin && plugin->module);
if (NULL == (f = dlsym(plugin->module, "prof_on_presence_stanza_send")))
return NULL;
func = (char* (*)(const char *const))f;
func = (char* (*)(const char* const))f;
return func(text);
}
gboolean
c_on_presence_stanza_receive_hook(ProfPlugin *plugin, const char *const text)
c_on_presence_stanza_receive_hook(ProfPlugin* plugin, const char* const text)
{
void *f = NULL;
int (*func)(const char *const __text);
void* f = NULL;
int (*func)(const char* const __text);
assert(plugin && plugin->module);
if (NULL == (f = dlsym(plugin->module, "prof_on_presence_stanza_receive")))
return TRUE;
func = (int (*)(const char *const))f;
func = (int (*)(const char* const))f;
return func(text);
}
char*
c_on_iq_stanza_send_hook(ProfPlugin *plugin, const char *const text)
c_on_iq_stanza_send_hook(ProfPlugin* plugin, const char* const text)
{
void *f = NULL;
char* (*func)(const char *const __text);
void* f = NULL;
char* (*func)(const char* const __text);
assert(plugin && plugin->module);
if (NULL == (f = dlsym(plugin->module, "prof_on_iq_stanza_send")))
return NULL;
func = (char* (*)(const char *const))f;
func = (char* (*)(const char* const))f;
return func(text);
}
gboolean
c_on_iq_stanza_receive_hook(ProfPlugin *plugin, const char *const text)
c_on_iq_stanza_receive_hook(ProfPlugin* plugin, const char* const text)
{
void *f = NULL;
int (*func)(const char *const __text);
void* f = NULL;
int (*func)(const char* const __text);
assert(plugin && plugin->module);
if (NULL == (f = dlsym(plugin->module, "prof_on_iq_stanza_receive")))
return TRUE;
func = (int (*)(const char *const))f;
func = (int (*)(const char* const))f;
return func(text);
}
void
c_on_contact_offline_hook(ProfPlugin *plugin, const char *const barejid, const char *const resource,
const char *const status)
c_on_contact_offline_hook(ProfPlugin* plugin, const char* const barejid, const char* const resource,
const char* const status)
{
void *f = NULL;
void (*func)(const char *const __barejid, const char *const __resource, const char *const __status);
void* f = NULL;
void (*func)(const char* const __barejid, const char* const __resource, const char* const __status);
assert(plugin && plugin->module);
if (NULL == (f = dlsym(plugin->module, "prof_on_contact_offline")))
return;
func = (void (*)(const char *const, const char *const, const char *const))f;
func = (void (*)(const char* const, const char* const, const char* const))f;
func(barejid, resource, status);
}
void
c_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)
c_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)
{
void *f = NULL;
void (*func)(const char *const __barejid, const char *const __resource, const char *const __presence,
const char *const __status, const int __priority);
void* f = NULL;
void (*func)(const char* const __barejid, const char* const __resource, const char* const __presence,
const char* const __status, const int __priority);
assert(plugin && plugin->module);
if (NULL == (f = dlsym(plugin->module, "prof_on_contact_presence")))
return;
func = (void (*)(const char *const, const char *const, const char *const, const char *const, const int))f;
func = (void (*)(const char* const, const char* const, const char* const, const char* const, const int))f;
func(barejid, resource, presence, status, priority);
}
void
c_on_chat_win_focus_hook(ProfPlugin *plugin, const char *const barejid)
c_on_chat_win_focus_hook(ProfPlugin* plugin, const char* const barejid)
{
void *f = NULL;
void (*func)(const char *const __barejid);
void* f = NULL;
void (*func)(const char* const __barejid);
assert(plugin && plugin->module);
if (NULL == (f = dlsym(plugin->module, "prof_on_chat_win_focus")))
return;
func = (void (*)(const char *const))f;
func = (void (*)(const char* const))f;
func(barejid);
}
void
c_on_room_win_focus_hook(ProfPlugin *plugin, const char *const barejid)
c_on_room_win_focus_hook(ProfPlugin* plugin, const char* const barejid)
{
void *f = NULL;
void (*func)(const char *const __barejid);
void* f = NULL;
void (*func)(const char* const __barejid);
assert(plugin && plugin->module);
if (NULL == (f = dlsym(plugin->module, "prof_on_room_win_focus")))
return;
func = (void (*)(const char *const))f;
func = (void (*)(const char* const))f;
func(barejid);
}
void
c_plugin_destroy(ProfPlugin *plugin)
c_plugin_destroy(ProfPlugin* plugin)
{
assert (plugin && plugin->module);
assert(plugin && plugin->module);
callbacks_remove(plugin->name);
disco_remove_features(plugin->name);
if (dlclose (plugin->module)) {
log_warning ("dlclose failed to close `%s' with `%s'", plugin->name, dlerror ());
if (dlclose(plugin->module)) {
log_warning("dlclose failed to close `%s' with `%s'", plugin->name, dlerror());
}
free(plugin->name);
@@ -567,5 +567,4 @@ c_plugin_destroy(ProfPlugin *plugin)
void
c_shutdown(void)
{
}

View File

@@ -40,59 +40,59 @@
void c_env_init(void);
ProfPlugin* c_plugin_create(const char *const filename);
void c_plugin_destroy(ProfPlugin *plugin);
ProfPlugin* c_plugin_create(const char* const filename);
void c_plugin_destroy(ProfPlugin* plugin);
void c_shutdown(void);
void c_init_hook(ProfPlugin *plugin, const char *const version, const char *const status, const char *const account_name,
const char *const fulljid);
void c_init_hook(ProfPlugin* plugin, const char* const version, const char* const status, const char* const account_name,
const char* const fulljid);
gboolean c_contains_hook(ProfPlugin *plugin, const char *const hook);
gboolean c_contains_hook(ProfPlugin* plugin, const char* const hook);
void c_on_start_hook(ProfPlugin *plugin);
void c_on_shutdown_hook(ProfPlugin *plugin);
void c_on_unload_hook(ProfPlugin *plugin);
void c_on_connect_hook(ProfPlugin *plugin, const char *const account_name, const char *const fulljid);
void c_on_disconnect_hook(ProfPlugin *plugin, const char *const account_name, const char *const fulljid);
void c_on_start_hook(ProfPlugin* plugin);
void c_on_shutdown_hook(ProfPlugin* plugin);
void c_on_unload_hook(ProfPlugin* plugin);
void c_on_connect_hook(ProfPlugin* plugin, const char* const account_name, const char* const fulljid);
void c_on_disconnect_hook(ProfPlugin* plugin, const char* const account_name, const char* const fulljid);
char* c_pre_chat_message_display_hook(ProfPlugin *plugin, const char *const barejid, const char *const resource, const char *message);
void c_post_chat_message_display_hook(ProfPlugin *plugin, const char *const barejid, const char *const resource, const char *message);
char* c_pre_chat_message_send_hook(ProfPlugin *plugin, const char *const barejid, const char *message);
void c_post_chat_message_send_hook(ProfPlugin *plugin, const char *const barejid, const char *message);
char* c_pre_chat_message_display_hook(ProfPlugin* plugin, const char* const barejid, const char* const resource, const char* message);
void c_post_chat_message_display_hook(ProfPlugin* plugin, const char* const barejid, const char* const resource, const char* message);
char* c_pre_chat_message_send_hook(ProfPlugin* plugin, const char* const barejid, const char* message);
void c_post_chat_message_send_hook(ProfPlugin* plugin, const char* const barejid, const char* message);
char* c_pre_room_message_display_hook(ProfPlugin *plugin, const char *const barejid, const char *const nick,
const char *message);
void c_post_room_message_display_hook(ProfPlugin *plugin, const char *const barejid, const char *const nick,
const char *message);
char* c_pre_room_message_send_hook(ProfPlugin *plugin, const char *const barejid, const char *message);
void c_post_room_message_send_hook(ProfPlugin *plugin, const char *const barejid, const char *message);
void c_on_room_history_message_hook(ProfPlugin *plugin, const char *const barejid, const char *const nick,
const char *const message, const char *const timestamp);
char* c_pre_room_message_display_hook(ProfPlugin* plugin, const char* const barejid, const char* const nick,
const char* message);
void c_post_room_message_display_hook(ProfPlugin* plugin, const char* const barejid, const char* const nick,
const char* message);
char* c_pre_room_message_send_hook(ProfPlugin* plugin, const char* const barejid, const char* message);
void c_post_room_message_send_hook(ProfPlugin* plugin, const char* const barejid, const char* message);
void c_on_room_history_message_hook(ProfPlugin* plugin, const char* const barejid, const char* const nick,
const char* const message, const char* const timestamp);
char* c_pre_priv_message_display_hook(ProfPlugin *plugin, const char *const barejid, const char *const nick,
const char *message);
void c_post_priv_message_display_hook(ProfPlugin *plugin, const char *const barejid, const char *const nick,
const char *message);
char* c_pre_priv_message_send_hook(ProfPlugin *plugin, const char *const barejid, const char *const nick,
const char *const message);
void c_post_priv_message_send_hook(ProfPlugin *plugin, const char *const barejid, const char *const nick,
const char * const message);
char* c_pre_priv_message_display_hook(ProfPlugin* plugin, const char* const barejid, const char* const nick,
const char* message);
void c_post_priv_message_display_hook(ProfPlugin* plugin, const char* const barejid, const char* const nick,
const char* message);
char* c_pre_priv_message_send_hook(ProfPlugin* plugin, const char* const barejid, const char* const nick,
const char* const message);
void c_post_priv_message_send_hook(ProfPlugin* plugin, const char* const barejid, const char* const nick,
const char* const message);
char* c_on_message_stanza_send_hook(ProfPlugin *plugin, const char *const text);
gboolean c_on_message_stanza_receive_hook(ProfPlugin *plugin, const char *const text);
char* c_on_message_stanza_send_hook(ProfPlugin* plugin, const char* const text);
gboolean c_on_message_stanza_receive_hook(ProfPlugin* plugin, const char* const text);
char* c_on_presence_stanza_send_hook(ProfPlugin *plugin, const char *const text);
gboolean c_on_presence_stanza_receive_hook(ProfPlugin *plugin, const char *const text);
char* c_on_presence_stanza_send_hook(ProfPlugin* plugin, const char* const text);
gboolean c_on_presence_stanza_receive_hook(ProfPlugin* plugin, const char* const text);
char* c_on_iq_stanza_send_hook(ProfPlugin *plugin, const char *const text);
gboolean c_on_iq_stanza_receive_hook(ProfPlugin *plugin, const char *const text);
char* c_on_iq_stanza_send_hook(ProfPlugin* plugin, const char* const text);
gboolean c_on_iq_stanza_receive_hook(ProfPlugin* plugin, const char* const text);
void c_on_contact_offline_hook(ProfPlugin *plugin, const char *const barejid, const char *const resource,
const char *const status);
void c_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);
void c_on_contact_offline_hook(ProfPlugin* plugin, const char* const barejid, const char* const resource,
const char* const status);
void c_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);
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 barejid);
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 barejid);
#endif

View File

@@ -45,12 +45,12 @@
#include "ui/ui.h"
#include "ui/window_list.h"
static GHashTable *p_commands = NULL;
static GHashTable *p_timed_functions = NULL;
static GHashTable *p_window_callbacks = NULL;
static GHashTable* p_commands = NULL;
static GHashTable* p_timed_functions = NULL;
static GHashTable* p_window_callbacks = NULL;
static void
_free_window_callback(PluginWindowCallback *window_callback)
_free_window_callback(PluginWindowCallback* window_callback)
{
if (window_callback->callback_destroy) {
window_callback->callback_destroy(window_callback->callback);
@@ -59,13 +59,13 @@ _free_window_callback(PluginWindowCallback *window_callback)
}
static void
_free_window_callbacks(GHashTable *window_callbacks)
_free_window_callbacks(GHashTable* window_callbacks)
{
g_hash_table_destroy(window_callbacks);
}
static void
_free_command_help(CommandHelp *help)
_free_command_help(CommandHelp* help)
{
int i = 0;
while (help->tags[i] != NULL) {
@@ -95,7 +95,7 @@ _free_command_help(CommandHelp *help)
}
static void
_free_command(PluginCommand *command)
_free_command(PluginCommand* command)
{
if (command->callback_destroy) {
command->callback_destroy(command->callback);
@@ -108,13 +108,13 @@ _free_command(PluginCommand *command)
}
static void
_free_command_hash(GHashTable *command_hash)
_free_command_hash(GHashTable* command_hash)
{
g_hash_table_destroy(command_hash);
}
static void
_free_timed_function(PluginTimedFunction *timed_function)
_free_timed_function(PluginTimedFunction* timed_function)
{
if (timed_function->callback_destroy) {
timed_function->callback_destroy(timed_function->callback);
@@ -126,7 +126,7 @@ _free_timed_function(PluginTimedFunction *timed_function)
}
static void
_free_timed_function_list(GList *timed_functions)
_free_timed_function_list(GList* timed_functions)
{
g_list_free_full(timed_functions, (GDestroyNotify)_free_timed_function);
}
@@ -140,14 +140,14 @@ callbacks_init(void)
}
void
callbacks_remove(const char *const plugin_name)
callbacks_remove(const char* const plugin_name)
{
GHashTable *command_hash = g_hash_table_lookup(p_commands, plugin_name);
GHashTable* command_hash = g_hash_table_lookup(p_commands, plugin_name);
if (command_hash) {
GList *commands = g_hash_table_get_keys(command_hash);
GList *curr = commands;
GList* commands = g_hash_table_get_keys(command_hash);
GList* curr = commands;
while (curr) {
char *command = curr->data;
char* command = curr->data;
cmd_ac_remove(command);
cmd_ac_remove_help(&command[1]);
curr = g_list_next(curr);
@@ -158,10 +158,10 @@ callbacks_remove(const char *const plugin_name)
g_hash_table_remove(p_commands, plugin_name);
g_hash_table_remove(p_timed_functions, plugin_name);
GHashTable *tag_to_win_cb_hash = g_hash_table_lookup(p_window_callbacks, plugin_name);
GHashTable* tag_to_win_cb_hash = g_hash_table_lookup(p_window_callbacks, plugin_name);
if (tag_to_win_cb_hash) {
GList *tags = g_hash_table_get_keys(tag_to_win_cb_hash);
GList *curr = tags;
GList* tags = g_hash_table_get_keys(tag_to_win_cb_hash);
GList* curr = tags;
while (curr) {
wins_close_plugin(curr->data);
curr = g_list_next(curr);
@@ -181,9 +181,9 @@ callbacks_close(void)
}
void
callbacks_add_command(const char *const plugin_name, PluginCommand *command)
callbacks_add_command(const char* const plugin_name, PluginCommand* command)
{
GHashTable *command_hash = g_hash_table_lookup(p_commands, plugin_name);
GHashTable* command_hash = g_hash_table_lookup(p_commands, plugin_name);
if (command_hash) {
g_hash_table_insert(command_hash, strdup(command->command_name), command);
} else {
@@ -196,9 +196,9 @@ callbacks_add_command(const char *const plugin_name, PluginCommand *command)
}
void
callbacks_add_timed(const char *const plugin_name, PluginTimedFunction *timed_function)
callbacks_add_timed(const char* const plugin_name, PluginTimedFunction* timed_function)
{
GList *timed_function_list = g_hash_table_lookup(p_timed_functions, plugin_name);
GList* timed_function_list = g_hash_table_lookup(p_timed_functions, plugin_name);
if (timed_function_list) {
// we assign this so we dont get: -Werror=unused-result
timed_function_list = g_list_append(timed_function_list, timed_function);
@@ -209,11 +209,11 @@ callbacks_add_timed(const char *const plugin_name, PluginTimedFunction *timed_fu
}
gboolean
callbacks_win_exists(const char *const plugin_name, const char *tag)
callbacks_win_exists(const char* const plugin_name, const char* tag)
{
GHashTable *window_callbacks = g_hash_table_lookup(p_window_callbacks, plugin_name);
GHashTable* window_callbacks = g_hash_table_lookup(p_window_callbacks, plugin_name);
if (window_callbacks) {
PluginWindowCallback *cb = g_hash_table_lookup(window_callbacks, tag);
PluginWindowCallback* cb = g_hash_table_lookup(window_callbacks, tag);
if (cb) {
return TRUE;
}
@@ -223,18 +223,18 @@ callbacks_win_exists(const char *const plugin_name, const char *tag)
}
void
callbacks_remove_win(const char *const plugin_name, const char *const tag)
callbacks_remove_win(const char* const plugin_name, const char* const tag)
{
GHashTable *window_callbacks = g_hash_table_lookup(p_window_callbacks, plugin_name);
GHashTable* window_callbacks = g_hash_table_lookup(p_window_callbacks, plugin_name);
if (window_callbacks) {
g_hash_table_remove(window_callbacks, tag);
}
}
void
callbacks_add_window_handler(const char *const plugin_name, const char *tag, PluginWindowCallback *window_callback)
callbacks_add_window_handler(const char* const plugin_name, const char* tag, PluginWindowCallback* window_callback)
{
GHashTable *window_callbacks = g_hash_table_lookup(p_window_callbacks, plugin_name);
GHashTable* window_callbacks = g_hash_table_lookup(p_window_callbacks, plugin_name);
if (window_callbacks) {
g_hash_table_insert(window_callbacks, strdup(tag), window_callback);
} else {
@@ -244,15 +244,15 @@ callbacks_add_window_handler(const char *const plugin_name, const char *tag, Plu
}
}
void *
callbacks_get_window_handler(const char *tag)
void*
callbacks_get_window_handler(const char* tag)
{
if (p_window_callbacks) {
GList *window_callback_hashes = g_hash_table_get_values(p_window_callbacks);
GList *curr_hash = window_callback_hashes;
GList* window_callback_hashes = g_hash_table_get_values(p_window_callbacks);
GList* curr_hash = window_callback_hashes;
while (curr_hash) {
GHashTable *window_callback_hash = curr_hash->data;
PluginWindowCallback *callback = g_hash_table_lookup(window_callback_hash, tag);
GHashTable* window_callback_hash = curr_hash->data;
PluginWindowCallback* callback = g_hash_table_lookup(window_callback_hash, tag);
if (callback) {
g_list_free(window_callback_hashes);
return callback;
@@ -269,19 +269,19 @@ callbacks_get_window_handler(const char *tag)
}
gboolean
plugins_run_command(const char * const input)
plugins_run_command(const char* const input)
{
gchar **split = g_strsplit(input, " ", -1);
gchar** split = g_strsplit(input, " ", -1);
GList *command_hashes = g_hash_table_get_values(p_commands);
GList *curr_hash = command_hashes;
GList* command_hashes = g_hash_table_get_values(p_commands);
GList* curr_hash = command_hashes;
while (curr_hash) {
GHashTable *command_hash = curr_hash->data;
GHashTable* command_hash = curr_hash->data;
PluginCommand *command = g_hash_table_lookup(command_hash, split[0]);
PluginCommand* command = g_hash_table_lookup(command_hash, split[0]);
if (command) {
gboolean result;
gchar **args = parse_args_with_freetext(input, command->min_args, command->max_args, &result);
gchar** args = parse_args_with_freetext(input, command->min_args, command->max_args, &result);
if (result == FALSE) {
ui_invalid_command_usage(command->command_name, NULL);
g_strfreev(split);
@@ -305,14 +305,14 @@ plugins_run_command(const char * const input)
}
CommandHelp*
plugins_get_help(const char *const cmd)
plugins_get_help(const char* const cmd)
{
GList *command_hashes = g_hash_table_get_values(p_commands);
GList *curr_hash = command_hashes;
GList* command_hashes = g_hash_table_get_values(p_commands);
GList* curr_hash = command_hashes;
while (curr_hash) {
GHashTable *command_hash = curr_hash->data;
GHashTable* command_hash = curr_hash->data;
PluginCommand *command = g_hash_table_lookup(command_hash, cmd);
PluginCommand* command = g_hash_table_lookup(command_hash, cmd);
if (command) {
g_list_free(command_hashes);
return command->help;
@@ -329,14 +329,14 @@ plugins_get_help(const char *const cmd)
void
plugins_run_timed(void)
{
GList *timed_functions_lists = g_hash_table_get_values(p_timed_functions);
GList* timed_functions_lists = g_hash_table_get_values(p_timed_functions);
GList *curr_list = timed_functions_lists;
GList* curr_list = timed_functions_lists;
while (curr_list) {
GList *timed_function_list = curr_list->data;
GList *curr = timed_function_list;
GList* timed_function_list = curr_list->data;
GList* curr = timed_function_list;
while (curr) {
PluginTimedFunction *timed_function = curr->data;
PluginTimedFunction* timed_function = curr->data;
gdouble elapsed = g_timer_elapsed(timed_function->timer, NULL);
@@ -356,16 +356,16 @@ plugins_run_timed(void)
GList*
plugins_get_command_names(void)
{
GList *result = NULL;
GList* result = NULL;
GList *command_hashes = g_hash_table_get_values(p_commands);
GList *curr_hash = command_hashes;
GList* command_hashes = g_hash_table_get_values(p_commands);
GList* curr_hash = command_hashes;
while (curr_hash) {
GHashTable *command_hash = curr_hash->data;
GList *commands = g_hash_table_get_keys(command_hash);
GList *curr = commands;
GHashTable* command_hash = curr_hash->data;
GList* commands = g_hash_table_get_keys(command_hash);
GList* curr = commands;
while (curr) {
char *command = curr->data;
char* command = curr->data;
result = g_list_append(result, command);
curr = g_list_next(curr);
}

View File

@@ -40,39 +40,42 @@
#include "command/cmd_defs.h"
typedef struct p_command {
char *command_name;
typedef struct p_command
{
char* command_name;
int min_args;
int max_args;
CommandHelp *help;
void *callback;
void (*callback_exec)(struct p_command *command, gchar **args);
void (*callback_destroy)(void *callback);
CommandHelp* help;
void* callback;
void (*callback_exec)(struct p_command* command, gchar** args);
void (*callback_destroy)(void* callback);
} PluginCommand;
typedef struct p_timed_function {
void *callback;
void (*callback_exec)(struct p_timed_function *timed_function);
void (*callback_destroy)(void *callback);
typedef struct p_timed_function
{
void* callback;
void (*callback_exec)(struct p_timed_function* timed_function);
void (*callback_destroy)(void* callback);
int interval_seconds;
GTimer *timer;
GTimer* timer;
} PluginTimedFunction;
typedef struct p_window_input_callback {
void *callback;
void (*callback_exec)(struct p_window_input_callback *window_callback, const char *tag, const char * const line);
void (*callback_destroy)(void *callback);
typedef struct p_window_input_callback
{
void* callback;
void (*callback_exec)(struct p_window_input_callback* window_callback, const char* tag, const char* const line);
void (*callback_destroy)(void* callback);
} PluginWindowCallback;
void callbacks_init(void);
void callbacks_remove(const char *const plugin_name);
void callbacks_remove(const char* const plugin_name);
void callbacks_close(void);
void callbacks_add_command(const char *const plugin_name, PluginCommand *command);
void callbacks_add_timed(const char *const plugin_name, PluginTimedFunction *timed_function);
gboolean callbacks_win_exists(const char *const plugin_name, const char *tag);
void callbacks_add_window_handler(const char *const plugin_name, const char *tag, PluginWindowCallback *window_callback);
void * callbacks_get_window_handler(const char *tag);
void callbacks_remove_win(const char *const plugin_name, const char *const tag);
void callbacks_add_command(const char* const plugin_name, PluginCommand* command);
void callbacks_add_timed(const char* const plugin_name, PluginTimedFunction* timed_function);
gboolean callbacks_win_exists(const char* const plugin_name, const char* tag);
void callbacks_add_window_handler(const char* const plugin_name, const char* tag, PluginWindowCallback* window_callback);
void* callbacks_get_window_handler(const char* tag);
void callbacks_remove_win(const char* const plugin_name, const char* const tag);
#endif

View File

@@ -39,19 +39,19 @@
#include <glib.h>
// features to reference count map
static GHashTable *features = NULL;
static GHashTable* features = NULL;
// plugin to feature map
static GHashTable *plugin_to_features = NULL;
static GHashTable* plugin_to_features = NULL;
static void
_free_features(GHashTable *features)
_free_features(GHashTable* features)
{
g_hash_table_destroy(features);
}
void
disco_add_feature(const char *plugin_name, char *feature)
disco_add_feature(const char* plugin_name, char* feature)
{
if (feature == NULL || plugin_name == NULL) {
return;
@@ -64,7 +64,7 @@ disco_add_feature(const char *plugin_name, char *feature)
plugin_to_features = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)_free_features);
}
GHashTable *plugin_features = g_hash_table_lookup(plugin_to_features, plugin_name);
GHashTable* plugin_features = g_hash_table_lookup(plugin_to_features, plugin_name);
gboolean added = FALSE;
if (plugin_features == NULL) {
plugin_features = g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL);
@@ -83,7 +83,7 @@ disco_add_feature(const char *plugin_name, char *feature)
if (!g_hash_table_contains(features, feature)) {
g_hash_table_insert(features, strdup(feature), GINT_TO_POINTER(1));
} else {
void *refcountp = g_hash_table_lookup(features, feature);
void* refcountp = g_hash_table_lookup(features, feature);
int refcount = GPOINTER_TO_INT(refcountp);
refcount++;
g_hash_table_replace(features, strdup(feature), GINT_TO_POINTER(refcount));
@@ -91,7 +91,7 @@ disco_add_feature(const char *plugin_name, char *feature)
}
void
disco_remove_features(const char *plugin_name)
disco_remove_features(const char* plugin_name)
{
if (!features) {
return;
@@ -100,17 +100,17 @@ disco_remove_features(const char *plugin_name)
return;
}
GHashTable *plugin_features_set = g_hash_table_lookup(plugin_to_features, plugin_name);
GHashTable* plugin_features_set = g_hash_table_lookup(plugin_to_features, plugin_name);
if (!plugin_features_set) {
return;
}
GList *plugin_feature_list = g_hash_table_get_keys(plugin_features_set);
GList *curr = plugin_feature_list;
GList* plugin_feature_list = g_hash_table_get_keys(plugin_features_set);
GList* curr = plugin_feature_list;
while (curr) {
char *feature = curr->data;
char* feature = curr->data;
if (g_hash_table_contains(features, feature)) {
void *refcountp = g_hash_table_lookup(features, feature);
void* refcountp = g_hash_table_lookup(features, feature);
int refcount = GPOINTER_TO_INT(refcountp);
if (refcount == 1) {
g_hash_table_remove(features, feature);
@@ -123,7 +123,6 @@ disco_remove_features(const char *plugin_name)
curr = g_list_next(curr);
}
g_list_free(plugin_feature_list);
}
GList*

View File

@@ -38,10 +38,9 @@
#include <glib.h>
void disco_add_feature(const char* plugin_name, char *feature);
void disco_remove_features(const char *plugin_name);
void disco_add_feature(const char* plugin_name, char* feature);
void disco_remove_features(const char* plugin_name);
GList* disco_get_features(void);
void disco_close(void);
#endif

View File

@@ -63,7 +63,7 @@
#include "plugins/c_api.h"
#endif
static GHashTable *plugins;
static GHashTable* plugins;
void
plugins_init(void)
@@ -82,16 +82,15 @@ plugins_init(void)
#endif
// load plugins
gchar **plugins_pref = prefs_get_plugins();
gchar** plugins_pref = prefs_get_plugins();
if (plugins_pref) {
int i;
for (i = 0; i < g_strv_length(plugins_pref); i++)
{
for (i = 0; i < g_strv_length(plugins_pref); i++) {
gboolean loaded = FALSE;
gchar *filename = plugins_pref[i];
gchar* filename = plugins_pref[i];
#ifdef HAVE_PYTHON
if (g_str_has_suffix(filename, ".py")) {
ProfPlugin *plugin = python_plugin_create(filename);
ProfPlugin* plugin = python_plugin_create(filename);
if (plugin) {
g_hash_table_insert(plugins, strdup(filename), plugin);
loaded = TRUE;
@@ -100,7 +99,7 @@ plugins_init(void)
#endif
#ifdef HAVE_C
if (g_str_has_suffix(filename, ".so")) {
ProfPlugin *plugin = c_plugin_create(filename);
ProfPlugin* plugin = c_plugin_create(filename);
if (plugin) {
g_hash_table_insert(plugins, strdup(filename), plugin);
loaded = TRUE;
@@ -115,15 +114,14 @@ plugins_init(void)
}
// initialise plugins
GList *values = g_hash_table_get_values(plugins);
GList *curr = values;
GList* values = g_hash_table_get_values(plugins);
GList* curr = values;
while (curr) {
ProfPlugin *plugin = curr->data;
ProfPlugin* plugin = curr->data;
plugin->init_func(plugin, PACKAGE_VERSION, PACKAGE_STATUS, NULL, NULL);
curr = g_list_next(curr);
}
g_list_free(values);
}
prefs_free_plugins(plugins_pref);
@@ -132,7 +130,7 @@ plugins_init(void)
}
void
plugins_free_install_result(PluginsInstallResult *result)
plugins_free_install_result(PluginsInstallResult* result)
{
if (!result) {
return;
@@ -142,20 +140,20 @@ plugins_free_install_result(PluginsInstallResult *result)
}
PluginsInstallResult*
plugins_install_all(const char *const path)
plugins_install_all(const char* const path)
{
PluginsInstallResult *result = malloc(sizeof(PluginsInstallResult));
PluginsInstallResult* result = malloc(sizeof(PluginsInstallResult));
result->installed = NULL;
result->failed = NULL;
GSList *contents = NULL;
GSList* contents = NULL;
get_file_paths_recursive(path, &contents);
GSList *curr = contents;
GString *error_message = NULL;
GSList* curr = contents;
GString* error_message = NULL;
while (curr) {
error_message = g_string_new(NULL);
if (g_str_has_suffix(curr->data, ".py") || g_str_has_suffix(curr->data, ".so")) {
gchar *plugin_name = g_path_get_basename(curr->data);
gchar* plugin_name = g_path_get_basename(curr->data);
if (plugins_install(plugin_name, curr->data, error_message)) {
result->installed = g_slist_append(result->installed, strdup(curr->data));
} else {
@@ -172,16 +170,16 @@ plugins_install_all(const char *const path)
}
gboolean
plugins_uninstall(const char *const plugin_name)
plugins_uninstall(const char* const plugin_name)
{
plugins_unload(plugin_name);
char *plugins_dir = files_get_data_path(DIR_PLUGINS);
GString *target_path = g_string_new(plugins_dir);
char* plugins_dir = files_get_data_path(DIR_PLUGINS);
GString* target_path = g_string_new(plugins_dir);
free(plugins_dir);
g_string_append(target_path, "/");
g_string_append(target_path, plugin_name);
GFile *file = g_file_new_for_path(target_path->str);
GError *error = NULL;
GFile* file = g_file_new_for_path(target_path->str);
GError* error = NULL;
gboolean result = g_file_delete(file, NULL, &error);
g_object_unref(file);
g_error_free(error);
@@ -190,16 +188,15 @@ plugins_uninstall(const char *const plugin_name)
}
gboolean
plugins_install(const char *const plugin_name, const char *const filename, GString *error_message)
plugins_install(const char* const plugin_name, const char* const filename, GString* error_message)
{
char *plugins_dir = files_get_data_path(DIR_PLUGINS);
GString *target_path = g_string_new(plugins_dir);
char* plugins_dir = files_get_data_path(DIR_PLUGINS);
GString* target_path = g_string_new(plugins_dir);
free(plugins_dir);
g_string_append(target_path, "/");
g_string_append(target_path, plugin_name);
if (g_file_test (target_path->str, G_FILE_TEST_EXISTS))
{
if (g_file_test(target_path->str, G_FILE_TEST_EXISTS)) {
log_info("Failed to install plugin: %s, file exists", plugin_name);
g_string_assign(error_message, "File exists");
return FALSE;
@@ -217,10 +214,10 @@ plugins_install(const char *const plugin_name, const char *const filename, GStri
GSList*
plugins_load_all(void)
{
GSList *plugins = plugins_unloaded_list();
GSList *loaded = NULL;
GSList *curr = plugins;
GString *error_message = NULL;
GSList* plugins = plugins_unloaded_list();
GSList* loaded = NULL;
GSList* curr = plugins;
GString* error_message = NULL;
while (curr) {
error_message = g_string_new(NULL);
if (plugins_load(curr->data, error_message)) {
@@ -235,9 +232,9 @@ plugins_load_all(void)
}
gboolean
plugins_load(const char *const name, GString *error_message)
plugins_load(const char* const name, GString* error_message)
{
ProfPlugin *plugin = g_hash_table_lookup(plugins, name);
ProfPlugin* plugin = g_hash_table_lookup(plugins, name);
if (plugin) {
log_info("Failed to load plugin: %s, plugin already loaded", name);
return FALSE;
@@ -261,8 +258,8 @@ plugins_load(const char *const name, GString *error_message)
if (plugin) {
g_hash_table_insert(plugins, strdup(name), plugin);
if (connection_get_status() == JABBER_CONNECTED) {
const char *account_name = session_get_account_name();
const char *fulljid = connection_get_fulljid();
const char* account_name = session_get_account_name();
const char* fulljid = connection_get_fulljid();
plugin->init_func(plugin, PACKAGE_VERSION, PACKAGE_STATUS, account_name, fulljid);
} else {
plugin->init_func(plugin, PACKAGE_VERSION, PACKAGE_STATUS, NULL, NULL);
@@ -280,9 +277,9 @@ gboolean
plugins_unload_all(void)
{
gboolean result = TRUE;
GList *plugin_names = g_hash_table_get_keys(plugins);
GList *plugin_names_dup = NULL;
GList *curr = plugin_names;
GList* plugin_names = g_hash_table_get_keys(plugins);
GList* plugin_names_dup = NULL;
GList* curr = plugin_names;
while (curr) {
plugin_names_dup = g_list_append(plugin_names_dup, strdup(curr->data));
curr = g_list_next(curr);
@@ -303,9 +300,9 @@ plugins_unload_all(void)
}
gboolean
plugins_unload(const char *const name)
plugins_unload(const char* const name)
{
ProfPlugin *plugin = g_hash_table_lookup(plugins, name);
ProfPlugin* plugin = g_hash_table_lookup(plugins, name);
if (plugin) {
plugin->on_unload_func(plugin);
#ifdef HAVE_PYTHON
@@ -336,16 +333,16 @@ plugins_unload(const char *const name)
void
plugins_reload_all(void)
{
GList *plugin_names = g_hash_table_get_keys(plugins);
GList *plugin_names_dup = NULL;
GList *curr = plugin_names;
GList* plugin_names = g_hash_table_get_keys(plugins);
GList* plugin_names_dup = NULL;
GList* curr = plugin_names;
while (curr) {
plugin_names_dup = g_list_append(plugin_names_dup, strdup(curr->data));
curr = g_list_next(curr);
}
g_list_free(plugin_names);
GString *error_message = NULL;
GString* error_message = NULL;
curr = plugin_names_dup;
while (curr) {
error_message = g_string_new(NULL);
@@ -358,7 +355,7 @@ plugins_reload_all(void)
}
gboolean
plugins_reload(const char *const name, GString *error_message)
plugins_reload(const char* const name, GString* error_message)
{
gboolean res = plugins_unload(name);
if (res) {
@@ -369,16 +366,16 @@ plugins_reload(const char *const name, GString *error_message)
}
void
_plugins_unloaded_list_dir(const gchar *const dir, GSList **result)
_plugins_unloaded_list_dir(const gchar* const dir, GSList** result)
{
GDir *plugins_dir = g_dir_open(dir, 0, NULL);
GDir* plugins_dir = g_dir_open(dir, 0, NULL);
if (plugins_dir == NULL) {
return;
}
const gchar *plugin = g_dir_read_name(plugins_dir);
const gchar* plugin = g_dir_read_name(plugins_dir);
while (plugin) {
ProfPlugin *found = g_hash_table_lookup(plugins, plugin);
ProfPlugin* found = g_hash_table_lookup(plugins, plugin);
if ((g_str_has_suffix(plugin, ".so") || g_str_has_suffix(plugin, ".py")) && !found) {
*result = g_slist_append(*result, strdup(plugin));
}
@@ -390,8 +387,8 @@ _plugins_unloaded_list_dir(const gchar *const dir, GSList **result)
GSList*
plugins_unloaded_list(void)
{
GSList *result = NULL;
char *plugins_dir = files_get_data_path(DIR_PLUGINS);
GSList* result = NULL;
char* plugins_dir = files_get_data_path(DIR_PLUGINS);
_plugins_unloaded_list_dir(plugins_dir, &result);
free(plugins_dir);
@@ -404,8 +401,8 @@ plugins_loaded_list(void)
return g_hash_table_get_keys(plugins);
}
char *
plugins_autocomplete(const char * const input, gboolean previous)
char*
plugins_autocomplete(const char* const input, gboolean previous)
{
return autocompleters_complete(input, previous);
}
@@ -417,16 +414,16 @@ plugins_reset_autocomplete(void)
}
void
plugins_win_process_line(char *win, const char * const line)
plugins_win_process_line(char* win, const char* const line)
{
PluginWindowCallback *window = callbacks_get_window_handler(win);
PluginWindowCallback* window = callbacks_get_window_handler(win);
if (window) {
window->callback_exec(window, win, line);
}
}
void
plugins_close_win(const char *const plugin_name, const char *const tag)
plugins_close_win(const char* const plugin_name, const char* const tag)
{
callbacks_remove_win(plugin_name, tag);
}
@@ -434,10 +431,10 @@ plugins_close_win(const char *const plugin_name, const char *const tag)
void
plugins_on_start(void)
{
GList *values = g_hash_table_get_values(plugins);
GList *curr = values;
GList* values = g_hash_table_get_values(plugins);
GList* curr = values;
while (curr) {
ProfPlugin *plugin = curr->data;
ProfPlugin* plugin = curr->data;
plugin->on_start_func(plugin);
curr = g_list_next(curr);
}
@@ -447,10 +444,10 @@ plugins_on_start(void)
void
plugins_on_shutdown(void)
{
GList *values = g_hash_table_get_values(plugins);
GList *curr = values;
GList* values = g_hash_table_get_values(plugins);
GList* curr = values;
while (curr) {
ProfPlugin *plugin = curr->data;
ProfPlugin* plugin = curr->data;
plugin->on_shutdown_func(plugin);
curr = g_list_next(curr);
}
@@ -458,12 +455,12 @@ plugins_on_shutdown(void)
}
void
plugins_on_connect(const char * const account_name, const char * const fulljid)
plugins_on_connect(const char* const account_name, const char* const fulljid)
{
GList *values = g_hash_table_get_values(plugins);
GList *curr = values;
GList* values = g_hash_table_get_values(plugins);
GList* curr = values;
while (curr) {
ProfPlugin *plugin = curr->data;
ProfPlugin* plugin = curr->data;
plugin->on_connect_func(plugin, account_name, fulljid);
curr = g_list_next(curr);
}
@@ -471,12 +468,12 @@ plugins_on_connect(const char * const account_name, const char * const fulljid)
}
void
plugins_on_disconnect(const char * const account_name, const char * const fulljid)
plugins_on_disconnect(const char* const account_name, const char* const fulljid)
{
GList *values = g_hash_table_get_values(plugins);
GList *curr = values;
GList* values = g_hash_table_get_values(plugins);
GList* curr = values;
while (curr) {
ProfPlugin *plugin = curr->data;
ProfPlugin* plugin = curr->data;
plugin->on_disconnect_func(plugin, account_name, fulljid);
curr = g_list_next(curr);
}
@@ -484,15 +481,15 @@ plugins_on_disconnect(const char * const account_name, const char * const fullji
}
char*
plugins_pre_chat_message_display(const char * const barejid, const char *const resource, const char *message)
plugins_pre_chat_message_display(const char* const barejid, const char* const resource, const char* message)
{
char *new_message = NULL;
char *curr_message = strdup(message);
char* new_message = NULL;
char* curr_message = strdup(message);
GList *values = g_hash_table_get_values(plugins);
GList *curr = values;
GList* values = g_hash_table_get_values(plugins);
GList* curr = values;
while (curr) {
ProfPlugin *plugin = curr->data;
ProfPlugin* plugin = curr->data;
new_message = plugin->pre_chat_message_display(plugin, barejid, resource, curr_message);
if (new_message) {
free(curr_message);
@@ -507,12 +504,12 @@ plugins_pre_chat_message_display(const char * const barejid, const char *const r
}
void
plugins_post_chat_message_display(const char * const barejid, const char *const resource, const char *message)
plugins_post_chat_message_display(const char* const barejid, const char* const resource, const char* message)
{
GList *values = g_hash_table_get_values(plugins);
GList *curr = values;
GList* values = g_hash_table_get_values(plugins);
GList* curr = values;
while (curr) {
ProfPlugin *plugin = curr->data;
ProfPlugin* plugin = curr->data;
plugin->post_chat_message_display(plugin, barejid, resource, message);
curr = g_list_next(curr);
}
@@ -520,15 +517,15 @@ plugins_post_chat_message_display(const char * const barejid, const char *const
}
char*
plugins_pre_chat_message_send(const char * const barejid, const char *message)
plugins_pre_chat_message_send(const char* const barejid, const char* message)
{
char *new_message = NULL;
char *curr_message = strdup(message);
char* new_message = NULL;
char* curr_message = strdup(message);
GList *values = g_hash_table_get_values(plugins);
GList *curr = values;
GList* values = g_hash_table_get_values(plugins);
GList* curr = values;
while (curr) {
ProfPlugin *plugin = curr->data;
ProfPlugin* plugin = curr->data;
if (plugin->contains_hook(plugin, "prof_pre_chat_message_send")) {
new_message = plugin->pre_chat_message_send(plugin, barejid, curr_message);
if (new_message) {
@@ -550,12 +547,12 @@ plugins_pre_chat_message_send(const char * const barejid, const char *message)
}
void
plugins_post_chat_message_send(const char * const barejid, const char *message)
plugins_post_chat_message_send(const char* const barejid, const char* message)
{
GList *values = g_hash_table_get_values(plugins);
GList *curr = values;
GList* values = g_hash_table_get_values(plugins);
GList* curr = values;
while (curr) {
ProfPlugin *plugin = curr->data;
ProfPlugin* plugin = curr->data;
plugin->post_chat_message_send(plugin, barejid, message);
curr = g_list_next(curr);
}
@@ -563,15 +560,15 @@ plugins_post_chat_message_send(const char * const barejid, const char *message)
}
char*
plugins_pre_room_message_display(const char * const barejid, const char * const nick, const char *message)
plugins_pre_room_message_display(const char* const barejid, const char* const nick, const char* message)
{
char *new_message = NULL;
char *curr_message = strdup(message);
char* new_message = NULL;
char* curr_message = strdup(message);
GList *values = g_hash_table_get_values(plugins);
GList *curr = values;
GList* values = g_hash_table_get_values(plugins);
GList* curr = values;
while (curr) {
ProfPlugin *plugin = curr->data;
ProfPlugin* plugin = curr->data;
new_message = plugin->pre_room_message_display(plugin, barejid, nick, curr_message);
if (new_message) {
free(curr_message);
@@ -586,12 +583,12 @@ plugins_pre_room_message_display(const char * const barejid, const char * const
}
void
plugins_post_room_message_display(const char * const barejid, const char * const nick, const char *message)
plugins_post_room_message_display(const char* const barejid, const char* const nick, const char* message)
{
GList *values = g_hash_table_get_values(plugins);
GList *curr = values;
GList* values = g_hash_table_get_values(plugins);
GList* curr = values;
while (curr) {
ProfPlugin *plugin = curr->data;
ProfPlugin* plugin = curr->data;
plugin->post_room_message_display(plugin, barejid, nick, message);
curr = g_list_next(curr);
}
@@ -599,15 +596,15 @@ plugins_post_room_message_display(const char * const barejid, const char * const
}
char*
plugins_pre_room_message_send(const char * const barejid, const char *message)
plugins_pre_room_message_send(const char* const barejid, const char* message)
{
char *new_message = NULL;
char *curr_message = strdup(message);
char* new_message = NULL;
char* curr_message = strdup(message);
GList *values = g_hash_table_get_values(plugins);
GList *curr = values;
GList* values = g_hash_table_get_values(plugins);
GList* curr = values;
while (curr) {
ProfPlugin *plugin = curr->data;
ProfPlugin* plugin = curr->data;
if (plugin->contains_hook(plugin, "prof_pre_room_message_send")) {
new_message = plugin->pre_room_message_send(plugin, barejid, curr_message);
if (new_message) {
@@ -629,12 +626,12 @@ plugins_pre_room_message_send(const char * const barejid, const char *message)
}
void
plugins_post_room_message_send(const char * const barejid, const char *message)
plugins_post_room_message_send(const char* const barejid, const char* message)
{
GList *values = g_hash_table_get_values(plugins);
GList *curr = values;
GList* values = g_hash_table_get_values(plugins);
GList* curr = values;
while (curr) {
ProfPlugin *plugin = curr->data;
ProfPlugin* plugin = curr->data;
plugin->post_room_message_send(plugin, barejid, message);
curr = g_list_next(curr);
}
@@ -642,20 +639,20 @@ plugins_post_room_message_send(const char * const barejid, const char *message)
}
void
plugins_on_room_history_message(const char *const barejid, const char *const nick, const char *const message,
GDateTime *timestamp)
plugins_on_room_history_message(const char* const barejid, const char* const nick, const char* const message,
GDateTime* timestamp)
{
char *timestamp_str = NULL;
char* timestamp_str = NULL;
GTimeVal timestamp_tv;
gboolean res = g_date_time_to_timeval(timestamp, &timestamp_tv);
if (res) {
timestamp_str = g_time_val_to_iso8601(&timestamp_tv);
}
GList *values = g_hash_table_get_values(plugins);
GList *curr = values;
GList* values = g_hash_table_get_values(plugins);
GList* curr = values;
while (curr) {
ProfPlugin *plugin = curr->data;
ProfPlugin* plugin = curr->data;
plugin->on_room_history_message(plugin, barejid, nick, message, timestamp_str);
curr = g_list_next(curr);
}
@@ -665,16 +662,16 @@ plugins_on_room_history_message(const char *const barejid, const char *const nic
}
char*
plugins_pre_priv_message_display(const char * const fulljid, const char *message)
plugins_pre_priv_message_display(const char* const fulljid, const char* message)
{
Jid *jidp = jid_create(fulljid);
char *new_message = NULL;
char *curr_message = strdup(message);
Jid* jidp = jid_create(fulljid);
char* new_message = NULL;
char* curr_message = strdup(message);
GList *values = g_hash_table_get_values(plugins);
GList *curr = values;
GList* values = g_hash_table_get_values(plugins);
GList* curr = values;
while (curr) {
ProfPlugin *plugin = curr->data;
ProfPlugin* plugin = curr->data;
new_message = plugin->pre_priv_message_display(plugin, jidp->barejid, jidp->resourcepart, curr_message);
if (new_message) {
free(curr_message);
@@ -690,14 +687,14 @@ plugins_pre_priv_message_display(const char * const fulljid, const char *message
}
void
plugins_post_priv_message_display(const char * const fulljid, const char *message)
plugins_post_priv_message_display(const char* const fulljid, const char* message)
{
Jid *jidp = jid_create(fulljid);
Jid* jidp = jid_create(fulljid);
GList *values = g_hash_table_get_values(plugins);
GList *curr = values;
GList* values = g_hash_table_get_values(plugins);
GList* curr = values;
while (curr) {
ProfPlugin *plugin = curr->data;
ProfPlugin* plugin = curr->data;
plugin->post_priv_message_display(plugin, jidp->barejid, jidp->resourcepart, message);
curr = g_list_next(curr);
}
@@ -707,16 +704,16 @@ plugins_post_priv_message_display(const char * const fulljid, const char *messag
}
char*
plugins_pre_priv_message_send(const char * const fulljid, const char * const message)
plugins_pre_priv_message_send(const char* const fulljid, const char* const message)
{
Jid *jidp = jid_create(fulljid);
char *new_message = NULL;
char *curr_message = strdup(message);
Jid* jidp = jid_create(fulljid);
char* new_message = NULL;
char* curr_message = strdup(message);
GList *values = g_hash_table_get_values(plugins);
GList *curr = values;
GList* values = g_hash_table_get_values(plugins);
GList* curr = values;
while (curr) {
ProfPlugin *plugin = curr->data;
ProfPlugin* plugin = curr->data;
if (plugin->contains_hook(plugin, "prof_pre_priv_message_send")) {
new_message = plugin->pre_priv_message_send(plugin, jidp->barejid, jidp->resourcepart, curr_message);
if (new_message) {
@@ -740,14 +737,14 @@ plugins_pre_priv_message_send(const char * const fulljid, const char * const mes
}
void
plugins_post_priv_message_send(const char * const fulljid, const char * const message)
plugins_post_priv_message_send(const char* const fulljid, const char* const message)
{
Jid *jidp = jid_create(fulljid);
Jid* jidp = jid_create(fulljid);
GList *values = g_hash_table_get_values(plugins);
GList *curr = values;
GList* values = g_hash_table_get_values(plugins);
GList* curr = values;
while (curr) {
ProfPlugin *plugin = curr->data;
ProfPlugin* plugin = curr->data;
plugin->post_priv_message_send(plugin, jidp->barejid, jidp->resourcepart, message);
curr = g_list_next(curr);
}
@@ -757,15 +754,15 @@ plugins_post_priv_message_send(const char * const fulljid, const char * const me
}
char*
plugins_on_message_stanza_send(const char *const text)
plugins_on_message_stanza_send(const char* const text)
{
char *new_stanza = NULL;
char *curr_stanza = strdup(text);
char* new_stanza = NULL;
char* curr_stanza = strdup(text);
GList *values = g_hash_table_get_values(plugins);
GList *curr = values;
GList* values = g_hash_table_get_values(plugins);
GList* curr = values;
while (curr) {
ProfPlugin *plugin = curr->data;
ProfPlugin* plugin = curr->data;
new_stanza = plugin->on_message_stanza_send(plugin, curr_stanza);
if (new_stanza) {
free(curr_stanza);
@@ -780,14 +777,14 @@ plugins_on_message_stanza_send(const char *const text)
}
gboolean
plugins_on_message_stanza_receive(const char *const text)
plugins_on_message_stanza_receive(const char* const text)
{
gboolean cont = TRUE;
GList *values = g_hash_table_get_values(plugins);
GList *curr = values;
GList* values = g_hash_table_get_values(plugins);
GList* curr = values;
while (curr) {
ProfPlugin *plugin = curr->data;
ProfPlugin* plugin = curr->data;
gboolean res = plugin->on_message_stanza_receive(plugin, text);
if (res == FALSE) {
cont = FALSE;
@@ -800,15 +797,15 @@ plugins_on_message_stanza_receive(const char *const text)
}
char*
plugins_on_presence_stanza_send(const char *const text)
plugins_on_presence_stanza_send(const char* const text)
{
char *new_stanza = NULL;
char *curr_stanza = strdup(text);
char* new_stanza = NULL;
char* curr_stanza = strdup(text);
GList *values = g_hash_table_get_values(plugins);
GList *curr = values;
GList* values = g_hash_table_get_values(plugins);
GList* curr = values;
while (curr) {
ProfPlugin *plugin = curr->data;
ProfPlugin* plugin = curr->data;
new_stanza = plugin->on_presence_stanza_send(plugin, curr_stanza);
if (new_stanza) {
free(curr_stanza);
@@ -823,14 +820,14 @@ plugins_on_presence_stanza_send(const char *const text)
}
gboolean
plugins_on_presence_stanza_receive(const char *const text)
plugins_on_presence_stanza_receive(const char* const text)
{
gboolean cont = TRUE;
GList *values = g_hash_table_get_values(plugins);
GList *curr = values;
GList* values = g_hash_table_get_values(plugins);
GList* curr = values;
while (curr) {
ProfPlugin *plugin = curr->data;
ProfPlugin* plugin = curr->data;
gboolean res = plugin->on_presence_stanza_receive(plugin, text);
if (res == FALSE) {
cont = FALSE;
@@ -843,15 +840,15 @@ plugins_on_presence_stanza_receive(const char *const text)
}
char*
plugins_on_iq_stanza_send(const char *const text)
plugins_on_iq_stanza_send(const char* const text)
{
char *new_stanza = NULL;
char *curr_stanza = strdup(text);
char* new_stanza = NULL;
char* curr_stanza = strdup(text);
GList *values = g_hash_table_get_values(plugins);
GList *curr = values;
GList* values = g_hash_table_get_values(plugins);
GList* curr = values;
while (curr) {
ProfPlugin *plugin = curr->data;
ProfPlugin* plugin = curr->data;
new_stanza = plugin->on_iq_stanza_send(plugin, curr_stanza);
if (new_stanza) {
free(curr_stanza);
@@ -866,14 +863,14 @@ plugins_on_iq_stanza_send(const char *const text)
}
gboolean
plugins_on_iq_stanza_receive(const char *const text)
plugins_on_iq_stanza_receive(const char* const text)
{
gboolean cont = TRUE;
GList *values = g_hash_table_get_values(plugins);
GList *curr = values;
GList* values = g_hash_table_get_values(plugins);
GList* curr = values;
while (curr) {
ProfPlugin *plugin = curr->data;
ProfPlugin* plugin = curr->data;
gboolean res = plugin->on_iq_stanza_receive(plugin, text);
if (res == FALSE) {
cont = FALSE;
@@ -886,12 +883,12 @@ plugins_on_iq_stanza_receive(const char *const text)
}
void
plugins_on_contact_offline(const char *const barejid, const char *const resource, const char *const status)
plugins_on_contact_offline(const char* const barejid, const char* const resource, const char* const status)
{
GList *values = g_hash_table_get_values(plugins);
GList *curr = values;
GList* values = g_hash_table_get_values(plugins);
GList* curr = values;
while (curr) {
ProfPlugin *plugin = curr->data;
ProfPlugin* plugin = curr->data;
plugin->on_contact_offline(plugin, barejid, resource, status);
curr = g_list_next(curr);
}
@@ -899,12 +896,12 @@ plugins_on_contact_offline(const char *const barejid, const char *const resource
}
void
plugins_on_contact_presence(const char *const barejid, const char *const resource, const char *const presence, const char *const status, const int priority)
plugins_on_contact_presence(const char* const barejid, const char* const resource, const char* const presence, const char* const status, const int priority)
{
GList *values = g_hash_table_get_values(plugins);
GList *curr = values;
GList* values = g_hash_table_get_values(plugins);
GList* curr = values;
while (curr) {
ProfPlugin *plugin = curr->data;
ProfPlugin* plugin = curr->data;
plugin->on_contact_presence(plugin, barejid, resource, presence, status, priority);
curr = g_list_next(curr);
}
@@ -912,12 +909,12 @@ plugins_on_contact_presence(const char *const barejid, const char *const resourc
}
void
plugins_on_chat_win_focus(const char *const barejid)
plugins_on_chat_win_focus(const char* const barejid)
{
GList *values = g_hash_table_get_values(plugins);
GList *curr = values;
GList* values = g_hash_table_get_values(plugins);
GList* curr = values;
while (curr) {
ProfPlugin *plugin = curr->data;
ProfPlugin* plugin = curr->data;
plugin->on_chat_win_focus(plugin, barejid);
curr = g_list_next(curr);
}
@@ -925,12 +922,12 @@ plugins_on_chat_win_focus(const char *const barejid)
}
void
plugins_on_room_win_focus(const char *const barejid)
plugins_on_room_win_focus(const char* const barejid)
{
GList *values = g_hash_table_get_values(plugins);
GList *curr = values;
GList* values = g_hash_table_get_values(plugins);
GList* curr = values;
while (curr) {
ProfPlugin *plugin = curr->data;
ProfPlugin* plugin = curr->data;
plugin->on_room_win_focus(plugin, barejid);
curr = g_list_next(curr);
}
@@ -946,17 +943,17 @@ plugins_get_disco_features(void)
void
plugins_shutdown(void)
{
GList *values = g_hash_table_get_values(plugins);
GList *curr = values;
GList* values = g_hash_table_get_values(plugins);
GList* curr = values;
while (curr) {
#ifdef HAVE_PYTHON
if (((ProfPlugin *)curr->data)->lang == LANG_PYTHON) {
if (((ProfPlugin*)curr->data)->lang == LANG_PYTHON) {
python_plugin_destroy(curr->data);
}
#endif
#ifdef HAVE_C
if (((ProfPlugin *)curr->data)->lang == LANG_C) {
if (((ProfPlugin*)curr->data)->lang == LANG_C) {
c_plugin_destroy(curr->data);
}
#endif

View File

@@ -43,136 +43,138 @@ typedef enum {
LANG_C
} lang_t;
typedef struct prof_plugins_install_t {
GSList *installed;
GSList *failed;
typedef struct prof_plugins_install_t
{
GSList* installed;
GSList* failed;
} PluginsInstallResult;
typedef struct prof_plugin_t {
char *name;
typedef struct prof_plugin_t
{
char* name;
lang_t lang;
void *module;
void (*init_func)(struct prof_plugin_t* plugin, const char * const version,
const char * const status, const char *const account_name, const char *const fulljid);
void* module;
void (*init_func)(struct prof_plugin_t* plugin, const char* const version,
const char* const status, const char* const account_name, const char* const fulljid);
gboolean (*contains_hook)(struct prof_plugin_t* plugin, const char *const hook);
gboolean (*contains_hook)(struct prof_plugin_t* plugin, const char* const hook);
void (*on_start_func)(struct prof_plugin_t* plugin);
void (*on_shutdown_func)(struct prof_plugin_t* plugin);
void (*on_unload_func)(struct prof_plugin_t* plugin);
void (*on_connect_func)(struct prof_plugin_t* plugin, const char *const account_name, const char *const fulljid);
void (*on_disconnect_func)(struct prof_plugin_t* plugin, const char *const account_name,
const char *const fulljid);
void (*on_connect_func)(struct prof_plugin_t* plugin, const char* const account_name, const char* const fulljid);
void (*on_disconnect_func)(struct prof_plugin_t* plugin, const char* const account_name,
const char* const fulljid);
char* (*pre_chat_message_display)(struct prof_plugin_t* plugin, const char *const barejid, const char *const resource, const char *message);
void (*post_chat_message_display)(struct prof_plugin_t* plugin, const char *const barejid, const char *const resource, const char *message);
char* (*pre_chat_message_send)(struct prof_plugin_t* plugin, const char *const barejid, const char *message);
void (*post_chat_message_send)(struct prof_plugin_t* plugin, const char *const barejid, const char *message);
char* (*pre_chat_message_display)(struct prof_plugin_t* plugin, const char* const barejid, const char* const resource, const char* message);
void (*post_chat_message_display)(struct prof_plugin_t* plugin, const char* const barejid, const char* const resource, const char* message);
char* (*pre_chat_message_send)(struct prof_plugin_t* plugin, const char* const barejid, const char* message);
void (*post_chat_message_send)(struct prof_plugin_t* plugin, const char* const barejid, const char* message);
char* (*pre_room_message_display)(struct prof_plugin_t* plugin, const char *const barejid, const char *const nick,
const char *message);
void (*post_room_message_display)(struct prof_plugin_t* plugin, const char *const barejid, const char *const nick,
const char *message);
char* (*pre_room_message_send)(struct prof_plugin_t* plugin, const char *const barejid, const char *message);
void (*post_room_message_send)(struct prof_plugin_t* plugin, const char *const barejid, const char *message);
void (*on_room_history_message)(struct prof_plugin_t* plugin, const char *const barejid, const char *const nick, const char *const message,
const char *const timestamp);
char* (*pre_room_message_display)(struct prof_plugin_t* plugin, const char* const barejid, const char* const nick,
const char* message);
void (*post_room_message_display)(struct prof_plugin_t* plugin, const char* const barejid, const char* const nick,
const char* message);
char* (*pre_room_message_send)(struct prof_plugin_t* plugin, const char* const barejid, const char* message);
void (*post_room_message_send)(struct prof_plugin_t* plugin, const char* const barejid, const char* message);
void (*on_room_history_message)(struct prof_plugin_t* plugin, const char* const barejid, const char* const nick, const char* const message,
const char* const timestamp);
char* (*pre_priv_message_display)(struct prof_plugin_t* plugin, const char *const barejid, const char *const nick,
const char *message);
void (*post_priv_message_display)(struct prof_plugin_t* plugin, const char *const barejid, const char *const nick,
const char *message);
char* (*pre_priv_message_send)(struct prof_plugin_t* plugin, const char *const barejid, const char *const nick,
const char *const message);
void (*post_priv_message_send)(struct prof_plugin_t* plugin, const char *const barejid, const char *const nick,
const char *const message);
char* (*pre_priv_message_display)(struct prof_plugin_t* plugin, const char* const barejid, const char* const nick,
const char* message);
void (*post_priv_message_display)(struct prof_plugin_t* plugin, const char* const barejid, const char* const nick,
const char* message);
char* (*pre_priv_message_send)(struct prof_plugin_t* plugin, const char* const barejid, const char* const nick,
const char* const message);
void (*post_priv_message_send)(struct prof_plugin_t* plugin, const char* const barejid, const char* const nick,
const char* const message);
char* (*on_message_stanza_send)(struct prof_plugin_t* plugin, const char *const text);
gboolean (*on_message_stanza_receive)(struct prof_plugin_t* plugin, const char *const text);
char* (*on_message_stanza_send)(struct prof_plugin_t* plugin, const char* const text);
gboolean (*on_message_stanza_receive)(struct prof_plugin_t* plugin, const char* const text);
char* (*on_presence_stanza_send)(struct prof_plugin_t* plugin, const char *const text);
gboolean (*on_presence_stanza_receive)(struct prof_plugin_t* plugin, const char *const text);
char* (*on_presence_stanza_send)(struct prof_plugin_t* plugin, const char* const text);
gboolean (*on_presence_stanza_receive)(struct prof_plugin_t* plugin, const char* const text);
char* (*on_iq_stanza_send)(struct prof_plugin_t* plugin, const char *const text);
gboolean (*on_iq_stanza_receive)(struct prof_plugin_t* plugin, const char *const text);
char* (*on_iq_stanza_send)(struct prof_plugin_t* plugin, const char* const text);
gboolean (*on_iq_stanza_receive)(struct prof_plugin_t* plugin, const char* const text);
void (*on_contact_offline)(struct prof_plugin_t* plugin, const char *const barejid, const char *const resource,
const char *const status);
void (*on_contact_presence)(struct prof_plugin_t* plugin, const char *const barejid, const char *const resource,
const char *const presence, const char *const status, const int priority);
void (*on_contact_offline)(struct prof_plugin_t* plugin, const char* const barejid, const char* const resource,
const char* const status);
void (*on_contact_presence)(struct prof_plugin_t* plugin, const char* const barejid, const char* const resource,
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 barejid);
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 barejid);
} ProfPlugin;
void plugins_init(void);
GSList *plugins_unloaded_list(void);
GList *plugins_loaded_list(void);
char* plugins_autocomplete(const char *const input, gboolean previous);
GSList* plugins_unloaded_list(void);
GList* plugins_loaded_list(void);
char* plugins_autocomplete(const char* const input, gboolean previous);
void plugins_reset_autocomplete(void);
void plugins_shutdown(void);
void plugins_free_install_result(PluginsInstallResult *result);
void plugins_free_install_result(PluginsInstallResult* result);
gboolean plugins_install(const char *const plugin_name, const char *const filename, GString * error_message);
gboolean plugins_uninstall(const char *const plugin_name);
gboolean plugins_update(const char *const plugin_name, const char *const filename, GString * error_message);
PluginsInstallResult* plugins_install_all(const char *const path);
gboolean plugins_load(const char *const name, GString *error_message);
gboolean plugins_install(const char* const plugin_name, const char* const filename, GString* error_message);
gboolean plugins_uninstall(const char* const plugin_name);
gboolean plugins_update(const char* const plugin_name, const char* const filename, GString* error_message);
PluginsInstallResult* plugins_install_all(const char* const path);
gboolean plugins_load(const char* const name, GString* error_message);
GSList* plugins_load_all(void);
gboolean plugins_unload(const char *const name);
gboolean plugins_unload(const char* const name);
gboolean plugins_unload_all(void);
gboolean plugins_reload(const char *const name, GString *error_message);
gboolean plugins_reload(const char* const name, GString* error_message);
void plugins_reload_all(void);
void plugins_on_start(void);
void plugins_on_shutdown(void);
void plugins_on_connect(const char *const account_name, const char *const fulljid);
void plugins_on_disconnect(const char *const account_name, const char *const fulljid);
void plugins_on_connect(const char* const account_name, const char* const fulljid);
void plugins_on_disconnect(const char* const account_name, const char* const fulljid);
char* plugins_pre_chat_message_display(const char *const barejid, const char *const resource, const char *message);
void plugins_post_chat_message_display(const char *const barejid, const char *const resource, const char *message);
char* plugins_pre_chat_message_send(const char *const barejid, const char *message);
void plugins_post_chat_message_send(const char *const barejid, const char *message);
char* plugins_pre_chat_message_display(const char* const barejid, const char* const resource, const char* message);
void plugins_post_chat_message_display(const char* const barejid, const char* const resource, const char* message);
char* plugins_pre_chat_message_send(const char* const barejid, const char* message);
void plugins_post_chat_message_send(const char* const barejid, const char* message);
char* plugins_pre_room_message_display(const char *const barejid, const char *const nick, const char *message);
void plugins_post_room_message_display(const char *const barejid, const char *const nick, const char *message);
char* plugins_pre_room_message_send(const char *const barejid, const char *message);
void plugins_post_room_message_send(const char *const barejid, const char *message);
void plugins_on_room_history_message(const char *const barejid, const char *const nick, const char *const message,
GDateTime *timestamp);
char* plugins_pre_room_message_display(const char* const barejid, const char* const nick, const char* message);
void plugins_post_room_message_display(const char* const barejid, const char* const nick, const char* message);
char* plugins_pre_room_message_send(const char* const barejid, const char* message);
void plugins_post_room_message_send(const char* const barejid, const char* message);
void plugins_on_room_history_message(const char* const barejid, const char* const nick, const char* const message,
GDateTime* timestamp);
char* plugins_pre_priv_message_display(const char *const fulljid, const char *message);
void plugins_post_priv_message_display(const char *const fulljid, const char *message);
char* plugins_pre_priv_message_send(const char *const fulljid, const char *const message);
void plugins_post_priv_message_send(const char *const fulljid, const char *const message);
char* plugins_pre_priv_message_display(const char* const fulljid, const char* message);
void plugins_post_priv_message_display(const char* const fulljid, const char* message);
char* plugins_pre_priv_message_send(const char* const fulljid, const char* const message);
void plugins_post_priv_message_send(const char* const fulljid, const char* const message);
void plugins_win_process_line(char *win, const char *const line);
void plugins_close_win(const char *const plugin_name, const char *const tag);
void plugins_win_process_line(char* win, const char* const line);
void plugins_close_win(const char* const plugin_name, const char* const tag);
char* plugins_on_message_stanza_send(const char *const text);
gboolean plugins_on_message_stanza_receive(const char *const text);
char* plugins_on_message_stanza_send(const char* const text);
gboolean plugins_on_message_stanza_receive(const char* const text);
char* plugins_on_presence_stanza_send(const char *const text);
gboolean plugins_on_presence_stanza_receive(const char *const text);
char* plugins_on_presence_stanza_send(const char* const text);
gboolean plugins_on_presence_stanza_receive(const char* const text);
char* plugins_on_iq_stanza_send(const char *const text);
gboolean plugins_on_iq_stanza_receive(const char *const text);
char* plugins_on_iq_stanza_send(const char* const text);
gboolean plugins_on_iq_stanza_receive(const char* const text);
void plugins_on_contact_offline(const char *const barejid, const char *const resource, const char *const status);
void plugins_on_contact_presence(const char *const barejid, const char *const resource, const char *const presence,
const char *const status, const int priority);
void plugins_on_contact_offline(const char* const barejid, const char* const resource, const char* const status);
void plugins_on_contact_presence(const char* const barejid, const char* const resource, const char* const presence,
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 barejid);
void plugins_on_chat_win_focus(const char* const barejid);
void plugins_on_room_win_focus(const char* const barejid);
gboolean plugins_run_command(const char * const cmd);
gboolean plugins_run_command(const char* const cmd);
void plugins_run_timed(void);
GList* plugins_get_command_names(void);
gchar * plugins_get_dir(void);
CommandHelp* plugins_get_help(const char *const cmd);
gchar* plugins_get_dir(void);
CommandHelp* plugins_get_help(const char* const cmd);
GList* plugins_get_disco_features(void);

File diff suppressed because it is too large Load Diff

View File

@@ -40,10 +40,10 @@ void python_env_init(void);
void python_init_prof(void);
void python_shutdown(void);
void python_command_callback(PluginCommand *command, gchar **args);
void python_timed_callback(PluginTimedFunction *timed_function);
void python_window_callback(PluginWindowCallback *window_callback, char *tag, char *line);
void python_command_callback(PluginCommand* command, gchar** args);
void python_timed_callback(PluginTimedFunction* timed_function);
void python_window_callback(PluginWindowCallback* window_callback, char* tag, char* line);
char* python_str_or_unicode_to_string(void *obj);
char* python_str_or_unicode_to_string(void* obj);
#endif

View File

@@ -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,19 +228,18 @@ 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();
@@ -254,12 +253,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();
@@ -273,13 +272,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();
@@ -294,13 +293,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();
@@ -315,19 +314,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);
@@ -340,13 +339,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();
@@ -361,18 +360,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);
@@ -385,13 +384,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();
@@ -406,18 +405,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);
@@ -430,14 +429,14 @@ python_pre_room_message_display_hook(ProfPlugin *plugin, const char * const bare
}
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();
@@ -452,18 +451,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);
@@ -476,13 +475,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();
@@ -497,14 +496,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();
@@ -519,19 +518,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);
@@ -544,14 +543,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();
@@ -566,19 +565,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);
@@ -591,14 +590,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();
@@ -613,18 +612,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);
@@ -637,18 +636,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);
@@ -661,18 +660,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);
@@ -685,18 +684,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);
@@ -709,18 +708,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);
@@ -733,18 +732,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);
@@ -757,14 +756,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();
@@ -779,14 +778,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();
@@ -801,13 +800,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();
@@ -822,13 +821,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();
@@ -853,7 +852,7 @@ python_check_error(void)
}
void
python_plugin_destroy(ProfPlugin *plugin)
python_plugin_destroy(ProfPlugin* plugin)
{
disable_python_threads();
callbacks_remove(plugin->name);
@@ -872,10 +871,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);
@@ -887,10 +886,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);
@@ -902,7 +901,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();
@@ -922,13 +921,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();

View File

@@ -38,8 +38,8 @@
#include "plugins/plugins.h"
ProfPlugin* python_plugin_create(const char *const filename);
void python_plugin_destroy(ProfPlugin *plugin);
ProfPlugin* python_plugin_create(const char* const filename);
void python_plugin_destroy(ProfPlugin* plugin);
void python_check_error(void);
void allow_python_threads();
void disable_python_threads();
@@ -47,53 +47,53 @@ void disable_python_threads();
const char* python_get_version_string(void);
gchar* python_get_version_number(void);
void python_init_hook(ProfPlugin *plugin, const char *const version, const char *const status,
const char *const account_name, const char *const fulljid);
void python_init_hook(ProfPlugin* plugin, const char* const version, const char* const status,
const char* const account_name, const char* const fulljid);
gboolean python_contains_hook(ProfPlugin *plugin, const char *const hook);
gboolean python_contains_hook(ProfPlugin* plugin, const char* const hook);
void python_on_start_hook(ProfPlugin *plugin);
void python_on_shutdown_hook(ProfPlugin *plugin);
void python_on_unload_hook(ProfPlugin *plugin);
void python_on_connect_hook(ProfPlugin *plugin, const char *const account_name, const char *const fulljid);
void python_on_disconnect_hook(ProfPlugin *plugin, const char *const account_name, const char *const fulljid);
void python_on_start_hook(ProfPlugin* plugin);
void python_on_shutdown_hook(ProfPlugin* plugin);
void python_on_unload_hook(ProfPlugin* plugin);
void python_on_connect_hook(ProfPlugin* plugin, const char* const account_name, const char* const fulljid);
void python_on_disconnect_hook(ProfPlugin* plugin, const char* const account_name, const char* const fulljid);
char* python_pre_chat_message_display_hook(ProfPlugin *plugin, const char *const barejid, const char *const resource, const char *message);
void python_post_chat_message_display_hook(ProfPlugin *plugin, const char *const barejid, const char *const resource, const char *message);
char* python_pre_chat_message_send_hook(ProfPlugin *plugin, const char *const barejid, const char *message);
void python_post_chat_message_send_hook(ProfPlugin *plugin, const char *const barejid, const char *message);
char* python_pre_chat_message_display_hook(ProfPlugin* plugin, const char* const barejid, const char* const resource, const char* message);
void python_post_chat_message_display_hook(ProfPlugin* plugin, const char* const barejid, const char* const resource, const char* message);
char* python_pre_chat_message_send_hook(ProfPlugin* plugin, const char* const barejid, const char* message);
void python_post_chat_message_send_hook(ProfPlugin* plugin, const char* const barejid, const char* message);
char* python_pre_room_message_display_hook(ProfPlugin *plugin, const char *const barejid, const char *const nick,
const char *message);
void python_post_room_message_display_hook(ProfPlugin *plugin, const char *const barejid, const char *const nick,
const char *message);
char* python_pre_room_message_send_hook(ProfPlugin *plugin, const char *const barejid, const char *message);
void python_post_room_message_send_hook(ProfPlugin *plugin, const char *const barejid, const char *message);
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);
char* python_pre_room_message_display_hook(ProfPlugin* plugin, const char* const barejid, const char* const nick,
const char* message);
void python_post_room_message_display_hook(ProfPlugin* plugin, const char* const barejid, const char* const nick,
const char* message);
char* python_pre_room_message_send_hook(ProfPlugin* plugin, const char* const barejid, const char* message);
void python_post_room_message_send_hook(ProfPlugin* plugin, const char* const barejid, const char* message);
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);
char* python_pre_priv_message_display_hook(ProfPlugin *plugin, const char *const barejid, const char *const nick,
const char *message);
void python_post_priv_message_display_hook(ProfPlugin *plugin, const char *const barejid, const char *const nick,
const char *message);
char* python_pre_priv_message_send_hook(ProfPlugin *plugin, const char *const barejid, const char *const nick,
const char *const message);
void python_post_priv_message_send_hook(ProfPlugin *plugin, const char *const barejid, const char *const nick,
const char *const message);
char* python_pre_priv_message_display_hook(ProfPlugin* plugin, const char* const barejid, const char* const nick,
const char* message);
void python_post_priv_message_display_hook(ProfPlugin* plugin, const char* const barejid, const char* const nick,
const char* message);
char* python_pre_priv_message_send_hook(ProfPlugin* plugin, const char* const barejid, const char* const nick,
const char* const message);
void python_post_priv_message_send_hook(ProfPlugin* plugin, const char* const barejid, const char* const nick,
const char* const message);
char* 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);
char* 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);
char* 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);
char* 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);
char* 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);
char* 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);
void python_on_contact_offline_hook(ProfPlugin *plugin, const char *const barejid, const char *const resource,
const char *const status);
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);
void python_on_contact_offline_hook(ProfPlugin* plugin, const char* const barejid, const char* const resource,
const char* const status);
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);
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 barejid);
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 barejid);
#endif

View File

@@ -44,14 +44,14 @@
#include "config/files.h"
#include "config/conflists.h"
static GKeyFile *settings;
static GKeyFile* settings;
static void _save_settings(void);
void
plugin_settings_init(void)
{
char *settings_file = files_get_data_path(FILE_PLUGIN_SETTINGS);
char* settings_file = files_get_data_path(FILE_PLUGIN_SETTINGS);
if (g_file_test(settings_file, G_FILE_TEST_EXISTS)) {
g_chmod(settings_file, S_IRUSR | S_IWUSR);
@@ -61,7 +61,7 @@ plugin_settings_init(void)
g_key_file_load_from_file(settings, settings_file, G_KEY_FILE_KEEP_COMMENTS, NULL);
gsize g_data_size;
gchar *g_data = g_key_file_to_data(settings, &g_data_size, NULL);
gchar* g_data = g_key_file_to_data(settings, &g_data_size, NULL);
g_file_set_contents(settings_file, g_data, g_data_size, NULL);
g_chmod(settings_file, S_IRUSR | S_IWUSR);
g_free(g_data);
@@ -76,7 +76,7 @@ plugin_settings_close(void)
}
gboolean
plugin_settings_boolean_get(const char *const group, const char *const key, gboolean def)
plugin_settings_boolean_get(const char* const group, const char* const key, gboolean def)
{
if (group && key && g_key_file_has_key(settings, group, key, NULL)) {
return g_key_file_get_boolean(settings, group, key, NULL);
@@ -86,14 +86,14 @@ plugin_settings_boolean_get(const char *const group, const char *const key, gboo
}
void
plugin_settings_boolean_set(const char *const group, const char *const key, gboolean value)
plugin_settings_boolean_set(const char* const group, const char* const key, gboolean value)
{
g_key_file_set_boolean(settings, group, key, value);
_save_settings();
}
char*
plugin_settings_string_get(const char *const group, const char *const key, const char *const def)
plugin_settings_string_get(const char* const group, const char* const key, const char* const def)
{
if (group && key && g_key_file_has_key(settings, group, key, NULL)) {
return g_key_file_get_string(settings, group, key, NULL);
@@ -105,14 +105,14 @@ plugin_settings_string_get(const char *const group, const char *const key, const
}
void
plugin_settings_string_set(const char *const group, const char *const key, const char *const value)
plugin_settings_string_set(const char* const group, const char* const key, const char* const value)
{
g_key_file_set_string(settings, group, key, value);
_save_settings();
}
int
plugin_settings_int_get(const char *const group, const char *const key, int def)
plugin_settings_int_get(const char* const group, const char* const key, int def)
{
if (group && key && g_key_file_has_key(settings, group, key, NULL)) {
return g_key_file_get_integer(settings, group, key, NULL);
@@ -122,14 +122,14 @@ plugin_settings_int_get(const char *const group, const char *const key, int def)
}
void
plugin_settings_int_set(const char *const group, const char *const key, int value)
plugin_settings_int_set(const char* const group, const char* const key, int value)
{
g_key_file_set_integer(settings, group, key, value);
_save_settings();
}
gchar**
plugin_settings_string_list_get(const char *const group, const char *const key)
plugin_settings_string_list_get(const char* const group, const char* const key)
{
if (!g_key_file_has_key(settings, group, key, NULL)) {
return NULL;
@@ -139,7 +139,7 @@ plugin_settings_string_list_get(const char *const group, const char *const key)
}
int
plugin_settings_string_list_add(const char *const group, const char *const key, const char *const value)
plugin_settings_string_list_add(const char* const group, const char* const key, const char* const value)
{
int res = conf_string_list_add(settings, group, key, value);
_save_settings();
@@ -148,7 +148,7 @@ plugin_settings_string_list_add(const char *const group, const char *const key,
}
int
plugin_settings_string_list_remove(const char *const group, const char *const key, const char *const value)
plugin_settings_string_list_remove(const char* const group, const char* const key, const char* const value)
{
int res = conf_string_list_remove(settings, group, key, value);
_save_settings();
@@ -157,7 +157,7 @@ plugin_settings_string_list_remove(const char *const group, const char *const ke
}
int
plugin_settings_string_list_clear(const char *const group, const char *const key)
plugin_settings_string_list_clear(const char* const group, const char* const key)
{
if (!g_key_file_has_key(settings, group, key, NULL)) {
return 0;
@@ -173,11 +173,11 @@ static void
_save_settings(void)
{
gsize g_data_size;
gchar *g_data = g_key_file_to_data(settings, &g_data_size, NULL);
gchar* g_data = g_key_file_to_data(settings, &g_data_size, NULL);
char *fileloc = files_get_data_path(FILE_PLUGIN_SETTINGS);
gchar *base = g_path_get_dirname(fileloc);
gchar *true_loc = get_file_or_linked(fileloc, base);
char* fileloc = files_get_data_path(FILE_PLUGIN_SETTINGS);
gchar* base = g_path_get_dirname(fileloc);
gchar* true_loc = get_file_or_linked(fileloc, base);
g_free(base);
g_file_set_contents(true_loc, g_data, g_data_size, NULL);
free(true_loc);

View File

@@ -39,15 +39,15 @@
void plugin_settings_init(void);
void plugin_settings_close(void);
gboolean plugin_settings_boolean_get(const char *const group, const char *const key, gboolean def);
void plugin_settings_boolean_set(const char *const group, const char *const key, gboolean value);
char* plugin_settings_string_get(const char *const group, const char *const key, const char *const def);
void plugin_settings_string_set(const char *const group, const char *const key, const char *const value);
int plugin_settings_int_get(const char *const group, const char *const key, int def);
void plugin_settings_int_set(const char *const group, const char *const key, int value);
char** plugin_settings_string_list_get(const char *const group, const char *const key);
void plugin_settings_string_list_add(const char *const group, const char *const key, const char *const value);
int plugin_settings_string_list_remove(const char *const group, const char *const key, const char *const value);
int plugin_settings_string_list_clear(const char *const group, const char *const key);
gboolean plugin_settings_boolean_get(const char* const group, const char* const key, gboolean def);
void plugin_settings_boolean_set(const char* const group, const char* const key, gboolean value);
char* plugin_settings_string_get(const char* const group, const char* const key, const char* const def);
void plugin_settings_string_set(const char* const group, const char* const key, const char* const value);
int plugin_settings_int_get(const char* const group, const char* const key, int def);
void plugin_settings_int_set(const char* const group, const char* const key, int value);
char** plugin_settings_string_list_get(const char* const group, const char* const key);
void plugin_settings_string_list_add(const char* const group, const char* const key, const char* const value);
int plugin_settings_string_list_remove(const char* const group, const char* const key, const char* const value);
int plugin_settings_string_list_clear(const char* const group, const char* const key);
#endif

View File

@@ -42,12 +42,12 @@
#include "config/theme.h"
#include "config/files.h"
static GKeyFile *themes;
static GKeyFile* themes;
void
plugin_themes_init(void)
{
char *themes_file = files_get_data_path(FILE_PLUGIN_THEMES);
char* themes_file = files_get_data_path(FILE_PLUGIN_THEMES);
if (g_file_test(themes_file, G_FILE_TEST_EXISTS)) {
g_chmod(themes_file, S_IRUSR | S_IWUSR);
@@ -57,7 +57,7 @@ plugin_themes_init(void)
g_key_file_load_from_file(themes, themes_file, G_KEY_FILE_KEEP_COMMENTS, NULL);
gsize g_data_size;
gchar *g_data = g_key_file_to_data(themes, &g_data_size, NULL);
gchar* g_data = g_key_file_to_data(themes, &g_data_size, NULL);
g_file_set_contents(themes_file, g_data, g_data_size, NULL);
g_chmod(themes_file, S_IRUSR | S_IWUSR);
g_free(g_data);
@@ -72,71 +72,121 @@ plugin_themes_close(void)
}
theme_item_t
plugin_themes_get(const char *const group, const char *const key, const char *const def)
plugin_themes_get(const char* const group, const char* const key, const char* const def)
{
if (group && key && g_key_file_has_key(themes, group, key, NULL)) {
gchar *result = g_key_file_get_string(themes, group, key, NULL);
gchar* result = g_key_file_get_string(themes, group, key, NULL);
theme_item_t ret;
if (g_strcmp0(result, "white") == 0) ret = THEME_WHITE;
else if (g_strcmp0(result, "bold_white") == 0) ret = THEME_WHITE_BOLD;
else if (g_strcmp0(result, "red") == 0) ret = THEME_RED;
else if (g_strcmp0(result, "bold_red") == 0) ret = THEME_RED_BOLD;
else if (g_strcmp0(result, "green") == 0) ret = THEME_GREEN;
else if (g_strcmp0(result, "bold_green") == 0) ret = THEME_GREEN_BOLD;
else if (g_strcmp0(result, "blue") == 0) ret = THEME_BLUE;
else if (g_strcmp0(result, "bold_blue") == 0) ret = THEME_BLUE_BOLD;
else if (g_strcmp0(result, "yellow") == 0) ret = THEME_YELLOW;
else if (g_strcmp0(result, "bold_yellow") == 0) ret = THEME_YELLOW_BOLD;
else if (g_strcmp0(result, "cyan") == 0) ret = THEME_CYAN;
else if (g_strcmp0(result, "bold_cyan") == 0) ret = THEME_CYAN_BOLD;
else if (g_strcmp0(result, "magenta") == 0) ret = THEME_MAGENTA;
else if (g_strcmp0(result, "bold_magenta") == 0) ret = THEME_MAGENTA_BOLD;
else if (g_strcmp0(result, "black") == 0) ret = THEME_BLACK;
else if (g_strcmp0(result, "bold_black") == 0) ret = THEME_BLACK_BOLD;
if (g_strcmp0(result, "white") == 0)
ret = THEME_WHITE;
else if (g_strcmp0(result, "bold_white") == 0)
ret = THEME_WHITE_BOLD;
else if (g_strcmp0(result, "red") == 0)
ret = THEME_RED;
else if (g_strcmp0(result, "bold_red") == 0)
ret = THEME_RED_BOLD;
else if (g_strcmp0(result, "green") == 0)
ret = THEME_GREEN;
else if (g_strcmp0(result, "bold_green") == 0)
ret = THEME_GREEN_BOLD;
else if (g_strcmp0(result, "blue") == 0)
ret = THEME_BLUE;
else if (g_strcmp0(result, "bold_blue") == 0)
ret = THEME_BLUE_BOLD;
else if (g_strcmp0(result, "yellow") == 0)
ret = THEME_YELLOW;
else if (g_strcmp0(result, "bold_yellow") == 0)
ret = THEME_YELLOW_BOLD;
else if (g_strcmp0(result, "cyan") == 0)
ret = THEME_CYAN;
else if (g_strcmp0(result, "bold_cyan") == 0)
ret = THEME_CYAN_BOLD;
else if (g_strcmp0(result, "magenta") == 0)
ret = THEME_MAGENTA;
else if (g_strcmp0(result, "bold_magenta") == 0)
ret = THEME_MAGENTA_BOLD;
else if (g_strcmp0(result, "black") == 0)
ret = THEME_BLACK;
else if (g_strcmp0(result, "bold_black") == 0)
ret = THEME_BLACK_BOLD;
else if (g_strcmp0(def, "white") == 0) ret = THEME_WHITE;
else if (g_strcmp0(def, "bold_white") == 0) ret = THEME_WHITE_BOLD;
else if (g_strcmp0(def, "red") == 0) ret = THEME_RED;
else if (g_strcmp0(def, "bold_red") == 0) ret = THEME_RED_BOLD;
else if (g_strcmp0(def, "green") == 0) ret = THEME_GREEN;
else if (g_strcmp0(def, "bold_green") == 0) ret = THEME_GREEN_BOLD;
else if (g_strcmp0(def, "blue") == 0) ret = THEME_BLUE;
else if (g_strcmp0(def, "bold_blue") == 0) ret = THEME_BLUE_BOLD;
else if (g_strcmp0(def, "yellow") == 0) ret = THEME_YELLOW;
else if (g_strcmp0(def, "bold_yellow") == 0) ret = THEME_YELLOW_BOLD;
else if (g_strcmp0(def, "cyan") == 0) ret = THEME_CYAN;
else if (g_strcmp0(def, "bold_cyan") == 0) ret = THEME_CYAN_BOLD;
else if (g_strcmp0(def, "magenta") == 0) ret = THEME_MAGENTA;
else if (g_strcmp0(def, "bold_magenta") == 0) ret = THEME_MAGENTA_BOLD;
else if (g_strcmp0(def, "black") == 0) ret = THEME_BLACK;
else if (g_strcmp0(def, "bold_black") == 0) ret = THEME_BLACK_BOLD;
else if (g_strcmp0(def, "white") == 0)
ret = THEME_WHITE;
else if (g_strcmp0(def, "bold_white") == 0)
ret = THEME_WHITE_BOLD;
else if (g_strcmp0(def, "red") == 0)
ret = THEME_RED;
else if (g_strcmp0(def, "bold_red") == 0)
ret = THEME_RED_BOLD;
else if (g_strcmp0(def, "green") == 0)
ret = THEME_GREEN;
else if (g_strcmp0(def, "bold_green") == 0)
ret = THEME_GREEN_BOLD;
else if (g_strcmp0(def, "blue") == 0)
ret = THEME_BLUE;
else if (g_strcmp0(def, "bold_blue") == 0)
ret = THEME_BLUE_BOLD;
else if (g_strcmp0(def, "yellow") == 0)
ret = THEME_YELLOW;
else if (g_strcmp0(def, "bold_yellow") == 0)
ret = THEME_YELLOW_BOLD;
else if (g_strcmp0(def, "cyan") == 0)
ret = THEME_CYAN;
else if (g_strcmp0(def, "bold_cyan") == 0)
ret = THEME_CYAN_BOLD;
else if (g_strcmp0(def, "magenta") == 0)
ret = THEME_MAGENTA;
else if (g_strcmp0(def, "bold_magenta") == 0)
ret = THEME_MAGENTA_BOLD;
else if (g_strcmp0(def, "black") == 0)
ret = THEME_BLACK;
else if (g_strcmp0(def, "bold_black") == 0)
ret = THEME_BLACK_BOLD;
else ret = THEME_TEXT;
else
ret = THEME_TEXT;
g_free(result);
return ret;
} else {
if (g_strcmp0(def, "white") == 0) return THEME_WHITE;
else if (g_strcmp0(def, "bold_white") == 0) return THEME_WHITE_BOLD;
else if (g_strcmp0(def, "red") == 0) return THEME_RED;
else if (g_strcmp0(def, "bold_red") == 0) return THEME_RED_BOLD;
else if (g_strcmp0(def, "green") == 0) return THEME_GREEN;
else if (g_strcmp0(def, "bold_green") == 0) return THEME_GREEN_BOLD;
else if (g_strcmp0(def, "blue") == 0) return THEME_BLUE;
else if (g_strcmp0(def, "bold_blue") == 0) return THEME_BLUE_BOLD;
else if (g_strcmp0(def, "yellow") == 0) return THEME_YELLOW;
else if (g_strcmp0(def, "bold_yellow") == 0) return THEME_YELLOW_BOLD;
else if (g_strcmp0(def, "cyan") == 0) return THEME_CYAN;
else if (g_strcmp0(def, "bold_cyan") == 0) return THEME_CYAN_BOLD;
else if (g_strcmp0(def, "magenta") == 0) return THEME_MAGENTA;
else if (g_strcmp0(def, "bold_magenta") == 0) return THEME_MAGENTA_BOLD;
else if (g_strcmp0(def, "black") == 0) return THEME_BLACK;
else if (g_strcmp0(def, "bold_black") == 0) return THEME_BLACK_BOLD;
if (g_strcmp0(def, "white") == 0)
return THEME_WHITE;
else if (g_strcmp0(def, "bold_white") == 0)
return THEME_WHITE_BOLD;
else if (g_strcmp0(def, "red") == 0)
return THEME_RED;
else if (g_strcmp0(def, "bold_red") == 0)
return THEME_RED_BOLD;
else if (g_strcmp0(def, "green") == 0)
return THEME_GREEN;
else if (g_strcmp0(def, "bold_green") == 0)
return THEME_GREEN_BOLD;
else if (g_strcmp0(def, "blue") == 0)
return THEME_BLUE;
else if (g_strcmp0(def, "bold_blue") == 0)
return THEME_BLUE_BOLD;
else if (g_strcmp0(def, "yellow") == 0)
return THEME_YELLOW;
else if (g_strcmp0(def, "bold_yellow") == 0)
return THEME_YELLOW_BOLD;
else if (g_strcmp0(def, "cyan") == 0)
return THEME_CYAN;
else if (g_strcmp0(def, "bold_cyan") == 0)
return THEME_CYAN_BOLD;
else if (g_strcmp0(def, "magenta") == 0)
return THEME_MAGENTA;
else if (g_strcmp0(def, "bold_magenta") == 0)
return THEME_MAGENTA_BOLD;
else if (g_strcmp0(def, "black") == 0)
return THEME_BLACK;
else if (g_strcmp0(def, "bold_black") == 0)
return THEME_BLACK_BOLD;
else return THEME_TEXT;
else
return THEME_TEXT;
}
}

View File

@@ -38,6 +38,6 @@
void plugin_themes_init(void);
void plugin_themes_close(void);
theme_item_t plugin_themes_get(const char *const group, const char *const key, const char *const def);
theme_item_t plugin_themes_get(const char* const group, const char* const key, const char* const def);
#endif