diff options
213 files changed, 19156 insertions, 17154 deletions
diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index 0d9d4cc5..13c06832 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -64,72 +64,72 @@ #include "omemo/omemo.h" #endif -static char* _sub_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _notify_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _theme_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _autoaway_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _autoconnect_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _account_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _who_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _roster_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _bookmark_autocomplete(ProfWin *window, const char *const input, gboolean previous); +static char* _sub_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _notify_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _theme_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _autoaway_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _autoconnect_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _account_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _who_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _roster_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _bookmark_autocomplete(ProfWin* window, const char* const input, gboolean previous); #ifdef HAVE_LIBOTR -static char* _otr_autocomplete(ProfWin *window, const char *const input, gboolean previous); +static char* _otr_autocomplete(ProfWin* window, const char* const input, gboolean previous); #endif #ifdef HAVE_LIBGPGME -static char* _pgp_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _ox_autocomplete(ProfWin *window, const char *const input, gboolean previous); +static char* _pgp_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _ox_autocomplete(ProfWin* window, const char* const input, gboolean previous); #endif #ifdef HAVE_OMEMO -static char* _omemo_autocomplete(ProfWin *window, const char *const input, gboolean previous); +static char* _omemo_autocomplete(ProfWin* window, const char* const input, gboolean previous); #endif -static char* _connect_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _alias_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _join_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _log_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _form_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _form_field_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _occupants_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _kick_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _ban_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _affiliation_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _role_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _resource_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _wintitle_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _inpblock_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _time_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _receipts_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _help_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _wins_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _tls_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _titlebar_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _script_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _subject_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _console_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _win_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _close_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _plugins_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _sendfile_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _blocked_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _tray_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _presence_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _rooms_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _statusbar_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _clear_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _invite_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _status_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _logging_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _color_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _avatar_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _correction_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _correct_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _software_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _url_autocomplete(ProfWin *window, const char *const input, gboolean previous); -static char* _executable_autocomplete(ProfWin *window, const char *const input, gboolean previous); - -static char* _script_autocomplete_func(const char *const prefix, gboolean previous, void *context); - -static char* _cmd_ac_complete_params(ProfWin *window, const char *const input, gboolean previous); +static char* _connect_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _alias_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _join_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _log_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _form_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _form_field_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _occupants_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _kick_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _ban_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _affiliation_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _role_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _resource_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _wintitle_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _inpblock_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _time_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _receipts_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _help_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _wins_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _tls_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _titlebar_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _script_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _subject_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _console_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _win_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _close_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _plugins_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _sendfile_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _blocked_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _tray_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _presence_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _rooms_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _statusbar_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _clear_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _invite_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _status_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _logging_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _color_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _avatar_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _correction_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _correct_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _software_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _url_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _executable_autocomplete(ProfWin* window, const char* const input, gboolean previous); + +static char* _script_autocomplete_func(const char* const prefix, gboolean previous, void* context); + +static char* _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previous); static Autocomplete commands_ac; static Autocomplete who_room_ac; @@ -1053,7 +1053,7 @@ cmd_ac_init(void) } void -cmd_ac_add(const char *const value) +cmd_ac_add(const char* const value) { if (commands_ac == NULL) { return; @@ -1063,7 +1063,7 @@ cmd_ac_add(const char *const value) } void -cmd_ac_add_help(const char *const value) +cmd_ac_add_help(const char* const value) { if (help_ac == NULL) { return; @@ -1073,16 +1073,16 @@ cmd_ac_add_help(const char *const value) } void -cmd_ac_add_cmd(Command *command) +cmd_ac_add_cmd(Command* command) { autocomplete_add(commands_ac, command->cmd); - autocomplete_add(help_ac, command->cmd+1); + autocomplete_add(help_ac, command->cmd + 1); } void -cmd_ac_add_alias(ProfAlias *alias) +cmd_ac_add_alias(ProfAlias* alias) { - GString *ac_alias = g_string_new("/"); + GString* ac_alias = g_string_new("/"); g_string_append(ac_alias, alias->name); autocomplete_add(commands_ac, ac_alias->str); autocomplete_add(aliases_ac, alias->name); @@ -1090,7 +1090,7 @@ cmd_ac_add_alias(ProfAlias *alias) } void -cmd_ac_add_alias_value(char *value) +cmd_ac_add_alias_value(char* value) { if (aliases_ac == NULL) { return; @@ -1100,7 +1100,7 @@ cmd_ac_add_alias_value(char *value) } void -cmd_ac_remove_alias_value(char *value) +cmd_ac_remove_alias_value(char* value) { if (aliases_ac == NULL) { return; @@ -1109,7 +1109,7 @@ cmd_ac_remove_alias_value(char *value) } void -cmd_ac_remove(const char *const value) +cmd_ac_remove(const char* const value) { if (commands_ac == NULL) { return; @@ -1119,7 +1119,7 @@ cmd_ac_remove(const char *const value) } void -cmd_ac_remove_help(const char *const value) +cmd_ac_remove_help(const char* const value) { if (help_ac == NULL) { return; @@ -1129,7 +1129,7 @@ cmd_ac_remove_help(const char *const value) } gboolean -cmd_ac_exists(char *cmd) +cmd_ac_exists(char* cmd) { if (commands_ac == NULL) { return FALSE; @@ -1139,16 +1139,16 @@ cmd_ac_exists(char *cmd) } void -cmd_ac_add_form_fields(DataForm *form) +cmd_ac_add_form_fields(DataForm* form) { if (form == NULL) { return; } - GList *fields = autocomplete_create_list(form->tag_ac); - GList *curr_field = fields; + GList* fields = autocomplete_create_list(form->tag_ac); + GList* curr_field = fields; while (curr_field) { - GString *field_str = g_string_new("/"); + GString* field_str = g_string_new("/"); g_string_append(field_str, curr_field->data); cmd_ac_add(field_str->str); g_string_free(field_str, TRUE); @@ -1158,16 +1158,16 @@ cmd_ac_add_form_fields(DataForm *form) } void -cmd_ac_remove_form_fields(DataForm *form) +cmd_ac_remove_form_fields(DataForm* form) { if (form == NULL) { return; } - GList *fields = autocomplete_create_list(form->tag_ac); - GList *curr_field = fields; + GList* fields = autocomplete_create_list(form->tag_ac); + GList* curr_field = fields; while (curr_field) { - GString *field_str = g_string_new("/"); + GString* field_str = g_string_new("/"); g_string_append(field_str, curr_field->data); cmd_ac_remove(field_str->str); g_string_free(field_str, TRUE); @@ -1177,19 +1177,19 @@ cmd_ac_remove_form_fields(DataForm *form) } char* -cmd_ac_complete(ProfWin *window, const char *const input, gboolean previous) +cmd_ac_complete(ProfWin* window, const char* const input, gboolean previous) { // autocomplete command if ((strncmp(input, "/", 1) == 0) && (!str_contains(input, strlen(input), ' '))) { - char *found = NULL; + char* found = NULL; found = autocomplete_complete(commands_ac, input, TRUE, previous); if (found) { return found; } - // autocomplete parameters + // autocomplete parameters } else { - char *found = _cmd_ac_complete_params(window, input, previous); + char* found = _cmd_ac_complete_params(window, input, previous); if (found) { return found; } @@ -1199,14 +1199,14 @@ cmd_ac_complete(ProfWin *window, const char *const input, gboolean previous) } void -cmd_ac_reset(ProfWin *window) +cmd_ac_reset(ProfWin* window) { jabber_conn_status_t conn_status = connection_get_status(); if (conn_status == JABBER_CONNECTED) { roster_reset_search_attempts(); if (window->type == WIN_CHAT) { - ProfChatWin *chatwin = (ProfChatWin*)window; + ProfChatWin* chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); PContact contact = roster_get_contact(chatwin->barejid); if (contact) { @@ -1378,14 +1378,14 @@ cmd_ac_reset(ProfWin *window) } if (window->type == WIN_MUC) { - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); muc_autocomplete_reset(mucwin->roomjid); muc_jid_autocomplete_reset(mucwin->roomjid); } if (window->type == WIN_CONFIG) { - ProfConfWin *confwin = (ProfConfWin*)window; + ProfConfWin* confwin = (ProfConfWin*)window; assert(confwin->memcheck == PROFCONFWIN_MEMCHECK); if (confwin->form) { form_reset_autocompleters(confwin->form); @@ -1535,21 +1535,22 @@ cmd_ac_uninit(void) } static void -_filepath_item_free(char **ptr) { - char *item = *ptr; +_filepath_item_free(char** ptr) +{ + char* item = *ptr; free(item); } char* -cmd_ac_complete_filepath(const char *const input, char *const startstr, gboolean previous) +cmd_ac_complete_filepath(const char* const input, char* const startstr, gboolean previous) { unsigned int output_off = 0; - char *result = NULL; - char *tmp; + char* result = NULL; + char* tmp; // strip command - char *inpcp = (char*)input + strlen(startstr); + char* inpcp = (char*)input + strlen(startstr); while (*inpcp == ' ') { inpcp++; } @@ -1558,22 +1559,22 @@ cmd_ac_complete_filepath(const char *const input, char *const startstr, gboolean // strip quotes if (*inpcp == '"') { - tmp = strchr(inpcp+1, '"'); + tmp = strchr(inpcp + 1, '"'); if (tmp) { *tmp = '\0'; } - tmp = strdup(inpcp+1); + tmp = strdup(inpcp + 1); free(inpcp); inpcp = tmp; } // expand ~ to $HOME if (inpcp[0] == '~' && inpcp[1] == '/') { - if (asprintf(&tmp, "%s/%sfoo", getenv("HOME"), inpcp+2) == -1) { + if (asprintf(&tmp, "%s/%sfoo", getenv("HOME"), inpcp + 2) == -1) { free(inpcp); return NULL; } - output_off = strlen(getenv("HOME"))+1; + output_off = strlen(getenv("HOME")) + 1; } else { if (asprintf(&tmp, "%sfoo", inpcp) == -1) { free(inpcp); @@ -1589,11 +1590,11 @@ cmd_ac_complete_filepath(const char *const input, char *const startstr, gboolean free(inpcp); free(inpcp2); - struct dirent *dir; - GArray *files = g_array_new(TRUE, FALSE, sizeof(char *)); + struct dirent* dir; + GArray* files = g_array_new(TRUE, FALSE, sizeof(char*)); g_array_set_clear_func(files, (GDestroyNotify)_filepath_item_free); - DIR *d = opendir(directory); + DIR* d = opendir(directory); if (d) { while ((dir = readdir(d)) != NULL) { if (strcmp(dir->d_name, ".") == 0) { @@ -1605,17 +1606,17 @@ cmd_ac_complete_filepath(const char *const input, char *const startstr, gboolean continue; } - char *acstring; + char* acstring; if (output_off) { if (asprintf(&tmp, "%s/%s", directory, dir->d_name) == -1) { free(directory); free(foofile); return NULL; } - if (asprintf(&acstring, "~/%s", tmp+output_off) == -1) { + if (asprintf(&acstring, "~/%s", tmp + output_off) == -1) { free(directory); free(foofile); - return NULL; + return NULL; } free(tmp); } else if (strcmp(directory, "/") == 0) { @@ -1632,7 +1633,7 @@ cmd_ac_complete_filepath(const char *const input, char *const startstr, gboolean } } - char *acstring_cpy = strdup(acstring); + char* acstring_cpy = strdup(acstring); g_array_append_val(files, acstring_cpy); free(acstring); } @@ -1641,7 +1642,7 @@ cmd_ac_complete_filepath(const char *const input, char *const startstr, gboolean free(directory); free(foofile); - autocomplete_update(filepath_ac, (char **)files->data); + autocomplete_update(filepath_ac, (char**)files->data); g_array_free(files, TRUE); result = autocomplete_param_with_ac(input, startstr, filepath_ac, TRUE, previous); @@ -1653,16 +1654,16 @@ cmd_ac_complete_filepath(const char *const input, char *const startstr, gboolean } static char* -_cmd_ac_complete_params(ProfWin *window, const char *const input, gboolean previous) +_cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previous) { int i; - char *result = NULL; + char* result = NULL; jabber_conn_status_t conn_status = connection_get_status(); // autocomplete boolean settings - gchar *boolean_choices[] = { "/beep", "/intype", "/states", "/outtype", "/flash", "/splash", - "/history", "/vercheck", "/privileges", "/wrap", "/carbons", "/lastactivity", "/os", "/slashguard"}; + gchar* boolean_choices[] = { "/beep", "/intype", "/states", "/outtype", "/flash", "/splash", + "/history", "/vercheck", "/privileges", "/wrap", "/carbons", "/lastactivity", "/os", "/slashguard" }; for (i = 0; i < ARRAY_SIZE(boolean_choices); i++) { result = autocomplete_param_with_func(input, boolean_choices[i], prefs_autocomplete_boolean_choice, previous, NULL); @@ -1673,14 +1674,14 @@ _cmd_ac_complete_params(ProfWin *window, const char *const input, gboolean previ // autocomplete nickname in chat rooms if (window->type == WIN_MUC) { - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); Autocomplete nick_ac = muc_roster_ac(mucwin->roomjid); if (nick_ac) { - gchar *nick_choices[] = { "/msg", "/info", "/caps" } ; + gchar* nick_choices[] = { "/msg", "/info", "/caps" }; // Remove quote character before and after names when doing autocomplete - char *unquoted = strip_arg_quotes(input); + char* unquoted = strip_arg_quotes(input); for (i = 0; i < ARRAY_SIZE(nick_choices); i++) { result = autocomplete_param_with_ac(unquoted, nick_choices[i], nick_ac, TRUE, previous); if (result) { @@ -1691,11 +1692,11 @@ _cmd_ac_complete_params(ProfWin *window, const char *const input, gboolean previ free(unquoted); } - // otherwise autocomplete using roster + // otherwise autocomplete using roster } else if (conn_status == JABBER_CONNECTED) { - gchar *contact_choices[] = { "/msg", "/info" }; + gchar* contact_choices[] = { "/msg", "/info" }; // Remove quote character before and after names when doing autocomplete - char *unquoted = strip_arg_quotes(input); + char* unquoted = strip_arg_quotes(input); for (i = 0; i < ARRAY_SIZE(contact_choices); i++) { result = autocomplete_param_with_func(unquoted, contact_choices[i], roster_contact_autocomplete, previous, NULL); if (result) { @@ -1705,7 +1706,7 @@ _cmd_ac_complete_params(ProfWin *window, const char *const input, gboolean previ } free(unquoted); - gchar *resource_choices[] = { "/caps", "/ping" }; + gchar* resource_choices[] = { "/caps", "/ping" }; for (i = 0; i < ARRAY_SIZE(resource_choices); i++) { result = autocomplete_param_with_func(input, resource_choices[i], roster_fulljid_autocomplete, previous, NULL); if (result) { @@ -1714,7 +1715,7 @@ _cmd_ac_complete_params(ProfWin *window, const char *const input, gboolean previ } } - gchar *invite_choices[] = { "/join" }; + gchar* invite_choices[] = { "/join" }; for (i = 0; i < ARRAY_SIZE(invite_choices); i++) { result = autocomplete_param_with_func(input, invite_choices[i], muc_invites_find, previous, NULL); if (result) { @@ -1722,7 +1723,7 @@ _cmd_ac_complete_params(ProfWin *window, const char *const input, gboolean previ } } - gchar *cmds[] = { "/prefs", "/disco", "/room", "/autoping", "/mainwin", "/inputwin" }; + gchar* cmds[] = { "/prefs", "/disco", "/room", "/autoping", "/mainwin", "/inputwin" }; Autocomplete completers[] = { prefs_ac, disco_ac, room_ac, autoping_ac, winpos_ac, winpos_ac }; for (i = 0; i < ARRAY_SIZE(cmds); i++) { @@ -1732,71 +1733,71 @@ _cmd_ac_complete_params(ProfWin *window, const char *const input, gboolean previ } } - GHashTable *ac_funcs = g_hash_table_new(g_str_hash, g_str_equal); - g_hash_table_insert(ac_funcs, "/help", _help_autocomplete); - g_hash_table_insert(ac_funcs, "/who", _who_autocomplete); - g_hash_table_insert(ac_funcs, "/sub", _sub_autocomplete); - g_hash_table_insert(ac_funcs, "/notify", _notify_autocomplete); - g_hash_table_insert(ac_funcs, "/autoaway", _autoaway_autocomplete); - g_hash_table_insert(ac_funcs, "/theme", _theme_autocomplete); - g_hash_table_insert(ac_funcs, "/log", _log_autocomplete); - g_hash_table_insert(ac_funcs, "/account", _account_autocomplete); - g_hash_table_insert(ac_funcs, "/roster", _roster_autocomplete); - g_hash_table_insert(ac_funcs, "/bookmark", _bookmark_autocomplete); - g_hash_table_insert(ac_funcs, "/autoconnect", _autoconnect_autocomplete); + GHashTable* ac_funcs = g_hash_table_new(g_str_hash, g_str_equal); + g_hash_table_insert(ac_funcs, "/help", _help_autocomplete); + g_hash_table_insert(ac_funcs, "/who", _who_autocomplete); + g_hash_table_insert(ac_funcs, "/sub", _sub_autocomplete); + g_hash_table_insert(ac_funcs, "/notify", _notify_autocomplete); + g_hash_table_insert(ac_funcs, "/autoaway", _autoaway_autocomplete); + g_hash_table_insert(ac_funcs, "/theme", _theme_autocomplete); + g_hash_table_insert(ac_funcs, "/log", _log_autocomplete); + g_hash_table_insert(ac_funcs, "/account", _account_autocomplete); + g_hash_table_insert(ac_funcs, "/roster", _roster_autocomplete); + g_hash_table_insert(ac_funcs, "/bookmark", _bookmark_autocomplete); + g_hash_table_insert(ac_funcs, "/autoconnect", _autoconnect_autocomplete); #ifdef HAVE_LIBOTR - g_hash_table_insert(ac_funcs, "/otr", _otr_autocomplete); + g_hash_table_insert(ac_funcs, "/otr", _otr_autocomplete); #endif #ifdef HAVE_LIBGPGME - g_hash_table_insert(ac_funcs, "/pgp", _pgp_autocomplete); - g_hash_table_insert(ac_funcs, "/ox", _ox_autocomplete); + g_hash_table_insert(ac_funcs, "/pgp", _pgp_autocomplete); + g_hash_table_insert(ac_funcs, "/ox", _ox_autocomplete); #endif #ifdef HAVE_OMEMO - g_hash_table_insert(ac_funcs, "/omemo", _omemo_autocomplete); + g_hash_table_insert(ac_funcs, "/omemo", _omemo_autocomplete); #endif - g_hash_table_insert(ac_funcs, "/connect", _connect_autocomplete); - g_hash_table_insert(ac_funcs, "/alias", _alias_autocomplete); - g_hash_table_insert(ac_funcs, "/join", _join_autocomplete); - g_hash_table_insert(ac_funcs, "/form", _form_autocomplete); - g_hash_table_insert(ac_funcs, "/occupants", _occupants_autocomplete); - g_hash_table_insert(ac_funcs, "/kick", _kick_autocomplete); - g_hash_table_insert(ac_funcs, "/ban", _ban_autocomplete); - g_hash_table_insert(ac_funcs, "/affiliation", _affiliation_autocomplete); - g_hash_table_insert(ac_funcs, "/role", _role_autocomplete); - g_hash_table_insert(ac_funcs, "/resource", _resource_autocomplete); - g_hash_table_insert(ac_funcs, "/wintitle", _wintitle_autocomplete); - g_hash_table_insert(ac_funcs, "/inpblock", _inpblock_autocomplete); - g_hash_table_insert(ac_funcs, "/time", _time_autocomplete); - g_hash_table_insert(ac_funcs, "/receipts", _receipts_autocomplete); - g_hash_table_insert(ac_funcs, "/wins", _wins_autocomplete); - g_hash_table_insert(ac_funcs, "/tls", _tls_autocomplete); - g_hash_table_insert(ac_funcs, "/titlebar", _titlebar_autocomplete); - g_hash_table_insert(ac_funcs, "/script", _script_autocomplete); - g_hash_table_insert(ac_funcs, "/subject", _subject_autocomplete); - g_hash_table_insert(ac_funcs, "/console", _console_autocomplete); - g_hash_table_insert(ac_funcs, "/win", _win_autocomplete); - g_hash_table_insert(ac_funcs, "/close", _close_autocomplete); - g_hash_table_insert(ac_funcs, "/plugins", _plugins_autocomplete); - g_hash_table_insert(ac_funcs, "/sendfile", _sendfile_autocomplete); - g_hash_table_insert(ac_funcs, "/blocked", _blocked_autocomplete); - g_hash_table_insert(ac_funcs, "/tray", _tray_autocomplete); - g_hash_table_insert(ac_funcs, "/presence", _presence_autocomplete); - g_hash_table_insert(ac_funcs, "/rooms", _rooms_autocomplete); - g_hash_table_insert(ac_funcs, "/statusbar", _statusbar_autocomplete); - g_hash_table_insert(ac_funcs, "/clear", _clear_autocomplete); - g_hash_table_insert(ac_funcs, "/invite", _invite_autocomplete); - g_hash_table_insert(ac_funcs, "/status", _status_autocomplete); - g_hash_table_insert(ac_funcs, "/logging", _logging_autocomplete); - g_hash_table_insert(ac_funcs, "/color", _color_autocomplete); - g_hash_table_insert(ac_funcs, "/avatar", _avatar_autocomplete); - g_hash_table_insert(ac_funcs, "/correction", _correction_autocomplete); - g_hash_table_insert(ac_funcs, "/correct", _correct_autocomplete); - g_hash_table_insert(ac_funcs, "/software", _software_autocomplete); - g_hash_table_insert(ac_funcs, "/url", _url_autocomplete); - g_hash_table_insert(ac_funcs, "/executable", _executable_autocomplete); + g_hash_table_insert(ac_funcs, "/connect", _connect_autocomplete); + g_hash_table_insert(ac_funcs, "/alias", _alias_autocomplete); + g_hash_table_insert(ac_funcs, "/join", _join_autocomplete); + g_hash_table_insert(ac_funcs, "/form", _form_autocomplete); + g_hash_table_insert(ac_funcs, "/occupants", _occupants_autocomplete); + g_hash_table_insert(ac_funcs, "/kick", _kick_autocomplete); + g_hash_table_insert(ac_funcs, "/ban", _ban_autocomplete); + g_hash_table_insert(ac_funcs, "/affiliation", _affiliation_autocomplete); + g_hash_table_insert(ac_funcs, "/role", _role_autocomplete); + g_hash_table_insert(ac_funcs, "/resource", _resource_autocomplete); + g_hash_table_insert(ac_funcs, "/wintitle", _wintitle_autocomplete); + g_hash_table_insert(ac_funcs, "/inpblock", _inpblock_autocomplete); + g_hash_table_insert(ac_funcs, "/time", _time_autocomplete); + g_hash_table_insert(ac_funcs, "/receipts", _receipts_autocomplete); + g_hash_table_insert(ac_funcs, "/wins", _wins_autocomplete); + g_hash_table_insert(ac_funcs, "/tls", _tls_autocomplete); + g_hash_table_insert(ac_funcs, "/titlebar", _titlebar_autocomplete); + g_hash_table_insert(ac_funcs, "/script", _script_autocomplete); + g_hash_table_insert(ac_funcs, "/subject", _subject_autocomplete); + g_hash_table_insert(ac_funcs, "/console", _console_autocomplete); + g_hash_table_insert(ac_funcs, "/win", _win_autocomplete); + g_hash_table_insert(ac_funcs, "/close", _close_autocomplete); + g_hash_table_insert(ac_funcs, "/plugins", _plugins_autocomplete); + g_hash_table_insert(ac_funcs, "/sendfile", _sendfile_autocomplete); + g_hash_table_insert(ac_funcs, "/blocked", _blocked_autocomplete); + g_hash_table_insert(ac_funcs, "/tray", _tray_autocomplete); + g_hash_table_insert(ac_funcs, "/presence", _presence_autocomplete); + g_hash_table_insert(ac_funcs, "/rooms", _rooms_autocomplete); + g_hash_table_insert(ac_funcs, "/statusbar", _statusbar_autocomplete); + g_hash_table_insert(ac_funcs, "/clear", _clear_autocomplete); + g_hash_table_insert(ac_funcs, "/invite", _invite_autocomplete); + g_hash_table_insert(ac_funcs, "/status", _status_autocomplete); + g_hash_table_insert(ac_funcs, "/logging", _logging_autocomplete); + g_hash_table_insert(ac_funcs, "/color", _color_autocomplete); + g_hash_table_insert(ac_funcs, "/avatar", _avatar_autocomplete); + g_hash_table_insert(ac_funcs, "/correction", _correction_autocomplete); + g_hash_table_insert(ac_funcs, "/correct", _correct_autocomplete); + g_hash_table_insert(ac_funcs, "/software", _software_autocomplete); + g_hash_table_insert(ac_funcs, "/url", _url_autocomplete); + g_hash_table_insert(ac_funcs, "/executable", _executable_autocomplete); int len = strlen(input); - char parsed[len+1]; + char parsed[len + 1]; i = 0; while (i < len) { if (input[i] == ' ') { @@ -1808,7 +1809,7 @@ _cmd_ac_complete_params(ProfWin *window, const char *const input, gboolean previ } parsed[i] = '\0'; - char * (*ac_func)(ProfWin*, const char * const, gboolean) = g_hash_table_lookup(ac_funcs, parsed); + char* (*ac_func)(ProfWin*, const char* const, gboolean) = g_hash_table_lookup(ac_funcs, parsed); if (ac_func) { result = ac_func(window, input, previous); if (result) { @@ -1834,9 +1835,9 @@ _cmd_ac_complete_params(ProfWin *window, const char *const input, gboolean previ } static char* -_sub_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_sub_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *result = NULL; + char* result = NULL; result = autocomplete_param_with_func(input, "/sub allow", presence_sub_request_find, previous, NULL); if (result) { return result; @@ -1854,9 +1855,9 @@ _sub_autocomplete(ProfWin *window, const char *const input, gboolean previous) } static char* -_tray_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_tray_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *result = NULL; + char* result = NULL; result = autocomplete_param_with_func(input, "/tray read", prefs_autocomplete_boolean_choice, previous, NULL); if (result) { return result; @@ -1871,9 +1872,9 @@ _tray_autocomplete(ProfWin *window, const char *const input, gboolean previous) } static char* -_who_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_who_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *result = NULL; + char* result = NULL; if (window->type == WIN_MUC) { result = autocomplete_param_with_ac(input, "/who", who_room_ac, TRUE, previous); @@ -1884,9 +1885,9 @@ _who_autocomplete(ProfWin *window, const char *const input, gboolean previous) jabber_conn_status_t conn_status = connection_get_status(); if (conn_status == JABBER_CONNECTED) { int i = 0; - gchar *group_commands[] = { "/who any", "/who online", "/who offline", - "/who chat", "/who away", "/who xa", "/who dnd", "/who available", - "/who unavailable" }; + gchar* group_commands[] = { "/who any", "/who online", "/who offline", + "/who chat", "/who away", "/who xa", "/who dnd", "/who available", + "/who unavailable" }; for (i = 0; i < ARRAY_SIZE(group_commands); i++) { result = autocomplete_param_with_func(input, group_commands[i], roster_group_autocomplete, previous, NULL); @@ -1906,9 +1907,9 @@ _who_autocomplete(ProfWin *window, const char *const input, gboolean previous) } static char* -_roster_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_roster_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *result = NULL; + char* result = NULL; result = autocomplete_param_with_ac(input, "/roster room private char", roster_char_ac, TRUE, previous); if (result) { return result; @@ -2084,9 +2085,9 @@ _roster_autocomplete(ProfWin *window, const char *const input, gboolean previous } static char* -_blocked_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_blocked_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *result = NULL; + char* result = NULL; result = autocomplete_param_with_func(input, "/blocked remove", blocked_ac_find, previous, NULL); if (result) { @@ -2102,18 +2103,18 @@ _blocked_autocomplete(ProfWin *window, const char *const input, gboolean previou } static char* -_bookmark_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_bookmark_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *found = NULL; + char* found = NULL; gboolean result; - gchar **args = parse_args(input, 2, 8, &result); + gchar** args = parse_args(input, 2, 8, &result); - if (result && ((strcmp(args[0], "add") == 0) || (strcmp(args[0], "update") == 0)) ) { + if (result && ((strcmp(args[0], "add") == 0) || (strcmp(args[0], "update") == 0))) { gboolean space_at_end = g_str_has_suffix(input, " "); int num_args = g_strv_length(args); if ((num_args == 2 && space_at_end) || (num_args == 3 && !space_at_end)) { - GString *beginning = g_string_new("/bookmark"); + GString* beginning = g_string_new("/bookmark"); g_string_append_printf(beginning, " %s %s", args[0], args[1]); found = autocomplete_param_with_ac(input, beginning->str, bookmark_property_ac, TRUE, previous); g_string_free(beginning, TRUE); @@ -2123,8 +2124,8 @@ _bookmark_autocomplete(ProfWin *window, const char *const input, gboolean previo } } if ((num_args == 3 && space_at_end && (g_strcmp0(args[2], "autojoin") == 0)) - || (num_args == 4 && (g_strcmp0(args[2], "autojoin") == 0) && !space_at_end)) { - GString *beginning = g_string_new("/bookmark"); + || (num_args == 4 && (g_strcmp0(args[2], "autojoin") == 0) && !space_at_end)) { + GString* beginning = g_string_new("/bookmark"); g_string_append_printf(beginning, " %s %s %s", args[0], args[1], args[2]); found = autocomplete_param_with_func(input, beginning->str, prefs_autocomplete_boolean_choice, previous, NULL); g_string_free(beginning, TRUE); @@ -2134,7 +2135,7 @@ _bookmark_autocomplete(ProfWin *window, const char *const input, gboolean previo } } if ((num_args == 4 && space_at_end) || (num_args == 5 && !space_at_end)) { - GString *beginning = g_string_new("/bookmark"); + GString* beginning = g_string_new("/bookmark"); g_string_append_printf(beginning, " %s %s %s %s", args[0], args[1], args[2], args[3]); found = autocomplete_param_with_ac(input, beginning->str, bookmark_property_ac, TRUE, previous); g_string_free(beginning, TRUE); @@ -2144,8 +2145,8 @@ _bookmark_autocomplete(ProfWin *window, const char *const input, gboolean previo } } if ((num_args == 5 && space_at_end && (g_strcmp0(args[4], "autojoin") == 0)) - || (num_args == 6 && (g_strcmp0(args[4], "autojoin") == 0) && !space_at_end)) { - GString *beginning = g_string_new("/bookmark"); + || (num_args == 6 && (g_strcmp0(args[4], "autojoin") == 0) && !space_at_end)) { + GString* beginning = g_string_new("/bookmark"); g_string_append_printf(beginning, " %s %s %s %s %s", args[0], args[1], args[2], args[3], args[4]); found = autocomplete_param_with_func(input, beginning->str, prefs_autocomplete_boolean_choice, previous, NULL); g_string_free(beginning, TRUE); @@ -2155,7 +2156,7 @@ _bookmark_autocomplete(ProfWin *window, const char *const input, gboolean previo } } if ((num_args == 6 && space_at_end) || (num_args == 7 && !space_at_end)) { - GString *beginning = g_string_new("/bookmark"); + GString* beginning = g_string_new("/bookmark"); g_string_append_printf(beginning, " %s %s %s %s %s %s", args[0], args[1], args[2], args[3], args[4], args[5]); found = autocomplete_param_with_ac(input, beginning->str, bookmark_property_ac, TRUE, previous); g_string_free(beginning, TRUE); @@ -2165,8 +2166,8 @@ _bookmark_autocomplete(ProfWin *window, const char *const input, gboolean previo } } if ((num_args == 7 && space_at_end && (g_strcmp0(args[6], "autojoin") == 0)) - || (num_args == 8 && (g_strcmp0(args[6], "autojoin") == 0) && !space_at_end)) { - GString *beginning = g_string_new("/bookmark"); + || (num_args == 8 && (g_strcmp0(args[6], "autojoin") == 0) && !space_at_end)) { + GString* beginning = g_string_new("/bookmark"); g_string_append_printf(beginning, " %s %s %s %s %s %s %s", args[0], args[1], args[2], args[3], args[4], args[5], args[6]); found = autocomplete_param_with_func(input, beginning->str, prefs_autocomplete_boolean_choice, previous, NULL); g_string_free(beginning, TRUE); @@ -2214,18 +2215,18 @@ _bookmark_autocomplete(ProfWin *window, const char *const input, gboolean previo } static char* -_notify_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_notify_autocomplete(ProfWin* window, const char* const input, gboolean previous) { int i = 0; - char *result = NULL; + char* result = NULL; result = autocomplete_param_with_func(input, "/notify room trigger remove", prefs_autocomplete_room_trigger, previous, NULL); if (result) { return result; } - gchar *boolean_choices1[] = { "/notify room current", "/notify chat current", "/notify typing current", - "/notify room text", "/notify chat text" }; + gchar* boolean_choices1[] = { "/notify room current", "/notify chat current", "/notify typing current", + "/notify room text", "/notify chat text" }; for (i = 0; i < ARRAY_SIZE(boolean_choices1); i++) { result = autocomplete_param_with_func(input, boolean_choices1[i], prefs_autocomplete_boolean_choice, previous, NULL); if (result) { @@ -2258,7 +2259,7 @@ _notify_autocomplete(ProfWin *window, const char *const input, gboolean previous return result; } - gchar *boolean_choices2[] = { "/notify invite", "/notify sub", "/notify mention", "/notify trigger"}; + gchar* boolean_choices2[] = { "/notify invite", "/notify sub", "/notify mention", "/notify trigger" }; for (i = 0; i < ARRAY_SIZE(boolean_choices2); i++) { result = autocomplete_param_with_func(input, boolean_choices2[i], prefs_autocomplete_boolean_choice, previous, NULL); if (result) { @@ -2275,9 +2276,9 @@ _notify_autocomplete(ProfWin *window, const char *const input, gboolean previous } static char* -_autoaway_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_autoaway_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *result = NULL; + char* result = NULL; result = autocomplete_param_with_ac(input, "/autoaway mode", autoaway_mode_ac, TRUE, previous); if (result) { @@ -2307,9 +2308,9 @@ _autoaway_autocomplete(ProfWin *window, const char *const input, gboolean previo } static char* -_log_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_log_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *result = NULL; + char* result = NULL; result = autocomplete_param_with_func(input, "/log rotate", prefs_autocomplete_boolean_choice, previous, NULL); if (result) { @@ -2328,9 +2329,9 @@ _log_autocomplete(ProfWin *window, const char *const input, gboolean previous) } static char* -_autoconnect_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_autoconnect_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *result = NULL; + char* result = NULL; result = autocomplete_param_with_func(input, "/autoconnect set", accounts_find_enabled, previous, NULL); if (result) { @@ -2347,9 +2348,9 @@ _autoconnect_autocomplete(ProfWin *window, const char *const input, gboolean pre #ifdef HAVE_LIBOTR static char* -_otr_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_otr_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *found = NULL; + char* found = NULL; jabber_conn_status_t conn_status = connection_get_status(); @@ -2368,9 +2369,9 @@ _otr_autocomplete(ProfWin *window, const char *const input, gboolean previous) // /otr policy always user@server.com if (conn_status == JABBER_CONNECTED) { gboolean result; - gchar **args = parse_args(input, 2, 3, &result); + gchar** args = parse_args(input, 2, 3, &result); if (result && (strcmp(args[0], "policy") == 0)) { - GString *beginning = g_string_new("/otr "); + GString* beginning = g_string_new("/otr "); g_string_append(beginning, args[0]); g_string_append(beginning, " "); if (args[1]) { @@ -2408,9 +2409,9 @@ _otr_autocomplete(ProfWin *window, const char *const input, gboolean previous) #ifdef HAVE_LIBGPGME static char* -_pgp_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_pgp_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *found = NULL; + char* found = NULL; jabber_conn_status_t conn_status = connection_get_status(); @@ -2432,9 +2433,9 @@ _pgp_autocomplete(ProfWin *window, const char *const input, gboolean previous) } gboolean result; - gchar **args = parse_args(input, 2, 3, &result); + gchar** args = parse_args(input, 2, 3, &result); if ((strncmp(input, "/pgp", 4) == 0) && (result == TRUE)) { - GString *beginning = g_string_new("/pgp "); + GString* beginning = g_string_new("/pgp "); g_string_append(beginning, args[0]); if (args[1]) { g_string_append(beginning, " "); @@ -2470,9 +2471,9 @@ _pgp_autocomplete(ProfWin *window, const char *const input, gboolean previous) * */ static char* -_ox_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_ox_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *found = NULL; + char* found = NULL; jabber_conn_status_t conn_status = connection_get_status(); @@ -2494,9 +2495,9 @@ _ox_autocomplete(ProfWin *window, const char *const input, gboolean previous) } gboolean result; - gchar **args = parse_args(input, 2, 3, &result); + gchar** args = parse_args(input, 2, 3, &result); if ((strncmp(input, "/ox", 4) == 0) && (result == TRUE)) { - GString *beginning = g_string_new("/ox "); + GString* beginning = g_string_new("/ox "); g_string_append(beginning, args[0]); if (args[1]) { g_string_append(beginning, " "); @@ -2529,9 +2530,9 @@ _ox_autocomplete(ProfWin *window, const char *const input, gboolean previous) #ifdef HAVE_OMEMO static char* -_omemo_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_omemo_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *found = NULL; + char* found = NULL; found = autocomplete_param_with_ac(input, "/omemo log", omemo_log_ac, TRUE, previous); if (found) { @@ -2562,7 +2563,7 @@ _omemo_autocomplete(ProfWin *window, const char *const input, gboolean previous) } if (window->type == WIN_CHAT) { - ProfChatWin *chatwin = (ProfChatWin*)window; + ProfChatWin* chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); found = autocomplete_param_with_func(input, "/omemo trust", omemo_fingerprint_autocomplete, previous, chatwin->barejid); if (found) { @@ -2577,9 +2578,9 @@ _omemo_autocomplete(ProfWin *window, const char *const input, gboolean previous) int num_tokens = count_tokens(input); if (num_tokens == 4) { gboolean result; - gchar **args = parse_args(input, 2, 3, &result); + gchar** args = parse_args(input, 2, 3, &result); if (result) { - gchar *jid = g_strdup(args[1]); + gchar* jid = g_strdup(args[1]); found = autocomplete_param_no_with_func(input, "/omemo trust", 4, omemo_fingerprint_autocomplete, previous, jid); if (found) { return found; @@ -2599,9 +2600,9 @@ _omemo_autocomplete(ProfWin *window, const char *const input, gboolean previous) #endif static char* -_plugins_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_plugins_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *result = NULL; + char* result = NULL; if (strncmp(input, "/plugins sourcepath set ", 24) == 0) { return cmd_ac_complete_filepath(input, "/plugins sourcepath set", previous); @@ -2621,8 +2622,8 @@ _plugins_autocomplete(ProfWin *window, const char *const input, gboolean previou if (strncmp(input, "/plugins load ", 14) == 0) { if (plugins_load_ac == NULL) { plugins_load_ac = autocomplete_new(); - GSList *plugins = plugins_unloaded_list(); - GSList *curr = plugins; + GSList* plugins = plugins_unloaded_list(); + GSList* curr = plugins; while (curr) { autocomplete_add(plugins_load_ac, curr->data); curr = g_slist_next(curr); @@ -2638,8 +2639,8 @@ _plugins_autocomplete(ProfWin *window, const char *const input, gboolean previou if (strncmp(input, "/plugins reload ", 16) == 0) { if (plugins_reload_ac == NULL) { plugins_reload_ac = autocomplete_new(); - GList *plugins = plugins_loaded_list(); - GList *curr = plugins; + GList* plugins = plugins_loaded_list(); + GList* curr = plugins; while (curr) { autocomplete_add(plugins_reload_ac, curr->data); curr = g_list_next(curr); @@ -2655,8 +2656,8 @@ _plugins_autocomplete(ProfWin *window, const char *const input, gboolean previou if (strncmp(input, "/plugins unload ", 16) == 0) { if (plugins_unload_ac == NULL) { plugins_unload_ac = autocomplete_new(); - GList *plugins = plugins_loaded_list(); - GList *curr = plugins; + GList* plugins = plugins_loaded_list(); + GList* curr = plugins; while (curr) { autocomplete_add(plugins_unload_ac, curr->data); curr = g_list_next(curr); @@ -2678,15 +2679,15 @@ _plugins_autocomplete(ProfWin *window, const char *const input, gboolean previou } static char* -_theme_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_theme_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *result = NULL; + char* result = NULL; if (strncmp(input, "/theme load ", 12) == 0) { if (theme_load_ac == NULL) { theme_load_ac = autocomplete_new(); - GSList *themes = theme_list(); - GSList *curr = themes; + GSList* themes = theme_list(); + GSList* curr = themes; while (curr) { autocomplete_add(theme_load_ac, curr->data); @@ -2706,8 +2707,8 @@ _theme_autocomplete(ProfWin *window, const char *const input, gboolean previous) if (strncmp(input, "/theme full-load ", 17) == 0) { if (theme_load_ac == NULL) { theme_load_ac = autocomplete_new(); - GSList *themes = theme_list(); - GSList *curr = themes; + GSList* themes = theme_list(); + GSList* curr = themes; while (curr) { autocomplete_add(theme_load_ac, curr->data); @@ -2733,12 +2734,12 @@ _theme_autocomplete(ProfWin *window, const char *const input, gboolean previous) } static char* -_script_autocomplete_func(const char *const prefix, gboolean previous, void *context) +_script_autocomplete_func(const char* const prefix, gboolean previous, void* context) { if (script_show_ac == NULL) { script_show_ac = autocomplete_new(); - GSList *scripts = scripts_list(); - GSList *curr = scripts; + GSList* scripts = scripts_list(); + GSList* curr = scripts; while (curr) { autocomplete_add(script_show_ac, curr->data); curr = g_slist_next(curr); @@ -2749,11 +2750,10 @@ _script_autocomplete_func(const char *const prefix, gboolean previous, void *con return autocomplete_complete(script_show_ac, prefix, FALSE, previous); } - static char* -_script_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_script_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *result = NULL; + char* result = NULL; if (strncmp(input, "/script show ", 13) == 0) { result = autocomplete_param_with_func(input, "/script show", _script_autocomplete_func, previous, NULL); if (result) { @@ -2777,13 +2777,13 @@ _script_autocomplete(ProfWin *window, const char *const input, gboolean previous } static char* -_resource_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_resource_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *found = NULL; + char* found = NULL; jabber_conn_status_t conn_status = connection_get_status(); if (conn_status == JABBER_CONNECTED && window->type == WIN_CHAT) { - ProfChatWin *chatwin = (ProfChatWin*)window; + ProfChatWin* chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); PContact contact = roster_get_contact(chatwin->barejid); if (contact) { @@ -2814,9 +2814,9 @@ _resource_autocomplete(ProfWin *window, const char *const input, gboolean previo } static char* -_wintitle_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_wintitle_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *found = NULL; + char* found = NULL; found = autocomplete_param_with_func(input, "/wintitle show", prefs_autocomplete_boolean_choice, previous, NULL); if (found) { @@ -2837,9 +2837,9 @@ _wintitle_autocomplete(ProfWin *window, const char *const input, gboolean previo } static char* -_inpblock_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_inpblock_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *found = NULL; + char* found = NULL; found = autocomplete_param_with_func(input, "/inpblock dynamic", prefs_autocomplete_boolean_choice, previous, NULL); if (found) { @@ -2855,16 +2855,16 @@ _inpblock_autocomplete(ProfWin *window, const char *const input, gboolean previo } static char* -_form_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_form_autocomplete(ProfWin* window, const char* const input, gboolean previous) { if (window->type != WIN_CONFIG) { return NULL; } - char *found = NULL; + char* found = NULL; - ProfConfWin *confwin = (ProfConfWin*)window; - DataForm *form = confwin->form; + ProfConfWin* confwin = (ProfConfWin*)window; + DataForm* form = confwin->form; if (form) { found = autocomplete_param_with_ac(input, "/form help", form->tag_ac, TRUE, previous); if (found) { @@ -2881,33 +2881,34 @@ _form_autocomplete(ProfWin *window, const char *const input, gboolean previous) } static char* -_form_field_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_form_field_autocomplete(ProfWin* window, const char* const input, gboolean previous) { if (window->type != WIN_CONFIG) { return NULL; } - char *found = NULL; + char* found = NULL; - ProfConfWin *confwin = (ProfConfWin*)window; - DataForm *form = confwin->form; + ProfConfWin* confwin = (ProfConfWin*)window; + DataForm* form = confwin->form; if (form == NULL) { return NULL; } - gchar **split = g_strsplit(input, " ", 0); + gchar** split = g_strsplit(input, " ", 0); if (g_strv_length(split) == 3) { - char *field_tag = split[0]+1; + char* field_tag = split[0] + 1; if (form_tag_exists(form, field_tag)) { form_field_type_t field_type = form_get_field_type(form, field_tag); - Autocomplete value_ac = form_get_value_ac(form, field_tag);; - GString *beginning = g_string_new(split[0]); + Autocomplete value_ac = form_get_value_ac(form, field_tag); + ; + GString* beginning = g_string_new(split[0]); g_string_append(beginning, " "); g_string_append(beginning, split[1]); if (((g_strcmp0(split[1], "add") == 0) || (g_strcmp0(split[1], "remove") == 0)) - && field_type == FIELD_LIST_MULTI) { + && field_type == FIELD_LIST_MULTI) { found = autocomplete_param_with_ac(input, beginning->str, value_ac, TRUE, previous); } else if ((g_strcmp0(split[1], "remove") == 0) && field_type == FIELD_TEXT_MULTI) { @@ -2921,26 +2922,26 @@ _form_field_autocomplete(ProfWin *window, const char *const input, gboolean prev } } else if (g_strv_length(split) == 2) { - char *field_tag = split[0]+1; + char* field_tag = split[0] + 1; if (form_tag_exists(form, field_tag)) { form_field_type_t field_type = form_get_field_type(form, field_tag); - Autocomplete value_ac = form_get_value_ac(form, field_tag);; - - switch (field_type) - { - case FIELD_BOOLEAN: - found = autocomplete_param_with_func(input, split[0], prefs_autocomplete_boolean_choice, previous, NULL); - break; - case FIELD_LIST_SINGLE: - found = autocomplete_param_with_ac(input, split[0], value_ac, TRUE, previous); - break; - case FIELD_LIST_MULTI: - case FIELD_JID_MULTI: - case FIELD_TEXT_MULTI: - found = autocomplete_param_with_ac(input, split[0], form_field_multi_ac, TRUE, previous); - break; - default: - break; + Autocomplete value_ac = form_get_value_ac(form, field_tag); + ; + + switch (field_type) { + case FIELD_BOOLEAN: + found = autocomplete_param_with_func(input, split[0], prefs_autocomplete_boolean_choice, previous, NULL); + break; + case FIELD_LIST_SINGLE: + found = autocomplete_param_with_ac(input, split[0], value_ac, TRUE, previous); + break; + case FIELD_LIST_MULTI: + case FIELD_JID_MULTI: + case FIELD_TEXT_MULTI: + found = autocomplete_param_with_ac(input, split[0], form_field_multi_ac, TRUE, previous); + break; + default: + break; } } } @@ -2951,9 +2952,9 @@ _form_field_autocomplete(ProfWin *window, const char *const input, gboolean prev } static char* -_occupants_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_occupants_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *found = NULL; + char* found = NULL; found = autocomplete_param_with_ac(input, "/occupants default show", occupants_show_ac, TRUE, previous); if (found) { @@ -3014,9 +3015,9 @@ _occupants_autocomplete(ProfWin *window, const char *const input, gboolean previ } static char* -_time_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_time_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *found = NULL; + char* found = NULL; found = autocomplete_param_with_ac(input, "/time statusbar", time_format_ac, TRUE, previous); if (found) { @@ -3072,58 +3073,58 @@ _time_autocomplete(ProfWin *window, const char *const input, gboolean previous) } static char* -_kick_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_kick_autocomplete(ProfWin* window, const char* const input, gboolean previous) { if (window->type != WIN_MUC) { return NULL; } - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); Autocomplete nick_ac = muc_roster_ac(mucwin->roomjid); if (nick_ac == NULL) { return NULL; } - char *result = autocomplete_param_with_ac(input, "/kick", nick_ac, TRUE, previous); + char* result = autocomplete_param_with_ac(input, "/kick", nick_ac, TRUE, previous); return result; } static char* -_ban_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_ban_autocomplete(ProfWin* window, const char* const input, gboolean previous) { if (window->type != WIN_MUC) { return NULL; } - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); Autocomplete jid_ac = muc_roster_jid_ac(mucwin->roomjid); if (jid_ac == NULL) { return NULL; } - char *result = autocomplete_param_with_ac(input, "/ban", jid_ac, TRUE, previous); + char* result = autocomplete_param_with_ac(input, "/ban", jid_ac, TRUE, previous); return result; } static char* -_affiliation_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_affiliation_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *result = NULL; + char* result = NULL; if (window->type == WIN_MUC) { - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); gboolean parse_result; Autocomplete jid_ac = muc_roster_jid_ac(mucwin->roomjid); - gchar **args = parse_args(input, 2, 3, &parse_result); + gchar** args = parse_args(input, 2, 3, &parse_result); if ((strncmp(input, "/affiliation", 12) == 0) && (parse_result == TRUE)) { - GString *beginning = g_string_new("/affiliation "); + GString* beginning = g_string_new("/affiliation "); g_string_append(beginning, args[0]); g_string_append(beginning, " "); if (args[1]) { @@ -3160,20 +3161,20 @@ _affiliation_autocomplete(ProfWin *window, const char *const input, gboolean pre } static char* -_role_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_role_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *result = NULL; + char* result = NULL; if (window->type == WIN_MUC) { - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); gboolean parse_result; Autocomplete nick_ac = muc_roster_ac(mucwin->roomjid); - gchar **args = parse_args(input, 2, 3, &parse_result); + gchar** args = parse_args(input, 2, 3, &parse_result); if ((strncmp(input, "/role", 5) == 0) && (parse_result == TRUE)) { - GString *beginning = g_string_new("/role "); + GString* beginning = g_string_new("/role "); g_string_append(beginning, args[0]); g_string_append(beginning, " "); if (args[1]) { @@ -3210,9 +3211,9 @@ _role_autocomplete(ProfWin *window, const char *const input, gboolean previous) } static char* -_wins_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_wins_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *result = NULL; + char* result = NULL; result = autocomplete_param_with_ac(input, "/wins", wins_ac, TRUE, previous); if (result) { @@ -3223,9 +3224,9 @@ _wins_autocomplete(ProfWin *window, const char *const input, gboolean previous) } static char* -_tls_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_tls_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *result = NULL; + char* result = NULL; result = autocomplete_param_with_func(input, "/tls revoke", tlscerts_complete, previous, NULL); if (result) { @@ -3251,9 +3252,9 @@ _tls_autocomplete(ProfWin *window, const char *const input, gboolean previous) } static char* -_titlebar_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_titlebar_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *result = NULL; + char* result = NULL; result = autocomplete_param_with_ac(input, "/titlebar show", titlebar_show_ac, TRUE, previous); if (result) { @@ -3274,9 +3275,9 @@ _titlebar_autocomplete(ProfWin *window, const char *const input, gboolean previo } static char* -_receipts_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_receipts_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *result = NULL; + char* result = NULL; result = autocomplete_param_with_func(input, "/receipts send", prefs_autocomplete_boolean_choice, previous, NULL); if (result) { @@ -3297,9 +3298,9 @@ _receipts_autocomplete(ProfWin *window, const char *const input, gboolean previo } static char* -_alias_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_alias_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *result = NULL; + char* result = NULL; result = autocomplete_param_with_ac(input, "/alias remove", aliases_ac, TRUE, previous); if (result) { @@ -3315,18 +3316,18 @@ _alias_autocomplete(ProfWin *window, const char *const input, gboolean previous) } static char* -_connect_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_connect_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *found = NULL; + char* found = NULL; gboolean result = FALSE; - gchar **args = parse_args(input, 1, 9, &result); + gchar** args = parse_args(input, 1, 9, &result); if (result) { gboolean space_at_end = g_str_has_suffix(input, " "); int num_args = g_strv_length(args); if ((num_args == 1 && space_at_end) || (num_args == 2 && !space_at_end)) { - GString *beginning = g_string_new("/connect"); + GString* beginning = g_string_new("/connect"); g_string_append_printf(beginning, " %s", args[0]); found = autocomplete_param_with_ac(input, beginning->str, connect_property_ac, TRUE, previous); g_string_free(beginning, TRUE); @@ -3336,8 +3337,8 @@ _connect_autocomplete(ProfWin *window, const char *const input, gboolean previou } } if ((num_args == 2 && space_at_end && (g_strcmp0(args[1], "tls") == 0)) - || (num_args == 3 && (g_strcmp0(args[1], "tls") == 0) && !space_at_end)) { - GString *beginning = g_string_new("/connect"); + || (num_args == 3 && (g_strcmp0(args[1], "tls") == 0) && !space_at_end)) { + GString* beginning = g_string_new("/connect"); g_string_append_printf(beginning, " %s %s", args[0], args[1]); found = autocomplete_param_with_ac(input, beginning->str, tls_property_ac, TRUE, previous); g_string_free(beginning, TRUE); @@ -3347,7 +3348,7 @@ _connect_autocomplete(ProfWin *window, const char *const input, gboolean previou } } if ((num_args == 3 && space_at_end) || (num_args == 4 && !space_at_end)) { - GString *beginning = g_string_new("/connect"); + GString* beginning = g_string_new("/connect"); g_string_append_printf(beginning, " %s %s %s", args[0], args[1], args[2]); found = autocomplete_param_with_ac(input, beginning->str, connect_property_ac, TRUE, previous); g_string_free(beginning, TRUE); @@ -3357,8 +3358,8 @@ _connect_autocomplete(ProfWin *window, const char *const input, gboolean previou } } if ((num_args == 4 && space_at_end && (g_strcmp0(args[3], "tls") == 0)) - || (num_args == 5 && (g_strcmp0(args[3], "tls") == 0) && !space_at_end)) { - GString *beginning = g_string_new("/connect"); + || (num_args == 5 && (g_strcmp0(args[3], "tls") == 0) && !space_at_end)) { + GString* beginning = g_string_new("/connect"); g_string_append_printf(beginning, " %s %s %s %s", args[0], args[1], args[2], args[3]); found = autocomplete_param_with_ac(input, beginning->str, tls_property_ac, TRUE, previous); g_string_free(beginning, TRUE); @@ -3368,7 +3369,7 @@ _connect_autocomplete(ProfWin *window, const char *const input, gboolean previou } } if ((num_args == 5 && space_at_end) || (num_args == 6 && !space_at_end)) { - GString *beginning = g_string_new("/connect"); + GString* beginning = g_string_new("/connect"); g_string_append_printf(beginning, " %s %s %s %s %s", args[0], args[1], args[2], args[3], args[4]); found = autocomplete_param_with_ac(input, beginning->str, connect_property_ac, TRUE, previous); g_string_free(beginning, TRUE); @@ -3378,8 +3379,8 @@ _connect_autocomplete(ProfWin *window, const char *const input, gboolean previou } } if ((num_args == 6 && space_at_end && (g_strcmp0(args[5], "tls") == 0)) - || (num_args == 7 && (g_strcmp0(args[5], "tls") == 0) && !space_at_end)) { - GString *beginning = g_string_new("/connect"); + || (num_args == 7 && (g_strcmp0(args[5], "tls") == 0) && !space_at_end)) { + GString* beginning = g_string_new("/connect"); g_string_append_printf(beginning, " %s %s %s %s %s %s", args[0], args[1], args[2], args[3], args[4], args[5]); found = autocomplete_param_with_ac(input, beginning->str, tls_property_ac, TRUE, previous); g_string_free(beginning, TRUE); @@ -3389,7 +3390,7 @@ _connect_autocomplete(ProfWin *window, const char *const input, gboolean previou } } if ((num_args == 7 && space_at_end) || (num_args == 8 && !space_at_end)) { - GString *beginning = g_string_new("/connect"); + GString* beginning = g_string_new("/connect"); g_string_append_printf(beginning, " %s %s %s %s %s %s %s", args[0], args[1], args[2], args[3], args[4], args[5], args[6]); found = autocomplete_param_with_ac(input, beginning->str, connect_property_ac, TRUE, previous); g_string_free(beginning, TRUE); @@ -3399,8 +3400,8 @@ _connect_autocomplete(ProfWin *window, const char *const input, gboolean previou } } if ((num_args == 8 && space_at_end && (g_strcmp0(args[7], "tls") == 0)) - || (num_args == 9 && (g_strcmp0(args[7], "tls") == 0) && !space_at_end)) { - GString *beginning = g_string_new("/connect"); + || (num_args == 9 && (g_strcmp0(args[7], "tls") == 0) && !space_at_end)) { + GString* beginning = g_string_new("/connect"); g_string_append_printf(beginning, " %s %s %s %s %s %s %s %s", args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]); found = autocomplete_param_with_ac(input, beginning->str, tls_property_ac, TRUE, previous); g_string_free(beginning, TRUE); @@ -3413,8 +3414,8 @@ _connect_autocomplete(ProfWin *window, const char *const input, gboolean previou /* auth option */ if ((num_args == 2 && space_at_end && (g_strcmp0(args[1], "auth") == 0)) - || (num_args == 3 && (g_strcmp0(args[1], "auth") == 0) && !space_at_end)) { - GString *beginning = g_string_new("/connect"); + || (num_args == 3 && (g_strcmp0(args[1], "auth") == 0) && !space_at_end)) { + GString* beginning = g_string_new("/connect"); g_string_append_printf(beginning, " %s %s", args[0], args[1]); found = autocomplete_param_with_ac(input, beginning->str, auth_property_ac, TRUE, previous); g_string_free(beginning, TRUE); @@ -3424,8 +3425,8 @@ _connect_autocomplete(ProfWin *window, const char *const input, gboolean previou } } if ((num_args == 4 && space_at_end && (g_strcmp0(args[3], "auth") == 0)) - || (num_args == 5 && (g_strcmp0(args[3], "auth") == 0) && !space_at_end)) { - GString *beginning = g_string_new("/connect"); + || (num_args == 5 && (g_strcmp0(args[3], "auth") == 0) && !space_at_end)) { + GString* beginning = g_string_new("/connect"); g_string_append_printf(beginning, " %s %s %s %s", args[0], args[1], args[2], args[3]); found = autocomplete_param_with_ac(input, beginning->str, auth_property_ac, TRUE, previous); g_string_free(beginning, TRUE); @@ -3435,8 +3436,8 @@ _connect_autocomplete(ProfWin *window, const char *const input, gboolean previou } } if ((num_args == 6 && space_at_end && (g_strcmp0(args[5], "auth") == 0)) - || (num_args == 7 && (g_strcmp0(args[5], "auth") == 0) && !space_at_end)) { - GString *beginning = g_string_new("/connect"); + || (num_args == 7 && (g_strcmp0(args[5], "auth") == 0) && !space_at_end)) { + GString* beginning = g_string_new("/connect"); g_string_append_printf(beginning, " %s %s %s %s %s %s", args[0], args[1], args[2], args[3], args[4], args[5]); found = autocomplete_param_with_ac(input, beginning->str, auth_property_ac, TRUE, previous); g_string_free(beginning, TRUE); @@ -3446,8 +3447,8 @@ _connect_autocomplete(ProfWin *window, const char *const input, gboolean previou } } if ((num_args == 8 && space_at_end && (g_strcmp0(args[7], "auth") == 0)) - || (num_args == 9 && (g_strcmp0(args[7], "auth") == 0) && !space_at_end)) { - GString *beginning = g_string_new("/connect"); + || (num_args == 9 && (g_strcmp0(args[7], "auth") == 0) && !space_at_end)) { + GString* beginning = g_string_new("/connect"); g_string_append_printf(beginning, " %s %s %s %s %s %s %s %s", args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]); found = autocomplete_param_with_ac(input, beginning->str, auth_property_ac, TRUE, previous); g_string_free(beginning, TRUE); @@ -3469,9 +3470,9 @@ _connect_autocomplete(ProfWin *window, const char *const input, gboolean previou } static char* -_help_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_help_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *result = NULL; + char* result = NULL; result = autocomplete_param_with_ac(input, "/help commands", help_commands_ac, TRUE, previous); if (result) { @@ -3487,18 +3488,18 @@ _help_autocomplete(ProfWin *window, const char *const input, gboolean previous) } static char* -_join_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_join_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *found = NULL; + char* found = NULL; gboolean result = FALSE; - gchar **args = parse_args(input, 1, 5, &result); + gchar** args = parse_args(input, 1, 5, &result); if (result) { gboolean space_at_end = g_str_has_suffix(input, " "); int num_args = g_strv_length(args); if ((num_args == 1 && space_at_end) || (num_args == 2 && !space_at_end)) { - GString *beginning = g_string_new("/join"); + GString* beginning = g_string_new("/join"); g_string_append_printf(beginning, " %s", args[0]); found = autocomplete_param_with_ac(input, beginning->str, join_property_ac, TRUE, previous); g_string_free(beginning, TRUE); @@ -3508,7 +3509,7 @@ _join_autocomplete(ProfWin *window, const char *const input, gboolean previous) } } if ((num_args == 3 && space_at_end) || (num_args == 4 && !space_at_end)) { - GString *beginning = g_string_new("/join"); + GString* beginning = g_string_new("/join"); g_string_append_printf(beginning, " %s %s %s", args[0], args[1], args[2]); found = autocomplete_param_with_ac(input, beginning->str, join_property_ac, TRUE, previous); g_string_free(beginning, TRUE); @@ -3530,9 +3531,9 @@ _join_autocomplete(ProfWin *window, const char *const input, gboolean previous) } static char* -_console_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_console_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *result = NULL; + char* result = NULL; result = autocomplete_param_with_ac(input, "/console chat", console_msg_ac, TRUE, previous); if (result) { @@ -3556,41 +3557,41 @@ _console_autocomplete(ProfWin *window, const char *const input, gboolean previou } static char* -_win_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_win_autocomplete(ProfWin* window, const char* const input, gboolean previous) { return autocomplete_param_with_func(input, "/win", win_autocomplete, previous, NULL); } static char* -_close_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_close_autocomplete(ProfWin* window, const char* const input, gboolean previous) { return autocomplete_param_with_func(input, "/close", win_close_autocomplete, previous, NULL); } static char* -_sendfile_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_sendfile_autocomplete(ProfWin* window, const char* const input, gboolean previous) { return cmd_ac_complete_filepath(input, "/sendfile", previous); } static char* -_subject_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_subject_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *result = NULL; + char* result = NULL; if (window->type == WIN_MUC) { if ((g_strcmp0(input, "/subject e") == 0) - || (g_strcmp0(input, "/subject ed") == 0) - || (g_strcmp0(input, "/subject edi") == 0) - || (g_strcmp0(input, "/subject edit") == 0) - || (g_strcmp0(input, "/subject edit ") == 0) - || (g_strcmp0(input, "/subject edit \"") == 0)) { - ProfMucWin *mucwin = (ProfMucWin*)window; + || (g_strcmp0(input, "/subject ed") == 0) + || (g_strcmp0(input, "/subject edi") == 0) + || (g_strcmp0(input, "/subject edit") == 0) + || (g_strcmp0(input, "/subject edit ") == 0) + || (g_strcmp0(input, "/subject edit \"") == 0)) { + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); - char *subject = muc_subject(mucwin->roomjid); + char* subject = muc_subject(mucwin->roomjid); if (subject) { - GString *result_str = g_string_new("/subject edit \""); + GString* result_str = g_string_new("/subject edit \""); g_string_append(result_str, subject); g_string_append(result_str, "\""); @@ -3612,17 +3613,17 @@ _subject_autocomplete(ProfWin *window, const char *const input, gboolean previou } static char* -_account_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_account_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *found = NULL; + char* found = NULL; gboolean result = FALSE; - gchar **args = parse_args(input, 2, 4, &result); + gchar** args = parse_args(input, 2, 4, &result); if (result && (strcmp(args[0], "set") == 0)) { gboolean space_at_end = g_str_has_suffix(input, " "); int num_args = g_strv_length(args); if ((num_args == 2 && space_at_end) || (num_args == 3 && !space_at_end)) { - GString *beginning = g_string_new("/account"); + GString* beginning = g_string_new("/account"); g_string_append_printf(beginning, " %s %s", args[0], args[1]); found = autocomplete_param_with_ac(input, beginning->str, account_set_ac, TRUE, previous); g_string_free(beginning, TRUE); @@ -3633,8 +3634,8 @@ _account_autocomplete(ProfWin *window, const char *const input, gboolean previou } #ifdef HAVE_LIBOTR if ((num_args == 3 && space_at_end && (g_strcmp0(args[2], "otr") == 0)) - || (num_args == 4 && (g_strcmp0(args[2], "otr") == 0) && !space_at_end)) { - GString *beginning = g_string_new("/account"); + || (num_args == 4 && (g_strcmp0(args[2], "otr") == 0) && !space_at_end)) { + GString* beginning = g_string_new("/account"); g_string_append_printf(beginning, " %s %s %s", args[0], args[1], args[2]); found = autocomplete_param_with_ac(input, beginning->str, otr_policy_ac, TRUE, previous); g_string_free(beginning, TRUE); @@ -3645,8 +3646,8 @@ _account_autocomplete(ProfWin *window, const char *const input, gboolean previou } #endif if ((num_args == 3 && space_at_end && (g_strcmp0(args[2], "status") == 0)) - || (num_args == 4 && (g_strcmp0(args[2], "status") == 0) && !space_at_end)) { - GString *beginning = g_string_new("/account"); + || (num_args == 4 && (g_strcmp0(args[2], "status") == 0) && !space_at_end)) { + GString* beginning = g_string_new("/account"); g_string_append_printf(beginning, " %s %s %s", args[0], args[1], args[2]); found = autocomplete_param_with_ac(input, beginning->str, account_status_ac, TRUE, previous); g_string_free(beginning, TRUE); @@ -3656,8 +3657,8 @@ _account_autocomplete(ProfWin *window, const char *const input, gboolean previou } } if ((num_args == 3 && space_at_end && (g_strcmp0(args[2], "tls") == 0)) - || (num_args == 4 && (g_strcmp0(args[2], "tls") == 0) && !space_at_end)) { - GString *beginning = g_string_new("/account"); + || (num_args == 4 && (g_strcmp0(args[2], "tls") == 0) && !space_at_end)) { + GString* beginning = g_string_new("/account"); g_string_append_printf(beginning, " %s %s %s", args[0], args[1], args[2]); found = autocomplete_param_with_ac(input, beginning->str, tls_property_ac, TRUE, previous); g_string_free(beginning, TRUE); @@ -3667,8 +3668,8 @@ _account_autocomplete(ProfWin *window, const char *const input, gboolean previou } } if ((num_args == 3 && space_at_end && (g_strcmp0(args[2], "auth") == 0)) - || (num_args == 4 && (g_strcmp0(args[2], "auth") == 0) && !space_at_end)) { - GString *beginning = g_string_new("/account"); + || (num_args == 4 && (g_strcmp0(args[2], "auth") == 0) && !space_at_end)) { + GString* beginning = g_string_new("/account"); g_string_append_printf(beginning, " %s %s %s", args[0], args[1], args[2]); found = autocomplete_param_with_ac(input, beginning->str, auth_property_ac, TRUE, previous); g_string_free(beginning, TRUE); @@ -3678,8 +3679,8 @@ _account_autocomplete(ProfWin *window, const char *const input, gboolean previou } } if ((num_args == 3 && space_at_end && (g_strcmp0(args[2], "startscript") == 0)) - || (num_args == 4 && (g_strcmp0(args[2], "startscript") == 0) && !space_at_end)) { - GString *beginning = g_string_new("/account"); + || (num_args == 4 && (g_strcmp0(args[2], "startscript") == 0) && !space_at_end)) { + GString* beginning = g_string_new("/account"); g_string_append_printf(beginning, " %s %s %s", args[0], args[1], args[2]); found = autocomplete_param_with_func(input, beginning->str, _script_autocomplete_func, previous, NULL); g_string_free(beginning, TRUE); @@ -3689,13 +3690,13 @@ _account_autocomplete(ProfWin *window, const char *const input, gboolean previou } } if ((num_args == 3 && space_at_end && (g_strcmp0(args[2], "theme") == 0)) - || (num_args == 4 && (g_strcmp0(args[2], "theme") == 0) && !space_at_end)) { - GString *beginning = g_string_new("/account"); + || (num_args == 4 && (g_strcmp0(args[2], "theme") == 0) && !space_at_end)) { + GString* beginning = g_string_new("/account"); g_string_append_printf(beginning, " %s %s %s", args[0], args[1], args[2]); if (theme_load_ac == NULL) { theme_load_ac = autocomplete_new(); - GSList *themes = theme_list(); - GSList *curr = themes; + GSList* themes = theme_list(); + GSList* curr = themes; while (curr) { autocomplete_add(theme_load_ac, curr->data); curr = g_slist_next(curr); @@ -3712,8 +3713,8 @@ _account_autocomplete(ProfWin *window, const char *const input, gboolean previou } #ifdef HAVE_LIBGPGME if ((num_args == 3 && space_at_end && (g_strcmp0(args[2], "pgpkeyid") == 0)) - || (num_args == 4 && (g_strcmp0(args[2], "pgpkeyid") == 0) && !space_at_end)) { - GString *beginning = g_string_new("/account"); + || (num_args == 4 && (g_strcmp0(args[2], "pgpkeyid") == 0) && !space_at_end)) { + GString* beginning = g_string_new("/account"); g_string_append_printf(beginning, " %s %s %s", args[0], args[1], args[2]); found = autocomplete_param_with_func(input, beginning->str, p_gpg_autocomplete_key, previous, NULL); g_string_free(beginning, TRUE); @@ -3726,7 +3727,7 @@ _account_autocomplete(ProfWin *window, const char *const input, gboolean previou } if ((strncmp(input, "/account clear", 14) == 0) && (result == TRUE)) { - GString *beginning = g_string_new("/account clear "); + GString* beginning = g_string_new("/account clear "); g_string_append(beginning, args[1]); found = autocomplete_param_with_ac(input, beginning->str, account_clear_ac, TRUE, previous); g_string_free(beginning, TRUE); @@ -3739,14 +3740,14 @@ _account_autocomplete(ProfWin *window, const char *const input, gboolean previou g_strfreev(args); found = autocomplete_param_with_ac(input, "/account default", account_default_ac, TRUE, previous); - if(found){ + if (found) { return found; } int i = 0; - gchar *account_choice[] = { "/account set", "/account show", "/account enable", - "/account disable", "/account rename", "/account clear", "/account remove", - "/account default set" }; + gchar* account_choice[] = { "/account set", "/account show", "/account enable", + "/account disable", "/account rename", "/account clear", "/account remove", + "/account default set" }; for (i = 0; i < ARRAY_SIZE(account_choice); i++) { found = autocomplete_param_with_func(input, account_choice[i], accounts_find_all, previous, NULL); @@ -3760,9 +3761,9 @@ _account_autocomplete(ProfWin *window, const char *const input, gboolean previou } static char* -_presence_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_presence_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *found = NULL; + char* found = NULL; found = autocomplete_param_with_func(input, "/presence titlebar", prefs_autocomplete_boolean_choice, previous, NULL); if (found) { @@ -3793,12 +3794,12 @@ _presence_autocomplete(ProfWin *window, const char *const input, gboolean previo } static char* -_rooms_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_rooms_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *found = NULL; + char* found = NULL; gboolean result = FALSE; - gchar **args = parse_args(input, 0, 4, &result); + gchar** args = parse_args(input, 0, 4, &result); if (result) { gboolean space_at_end = g_str_has_suffix(input, " "); @@ -3810,16 +3811,14 @@ _rooms_autocomplete(ProfWin *window, const char *const input, gboolean previous) return found; } } - if ((num_args == 1 && g_strcmp0(args[0], "service") == 0 && space_at_end) || - (num_args == 2 && g_strcmp0(args[0], "service") == 0 && !space_at_end)) { + if ((num_args == 1 && g_strcmp0(args[0], "service") == 0 && space_at_end) || (num_args == 2 && g_strcmp0(args[0], "service") == 0 && !space_at_end)) { found = autocomplete_param_with_func(input, "/rooms service", muc_confserver_find, previous, NULL); if (found) { g_strfreev(args); return found; } } - if ((num_args == 1 && g_strcmp0(args[0], "cache") == 0 && space_at_end) || - (num_args == 2 && g_strcmp0(args[0], "cache") == 0 && !space_at_end)) { + if ((num_args == 1 && g_strcmp0(args[0], "cache") == 0 && space_at_end) || (num_args == 2 && g_strcmp0(args[0], "cache") == 0 && !space_at_end)) { found = autocomplete_param_with_ac(input, "/rooms cache", rooms_cache_ac, TRUE, previous); if (found) { g_strfreev(args); @@ -3827,7 +3826,7 @@ _rooms_autocomplete(ProfWin *window, const char *const input, gboolean previous) } } if ((num_args == 2 && space_at_end) || (num_args == 3 && !space_at_end)) { - GString *beginning = g_string_new("/rooms"); + GString* beginning = g_string_new("/rooms"); g_string_append_printf(beginning, " %s %s", args[0], args[1]); found = autocomplete_param_with_ac(input, beginning->str, rooms_list_ac, TRUE, previous); g_string_free(beginning, TRUE); @@ -3836,9 +3835,8 @@ _rooms_autocomplete(ProfWin *window, const char *const input, gboolean previous) return found; } } - if ((num_args == 3 && g_strcmp0(args[2], "service") == 0 && space_at_end) || - (num_args == 4 && g_strcmp0(args[2], "service") == 0 && !space_at_end)) { - GString *beginning = g_string_new("/rooms"); + if ((num_args == 3 && g_strcmp0(args[2], "service") == 0 && space_at_end) || (num_args == 4 && g_strcmp0(args[2], "service") == 0 && !space_at_end)) { + GString* beginning = g_string_new("/rooms"); g_string_append_printf(beginning, " %s %s %s", args[0], args[1], args[2]); found = autocomplete_param_with_func(input, beginning->str, muc_confserver_find, previous, NULL); g_string_free(beginning, TRUE); @@ -3859,9 +3857,9 @@ _rooms_autocomplete(ProfWin *window, const char *const input, gboolean previous) } static char* -_statusbar_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_statusbar_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *found = NULL; + char* found = NULL; found = autocomplete_param_with_ac(input, "/statusbar", statusbar_ac, TRUE, previous); if (found) { @@ -3897,9 +3895,9 @@ _statusbar_autocomplete(ProfWin *window, const char *const input, gboolean previ } static char* -_clear_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_clear_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *result = NULL; + char* result = NULL; result = autocomplete_param_with_ac(input, "/clear", clear_ac, TRUE, previous); if (result) { @@ -3915,9 +3913,9 @@ _clear_autocomplete(ProfWin *window, const char *const input, gboolean previous) } static char* -_invite_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_invite_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *result = NULL; + char* result = NULL; result = autocomplete_param_with_ac(input, "/invite", invite_ac, TRUE, previous); if (result) { @@ -3942,9 +3940,9 @@ _invite_autocomplete(ProfWin *window, const char *const input, gboolean previous } static char* -_status_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_status_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *result = NULL; + char* result = NULL; result = autocomplete_param_with_ac(input, "/status", status_ac, TRUE, previous); if (result) { @@ -3962,11 +3960,11 @@ _status_autocomplete(ProfWin *window, const char *const input, gboolean previous } // Remove quote character before and after names when doing autocomplete - char *unquoted = strip_arg_quotes(input); + char* unquoted = strip_arg_quotes(input); // MUC completion with nicknames if (window->type == WIN_MUC) { - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); Autocomplete nick_ac = muc_roster_ac(mucwin->roomjid); if (nick_ac) { @@ -3976,7 +3974,7 @@ _status_autocomplete(ProfWin *window, const char *const input, gboolean previous return result; } } - // roster completion + // roster completion } else { result = autocomplete_param_with_func(unquoted, "/status get", roster_contact_autocomplete, previous, NULL); if (result) { @@ -3992,9 +3990,9 @@ _status_autocomplete(ProfWin *window, const char *const input, gboolean previous } static char* -_logging_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_logging_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *result = NULL; + char* result = NULL; result = autocomplete_param_with_ac(input, "/logging", logging_ac, TRUE, previous); if (result) { @@ -4015,9 +4013,9 @@ _logging_autocomplete(ProfWin *window, const char *const input, gboolean previou } static char* -_color_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_color_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *result = NULL; + char* result = NULL; result = autocomplete_param_with_func(input, "/color own", prefs_autocomplete_boolean_choice, previous, NULL); if (result) { @@ -4033,9 +4031,9 @@ _color_autocomplete(ProfWin *window, const char *const input, gboolean previous) } static char* -_avatar_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_avatar_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *result = NULL; + char* result = NULL; result = autocomplete_param_with_ac(input, "/avatar", avatar_ac, TRUE, previous); if (result) { @@ -4059,9 +4057,9 @@ _avatar_autocomplete(ProfWin *window, const char *const input, gboolean previous } static char* -_correction_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_correction_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *result = NULL; + char* result = NULL; result = autocomplete_param_with_ac(input, "/correction", correction_ac, TRUE, previous); if (result) { @@ -4072,55 +4070,55 @@ _correction_autocomplete(ProfWin *window, const char *const input, gboolean prev } static char* -_correct_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_correct_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *last_message = NULL; - switch(window->type) { - case WIN_CHAT: - { - ProfChatWin *chatwin = (ProfChatWin*)window; - assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); - last_message = chatwin->last_message; - break; - } - case WIN_MUC: - { - ProfMucWin *mucwin = (ProfMucWin*)window; - assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); - last_message = mucwin->last_message; - } - default: - break; - } - - if (last_message == NULL) { - return NULL; - } - - GString *result_str = g_string_new("/correct "); - g_string_append(result_str, last_message); - char *result = result_str->str; - g_string_free(result_str, FALSE); - - return result; + char* last_message = NULL; + switch (window->type) { + case WIN_CHAT: + { + ProfChatWin* chatwin = (ProfChatWin*)window; + assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); + last_message = chatwin->last_message; + break; + } + case WIN_MUC: + { + ProfMucWin* mucwin = (ProfMucWin*)window; + assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); + last_message = mucwin->last_message; + } + default: + break; + } + + if (last_message == NULL) { + return NULL; + } + + GString* result_str = g_string_new("/correct "); + g_string_append(result_str, last_message); + char* result = result_str->str; + g_string_free(result_str, FALSE); + + return result; } static char* -_software_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_software_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *result = NULL; + char* result = NULL; - if (window->type == WIN_CHAT){ - ProfChatWin *chatwin = (ProfChatWin*)window; + if (window->type == WIN_CHAT) { + ProfChatWin* chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); - GString *search_str = g_string_new("/software "); + GString* search_str = g_string_new("/software "); g_string_append(search_str, chatwin->barejid); result = autocomplete_param_with_func(search_str->str, "/software", roster_fulljid_autocomplete, previous, NULL); g_string_free(search_str, TRUE); } else if (window->type == WIN_MUC) { - ProfMucWin *mucwin = (ProfMucWin*)window; - assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); + ProfMucWin* mucwin = (ProfMucWin*)window; + assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); Autocomplete nick_ac = muc_roster_ac(mucwin->roomjid); @@ -4130,29 +4128,27 @@ _software_autocomplete(ProfWin *window, const char *const input, gboolean previo return result; } } - } else { + } else { result = autocomplete_param_with_func(input, "/software", roster_fulljid_autocomplete, previous, NULL); if (result) { return result; } - } + } - return result; + return result; } static char* -_url_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_url_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *result = NULL; + char* result = NULL; result = autocomplete_param_with_ac(input, "/url", url_ac, TRUE, previous); if (result) { return result; } - if (window->type == WIN_CHAT || - window->type == WIN_MUC || - window->type == WIN_PRIVATE) { + if (window->type == WIN_CHAT || window->type == WIN_MUC || window->type == WIN_PRIVATE) { result = autocomplete_param_with_func(input, "/url open", wins_get_url, previous, window); if (result) { return result; @@ -4165,9 +4161,9 @@ _url_autocomplete(ProfWin *window, const char *const input, gboolean previous) } static char* -_executable_autocomplete(ProfWin *window, const char *const input, gboolean previous) +_executable_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - char *result = NULL; + char* result = NULL; result = autocomplete_param_with_ac(input, "/executable", executable_ac, TRUE, previous); if (result) { diff --git a/src/command/cmd_ac.h b/src/command/cmd_ac.h index d6ba3e2a..ef715310 100644 --- a/src/command/cmd_ac.h +++ b/src/command/cmd_ac.h @@ -41,23 +41,23 @@ void cmd_ac_init(void); void cmd_ac_uninit(void); -char* cmd_ac_complete(ProfWin *window, const char *const input, gboolean previous); -void cmd_ac_reset(ProfWin *window); -gboolean cmd_ac_exists(char *cmd); +char* cmd_ac_complete(ProfWin* window, const char* const input, gboolean previous); +void cmd_ac_reset(ProfWin* window); +gboolean cmd_ac_exists(char* cmd); -void cmd_ac_add(const char *const value); -void cmd_ac_add_help(const char *const value); -void cmd_ac_add_cmd(Command *command); -void cmd_ac_add_alias(ProfAlias *alias); -void cmd_ac_add_alias_value(char *value); +void cmd_ac_add(const char* const value); +void cmd_ac_add_help(const char* const value); +void cmd_ac_add_cmd(Command* command); +void cmd_ac_add_alias(ProfAlias* alias); +void cmd_ac_add_alias_value(char* value); -void cmd_ac_remove(const char *const value); -void cmd_ac_remove_help(const char *const value); -void cmd_ac_remove_alias_value(char *value); +void cmd_ac_remove(const char* const value); +void cmd_ac_remove_help(const char* const value); +void cmd_ac_remove_alias_value(char* value); -void cmd_ac_add_form_fields(DataForm *form); -void cmd_ac_remove_form_fields(DataForm *form); +void cmd_ac_add_form_fields(DataForm* form); +void cmd_ac_remove_form_fields(DataForm* form); -char* cmd_ac_complete_filepath(const char *const input, char *const startstr, gboolean previous); +char* cmd_ac_complete_filepath(const char* const input, char* const startstr, gboolean previous); #endif diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index 48cbc80d..04adb92d 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -82,2482 +82,2394 @@ #include "pgp/gpg.h" #endif -#define CMD_TAG_CHAT "chat" -#define CMD_TAG_GROUPCHAT "groupchat" -#define CMD_TAG_ROSTER "roster" -#define CMD_TAG_PRESENCE "presence" -#define CMD_TAG_CONNECTION "connection" -#define CMD_TAG_DISCOVERY "discovery" -#define CMD_TAG_UI "ui" -#define CMD_TAG_PLUGINS "plugins" - -#define CMD_MAINFUNC(func) func, -#define CMD_NOMAINFUNC NULL, -#define CMD_SUBFUNCS(...) { __VA_ARGS__, { NULL, NULL } }, -#define CMD_NOSUBFUNCS { { NULL, NULL } }, - -#define CMD_NOTAGS { { NULL }, -#define CMD_TAGS(...) { { __VA_ARGS__, NULL }, -#define CMD_SYN(...) { __VA_ARGS__, NULL }, -#define CMD_DESC(desc) desc, -#define CMD_NOARGS { { NULL, NULL } }, -#define CMD_ARGS(...) { __VA_ARGS__, { NULL, NULL } }, -#define CMD_NOEXAMPLES { NULL } } -#define CMD_EXAMPLES(...) { __VA_ARGS__, NULL } } - -GHashTable *commands = NULL; - -static gboolean _cmd_has_tag(Command *pcmd, const char *const tag); +#define CMD_TAG_CHAT "chat" +#define CMD_TAG_GROUPCHAT "groupchat" +#define CMD_TAG_ROSTER "roster" +#define CMD_TAG_PRESENCE "presence" +#define CMD_TAG_CONNECTION "connection" +#define CMD_TAG_DISCOVERY "discovery" +#define CMD_TAG_UI "ui" +#define CMD_TAG_PLUGINS "plugins" + +#define CMD_MAINFUNC(func) func, +#define CMD_NOMAINFUNC NULL, +#define CMD_SUBFUNCS(...) { __VA_ARGS__, { NULL, NULL } }, +#define CMD_NOSUBFUNCS { { NULL, NULL } }, + +#define CMD_NOTAGS \ + { \ + { NULL }, +#define CMD_TAGS(...) \ + { \ + { __VA_ARGS__, NULL }, +#define CMD_SYN(...) { __VA_ARGS__, NULL }, +#define CMD_DESC(desc) desc, +#define CMD_NOARGS { { NULL, NULL } }, +#define CMD_ARGS(...) { __VA_ARGS__, { NULL, NULL } }, +#define CMD_NOEXAMPLES \ + { \ + NULL \ + } \ + } +#define CMD_EXAMPLES(...) \ + { \ + __VA_ARGS__, NULL \ + } \ + } + +GHashTable* commands = NULL; + +static gboolean _cmd_has_tag(Command* pcmd, const char* const tag); /* * Command list */ -static struct cmd_t command_defs[] = -{ +static struct cmd_t command_defs[] = { { "/help", - parse_args_with_freetext, 0, 2, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_help) - CMD_NOTAGS - CMD_SYN( - "/help [<area>|<command>|search_all|search_any] [<search_terms>]") - CMD_DESC( - "Help on using Profanity. Passing no arguments list help areas. " - "For command help, optional arguments are shown using square brackets, " - "arguments representing variables rather than a literal name are surrounded by angle brackets. " - "Arguments that may be one of a number of values are separated by a pipe " - "e.g. val1|val2|val3.") - CMD_ARGS( - { "<area>", "Summary help for commands in a certain area of functionality." }, - { "<command>", "Full help for a specific command, for example '/help connect'." }, - { "search_all <search_terms>", "Search commands for returning matches that contain all of the search terms." }, - { "search_any <search_terms>", "Search commands for returning matches that contain any of the search terms." }) - CMD_EXAMPLES( - "/help search_all presence online", - "/help commands", - "/help presence", - "/help who") - }, + parse_args_with_freetext, 0, 2, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_help) + CMD_NOTAGS + CMD_SYN( + "/help [<area>|<command>|search_all|search_any] [<search_terms>]") + CMD_DESC( + "Help on using Profanity. Passing no arguments list help areas. " + "For command help, optional arguments are shown using square brackets, " + "arguments representing variables rather than a literal name are surrounded by angle brackets. " + "Arguments that may be one of a number of values are separated by a pipe " + "e.g. val1|val2|val3.") + CMD_ARGS( + { "<area>", "Summary help for commands in a certain area of functionality." }, + { "<command>", "Full help for a specific command, for example '/help connect'." }, + { "search_all <search_terms>", "Search commands for returning matches that contain all of the search terms." }, + { "search_any <search_terms>", "Search commands for returning matches that contain any of the search terms." }) + CMD_EXAMPLES( + "/help search_all presence online", + "/help commands", + "/help presence", + "/help who") }, { "/about", - parse_args, 0, 0, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_about) - CMD_NOTAGS - CMD_SYN( - "/about") - CMD_DESC( - "Show version and license information.") - CMD_NOARGS - CMD_NOEXAMPLES - }, + parse_args, 0, 0, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_about) + CMD_NOTAGS + CMD_SYN( + "/about") + CMD_DESC( + "Show version and license information.") + CMD_NOARGS + CMD_NOEXAMPLES }, { "/connect", - parse_args, 0, 7, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_connect) - CMD_TAGS( - CMD_TAG_CONNECTION) - CMD_SYN( - "/connect [<account>]", - "/connect <account> [server <server>] [port <port>] [tls force|allow|trust|legacy|disable] [auth default|legacy]") - CMD_DESC( - "Login to a chat service. " - "If no account is specified, the default is used if one is configured. " - "A local account is created with the JID as it's name if it doesn't already exist.") - CMD_ARGS( - { "<account>", "The local account you wish to connect with, or a JID if connecting for the first time." }, - { "server <server>", "Supply a server if it is different to the domain part of your JID." }, - { "port <port>", "The port to use if different to the default (5222, or 5223 for SSL)." }, - { "tls force", "Force TLS connection, and fail if one cannot be established, this is default behaviour." }, - { "tls allow", "Use TLS for the connection if it is available." }, - { "tls trust", "Force TLS connection and trust server's certificate." }, - { "tls legacy", "Use legacy TLS for the connection. It means server doesn't support STARTTLS and TLS is forced just after TCP connection is established." }, - { "tls disable", "Disable TLS for the connection." }, - { "auth default", "Default authentication process." }, - { "auth legacy", "Allow legacy authentication." }) - CMD_EXAMPLES( - "/connect", - "/connect odin@valhalla.edda", - "/connect odin@valhalla.edda server talk.google.com", - "/connect freyr@vanaheimr.edda port 5678", - "/connect me@localhost.test.org server 127.0.0.1 tls disable", - "/connect me@chatty server chatty.com port 5443") - }, + parse_args, 0, 7, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_connect) + CMD_TAGS( + CMD_TAG_CONNECTION) + CMD_SYN( + "/connect [<account>]", + "/connect <account> [server <server>] [port <port>] [tls force|allow|trust|legacy|disable] [auth default|legacy]") + CMD_DESC( + "Login to a chat service. " + "If no account is specified, the default is used if one is configured. " + "A local account is created with the JID as it's name if it doesn't already exist.") + CMD_ARGS( + { "<account>", "The local account you wish to connect with, or a JID if connecting for the first time." }, + { "server <server>", "Supply a server if it is different to the domain part of your JID." }, + { "port <port>", "The port to use if different to the default (5222, or 5223 for SSL)." }, + { "tls force", "Force TLS connection, and fail if one cannot be established, this is default behaviour." }, + { "tls allow", "Use TLS for the connection if it is available." }, + { "tls trust", "Force TLS connection and trust server's certificate." }, + { "tls legacy", "Use legacy TLS for the connection. It means server doesn't support STARTTLS and TLS is forced just after TCP connection is established." }, + { "tls disable", "Disable TLS for the connection." }, + { "auth default", "Default authentication process." }, + { "auth legacy", "Allow legacy authentication." }) + CMD_EXAMPLES( + "/connect", + "/connect odin@valhalla.edda", + "/connect odin@valhalla.edda server talk.google.com", + "/connect freyr@vanaheimr.edda port 5678", + "/connect me@localhost.test.org server 127.0.0.1 tls disable", + "/connect me@chatty server chatty.com port 5443") }, { "/tls", - parse_args, 1, 3, NULL, - CMD_SUBFUNCS( - { "certpath", cmd_tls_certpath }, - { "trust", cmd_tls_trust }, - { "trusted", cmd_tls_trusted }, - { "revoke", cmd_tls_revoke }, - { "cert", cmd_tls_cert }) - CMD_NOMAINFUNC - CMD_TAGS( - CMD_TAG_CONNECTION, - CMD_TAG_UI) - CMD_SYN( - "/tls allow", - "/tls always", - "/tls deny", - "/tls cert [<fingerprint>]", - "/tls trust", - "/tls trusted", - "/tls revoke <fingerprint>", - "/tls certpath", - "/tls certpath set <path>", - "/tls certpath clear", - "/tls certpath default") - CMD_DESC( - "Handle TLS certificates. ") - CMD_ARGS( - { "allow", "Allow connection to continue with TLS certificate." }, - { "always", "Always allow connections with TLS certificate." }, - { "deny", "Abort connection." }, - { "cert", "Show the current TLS certificate." }, - { "cert <fingerprint>", "Show details of trusted certificate." }, - { "trust", "Add the current TLS certificate to manually trusted certificates." }, - { "trusted", "List summary of manually trusted certificates (with '/tls always' or '/tls trust')." }, - { "revoke <fingerprint>", "Remove a manually trusted certificate." }, - { "certpath", "Show the trusted certificate path." }, - { "certpath set <path>", "Specify filesystem path containing trusted certificates." }, - { "certpath clear", "Clear the trusted certificate path." }, - { "certpath default", "Use default system certificate path, if it can be found." }) - CMD_NOEXAMPLES - }, + parse_args, 1, 3, NULL, + CMD_SUBFUNCS( + { "certpath", cmd_tls_certpath }, + { "trust", cmd_tls_trust }, + { "trusted", cmd_tls_trusted }, + { "revoke", cmd_tls_revoke }, + { "cert", cmd_tls_cert }) + CMD_NOMAINFUNC + CMD_TAGS( + CMD_TAG_CONNECTION, + CMD_TAG_UI) + CMD_SYN( + "/tls allow", + "/tls always", + "/tls deny", + "/tls cert [<fingerprint>]", + "/tls trust", + "/tls trusted", + "/tls revoke <fingerprint>", + "/tls certpath", + "/tls certpath set <path>", + "/tls certpath clear", + "/tls certpath default") + CMD_DESC( + "Handle TLS certificates. ") + CMD_ARGS( + { "allow", "Allow connection to continue with TLS certificate." }, + { "always", "Always allow connections with TLS certificate." }, + { "deny", "Abort connection." }, + { "cert", "Show the current TLS certificate." }, + { "cert <fingerprint>", "Show details of trusted certificate." }, + { "trust", "Add the current TLS certificate to manually trusted certificates." }, + { "trusted", "List summary of manually trusted certificates (with '/tls always' or '/tls trust')." }, + { "revoke <fingerprint>", "Remove a manually trusted certificate." }, + { "certpath", "Show the trusted certificate path." }, + { "certpath set <path>", "Specify filesystem path containing trusted certificates." }, + { "certpath clear", "Clear the trusted certificate path." }, + { "certpath default", "Use default system certificate path, if it can be found." }) + CMD_NOEXAMPLES }, { "/disconnect", - parse_args, 0, 0, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_disconnect) - CMD_TAGS( - CMD_TAG_CONNECTION) - CMD_SYN( - "/disconnect") - CMD_DESC( - "Disconnect from the current chat service.") - CMD_NOARGS - CMD_NOEXAMPLES - }, + parse_args, 0, 0, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_disconnect) + CMD_TAGS( + CMD_TAG_CONNECTION) + CMD_SYN( + "/disconnect") + CMD_DESC( + "Disconnect from the current chat service.") + CMD_NOARGS + CMD_NOEXAMPLES }, { "/msg", - parse_args_with_freetext, 1, 2, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_msg) - CMD_TAGS( - CMD_TAG_CHAT) - CMD_SYN( - "/msg <contact> [<message>]", - "/msg <nick> [<message>]") - CMD_DESC( - "Send a one to one chat message, or a private message to a chat room occupant. " - "If the message is omitted, a new chat window will be opened without sending a message. " - "Use quotes if the nickname includes spaces.") - CMD_ARGS( - { "<contact>", "Open chat window with contact, by JID or nickname." }, - { "<contact> [<message>]", "Send message to contact, by JID or nickname." }, - { "<nick>", "Open private chat window with chat room occupant." }, - { "<nick> [<message>]", "Send a private message to a chat room occupant." }) - CMD_EXAMPLES( - "/msg thor@valhalla.edda Hey, here's a message!", - "/msg heimdall@valhalla.edda", - "/msg Thor Here is a private message", - "/msg \"My Friend\" Hi, how are you?") - }, + parse_args_with_freetext, 1, 2, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_msg) + CMD_TAGS( + CMD_TAG_CHAT) + CMD_SYN( + "/msg <contact> [<message>]", + "/msg <nick> [<message>]") + CMD_DESC( + "Send a one to one chat message, or a private message to a chat room occupant. " + "If the message is omitted, a new chat window will be opened without sending a message. " + "Use quotes if the nickname includes spaces.") + CMD_ARGS( + { "<contact>", "Open chat window with contact, by JID or nickname." }, + { "<contact> [<message>]", "Send message to contact, by JID or nickname." }, + { "<nick>", "Open private chat window with chat room occupant." }, + { "<nick> [<message>]", "Send a private message to a chat room occupant." }) + CMD_EXAMPLES( + "/msg thor@valhalla.edda Hey, here's a message!", + "/msg heimdall@valhalla.edda", + "/msg Thor Here is a private message", + "/msg \"My Friend\" Hi, how are you?") }, { "/roster", - parse_args_with_freetext, 0, 4, NULL, - CMD_SUBFUNCS( - { "group", cmd_group }) - CMD_MAINFUNC(cmd_roster) - CMD_TAGS( - CMD_TAG_ROSTER, - CMD_TAG_UI) - CMD_SYN( - "/roster", - "/roster online", - "/roster show [offline|resource|presence|status|empty|priority|contacts|rooms]", - "/roster hide [offline|resource|presence|status|empty|priority|contacts|rooms]", - "/roster by group|presence|none", - "/roster count unread|items|off", - "/roster count zero on|off", - "/roster color on|off", - "/roster order name|presence", - "/roster unread before|after|off", - "/roster room char <char>|none", - "/roster room private char <char>|none", - "/roster room position first|last", - "/roster room by service|none", - "/roster room order name|unread", - "/roster room unread before|after|off", - "/roster room show server", - "/roster room hide server", - "/roster room use name|jid", - "/roster private room|group|off", - "/roster private char <char>|none", - "/roster header char <char>|none", - "/roster presence indent <indent>", - "/roster contact char <char>|none", - "/roster contact indent <indent>", - "/roster resource char <char>|none", - "/roster resource indent <indent>", - "/roster resource join on|off", - "/roster size <percent>", - "/roster wrap on|off", - "/roster add <jid> [<nick>]", - "/roster remove <jid>", - "/roster remove_all contacts", - "/roster nick <jid> <nick>", - "/roster clearnick <jid>", - "/roster group", - "/roster group show <group>", - "/roster group add <group> <contat>", - "/roster group remove <group> <contact>") - CMD_DESC( - "Manage your roster, and roster display settings. " - "Passing no arguments lists all contacts in your roster.") - CMD_ARGS( - { "online", "Show all online contacts in console." }, - { "show", "Show the roster panel." }, - { "show offline", "Show offline contacts in roster panel." }, - { "show resource", "Show contact's connected resources in roster panel." }, - { "show presence", "Show contact's presence in roster panel." }, - { "show status", "Show contact's status message in roster panel." }, - { "show empty", "Show empty groups in roster panel." }, - { "show priority", "Show resource priority in roster panel." }, - { "show contacts", "Show contacts in roster panel." }, - { "show rooms", "Show chat rooms in roster panel." }, - { "hide", "Hide the roster panel." }, - { "hide offline", "Hide offline contacts in roster panel." }, - { "hide resource", "Hide contact's connected resources in roster panel." }, - { "hide presence", "Hide contact's presence in roster panel." }, - { "hide status", "Hide contact's status message in roster panel." }, - { "hide empty", "Hide empty groups in roster panel." }, - { "hide priority", "Hide resource priority in roster panel." }, - { "hide contacts", "Hide contacts in roster panel." }, - { "hide rooms", "Hide chat rooms in roster panel." }, - { "by group", "Group contacts in roster panel by roster group." }, - { "by presence", "Group contacts in roster panel by presence." }, - { "by none", "No grouping in roster panel." }, - { "count unread", "Show unread message count with roster headers." }, - { "count items", "Show item count with roster headers." }, - { "count off", "Do not show any count with roster headers." }, - { "count zero on", "Show roster header count when 0." }, - { "count zero off", "Hide roster header count when 0." }, - { "color on", "Enable generated color names (XEP-0392)" }, - { "color off", "Disable generated color names (XEP-0392)" }, - { "order name", "Order roster contacts by name only." }, - { "order presence", "Order roster contacts by presence, and then by name." }, - { "unread before", "Show unread message count before contact." }, - { "unread after", "Show unread message count after contact." }, - { "unread off", "Do not show unread message count for contacts." }, - { "room char <char>", "Prefix rooms with specified character." }, - { "room char none", "Remove room character prefix." }, - { "room private char <char>", "Prefix private room chat with specified character when displayed with room." }, - { "room private char none", "Remove private room chat character prefix when displayed with room." }, - { "room position first", "Show rooms first in roster." }, - { "room position last", "Show rooms last in roster." }, - { "room by service", "Group rooms by chat service." }, - { "room by none", "Do not group rooms." }, - { "room order name", "Order rooms by name." }, - { "room order unread", "Order rooms by unread messages, and then by name." }, - { "room unread before", "Show unread message count before room." }, - { "room unread after", "Show unread message count after room." }, - { "room unread off", "Do not show unread message count for rooms." }, - { "room show server", "Show the conference server with room JIDs." }, - { "room hide server", "Do not show the conference server with room JIDs." }, - { "room use name", "Use the MUC name as room name." }, - { "room use jid", "Use the JID as room name." }, - { "private room", "Show room private chats with the room." }, - { "private group", "Show room private chats as a separate roster group." }, - { "private off", "Do not show room private chats." }, - { "private char <char>", "Prefix private room chats with specified character when displayed in separate group." }, - { "private char none", "Remove private room chat character prefix." }, - { "header char <char>", "Prefix roster headers with specified character." }, - { "header char none", "Remove roster header character prefix." }, - { "contact char <char>", "Prefix roster contacts with specified character." }, - { "contact char none", "Remove roster contact character prefix." }, - { "contact indent <indent>", "Indent contact line by <indent> spaces (0 to 10)." }, - { "resource char <char>", "Prefix roster resources with specified character." }, - { "resource char none", "Remove roster resource character prefix." }, - { "resource indent <indent>", "Indent resource line by <indent> spaces (0 to 10)." }, - { "resource join on|off", "Join resource with previous line when only one available resource." }, - { "presence indent <indent>", "Indent presence line by <indent> spaces (-1 to 10), a value of -1 will show presence on the previous line." }, - { "size <percent>", "Percentage of the screen taken up by the roster (1-99)." }, - { "wrap on|off", "Enable or disable line wrapping in roster panel." }, - { "add <jid> [<nick>]", "Add a new item to the roster." }, - { "remove <jid>", "Removes an item from the roster." }, - { "remove_all contacts", "Remove all items from roster." }, - { "nick <jid> <nick>", "Change a contacts nickname." }, - { "clearnick <jid>", "Removes the current nickname." }, - { "group show <group>", "List all roster items in a group." }, - { "group add <group> <contact>", "Add a contact to a group." }, - { "group remove <group> <contact>", "Remove a contact from a group." }) - CMD_EXAMPLES( - "/roster", - "/roster add odin@valhalla.edda", - "/roster add odin@valhalla.edda Allfather", - "/roster remove loki@ownserver.org", - "/roster nick odin@valhalla.edda \"All Father\"", - "/roster clearnick thor@valhalla.edda", - "/roster size 15", - "/roster group", - "/roster group show friends", - "/roster group add friends fenris@ownserver.org", - "/roster group add family Brother", - "/roster group remove colleagues boss@work.com") - }, + parse_args_with_freetext, 0, 4, NULL, + CMD_SUBFUNCS( + { "group", cmd_group }) + CMD_MAINFUNC(cmd_roster) + CMD_TAGS( + CMD_TAG_ROSTER, + CMD_TAG_UI) + CMD_SYN( + "/roster", + "/roster online", + "/roster show [offline|resource|presence|status|empty|priority|contacts|rooms]", + "/roster hide [offline|resource|presence|status|empty|priority|contacts|rooms]", + "/roster by group|presence|none", + "/roster count unread|items|off", + "/roster count zero on|off", + "/roster color on|off", + "/roster order name|presence", + "/roster unread before|after|off", + "/roster room char <char>|none", + "/roster room private char <char>|none", + "/roster room position first|last", + "/roster room by service|none", + "/roster room order name|unread", + "/roster room unread before|after|off", + "/roster room show server", + "/roster room hide server", + "/roster room use name|jid", + "/roster private room|group|off", + "/roster private char <char>|none", + "/roster header char <char>|none", + "/roster presence indent <indent>", + "/roster contact char <char>|none", + "/roster contact indent <indent>", + "/roster resource char <char>|none", + "/roster resource indent <indent>", + "/roster resource join on|off", + "/roster size <percent>", + "/roster wrap on|off", + "/roster add <jid> [<nick>]", + "/roster remove <jid>", + "/roster remove_all contacts", + "/roster nick <jid> <nick>", + "/roster clearnick <jid>", + "/roster group", + "/roster group show <group>", + "/roster group add <group> <contat>", + "/roster group remove <group> <contact>") + CMD_DESC( + "Manage your roster, and roster display settings. " + "Passing no arguments lists all contacts in your roster.") + CMD_ARGS( + { "online", "Show all online contacts in console." }, + { "show", "Show the roster panel." }, + { "show offline", "Show offline contacts in roster panel." }, + { "show resource", "Show contact's connected resources in roster panel." }, + { "show presence", "Show contact's presence in roster panel." }, + { "show status", "Show contact's status message in roster panel." }, + { "show empty", "Show empty groups in roster panel." }, + { "show priority", "Show resource priority in roster panel." }, + { "show contacts", "Show contacts in roster panel." }, + { "show rooms", "Show chat rooms in roster panel." }, + { "hide", "Hide the roster panel." }, + { "hide offline", "Hide offline contacts in roster panel." }, + { "hide resource", "Hide contact's connected resources in roster panel." }, + { "hide presence", "Hide contact's presence in roster panel." }, + { "hide status", "Hide contact's status message in roster panel." }, + { "hide empty", "Hide empty groups in roster panel." }, + { "hide priority", "Hide resource priority in roster panel." }, + { "hide contacts", "Hide contacts in roster panel." }, + { "hide rooms", "Hide chat rooms in roster panel." }, + { "by group", "Group contacts in roster panel by roster group." }, + { "by presence", "Group contacts in roster panel by presence." }, + { "by none", "No grouping in roster panel." }, + { "count unread", "Show unread message count with roster headers." }, + { "count items", "Show item count with roster headers." }, + { "count off", "Do not show any count with roster headers." }, + { "count zero on", "Show roster header count when 0." }, + { "count zero off", "Hide roster header count when 0." }, + { "color on", "Enable generated color names (XEP-0392)" }, + { "color off", "Disable generated color names (XEP-0392)" }, + { "order name", "Order roster contacts by name only." }, + { "order presence", "Order roster contacts by presence, and then by name." }, + { "unread before", "Show unread message count before contact." }, + { "unread after", "Show unread message count after contact." }, + { "unread off", "Do not show unread message count for contacts." }, + { "room char <char>", "Prefix rooms with specified character." }, + { "room char none", "Remove room character prefix." }, + { "room private char <char>", "Prefix private room chat with specified character when displayed with room." }, + { "room private char none", "Remove private room chat character prefix when displayed with room." }, + { "room position first", "Show rooms first in roster." }, + { "room position last", "Show rooms last in roster." }, + { "room by service", "Group rooms by chat service." }, + { "room by none", "Do not group rooms." }, + { "room order name", "Order rooms by name." }, + { "room order unread", "Order rooms by unread messages, and then by name." }, + { "room unread before", "Show unread message count before room." }, + { "room unread after", "Show unread message count after room." }, + { "room unread off", "Do not show unread message count for rooms." }, + { "room show server", "Show the conference server with room JIDs." }, + { "room hide server", "Do not show the conference server with room JIDs." }, + { "room use name", "Use the MUC name as room name." }, + { "room use jid", "Use the JID as room name." }, + { "private room", "Show room private chats with the room." }, + { "private group", "Show room private chats as a separate roster group." }, + { "private off", "Do not show room private chats." }, + { "private char <char>", "Prefix private room chats with specified character when displayed in separate group." }, + { "private char none", "Remove private room chat character prefix." }, + { "header char <char>", "Prefix roster headers with specified character." }, + { "header char none", "Remove roster header character prefix." }, + { "contact char <char>", "Prefix roster contacts with specified character." }, + { "contact char none", "Remove roster contact character prefix." }, + { "contact indent <indent>", "Indent contact line by <indent> spaces (0 to 10)." }, + { "resource char <char>", "Prefix roster resources with specified character." }, + { "resource char none", "Remove roster resource character prefix." }, + { "resource indent <indent>", "Indent resource line by <indent> spaces (0 to 10)." }, + { "resource join on|off", "Join resource with previous line when only one available resource." }, + { "presence indent <indent>", "Indent presence line by <indent> spaces (-1 to 10), a value of -1 will show presence on the previous line." }, + { "size <percent>", "Percentage of the screen taken up by the roster (1-99)." }, + { "wrap on|off", "Enable or disable line wrapping in roster panel." }, + { "add <jid> [<nick>]", "Add a new item to the roster." }, + { "remove <jid>", "Removes an item from the roster." }, + { "remove_all contacts", "Remove all items from roster." }, + { "nick <jid> <nick>", "Change a contacts nickname." }, + { "clearnick <jid>", "Removes the current nickname." }, + { "group show <group>", "List all roster items in a group." }, + { "group add <group> <contact>", "Add a contact to a group." }, + { "group remove <group> <contact>", "Remove a contact from a group." }) + CMD_EXAMPLES( + "/roster", + "/roster add odin@valhalla.edda", + "/roster add odin@valhalla.edda Allfather", + "/roster remove loki@ownserver.org", + "/roster nick odin@valhalla.edda \"All Father\"", + "/roster clearnick thor@valhalla.edda", + "/roster size 15", + "/roster group", + "/roster group show friends", + "/roster group add friends fenris@ownserver.org", + "/roster group add family Brother", + "/roster group remove colleagues boss@work.com") }, { "/blocked", - parse_args, 0, 2, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_blocked) - CMD_TAGS( - CMD_TAG_ROSTER, - CMD_TAG_CHAT) - CMD_SYN( - "/blocked", - "/blocked add [<jid>]", - "/blocked remove <jid>") - CMD_DESC( - "Manage blocked users (XEP-0191), calling with no arguments shows the current list of blocked users. " - "To blog a certain user in a MUC use the following as jid: room@conference.example.org/spammy-user") - CMD_ARGS( - { "add [<jid>]", "Block the specified Jabber ID. If in a chat window and no jid is specified, the current recipient will be blocked." }, - { "remove <jid>", "Remove the specified Jabber ID from the blocked list." }) - CMD_EXAMPLES( - "/blocked add hel@helheim.edda", - "/blocked add profanity@rooms.dismail.de/spammy-user") - }, + parse_args, 0, 2, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_blocked) + CMD_TAGS( + CMD_TAG_ROSTER, + CMD_TAG_CHAT) + CMD_SYN( + "/blocked", + "/blocked add [<jid>]", + "/blocked remove <jid>") + CMD_DESC( + "Manage blocked users (XEP-0191), calling with no arguments shows the current list of blocked users. " + "To blog a certain user in a MUC use the following as jid: room@conference.example.org/spammy-user") + CMD_ARGS( + { "add [<jid>]", "Block the specified Jabber ID. If in a chat window and no jid is specified, the current recipient will be blocked." }, + { "remove <jid>", "Remove the specified Jabber ID from the blocked list." }) + CMD_EXAMPLES( + "/blocked add hel@helheim.edda", + "/blocked add profanity@rooms.dismail.de/spammy-user") }, { "/info", - parse_args, 0, 1, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_info) - CMD_TAGS( - CMD_TAG_ROSTER, - CMD_TAG_CHAT, - CMD_TAG_GROUPCHAT) - CMD_SYN( - "/info", - "/info <contact>|<nick>") - CMD_DESC( - "Show information about a contact, room, or room member. " - "Passing no argument in a chat window will use the current recipient. " - "Passing no argument in a chat room will display information about the room.") - CMD_ARGS( - { "<contact>", "The contact you wish to view information about." }, - { "<nick>", "When in a chat room, the occupant you wish to view information about." }) - CMD_EXAMPLES( - "/info thor@aasgard.server.org", - "/info heimdall") - }, + parse_args, 0, 1, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_info) + CMD_TAGS( + CMD_TAG_ROSTER, + CMD_TAG_CHAT, + CMD_TAG_GROUPCHAT) + CMD_SYN( + "/info", + "/info <contact>|<nick>") + CMD_DESC( + "Show information about a contact, room, or room member. " + "Passing no argument in a chat window will use the current recipient. " + "Passing no argument in a chat room will display information about the room.") + CMD_ARGS( + { "<contact>", "The contact you wish to view information about." }, + { "<nick>", "When in a chat room, the occupant you wish to view information about." }) + CMD_EXAMPLES( + "/info thor@aasgard.server.org", + "/info heimdall") }, { "/caps", - parse_args, 0, 1, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_caps) - CMD_TAGS( - CMD_TAG_DISCOVERY, - CMD_TAG_CHAT, - CMD_TAG_GROUPCHAT) - CMD_SYN( - "/caps", - "/caps <fulljid>|<nick>") - CMD_DESC( - "Find out a contacts, or room members client software capabilities. " - "If in private chat initiated from a chat room, no parameter is required.") - CMD_ARGS( - { "<fulljid>", "If in the console or a chat window, the full JID for which you wish to see capabilities." }, - { "<nick>", "If in a chat room, nickname for which you wish to see capabilities." }) - CMD_EXAMPLES( - "/caps ran@cold.sea.org/laptop", - "/caps ran@cold.sea.org/phone", - "/caps aegir") - }, + parse_args, 0, 1, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_caps) + CMD_TAGS( + CMD_TAG_DISCOVERY, + CMD_TAG_CHAT, + CMD_TAG_GROUPCHAT) + CMD_SYN( + "/caps", + "/caps <fulljid>|<nick>") + CMD_DESC( + "Find out a contacts, or room members client software capabilities. " + "If in private chat initiated from a chat room, no parameter is required.") + CMD_ARGS( + { "<fulljid>", "If in the console or a chat window, the full JID for which you wish to see capabilities." }, + { "<nick>", "If in a chat room, nickname for which you wish to see capabilities." }) + CMD_EXAMPLES( + "/caps ran@cold.sea.org/laptop", + "/caps ran@cold.sea.org/phone", + "/caps aegir") }, { "/software", - parse_args, 0, 1, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_software) - CMD_TAGS( - CMD_TAG_DISCOVERY, - CMD_TAG_CHAT, - CMD_TAG_GROUPCHAT) - CMD_SYN( - "/software", - "/software <fulljid>|<nick>") - CMD_DESC( - "Find out a contact, or room members software version information. " - "If in private chat initiated from a chat room, no parameter is required. " - "If the contact's software does not support software version requests, nothing will be displayed.") - CMD_ARGS( - { "<fulljid>", "If in the console or a chat window, the full JID for which you wish to see software information." }, - { "<nick>", "If in a chat room, nickname for which you wish to see software information." }) - CMD_EXAMPLES( - "/software odin@valhalla.edda/laptop", - "/software odin@valhalla.edda/phone", - "/software thor") - }, + parse_args, 0, 1, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_software) + CMD_TAGS( + CMD_TAG_DISCOVERY, + CMD_TAG_CHAT, + CMD_TAG_GROUPCHAT) + CMD_SYN( + "/software", + "/software <fulljid>|<nick>") + CMD_DESC( + "Find out a contact, or room members software version information. " + "If in private chat initiated from a chat room, no parameter is required. " + "If the contact's software does not support software version requests, nothing will be displayed.") + CMD_ARGS( + { "<fulljid>", "If in the console or a chat window, the full JID for which you wish to see software information." }, + { "<nick>", "If in a chat room, nickname for which you wish to see software information." }) + CMD_EXAMPLES( + "/software odin@valhalla.edda/laptop", + "/software odin@valhalla.edda/phone", + "/software thor") }, { "/status", - parse_args, 2, 3, NULL, - CMD_SUBFUNCS( - { "get", cmd_status_get }, - { "set", cmd_status_set }) - CMD_NOMAINFUNC - CMD_TAGS( - CMD_TAG_CHAT, - CMD_TAG_GROUPCHAT) - CMD_SYN( - "/status set <state> [\"<message>\"]", - "/status get <contact>|<nick>") - CMD_DESC( - "/status get: Find out a contact, or room members presence information. " - "/status set: set own status.") - CMD_ARGS( - { "<state>", "Own status. Possible values: chat, online, away, dnd, xa" }, - { "<message>", "Optional message to use with the status. Needs quotation marks if it's more than one word." }, - { "<contact>", "The contact who's presence you which to see." }, - { "<nick>", "If in a chat room, the occupant who's presence you wish to see." }) - CMD_EXAMPLES( - "/status get odin@valhalla.edda", - "/status get jon", - "/status set online") - }, + parse_args, 2, 3, NULL, + CMD_SUBFUNCS( + { "get", cmd_status_get }, + { "set", cmd_status_set }) + CMD_NOMAINFUNC + CMD_TAGS( + CMD_TAG_CHAT, + CMD_TAG_GROUPCHAT) + CMD_SYN( + "/status set <state> [\"<message>\"]", + "/status get <contact>|<nick>") + CMD_DESC( + "/status get: Find out a contact, or room members presence information. " + "/status set: set own status.") + CMD_ARGS( + { "<state>", "Own status. Possible values: chat, online, away, dnd, xa" }, + { "<message>", "Optional message to use with the status. Needs quotation marks if it's more than one word." }, + { "<contact>", "The contact who's presence you which to see." }, + { "<nick>", "If in a chat room, the occupant who's presence you wish to see." }) + CMD_EXAMPLES( + "/status get odin@valhalla.edda", + "/status get jon", + "/status set online") }, { "/resource", - parse_args, 1, 2, &cons_resource_setting, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_resource) - CMD_TAGS( - CMD_TAG_CHAT, - CMD_TAG_UI) - CMD_SYN( - "/resource set <resource>", - "/resource off", - "/resource title on|off", - "/resource message on|off") - CMD_DESC( - "Override chat session resource, and manage resource display settings.") - CMD_ARGS( - { "set <resource>", "Set the resource to which messages will be sent." }, - { "off", "Let the server choose which resource to route messages to." }, - { "title on|off", "Show or hide the current resource in the titlebar." }, - { "message on|off", "Show or hide the resource when showing an incoming message." }) - CMD_NOEXAMPLES - }, + parse_args, 1, 2, &cons_resource_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_resource) + CMD_TAGS( + CMD_TAG_CHAT, + CMD_TAG_UI) + CMD_SYN( + "/resource set <resource>", + "/resource off", + "/resource title on|off", + "/resource message on|off") + CMD_DESC( + "Override chat session resource, and manage resource display settings.") + CMD_ARGS( + { "set <resource>", "Set the resource to which messages will be sent." }, + { "off", "Let the server choose which resource to route messages to." }, + { "title on|off", "Show or hide the current resource in the titlebar." }, + { "message on|off", "Show or hide the resource when showing an incoming message." }) + CMD_NOEXAMPLES }, { "/join", - parse_args, 0, 5, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_join) - CMD_TAGS( - CMD_TAG_GROUPCHAT) - CMD_SYN( - "/join", - "/join <room> [nick <nick>] [password <password>]") - CMD_DESC( - "Join a chat room at the conference server. " - "If no room is supplied, a generated name will be used with the format private-chat-[UUID]. " - "If the domain part is not included in the room name, the account preference 'muc.service' will be used. " - "If no nickname is specified the account preference 'muc.nick' will be used which by default is the localpart of your JID. " - "If the room doesn't exist, and the server allows it, a new one will be created.") - CMD_ARGS( - { "<room>", "The chat room to join." }, - { "nick <nick>", "Nickname to use in the room." }, - { "password <password>", "Password if the room requires one." }) - CMD_EXAMPLES( - "/join", - "/join profanity@rooms.dismail.de", - "/join profanity@rooms.dismail.de nick mynick", - "/join private@conference.jabber.org nick mynick password mypassword", - "/join mychannel") - }, + parse_args, 0, 5, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_join) + CMD_TAGS( + CMD_TAG_GROUPCHAT) + CMD_SYN( + "/join", + "/join <room> [nick <nick>] [password <password>]") + CMD_DESC( + "Join a chat room at the conference server. " + "If no room is supplied, a generated name will be used with the format private-chat-[UUID]. " + "If the domain part is not included in the room name, the account preference 'muc.service' will be used. " + "If no nickname is specified the account preference 'muc.nick' will be used which by default is the localpart of your JID. " + "If the room doesn't exist, and the server allows it, a new one will be created.") + CMD_ARGS( + { "<room>", "The chat room to join." }, + { "nick <nick>", "Nickname to use in the room." }, + { "password <password>", "Password if the room requires one." }) + CMD_EXAMPLES( + "/join", + "/join profanity@rooms.dismail.de", + "/join profanity@rooms.dismail.de nick mynick", + "/join private@conference.jabber.org nick mynick password mypassword", + "/join mychannel") }, { "/invite", - parse_args_with_freetext, 1, 3, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_invite) - CMD_TAGS( - CMD_TAG_GROUPCHAT) - CMD_SYN( - "/invite send <contact> [<message>]", - "/invite list", - "/invite decline") - CMD_DESC( - "Manage room invites. " - "Send an invite to a contact for the current chat room. " - "List received invites. " - "Decline them using /invite decline and accept them using /join.") - CMD_ARGS( - { "send <contact> [<message>]", "The contact you wish to invite. And an optional message." }, - { "list", "Show all rooms that you have been invited to, and not accepted or declined."}, - { "decline <room>", "Decline a chat room invitation."}) - CMD_EXAMPLES( - "/invite send gustavo@pollos.tx", - "/invite decline profanity@rooms.dismail.de", - "/invite list") - }, + parse_args_with_freetext, 1, 3, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_invite) + CMD_TAGS( + CMD_TAG_GROUPCHAT) + CMD_SYN( + "/invite send <contact> [<message>]", + "/invite list", + "/invite decline") + CMD_DESC( + "Manage room invites. " + "Send an invite to a contact for the current chat room. " + "List received invites. " + "Decline them using /invite decline and accept them using /join.") + CMD_ARGS( + { "send <contact> [<message>]", "The contact you wish to invite. And an optional message." }, + { "list", "Show all rooms that you have been invited to, and not accepted or declined." }, + { "decline <room>", "Decline a chat room invitation." }) + CMD_EXAMPLES( + "/invite send gustavo@pollos.tx", + "/invite decline profanity@rooms.dismail.de", + "/invite list") }, { "/room", - parse_args, 1, 1, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_room) - CMD_TAGS( - CMD_TAG_GROUPCHAT) - CMD_SYN( - "/room accept|destroy|config") - CMD_DESC( - "Chat room configuration.") - CMD_ARGS( - { "accept", "Accept default room configuration." }, - { "destroy", "Reject default room configuration, and destroy the room." }, - { "config", "Edit room configuration." }) - CMD_NOEXAMPLES - }, + parse_args, 1, 1, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_room) + CMD_TAGS( + CMD_TAG_GROUPCHAT) + CMD_SYN( + "/room accept|destroy|config") + CMD_DESC( + "Chat room configuration.") + CMD_ARGS( + { "accept", "Accept default room configuration." }, + { "destroy", "Reject default room configuration, and destroy the room." }, + { "config", "Edit room configuration." }) + CMD_NOEXAMPLES }, { "/kick", - parse_args_with_freetext, 1, 2, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_kick) - CMD_TAGS( - CMD_TAG_GROUPCHAT) - CMD_SYN( - "/kick <nick> [<reason>]") - CMD_DESC( - "Kick occupant from chat room.") - CMD_ARGS( - { "<nick>", "Nickname of the occupant to kick from the room." }, - { "<reason>", "Optional reason for kicking the occupant." }) - CMD_NOEXAMPLES - }, + parse_args_with_freetext, 1, 2, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_kick) + CMD_TAGS( + CMD_TAG_GROUPCHAT) + CMD_SYN( + "/kick <nick> [<reason>]") + CMD_DESC( + "Kick occupant from chat room.") + CMD_ARGS( + { "<nick>", "Nickname of the occupant to kick from the room." }, + { "<reason>", "Optional reason for kicking the occupant." }) + CMD_NOEXAMPLES }, { "/ban", - parse_args_with_freetext, 1, 2, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_ban) - CMD_TAGS( - CMD_TAG_GROUPCHAT) - CMD_SYN( - "/ban <jid> [<reason>]") - CMD_DESC( - "Ban user from chat room.") - CMD_ARGS( - { "<jid>", "Bare JID of the user to ban from the room." }, - { "<reason>", "Optional reason for banning the user." }) - CMD_NOEXAMPLES - }, + parse_args_with_freetext, 1, 2, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_ban) + CMD_TAGS( + CMD_TAG_GROUPCHAT) + CMD_SYN( + "/ban <jid> [<reason>]") + CMD_DESC( + "Ban user from chat room.") + CMD_ARGS( + { "<jid>", "Bare JID of the user to ban from the room." }, + { "<reason>", "Optional reason for banning the user." }) + CMD_NOEXAMPLES }, { "/subject", - parse_args_with_freetext, 0, 2, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_subject) - CMD_TAGS( - CMD_TAG_GROUPCHAT) - CMD_SYN( - "/subject set <subject>", - "/subject edit <subject>", - "/subject prepend <text>", - "/subject append <text>", - "/subject clear") - CMD_DESC( - "Set, modify, or clear room subject.") - CMD_ARGS( - { "set <subject>", "Set the room subject." }, - { "edit <subject>", "Edit the current room subject, tab autocompletion will display the subject to edit." }, - { "prepend <text>", "Prepend text to the current room subject, use double quotes if a trailing space is needed." }, - { "append <text>", "Append text to the current room subject, use double quotes if a preceding space is needed." }, - { "clear", "Clear the room subject." }) - CMD_NOEXAMPLES - }, + parse_args_with_freetext, 0, 2, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_subject) + CMD_TAGS( + CMD_TAG_GROUPCHAT) + CMD_SYN( + "/subject set <subject>", + "/subject edit <subject>", + "/subject prepend <text>", + "/subject append <text>", + "/subject clear") + CMD_DESC( + "Set, modify, or clear room subject.") + CMD_ARGS( + { "set <subject>", "Set the room subject." }, + { "edit <subject>", "Edit the current room subject, tab autocompletion will display the subject to edit." }, + { "prepend <text>", "Prepend text to the current room subject, use double quotes if a trailing space is needed." }, + { "append <text>", "Append text to the current room subject, use double quotes if a preceding space is needed." }, + { "clear", "Clear the room subject." }) + CMD_NOEXAMPLES }, { "/affiliation", - parse_args_with_freetext, 1, 4, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_affiliation) - CMD_TAGS( - CMD_TAG_GROUPCHAT) - CMD_SYN( - "/affiliation set <affiliation> <jid> [<reason>]", - "/affiliation list [<affiliation>]") - CMD_DESC( - "Manage room affiliations. " - "Affiliation may be one of owner, admin, member, outcast or none.") - CMD_ARGS( - { "set <affiliation> <jid> [<reason>]", "Set the affiliation of user with jid, with an optional reason." }, - { "list [<affiliation>]", "List all users with the specified affiliation, or all if none specified." }) - CMD_NOEXAMPLES - }, + parse_args_with_freetext, 1, 4, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_affiliation) + CMD_TAGS( + CMD_TAG_GROUPCHAT) + CMD_SYN( + "/affiliation set <affiliation> <jid> [<reason>]", + "/affiliation list [<affiliation>]") + CMD_DESC( + "Manage room affiliations. " + "Affiliation may be one of owner, admin, member, outcast or none.") + CMD_ARGS( + { "set <affiliation> <jid> [<reason>]", "Set the affiliation of user with jid, with an optional reason." }, + { "list [<affiliation>]", "List all users with the specified affiliation, or all if none specified." }) + CMD_NOEXAMPLES }, { "/role", - parse_args_with_freetext, 1, 4, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_role) - CMD_TAGS( - CMD_TAG_GROUPCHAT) - CMD_SYN( - "/role set <role> <nick> [<reason>]", - "/role list [<role>]") - CMD_DESC( - "Manage room roles. " - "Role may be one of moderator, participant, visitor or none.") - CMD_ARGS( - { "set <role> <nick> [<reason>]", "Set the role of occupant with nick, with an optional reason." }, - { "list [<role>]", "List all occupants with the specified role, or all if none specified." }) - CMD_NOEXAMPLES - }, + parse_args_with_freetext, 1, 4, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_role) + CMD_TAGS( + CMD_TAG_GROUPCHAT) + CMD_SYN( + "/role set <role> <nick> [<reason>]", + "/role list [<role>]") + CMD_DESC( + "Manage room roles. " + "Role may be one of moderator, participant, visitor or none.") + CMD_ARGS( + { "set <role> <nick> [<reason>]", "Set the role of occupant with nick, with an optional reason." }, + { "list [<role>]", "List all occupants with the specified role, or all if none specified." }) + CMD_NOEXAMPLES }, { "/occupants", - parse_args, 1, 3, cons_occupants_setting, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_occupants) - CMD_TAGS( - CMD_TAG_GROUPCHAT, - CMD_TAG_UI) - CMD_SYN( - "/occupants show|hide [jid]", - "/occupants char <char>|none", - "/occupants color on|off", - "/occupants default show|hide [jid]", - "/occupants size [<percent>]", - "/occupants indent <indent>", - "/occupants header char <char>|none", - "/occupants wrap on|off") - CMD_DESC( - "Show or hide room occupants, and occupants panel display settings.") - CMD_ARGS( - { "show", "Show the occupants panel in current room." }, - { "char <char>", "Prefix occupants with specified character." }, - { "char none", "Remove occupants character prefix." }, - { "color on", "Enable generated color names (XEP-0392) for occupants" }, - { "color off", "Disable generated color names (XEP-0392) for occupants" }, - { "hide", "Hide the occupants panel in current room." }, - { "show jid", "Show jid in the occupants panel in current room." }, - { "hide jid", "Hide jid in the occupants panel in current room." }, - { "default show|hide", "Whether occupants are shown by default in new rooms." }, - { "default show|hide jid", "Whether occupants jids are shown by default in new rooms." }, - { "size <percent>", "Percentage of the screen taken by the occupants list in rooms (1-99)." }, - { "indent <indent>", "Indent contact line by <indent> spaces (0 to 10)." }, - { "header char <char>", "Prefix occupants headers with specified character." }, - { "header char none", "Remove occupants header character prefix." }, - { "wrap on|off", "Enable or disable line wrapping in occupants panel." }) - CMD_NOEXAMPLES - }, + parse_args, 1, 3, cons_occupants_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_occupants) + CMD_TAGS( + CMD_TAG_GROUPCHAT, + CMD_TAG_UI) + CMD_SYN( + "/occupants show|hide [jid]", + "/occupants char <char>|none", + "/occupants color on|off", + "/occupants default show|hide [jid]", + "/occupants size [<percent>]", + "/occupants indent <indent>", + "/occupants header char <char>|none", + "/occupants wrap on|off") + CMD_DESC( + "Show or hide room occupants, and occupants panel display settings.") + CMD_ARGS( + { "show", "Show the occupants panel in current room." }, + { "char <char>", "Prefix occupants with specified character." }, + { "char none", "Remove occupants character prefix." }, + { "color on", "Enable generated color names (XEP-0392) for occupants" }, + { "color off", "Disable generated color names (XEP-0392) for occupants" }, + { "hide", "Hide the occupants panel in current room." }, + { "show jid", "Show jid in the occupants panel in current room." }, + { "hide jid", "Hide jid in the occupants panel in current room." }, + { "default show|hide", "Whether occupants are shown by default in new rooms." }, + { "default show|hide jid", "Whether occupants jids are shown by default in new rooms." }, + { "size <percent>", "Percentage of the screen taken by the occupants list in rooms (1-99)." }, + { "indent <indent>", "Indent contact line by <indent> spaces (0 to 10)." }, + { "header char <char>", "Prefix occupants headers with specified character." }, + { "header char none", "Remove occupants header character prefix." }, + { "wrap on|off", "Enable or disable line wrapping in occupants panel." }) + CMD_NOEXAMPLES }, { "/form", - parse_args, 1, 2, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_form) - CMD_TAGS( - CMD_TAG_GROUPCHAT) - CMD_SYN( - "/form show", - "/form submit", - "/form cancel", - "/form help [<tag>]") - CMD_DESC( - "Form configuration.") - CMD_ARGS( - { "show", "Show the current form." }, - { "submit", "Submit the current form." }, - { "cancel", "Cancel changes to the current form." }, - { "help [<tag>]", "Display help for form, or a specific field." }) - CMD_NOEXAMPLES - }, + parse_args, 1, 2, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_form) + CMD_TAGS( + CMD_TAG_GROUPCHAT) + CMD_SYN( + "/form show", + "/form submit", + "/form cancel", + "/form help [<tag>]") + CMD_DESC( + "Form configuration.") + CMD_ARGS( + { "show", "Show the current form." }, + { "submit", "Submit the current form." }, + { "cancel", "Cancel changes to the current form." }, + { "help [<tag>]", "Display help for form, or a specific field." }) + CMD_NOEXAMPLES }, { "/rooms", - parse_args, 0, 4, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_rooms) - CMD_TAGS( - CMD_TAG_GROUPCHAT) - CMD_SYN( - "/rooms", - "/rooms filter <text>", - "/rooms service <service>", - "/rooms service <service> filter <text>", - "/rooms cache on|off|clear") - CMD_DESC( - "List the chat rooms available at the specified conference service. " - "If no argument is supplied, the account preference 'muc.service' is used, 'conference.<domain-part>' by default. " - "The filter argument only shows rooms that contain the provided text, case insensitive.") - CMD_ARGS( - { "service <service>", "The conference service to query." }, - { "filter <text>", "The text to filter results by."}, - { "cache on|off", "Enable or disable caching of rooms list response, enabled by default."}, - { "cache clear", "Clear the rooms response cache if enabled."}) - CMD_EXAMPLES( - "/rooms", - "/rooms filter development", - "/rooms service conference.jabber.org", - "/rooms service conference.jabber.org filter \"News Room\"") - }, + parse_args, 0, 4, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_rooms) + CMD_TAGS( + CMD_TAG_GROUPCHAT) + CMD_SYN( + "/rooms", + "/rooms filter <text>", + "/rooms service <service>", + "/rooms service <service> filter <text>", + "/rooms cache on|off|clear") + CMD_DESC( + "List the chat rooms available at the specified conference service. " + "If no argument is supplied, the account preference 'muc.service' is used, 'conference.<domain-part>' by default. " + "The filter argument only shows rooms that contain the provided text, case insensitive.") + CMD_ARGS( + { "service <service>", "The conference service to query." }, + { "filter <text>", "The text to filter results by." }, + { "cache on|off", "Enable or disable caching of rooms list response, enabled by default." }, + { "cache clear", "Clear the rooms response cache if enabled." }) + CMD_EXAMPLES( + "/rooms", + "/rooms filter development", + "/rooms service conference.jabber.org", + "/rooms service conference.jabber.org filter \"News Room\"") }, { "/bookmark", - parse_args, 0, 8, NULL, - CMD_SUBFUNCS( - { "ignore", cmd_bookmark_ignore } - ) - CMD_MAINFUNC(cmd_bookmark) - CMD_TAGS( - CMD_TAG_GROUPCHAT) - CMD_SYN( - "/bookmark", - "/bookmark list", - "/bookmark add [<room>] [nick <nick>] [password <password>] [name <roomname>] [autojoin on|off]", - "/bookmark update <room> [nick <nick>] [password <password>] [name <roomname>] autojoin on|off]", - "/bookmark remove [<room>]", - "/bookmark join <room>", - "/bookmark invites on|off", - "/bookmark ignore", - "/bookmark ignore add <jid>", - "/bookmark ignore remove <jid>") - CMD_DESC( - "Manage bookmarks and join bookmarked rooms. " - "In a chat room, no arguments will bookmark the current room, setting autojoin to \"on\"." - "There is also an autojoin ignore list in case you want to autojoind in many clients but not on Profanity.") - CMD_ARGS( - { "list", "List all bookmarks." }, - { "add [<room>]", "Add a bookmark, passing no room will bookmark the current room, setting autojoin to \"on\"." }, - { "remove [<room>]", "Remove a bookmark, passing no room will remove the bookmark for the current room, if one exists." }, - { "update <room>", "Update the properties associated with a bookmark." }, - { "nick <nick>", "Nickname used in the chat room." }, - { "password <password>", "Password if required, may be stored in plaintext on your server." }, - { "name <roomname>", "Optional name for the bookmark. By default localpart of the JID will be used." }, - { "autojoin on|off", "Whether to join the room automatically on login." }, - { "join <room>", "Join room using the properties associated with the bookmark." }, - { "invites on|off", "Whether or not to bookmark accepted room invites, defaults to 'on'."}, - { "ignore add <barejid>", "Add a bookmark to the autojoin ignore list."}, - { "ignore remove <barejid>", "Remove a bookmark from the autojoin ignore list."}) - CMD_NOEXAMPLES - }, + parse_args, 0, 8, NULL, + CMD_SUBFUNCS( + { "ignore", cmd_bookmark_ignore }) + CMD_MAINFUNC(cmd_bookmark) + CMD_TAGS( + CMD_TAG_GROUPCHAT) + CMD_SYN( + "/bookmark", + "/bookmark list", + "/bookmark add [<room>] [nick <nick>] [password <password>] [name <roomname>] [autojoin on|off]", + "/bookmark update <room> [nick <nick>] [password <password>] [name <roomname>] autojoin on|off]", + "/bookmark remove [<room>]", + "/bookmark join <room>", + "/bookmark invites on|off", + "/bookmark ignore", + "/bookmark ignore add <jid>", + "/bookmark ignore remove <jid>") + CMD_DESC( + "Manage bookmarks and join bookmarked rooms. " + "In a chat room, no arguments will bookmark the current room, setting autojoin to \"on\"." + "There is also an autojoin ignore list in case you want to autojoind in many clients but not on Profanity.") + CMD_ARGS( + { "list", "List all bookmarks." }, + { "add [<room>]", "Add a bookmark, passing no room will bookmark the current room, setting autojoin to \"on\"." }, + { "remove [<room>]", "Remove a bookmark, passing no room will remove the bookmark for the current room, if one exists." }, + { "update <room>", "Update the properties associated with a bookmark." }, + { "nick <nick>", "Nickname used in the chat room." }, + { "password <password>", "Password if required, may be stored in plaintext on your server." }, + { "name <roomname>", "Optional name for the bookmark. By default localpart of the JID will be used." }, + { "autojoin on|off", "Whether to join the room automatically on login." }, + { "join <room>", "Join room using the properties associated with the bookmark." }, + { "invites on|off", "Whether or not to bookmark accepted room invites, defaults to 'on'." }, + { "ignore add <barejid>", "Add a bookmark to the autojoin ignore list." }, + { "ignore remove <barejid>", "Remove a bookmark from the autojoin ignore list." }) + CMD_NOEXAMPLES }, { "/disco", - parse_args, 1, 2, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_disco) - CMD_TAGS( - CMD_TAG_DISCOVERY) - CMD_SYN( - "/disco info [<jid>]", - "/disco items [<jid>]") - CMD_DESC( - "Find out information about an entities supported services. " - "Calling with no arguments will query the server you are currently connected to.") - CMD_ARGS( - { "info [<jid>]", "List protocols and features supported by an entity." }, - { "items [<jid>]", "List items associated with an entity." }) - CMD_EXAMPLES( - "/disco info", - "/disco items myserver.org", - "/disco items conference.jabber.org", - "/disco info odin@valhalla.edda/laptop") - }, + parse_args, 1, 2, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_disco) + CMD_TAGS( + CMD_TAG_DISCOVERY) + CMD_SYN( + "/disco info [<jid>]", + "/disco items [<jid>]") + CMD_DESC( + "Find out information about an entities supported services. " + "Calling with no arguments will query the server you are currently connected to.") + CMD_ARGS( + { "info [<jid>]", "List protocols and features supported by an entity." }, + { "items [<jid>]", "List items associated with an entity." }) + CMD_EXAMPLES( + "/disco info", + "/disco items myserver.org", + "/disco items conference.jabber.org", + "/disco info odin@valhalla.edda/laptop") }, { "/sendfile", - parse_args_with_freetext, 1, 1, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_sendfile) - CMD_TAGS( - CMD_TAG_CHAT, - CMD_TAG_GROUPCHAT) - CMD_SYN( - "/sendfile <file>") - CMD_DESC( - "Send a file using XEP-0363 HTTP file transfer.") - CMD_ARGS( - { "<file>", "Path to the file." }) - CMD_EXAMPLES( - "/sendfile /etc/hosts", - "/sendfile ~/images/sweet_cat.jpg") - }, + parse_args_with_freetext, 1, 1, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_sendfile) + CMD_TAGS( + CMD_TAG_CHAT, + CMD_TAG_GROUPCHAT) + CMD_SYN( + "/sendfile <file>") + CMD_DESC( + "Send a file using XEP-0363 HTTP file transfer.") + CMD_ARGS( + { "<file>", "Path to the file." }) + CMD_EXAMPLES( + "/sendfile /etc/hosts", + "/sendfile ~/images/sweet_cat.jpg") }, { "/lastactivity", - parse_args, 0, 1, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_lastactivity) - CMD_TAGS( - CMD_TAG_PRESENCE) - CMD_SYN( - "/lastactivity on|off", - "/lastactivity [<jid>]") - CMD_DESC( - "Enable/disable sending last activity, and send last activity requests.") - CMD_ARGS( - { "on|off", "Enable or disable sending of last activity." }, - { "<jid>", "The JID of the entity to query, omitting the JID will query your server." }) - CMD_EXAMPLES( - "/lastactivity", - "/lastactivity off", - "/lastactivity freyja@asgaard.edda", - "/lastactivity freyja@asgaard.edda/laptop", - "/lastactivity someserver.com") - }, + parse_args, 0, 1, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_lastactivity) + CMD_TAGS( + CMD_TAG_PRESENCE) + CMD_SYN( + "/lastactivity on|off", + "/lastactivity [<jid>]") + CMD_DESC( + "Enable/disable sending last activity, and send last activity requests.") + CMD_ARGS( + { "on|off", "Enable or disable sending of last activity." }, + { "<jid>", "The JID of the entity to query, omitting the JID will query your server." }) + CMD_EXAMPLES( + "/lastactivity", + "/lastactivity off", + "/lastactivity freyja@asgaard.edda", + "/lastactivity freyja@asgaard.edda/laptop", + "/lastactivity someserver.com") }, { "/nick", - parse_args_with_freetext, 1, 1, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_nick) - CMD_TAGS( - CMD_TAG_GROUPCHAT) - CMD_SYN( - "/nick <nickname>") - CMD_DESC( - "Change your nickname in the current chat room.") - CMD_ARGS( - { "<nickname>", "Your new nickname." }) - CMD_NOEXAMPLES - }, + parse_args_with_freetext, 1, 1, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_nick) + CMD_TAGS( + CMD_TAG_GROUPCHAT) + CMD_SYN( + "/nick <nickname>") + CMD_DESC( + "Change your nickname in the current chat room.") + CMD_ARGS( + { "<nickname>", "Your new nickname." }) + CMD_NOEXAMPLES }, { "/win", - parse_args, 1, 1, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_win) - CMD_TAGS( - CMD_TAG_UI) - CMD_SYN( - "/win console", - "/win <num>", - "/win <barejid>", - "/win <nick>", - "/win <roomjid>", - "/win <roomoccupantjid>", - "/win xmlconsole", - "/win <plugin>") - CMD_DESC( - "Move to the specified window.") - CMD_ARGS( - { "console", "Focus the Console window." }, - { "<num>", "Focus specified window number." }, - { "<barejid>", "Focus chat window with contact by JID if open." }, - { "<nick>", "Focus chat window with contact by nickname if open." }, - { "<roomjid>", "Focus chat room window with roomjid if open." }, - { "<roomoccupantjid>", "Focus private chat roomoccupantjid if open." }, - { "xmlconsole", "Focus the XML Console window if open." }, - { "<plugin>", "Focus the plugin window."}) - CMD_EXAMPLES( - "/win console", - "/win 4", - "/win odin@valhalla.edda", - "/win Eddie", - "/win bigroom@conference.chat.org", - "/win bigroom@conference.chat.org/thor", - "/win wikipedia") - }, + parse_args, 1, 1, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_win) + CMD_TAGS( + CMD_TAG_UI) + CMD_SYN( + "/win console", + "/win <num>", + "/win <barejid>", + "/win <nick>", + "/win <roomjid>", + "/win <roomoccupantjid>", + "/win xmlconsole", + "/win <plugin>") + CMD_DESC( + "Move to the specified window.") + CMD_ARGS( + { "console", "Focus the Console window." }, + { "<num>", "Focus specified window number." }, + { "<barejid>", "Focus chat window with contact by JID if open." }, + { "<nick>", "Focus chat window with contact by nickname if open." }, + { "<roomjid>", "Focus chat room window with roomjid if open." }, + { "<roomoccupantjid>", "Focus private chat roomoccupantjid if open." }, + { "xmlconsole", "Focus the XML Console window if open." }, + { "<plugin>", "Focus the plugin window." }) + CMD_EXAMPLES( + "/win console", + "/win 4", + "/win odin@valhalla.edda", + "/win Eddie", + "/win bigroom@conference.chat.org", + "/win bigroom@conference.chat.org/thor", + "/win wikipedia") }, { "/wins", - parse_args, 0, 3, NULL, - CMD_SUBFUNCS( - { "unread", cmd_wins_unread }, - { "prune", cmd_wins_prune }, - { "swap", cmd_wins_swap }) - CMD_MAINFUNC(cmd_wins) - CMD_TAGS( - CMD_TAG_UI) - CMD_SYN( - "/wins", - "/wins unread", - "/wins prune", - "/wins swap <source> <target>") - CMD_DESC( - "Manage windows. " - "Passing no argument will list all currently active windows and information about their usage.") - CMD_ARGS( - { "unread", "List windows with unread messages." }, - { "prune", "Close all windows with no unread messages." }, - { "swap <source> <target>", "Swap windows, target may be an empty position." }) - CMD_NOEXAMPLES - }, + parse_args, 0, 3, NULL, + CMD_SUBFUNCS( + { "unread", cmd_wins_unread }, + { "prune", cmd_wins_prune }, + { "swap", cmd_wins_swap }) + CMD_MAINFUNC(cmd_wins) + CMD_TAGS( + CMD_TAG_UI) + CMD_SYN( + "/wins", + "/wins unread", + "/wins prune", + "/wins swap <source> <target>") + CMD_DESC( + "Manage windows. " + "Passing no argument will list all currently active windows and information about their usage.") + CMD_ARGS( + { "unread", "List windows with unread messages." }, + { "prune", "Close all windows with no unread messages." }, + { "swap <source> <target>", "Swap windows, target may be an empty position." }) + CMD_NOEXAMPLES }, { "/sub", - parse_args, 1, 2, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_sub) - CMD_TAGS( - CMD_TAG_ROSTER) - CMD_SYN( - "/sub request [<jid>]", - "/sub allow [<jid>]", - "/sub deny [<jid>]", - "/sub show [<jid>]", - "/sub sent", - "/sub received") - CMD_DESC( - "Manage subscriptions to contact presence. " - "If jid is omitted, the contact of the current window is used.") - CMD_ARGS( - { "request [<jid>]", "Send a subscription request to the user." }, - { "allow [<jid>]", "Approve a contact's subscription request." }, - { "deny [<jid>]", "Remove subscription for a contact, or deny a request." }, - { "show [<jid>]", "Show subscription status for a contact." }, - { "sent", "Show all sent subscription requests pending a response." }, - { "received", "Show all received subscription requests awaiting your response." }) - CMD_EXAMPLES( - "/sub request odin@valhalla.edda", - "/sub allow odin@valhalla.edda", - "/sub request", - "/sub sent") - }, + parse_args, 1, 2, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_sub) + CMD_TAGS( + CMD_TAG_ROSTER) + CMD_SYN( + "/sub request [<jid>]", + "/sub allow [<jid>]", + "/sub deny [<jid>]", + "/sub show [<jid>]", + "/sub sent", + "/sub received") + CMD_DESC( + "Manage subscriptions to contact presence. " + "If jid is omitted, the contact of the current window is used.") + CMD_ARGS( + { "request [<jid>]", "Send a subscription request to the user." }, + { "allow [<jid>]", "Approve a contact's subscription request." }, + { "deny [<jid>]", "Remove subscription for a contact, or deny a request." }, + { "show [<jid>]", "Show subscription status for a contact." }, + { "sent", "Show all sent subscription requests pending a response." }, + { "received", "Show all received subscription requests awaiting your response." }) + CMD_EXAMPLES( + "/sub request odin@valhalla.edda", + "/sub allow odin@valhalla.edda", + "/sub request", + "/sub sent") }, { "/tiny", - parse_args, 1, 1, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_tiny) - CMD_TAGS( - CMD_TAG_CHAT, - CMD_TAG_GROUPCHAT) - CMD_SYN( - "/tiny <url>") - CMD_DESC( - "Send url as tinyurl in current chat.") - CMD_ARGS( - { "<url>", "The url to make tiny." }) - CMD_EXAMPLES( - "Example: /tiny https://profanity-im.github.io/") - }, + parse_args, 1, 1, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_tiny) + CMD_TAGS( + CMD_TAG_CHAT, + CMD_TAG_GROUPCHAT) + CMD_SYN( + "/tiny <url>") + CMD_DESC( + "Send url as tinyurl in current chat.") + CMD_ARGS( + { "<url>", "The url to make tiny." }) + CMD_EXAMPLES( + "Example: /tiny https://profanity-im.github.io/") }, { "/who", - parse_args, 0, 2, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_who) - CMD_TAGS( - CMD_TAG_CHAT, - CMD_TAG_GROUPCHAT, - CMD_TAG_ROSTER) - CMD_SYN( - "/who", - "/who online|offline|away|dnd|xa|chat|available|unavailable|any [<group>]", - "/who moderator|participant|visitor", - "/who owner|admin|member") - CMD_DESC( - "Show contacts or room occupants with chosen status, role or affiliation.") - CMD_ARGS( - { "offline|away|dnd|xa|chat", "Show contacts or room occupants with specified presence." }, - { "online", "Contacts that are online, chat, away, xa, dnd." }, - { "available", "Contacts that are available for chat - online, chat." }, - { "unavailable", "Contacts that are not available for chat - offline, away, xa, dnd." }, - { "any", "Contacts with any status (same as calling with no argument)." }, - { "<group>", "Filter the results by the specified roster group, not applicable in chat rooms." }, - { "moderator|participant|visitor", "Room occupants with the specified role." }, - { "owner|admin|member", "Room occupants with the specified affiliation." }) - CMD_EXAMPLES( - "/who", - "/who xa", - "/who online friends", - "/who any family", - "/who participant", - "/who admin") - }, + parse_args, 0, 2, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_who) + CMD_TAGS( + CMD_TAG_CHAT, + CMD_TAG_GROUPCHAT, + CMD_TAG_ROSTER) + CMD_SYN( + "/who", + "/who online|offline|away|dnd|xa|chat|available|unavailable|any [<group>]", + "/who moderator|participant|visitor", + "/who owner|admin|member") + CMD_DESC( + "Show contacts or room occupants with chosen status, role or affiliation.") + CMD_ARGS( + { "offline|away|dnd|xa|chat", "Show contacts or room occupants with specified presence." }, + { "online", "Contacts that are online, chat, away, xa, dnd." }, + { "available", "Contacts that are available for chat - online, chat." }, + { "unavailable", "Contacts that are not available for chat - offline, away, xa, dnd." }, + { "any", "Contacts with any status (same as calling with no argument)." }, + { "<group>", "Filter the results by the specified roster group, not applicable in chat rooms." }, + { "moderator|participant|visitor", "Room occupants with the specified role." }, + { "owner|admin|member", "Room occupants with the specified affiliation." }) + CMD_EXAMPLES( + "/who", + "/who xa", + "/who online friends", + "/who any family", + "/who participant", + "/who admin") }, { "/close", - parse_args, 0, 1, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_close) - CMD_TAGS( - CMD_TAG_UI) - CMD_SYN( - "/close", - "/close <num>", - "/close <barejid>", - "/close <nick>", - "/close <roomjid>", - "/close <roomoccupantjid>", - "/close xmlconsole", - "/close all|read") - CMD_DESC( - "Close windows. " - "Passing no argument closes the current window.") - CMD_ARGS( - { "<num>", "Close specified window number." }, - { "<barejid>", "Close chat window with contact by JID if open." }, - { "<nick>", "Close chat window with contact by nickname if open." }, - { "<roomjid>", "Close chat room window with roomjid if open." }, - { "<roomoccupantjid>", "Close private chat roomoccupantjid if open." }, - { "xmlconsole", "Close the XML Console window if open." }, - { "all", "Close all windows." }, - { "read", "Close all windows that have no unread messages." }) - CMD_NOEXAMPLES - }, + parse_args, 0, 1, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_close) + CMD_TAGS( + CMD_TAG_UI) + CMD_SYN( + "/close", + "/close <num>", + "/close <barejid>", + "/close <nick>", + "/close <roomjid>", + "/close <roomoccupantjid>", + "/close xmlconsole", + "/close all|read") + CMD_DESC( + "Close windows. " + "Passing no argument closes the current window.") + CMD_ARGS( + { "<num>", "Close specified window number." }, + { "<barejid>", "Close chat window with contact by JID if open." }, + { "<nick>", "Close chat window with contact by nickname if open." }, + { "<roomjid>", "Close chat room window with roomjid if open." }, + { "<roomoccupantjid>", "Close private chat roomoccupantjid if open." }, + { "xmlconsole", "Close the XML Console window if open." }, + { "all", "Close all windows." }, + { "read", "Close all windows that have no unread messages." }) + CMD_NOEXAMPLES }, { "/clear", - parse_args, 0, 2, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_clear) - CMD_TAGS( - CMD_TAG_UI) - CMD_SYN( - "/clear", - "/clear persist_history <on|off>") - CMD_DESC( - "Clear the current window. " - "If you set persist_history you can still access the history by pressing PAGE UP.") - CMD_ARGS( - { "persist_history on|off", "Whether or not to clear the screen persistently."}) - CMD_EXAMPLES( - "/clear", - "/clear persist_history", - "/clear persist_history on") - }, + parse_args, 0, 2, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_clear) + CMD_TAGS( + CMD_TAG_UI) + CMD_SYN( + "/clear", + "/clear persist_history <on|off>") + CMD_DESC( + "Clear the current window. " + "If you set persist_history you can still access the history by pressing PAGE UP.") + CMD_ARGS( + { "persist_history on|off", "Whether or not to clear the screen persistently." }) + CMD_EXAMPLES( + "/clear", + "/clear persist_history", + "/clear persist_history on") }, { "/quit", - parse_args, 0, 0, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_quit) - CMD_NOTAGS - CMD_SYN( - "/quit") - CMD_DESC( - "Logout of any current session, and quit Profanity.") - CMD_NOARGS - CMD_NOEXAMPLES - }, + parse_args, 0, 0, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_quit) + CMD_NOTAGS + CMD_SYN( + "/quit") + CMD_DESC( + "Logout of any current session, and quit Profanity.") + CMD_NOARGS + CMD_NOEXAMPLES }, { "/privileges", - parse_args, 1, 1, &cons_privileges_setting, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_privileges) - CMD_TAGS( - CMD_TAG_GROUPCHAT, - CMD_TAG_UI) - CMD_SYN( - "/privileges on|off") - CMD_DESC( - "Group occupants panel by role, and show role information in chat rooms.") - CMD_ARGS( - { "on|off", "Enable or disable privilege information." }) - CMD_NOEXAMPLES - }, + parse_args, 1, 1, &cons_privileges_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_privileges) + CMD_TAGS( + CMD_TAG_GROUPCHAT, + CMD_TAG_UI) + CMD_SYN( + "/privileges on|off") + CMD_DESC( + "Group occupants panel by role, and show role information in chat rooms.") + CMD_ARGS( + { "on|off", "Enable or disable privilege information." }) + CMD_NOEXAMPLES }, { "/charset", - parse_args, 0, 0, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_charset) - CMD_TAGS( - CMD_TAG_UI) - CMD_SYN( - "/charset") - CMD_DESC( - "Display information about the current character set supported by the terminal. ") - CMD_NOARGS - CMD_NOEXAMPLES - }, + parse_args, 0, 0, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_charset) + CMD_TAGS( + CMD_TAG_UI) + CMD_SYN( + "/charset") + CMD_DESC( + "Display information about the current character set supported by the terminal. ") + CMD_NOARGS + CMD_NOEXAMPLES }, { "/beep", - parse_args, 1, 1, &cons_beep_setting, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_beep) - CMD_TAGS( - CMD_TAG_UI) - CMD_SYN( - "/beep on|off") - CMD_DESC( - "Switch the terminal bell on or off. " - "The bell will sound when incoming messages are received. " - "If the terminal does not support sounds, it may attempt to flash the screen instead.") - CMD_ARGS( - { "on|off", "Enable or disable terminal bell." }) - CMD_NOEXAMPLES - }, + parse_args, 1, 1, &cons_beep_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_beep) + CMD_TAGS( + CMD_TAG_UI) + CMD_SYN( + "/beep on|off") + CMD_DESC( + "Switch the terminal bell on or off. " + "The bell will sound when incoming messages are received. " + "If the terminal does not support sounds, it may attempt to flash the screen instead.") + CMD_ARGS( + { "on|off", "Enable or disable terminal bell." }) + CMD_NOEXAMPLES }, { "/console", - parse_args, 2, 2, &cons_console_setting, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_console) - CMD_TAGS( - CMD_TAG_UI, - CMD_TAG_CHAT, - CMD_TAG_GROUPCHAT) - CMD_SYN( - "/console chat all|first|none", - "/console muc all|first|none", - "/console private all|first|none") - CMD_DESC( - "Configure what is displayed in the console window when messages are received. " - "The default is set to 'all' for all types of messages.") - CMD_ARGS( - { "chat all", "Indicate all new chat messages in the console." }, - { "chat first", "Indicate only the first new message per chat in the console." }, - { "chat none", "Do not show any new chat messages in the console window." }, - { "muc all", "Indicate all new chat room messages in the console." }, - { "muc first", "Indicate only the first new message in each room in the console." }, - { "muc none", "Do not show any new chat room messages in the console window." }, - { "private all", "Indicate all new private room messages in the console." }, - { "private first", "Indicate only the first private room message in the console." }, - { "private none", "Do not show any new private room messages in the console window." }) - CMD_NOEXAMPLES - }, + parse_args, 2, 2, &cons_console_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_console) + CMD_TAGS( + CMD_TAG_UI, + CMD_TAG_CHAT, + CMD_TAG_GROUPCHAT) + CMD_SYN( + "/console chat all|first|none", + "/console muc all|first|none", + "/console private all|first|none") + CMD_DESC( + "Configure what is displayed in the console window when messages are received. " + "The default is set to 'all' for all types of messages.") + CMD_ARGS( + { "chat all", "Indicate all new chat messages in the console." }, + { "chat first", "Indicate only the first new message per chat in the console." }, + { "chat none", "Do not show any new chat messages in the console window." }, + { "muc all", "Indicate all new chat room messages in the console." }, + { "muc first", "Indicate only the first new message in each room in the console." }, + { "muc none", "Do not show any new chat room messages in the console window." }, + { "private all", "Indicate all new private room messages in the console." }, + { "private first", "Indicate only the first private room message in the console." }, + { "private none", "Do not show any new private room messages in the console window." }) + CMD_NOEXAMPLES }, { "/presence", - parse_args, 2, 2, &cons_presence_setting, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_presence) - CMD_TAGS( - CMD_TAG_UI, - CMD_TAG_CHAT, - CMD_TAG_GROUPCHAT) - CMD_SYN( - "/presence titlebar on|off", - "/presence console all|online|none", - "/presence chat all|online|none", - "/presence room all|online|none") - CMD_DESC( - "Show the contacts presence in the titlebar and configure presence messages in different window types.") - CMD_ARGS( - { "titlebar on|off", "Switch display of the contacts presence in the titlebar on or off." }, - { "console all", "Show all presence changes in the console window." }, - { "console online", "Show only online/offline presence changes in the console window." }, - { "console none", "Don't show any presence changes in the console window." }, - { "chat all", "Show all presence changes in the chat windows." }, - { "chat online", "Show only online/offline presence changes in chat windows." }, - { "chat none", "Don't show any presence changes in chat windows." }, - { "room all", "Show all presence changes in chat room windows." }, - { "room online", "Show only online/offline presence changes in chat room windows." }, - { "room none", "Don't show any presence changes in chat room windows." }) - CMD_EXAMPLES( - "/presence titlebar off", - "/presence console none", - "/presence chat online", - "/presence room all") - }, + parse_args, 2, 2, &cons_presence_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_presence) + CMD_TAGS( + CMD_TAG_UI, + CMD_TAG_CHAT, + CMD_TAG_GROUPCHAT) + CMD_SYN( + "/presence titlebar on|off", + "/presence console all|online|none", + "/presence chat all|online|none", + "/presence room all|online|none") + CMD_DESC( + "Show the contacts presence in the titlebar and configure presence messages in different window types.") + CMD_ARGS( + { "titlebar on|off", "Switch display of the contacts presence in the titlebar on or off." }, + { "console all", "Show all presence changes in the console window." }, + { "console online", "Show only online/offline presence changes in the console window." }, + { "console none", "Don't show any presence changes in the console window." }, + { "chat all", "Show all presence changes in the chat windows." }, + { "chat online", "Show only online/offline presence changes in chat windows." }, + { "chat none", "Don't show any presence changes in chat windows." }, + { "room all", "Show all presence changes in chat room windows." }, + { "room online", "Show only online/offline presence changes in chat room windows." }, + { "room none", "Don't show any presence changes in chat room windows." }) + CMD_EXAMPLES( + "/presence titlebar off", + "/presence console none", + "/presence chat online", + "/presence room all") }, { "/wrap", - parse_args, 1, 1, &cons_wrap_setting, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_wrap) - CMD_TAGS( - CMD_TAG_UI) - CMD_SYN( - "/wrap on|off") - CMD_DESC( - "Word wrapping.") - CMD_ARGS( - { "on|off", "Enable or disable word wrapping in the main window." }) - CMD_NOEXAMPLES - }, + parse_args, 1, 1, &cons_wrap_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_wrap) + CMD_TAGS( + CMD_TAG_UI) + CMD_SYN( + "/wrap on|off") + CMD_DESC( + "Word wrapping.") + CMD_ARGS( + { "on|off", "Enable or disable word wrapping in the main window." }) + CMD_NOEXAMPLES }, { "/time", - parse_args, 1, 3, &cons_time_setting, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_time) - CMD_TAGS( - CMD_TAG_UI) - CMD_SYN( - "/time all|console|chat|muc|config|private|xml set <format>", - "/time all|console|chat|muc|config|private|xml off", - "/time statusbar set <format>", - "/time statusbar off", - "/time lastactivity set <format>") - CMD_DESC( - "Configure time display preferences. " - "Time formats are strings supported by g_date_time_format. " - "See https://developer.gnome.org/glib/stable/glib-GDateTime.html#g-date-time-format for more details. " - "Setting the format to an unsupported string, will display the string. " - "If the format contains spaces, it must be surrounded with double quotes.") - CMD_ARGS( - { "console set <format>", "Set time format for console window." }, - { "console off", "Do not show time in console window." }, - { "chat set <format>", "Set time format for chat windows." }, - { "chat off", "Do not show time in chat windows." }, - { "muc set <format>", "Set time format for chat room windows." }, - { "muc off", "Do not show time in chat room windows." }, - { "config set <format>", "Set time format for config windows." }, - { "config off", "Do not show time in config windows." }, - { "private set <format>", "Set time format for private chat windows." }, - { "private off", "Do not show time in private chat windows." }, - { "xml set <format>", "Set time format for XML console window." }, - { "xml off", "Do not show time in XML console window." }, - { "statusbar set <format>", "Change time format in statusbar." }, - { "statusbar off", "Do not show time in status bar." }, - { "lastactivity set <format>", "Change time format for last activity." }, - { "all set <format>", "Set time for: console, chat, muc, config, private and xml windows." }, - { "all off", "Do not show time for: console, chat, muc, config, private and xml windows." }) - CMD_EXAMPLES( - "/time console set %H:%M:%S", - "/time chat set \"%d-%m-%y %H:%M:%S\"", - "/time xml off", - "/time statusbar set %H:%M", - "/time lastactivity set \"%d-%m-%y %H:%M:%S\"", - "/time all set \"%d-%m-%y %H:%M:%S\"") - }, + parse_args, 1, 3, &cons_time_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_time) + CMD_TAGS( + CMD_TAG_UI) + CMD_SYN( + "/time all|console|chat|muc|config|private|xml set <format>", + "/time all|console|chat|muc|config|private|xml off", + "/time statusbar set <format>", + "/time statusbar off", + "/time lastactivity set <format>") + CMD_DESC( + "Configure time display preferences. " + "Time formats are strings supported by g_date_time_format. " + "See https://developer.gnome.org/glib/stable/glib-GDateTime.html#g-date-time-format for more details. " + "Setting the format to an unsupported string, will display the string. " + "If the format contains spaces, it must be surrounded with double quotes.") + CMD_ARGS( + { "console set <format>", "Set time format for console window." }, + { "console off", "Do not show time in console window." }, + { "chat set <format>", "Set time format for chat windows." }, + { "chat off", "Do not show time in chat windows." }, + { "muc set <format>", "Set time format for chat room windows." }, + { "muc off", "Do not show time in chat room windows." }, + { "config set <format>", "Set time format for config windows." }, + { "config off", "Do not show time in config windows." }, + { "private set <format>", "Set time format for private chat windows." }, + { "private off", "Do not show time in private chat windows." }, + { "xml set <format>", "Set time format for XML console window." }, + { "xml off", "Do not show time in XML console window." }, + { "statusbar set <format>", "Change time format in statusbar." }, + { "statusbar off", "Do not show time in status bar." }, + { "lastactivity set <format>", "Change time format for last activity." }, + { "all set <format>", "Set time for: console, chat, muc, config, private and xml windows." }, + { "all off", "Do not show time for: console, chat, muc, config, private and xml windows." }) + CMD_EXAMPLES( + "/time console set %H:%M:%S", + "/time chat set \"%d-%m-%y %H:%M:%S\"", + "/time xml off", + "/time statusbar set %H:%M", + "/time lastactivity set \"%d-%m-%y %H:%M:%S\"", + "/time all set \"%d-%m-%y %H:%M:%S\"") }, { "/inpblock", - parse_args, 2, 2, &cons_inpblock_setting, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_inpblock) - CMD_TAGS( - CMD_TAG_UI) - CMD_SYN( - "/inpblock timeout <millis>", - "/inpblock dynamic on|off") - CMD_DESC( - "How long to wait for keyboard input before checking for new messages or checking for state changes such as 'idle'.") - CMD_ARGS( - { "timeout <millis>", "Time to wait (1-1000) in milliseconds before reading input from the terminal buffer, default: 1000." }, - { "dynamic on|off", "Start with 0 millis and dynamically increase up to timeout when no activity, default: on." }) - CMD_NOEXAMPLES - }, + parse_args, 2, 2, &cons_inpblock_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_inpblock) + CMD_TAGS( + CMD_TAG_UI) + CMD_SYN( + "/inpblock timeout <millis>", + "/inpblock dynamic on|off") + CMD_DESC( + "How long to wait for keyboard input before checking for new messages or checking for state changes such as 'idle'.") + CMD_ARGS( + { "timeout <millis>", "Time to wait (1-1000) in milliseconds before reading input from the terminal buffer, default: 1000." }, + { "dynamic on|off", "Start with 0 millis and dynamically increase up to timeout when no activity, default: on." }) + CMD_NOEXAMPLES }, { "/titlebar", - parse_args, 1, 2, &cons_titlebar_setting, - CMD_SUBFUNCS( - { "show", cmd_titlebar_show_hide }, - { "hide", cmd_titlebar_show_hide } - ) - CMD_MAINFUNC(cmd_titlebar) - CMD_TAGS( - CMD_TAG_UI) - CMD_SYN( - "/titlebar up", - "/titlebar down", - "/titlebar show|hide [encwarn|resource|tls]" - ) - CMD_DESC( - "Titlebar settings.") - CMD_ARGS( - { "up", "Move the title bar up the screen." }, - { "down", "Move the title bar down the screen." }, - { "show tls", "Show or hide TLS indicator in the titlebar." }, - { "show encwarn", "Enable or disable the unencrypted warning message in the titlebar." }, - { "show resource", "Show or hide the current resource in the titlebar." }, - { "show name", "In case of a MUC. Show the MUC name in the titlebar." }, - { "show jid", "In case of a MUC. Show the JID in the titlebar." } - ) - CMD_EXAMPLES( - "/titlebar up", - "/titlebar show tls", - "/titlebar hide encwarn") - }, + parse_args, 1, 2, &cons_titlebar_setting, + CMD_SUBFUNCS( + { "show", cmd_titlebar_show_hide }, + { "hide", cmd_titlebar_show_hide }) + CMD_MAINFUNC(cmd_titlebar) + CMD_TAGS( + CMD_TAG_UI) + CMD_SYN( + "/titlebar up", + "/titlebar down", + "/titlebar show|hide [encwarn|resource|tls]") + CMD_DESC( + "Titlebar settings.") + CMD_ARGS( + { "up", "Move the title bar up the screen." }, + { "down", "Move the title bar down the screen." }, + { "show tls", "Show or hide TLS indicator in the titlebar." }, + { "show encwarn", "Enable or disable the unencrypted warning message in the titlebar." }, + { "show resource", "Show or hide the current resource in the titlebar." }, + { "show name", "In case of a MUC. Show the MUC name in the titlebar." }, + { "show jid", "In case of a MUC. Show the JID in the titlebar." }) + CMD_EXAMPLES( + "/titlebar up", + "/titlebar show tls", + "/titlebar hide encwarn") }, { "/mainwin", - parse_args, 1, 1, &cons_winpos_setting, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_mainwin) - CMD_TAGS( - CMD_TAG_UI) - CMD_SYN( - "/mainwin up", - "/mainwin down") - CMD_DESC( - "Move the main window.") - CMD_ARGS( - { "up", "Move the main window up the screen." }, - { "down", "Move the main window down the screen." }) - CMD_NOEXAMPLES - }, + parse_args, 1, 1, &cons_winpos_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_mainwin) + CMD_TAGS( + CMD_TAG_UI) + CMD_SYN( + "/mainwin up", + "/mainwin down") + CMD_DESC( + "Move the main window.") + CMD_ARGS( + { "up", "Move the main window up the screen." }, + { "down", "Move the main window down the screen." }) + CMD_NOEXAMPLES }, { "/statusbar", - parse_args, 1, 2, &cons_statusbar_setting, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_statusbar) - CMD_TAGS( - CMD_TAG_UI) - CMD_SYN( - "/statusbar show name|number|read", - "/statusbar hide name|number|read", - "/statusbar maxtabs <value>", - "/statusbar tablen <value>", - "/statusbar self user|barejid|fulljid|off", - "/statusbar chat user|jid", - "/statusbar room room|jid", - "/statusbar up", - "/statusbar down") - CMD_DESC( - "Manage statusbar display preferences.") - CMD_ARGS( - { "maxtabs <value>", "Set the maximum number of tabs to display, <value> must be between 0 and 10." }, - { "tablen <value>", "Set the maximum number of characters to show as the tab name, 0 sets to unlimited." }, - { "show|hide name", "Show or hide names in tabs." }, - { "show|hide number", "Show or hide numbers in tabs." }, - { "show|hide read", "Show or hide inactive tabs." }, - { "self user|barejid|fulljid", "Show account user name, barejid, fulljid as status bar title." }, - { "self off", "Disable showing self as status bar title." }, - { "chat user|jid", "Show users name, or the fulljid if no nick is present for chat tabs." }, - { "room room|jid", "Show room name, or the fulljid for room tabs." }, - { "up", "Move the status bar up the screen." }, - { "down", "Move the status bar down the screen." }) - CMD_EXAMPLES( - "/statusbar maxtabs 8", - "/statusbar tablen 5", - "/statusbar self user", - "/statusbar chat jid", - "/statusbar hide read", - "/statusbar hide name") - }, + parse_args, 1, 2, &cons_statusbar_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_statusbar) + CMD_TAGS( + CMD_TAG_UI) + CMD_SYN( + "/statusbar show name|number|read", + "/statusbar hide name|number|read", + "/statusbar maxtabs <value>", + "/statusbar tablen <value>", + "/statusbar self user|barejid|fulljid|off", + "/statusbar chat user|jid", + "/statusbar room room|jid", + "/statusbar up", + "/statusbar down") + CMD_DESC( + "Manage statusbar display preferences.") + CMD_ARGS( + { "maxtabs <value>", "Set the maximum number of tabs to display, <value> must be between 0 and 10." }, + { "tablen <value>", "Set the maximum number of characters to show as the tab name, 0 sets to unlimited." }, + { "show|hide name", "Show or hide names in tabs." }, + { "show|hide number", "Show or hide numbers in tabs." }, + { "show|hide read", "Show or hide inactive tabs." }, + { "self user|barejid|fulljid", "Show account user name, barejid, fulljid as status bar title." }, + { "self off", "Disable showing self as status bar title." }, + { "chat user|jid", "Show users name, or the fulljid if no nick is present for chat tabs." }, + { "room room|jid", "Show room name, or the fulljid for room tabs." }, + { "up", "Move the status bar up the screen." }, + { "down", "Move the status bar down the screen." }) + CMD_EXAMPLES( + "/statusbar maxtabs 8", + "/statusbar tablen 5", + "/statusbar self user", + "/statusbar chat jid", + "/statusbar hide read", + "/statusbar hide name") }, { "/inputwin", - parse_args, 1, 1, &cons_winpos_setting, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_inputwin) - CMD_TAGS( - CMD_TAG_UI) - CMD_SYN( - "/inputwin up", - "/inputwin down") - CMD_DESC( - "Move the input window.") - CMD_ARGS( - { "up", "Move the input window up the screen." }, - { "down", "Move the input window down the screen." }) - CMD_NOEXAMPLES - }, + parse_args, 1, 1, &cons_winpos_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_inputwin) + CMD_TAGS( + CMD_TAG_UI) + CMD_SYN( + "/inputwin up", + "/inputwin down") + CMD_DESC( + "Move the input window.") + CMD_ARGS( + { "up", "Move the input window up the screen." }, + { "down", "Move the input window down the screen." }) + CMD_NOEXAMPLES }, { "/notify", - parse_args_with_freetext, 0, 4, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_notify) - CMD_TAGS( - CMD_TAG_UI, - CMD_TAG_CHAT, - CMD_TAG_GROUPCHAT) - CMD_SYN( - "/notify chat on|off", - "/notify chat current on|off", - "/notify chat text on|off", - "/notify room on|off", - "/notify room mention on|off", - "/notify room mention case_sensitive|case_insensitive", - "/notify room mention word_whole|word_part", - "/notify room current on|off", - "/notify room text on|off", - "/notify room trigger add <text>", - "/notify room trigger remove <text>", - "/notify room trigger list", - "/notify room trigger on|off", - "/notify on|off", - "/notify mention on|off", - "/notify trigger on|off", - "/notify reset", - "/notify remind <seconds>", - "/notify typing on|off", - "/notify typing current on|off", - "/notify invite on|off", - "/notify sub on|off") - CMD_DESC( - "Configure desktop notifications. " - "To configure presence update messages in the console, chat and chat room windows, see '/help presence'.") - CMD_ARGS( - { "chat on|off", "Notifications for regular chat messages." }, - { "chat current on|off", "Whether to show regular chat message notifications when the window is focussed." }, - { "chat text on|off", "Show message text in regular message notifications." }, - { "room on|off", "Notifications for all chat room messages." }, - { "room mention on|off", "Notifications for chat room messages when your nick is mentioned." }, - { "room mention case_sensitive", "Set room mention notifications as case sensitive." }, - { "room mention case_insensitive", "Set room mention notifications as case insensitive." }, - { "room mention word_whole", "Set room mention notifications only on whole word match, i.e. when nickname is not part of a larger word." }, - { "room mention word_part", "Set room mention notifications on partial word match, i.e. nickname may be part of a larger word." }, - { "room current on|off", "Whether to show all chat room messages notifications when the window is focussed." }, - { "room text on|off", "Show message text in chat room message notifications." }, - { "room trigger add <text>", "Notify when specified text included in all chat room messages." }, - { "room trigger remove <text>", "Remove chat room notification trigger." }, - { "room trigger list", "List all chat room highlight triggers." }, - { "room trigger on|off", "Enable or disable all chat room notification triggers." }, - { "on|off", "Override the global message setting for the current chat room." }, - { "mention on|off", "Override the global 'mention' setting for the current chat room." }, - { "trigger on|off", "Override the global 'trigger' setting for the current chat room." }, - { "reset", "Reset to global notification settings for the current chat room." }, - { "remind <seconds>", "Notification reminder period for unread messages, use 0 to disable." }, - { "typing on|off", "Notifications when contacts are typing." }, - { "typing current on|off", "Whether typing notifications are triggered for the current window." }, - { "invite on|off", "Notifications for chat room invites." }, - { "sub on|off", "Notifications for subscription requests." }) - CMD_EXAMPLES( - "/notify chat on", - "/notify chat text on", - "/notify room mention on", - "/notify room trigger add beer", - "/notify room trigger on", - "/notify room current off", - "/notify room text off", - "/notify remind 60", - "/notify typing on", - "/notify invite on") - }, + parse_args_with_freetext, 0, 4, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_notify) + CMD_TAGS( + CMD_TAG_UI, + CMD_TAG_CHAT, + CMD_TAG_GROUPCHAT) + CMD_SYN( + "/notify chat on|off", + "/notify chat current on|off", + "/notify chat text on|off", + "/notify room on|off", + "/notify room mention on|off", + "/notify room mention case_sensitive|case_insensitive", + "/notify room mention word_whole|word_part", + "/notify room current on|off", + "/notify room text on|off", + "/notify room trigger add <text>", + "/notify room trigger remove <text>", + "/notify room trigger list", + "/notify room trigger on|off", + "/notify on|off", + "/notify mention on|off", + "/notify trigger on|off", + "/notify reset", + "/notify remind <seconds>", + "/notify typing on|off", + "/notify typing current on|off", + "/notify invite on|off", + "/notify sub on|off") + CMD_DESC( + "Configure desktop notifications. " + "To configure presence update messages in the console, chat and chat room windows, see '/help presence'.") + CMD_ARGS( + { "chat on|off", "Notifications for regular chat messages." }, + { "chat current on|off", "Whether to show regular chat message notifications when the window is focussed." }, + { "chat text on|off", "Show message text in regular message notifications." }, + { "room on|off", "Notifications for all chat room messages." }, + { "room mention on|off", "Notifications for chat room messages when your nick is mentioned." }, + { "room mention case_sensitive", "Set room mention notifications as case sensitive." }, + { "room mention case_insensitive", "Set room mention notifications as case insensitive." }, + { "room mention word_whole", "Set room mention notifications only on whole word match, i.e. when nickname is not part of a larger word." }, + { "room mention word_part", "Set room mention notifications on partial word match, i.e. nickname may be part of a larger word." }, + { "room current on|off", "Whether to show all chat room messages notifications when the window is focussed." }, + { "room text on|off", "Show message text in chat room message notifications." }, + { "room trigger add <text>", "Notify when specified text included in all chat room messages." }, + { "room trigger remove <text>", "Remove chat room notification trigger." }, + { "room trigger list", "List all chat room highlight triggers." }, + { "room trigger on|off", "Enable or disable all chat room notification triggers." }, + { "on|off", "Override the global message setting for the current chat room." }, + { "mention on|off", "Override the global 'mention' setting for the current chat room." }, + { "trigger on|off", "Override the global 'trigger' setting for the current chat room." }, + { "reset", "Reset to global notification settings for the current chat room." }, + { "remind <seconds>", "Notification reminder period for unread messages, use 0 to disable." }, + { "typing on|off", "Notifications when contacts are typing." }, + { "typing current on|off", "Whether typing notifications are triggered for the current window." }, + { "invite on|off", "Notifications for chat room invites." }, + { "sub on|off", "Notifications for subscription requests." }) + CMD_EXAMPLES( + "/notify chat on", + "/notify chat text on", + "/notify room mention on", + "/notify room trigger add beer", + "/notify room trigger on", + "/notify room current off", + "/notify room text off", + "/notify remind 60", + "/notify typing on", + "/notify invite on") }, { "/flash", - parse_args, 1, 1, &cons_flash_setting, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_flash) - CMD_TAGS( - CMD_TAG_UI) - CMD_SYN( - "/flash on|off") - CMD_DESC( - "Make the terminal flash when incoming messages are received in another window. " - "If the terminal doesn't support flashing, it may attempt to beep.") - CMD_ARGS( - { "on|off", "Enable or disable terminal flash." }) - CMD_NOEXAMPLES - }, + parse_args, 1, 1, &cons_flash_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_flash) + CMD_TAGS( + CMD_TAG_UI) + CMD_SYN( + "/flash on|off") + CMD_DESC( + "Make the terminal flash when incoming messages are received in another window. " + "If the terminal doesn't support flashing, it may attempt to beep.") + CMD_ARGS( + { "on|off", "Enable or disable terminal flash." }) + CMD_NOEXAMPLES }, { "/tray", - parse_args, 1, 2, &cons_tray_setting, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_tray) - CMD_TAGS( - CMD_TAG_UI) - CMD_SYN( - "/tray on|off", - "/tray read on|off", - "/tray timer <seconds>") - CMD_DESC( - "Display an icon in the tray that will indicate new messages.") - CMD_ARGS( - { "on|off", "Show tray icon." }, - { "read on|off", "Show tray icon when no unread messages." }, - { "timer <seconds>", "Set tray icon timer, seconds must be between 1-10." }) - CMD_NOEXAMPLES - }, + parse_args, 1, 2, &cons_tray_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_tray) + CMD_TAGS( + CMD_TAG_UI) + CMD_SYN( + "/tray on|off", + "/tray read on|off", + "/tray timer <seconds>") + CMD_DESC( + "Display an icon in the tray that will indicate new messages.") + CMD_ARGS( + { "on|off", "Show tray icon." }, + { "read on|off", "Show tray icon when no unread messages." }, + { "timer <seconds>", "Set tray icon timer, seconds must be between 1-10." }) + CMD_NOEXAMPLES }, { "/intype", - parse_args, 1, 1, &cons_intype_setting, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_intype) - CMD_TAGS( - CMD_TAG_UI, - CMD_TAG_CHAT) - CMD_SYN( - "/intype on|off") - CMD_DESC( - "Show when a contact is typing in the console, and in active message window.") - CMD_ARGS( - { "on|off", "Enable or disable contact typing messages." }) - CMD_NOEXAMPLES - }, + parse_args, 1, 1, &cons_intype_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_intype) + CMD_TAGS( + CMD_TAG_UI, + CMD_TAG_CHAT) + CMD_SYN( + "/intype on|off") + CMD_DESC( + "Show when a contact is typing in the console, and in active message window.") + CMD_ARGS( + { "on|off", "Enable or disable contact typing messages." }) + CMD_NOEXAMPLES }, { "/splash", - parse_args, 1, 1, &cons_splash_setting, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_splash) - CMD_TAGS( - CMD_TAG_UI) - CMD_SYN( - "/splash on|off") - CMD_DESC( - "Switch on or off the ascii logo on start up and when the /about command is called.") - CMD_ARGS( - { "on|off", "Enable or disable splash logo." }) - CMD_NOEXAMPLES - }, + parse_args, 1, 1, &cons_splash_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_splash) + CMD_TAGS( + CMD_TAG_UI) + CMD_SYN( + "/splash on|off") + CMD_DESC( + "Switch on or off the ascii logo on start up and when the /about command is called.") + CMD_ARGS( + { "on|off", "Enable or disable splash logo." }) + CMD_NOEXAMPLES }, { "/autoconnect", - parse_args, 1, 2, &cons_autoconnect_setting, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_autoconnect) - CMD_TAGS( - CMD_TAG_CONNECTION) - CMD_SYN( - "/autoconnect set <account>", - "/autoconnect off") - CMD_DESC( - "Enable or disable autoconnect on start up. " - "The setting can be overridden by the -a (--account) command line option.") - CMD_ARGS( - { "set <account>", "Connect with account on start up." }, - { "off", "Disable autoconnect." }) - CMD_EXAMPLES( - "/autoconnect set ulfhednar@valhalla.edda", - "/autoconnect off") - }, + parse_args, 1, 2, &cons_autoconnect_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_autoconnect) + CMD_TAGS( + CMD_TAG_CONNECTION) + CMD_SYN( + "/autoconnect set <account>", + "/autoconnect off") + CMD_DESC( + "Enable or disable autoconnect on start up. " + "The setting can be overridden by the -a (--account) command line option.") + CMD_ARGS( + { "set <account>", "Connect with account on start up." }, + { "off", "Disable autoconnect." }) + CMD_EXAMPLES( + "/autoconnect set ulfhednar@valhalla.edda", + "/autoconnect off") }, { "/vercheck", - parse_args, 0, 1, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_vercheck) - CMD_TAGS( - CMD_TAG_UI) - CMD_SYN( - "/vercheck on|off") - CMD_DESC( - "Check for new versions when Profanity starts, and when the /about command is run.") - CMD_ARGS( - { "on|off", "Enable or disable the version check." }) - CMD_NOEXAMPLES - }, + parse_args, 0, 1, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_vercheck) + CMD_TAGS( + CMD_TAG_UI) + CMD_SYN( + "/vercheck on|off") + CMD_DESC( + "Check for new versions when Profanity starts, and when the /about command is run.") + CMD_ARGS( + { "on|off", "Enable or disable the version check." }) + CMD_NOEXAMPLES }, { "/wintitle", - parse_args, 2, 2, &cons_wintitle_setting, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_wintitle) - CMD_TAGS( - CMD_TAG_UI) - CMD_SYN( - "/wintitle show on|off", - "/wintitle goodbye on|off") - CMD_DESC( - "Allow Profanity to modify the window title bar.") - CMD_ARGS( - { "show on|off", "Show current logged in user, and unread messages as the window title." }, - { "goodbye on|off", "Show a message in the title when exiting profanity." }) - CMD_NOEXAMPLES - }, + parse_args, 2, 2, &cons_wintitle_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_wintitle) + CMD_TAGS( + CMD_TAG_UI) + CMD_SYN( + "/wintitle show on|off", + "/wintitle goodbye on|off") + CMD_DESC( + "Allow Profanity to modify the window title bar.") + CMD_ARGS( + { "show on|off", "Show current logged in user, and unread messages as the window title." }, + { "goodbye on|off", "Show a message in the title when exiting profanity." }) + CMD_NOEXAMPLES }, { "/alias", - parse_args_with_freetext, 1, 3, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_alias) - CMD_NOTAGS - CMD_SYN( - "/alias list", - "/alias add <name> <value>", - "/alias remove <name>") - CMD_DESC( - "Add, remove or list command aliases.") - CMD_ARGS( - { "list", "List all aliases." }, - { "add <name> <value>", "Add a new command alias." }, - { "remove <name>", "Remove a command alias." }) - CMD_EXAMPLES( - "/alias add friends /who online friends", - "/alias add /q /quit", - "/alias add a /away \"I'm in a meeting.\"", - "/alias remove q", - "/alias list") - }, + parse_args_with_freetext, 1, 3, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_alias) + CMD_NOTAGS + CMD_SYN( + "/alias list", + "/alias add <name> <value>", + "/alias remove <name>") + CMD_DESC( + "Add, remove or list command aliases.") + CMD_ARGS( + { "list", "List all aliases." }, + { "add <name> <value>", "Add a new command alias." }, + { "remove <name>", "Remove a command alias." }) + CMD_EXAMPLES( + "/alias add friends /who online friends", + "/alias add /q /quit", + "/alias add a /away \"I'm in a meeting.\"", + "/alias remove q", + "/alias list") }, { "/logging", - parse_args, 2, 3, &cons_logging_setting, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_logging) - CMD_TAGS( - CMD_TAG_CHAT) - CMD_SYN( - "/logging chat|group on|off") - CMD_DESC( - "Configure chat logging. " - "Switch logging on or off. " - "Chat logging will be enabled if /history is set to on. " - "When disabling this option, /history will also be disabled. ") - CMD_ARGS( - { "chat on|off", "Enable/Disable regular chat logging." }, - { "group on|off", "Enable/Disable groupchat (room) logging." }) - CMD_EXAMPLES( - "/logging chat on", - "/logging group off") - }, + parse_args, 2, 3, &cons_logging_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_logging) + CMD_TAGS( + CMD_TAG_CHAT) + CMD_SYN( + "/logging chat|group on|off") + CMD_DESC( + "Configure chat logging. " + "Switch logging on or off. " + "Chat logging will be enabled if /history is set to on. " + "When disabling this option, /history will also be disabled. ") + CMD_ARGS( + { "chat on|off", "Enable/Disable regular chat logging." }, + { "group on|off", "Enable/Disable groupchat (room) logging." }) + CMD_EXAMPLES( + "/logging chat on", + "/logging group off") }, { "/states", - parse_args, 1, 1, &cons_states_setting, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_states) - CMD_TAGS( - CMD_TAG_CHAT) - CMD_SYN( - "/states on|off") - CMD_DESC( - "Send chat state notifications to recipient during chat sessions, such as typing, paused, active, gone.") - CMD_ARGS( - { "on|off", "Enable or disable sending of chat state notifications." }) - CMD_NOEXAMPLES - }, + parse_args, 1, 1, &cons_states_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_states) + CMD_TAGS( + CMD_TAG_CHAT) + CMD_SYN( + "/states on|off") + CMD_DESC( + "Send chat state notifications to recipient during chat sessions, such as typing, paused, active, gone.") + CMD_ARGS( + { "on|off", "Enable or disable sending of chat state notifications." }) + CMD_NOEXAMPLES }, { "/pgp", - parse_args, 1, 3, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_pgp) - CMD_TAGS( - CMD_TAG_CHAT, - CMD_TAG_UI) - CMD_SYN( - "/pgp libver", - "/pgp keys", - "/pgp contacts", - "/pgp setkey <contact> <keyid>", - "/pgp start [<contact>]", - "/pgp end", - "/pgp log on|off|redact", - "/pgp char <char>", - "/pgp sendfile on|off") - CMD_DESC( - "Open PGP commands to manage keys, and perform PGP encryption during chat sessions. " - "See the /account command to set your own PGP key.") - CMD_ARGS( - { "libver", "Show which version of the libgpgme library is being used." }, - { "keys", "List all keys known to the system." }, - { "contacts", "Show contacts with assigned public keys." }, - { "setkey <contact> <keyid>", "Manually associate a contact with a public key." }, - { "start [<contact>]", "Start PGP encrypted chat, current contact will be used if not specified." }, - { "end", "End PGP encrypted chat with the current recipient." }, - { "log on|off", "Enable or disable plaintext logging of PGP encrypted messages." }, - { "log redact", "Log PGP encrypted messages, but replace the contents with [redacted]. This is the default." }, - { "char <char>", "Set the character to be displayed next to PGP encrypted messages." }, - { "sendfile on|off", "Allow /sendfile to send unencrypted files while otherwise using PGP."}) - CMD_EXAMPLES( - "/pgp log off", - "/pgp setkey odin@valhalla.edda BA19CACE5A9592C5", - "/pgp start odin@valhalla.edda", - "/pgp end", - "/pgp char P") - }, + parse_args, 1, 3, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_pgp) + CMD_TAGS( + CMD_TAG_CHAT, + CMD_TAG_UI) + CMD_SYN( + "/pgp libver", + "/pgp keys", + "/pgp contacts", + "/pgp setkey <contact> <keyid>", + "/pgp start [<contact>]", + "/pgp end", + "/pgp log on|off|redact", + "/pgp char <char>", + "/pgp sendfile on|off") + CMD_DESC( + "Open PGP commands to manage keys, and perform PGP encryption during chat sessions. " + "See the /account command to set your own PGP key.") + CMD_ARGS( + { "libver", "Show which version of the libgpgme library is being used." }, + { "keys", "List all keys known to the system." }, + { "contacts", "Show contacts with assigned public keys." }, + { "setkey <contact> <keyid>", "Manually associate a contact with a public key." }, + { "start [<contact>]", "Start PGP encrypted chat, current contact will be used if not specified." }, + { "end", "End PGP encrypted chat with the current recipient." }, + { "log on|off", "Enable or disable plaintext logging of PGP encrypted messages." }, + { "log redact", "Log PGP encrypted messages, but replace the contents with [redacted]. This is the default." }, + { "char <char>", "Set the character to be displayed next to PGP encrypted messages." }, + { "sendfile on|off", "Allow /sendfile to send unencrypted files while otherwise using PGP." }) + CMD_EXAMPLES( + "/pgp log off", + "/pgp setkey odin@valhalla.edda BA19CACE5A9592C5", + "/pgp start odin@valhalla.edda", + "/pgp end", + "/pgp char P") }, // XEP-0373: OpenPGP for XMPP #ifdef HAVE_LIBGPGME { "/ox", - parse_args, 1, 3, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_ox) - CMD_TAGS( - CMD_TAG_CHAT, - CMD_TAG_UI) - CMD_SYN( - "/ox keys", - "/ox contacts", - "/ox start [<contact>]", - "/ox end", - "/ox log on|off|redact", - "/ox char <char>", - "/ox sendfile on|off", - "/ox announce <file>", - "/ox discover", - "/ox request <jid>") - CMD_DESC( - "OpenPGP (OX) commands to manage keys, and perform PGP encryption during chat sessions. ") - CMD_ARGS( - { "keys", "List all keys known to the system." }, - { "contacts", "Show contacts with assigned public keys." }, - { "start [<contact>]", "Start PGP encrypted chat, current contact will be used if not specified." }, - { "end", "End PGP encrypted chat with the current recipient." }, - { "log on|off", "Enable or disable plaintext logging of PGP encrypted messages." }, - { "log redact", "Log PGP encrypted messages, but replace the contents with [redacted]. This is the default." }, - { "char <char>", "Set the character to be displayed next to PGP encrypted messages." }, - { "announce <file>", "Announce a public key by pushing it on the XMPP Server"}, - { "discover <jid>", "Discover public keys of a jid "}, - { "request <jid>", "Request public keys"}, - { "sendfile on|off", "Allow /sendfile to send unencrypted files while otherwise using PGP."}) - CMD_EXAMPLES( - "/ox log off", - "/ox start odin@valhalla.edda", - "/ox end", - "/ox char X") - }, + parse_args, 1, 3, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_ox) + CMD_TAGS( + CMD_TAG_CHAT, + CMD_TAG_UI) + CMD_SYN( + "/ox keys", + "/ox contacts", + "/ox start [<contact>]", + "/ox end", + "/ox log on|off|redact", + "/ox char <char>", + "/ox sendfile on|off", + "/ox announce <file>", + "/ox discover", + "/ox request <jid>") + CMD_DESC( + "OpenPGP (OX) commands to manage keys, and perform PGP encryption during chat sessions. ") + CMD_ARGS( + { "keys", "List all keys known to the system." }, + { "contacts", "Show contacts with assigned public keys." }, + { "start [<contact>]", "Start PGP encrypted chat, current contact will be used if not specified." }, + { "end", "End PGP encrypted chat with the current recipient." }, + { "log on|off", "Enable or disable plaintext logging of PGP encrypted messages." }, + { "log redact", "Log PGP encrypted messages, but replace the contents with [redacted]. This is the default." }, + { "char <char>", "Set the character to be displayed next to PGP encrypted messages." }, + { "announce <file>", "Announce a public key by pushing it on the XMPP Server" }, + { "discover <jid>", "Discover public keys of a jid " }, + { "request <jid>", "Request public keys" }, + { "sendfile on|off", "Allow /sendfile to send unencrypted files while otherwise using PGP." }) + CMD_EXAMPLES( + "/ox log off", + "/ox start odin@valhalla.edda", + "/ox end", + "/ox char X") }, #endif // HAVE_LIBGPGME { "/otr", - parse_args, 1, 3, NULL, - CMD_SUBFUNCS( - { "char", cmd_otr_char }, - { "log", cmd_otr_log }, - { "libver", cmd_otr_libver }, - { "policy", cmd_otr_policy }, - { "gen", cmd_otr_gen }, - { "myfp", cmd_otr_myfp }, - { "theirfp", cmd_otr_theirfp }, - { "start", cmd_otr_start }, - { "end", cmd_otr_end }, - { "trust", cmd_otr_trust }, - { "untrust", cmd_otr_untrust }, - { "secret", cmd_otr_secret }, - { "question", cmd_otr_question }, - { "answer", cmd_otr_answer }, - { "sendfile", cmd_otr_sendfile }) - CMD_NOMAINFUNC - CMD_TAGS( - CMD_TAG_CHAT, - CMD_TAG_UI) - CMD_SYN( - "/otr libver", - "/otr gen", - "/otr myfp|theirfp", - "/otr start [<contact>]", - "/otr end", - "/otr trust|untrust", - "/otr secret <secret>", - "/otr question <question> <answer>", - "/otr answer <answer>", - "/otr policy manual|opportunistic|always [<contact>]", - "/otr log on|off|redact", - "/otr char <char>", - "/otr sendfile on|off") - CMD_DESC( - "Off The Record (OTR) commands to manage keys, and perform OTR encryption during chat sessions.") - CMD_ARGS( - { "libver", "Show which version of the libotr library is being used." }, - { "gen", "Generate your private key." }, - { "myfp", "Show your fingerprint." }, - { "theirfp", "Show contacts fingerprint." }, - { "start [<contact>]", "Start an OTR session with contact, or current recipient if omitted." }, - { "end", "End the current OTR session." }, - { "trust|untrust", "Indicate whether or not you trust the contact's fingerprint." }, - { "secret <secret>", "Verify a contact's identity using a shared secret." }, - { "question <question> <answer>", "Verify a contact's identity using a question and expected answer." }, - { "answer <answer>", "Respond to a question answer verification request with your answer." }, - { "policy manual", "Set the global OTR policy to manual, OTR sessions must be started manually." }, - { "policy manual <contact>", "Set the OTR policy to manual for a specific contact." }, - { "policy opportunistic", "Set the global OTR policy to opportunistic, an OTR session will be attempted upon starting a conversation." }, - { "policy opportunistic <contact>", "Set the OTR policy to opportunistic for a specific contact." }, - { "policy always", "Set the global OTR policy to always, an error will be displayed if an OTR session cannot be initiated upon starting a conversation." }, - { "policy always <contact>", "Set the OTR policy to always for a specific contact." }, - { "log on|off", "Enable or disable plaintext logging of OTR encrypted messages." }, - { "log redact", "Log OTR encrypted messages, but replace the contents with [redacted]. This is the default." }, - { "char <char>", "Set the character to be displayed next to OTR encrypted messages." }, - { "sendfile on|off", "Allow /sendfile to send unencrypted files while in an OTR session."}) - CMD_EXAMPLES( - "/otr log off", - "/otr policy manual", - "/otr policy opportunistic odin@valhalla.edda", - "/otr gen", - "/otr start odin@valhalla.edda", - "/otr myfp", - "/otr theirfp", - "/otr question \"What is the name of my rabbit?\" fiffi", - "/otr end", - "/otr char *") - }, + parse_args, 1, 3, NULL, + CMD_SUBFUNCS( + { "char", cmd_otr_char }, + { "log", cmd_otr_log }, + { "libver", cmd_otr_libver }, + { "policy", cmd_otr_policy }, + { "gen", cmd_otr_gen }, + { "myfp", cmd_otr_myfp }, + { "theirfp", cmd_otr_theirfp }, + { "start", cmd_otr_start }, + { "end", cmd_otr_end }, + { "trust", cmd_otr_trust }, + { "untrust", cmd_otr_untrust }, + { "secret", cmd_otr_secret }, + { "question", cmd_otr_question }, + { "answer", cmd_otr_answer }, + { "sendfile", cmd_otr_sendfile }) + CMD_NOMAINFUNC + CMD_TAGS( + CMD_TAG_CHAT, + CMD_TAG_UI) + CMD_SYN( + "/otr libver", + "/otr gen", + "/otr myfp|theirfp", + "/otr start [<contact>]", + "/otr end", + "/otr trust|untrust", + "/otr secret <secret>", + "/otr question <question> <answer>", + "/otr answer <answer>", + "/otr policy manual|opportunistic|always [<contact>]", + "/otr log on|off|redact", + "/otr char <char>", + "/otr sendfile on|off") + CMD_DESC( + "Off The Record (OTR) commands to manage keys, and perform OTR encryption during chat sessions.") + CMD_ARGS( + { "libver", "Show which version of the libotr library is being used." }, + { "gen", "Generate your private key." }, + { "myfp", "Show your fingerprint." }, + { "theirfp", "Show contacts fingerprint." }, + { "start [<contact>]", "Start an OTR session with contact, or current recipient if omitted." }, + { "end", "End the current OTR session." }, + { "trust|untrust", "Indicate whether or not you trust the contact's fingerprint." }, + { "secret <secret>", "Verify a contact's identity using a shared secret." }, + { "question <question> <answer>", "Verify a contact's identity using a question and expected answer." }, + { "answer <answer>", "Respond to a question answer verification request with your answer." }, + { "policy manual", "Set the global OTR policy to manual, OTR sessions must be started manually." }, + { "policy manual <contact>", "Set the OTR policy to manual for a specific contact." }, + { "policy opportunistic", "Set the global OTR policy to opportunistic, an OTR session will be attempted upon starting a conversation." }, + { "policy opportunistic <contact>", "Set the OTR policy to opportunistic for a specific contact." }, + { "policy always", "Set the global OTR policy to always, an error will be displayed if an OTR session cannot be initiated upon starting a conversation." }, + { "policy always <contact>", "Set the OTR policy to always for a specific contact." }, + { "log on|off", "Enable or disable plaintext logging of OTR encrypted messages." }, + { "log redact", "Log OTR encrypted messages, but replace the contents with [redacted]. This is the default." }, + { "char <char>", "Set the character to be displayed next to OTR encrypted messages." }, + { "sendfile on|off", "Allow /sendfile to send unencrypted files while in an OTR session." }) + CMD_EXAMPLES( + "/otr log off", + "/otr policy manual", + "/otr policy opportunistic odin@valhalla.edda", + "/otr gen", + "/otr start odin@valhalla.edda", + "/otr myfp", + "/otr theirfp", + "/otr question \"What is the name of my rabbit?\" fiffi", + "/otr end", + "/otr char *") }, { "/outtype", - parse_args, 1, 1, &cons_outtype_setting, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_outtype) - CMD_TAGS( - CMD_TAG_CHAT) - CMD_SYN( - "/outtype on|off") - CMD_DESC( - "Send typing notifications, chat states (/states) will be enabled if this setting is enabled.") - CMD_ARGS( - { "on|off", "Enable or disable sending typing notifications." }) - CMD_NOEXAMPLES - }, + parse_args, 1, 1, &cons_outtype_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_outtype) + CMD_TAGS( + CMD_TAG_CHAT) + CMD_SYN( + "/outtype on|off") + CMD_DESC( + "Send typing notifications, chat states (/states) will be enabled if this setting is enabled.") + CMD_ARGS( + { "on|off", "Enable or disable sending typing notifications." }) + CMD_NOEXAMPLES }, { "/gone", - parse_args, 1, 1, &cons_gone_setting, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_gone) - CMD_TAGS( - CMD_TAG_CHAT) - CMD_SYN( - "/gone <minutes>") - CMD_DESC( - "Send a 'gone' state to the recipient after the specified number of minutes. " - "Chat states (/states) will be enabled if this setting is set.") - CMD_ARGS( - { "<minutes>", "Number of minutes of inactivity before sending the 'gone' state, a value of 0 will disable sending this state." }) - CMD_NOEXAMPLES - }, + parse_args, 1, 1, &cons_gone_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_gone) + CMD_TAGS( + CMD_TAG_CHAT) + CMD_SYN( + "/gone <minutes>") + CMD_DESC( + "Send a 'gone' state to the recipient after the specified number of minutes. " + "Chat states (/states) will be enabled if this setting is set.") + CMD_ARGS( + { "<minutes>", "Number of minutes of inactivity before sending the 'gone' state, a value of 0 will disable sending this state." }) + CMD_NOEXAMPLES }, { "/history", - parse_args, 1, 1, &cons_history_setting, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_history) - CMD_TAGS( - CMD_TAG_UI, - CMD_TAG_CHAT) - CMD_SYN( - "/history on|off") - CMD_DESC( - "Switch chat history on or off, /chlog will automatically be enabled when this setting is on. " - "When history is enabled, previous messages are shown in chat windows.") - CMD_ARGS( - { "on|off", "Enable or disable showing chat history." }) - CMD_NOEXAMPLES - }, + parse_args, 1, 1, &cons_history_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_history) + CMD_TAGS( + CMD_TAG_UI, + CMD_TAG_CHAT) + CMD_SYN( + "/history on|off") + CMD_DESC( + "Switch chat history on or off, /chlog will automatically be enabled when this setting is on. " + "When history is enabled, previous messages are shown in chat windows.") + CMD_ARGS( + { "on|off", "Enable or disable showing chat history." }) + CMD_NOEXAMPLES }, { "/log", - parse_args, 1, 2, &cons_log_setting, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_log) - CMD_NOTAGS - CMD_SYN( - "/log where", - "/log rotate on|off", - "/log maxsize <bytes>", - "/log shared on|off") - CMD_DESC( - "Manage profanity log settings.") - CMD_ARGS( - { "where", "Show the current log file location." }, - { "rotate on|off", "Rotate log, default on." }, - { "maxsize <bytes>", "With rotate enabled, specifies the max log size, defaults to 1048580 (1MB)." }, - { "shared on|off", "Share logs between all instances, default: on. When off, the process id will be included in the log filename." }) - CMD_NOEXAMPLES - }, + parse_args, 1, 2, &cons_log_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_log) + CMD_NOTAGS + CMD_SYN( + "/log where", + "/log rotate on|off", + "/log maxsize <bytes>", + "/log shared on|off") + CMD_DESC( + "Manage profanity log settings.") + CMD_ARGS( + { "where", "Show the current log file location." }, + { "rotate on|off", "Rotate log, default on." }, + { "maxsize <bytes>", "With rotate enabled, specifies the max log size, defaults to 1048580 (1MB)." }, + { "shared on|off", "Share logs between all instances, default: on. When off, the process id will be included in the log filename." }) + CMD_NOEXAMPLES }, { "/carbons", - parse_args, 1, 1, &cons_carbons_setting, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_carbons) - CMD_TAGS( - CMD_TAG_CHAT) - CMD_SYN( - "/carbons on|off") - CMD_DESC( - "Enable or disable message carbons. " - "Message carbons ensure that both sides of all conversations are shared with all the user's clients that implement this protocol.") - CMD_ARGS( - { "on|off", "Enable or disable message carbons." }) - CMD_NOEXAMPLES - }, + parse_args, 1, 1, &cons_carbons_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_carbons) + CMD_TAGS( + CMD_TAG_CHAT) + CMD_SYN( + "/carbons on|off") + CMD_DESC( + "Enable or disable message carbons. " + "Message carbons ensure that both sides of all conversations are shared with all the user's clients that implement this protocol.") + CMD_ARGS( + { "on|off", "Enable or disable message carbons." }) + CMD_NOEXAMPLES }, { "/receipts", - parse_args, 2, 2, &cons_receipts_setting, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_receipts) - CMD_TAGS( - CMD_TAG_CHAT) - CMD_SYN( - "/receipts request on|off", - "/receipts send on|off") - CMD_DESC( - "Enable or disable message delivery receipts. The interface will indicate when a message has been received.") - CMD_ARGS( - { "request on|off", "Whether or not to request a receipt upon sending a message." }, - { "send on|off", "Whether or not to send a receipt if one has been requested with a received message." }) - CMD_NOEXAMPLES - }, + parse_args, 2, 2, &cons_receipts_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_receipts) + CMD_TAGS( + CMD_TAG_CHAT) + CMD_SYN( + "/receipts request on|off", + "/receipts send on|off") + CMD_DESC( + "Enable or disable message delivery receipts. The interface will indicate when a message has been received.") + CMD_ARGS( + { "request on|off", "Whether or not to request a receipt upon sending a message." }, + { "send on|off", "Whether or not to send a receipt if one has been requested with a received message." }) + CMD_NOEXAMPLES }, { "/reconnect", - parse_args, 1, 1, &cons_reconnect_setting, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_reconnect) - CMD_TAGS( - CMD_TAG_CONNECTION) - CMD_SYN( - "/reconnect <seconds>") - CMD_DESC( - "Set the reconnect attempt interval for when the connection is lost.") - CMD_ARGS( - { "<seconds>", "Number of seconds before attempting to reconnect, a value of 0 disables reconnect." }) - CMD_NOEXAMPLES - }, + parse_args, 1, 1, &cons_reconnect_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_reconnect) + CMD_TAGS( + CMD_TAG_CONNECTION) + CMD_SYN( + "/reconnect <seconds>") + CMD_DESC( + "Set the reconnect attempt interval for when the connection is lost.") + CMD_ARGS( + { "<seconds>", "Number of seconds before attempting to reconnect, a value of 0 disables reconnect." }) + CMD_NOEXAMPLES }, { "/autoping", - parse_args, 2, 2, &cons_autoping_setting, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_autoping) - CMD_TAGS( - CMD_TAG_CONNECTION) - CMD_SYN( - "/autoping set <seconds>", - "/autoping timeout <seconds>") - CMD_DESC( - "Set the interval between sending ping requests to the server to ensure the connection is kept alive.") - CMD_ARGS( - { "set <seconds>", "Number of seconds between sending pings, a value of 0 disables autoping." }, - { "timeout <seconds>", "Seconds to wait for autoping responses, after which the connection is considered broken." }) - CMD_NOEXAMPLES - }, + parse_args, 2, 2, &cons_autoping_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_autoping) + CMD_TAGS( + CMD_TAG_CONNECTION) + CMD_SYN( + "/autoping set <seconds>", + "/autoping timeout <seconds>") + CMD_DESC( + "Set the interval between sending ping requests to the server to ensure the connection is kept alive.") + CMD_ARGS( + { "set <seconds>", "Number of seconds between sending pings, a value of 0 disables autoping." }, + { "timeout <seconds>", "Seconds to wait for autoping responses, after which the connection is considered broken." }) + CMD_NOEXAMPLES }, { "/ping", - parse_args, 0, 1, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_ping) - CMD_TAGS( - CMD_TAG_CONNECTION) - CMD_SYN( - "/ping [<jid>]") - CMD_DESC( - "Sends an IQ ping stanza to the specified JID. " - "If no JID is supplied, your chat server will be pinged.") - CMD_ARGS( - { "<jid>", "The Jabber ID to send the ping request to." }) - CMD_NOEXAMPLES - }, + parse_args, 0, 1, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_ping) + CMD_TAGS( + CMD_TAG_CONNECTION) + CMD_SYN( + "/ping [<jid>]") + CMD_DESC( + "Sends an IQ ping stanza to the specified JID. " + "If no JID is supplied, your chat server will be pinged.") + CMD_ARGS( + { "<jid>", "The Jabber ID to send the ping request to." }) + CMD_NOEXAMPLES }, { "/autoaway", - parse_args_with_freetext, 2, 3, &cons_autoaway_setting, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_autoaway) - CMD_TAGS( - CMD_TAG_PRESENCE) - CMD_SYN( - "/autoaway mode idle|away|off", - "/autoaway time away|xa <minutes>", - "/autoaway message away|xa <message>|off", - "/autoaway check on|off") - CMD_DESC( - "Manage autoaway settings for idle time.") - CMD_ARGS( - { "mode idle", "Sends idle time, status remains online." }, - { "mode away", "Sends away and xa presence as well as idle time." }, - { "mode off", "Disabled (default)." }, - { "time away <minutes>", "Number of minutes before the away presence is sent, default: 15." }, - { "time xa <minutes>", "Number of minutes before the xa presence is sent, default: 0 (disabled)." }, - { "message away <message>", "Optional message to send with the away presence, default: off (disabled)." }, - { "message xa <message>", "Optional message to send with the xa presence, default: off (disabled)." }, - { "message away off", "Send no message with away presence." }, - { "message xa off", "Send no message with xa presence." }, - { "check on|off", "When enabled, checks for activity and sends online presence, default: on." }) - CMD_EXAMPLES( - "/autoaway mode away", - "/autoaway time away 30", - "/autoaway message away Away from computer for a while", - "/autoaway time xa 120", - "/autoaway message xa Away from computer for a very long time", - "/autoaway check off") - }, + parse_args_with_freetext, 2, 3, &cons_autoaway_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_autoaway) + CMD_TAGS( + CMD_TAG_PRESENCE) + CMD_SYN( + "/autoaway mode idle|away|off", + "/autoaway time away|xa <minutes>", + "/autoaway message away|xa <message>|off", + "/autoaway check on|off") + CMD_DESC( + "Manage autoaway settings for idle time.") + CMD_ARGS( + { "mode idle", "Sends idle time, status remains online." }, + { "mode away", "Sends away and xa presence as well as idle time." }, + { "mode off", "Disabled (default)." }, + { "time away <minutes>", "Number of minutes before the away presence is sent, default: 15." }, + { "time xa <minutes>", "Number of minutes before the xa presence is sent, default: 0 (disabled)." }, + { "message away <message>", "Optional message to send with the away presence, default: off (disabled)." }, + { "message xa <message>", "Optional message to send with the xa presence, default: off (disabled)." }, + { "message away off", "Send no message with away presence." }, + { "message xa off", "Send no message with xa presence." }, + { "check on|off", "When enabled, checks for activity and sends online presence, default: on." }) + CMD_EXAMPLES( + "/autoaway mode away", + "/autoaway time away 30", + "/autoaway message away Away from computer for a while", + "/autoaway time xa 120", + "/autoaway message xa Away from computer for a very long time", + "/autoaway check off") }, { "/priority", - parse_args, 1, 1, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_priority) - CMD_TAGS( - CMD_TAG_PRESENCE) - CMD_SYN( - "/priority <priority>") - CMD_DESC( - "Set priority for the current account. " - "See the /account command for specific priority settings per presence status.") - CMD_ARGS( - { "<priority>", "Number between -128 and 127, default: 0." }) - CMD_NOEXAMPLES - }, + parse_args, 1, 1, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_priority) + CMD_TAGS( + CMD_TAG_PRESENCE) + CMD_SYN( + "/priority <priority>") + CMD_DESC( + "Set priority for the current account. " + "See the /account command for specific priority settings per presence status.") + CMD_ARGS( + { "<priority>", "Number between -128 and 127, default: 0." }) + CMD_NOEXAMPLES }, { "/account", - parse_args, 0, 4, NULL, - CMD_SUBFUNCS( - { "list", cmd_account_list }, - { "show", cmd_account_show }, - { "add", cmd_account_add }, - { "remove", cmd_account_remove }, - { "enable", cmd_account_enable }, - { "disable", cmd_account_disable }, - { "rename", cmd_account_rename }, - { "default", cmd_account_default }, - { "set", cmd_account_set }, - { "clear", cmd_account_clear }) - CMD_MAINFUNC(cmd_account) - CMD_TAGS( - CMD_TAG_CONNECTION, - CMD_TAG_PRESENCE, - CMD_TAG_CHAT, - CMD_TAG_GROUPCHAT) - CMD_SYN( - "/account", - "/account list", - "/account show <account>", - "/account enable|disable <account>", - "/account default set <account>", - "/account default off", - "/account add <account>", - "/account remove <account>", - "/account rename <account> <newaccount>", - "/account set <account> jid <jid>", - "/account set <account> server <server>", - "/account set <account> port <port>", - "/account set <account> status <presence>", - "/account set <account> status last", - "/account set <account> <presence> <priority>", - "/account set <account> resource <resource>", - "/account set <account> password <password>", - "/account set <account> eval_password <command>", - "/account set <account> muc <service>", - "/account set <account> nick <nick>", - "/account set <account> otr <policy>", - "/account set <account> pgpkeyid <pgpkeyid>", - "/account set <account> startscript <script>", - "/account set <account> tls force|allow|trust|legacy|disable", - "/account set <account> auth default|legacy", - "/account set <account> theme <theme>", - "/account clear <account> password", - "/account clear <account> eval_password", - "/account clear <account> server", - "/account clear <account> port", - "/account clear <account> otr", - "/account clear <account> pgpkeyid", - "/account clear <account> startscript", - "/account clear <account> muc", - "/account clear <account> resource") - CMD_DESC( - "Commands for creating and managing accounts. " - "Calling with no arguments will display information for the current account.") - CMD_ARGS( - { "list", "List all accounts." }, - { "enable <account>", "Enable the account, it will be used for autocompletion." }, - { "show <account>", "Show details for the specified account." }, - { "disable <account>", "Disable the account." }, - { "default set <account>", "Set the default account, used when no argument passed to the /connect command." }, - { "default off", "Clear the default account setting." }, - { "add <account>", "Create a new account." }, - { "remove <account>", "Remove an account." }, - { "rename <account> <newaccount>", "Rename 'account' to 'newaccount'." }, - { "set <account> jid <jid>", "Set the Jabber ID for the account, account name will be used if not set." }, - { "set <account> server <server>", "The chat server, if different to the domainpart of the JID." }, - { "set <account> port <port>", "The port used for connecting if not the default (5222, or 5223 for SSL)." }, - { "set <account> status <presence>", "The presence status to use on login." }, - { "set <account> status last", "Use your last status before logging out, when logging in." }, - { "set <account> <presence> <priority>", "Set the priority (-128..127) to use for the specified presence." }, - { "set <account> resource <resource>", "The resource to be used for this account, defaults to 'profanity'." }, - { "set <account> password <password>", "Password for the account, note this is currently stored in plaintext if set." }, - { "set <account> eval_password <command>", "Shell command evaluated to retrieve password for the account. Can be used to retrieve password from keyring." }, - { "set <account> muc <service>", "The default MUC chat service to use, defaults to the servers disco info response." }, - { "set <account> nick <nick>", "The default nickname to use when joining chat rooms." }, - { "set <account> otr <policy>", "Override global OTR policy for this account, see /otr." }, - { "set <account> pgpkeyid <pgpkeyid>", "Set the ID of the PGP key for this account, see /pgp." }, - { "set <account> startscript <script>", "Set the script to execute after connecting." }, - { "set <account> tls force", "Force TLS connection, and fail if one cannot be established, this is default behaviour." }, - { "set <account> tls allow", "Use TLS for the connection if it is available." }, - { "set <account> tls trust", "Force TLS connection and trust server's certificate." }, - { "set <account> tls legacy", "Use legacy TLS for the connection. It means server doesn't support STARTTLS and TLS is forced just after TCP connection is established." }, - { "set <account> tls disable", "Disable TLS for the connection." }, - { "set <account> auth default", "Use default authentication process." }, - { "set <account> auth legacy", "Allow legacy authentication." }, - { "set <account> <theme>", "Set the UI theme for the account." }, - { "clear <account> server", "Remove the server setting for this account." }, - { "clear <account> port", "Remove the port setting for this account." }, - { "clear <account> password", "Remove the password setting for this account." }, - { "clear <account> eval_password", "Remove the eval_password setting for this account." }, - { "clear <account> otr", "Remove the OTR policy setting for this account." }, - { "clear <account> pgpkeyid", "Remove pgpkeyid associated with this account." }, - { "clear <account> startscript", "Remove startscript associated with this account." }, - { "clear <account> theme", "Clear the theme setting for the account, the global theme will be used." }, - { "clear <account> resource", "Remove the resource setting for this account."}, - { "clear <account> muc", "Remove the default MUC service setting."}) - CMD_EXAMPLES( - "/account add me", - "/account set me jid ulfhednar@valhalla.edda", - "/account set me server talk.chat.com", - "/account set me port 5111", - "/account set me muc chatservice.mycompany.com", - "/account set me nick dennis", - "/account set me status dnd", - "/account set me dnd -1", - "/account rename me chattyme", - "/account clear me pgpkeyid" - ) - }, + parse_args, 0, 4, NULL, + CMD_SUBFUNCS( + { "list", cmd_account_list }, + { "show", cmd_account_show }, + { "add", cmd_account_add }, + { "remove", cmd_account_remove }, + { "enable", cmd_account_enable }, + { "disable", cmd_account_disable }, + { "rename", cmd_account_rename }, + { "default", cmd_account_default }, + { "set", cmd_account_set }, + { "clear", cmd_account_clear }) + CMD_MAINFUNC(cmd_account) + CMD_TAGS( + CMD_TAG_CONNECTION, + CMD_TAG_PRESENCE, + CMD_TAG_CHAT, + CMD_TAG_GROUPCHAT) + CMD_SYN( + "/account", + "/account list", + "/account show <account>", + "/account enable|disable <account>", + "/account default set <account>", + "/account default off", + "/account add <account>", + "/account remove <account>", + "/account rename <account> <newaccount>", + "/account set <account> jid <jid>", + "/account set <account> server <server>", + "/account set <account> port <port>", + "/account set <account> status <presence>", + "/account set <account> status last", + "/account set <account> <presence> <priority>", + "/account set <account> resource <resource>", + "/account set <account> password <password>", + "/account set <account> eval_password <command>", + "/account set <account> muc <service>", + "/account set <account> nick <nick>", + "/account set <account> otr <policy>", + "/account set <account> pgpkeyid <pgpkeyid>", + "/account set <account> startscript <script>", + "/account set <account> tls force|allow|trust|legacy|disable", + "/account set <account> auth default|legacy", + "/account set <account> theme <theme>", + "/account clear <account> password", + "/account clear <account> eval_password", + "/account clear <account> server", + "/account clear <account> port", + "/account clear <account> otr", + "/account clear <account> pgpkeyid", + "/account clear <account> startscript", + "/account clear <account> muc", + "/account clear <account> resource") + CMD_DESC( + "Commands for creating and managing accounts. " + "Calling with no arguments will display information for the current account.") + CMD_ARGS( + { "list", "List all accounts." }, + { "enable <account>", "Enable the account, it will be used for autocompletion." }, + { "show <account>", "Show details for the specified account." }, + { "disable <account>", "Disable the account." }, + { "default set <account>", "Set the default account, used when no argument passed to the /connect command." }, + { "default off", "Clear the default account setting." }, + { "add <account>", "Create a new account." }, + { "remove <account>", "Remove an account." }, + { "rename <account> <newaccount>", "Rename 'account' to 'newaccount'." }, + { "set <account> jid <jid>", "Set the Jabber ID for the account, account name will be used if not set." }, + { "set <account> server <server>", "The chat server, if different to the domainpart of the JID." }, + { "set <account> port <port>", "The port used for connecting if not the default (5222, or 5223 for SSL)." }, + { "set <account> status <presence>", "The presence status to use on login." }, + { "set <account> status last", "Use your last status before logging out, when logging in." }, + { "set <account> <presence> <priority>", "Set the priority (-128..127) to use for the specified presence." }, + { "set <account> resource <resource>", "The resource to be used for this account, defaults to 'profanity'." }, + { "set <account> password <password>", "Password for the account, note this is currently stored in plaintext if set." }, + { "set <account> eval_password <command>", "Shell command evaluated to retrieve password for the account. Can be used to retrieve password from keyring." }, + { "set <account> muc <service>", "The default MUC chat service to use, defaults to the servers disco info response." }, + { "set <account> nick <nick>", "The default nickname to use when joining chat rooms." }, + { "set <account> otr <policy>", "Override global OTR policy for this account, see /otr." }, + { "set <account> pgpkeyid <pgpkeyid>", "Set the ID of the PGP key for this account, see /pgp." }, + { "set <account> startscript <script>", "Set the script to execute after connecting." }, + { "set <account> tls force", "Force TLS connection, and fail if one cannot be established, this is default behaviour." }, + { "set <account> tls allow", "Use TLS for the connection if it is available." }, + { "set <account> tls trust", "Force TLS connection and trust server's certificate." }, + { "set <account> tls legacy", "Use legacy TLS for the connection. It means server doesn't support STARTTLS and TLS is forced just after TCP connection is established." }, + { "set <account> tls disable", "Disable TLS for the connection." }, + { "set <account> auth default", "Use default authentication process." }, + { "set <account> auth legacy", "Allow legacy authentication." }, + { "set <account> <theme>", "Set the UI theme for the account." }, + { "clear <account> server", "Remove the server setting for this account." }, + { "clear <account> port", "Remove the port setting for this account." }, + { "clear <account> password", "Remove the password setting for this account." }, + { "clear <account> eval_password", "Remove the eval_password setting for this account." }, + { "clear <account> otr", "Remove the OTR policy setting for this account." }, + { "clear <account> pgpkeyid", "Remove pgpkeyid associated with this account." }, + { "clear <account> startscript", "Remove startscript associated with this account." }, + { "clear <account> theme", "Clear the theme setting for the account, the global theme will be used." }, + { "clear <account> resource", "Remove the resource setting for this account." }, + { "clear <account> muc", "Remove the default MUC service setting." }) + CMD_EXAMPLES( + "/account add me", + "/account set me jid ulfhednar@valhalla.edda", + "/account set me server talk.chat.com", + "/account set me port 5111", + "/account set me muc chatservice.mycompany.com", + "/account set me nick dennis", + "/account set me status dnd", + "/account set me dnd -1", + "/account rename me chattyme", + "/account clear me pgpkeyid") }, { "/plugins", - parse_args, 0, 3, NULL, - CMD_SUBFUNCS( - { "sourcepath", cmd_plugins_sourcepath }, - { "install", cmd_plugins_install }, - { "uninstall", cmd_plugins_uninstall }, - { "update", cmd_plugins_update }, - { "load", cmd_plugins_load }, - { "unload", cmd_plugins_unload }, - { "reload", cmd_plugins_reload }, - { "python_version", cmd_plugins_python_version }) - CMD_MAINFUNC(cmd_plugins) - CMD_NOTAGS - CMD_SYN( - "/plugins", - "/plugins sourcepath set <path>", - "/plugins sourcepath clear", - "/plugins install [<path>]", - "/plugins uninstall [<plugin>]", - "/plugins update [<path>]", - "/plugins unload [<plugin>]", - "/plugins load [<plugin>]", - "/plugins reload [<plugin>]", - "/plugins python_version") - CMD_DESC( - "Manage plugins. Passing no arguments lists currently loaded plugins.") - CMD_ARGS( - { "sourcepath set <path>", "Set the default path to install plugins from, will be used if no arg is passed to /plugins install." }, - { "sourcepath clear", "Clear the default plugins source path." }, - { "install [<path>]", "Install a plugin, or all plugins found in a directory (recursive). Passing no argument will use the sourcepath if one is set." }, - { "uninstall [<plugin>]", "Uninstall a plugin." }, - { "update [<path>]", "Updates an installed plugin" }, - { "load [<plugin>]", "Load a plugin that already exists in the plugin directory, passing no argument loads all found plugins." }, - { "unload [<plugin>]", "Unload a loaded plugin, passing no argument will unload all plugins." }, - { "reload [<plugin>]", "Reload a plugin, passing no argument will reload all plugins." }, - { "python_version", "Show the Python interpreter version." }) - CMD_EXAMPLES( - "/plugins sourcepath set /home/meee/projects/profanity-plugins", - "/plugins install", - "/plugins install /home/steveharris/Downloads/metal.py", - "/plugins update /home/steveharris/Downloads/metal.py", - "/plugins uninstall browser.py", - "/plugins load browser.py", - "/plugins unload say.py", - "/plugins reload wikipedia.py") - }, + parse_args, 0, 3, NULL, + CMD_SUBFUNCS( + { "sourcepath", cmd_plugins_sourcepath }, + { "install", cmd_plugins_install }, + { "uninstall", cmd_plugins_uninstall }, + { "update", cmd_plugins_update }, + { "load", cmd_plugins_load }, + { "unload", cmd_plugins_unload }, + { "reload", cmd_plugins_reload }, + { "python_version", cmd_plugins_python_version }) + CMD_MAINFUNC(cmd_plugins) + CMD_NOTAGS + CMD_SYN( + "/plugins", + "/plugins sourcepath set <path>", + "/plugins sourcepath clear", + "/plugins install [<path>]", + "/plugins uninstall [<plugin>]", + "/plugins update [<path>]", + "/plugins unload [<plugin>]", + "/plugins load [<plugin>]", + "/plugins reload [<plugin>]", + "/plugins python_version") + CMD_DESC( + "Manage plugins. Passing no arguments lists currently loaded plugins.") + CMD_ARGS( + { "sourcepath set <path>", "Set the default path to install plugins from, will be used if no arg is passed to /plugins install." }, + { "sourcepath clear", "Clear the default plugins source path." }, + { "install [<path>]", "Install a plugin, or all plugins found in a directory (recursive). Passing no argument will use the sourcepath if one is set." }, + { "uninstall [<plugin>]", "Uninstall a plugin." }, + { "update [<path>]", "Updates an installed plugin" }, + { "load [<plugin>]", "Load a plugin that already exists in the plugin directory, passing no argument loads all found plugins." }, + { "unload [<plugin>]", "Unload a loaded plugin, passing no argument will unload all plugins." }, + { "reload [<plugin>]", "Reload a plugin, passing no argument will reload all plugins." }, + { "python_version", "Show the Python interpreter version." }) + CMD_EXAMPLES( + "/plugins sourcepath set /home/meee/projects/profanity-plugins", + "/plugins install", + "/plugins install /home/steveharris/Downloads/metal.py", + "/plugins update /home/steveharris/Downloads/metal.py", + "/plugins uninstall browser.py", + "/plugins load browser.py", + "/plugins unload say.py", + "/plugins reload wikipedia.py") }, { "/prefs", - parse_args, 0, 1, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_prefs) - CMD_NOTAGS - CMD_SYN( - "/prefs [ui|desktop|chat|log|conn|presence|otr|pgp|omemo]") - CMD_DESC( - "Show preferences for different areas of functionality. " - "Passing no arguments shows all preferences.") - CMD_ARGS( - { "ui", "User interface preferences." }, - { "desktop", "Desktop notification preferences." }, - { "chat", "Chat state preferences." }, - { "log", "Logging preferences." }, - { "conn", "Connection handling preferences." }, - { "presence", "Chat presence preferences." }, - { "otr", "Off The Record preferences." }, - { "pgp", "OpenPGP preferences." }, - { "omemo", "OMEMO preferences." }) - CMD_NOEXAMPLES - }, + parse_args, 0, 1, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_prefs) + CMD_NOTAGS + CMD_SYN( + "/prefs [ui|desktop|chat|log|conn|presence|otr|pgp|omemo]") + CMD_DESC( + "Show preferences for different areas of functionality. " + "Passing no arguments shows all preferences.") + CMD_ARGS( + { "ui", "User interface preferences." }, + { "desktop", "Desktop notification preferences." }, + { "chat", "Chat state preferences." }, + { "log", "Logging preferences." }, + { "conn", "Connection handling preferences." }, + { "presence", "Chat presence preferences." }, + { "otr", "Off The Record preferences." }, + { "pgp", "OpenPGP preferences." }, + { "omemo", "OMEMO preferences." }) + CMD_NOEXAMPLES }, { "/theme", - parse_args, 1, 2, &cons_theme_setting, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_theme) - CMD_TAGS( - CMD_TAG_UI) - CMD_SYN( - "/theme list", - "/theme load <theme>", - "/theme full-load <theme>", - "/theme colours", - "/theme properties") - CMD_DESC( - "Load a theme, includes colours and UI options.") - CMD_ARGS( - { "list", "List all available themes." }, - { "load <theme>", "Load colours from specified theme. 'default' will reset to the default theme." }, - { "full-load <theme>", "Same as 'load' but will also load preferences set in the theme, not just colours." }, - { "colours", "Show colour values as rendered by the terminal." }, - { "properties", "Show colour settings for current theme." }) - CMD_EXAMPLES( - "/theme list", - "/theme load forest") - }, + parse_args, 1, 2, &cons_theme_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_theme) + CMD_TAGS( + CMD_TAG_UI) + CMD_SYN( + "/theme list", + "/theme load <theme>", + "/theme full-load <theme>", + "/theme colours", + "/theme properties") + CMD_DESC( + "Load a theme, includes colours and UI options.") + CMD_ARGS( + { "list", "List all available themes." }, + { "load <theme>", "Load colours from specified theme. 'default' will reset to the default theme." }, + { "full-load <theme>", "Same as 'load' but will also load preferences set in the theme, not just colours." }, + { "colours", "Show colour values as rendered by the terminal." }, + { "properties", "Show colour settings for current theme." }) + CMD_EXAMPLES( + "/theme list", + "/theme load forest") }, { "/xmlconsole", - parse_args, 0, 0, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_xmlconsole) - CMD_TAGS( - CMD_TAG_UI) - CMD_SYN( - "/xmlconsole") - CMD_DESC( - "Open the XML console to view incoming and outgoing XMPP traffic.") - CMD_NOARGS - CMD_NOEXAMPLES - }, + parse_args, 0, 0, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_xmlconsole) + CMD_TAGS( + CMD_TAG_UI) + CMD_SYN( + "/xmlconsole") + CMD_DESC( + "Open the XML console to view incoming and outgoing XMPP traffic.") + CMD_NOARGS + CMD_NOEXAMPLES }, { "/script", - parse_args, 1, 2, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_script) - CMD_NOTAGS - CMD_SYN( - "/script run <script>", - "/script list", - "/script show <script>") - CMD_DESC( - "Run command scripts. " - "Scripts are stored in $XDG_DATA_HOME/profanity/scripts/ which is usually $HOME/.local/share/profanity/scripts/.") - CMD_ARGS( - { "script run <script>", "Execute a script." }, - { "script list", "List all scripts TODO." }, - { "script show <script>", "Show the commands in script TODO." }) - CMD_EXAMPLES( - "/script list", - "/script run myscript", - "/script show somescript") - }, + parse_args, 1, 2, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_script) + CMD_NOTAGS + CMD_SYN( + "/script run <script>", + "/script list", + "/script show <script>") + CMD_DESC( + "Run command scripts. " + "Scripts are stored in $XDG_DATA_HOME/profanity/scripts/ which is usually $HOME/.local/share/profanity/scripts/.") + CMD_ARGS( + { "script run <script>", "Execute a script." }, + { "script list", "List all scripts TODO." }, + { "script show <script>", "Show the commands in script TODO." }) + CMD_EXAMPLES( + "/script list", + "/script run myscript", + "/script show somescript") }, { "/export", - parse_args, 1, 1, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_export) - CMD_NOTAGS - CMD_SYN( - "/export <filepath>") - CMD_DESC( - "Exports contacts to a csv file.") - CMD_ARGS( - { "<filepath>", "Path to the output file." }) - CMD_EXAMPLES( - "/export /path/to/output.csv", - "/export ~/contacts.csv") - }, + parse_args, 1, 1, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_export) + CMD_NOTAGS + CMD_SYN( + "/export <filepath>") + CMD_DESC( + "Exports contacts to a csv file.") + CMD_ARGS( + { "<filepath>", "Path to the output file." }) + CMD_EXAMPLES( + "/export /path/to/output.csv", + "/export ~/contacts.csv") }, { "/cmd", - parse_args, 1, 3, NULL, - CMD_SUBFUNCS( - { "list", cmd_command_list }, - { "exec", cmd_command_exec }) - CMD_NOMAINFUNC - CMD_NOTAGS - CMD_SYN( - "/cmd list [<jid>]", - "/cmd exec <command> [<jid>]") - CMD_DESC( - "Execute ad hoc commands.") - CMD_ARGS( - { "list", "List supported ad hoc commands." }, - { "exec <command>", "Execute a command." }) - CMD_EXAMPLES( - "/cmd list", - "/cmd exec ping") - }, + parse_args, 1, 3, NULL, + CMD_SUBFUNCS( + { "list", cmd_command_list }, + { "exec", cmd_command_exec }) + CMD_NOMAINFUNC + CMD_NOTAGS + CMD_SYN( + "/cmd list [<jid>]", + "/cmd exec <command> [<jid>]") + CMD_DESC( + "Execute ad hoc commands.") + CMD_ARGS( + { "list", "List supported ad hoc commands." }, + { "exec <command>", "Execute a command." }) + CMD_EXAMPLES( + "/cmd list", + "/cmd exec ping") }, { "/omemo", - parse_args, 1, 3, NULL, - CMD_SUBFUNCS( - { "gen", cmd_omemo_gen }, - { "log", cmd_omemo_log }, - { "start", cmd_omemo_start }, - { "end", cmd_omemo_end }, - { "trust", cmd_omemo_trust }, - { "untrust", cmd_omemo_untrust }, - { "fingerprint", cmd_omemo_fingerprint }, - { "char", cmd_omemo_char }, - { "policy", cmd_omemo_policy }, - { "clear_device_list", cmd_omemo_clear_device_list }, - { "sendfile", cmd_omemo_sendfile} ) - CMD_NOMAINFUNC - CMD_TAGS( - CMD_TAG_CHAT, - CMD_TAG_UI) - CMD_SYN( - "/omemo gen", - "/omemo log on|off|redact", - "/omemo start [<contact>]", - "/omemo trust [<contact>] <fingerprint>", - "/omemo end", - "/omemo fingerprint [<contact>]", - "/omemo char <char>", - "/omemo policy manual|automatic|always", - "/omemo sendfile on|off", - "/omemo clear_device_list") - CMD_DESC( - "OMEMO commands to manage keys, and perform encryption during chat sessions.") - CMD_ARGS( - { "gen", "Generate OMEMO crytographic materials for current account." }, - { "start [<contact>]", "Start an OMEMO session with contact, or current recipient if omitted." }, - { "end", "End the current OMEMO session." }, - { "log on|off", "Enable or disable plaintext logging of OMEMO encrypted messages." }, - { "log redact", "Log OMEMO encrypted messages, but replace the contents with [redacted]. This is the default." }, - { "fingerprint [<contact>]", "Show contact fingerprints, or current recipient if omitted." }, - { "char <char>", "Set the character to be displayed next to OMEMO encrypted messages." }, - { "policy manual", "Set the global OMEMO policy to manual, OMEMO sessions must be started manually." }, - { "policy automatic", "Set the global OMEMO policy to opportunistic, an OMEMO session will be attempted upon starting a conversation." }, - { "policy always", "Set the global OMEMO policy to always, an error will be displayed if an OMEMO session cannot be initiated upon starting a conversation." }, - { "sendfile on|off", "Allow /sendfile to send unencrypted files while in an OMEMO session."}, - { "clear_device_list", "Clear your own device list on server side. Each client will reannounce itself when connected back."}) - CMD_EXAMPLES( - "/omemo gen", - "/omemo start odin@valhalla.edda", - "/omemo trust c4f9c875-144d7a3b-0c4a05b6-ca3be51a-a037f329-0bd3ae62-07f99719-55559d2a", - "/omemo untrust loki@valhalla.edda c4f9c875-144d7a3b-0c4a05b6-ca3be51a-a037f329-0bd3ae62-07f99719-55559d2a", - "/omemo char *") - }, + parse_args, 1, 3, NULL, + CMD_SUBFUNCS( + { "gen", cmd_omemo_gen }, + { "log", cmd_omemo_log }, + { "start", cmd_omemo_start }, + { "end", cmd_omemo_end }, + { "trust", cmd_omemo_trust }, + { "untrust", cmd_omemo_untrust }, + { "fingerprint", cmd_omemo_fingerprint }, + { "char", cmd_omemo_char }, + { "policy", cmd_omemo_policy }, + { "clear_device_list", cmd_omemo_clear_device_list }, + { "sendfile", cmd_omemo_sendfile }) + CMD_NOMAINFUNC + CMD_TAGS( + CMD_TAG_CHAT, + CMD_TAG_UI) + CMD_SYN( + "/omemo gen", + "/omemo log on|off|redact", + "/omemo start [<contact>]", + "/omemo trust [<contact>] <fingerprint>", + "/omemo end", + "/omemo fingerprint [<contact>]", + "/omemo char <char>", + "/omemo policy manual|automatic|always", + "/omemo sendfile on|off", + "/omemo clear_device_list") + CMD_DESC( + "OMEMO commands to manage keys, and perform encryption during chat sessions.") + CMD_ARGS( + { "gen", "Generate OMEMO crytographic materials for current account." }, + { "start [<contact>]", "Start an OMEMO session with contact, or current recipient if omitted." }, + { "end", "End the current OMEMO session." }, + { "log on|off", "Enable or disable plaintext logging of OMEMO encrypted messages." }, + { "log redact", "Log OMEMO encrypted messages, but replace the contents with [redacted]. This is the default." }, + { "fingerprint [<contact>]", "Show contact fingerprints, or current recipient if omitted." }, + { "char <char>", "Set the character to be displayed next to OMEMO encrypted messages." }, + { "policy manual", "Set the global OMEMO policy to manual, OMEMO sessions must be started manually." }, + { "policy automatic", "Set the global OMEMO policy to opportunistic, an OMEMO session will be attempted upon starting a conversation." }, + { "policy always", "Set the global OMEMO policy to always, an error will be displayed if an OMEMO session cannot be initiated upon starting a conversation." }, + { "sendfile on|off", "Allow /sendfile to send unencrypted files while in an OMEMO session." }, + { "clear_device_list", "Clear your own device list on server side. Each client will reannounce itself when connected back." }) + CMD_EXAMPLES( + "/omemo gen", + "/omemo start odin@valhalla.edda", + "/omemo trust c4f9c875-144d7a3b-0c4a05b6-ca3be51a-a037f329-0bd3ae62-07f99719-55559d2a", + "/omemo untrust loki@valhalla.edda c4f9c875-144d7a3b-0c4a05b6-ca3be51a-a037f329-0bd3ae62-07f99719-55559d2a", + "/omemo char *") }, { "/save", - parse_args, 0, 0, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_save) - CMD_NOTAGS - CMD_SYN( - "/save") - CMD_DESC( - "Save preferences to configuration file.") - CMD_NOARGS - CMD_NOEXAMPLES - }, + parse_args, 0, 0, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_save) + CMD_NOTAGS + CMD_SYN( + "/save") + CMD_DESC( + "Save preferences to configuration file.") + CMD_NOARGS + CMD_NOEXAMPLES }, { "/reload", - parse_args, 0, 0, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_reload) - CMD_NOTAGS - CMD_SYN( - "/reload") - CMD_DESC( - "Reload preferences from configuration file.") - CMD_NOARGS - CMD_NOEXAMPLES - }, + parse_args, 0, 0, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_reload) + CMD_NOTAGS + CMD_SYN( + "/reload") + CMD_DESC( + "Reload preferences from configuration file.") + CMD_NOARGS + CMD_NOEXAMPLES }, { "/paste", - parse_args, 0, 0, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_paste) - CMD_NOTAGS - CMD_SYN( - "/paste") - CMD_DESC( - "Paste clipboard.") - CMD_NOARGS - CMD_NOEXAMPLES - }, + parse_args, 0, 0, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_paste) + CMD_NOTAGS + CMD_SYN( + "/paste") + CMD_DESC( + "Paste clipboard.") + CMD_NOARGS + CMD_NOEXAMPLES }, { "/color", - parse_args, 1, 2, &cons_color_setting, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_color) - CMD_TAGS( - CMD_TAG_UI) - CMD_SYN( - "/color on|off|redgreen|blue", - "/color own on|off") - CMD_DESC( - "Settings for consistent color generation for nicks (XEP-0392). Including corrections for Color Vision Deficiencies. " - "Your terminal needs to support 256 colors.") - CMD_ARGS( - { "on|off|redgreen|blue", "Enable or disable nick colorization for MUC nicks. 'redgreen' is for people with red/green blindess and 'blue' for people with blue blindness."}, - { "own on|off", "Enable color generation for own nick. If disabled the color from the color from the theme ('me') will get used."}) - CMD_EXAMPLES( - "/color off", - "/color on", - "/color blue", - "/color own off") - }, + parse_args, 1, 2, &cons_color_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_color) + CMD_TAGS( + CMD_TAG_UI) + CMD_SYN( + "/color on|off|redgreen|blue", + "/color own on|off") + CMD_DESC( + "Settings for consistent color generation for nicks (XEP-0392). Including corrections for Color Vision Deficiencies. " + "Your terminal needs to support 256 colors.") + CMD_ARGS( + { "on|off|redgreen|blue", "Enable or disable nick colorization for MUC nicks. 'redgreen' is for people with red/green blindess and 'blue' for people with blue blindness." }, + { "own on|off", "Enable color generation for own nick. If disabled the color from the color from the theme ('me') will get used." }) + CMD_EXAMPLES( + "/color off", + "/color on", + "/color blue", + "/color own off") }, { "/avatar", - parse_args, 2, 2, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_avatar) - CMD_TAGS( - CMD_TAG_CHAT) - CMD_SYN( - "/avatar get <barejid>", - "/avatar open <barejid>") - CMD_DESC( - "Download avatar (XEP-0084) for a certain contact. " - "If nothing happens after using this command the user either doesn't have an avatar set at all " - "or doesn't use XEP-0084 to publish it.") - CMD_ARGS( - { "get <barejid>", "Download the avatar. barejid is the JID to download avatar from."}, - { "open <barejid>", "Download avatar and open it with command."}) - CMD_EXAMPLES( - "/avatar get thor@valhalla.edda", - "/avatar open freyja@vanaheimr.edda") - }, + parse_args, 2, 2, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_avatar) + CMD_TAGS( + CMD_TAG_CHAT) + CMD_SYN( + "/avatar get <barejid>", + "/avatar open <barejid>") + CMD_DESC( + "Download avatar (XEP-0084) for a certain contact. " + "If nothing happens after using this command the user either doesn't have an avatar set at all " + "or doesn't use XEP-0084 to publish it.") + CMD_ARGS( + { "get <barejid>", "Download the avatar. barejid is the JID to download avatar from." }, + { "open <barejid>", "Download avatar and open it with command." }) + CMD_EXAMPLES( + "/avatar get thor@valhalla.edda", + "/avatar open freyja@vanaheimr.edda") }, { "/os", - parse_args, 1, 1, &cons_os_setting, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_os) - CMD_TAGS( - CMD_TAG_DISCOVERY) - CMD_SYN( - "/os <on>|<off>") - CMD_DESC( - "Choose whether to include the OS name if a user asks for software information (XEP-0092).") - CMD_ARGS( - { "on|off", ""}) - CMD_NOEXAMPLES - }, + parse_args, 1, 1, &cons_os_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_os) + CMD_TAGS( + CMD_TAG_DISCOVERY) + CMD_SYN( + "/os <on>|<off>") + CMD_DESC( + "Choose whether to include the OS name if a user asks for software information (XEP-0092).") + CMD_ARGS( + { "on|off", "" }) + CMD_NOEXAMPLES }, { "/correction", - parse_args, 1, 2, &cons_correction_setting, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_correction) - CMD_TAGS( - CMD_TAG_UI, - CMD_TAG_CHAT, - CMD_TAG_GROUPCHAT) - CMD_SYN( - "/correction <on>|<off>", - "/correction char <char>") - CMD_DESC( - "Settings regarding Last Message Correction (XEP-0308). " - "Corrections will only work in MUC and regular chat windows. MUC PMs won't be allowed. " - "For more information on how to correct messages, see: /help correct.") - CMD_ARGS( - { "on|off", "Enable/Disable support for last message correction."}, - { "char", "Set character that will prefix corrected messages. Default: '+'."}) - CMD_NOEXAMPLES - }, + parse_args, 1, 2, &cons_correction_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_correction) + CMD_TAGS( + CMD_TAG_UI, + CMD_TAG_CHAT, + CMD_TAG_GROUPCHAT) + CMD_SYN( + "/correction <on>|<off>", + "/correction char <char>") + CMD_DESC( + "Settings regarding Last Message Correction (XEP-0308). " + "Corrections will only work in MUC and regular chat windows. MUC PMs won't be allowed. " + "For more information on how to correct messages, see: /help correct.") + CMD_ARGS( + { "on|off", "Enable/Disable support for last message correction." }, + { "char", "Set character that will prefix corrected messages. Default: '+'." }) + CMD_NOEXAMPLES }, { "/correct", - parse_args, 1, -1, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_correct) - CMD_TAGS( - CMD_TAG_CHAT, - CMD_TAG_GROUPCHAT) - CMD_SYN( - "/correct <message>") - CMD_DESC( - "Correct and resend the last message (XEP-0308). " - "Use tab completion to get the last sent message. " - "For more information on how to configure corrections, see: /help correction.") - CMD_ARGS( - { "message", "The corrected message."}) - CMD_NOEXAMPLES - }, + parse_args, 1, -1, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_correct) + CMD_TAGS( + CMD_TAG_CHAT, + CMD_TAG_GROUPCHAT) + CMD_SYN( + "/correct <message>") + CMD_DESC( + "Correct and resend the last message (XEP-0308). " + "Use tab completion to get the last sent message. " + "For more information on how to configure corrections, see: /help correction.") + CMD_ARGS( + { "message", "The corrected message." }) + CMD_NOEXAMPLES }, { "/slashguard", - parse_args, 1, 1, &cons_slashguard_setting, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_slashguard) - CMD_TAGS( - CMD_TAG_UI, - CMD_TAG_CHAT) - CMD_SYN( - "/slashguard on|off") - CMD_DESC( - "Slashguard won't accept a slash in the first 4 characters of your input field. " - "It tries to protect you from typing ' /quit' and similar things in chats.") - CMD_ARGS( - { "on|off", "Enable or disable slashguard." }) - CMD_NOEXAMPLES - }, + parse_args, 1, 1, &cons_slashguard_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_slashguard) + CMD_TAGS( + CMD_TAG_UI, + CMD_TAG_CHAT) + CMD_SYN( + "/slashguard on|off") + CMD_DESC( + "Slashguard won't accept a slash in the first 4 characters of your input field. " + "It tries to protect you from typing ' /quit' and similar things in chats.") + CMD_ARGS( + { "on|off", "Enable or disable slashguard." }) + CMD_NOEXAMPLES }, { "/serversoftware", - parse_args, 1, 1, NULL, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_serversoftware) - CMD_TAGS( - CMD_TAG_DISCOVERY) - CMD_SYN( - "/serversoftware <domain>") - CMD_DESC( - "Find server or component software version information.") - CMD_ARGS( - { "<domain>", "The jid of your server or component." }) - CMD_EXAMPLES( - "/software valhalla.edda", - "/software xmpp.vanaheimr.edda") - }, + parse_args, 1, 1, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_serversoftware) + CMD_TAGS( + CMD_TAG_DISCOVERY) + CMD_SYN( + "/serversoftware <domain>") + CMD_DESC( + "Find server or component software version information.") + CMD_ARGS( + { "<domain>", "The jid of your server or component." }) + CMD_EXAMPLES( + "/software valhalla.edda", + "/software xmpp.vanaheimr.edda") }, { "/executable", - parse_args, 2, 4, &cons_executable_setting, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_executable) - CMD_TAGS( - CMD_TAG_DISCOVERY) - CMD_SYN( - "/executable avatar <cmd>", - "/executable urlopen (<fileType>|DEF <require_save> <cmd>", - "/executable urlsave (<protocol>|DEF) <cmd>") - CMD_DESC( - "Configure executable that should be called upon a certain command." - "Default is xdg-open.") - CMD_ARGS( - { "avatar", "Set executable that is run in /avatar open. Use your favourite image viewer." }, - { "urlopen", "Set executable that is run in /url open for a given file type. It may be your favorite browser or a specific viewer. Use DEF to set default command for undefined file type." }, - { "urlsave", "Set executable that is run in /url save for a given protocol. Use your favourite downloader. Use DEF to set default command for undefined protocol."}) - CMD_EXAMPLES( - "/executable avatar xdg-open", - "/executable urlopen DEF false \"xdg-open %u\"", - "/executable urlopen html false \"firefox %u\"", - "/executable urlsave aesgcm \"omut -d -o %p %u\"") - }, + parse_args, 2, 4, &cons_executable_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_executable) + CMD_TAGS( + CMD_TAG_DISCOVERY) + CMD_SYN( + "/executable avatar <cmd>", + "/executable urlopen (<fileType>|DEF <require_save> <cmd>", + "/executable urlsave (<protocol>|DEF) <cmd>") + CMD_DESC( + "Configure executable that should be called upon a certain command." + "Default is xdg-open.") + CMD_ARGS( + { "avatar", "Set executable that is run in /avatar open. Use your favourite image viewer." }, + { "urlopen", "Set executable that is run in /url open for a given file type. It may be your favorite browser or a specific viewer. Use DEF to set default command for undefined file type." }, + { "urlsave", "Set executable that is run in /url save for a given protocol. Use your favourite downloader. Use DEF to set default command for undefined protocol." }) + CMD_EXAMPLES( + "/executable avatar xdg-open", + "/executable urlopen DEF false \"xdg-open %u\"", + "/executable urlopen html false \"firefox %u\"", + "/executable urlsave aesgcm \"omut -d -o %p %u\"") }, { "/url", - parse_args, 2, 3, NULL, - CMD_SUBFUNCS( - { "open", cmd_url_open}, - { "save", cmd_url_save }) - CMD_NOMAINFUNC - CMD_TAGS( - CMD_TAG_CHAT, - CMD_TAG_GROUPCHAT) - CMD_SYN( - "/url open <url>", - "/url save <url> [<path>]") - CMD_DESC( - "Deal with URLs") - CMD_ARGS( - { "open", "Open URL with predefined executable." }, - { "save", "Save URL to optional path, default path is current directory"}) - CMD_EXAMPLES( - "/url open https://profanity-im.github.io", - "/url save https://profanity-im.github.io/guide/latest/userguide.html /home/user/Download/") - }, + parse_args, 2, 3, NULL, + CMD_SUBFUNCS( + { "open", cmd_url_open }, + { "save", cmd_url_save }) + CMD_NOMAINFUNC + CMD_TAGS( + CMD_TAG_CHAT, + CMD_TAG_GROUPCHAT) + CMD_SYN( + "/url open <url>", + "/url save <url> [<path>]") + CMD_DESC( + "Deal with URLs") + CMD_ARGS( + { "open", "Open URL with predefined executable." }, + { "save", "Save URL to optional path, default path is current directory" }) + CMD_EXAMPLES( + "/url open https://profanity-im.github.io", + "/url save https://profanity-im.github.io/guide/latest/userguide.html /home/user/Download/") }, }; -static GHashTable *search_index; +static GHashTable* search_index; char* -_cmd_index(Command *cmd) { - GString *index_source = g_string_new(""); +_cmd_index(Command* cmd) +{ + GString* index_source = g_string_new(""); index_source = g_string_append(index_source, cmd->cmd); index_source = g_string_append(index_source, " "); index_source = g_string_append(index_source, cmd->help.desc); @@ -2581,36 +2493,36 @@ _cmd_index(Command *cmd) { index_source = g_string_append(index_source, " "); } - gchar **tokens = g_str_tokenize_and_fold(index_source->str, NULL, NULL); + gchar** tokens = g_str_tokenize_and_fold(index_source->str, NULL, NULL); g_string_free(index_source, TRUE); - GString *index = g_string_new(""); + GString* index = g_string_new(""); for (i = 0; i < g_strv_length(tokens); i++) { index = g_string_append(index, tokens[i]); index = g_string_append(index, " "); } g_strfreev(tokens); - char *res = index->str; + char* res = index->str; g_string_free(index, FALSE); return res; } GList* -cmd_search_index_any(char *term) +cmd_search_index_any(char* term) { - GList *results = NULL; + GList* results = NULL; - gchar **processed_terms = g_str_tokenize_and_fold(term, NULL, NULL); + gchar** processed_terms = g_str_tokenize_and_fold(term, NULL, NULL); int terms_len = g_strv_length(processed_terms); int i = 0; for (i = 0; i < terms_len; i++) { - GList *index_keys = g_hash_table_get_keys(search_index); - GList *curr = index_keys; + GList* index_keys = g_hash_table_get_keys(search_index); + GList* curr = index_keys; while (curr) { - char *index_entry = g_hash_table_lookup(search_index, curr->data); + char* index_entry = g_hash_table_lookup(search_index, curr->data); if (g_str_match_string(processed_terms[i], index_entry, FALSE)) { results = g_list_append(results, curr->data); } @@ -2625,21 +2537,21 @@ cmd_search_index_any(char *term) } GList* -cmd_search_index_all(char *term) +cmd_search_index_all(char* term) { - GList *results = NULL; + GList* results = NULL; - gchar **terms = g_str_tokenize_and_fold(term, NULL, NULL); + gchar** terms = g_str_tokenize_and_fold(term, NULL, NULL); int terms_len = g_strv_length(terms); - GList *commands = g_hash_table_get_keys(search_index); - GList *curr = commands; + GList* commands = g_hash_table_get_keys(search_index); + GList* curr = commands; while (curr) { - char *command = curr->data; + char* command = curr->data; int matches = 0; int i = 0; for (i = 0; i < terms_len; i++) { - char *command_index = g_hash_table_lookup(search_index, command); + char* command_index = g_hash_table_lookup(search_index, command); if (g_str_match_string(terms[i], command_index, FALSE)) { matches++; } @@ -2672,7 +2584,7 @@ cmd_init(void) commands = g_hash_table_new(g_str_hash, g_str_equal); unsigned int i; for (i = 0; i < ARRAY_SIZE(command_defs); i++) { - Command *pcmd = command_defs+i; + Command* pcmd = command_defs + i; // add to hash g_hash_table_insert(commands, pcmd->cmd, pcmd); @@ -2685,10 +2597,10 @@ cmd_init(void) } // load aliases - GList *aliases = prefs_get_aliases(); - GList *curr = aliases; + GList* aliases = prefs_get_aliases(); + GList* curr = aliases; while (curr) { - ProfAlias *alias = curr->data; + ProfAlias* alias = curr->data; cmd_ac_add_alias(alias); curr = g_list_next(curr); } @@ -2703,20 +2615,13 @@ cmd_uninit(void) } gboolean -cmd_valid_tag(const char *const str) +cmd_valid_tag(const char* const str) { - return ((g_strcmp0(str, CMD_TAG_CHAT) == 0) || - (g_strcmp0(str, CMD_TAG_GROUPCHAT) == 0) || - (g_strcmp0(str, CMD_TAG_PRESENCE) == 0) || - (g_strcmp0(str, CMD_TAG_ROSTER) == 0) || - (g_strcmp0(str, CMD_TAG_DISCOVERY) == 0) || - (g_strcmp0(str, CMD_TAG_CONNECTION) == 0) || - (g_strcmp0(str, CMD_TAG_UI) == 0) || - (g_strcmp0(str, CMD_TAG_PLUGINS) == 0)); + return ((g_strcmp0(str, CMD_TAG_CHAT) == 0) || (g_strcmp0(str, CMD_TAG_GROUPCHAT) == 0) || (g_strcmp0(str, CMD_TAG_PRESENCE) == 0) || (g_strcmp0(str, CMD_TAG_ROSTER) == 0) || (g_strcmp0(str, CMD_TAG_DISCOVERY) == 0) || (g_strcmp0(str, CMD_TAG_CONNECTION) == 0) || (g_strcmp0(str, CMD_TAG_UI) == 0) || (g_strcmp0(str, CMD_TAG_PLUGINS) == 0)); } Command* -cmd_get(const char *const command) +cmd_get(const char* const command) { if (commands) { return g_hash_table_lookup(commands, command); @@ -2726,9 +2631,9 @@ cmd_get(const char *const command) } GList* -cmd_get_ordered(const char *const tag) +cmd_get_ordered(const char* const tag) { - GList *ordered_commands = NULL; + GList* ordered_commands = NULL; GHashTableIter iter; gpointer key; @@ -2736,7 +2641,7 @@ cmd_get_ordered(const char *const tag) g_hash_table_iter_init(&iter, commands); while (g_hash_table_iter_next(&iter, &key, &value)) { - Command *pcmd = (Command *)value; + Command* pcmd = (Command*)value; if (tag) { if (_cmd_has_tag(pcmd, tag)) { ordered_commands = g_list_insert_sorted(ordered_commands, pcmd->cmd, (GCompareFunc)g_strcmp0); @@ -2750,7 +2655,7 @@ cmd_get_ordered(const char *const tag) } static gboolean -_cmd_has_tag(Command *pcmd, const char *const tag) +_cmd_has_tag(Command* pcmd, const char* const tag) { int i = 0; for (i = 0; pcmd->help.tags[i] != NULL; i++) { @@ -2763,7 +2668,7 @@ _cmd_has_tag(Command *pcmd, const char *const tag) } static int -_cmp_command(Command *cmd1, Command *cmd2) +_cmp_command(Command* cmd1, Command* cmd2) { return g_strcmp0(cmd1->cmd, cmd2->cmd); } @@ -2771,22 +2676,22 @@ _cmp_command(Command *cmd1, Command *cmd2) void command_docgen(void) { - GList *cmds = NULL; + GList* cmds = NULL; unsigned int i; for (i = 0; i < ARRAY_SIZE(command_defs); i++) { - Command *pcmd = command_defs+i; + Command* pcmd = command_defs + i; cmds = g_list_insert_sorted(cmds, pcmd, (GCompareFunc)_cmp_command); } - FILE *toc_fragment = fopen("toc_fragment.html", "w"); - FILE *main_fragment = fopen("main_fragment.html", "w"); + FILE* toc_fragment = fopen("toc_fragment.html", "w"); + FILE* main_fragment = fopen("main_fragment.html", "w"); fputs("<ul><li><ul><li>\n", toc_fragment); fputs("<hr>\n", main_fragment); - GList *curr = cmds; + GList* curr = cmds; while (curr) { - Command *pcmd = curr->data; + Command* pcmd = curr->data; fprintf(toc_fragment, "<a href=\"#%s\">%s</a>,\n", &pcmd->cmd[1], pcmd->cmd); fprintf(main_fragment, "<a name=\"%s\"></a>\n", &pcmd->cmd[1]); @@ -2796,8 +2701,8 @@ command_docgen(void) fputs("<p><pre><code>", main_fragment); int i = 0; while (pcmd->help.synopsis[i]) { - char *str1 = str_replace(pcmd->help.synopsis[i], "<", "<"); - char *str2 = str_replace(str1, ">", ">"); + char* str1 = str_replace(pcmd->help.synopsis[i], "<", "<"); + char* str2 = str_replace(str1, ">", ">"); fprintf(main_fragment, "%s\n", str2); i++; } @@ -2815,8 +2720,8 @@ command_docgen(void) fputs("<tr>", main_fragment); fputs("<td>", main_fragment); fputs("<code>", main_fragment); - char *str1 = str_replace(pcmd->help.args[i][0], "<", "<"); - char *str2 = str_replace(str1, ">", ">"); + char* str1 = str_replace(pcmd->help.args[i][0], "<", "<"); + char* str2 = str_replace(str1, ">", ">"); fprintf(main_fragment, "%s", str2); fputs("</code>", main_fragment); fputs("</td>", main_fragment); diff --git a/src/command/cmd_defs.h b/src/command/cmd_defs.h index 6d829adc..32167c6d 100644 --- a/src/command/cmd_defs.h +++ b/src/command/cmd_defs.h @@ -44,14 +44,14 @@ void cmd_init(void); void cmd_uninit(void); -Command* cmd_get(const char *const command); -GList* cmd_get_ordered(const char *const tag); +Command* cmd_get(const char* const command); +GList* cmd_get_ordered(const char* const tag); -gboolean cmd_valid_tag(const char *const str); +gboolean cmd_valid_tag(const char* const str); void command_docgen(void); -GList* cmd_search_index_all(char *term); -GList* cmd_search_index_any(char *term); +GList* cmd_search_index_all(char* term); +GList* cmd_search_index_any(char* term); #endif diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 1020db96..d7488cff 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -107,21 +107,21 @@ #endif static void _update_presence(const resource_presence_t presence, - const char *const show, gchar **args); -static void _cmd_set_boolean_preference(gchar *arg, const char *const command, - const char *const display, preference_t pref); -static void _who_room(ProfWin *window, const char *const command, gchar **args); -static void _who_roster(ProfWin *window, const char *const command, gchar **args); -static gboolean _cmd_execute(ProfWin *window, const char *const command, const char *const inp); -static gboolean _cmd_execute_default(ProfWin *window, const char *inp); -static gboolean _cmd_execute_alias(ProfWin *window, const char *const inp, gboolean *ran); + const char* const show, gchar** args); +static void _cmd_set_boolean_preference(gchar* arg, const char* const command, + const char* const display, preference_t pref); +static void _who_room(ProfWin* window, const char* const command, gchar** args); +static void _who_roster(ProfWin* window, const char* const command, gchar** args); +static gboolean _cmd_execute(ProfWin* window, const char* const command, const char* const inp); +static gboolean _cmd_execute_default(ProfWin* window, const char* inp); +static gboolean _cmd_execute_alias(ProfWin* window, const char* const inp, gboolean* ran); /* * Take a line of input and process it, return TRUE if profanity is to * continue, FALSE otherwise */ gboolean -cmd_process_input(ProfWin *window, char *inp) +cmd_process_input(ProfWin* window, char* inp) { log_debug("Input received: %s", inp); gboolean result = FALSE; @@ -131,15 +131,15 @@ cmd_process_input(ProfWin *window, char *inp) if (strlen(inp) == 0) { result = TRUE; - // handle command if input starts with a '/' + // handle command if input starts with a '/' } else if (inp[0] == '/') { - char *inp_cpy = strdup(inp); - char *command = strtok(inp_cpy, " "); - char *question_mark = strchr(command, '?'); + char* inp_cpy = strdup(inp); + char* command = strtok(inp_cpy, " "); + char* question_mark = strchr(command, '?'); if (question_mark) { *question_mark = '\0'; - char *fakeinp; - if (asprintf(&fakeinp, "/help %s", command+1)) { + char* fakeinp; + if (asprintf(&fakeinp, "/help %s", command + 1)) { result = _cmd_execute(window, "/help", fakeinp); free(fakeinp); } @@ -148,7 +148,7 @@ cmd_process_input(ProfWin *window, char *inp) } free(inp_cpy); - // call a default handler if input didn't start with '/' + // call a default handler if input didn't start with '/' } else { result = _cmd_execute_default(window, inp); } @@ -159,16 +159,16 @@ cmd_process_input(ProfWin *window, char *inp) // Command execution void -cmd_execute_connect(ProfWin *window, const char *const account) +cmd_execute_connect(ProfWin* window, const char* const account) { - GString *command = g_string_new("/connect "); + GString* command = g_string_new("/connect "); g_string_append(command, account); cmd_process_input(window, command->str); g_string_free(command, TRUE); } gboolean -cmd_tls_certpath(ProfWin *window, const char *const command, gchar **args) +cmd_tls_certpath(ProfWin* window, const char* const command, gchar** args) { #ifdef HAVE_LIBMESODE if (g_strcmp0(args[1], "set") == 0) { @@ -193,7 +193,7 @@ cmd_tls_certpath(ProfWin *window, const char *const command, gchar **args) cons_show("Certificate path defaulted to finding system certpath."); return TRUE; } else if (args[1] == NULL) { - char *path = prefs_get_tls_certpath(); + char* path = prefs_get_tls_certpath(); if (path) { cons_show("Trusted certificate path: %s", path); free(path); @@ -209,11 +209,10 @@ cmd_tls_certpath(ProfWin *window, const char *const command, gchar **args) cons_show("Certificate path setting only supported when built with libmesode."); return TRUE; #endif - } gboolean -cmd_tls_trust(ProfWin *window, const char *const command, gchar **args) +cmd_tls_trust(ProfWin* window, const char* const command, gchar** args) { #ifdef HAVE_LIBMESODE jabber_conn_status_t conn_status = connection_get_status(); @@ -225,7 +224,7 @@ cmd_tls_trust(ProfWin *window, const char *const command, gchar **args) cons_show("No TLS connection established"); return TRUE; } - TLSCertificate *cert = connection_get_tls_peer_cert(); + TLSCertificate* cert = connection_get_tls_peer_cert(); if (!cert) { cons_show("Error getting TLS certificate."); return TRUE; @@ -246,11 +245,11 @@ cmd_tls_trust(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_tls_trusted(ProfWin *window, const char *const command, gchar **args) +cmd_tls_trusted(ProfWin* window, const char* const command, gchar** args) { #ifdef HAVE_LIBMESODE - GList *certs = tlscerts_list(); - GList *curr = certs; + GList* certs = tlscerts_list(); + GList* curr = certs; if (curr) { cons_show("Trusted certificates:"); @@ -259,7 +258,7 @@ cmd_tls_trusted(ProfWin *window, const char *const command, gchar **args) cons_show("No trusted certificates found."); } while (curr) { - TLSCertificate *cert = curr->data; + TLSCertificate* cert = curr->data; cons_show_tlscert_summary(cert); cons_show(""); curr = g_list_next(curr); @@ -273,7 +272,7 @@ cmd_tls_trusted(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_tls_revoke(ProfWin *window, const char *const command, gchar **args) +cmd_tls_revoke(ProfWin* window, const char* const command, gchar** args) { #ifdef HAVE_LIBMESODE if (args[1] == NULL) { @@ -294,11 +293,11 @@ cmd_tls_revoke(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_tls_cert(ProfWin *window, const char *const command, gchar **args) +cmd_tls_cert(ProfWin* window, const char* const command, gchar** args) { #ifdef HAVE_LIBMESODE if (args[1]) { - TLSCertificate *cert = tlscerts_get_trusted(args[1]); + TLSCertificate* cert = tlscerts_get_trusted(args[1]); if (!cert) { cons_show("No such certificate."); } else { @@ -316,7 +315,7 @@ cmd_tls_cert(ProfWin *window, const char *const command, gchar **args) cons_show("No TLS connection established"); return TRUE; } - TLSCertificate *cert = connection_get_tls_peer_cert(); + TLSCertificate* cert = connection_get_tls_peer_cert(); if (!cert) { cons_show("Error getting TLS certificate."); return TRUE; @@ -333,7 +332,7 @@ cmd_tls_cert(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_connect(ProfWin *window, const char *const command, gchar **args) +cmd_connect(ProfWin* window, const char* const command, gchar** args) { jabber_conn_status_t conn_status = connection_get_status(); if (conn_status != JABBER_DISCONNECTED) { @@ -341,10 +340,10 @@ cmd_connect(ProfWin *window, const char *const command, gchar **args) return TRUE; } - gchar *opt_keys[] = { "server", "port", "tls", "auth", NULL }; + gchar* opt_keys[] = { "server", "port", "tls", "auth", NULL }; gboolean parsed; - GHashTable *options = parse_options(&args[args[0] ? 1 : 0], opt_keys, &parsed); + GHashTable* options = parse_options(&args[args[0] ? 1 : 0], opt_keys, &parsed); if (!parsed) { cons_bad_cmd_usage(command); cons_show(""); @@ -352,25 +351,18 @@ cmd_connect(ProfWin *window, const char *const command, gchar **args) return TRUE; } - char *altdomain = g_hash_table_lookup(options, "server"); + char* altdomain = g_hash_table_lookup(options, "server"); - char *tls_policy = g_hash_table_lookup(options, "tls"); - if (tls_policy && - (g_strcmp0(tls_policy, "force") != 0) && - (g_strcmp0(tls_policy, "allow") != 0) && - (g_strcmp0(tls_policy, "trust") != 0) && - (g_strcmp0(tls_policy, "disable") != 0) && - (g_strcmp0(tls_policy, "legacy") != 0)) { + char* tls_policy = g_hash_table_lookup(options, "tls"); + if (tls_policy && (g_strcmp0(tls_policy, "force") != 0) && (g_strcmp0(tls_policy, "allow") != 0) && (g_strcmp0(tls_policy, "trust") != 0) && (g_strcmp0(tls_policy, "disable") != 0) && (g_strcmp0(tls_policy, "legacy") != 0)) { cons_bad_cmd_usage(command); cons_show(""); options_destroy(options); return TRUE; } - char *auth_policy = g_hash_table_lookup(options, "auth"); - if (auth_policy && - (g_strcmp0(auth_policy, "default") != 0) && - (g_strcmp0(auth_policy, "legacy") != 0)) { + char* auth_policy = g_hash_table_lookup(options, "auth"); + if (auth_policy && (g_strcmp0(auth_policy, "default") != 0) && (g_strcmp0(auth_policy, "legacy") != 0)) { cons_bad_cmd_usage(command); cons_show(""); options_destroy(options); @@ -379,8 +371,8 @@ cmd_connect(ProfWin *window, const char *const command, gchar **args) int port = 0; if (g_hash_table_contains(options, "port")) { - char *port_str = g_hash_table_lookup(options, "port"); - char *err_msg = NULL; + char* port_str = g_hash_table_lookup(options, "port"); + char* err_msg = NULL; gboolean res = strtoi_range(port_str, &port, 1, 65535, &err_msg); if (!res) { cons_show(err_msg); @@ -392,8 +384,8 @@ cmd_connect(ProfWin *window, const char *const command, gchar **args) } } - char *user = args[0]; - char *def = prefs_get_string(PREF_DEFAULT_ACCOUNT); + char* user = args[0]; + char* def = prefs_get_string(PREF_DEFAULT_ACCOUNT); if (!user) { if (def) { user = def; @@ -405,12 +397,12 @@ cmd_connect(ProfWin *window, const char *const command, gchar **args) } } - char *jid; + char* jid; user = strdup(user); g_free(def); // connect with account - ProfAccount *account = accounts_get_account(user); + ProfAccount* account = accounts_get_account(user); if (account) { // override account options with connect options if (altdomain != NULL) @@ -426,7 +418,7 @@ cmd_connect(ProfWin *window, const char *const command, gchar **args) if (account->password) { conn_status = cl_ev_connect_account(account); - // use eval_password if set + // use eval_password if set } else if (account->eval_password) { gboolean res = account_eval_password(account); if (res) { @@ -441,7 +433,7 @@ cmd_connect(ProfWin *window, const char *const command, gchar **args) return TRUE; } - // no account password setting, prompt + // no account password setting, prompt } else { account->password = ui_ask_password(); conn_status = cl_ev_connect_account(account); @@ -452,10 +444,10 @@ cmd_connect(ProfWin *window, const char *const command, gchar **args) jid = account_create_connect_jid(account); account_free(account); - // connect with JID + // connect with JID } else { jid = g_utf8_strdown(user, -1); - char *passwd = ui_ask_password(); + char* passwd = ui_ask_password(); conn_status = cl_ev_connect_jid(jid, passwd, altdomain, port, tls_policy, auth_policy); free(passwd); } @@ -473,9 +465,9 @@ cmd_connect(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_account_list(ProfWin *window, const char *const command, gchar **args) +cmd_account_list(ProfWin* window, const char* const command, gchar** args) { - gchar **accounts = accounts_get_list(); + gchar** accounts = accounts_get_list(); cons_show_account_list(accounts); g_strfreev(accounts); @@ -483,15 +475,15 @@ cmd_account_list(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_account_show(ProfWin *window, const char *const command, gchar **args) +cmd_account_show(ProfWin* window, const char* const command, gchar** args) { - char *account_name = args[1]; + char* account_name = args[1]; if (account_name == NULL) { cons_bad_cmd_usage(command); return TRUE; } - ProfAccount *account = accounts_get_account(account_name); + ProfAccount* account = accounts_get_account(account_name); if (account == NULL) { cons_show("No such account."); cons_show(""); @@ -504,9 +496,9 @@ cmd_account_show(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_account_add(ProfWin *window, const char *const command, gchar **args) +cmd_account_add(ProfWin* window, const char* const command, gchar** args) { - char *account_name = args[1]; + char* account_name = args[1]; if (account_name == NULL) { cons_bad_cmd_usage(command); return TRUE; @@ -520,18 +512,18 @@ cmd_account_add(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_account_remove(ProfWin *window, const char *const command, gchar **args) +cmd_account_remove(ProfWin* window, const char* const command, gchar** args) { - char *account_name = args[1]; - if(!account_name) { + char* account_name = args[1]; + if (!account_name) { cons_bad_cmd_usage(command); return TRUE; } - char *def = prefs_get_string(PREF_DEFAULT_ACCOUNT); - if(accounts_remove(account_name)){ + char* def = prefs_get_string(PREF_DEFAULT_ACCOUNT); + if (accounts_remove(account_name)) { cons_show("Account %s removed.", account_name); - if(def && strcmp(def, account_name) == 0){ + if (def && strcmp(def, account_name) == 0) { prefs_set_string(PREF_DEFAULT_ACCOUNT, NULL); cons_show("Default account removed because the corresponding account was removed."); } @@ -546,9 +538,9 @@ cmd_account_remove(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_account_enable(ProfWin *window, const char *const command, gchar **args) +cmd_account_enable(ProfWin* window, const char* const command, gchar** args) { - char *account_name = args[1]; + char* account_name = args[1]; if (account_name == NULL) { cons_bad_cmd_usage(command); return TRUE; @@ -565,9 +557,9 @@ cmd_account_enable(ProfWin *window, const char *const command, gchar **args) return TRUE; } gboolean -cmd_account_disable(ProfWin *window, const char *const command, gchar **args) +cmd_account_disable(ProfWin* window, const char* const command, gchar** args) { - char *account_name = args[1]; + char* account_name = args[1]; if (account_name == NULL) { cons_bad_cmd_usage(command); return TRUE; @@ -585,15 +577,15 @@ cmd_account_disable(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_account_rename(ProfWin *window, const char *const command, gchar **args) +cmd_account_rename(ProfWin* window, const char* const command, gchar** args) { if (g_strv_length(args) != 3) { cons_bad_cmd_usage(command); return TRUE; } - char *account_name = args[1]; - char *new_name = args[2]; + char* account_name = args[1]; + char* new_name = args[2]; if (accounts_rename(account_name, new_name)) { cons_show("Account renamed."); @@ -607,10 +599,10 @@ cmd_account_rename(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_account_default(ProfWin *window, const char *const command, gchar **args) +cmd_account_default(ProfWin* window, const char* const command, gchar** args) { if (g_strv_length(args) == 1) { - char *def = prefs_get_string(PREF_DEFAULT_ACCOUNT); + char* def = prefs_get_string(PREF_DEFAULT_ACCOUNT); if (def) { cons_show("The default account is %s.", def); free(def); @@ -626,7 +618,7 @@ cmd_account_default(ProfWin *window, const char *const command, gchar **args) } } else if (g_strv_length(args) == 3) { if (strcmp(args[1], "set") == 0) { - ProfAccount *account_p = accounts_get_account(args[2]); + ProfAccount* account_p = accounts_get_account(args[2]); if (account_p) { prefs_set_string(PREF_DEFAULT_ACCOUNT, args[2]); cons_show("Default account set to %s.", args[2]); @@ -645,9 +637,9 @@ cmd_account_default(ProfWin *window, const char *const command, gchar **args) } gboolean -_account_set_jid(char *account_name, char *jid) +_account_set_jid(char* account_name, char* jid) { - Jid *jidp = jid_create(jid); + Jid* jidp = jid_create(jid); if (jidp == NULL) { cons_show("Malformed jid: %s", jid); } else { @@ -665,7 +657,7 @@ _account_set_jid(char *account_name, char *jid) } gboolean -_account_set_server(char *account_name, char *server) +_account_set_server(char* account_name, char* server) { accounts_set_server(account_name, server); cons_show("Updated server for account %s: %s", account_name, server); @@ -674,10 +666,10 @@ _account_set_server(char *account_name, char *server) } gboolean -_account_set_port(char *account_name, char *port) +_account_set_port(char* account_name, char* port) { int porti; - char *err_msg = NULL; + char* err_msg = NULL; gboolean res = strtoi_range(port, &porti, 1, 65535, &err_msg); if (!res) { cons_show(err_msg); @@ -692,7 +684,7 @@ _account_set_port(char *account_name, char *port) } gboolean -_account_set_resource(char *account_name, char *resource) +_account_set_resource(char* account_name, char* resource) { accounts_set_resource(account_name, resource); if (connection_get_status() == JABBER_CONNECTED) { @@ -705,9 +697,9 @@ _account_set_resource(char *account_name, char *resource) } gboolean -_account_set_password(char *account_name, char *password) +_account_set_password(char* account_name, char* password) { - ProfAccount *account = accounts_get_account(account_name); + ProfAccount* account = accounts_get_account(account_name); if (account->eval_password) { cons_show("Cannot set password when eval_password is set."); } else { @@ -720,10 +712,10 @@ _account_set_password(char *account_name, char *password) } gboolean -_account_set_eval_password(char *account_name, char *eval_password) +_account_set_eval_password(char* account_name, char* eval_password) { - ProfAccount *account = accounts_get_account(account_name); - if(account->password) { + ProfAccount* account = accounts_get_account(account_name); + if (account->password) { cons_show("Cannot set eval_password when password is set."); } else { accounts_set_eval_password(account_name, eval_password); @@ -735,7 +727,7 @@ _account_set_eval_password(char *account_name, char *eval_password) } gboolean -_account_set_muc(char *account_name, char *muc) +_account_set_muc(char* account_name, char* muc) { accounts_set_muc_service(account_name, muc); cons_show("Updated muc service for account %s: %s", account_name, muc); @@ -744,7 +736,7 @@ _account_set_muc(char *account_name, char *muc) } gboolean -_account_set_nick(char *account_name, char *nick) +_account_set_nick(char* account_name, char* nick) { accounts_set_muc_nick(account_name, nick); cons_show("Updated muc nick for account %s: %s", account_name, nick); @@ -753,11 +745,11 @@ _account_set_nick(char *account_name, char *nick) } gboolean -_account_set_otr(char *account_name, char *policy) +_account_set_otr(char* account_name, char* policy) { if ((g_strcmp0(policy, "manual") != 0) - && (g_strcmp0(policy, "opportunistic") != 0) - && (g_strcmp0(policy, "always") != 0)) { + && (g_strcmp0(policy, "opportunistic") != 0) + && (g_strcmp0(policy, "always") != 0)) { cons_show("OTR policy must be one of: manual, opportunistic or always."); } else { accounts_set_otr_policy(account_name, policy); @@ -768,7 +760,7 @@ _account_set_otr(char *account_name, char *policy) } gboolean -_account_set_status(char *account_name, char *status) +_account_set_status(char* account_name, char* status) { if (!valid_resource_presence_string(status) && (strcmp(status, "last") != 0)) { cons_show("Invalid status: %s", status); @@ -781,10 +773,10 @@ _account_set_status(char *account_name, char *status) } gboolean -_account_set_pgpkeyid(char *account_name, char *pgpkeyid) +_account_set_pgpkeyid(char* account_name, char* pgpkeyid) { #ifdef HAVE_LIBGPGME - char *err_str = NULL; + char* err_str = NULL; if (!p_gpg_valid_key(pgpkeyid, &err_str)) { cons_show("Invalid PGP key ID specified: %s, see /pgp keys", err_str); } else { @@ -800,7 +792,7 @@ _account_set_pgpkeyid(char *account_name, char *pgpkeyid) } gboolean -_account_set_startscript(char *account_name, char *script) +_account_set_startscript(char* account_name, char* script) { accounts_set_script_start(account_name, script); cons_show("Updated start script for account %s: %s", account_name, script); @@ -808,7 +800,7 @@ _account_set_startscript(char *account_name, char *script) } gboolean -_account_set_theme(char *account_name, char *theme) +_account_set_theme(char* account_name, char* theme) { if (!theme_exists(theme)) { cons_show("Theme does not exist: %s", theme); @@ -817,7 +809,7 @@ _account_set_theme(char *account_name, char *theme) accounts_set_theme(account_name, theme); if (connection_get_status() == JABBER_CONNECTED) { - ProfAccount *account = accounts_get_account(session_get_account_name()); + ProfAccount* account = accounts_get_account(session_get_account_name()); if (account) { if (g_strcmp0(account->name, account_name) == 0) { theme_load(theme, false); @@ -842,13 +834,13 @@ _account_set_theme(char *account_name, char *theme) } gboolean -_account_set_tls(char *account_name, char *policy) +_account_set_tls(char* account_name, char* policy) { if ((g_strcmp0(policy, "force") != 0) - && (g_strcmp0(policy, "allow") != 0) - && (g_strcmp0(policy, "trust") != 0) - && (g_strcmp0(policy, "disable") != 0) - && (g_strcmp0(policy, "legacy") != 0)) { + && (g_strcmp0(policy, "allow") != 0) + && (g_strcmp0(policy, "trust") != 0) + && (g_strcmp0(policy, "disable") != 0) + && (g_strcmp0(policy, "legacy") != 0)) { cons_show("TLS policy must be one of: force, allow, legacy or disable."); } else { accounts_set_tls_policy(account_name, policy); @@ -859,10 +851,10 @@ _account_set_tls(char *account_name, char *policy) } gboolean -_account_set_auth(char *account_name, char *policy) +_account_set_auth(char* account_name, char* policy) { if ((g_strcmp0(policy, "default") != 0) - && (g_strcmp0(policy, "legacy") != 0)) { + && (g_strcmp0(policy, "legacy") != 0)) { cons_show("Auth policy must be either default or legacy."); } else { accounts_set_auth_policy(account_name, policy); @@ -873,10 +865,10 @@ _account_set_auth(char *account_name, char *policy) } gboolean -_account_set_presence_priority(char *account_name, char *presence, char *priority) +_account_set_presence_priority(char* account_name, char* presence, char* priority) { int intval; - char *err_msg = NULL; + char* err_msg = NULL; gboolean res = strtoi_range(priority, &intval, -128, 127, &err_msg); if (!res) { cons_show(err_msg); @@ -885,8 +877,7 @@ _account_set_presence_priority(char *account_name, char *presence, char *priorit } resource_presence_t presence_type = resource_presence_from_string(presence); - switch (presence_type) - { + switch (presence_type) { case (RESOURCE_ONLINE): accounts_set_priority_online(account_name, intval); break; @@ -906,7 +897,7 @@ _account_set_presence_priority(char *account_name, char *presence, char *priorit jabber_conn_status_t conn_status = connection_get_status(); if (conn_status == JABBER_CONNECTED) { - char *connected_account = session_get_account_name(); + char* connected_account = session_get_account_name(); resource_presence_t last_presence = accounts_get_last_presence(connected_account); if (presence_type == last_presence) { cl_ev_presence_send(last_presence, 0); @@ -918,37 +909,52 @@ _account_set_presence_priority(char *account_name, char *presence, char *priorit } gboolean -cmd_account_set(ProfWin *window, const char *const command, gchar **args) +cmd_account_set(ProfWin* window, const char* const command, gchar** args) { if (g_strv_length(args) != 4) { cons_bad_cmd_usage(command); return TRUE; } - char *account_name = args[1]; + char* account_name = args[1]; if (!accounts_account_exists(account_name)) { cons_show("Account %s doesn't exist", account_name); cons_show(""); return TRUE; } - char *property = args[2]; - char *value = args[3]; - if (strcmp(property, "jid") == 0) return _account_set_jid(account_name, value); - if (strcmp(property, "server") == 0) return _account_set_server(account_name, value); - if (strcmp(property, "port") == 0) return _account_set_port(account_name, value); - if (strcmp(property, "resource") == 0) return _account_set_resource(account_name, value); - if (strcmp(property, "password") == 0) return _account_set_password(account_name, value); - if (strcmp(property, "eval_password") == 0) return _account_set_eval_password(account_name, value); - if (strcmp(property, "muc") == 0) return _account_set_muc(account_name, value); - if (strcmp(property, "nick") == 0) return _account_set_nick(account_name, value); - if (strcmp(property, "otr") == 0) return _account_set_otr(account_name, value); - if (strcmp(property, "status") == 0) return _account_set_status(account_name, value); - if (strcmp(property, "pgpkeyid") == 0) return _account_set_pgpkeyid(account_name, value); - if (strcmp(property, "startscript") == 0) return _account_set_startscript(account_name, value); - if (strcmp(property, "theme") == 0) return _account_set_theme(account_name, value); - if (strcmp(property, "tls") == 0) return _account_set_tls(account_name, value); - if (strcmp(property, "auth") == 0) return _account_set_auth(account_name, value); + char* property = args[2]; + char* value = args[3]; + if (strcmp(property, "jid") == 0) + return _account_set_jid(account_name, value); + if (strcmp(property, "server") == 0) + return _account_set_server(account_name, value); + if (strcmp(property, "port") == 0) + return _account_set_port(account_name, value); + if (strcmp(property, "resource") == 0) + return _account_set_resource(account_name, value); + if (strcmp(property, "password") == 0) + return _account_set_password(account_name, value); + if (strcmp(property, "eval_password") == 0) + return _account_set_eval_password(account_name, value); + if (strcmp(property, "muc") == 0) + return _account_set_muc(account_name, value); + if (strcmp(property, "nick") == 0) + return _account_set_nick(account_name, value); + if (strcmp(property, "otr") == 0) + return _account_set_otr(account_name, value); + if (strcmp(property, "status") == 0) + return _account_set_status(account_name, value); + if (strcmp(property, "pgpkeyid") == 0) + return _account_set_pgpkeyid(account_name, value); + if (strcmp(property, "startscript") == 0) + return _account_set_startscript(account_name, value); + if (strcmp(property, "theme") == 0) + return _account_set_theme(account_name, value); + if (strcmp(property, "tls") == 0) + return _account_set_tls(account_name, value); + if (strcmp(property, "auth") == 0) + return _account_set_auth(account_name, value); if (valid_resource_presence_string(property)) { return _account_set_presence_priority(account_name, property, value); @@ -961,21 +967,21 @@ cmd_account_set(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_account_clear(ProfWin *window, const char *const command, gchar **args) +cmd_account_clear(ProfWin* window, const char* const command, gchar** args) { if (g_strv_length(args) != 3) { cons_bad_cmd_usage(command); return TRUE; } - char *account_name = args[1]; + char* account_name = args[1]; if (!accounts_account_exists(account_name)) { cons_show("Account %s doesn't exist", account_name); cons_show(""); return TRUE; } - char *property = args[2]; + char* property = args[2]; if (strcmp(property, "password") == 0) { accounts_clear_password(account_name); cons_show("Removed password for account %s", account_name); @@ -1025,7 +1031,7 @@ cmd_account_clear(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_account(ProfWin *window, const char *const command, gchar **args) +cmd_account(ProfWin* window, const char* const command, gchar** args) { if (args[0] != NULL) { cons_bad_cmd_usage(command); @@ -1038,7 +1044,7 @@ cmd_account(ProfWin *window, const char *const command, gchar **args) return TRUE; } - ProfAccount *account = accounts_get_account(session_get_account_name()); + ProfAccount* account = accounts_get_account(session_get_account_name()); if (account) { cons_show_account(account); account_free(account); @@ -1050,7 +1056,7 @@ cmd_account(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_script(ProfWin *window, const char *const command, gchar **args) +cmd_script(ProfWin* window, const char* const command, gchar** args) { if ((g_strcmp0(args[0], "run") == 0) && args[1]) { gboolean res = scripts_exec(args[1]); @@ -1058,11 +1064,11 @@ cmd_script(ProfWin *window, const char *const command, gchar **args) cons_show("Could not find script %s", args[1]); } } else if (g_strcmp0(args[0], "list") == 0) { - GSList *scripts = scripts_list(); + GSList* scripts = scripts_list(); cons_show_scripts(scripts); g_slist_free_full(scripts, g_free); } else if ((g_strcmp0(args[0], "show") == 0) && args[1]) { - GSList *commands = scripts_read(args[1]); + GSList* commands = scripts_read(args[1]); cons_show_script(args[1], commands); g_slist_free_full(commands, g_free); } else { @@ -1074,16 +1080,22 @@ cmd_script(ProfWin *window, const char *const command, gchar **args) /* escape a string into csv and write it to the file descriptor */ static int -_writecsv(int fd, const char *const str) +_writecsv(int fd, const char* const str) { - if (!str) return 0; + if (!str) + return 0; size_t len = strlen(str); - char *s = malloc(2 * len * sizeof(char)); - char *c = s; + char* s = malloc(2 * len * sizeof(char)); + char* c = s; int i = 0; for (; i < strlen(str); i++) { - if (str[i] != '"') *c++ = str[i]; - else { *c++ = '"'; *c++ = '"'; len++; } + if (str[i] != '"') + *c++ = str[i]; + else { + *c++ = '"'; + *c++ = '"'; + len++; + } } if (-1 == write(fd, s, len)) { cons_show("error: failed to write '%s' to the requested file: %s", s, strerror(errno)); @@ -1094,7 +1106,7 @@ _writecsv(int fd, const char *const str) } gboolean -cmd_export(ProfWin *window, const char *const command, gchar **args) +cmd_export(ProfWin* window, const char* const command, gchar** args) { jabber_conn_status_t conn_status = connection_get_status(); @@ -1103,8 +1115,8 @@ cmd_export(ProfWin *window, const char *const command, gchar **args) cons_show(""); return TRUE; } else { - GString *fname = g_string_new(""); - GSList *list = NULL; + GString* fname = g_string_new(""); + GSList* list = NULL; int fd; /* deal with the ~ convention for $HOME */ @@ -1124,22 +1136,28 @@ cmd_export(ProfWin *window, const char *const command, gchar **args) return TRUE; } - if (-1 == write(fd, "jid,name\n", strlen("jid,name\n"))) goto write_error; + if (-1 == write(fd, "jid,name\n", strlen("jid,name\n"))) + goto write_error; list = roster_get_contacts(ROSTER_ORD_NAME); if (list) { - GSList *curr = list; - while (curr){ + GSList* curr = list; + while (curr) { PContact contact = curr->data; - const char *jid = p_contact_barejid(contact); - const char *name = p_contact_name(contact); + const char* jid = p_contact_barejid(contact); + const char* name = p_contact_name(contact); /* write the data to the file */ - if (-1 == write(fd, "\"", 1)) goto write_error; - if (-1 == _writecsv(fd, jid)) goto write_error; - if (-1 == write(fd, "\",\"", 3)) goto write_error; - if (-1 == _writecsv(fd, name)) goto write_error; - if (-1 == write(fd, "\"\n", 2)) goto write_error; + if (-1 == write(fd, "\"", 1)) + goto write_error; + if (-1 == _writecsv(fd, jid)) + goto write_error; + if (-1 == write(fd, "\",\"", 3)) + goto write_error; + if (-1 == _writecsv(fd, name)) + goto write_error; + if (-1 == write(fd, "\"\n", 2)) + goto write_error; /* loop */ curr = g_slist_next(curr); @@ -1154,7 +1172,7 @@ cmd_export(ProfWin *window, const char *const command, gchar **args) g_slist_free(list); close(fd); return TRUE; -write_error: + write_error: cons_show("error: write failed: %s", strerror(errno)); cons_show(""); g_slist_free(list); @@ -1164,7 +1182,7 @@ write_error: } gboolean -cmd_sub(ProfWin *window, const char *const command, gchar **args) +cmd_sub(ProfWin* window, const char* const command, gchar** args) { jabber_conn_status_t conn_status = connection_get_status(); @@ -1198,12 +1216,12 @@ cmd_sub(ProfWin *window, const char *const command, gchar **args) } if (jid == NULL) { - ProfChatWin *chatwin = (ProfChatWin*)window; + ProfChatWin* chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); jid = chatwin->barejid; } - Jid *jidp = jid_create(jid); + Jid* jidp = jid_create(jid); if (strcmp(subcmd, "allow") == 0) { presence_subscription(jidp->barejid, PRESENCE_SUBSCRIBED); @@ -1229,18 +1247,18 @@ cmd_sub(ProfWin *window, const char *const command, gchar **args) if (window->type == WIN_CHAT) { if (p_contact_pending_out(contact)) { win_println(window, THEME_DEFAULT, "-", "%s subscription status: %s, request pending.", - jidp->barejid, p_contact_subscription(contact)); + jidp->barejid, p_contact_subscription(contact)); } else { win_println(window, THEME_DEFAULT, "-", "%s subscription status: %s.", jidp->barejid, - p_contact_subscription(contact)); + p_contact_subscription(contact)); } } else { if (p_contact_pending_out(contact)) { cons_show("%s subscription status: %s, request pending.", - jidp->barejid, p_contact_subscription(contact)); + jidp->barejid, p_contact_subscription(contact)); } else { cons_show("%s subscription status: %s.", jidp->barejid, - p_contact_subscription(contact)); + p_contact_subscription(contact)); } } } @@ -1254,7 +1272,7 @@ cmd_sub(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_disconnect(ProfWin *window, const char *const command, gchar **args) +cmd_disconnect(ProfWin* window, const char* const command, gchar** args) { if (connection_get_status() != JABBER_CONNECTED) { cons_show("You are not currently connected."); @@ -1263,7 +1281,7 @@ cmd_disconnect(ProfWin *window, const char *const command, gchar **args) cl_ev_disconnect(); - char *theme = prefs_get_string(PREF_THEME); + char* theme = prefs_get_string(PREF_THEME); if (theme) { gboolean res = theme_load(theme, false); g_free(theme); @@ -1290,7 +1308,7 @@ cmd_disconnect(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_quit(ProfWin *window, const char *const command, gchar **args) +cmd_quit(ProfWin* window, const char* const command, gchar** args) { log_info("Profanity is shutting down..."); exit(0); @@ -1298,21 +1316,21 @@ cmd_quit(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_wins_unread(ProfWin *window, const char *const command, gchar **args) +cmd_wins_unread(ProfWin* window, const char* const command, gchar** args) { cons_show_wins(TRUE); return TRUE; } gboolean -cmd_wins_prune(ProfWin *window, const char *const command, gchar **args) +cmd_wins_prune(ProfWin* window, const char* const command, gchar** args) { ui_prune_wins(); return TRUE; } gboolean -cmd_wins_swap(ProfWin *window, const char *const command, gchar **args) +cmd_wins_swap(ProfWin* window, const char* const command, gchar** args) { if ((args[1] == NULL) || (args[2] == NULL)) { cons_bad_cmd_usage(command); @@ -1353,7 +1371,7 @@ cmd_wins_swap(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_wins(ProfWin *window, const char *const command, gchar **args) +cmd_wins(ProfWin* window, const char* const command, gchar** args) { if (args[0] != NULL) { cons_bad_cmd_usage(command); @@ -1365,7 +1383,7 @@ cmd_wins(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_close(ProfWin *window, const char *const command, gchar **args) +cmd_close(ProfWin* window, const char* const command, gchar** args) { jabber_conn_status_t conn_status = connection_get_status(); @@ -1424,7 +1442,7 @@ cmd_close(ProfWin *window, const char *const command, gchar **args) return TRUE; } - ProfWin *toclose = wins_get_by_num(index); + ProfWin* toclose = wins_get_by_num(index); if (!toclose) { cons_show("Window is not open."); return TRUE; @@ -1454,7 +1472,7 @@ cmd_close(ProfWin *window, const char *const command, gchar **args) return TRUE; } - ProfWin *toclose = wins_get_by_string(args[0]); + ProfWin* toclose = wins_get_by_string(args[0]); if (!toclose) { cons_show("Window \"%s\" does not exist.", args[0]); return TRUE; @@ -1483,7 +1501,7 @@ cmd_close(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_win(ProfWin *window, const char *const command, gchar **args) +cmd_win(ProfWin* window, const char* const command, gchar** args) { gboolean is_num = TRUE; int i = 0; @@ -1497,14 +1515,14 @@ cmd_win(ProfWin *window, const char *const command, gchar **args) if (is_num) { int num = atoi(args[0]); - ProfWin *focuswin = wins_get_by_num(num); + ProfWin* focuswin = wins_get_by_num(num); if (!focuswin) { cons_show("Window %d does not exist.", num); } else { ui_focus_win(focuswin); } } else { - ProfWin *focuswin = wins_get_by_string(args[0]); + ProfWin* focuswin = wins_get_by_string(args[0]); if (!focuswin) { cons_show("Window \"%s\" does not exist.", args[0]); } else { @@ -1516,21 +1534,23 @@ cmd_win(ProfWin *window, const char *const command, gchar **args) } static void -_cmd_list_commands(GList *commands) { +_cmd_list_commands(GList* commands) +{ int maxlen = 0; - GList *curr = commands; + GList* curr = commands; while (curr) { - gchar *cmd = curr->data; + gchar* cmd = curr->data; int len = strlen(cmd); - if (len > maxlen) maxlen = len; + if (len > maxlen) + maxlen = len; curr = g_list_next(curr); } - GString *cmds = g_string_new(""); + GString* cmds = g_string_new(""); curr = commands; int count = 0; while (curr) { - gchar *cmd = curr->data; + gchar* cmd = curr->data; if (count == 5) { cons_show(cmds->str); g_string_free(cmds, TRUE); @@ -1551,21 +1571,21 @@ _cmd_list_commands(GList *commands) { } static void -_cmd_help_cmd_list(const char *const tag) +_cmd_help_cmd_list(const char* const tag) { cons_show(""); - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); if (tag) { win_println(console, THEME_HELP_HEADER, "-", "%s commands", tag); } else { win_println(console, THEME_HELP_HEADER, "-", "All commands"); } - GList *ordered_commands = NULL; + GList* ordered_commands = NULL; if (g_strcmp0(tag, "plugins") == 0) { - GList *plugins_cmds = plugins_get_command_names(); - GList *curr = plugins_cmds; + GList* plugins_cmds = plugins_get_command_names(); + GList* curr = plugins_cmds; while (curr) { ordered_commands = g_list_insert_sorted(ordered_commands, curr->data, (GCompareFunc)g_strcmp0); curr = g_list_next(curr); @@ -1576,8 +1596,8 @@ _cmd_help_cmd_list(const char *const tag) // add plugins if showing all commands if (!tag) { - GList *plugins_cmds = plugins_get_command_names(); - GList *curr = plugins_cmds; + GList* plugins_cmds = plugins_get_command_names(); + GList* curr = plugins_cmds; while (curr) { ordered_commands = g_list_insert_sorted(ordered_commands, curr->data, (GCompareFunc)g_strcmp0); curr = g_list_next(curr); @@ -1591,7 +1611,7 @@ _cmd_help_cmd_list(const char *const tag) } gboolean -cmd_help(ProfWin *window, const char *const command, gchar **args) +cmd_help(ProfWin* window, const char* const command, gchar** args) { int num_args = g_strv_length(args); if (num_args == 0) { @@ -1600,12 +1620,12 @@ cmd_help(ProfWin *window, const char *const command, gchar **args) if (args[1] == NULL) { cons_bad_cmd_usage(command); } else { - GList *cmds = cmd_search_index_all(args[1]); + GList* cmds = cmd_search_index_all(args[1]); if (cmds == NULL) { cons_show("No commands found."); } else { - GList *curr = cmds; - GList *results = NULL; + GList* curr = cmds; + GList* results = NULL; while (curr) { results = g_list_insert_sorted(results, curr->data, (GCompareFunc)g_strcmp0); curr = g_list_next(curr); @@ -1620,12 +1640,12 @@ cmd_help(ProfWin *window, const char *const command, gchar **args) if (args[1] == NULL) { cons_bad_cmd_usage(command); } else { - GList *cmds = cmd_search_index_any(args[1]); + GList* cmds = cmd_search_index_any(args[1]); if (cmds == NULL) { cons_show("No commands found."); } else { - GList *curr = cmds; - GList *results = NULL; + GList* curr = cmds; + GList* results = NULL; while (curr) { results = g_list_insert_sorted(results, curr->data, (GCompareFunc)g_strcmp0); curr = g_list_next(curr); @@ -1649,15 +1669,15 @@ cmd_help(ProfWin *window, const char *const command, gchar **args) } else if (strcmp(args[0], "navigation") == 0) { cons_navigation_help(); } else { - char *cmd = args[0]; + char* cmd = args[0]; char cmd_with_slash[1 + strlen(cmd) + 1]; sprintf(cmd_with_slash, "/%s", cmd); - Command *command = cmd_get(cmd_with_slash); + Command* command = cmd_get(cmd_with_slash); if (command) { cons_show_help(cmd_with_slash, &command->help); } else { - CommandHelp *commandHelp = plugins_get_help(cmd_with_slash); + CommandHelp* commandHelp = plugins_get_help(cmd_with_slash); if (commandHelp) { cons_show_help(cmd_with_slash, commandHelp); } else { @@ -1671,7 +1691,7 @@ cmd_help(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_about(ProfWin *window, const char *const command, gchar **args) +cmd_about(ProfWin* window, const char* const command, gchar** args) { cons_show(""); cons_about(); @@ -1679,7 +1699,7 @@ cmd_about(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_prefs(ProfWin *window, const char *const command, gchar **args) +cmd_prefs(ProfWin* window, const char* const command, gchar** args) { if (args[0] == NULL) { cons_prefs(); @@ -1728,18 +1748,18 @@ cmd_prefs(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_theme(ProfWin *window, const char *const command, gchar **args) +cmd_theme(ProfWin* window, const char* const command, gchar** args) { // 'full-load' means to load the theme including the settings (not just [colours]) gboolean fullload = (g_strcmp0(args[0], "full-load") == 0); // list themes if (g_strcmp0(args[0], "list") == 0) { - GSList *themes = theme_list(); + GSList* themes = theme_list(); cons_show_themes(themes); g_slist_free_full(themes, g_free); - // load a theme + // load a theme } else if (g_strcmp0(args[0], "load") == 0 || fullload) { if (args[1] == NULL) { cons_bad_cmd_usage(command); @@ -1762,7 +1782,7 @@ cmd_theme(ProfWin *window, const char *const command, gchar **args) cons_show("Couldn't find theme: %s", args[1]); } - // show colours + // show colours } else if (g_strcmp0(args[0], "colours") == 0) { cons_theme_colours(); } else if (g_strcmp0(args[0], "properties") == 0) { @@ -1775,7 +1795,7 @@ cmd_theme(ProfWin *window, const char *const command, gchar **args) } static void -_who_room(ProfWin *window, const char *const command, gchar **args) +_who_room(ProfWin* window, const char* const command, gchar** args) { if ((g_strv_length(args) == 2) && args[1]) { cons_show("Argument group is not applicable to chat rooms."); @@ -1783,53 +1803,30 @@ _who_room(ProfWin *window, const char *const command, gchar **args) } // bad arg - if (args[0] && - (g_strcmp0(args[0], "online") != 0) && - (g_strcmp0(args[0], "available") != 0) && - (g_strcmp0(args[0], "unavailable") != 0) && - (g_strcmp0(args[0], "away") != 0) && - (g_strcmp0(args[0], "chat") != 0) && - (g_strcmp0(args[0], "xa") != 0) && - (g_strcmp0(args[0], "dnd") != 0) && - (g_strcmp0(args[0], "any") != 0) && - (g_strcmp0(args[0], "moderator") != 0) && - (g_strcmp0(args[0], "participant") != 0) && - (g_strcmp0(args[0], "visitor") != 0) && - (g_strcmp0(args[0], "owner") != 0) && - (g_strcmp0(args[0], "admin") != 0) && - (g_strcmp0(args[0], "member") != 0) && - (g_strcmp0(args[0], "outcast") != 0)) { + if (args[0] && (g_strcmp0(args[0], "online") != 0) && (g_strcmp0(args[0], "available") != 0) && (g_strcmp0(args[0], "unavailable") != 0) && (g_strcmp0(args[0], "away") != 0) && (g_strcmp0(args[0], "chat") != 0) && (g_strcmp0(args[0], "xa") != 0) && (g_strcmp0(args[0], "dnd") != 0) && (g_strcmp0(args[0], "any") != 0) && (g_strcmp0(args[0], "moderator") != 0) && (g_strcmp0(args[0], "participant") != 0) && (g_strcmp0(args[0], "visitor") != 0) && (g_strcmp0(args[0], "owner") != 0) && (g_strcmp0(args[0], "admin") != 0) && (g_strcmp0(args[0], "member") != 0) && (g_strcmp0(args[0], "outcast") != 0)) { cons_bad_cmd_usage(command); return; } - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); // presence filter - if (args[0] == NULL || - (g_strcmp0(args[0], "online") == 0) || - (g_strcmp0(args[0], "available") == 0) || - (g_strcmp0(args[0], "unavailable") == 0) || - (g_strcmp0(args[0], "away") == 0) || - (g_strcmp0(args[0], "chat") == 0) || - (g_strcmp0(args[0], "xa") == 0) || - (g_strcmp0(args[0], "dnd") == 0) || - (g_strcmp0(args[0], "any") == 0)) { - - char *presence = args[0]; - GList *occupants = muc_roster(mucwin->roomjid); + if (args[0] == NULL || (g_strcmp0(args[0], "online") == 0) || (g_strcmp0(args[0], "available") == 0) || (g_strcmp0(args[0], "unavailable") == 0) || (g_strcmp0(args[0], "away") == 0) || (g_strcmp0(args[0], "chat") == 0) || (g_strcmp0(args[0], "xa") == 0) || (g_strcmp0(args[0], "dnd") == 0) || (g_strcmp0(args[0], "any") == 0)) { + + char* presence = args[0]; + GList* occupants = muc_roster(mucwin->roomjid); // no arg, show all contacts if ((presence == NULL) || (g_strcmp0(presence, "any") == 0)) { mucwin_roster(mucwin, occupants, NULL); - // available + // available } else if (strcmp("available", presence) == 0) { - GList *filtered = NULL; + GList* filtered = NULL; while (occupants) { - Occupant *occupant = occupants->data; + Occupant* occupant = occupants->data; if (muc_occupant_available(occupant)) { filtered = g_list_append(filtered, occupant); } @@ -1838,12 +1835,12 @@ _who_room(ProfWin *window, const char *const command, gchar **args) mucwin_roster(mucwin, filtered, "available"); - // unavailable + // unavailable } else if (strcmp("unavailable", presence) == 0) { - GList *filtered = NULL; + GList* filtered = NULL; while (occupants) { - Occupant *occupant = occupants->data; + Occupant* occupant = occupants->data; if (!muc_occupant_available(occupant)) { filtered = g_list_append(filtered, occupant); } @@ -1852,13 +1849,13 @@ _who_room(ProfWin *window, const char *const command, gchar **args) mucwin_roster(mucwin, filtered, "unavailable"); - // show specific status + // show specific status } else { - GList *filtered = NULL; + GList* filtered = NULL; while (occupants) { - Occupant *occupant = occupants->data; - const char *presence_str = string_from_resource_presence(occupant->presence); + Occupant* occupant = occupants->data; + const char* presence_str = string_from_resource_presence(occupant->presence); if (strcmp(presence_str, presence) == 0) { filtered = g_list_append(filtered, occupant); } @@ -1870,7 +1867,7 @@ _who_room(ProfWin *window, const char *const command, gchar **args) g_list_free(occupants); - // role or affiliation filter + // role or affiliation filter } else { if (g_strcmp0(args[0], "moderator") == 0) { mucwin_show_role_list(mucwin, MUC_ROLE_MODERATOR); @@ -1905,32 +1902,32 @@ _who_room(ProfWin *window, const char *const command, gchar **args) } static void -_who_roster(ProfWin *window, const char *const command, gchar **args) +_who_roster(ProfWin* window, const char* const command, gchar** args) { - char *presence = args[0]; + char* presence = args[0]; // bad arg if (presence - && (strcmp(presence, "online") != 0) - && (strcmp(presence, "available") != 0) - && (strcmp(presence, "unavailable") != 0) - && (strcmp(presence, "offline") != 0) - && (strcmp(presence, "away") != 0) - && (strcmp(presence, "chat") != 0) - && (strcmp(presence, "xa") != 0) - && (strcmp(presence, "dnd") != 0) - && (strcmp(presence, "any") != 0)) { + && (strcmp(presence, "online") != 0) + && (strcmp(presence, "available") != 0) + && (strcmp(presence, "unavailable") != 0) + && (strcmp(presence, "offline") != 0) + && (strcmp(presence, "away") != 0) + && (strcmp(presence, "chat") != 0) + && (strcmp(presence, "xa") != 0) + && (strcmp(presence, "dnd") != 0) + && (strcmp(presence, "any") != 0)) { cons_bad_cmd_usage(command); return; } - char *group = NULL; + char* group = NULL; if ((g_strv_length(args) == 2) && args[1]) { group = args[1]; } cons_show(""); - GSList *list = NULL; + GSList* list = NULL; if (group) { list = roster_get_group(group, ROSTER_ORD_NAME); if (list == NULL) { @@ -1963,11 +1960,11 @@ _who_roster(ProfWin *window, const char *const command, gchar **args) } } - // available + // available } else if (strcmp("available", presence) == 0) { - GSList *filtered = NULL; + GSList* filtered = NULL; - GSList *curr = list; + GSList* curr = list; while (curr) { PContact contact = curr->data; if (p_contact_is_available(contact)) { @@ -1993,11 +1990,11 @@ _who_roster(ProfWin *window, const char *const command, gchar **args) } g_slist_free(filtered); - // unavailable + // unavailable } else if (strcmp("unavailable", presence) == 0) { - GSList *filtered = NULL; + GSList* filtered = NULL; - GSList *curr = list; + GSList* curr = list; while (curr) { PContact contact = curr->data; if (!p_contact_is_available(contact)) { @@ -2023,11 +2020,11 @@ _who_roster(ProfWin *window, const char *const command, gchar **args) } g_slist_free(filtered); - // online, available resources + // online, available resources } else if (strcmp("online", presence) == 0) { - GSList *filtered = NULL; + GSList* filtered = NULL; - GSList *curr = list; + GSList* curr = list; while (curr) { PContact contact = curr->data; if (p_contact_has_available_resource(contact)) { @@ -2053,11 +2050,11 @@ _who_roster(ProfWin *window, const char *const command, gchar **args) } g_slist_free(filtered); - // offline, no available resources + // offline, no available resources } else if (strcmp("offline", presence) == 0) { - GSList *filtered = NULL; + GSList* filtered = NULL; - GSList *curr = list; + GSList* curr = list; while (curr) { PContact contact = curr->data; if (!p_contact_has_available_resource(contact)) { @@ -2083,11 +2080,11 @@ _who_roster(ProfWin *window, const char *const command, gchar **args) } g_slist_free(filtered); - // show specific status + // show specific status } else { - GSList *filtered = NULL; + GSList* filtered = NULL; - GSList *curr = list; + GSList* curr = list; while (curr) { PContact contact = curr->data; if (strcmp(p_contact_presence(contact), presence) == 0) { @@ -2118,7 +2115,7 @@ _who_roster(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_who(ProfWin *window, const char *const command, gchar **args) +cmd_who(ProfWin* window, const char* const command, gchar** args) { jabber_conn_status_t conn_status = connection_get_status(); @@ -2138,10 +2135,10 @@ cmd_who(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_msg(ProfWin *window, const char *const command, gchar **args) +cmd_msg(ProfWin* window, const char* const command, gchar** args) { - char *usr = args[0]; - char *msg = args[1]; + char* usr = args[0]; + char* msg = args[1]; jabber_conn_status_t conn_status = connection_get_status(); @@ -2152,14 +2149,14 @@ cmd_msg(ProfWin *window, const char *const command, gchar **args) // send private message when in MUC room if (window->type == WIN_MUC) { - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); if (muc_roster_contains_nick(mucwin->roomjid, usr)) { - GString *full_jid = g_string_new(mucwin->roomjid); + GString* full_jid = g_string_new(mucwin->roomjid); g_string_append(full_jid, "/"); g_string_append(full_jid, usr); - ProfPrivateWin *privwin = wins_get_private(full_jid->str); + ProfPrivateWin* privwin = wins_get_private(full_jid->str); if (!privwin) { privwin = (ProfPrivateWin*)wins_new_private(full_jid->str); } @@ -2177,14 +2174,14 @@ cmd_msg(ProfWin *window, const char *const command, gchar **args) return TRUE; - // send chat message + // send chat message } else { - char *barejid = roster_barejid_from_name(usr); + char* barejid = roster_barejid_from_name(usr); if (barejid == NULL) { barejid = usr; } - ProfChatWin *chatwin = wins_get_chat(barejid); + ProfChatWin* chatwin = wins_get_chat(barejid); if (!chatwin) { chatwin = chatwin_new(barejid); } @@ -2221,7 +2218,7 @@ cmd_msg(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_group(ProfWin *window, const char *const command, gchar **args) +cmd_group(ProfWin* window, const char* const command, gchar** args) { jabber_conn_status_t conn_status = connection_get_status(); @@ -2232,8 +2229,8 @@ cmd_group(ProfWin *window, const char *const command, gchar **args) // list all groups if (args[1] == NULL) { - GList *groups = roster_get_groups(); - GList *curr = groups; + GList* groups = roster_get_groups(); + GList* curr = groups; if (curr) { cons_show("Groups:"); while (curr) { @@ -2250,28 +2247,28 @@ cmd_group(ProfWin *window, const char *const command, gchar **args) // show contacts in group if (strcmp(args[1], "show") == 0) { - char *group = args[2]; + char* group = args[2]; if (group == NULL) { cons_bad_cmd_usage(command); return TRUE; } - GSList *list = roster_get_group(group, ROSTER_ORD_NAME); + GSList* list = roster_get_group(group, ROSTER_ORD_NAME); cons_show_roster_group(group, list); return TRUE; } // add contact to group if (strcmp(args[1], "add") == 0) { - char *group = args[2]; - char *contact = args[3]; + char* group = args[2]; + char* contact = args[3]; if ((group == NULL) || (contact == NULL)) { cons_bad_cmd_usage(command); return TRUE; } - char *barejid = roster_barejid_from_name(contact); + char* barejid = roster_barejid_from_name(contact); if (barejid == NULL) { barejid = contact; } @@ -2283,7 +2280,7 @@ cmd_group(ProfWin *window, const char *const command, gchar **args) } if (p_contact_in_group(pcontact, group)) { - const char *display_name = p_contact_name_or_jid(pcontact); + const char* display_name = p_contact_name_or_jid(pcontact); ui_contact_already_in_group(display_name, group); } else { roster_send_add_to_group(group, pcontact); @@ -2294,15 +2291,15 @@ cmd_group(ProfWin *window, const char *const command, gchar **args) // remove contact from group if (strcmp(args[1], "remove") == 0) { - char *group = args[2]; - char *contact = args[3]; + char* group = args[2]; + char* contact = args[3]; if ((group == NULL) || (contact == NULL)) { cons_bad_cmd_usage(command); return TRUE; } - char *barejid = roster_barejid_from_name(contact); + char* barejid = roster_barejid_from_name(contact); if (barejid == NULL) { barejid = contact; } @@ -2314,7 +2311,7 @@ cmd_group(ProfWin *window, const char *const command, gchar **args) } if (!p_contact_in_group(pcontact, group)) { - const char *display_name = p_contact_name_or_jid(pcontact); + const char* display_name = p_contact_name_or_jid(pcontact); ui_contact_not_in_group(display_name, group); } else { roster_send_remove_from_group(group, pcontact); @@ -2328,7 +2325,7 @@ cmd_group(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_roster(ProfWin *window, const char *const command, gchar **args) +cmd_roster(ProfWin* window, const char* const command, gchar** args) { jabber_conn_status_t conn_status = connection_get_status(); @@ -2339,31 +2336,31 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args) return TRUE; } - GSList *list = roster_get_contacts(ROSTER_ORD_NAME); + GSList* list = roster_get_contacts(ROSTER_ORD_NAME); cons_show_roster(list); g_slist_free(list); return TRUE; - // show roster, only online contacts - } else if(g_strcmp0(args[0], "online") == 0){ + // show roster, only online contacts + } else if (g_strcmp0(args[0], "online") == 0) { if (conn_status != JABBER_CONNECTED) { cons_show("You are not currently connected."); return TRUE; } - GSList *list = roster_get_contacts_online(); + GSList* list = roster_get_contacts_online(); cons_show_roster(list); g_slist_free(list); return TRUE; - // set roster size + // set roster size } else if (g_strcmp0(args[0], "size") == 0) { if (!args[1]) { cons_bad_cmd_usage(command); return TRUE; } int intval = 0; - char *err_msg = NULL; + char* err_msg = NULL; gboolean res = strtoi_range(args[1], &intval, 1, 99, &err_msg); if (res) { prefs_set_roster_size(intval); @@ -2378,7 +2375,7 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args) return TRUE; } - // set line wrapping + // set line wrapping } else if (g_strcmp0(args[0], "wrap") == 0) { if (!args[1]) { cons_bad_cmd_usage(command); @@ -2389,7 +2386,7 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args) return TRUE; } - // header settings + // header settings } else if (g_strcmp0(args[0], "header") == 0) { if (g_strcmp0(args[1], "char") == 0) { if (!args[2]) { @@ -2408,7 +2405,7 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args) } return TRUE; - // contact settings + // contact settings } else if (g_strcmp0(args[0], "contact") == 0) { if (g_strcmp0(args[1], "char") == 0) { if (!args[2]) { @@ -2427,7 +2424,7 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args) cons_bad_cmd_usage(command); } else { int intval = 0; - char *err_msg = NULL; + char* err_msg = NULL; gboolean res = strtoi_range(args[2], &intval, 0, 10, &err_msg); if (res) { prefs_set_roster_contact_indent(intval); @@ -2443,7 +2440,7 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args) } return TRUE; - // resource settings + // resource settings } else if (g_strcmp0(args[0], "resource") == 0) { if (g_strcmp0(args[1], "char") == 0) { if (!args[2]) { @@ -2462,7 +2459,7 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args) cons_bad_cmd_usage(command); } else { int intval = 0; - char *err_msg = NULL; + char* err_msg = NULL; gboolean res = strtoi_range(args[2], &intval, 0, 10, &err_msg); if (res) { prefs_set_roster_resource_indent(intval); @@ -2482,14 +2479,14 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args) } return TRUE; - // presence settings + // presence settings } else if (g_strcmp0(args[0], "presence") == 0) { if (g_strcmp0(args[1], "indent") == 0) { if (!args[2]) { cons_bad_cmd_usage(command); } else { int intval = 0; - char *err_msg = NULL; + char* err_msg = NULL; gboolean res = strtoi_range(args[2], &intval, -1, 10, &err_msg); if (res) { prefs_set_roster_presence_indent(intval); @@ -2505,10 +2502,10 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args) } return TRUE; - // show/hide roster + // show/hide roster } else if ((g_strcmp0(args[0], "show") == 0) || (g_strcmp0(args[0], "hide") == 0)) { preference_t pref; - const char *pref_str; + const char* pref_str; if (args[1] == NULL) { pref = PREF_ROSTER; pref_str = ""; @@ -2568,7 +2565,7 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args) } return TRUE; - // roster grouping + // roster grouping } else if (g_strcmp0(args[0], "by") == 0) { if (g_strcmp0(args[1], "group") == 0) { cons_show("Grouping roster by roster group"); @@ -2596,7 +2593,7 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args) return TRUE; } - // roster item order + // roster item order } else if (g_strcmp0(args[0], "order") == 0) { if (g_strcmp0(args[1], "name") == 0) { cons_show("Ordering roster by name"); @@ -2885,28 +2882,28 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args) return TRUE; } - // add contact + // add contact } else if (strcmp(args[0], "add") == 0) { if (conn_status != JABBER_CONNECTED) { cons_show("You are not currently connected."); return TRUE; } - char *jid = args[1]; + char* jid = args[1]; if (jid == NULL) { cons_bad_cmd_usage(command); } else { - char *name = args[2]; + char* name = args[2]; roster_send_add_new(jid, name); } return TRUE; - // remove contact + // remove contact } else if (strcmp(args[0], "remove") == 0) { if (conn_status != JABBER_CONNECTED) { cons_show("You are not currently connected."); return TRUE; } - char *jid = args[1]; + char* jid = args[1]; if (jid == NULL) { cons_bad_cmd_usage(command); } else { @@ -2924,8 +2921,8 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args) return TRUE; } - GSList *all = roster_get_contacts(ROSTER_ORD_NAME); - GSList *curr = all; + GSList* all = roster_get_contacts(ROSTER_ORD_NAME); + GSList* curr = all; while (curr) { PContact contact = curr->data; roster_send_remove(p_contact_barejid(contact)); @@ -2935,19 +2932,19 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args) g_slist_free(all); return TRUE; - // change nickname + // change nickname } else if (strcmp(args[0], "nick") == 0) { if (conn_status != JABBER_CONNECTED) { cons_show("You are not currently connected."); return TRUE; } - char *jid = args[1]; + char* jid = args[1]; if (jid == NULL) { cons_bad_cmd_usage(command); return TRUE; } - char *name = args[2]; + char* name = args[2]; if (name == NULL) { cons_bad_cmd_usage(command); return TRUE; @@ -2960,27 +2957,26 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args) return TRUE; } - const char *barejid = p_contact_barejid(contact); + const char* barejid = p_contact_barejid(contact); // TODO wait for result stanza before updating - const char *oldnick = p_contact_name(contact); + const char* oldnick = p_contact_name(contact); wins_change_nick(barejid, oldnick, name); roster_change_name(contact, name); - GSList *groups = p_contact_groups(contact); + GSList* groups = p_contact_groups(contact); roster_send_name_change(barejid, name, groups); - cons_show("Nickname for %s set to: %s.", jid, name); return TRUE; - // remove nickname + // remove nickname } else if (strcmp(args[0], "clearnick") == 0) { if (conn_status != JABBER_CONNECTED) { cons_show("You are not currently connected."); return TRUE; } - char *jid = args[1]; + char* jid = args[1]; if (jid == NULL) { cons_bad_cmd_usage(command); return TRUE; @@ -2993,13 +2989,13 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args) return TRUE; } - const char *barejid = p_contact_barejid(contact); + const char* barejid = p_contact_barejid(contact); // TODO wait for result stanza before updating - const char *oldnick = p_contact_name(contact); + const char* oldnick = p_contact_name(contact); wins_remove_nick(barejid, oldnick); roster_change_name(contact, NULL); - GSList *groups = p_contact_groups(contact); + GSList* groups = p_contact_groups(contact); roster_send_name_change(barejid, NULL, groups); cons_show("Nickname for %s removed.", jid); @@ -3012,7 +3008,7 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_blocked(ProfWin *window, const char *const command, gchar **args) +cmd_blocked(ProfWin* window, const char* const command, gchar** args) { if (connection_get_status() != JABBER_CONNECTED) { cons_show("You are not currently connected."); @@ -3025,9 +3021,9 @@ cmd_blocked(ProfWin *window, const char *const command, gchar **args) } if (g_strcmp0(args[0], "add") == 0) { - char *jid = args[1]; + char* jid = args[1]; if (jid == NULL && (window->type == WIN_CHAT)) { - ProfChatWin *chatwin = (ProfChatWin*)window; + ProfChatWin* chatwin = (ProfChatWin*)window; jid = chatwin->barejid; } @@ -3058,8 +3054,8 @@ cmd_blocked(ProfWin *window, const char *const command, gchar **args) return TRUE; } - GList *blocked = blocked_list(); - GList *curr = blocked; + GList* blocked = blocked_list(); + GList* curr = blocked; if (curr) { cons_show("Blocked users:"); while (curr) { @@ -3074,10 +3070,10 @@ cmd_blocked(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_resource(ProfWin *window, const char *const command, gchar **args) +cmd_resource(ProfWin* window, const char* const command, gchar** args) { - char *cmd = args[0]; - char *setting = NULL; + char* cmd = args[0]; + char* setting = NULL; if (g_strcmp0(cmd, "message") == 0) { setting = args[1]; if (!setting) { @@ -3109,10 +3105,10 @@ cmd_resource(ProfWin *window, const char *const command, gchar **args) return TRUE; } - ProfChatWin *chatwin = (ProfChatWin*)window; + ProfChatWin* chatwin = (ProfChatWin*)window; if (g_strcmp0(cmd, "set") == 0) { - char *resource = args[1]; + char* resource = args[1]; if (!resource) { cons_bad_cmd_usage(command); return TRUE; @@ -3157,7 +3153,7 @@ cmd_resource(ProfWin *window, const char *const command, gchar **args) static void _cmd_status_show_status(char* usr) { - char *usr_jid = roster_barejid_from_name(usr); + char* usr_jid = roster_barejid_from_name(usr); if (usr_jid == NULL) { usr_jid = usr; } @@ -3165,9 +3161,9 @@ _cmd_status_show_status(char* usr) } gboolean -cmd_status_set(ProfWin *window, const char *const command, gchar **args) +cmd_status_set(ProfWin* window, const char* const command, gchar** args) { - char *state = args[1]; + char* state = args[1]; if (g_strcmp0(state, "online") == 0) { _update_presence(RESOURCE_ONLINE, "online", args); @@ -3187,9 +3183,9 @@ cmd_status_set(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_status_get(ProfWin *window, const char *const command, gchar **args) +cmd_status_get(ProfWin* window, const char* const command, gchar** args) { - char *usr = args[1]; + char* usr = args[1]; jabber_conn_status_t conn_status = connection_get_status(); @@ -3198,70 +3194,69 @@ cmd_status_get(ProfWin *window, const char *const command, gchar **args) return TRUE; } - switch (window->type) - { - case WIN_MUC: - if (usr) { - ProfMucWin *mucwin = (ProfMucWin*)window; - assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); - Occupant *occupant = muc_roster_item(mucwin->roomjid, usr); - if (occupant) { - win_show_occupant(window, occupant); - } else { - win_println(window, THEME_DEFAULT, "-", "No such participant \"%s\" in room.", usr); - } - } else { - win_println(window, THEME_DEFAULT, "-", "You must specify a nickname."); - } - break; - case WIN_CHAT: - if (usr) { - _cmd_status_show_status(usr); + switch (window->type) { + case WIN_MUC: + if (usr) { + ProfMucWin* mucwin = (ProfMucWin*)window; + assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); + Occupant* occupant = muc_roster_item(mucwin->roomjid, usr); + if (occupant) { + win_show_occupant(window, occupant); } else { - ProfChatWin *chatwin = (ProfChatWin*)window; - assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); - PContact pcontact = roster_get_contact(chatwin->barejid); - if (pcontact) { - win_show_contact(window, pcontact); - } else { - win_println(window, THEME_DEFAULT, "-", "Error getting contact info."); - } + win_println(window, THEME_DEFAULT, "-", "No such participant \"%s\" in room.", usr); } - break; - case WIN_PRIVATE: - if (usr) { - _cmd_status_show_status(usr); + } else { + win_println(window, THEME_DEFAULT, "-", "You must specify a nickname."); + } + break; + case WIN_CHAT: + if (usr) { + _cmd_status_show_status(usr); + } else { + ProfChatWin* chatwin = (ProfChatWin*)window; + assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); + PContact pcontact = roster_get_contact(chatwin->barejid); + if (pcontact) { + win_show_contact(window, pcontact); } else { - ProfPrivateWin *privatewin = (ProfPrivateWin*)window; - assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK); - Jid *jid = jid_create(privatewin->fulljid); - Occupant *occupant = muc_roster_item(jid->barejid, jid->resourcepart); - if (occupant) { - win_show_occupant(window, occupant); - } else { - win_println(window, THEME_DEFAULT, "-", "Error getting contact info."); - } - jid_destroy(jid); + win_println(window, THEME_DEFAULT, "-", "Error getting contact info."); } - break; - case WIN_CONSOLE: - if (usr) { - _cmd_status_show_status(usr); + } + break; + case WIN_PRIVATE: + if (usr) { + _cmd_status_show_status(usr); + } else { + ProfPrivateWin* privatewin = (ProfPrivateWin*)window; + assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK); + Jid* jid = jid_create(privatewin->fulljid); + Occupant* occupant = muc_roster_item(jid->barejid, jid->resourcepart); + if (occupant) { + win_show_occupant(window, occupant); } else { - cons_bad_cmd_usage(command); + win_println(window, THEME_DEFAULT, "-", "Error getting contact info."); } - break; - default: - break; + jid_destroy(jid); + } + break; + case WIN_CONSOLE: + if (usr) { + _cmd_status_show_status(usr); + } else { + cons_bad_cmd_usage(command); + } + break; + default: + break; } return TRUE; } static void -_cmd_info_show_contact(char *usr) +_cmd_info_show_contact(char* usr) { - char *usr_jid = roster_barejid_from_name(usr); + char* usr_jid = roster_barejid_from_name(usr); if (usr_jid == NULL) { usr_jid = usr; } @@ -3274,9 +3269,9 @@ _cmd_info_show_contact(char *usr) } gboolean -cmd_info(ProfWin *window, const char *const command, gchar **args) +cmd_info(ProfWin* window, const char* const command, gchar** args) { - char *usr = args[0]; + char* usr = args[0]; jabber_conn_status_t conn_status = connection_get_status(); @@ -3285,150 +3280,148 @@ cmd_info(ProfWin *window, const char *const command, gchar **args) return TRUE; } - switch (window->type) - { - case WIN_MUC: - if (usr) { - ProfMucWin *mucwin = (ProfMucWin*)window; - assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); - Occupant *occupant = muc_roster_item(mucwin->roomjid, usr); - if (occupant) { - win_show_occupant_info(window, mucwin->roomjid, occupant); - } else { - win_println(window, THEME_DEFAULT, "-", "No such occupant \"%s\" in room.", usr); - } - } else { - ProfMucWin *mucwin = (ProfMucWin*)window; - assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); - iq_room_info_request(mucwin->roomjid, TRUE); - mucwin_info(mucwin); - return TRUE; - } - break; - case WIN_CHAT: - if (usr) { - _cmd_info_show_contact(usr); + switch (window->type) { + case WIN_MUC: + if (usr) { + ProfMucWin* mucwin = (ProfMucWin*)window; + assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); + Occupant* occupant = muc_roster_item(mucwin->roomjid, usr); + if (occupant) { + win_show_occupant_info(window, mucwin->roomjid, occupant); } else { - ProfChatWin *chatwin = (ProfChatWin*)window; - assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); - PContact pcontact = roster_get_contact(chatwin->barejid); - if (pcontact) { - win_show_info(window, pcontact); - } else { - win_println(window, THEME_DEFAULT, "-", "Error getting contact info."); - } + win_println(window, THEME_DEFAULT, "-", "No such occupant \"%s\" in room.", usr); } - break; - case WIN_PRIVATE: - if (usr) { - _cmd_info_show_contact(usr); + } else { + ProfMucWin* mucwin = (ProfMucWin*)window; + assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); + iq_room_info_request(mucwin->roomjid, TRUE); + mucwin_info(mucwin); + return TRUE; + } + break; + case WIN_CHAT: + if (usr) { + _cmd_info_show_contact(usr); + } else { + ProfChatWin* chatwin = (ProfChatWin*)window; + assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); + PContact pcontact = roster_get_contact(chatwin->barejid); + if (pcontact) { + win_show_info(window, pcontact); } else { - ProfPrivateWin *privatewin = (ProfPrivateWin*)window; - assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK); - Jid *jid = jid_create(privatewin->fulljid); - Occupant *occupant = muc_roster_item(jid->barejid, jid->resourcepart); - if (occupant) { - win_show_occupant_info(window, jid->barejid, occupant); - } else { - win_println(window, THEME_DEFAULT, "-", "Error getting contact info."); - } - jid_destroy(jid); + win_println(window, THEME_DEFAULT, "-", "Error getting contact info."); } - break; - case WIN_CONSOLE: - if (usr) { - _cmd_info_show_contact(usr); + } + break; + case WIN_PRIVATE: + if (usr) { + _cmd_info_show_contact(usr); + } else { + ProfPrivateWin* privatewin = (ProfPrivateWin*)window; + assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK); + Jid* jid = jid_create(privatewin->fulljid); + Occupant* occupant = muc_roster_item(jid->barejid, jid->resourcepart); + if (occupant) { + win_show_occupant_info(window, jid->barejid, occupant); } else { - cons_bad_cmd_usage(command); + win_println(window, THEME_DEFAULT, "-", "Error getting contact info."); } - break; - default: - break; + jid_destroy(jid); + } + break; + case WIN_CONSOLE: + if (usr) { + _cmd_info_show_contact(usr); + } else { + cons_bad_cmd_usage(command); + } + break; + default: + break; } return TRUE; } gboolean -cmd_caps(ProfWin *window, const char *const command, gchar **args) +cmd_caps(ProfWin* window, const char* const command, gchar** args) { jabber_conn_status_t conn_status = connection_get_status(); - Occupant *occupant = NULL; + Occupant* occupant = NULL; if (conn_status != JABBER_CONNECTED) { cons_show("You are not currently connected."); return TRUE; } - switch (window->type) - { - case WIN_MUC: - if (args[0]) { - ProfMucWin *mucwin = (ProfMucWin*)window; - assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); - occupant = muc_roster_item(mucwin->roomjid, args[0]); - if (occupant) { - Jid *jidp = jid_create_from_bare_and_resource(mucwin->roomjid, args[0]); - cons_show_caps(jidp->fulljid, occupant->presence); - jid_destroy(jidp); - } else { - cons_show("No such participant \"%s\" in room.", args[0]); - } + switch (window->type) { + case WIN_MUC: + if (args[0]) { + ProfMucWin* mucwin = (ProfMucWin*)window; + assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); + occupant = muc_roster_item(mucwin->roomjid, args[0]); + if (occupant) { + Jid* jidp = jid_create_from_bare_and_resource(mucwin->roomjid, args[0]); + cons_show_caps(jidp->fulljid, occupant->presence); + jid_destroy(jidp); } else { - cons_show("No nickname supplied to /caps in chat room."); + cons_show("No such participant \"%s\" in room.", args[0]); } - break; - case WIN_CHAT: - case WIN_CONSOLE: - if (args[0]) { - Jid *jid = jid_create(args[0]); + } else { + cons_show("No nickname supplied to /caps in chat room."); + } + break; + case WIN_CHAT: + case WIN_CONSOLE: + if (args[0]) { + Jid* jid = jid_create(args[0]); - if (jid->fulljid == NULL) { - cons_show("You must provide a full jid to the /caps command."); + if (jid->fulljid == NULL) { + cons_show("You must provide a full jid to the /caps command."); + } else { + PContact pcontact = roster_get_contact(jid->barejid); + if (pcontact == NULL) { + cons_show("Contact not found in roster: %s", jid->barejid); } else { - PContact pcontact = roster_get_contact(jid->barejid); - if (pcontact == NULL) { - cons_show("Contact not found in roster: %s", jid->barejid); + Resource* resource = p_contact_get_resource(pcontact, jid->resourcepart); + if (resource == NULL) { + cons_show("Could not find resource %s, for contact %s", jid->barejid, jid->resourcepart); } else { - Resource *resource = p_contact_get_resource(pcontact, jid->resourcepart); - if (resource == NULL) { - cons_show("Could not find resource %s, for contact %s", jid->barejid, jid->resourcepart); - } else { - cons_show_caps(jid->fulljid, resource->presence); - } + cons_show_caps(jid->fulljid, resource->presence); } } - jid_destroy(jid); - } else { - cons_show("You must provide a jid to the /caps command."); } - break; - case WIN_PRIVATE: - if (args[0]) { - cons_show("No parameter needed to /caps when in private chat."); - } else { - ProfPrivateWin *privatewin = (ProfPrivateWin*)window; - assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK); - Jid *jid = jid_create(privatewin->fulljid); - if (jid) { - occupant = muc_roster_item(jid->barejid, jid->resourcepart); - cons_show_caps(jid->resourcepart, occupant->presence); - jid_destroy(jid); - } + jid_destroy(jid); + } else { + cons_show("You must provide a jid to the /caps command."); + } + break; + case WIN_PRIVATE: + if (args[0]) { + cons_show("No parameter needed to /caps when in private chat."); + } else { + ProfPrivateWin* privatewin = (ProfPrivateWin*)window; + assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK); + Jid* jid = jid_create(privatewin->fulljid); + if (jid) { + occupant = muc_roster_item(jid->barejid, jid->resourcepart); + cons_show_caps(jid->resourcepart, occupant->presence); + jid_destroy(jid); } - break; - default: - break; + } + break; + default: + break; } return TRUE; } static void -_send_software_version_iq_to_fulljid(char *request) +_send_software_version_iq_to_fulljid(char* request) { - char *mybarejid = connection_get_barejid(); - Jid *jid = jid_create(request); + char* mybarejid = connection_get_barejid(); + Jid* jid = jid_create(request); if (jid == NULL || jid->fulljid == NULL) { cons_show("You must provide a full jid to the /software command."); @@ -3442,7 +3435,7 @@ _send_software_version_iq_to_fulljid(char *request) } gboolean -cmd_software(ProfWin *window, const char *const command, gchar **args) +cmd_software(ProfWin* window, const char* const command, gchar** args) { jabber_conn_status_t conn_status = connection_get_status(); @@ -3451,75 +3444,74 @@ cmd_software(ProfWin *window, const char *const command, gchar **args) return TRUE; } - switch (window->type) - { - case WIN_MUC: - if (args[0]) { - ProfMucWin *mucwin = (ProfMucWin*)window; - assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); - Occupant *occupant = muc_roster_item(mucwin->roomjid, args[0]); - if (occupant) { - Jid *jid = jid_create_from_bare_and_resource(mucwin->roomjid, args[0]); - iq_send_software_version(jid->fulljid); - jid_destroy(jid); - } else { - cons_show("No such participant \"%s\" in room.", args[0]); - } + switch (window->type) { + case WIN_MUC: + if (args[0]) { + ProfMucWin* mucwin = (ProfMucWin*)window; + assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); + Occupant* occupant = muc_roster_item(mucwin->roomjid, args[0]); + if (occupant) { + Jid* jid = jid_create_from_bare_and_resource(mucwin->roomjid, args[0]); + iq_send_software_version(jid->fulljid); + jid_destroy(jid); } else { - cons_show("No nickname supplied to /software in chat room."); + cons_show("No such participant \"%s\" in room.", args[0]); } + } else { + cons_show("No nickname supplied to /software in chat room."); + } + break; + case WIN_CHAT: + if (args[0]) { + _send_software_version_iq_to_fulljid(args[0]); break; - case WIN_CHAT: - if (args[0]) { - _send_software_version_iq_to_fulljid(args[0]); - break; - } else { - ProfChatWin *chatwin = (ProfChatWin*)window; - assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); - - char *resource = NULL; - ChatSession *session = chat_session_get(chatwin->barejid); - if (chatwin->resource_override) { - resource = chatwin->resource_override; - } else if (session && session->resource) { - resource = session->resource; - } + } else { + ProfChatWin* chatwin = (ProfChatWin*)window; + assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); - if (resource) { - GString *fulljid = g_string_new(chatwin->barejid); - g_string_append_printf(fulljid, "/%s", resource); - iq_send_software_version(fulljid->str); - g_string_free(fulljid, TRUE); - } else { - win_println(window, THEME_DEFAULT, "-", "Unknown resource for /software command. See /help resource."); - } - break; - } - case WIN_CONSOLE: - if (args[0]) { - _send_software_version_iq_to_fulljid(args[0]); - } else { - cons_show("You must provide a jid to the /software command."); + char* resource = NULL; + ChatSession* session = chat_session_get(chatwin->barejid); + if (chatwin->resource_override) { + resource = chatwin->resource_override; + } else if (session && session->resource) { + resource = session->resource; } - break; - case WIN_PRIVATE: - if (args[0]) { - cons_show("No parameter needed to /software when in private chat."); + + if (resource) { + GString* fulljid = g_string_new(chatwin->barejid); + g_string_append_printf(fulljid, "/%s", resource); + iq_send_software_version(fulljid->str); + g_string_free(fulljid, TRUE); } else { - ProfPrivateWin *privatewin = (ProfPrivateWin*)window; - assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK); - iq_send_software_version(privatewin->fulljid); + win_println(window, THEME_DEFAULT, "-", "Unknown resource for /software command. See /help resource."); } break; - default: - break; + } + case WIN_CONSOLE: + if (args[0]) { + _send_software_version_iq_to_fulljid(args[0]); + } else { + cons_show("You must provide a jid to the /software command."); + } + break; + case WIN_PRIVATE: + if (args[0]) { + cons_show("No parameter needed to /software when in private chat."); + } else { + ProfPrivateWin* privatewin = (ProfPrivateWin*)window; + assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK); + iq_send_software_version(privatewin->fulljid); + } + break; + default: + break; } return TRUE; } gboolean -cmd_serversoftware(ProfWin *window, const char *const command, gchar **args) +cmd_serversoftware(ProfWin* window, const char* const command, gchar** args) { jabber_conn_status_t conn_status = connection_get_status(); @@ -3538,7 +3530,7 @@ cmd_serversoftware(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_join(ProfWin *window, const char *const command, gchar **args) +cmd_join(ProfWin* window, const char* const command, gchar** args) { jabber_conn_status_t conn_status = connection_get_status(); if (conn_status != JABBER_CONNECTED) { @@ -3547,11 +3539,11 @@ cmd_join(ProfWin *window, const char *const command, gchar **args) } if (args[0] == NULL) { - char *account_name = session_get_account_name(); - ProfAccount *account = accounts_get_account(account_name); + char* account_name = session_get_account_name(); + ProfAccount* account = accounts_get_account(account_name); if (account->muc_service) { - GString *room_str = g_string_new(""); - char *uuid = connection_create_uuid(); + GString* room_str = g_string_new(""); + char* uuid = connection_create_uuid(); g_string_append_printf(room_str, "private-chat-%s@%s", uuid, account->muc_service); connection_free_uuid(uuid); @@ -3567,43 +3559,43 @@ cmd_join(ProfWin *window, const char *const command, gchar **args) return TRUE; } - Jid *room_arg = jid_create(args[0]); + Jid* room_arg = jid_create(args[0]); if (room_arg == NULL) { cons_show_error("Specified room has incorrect format."); cons_show(""); return TRUE; } - char *room = NULL; - char *nick = NULL; - char *passwd = NULL; - char *account_name = session_get_account_name(); - ProfAccount *account = accounts_get_account(account_name); + char* room = NULL; + char* nick = NULL; + char* passwd = NULL; + char* account_name = session_get_account_name(); + ProfAccount* account = accounts_get_account(account_name); // full room jid supplied (room@server) if (room_arg->localpart) { room = g_strdup(args[0]); - // server not supplied (room), use account preference + // server not supplied (room), use account preference } else if (account->muc_service) { - GString *room_str = g_string_new(""); + GString* room_str = g_string_new(""); g_string_append(room_str, args[0]); g_string_append(room_str, "@"); g_string_append(room_str, account->muc_service); room = room_str->str; g_string_free(room_str, FALSE); - // no account preference + // no account preference } else { cons_show("Account MUC service property not found."); return TRUE; } // Additional args supplied - gchar *opt_keys[] = { "nick", "password", NULL }; + gchar* opt_keys[] = { "nick", "password", NULL }; gboolean parsed; - GHashTable *options = parse_options(&args[1], opt_keys, &parsed); + GHashTable* options = parse_options(&args[1], opt_keys, &parsed); if (!parsed) { cons_bad_cmd_usage(command); cons_show(""); @@ -3645,7 +3637,7 @@ cmd_join(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_invite(ProfWin *window, const char *const command, gchar **args) +cmd_invite(ProfWin* window, const char* const command, gchar** args) { jabber_conn_status_t conn_status = connection_get_status(); @@ -3655,31 +3647,31 @@ cmd_invite(ProfWin *window, const char *const command, gchar **args) } if (g_strcmp0(args[0], "send") == 0) { - char *contact = args[1]; - char *reason = args[2]; + char* contact = args[1]; + char* reason = args[2]; if (window->type != WIN_MUC) { cons_show("You must be in a chat room to send an invite."); return TRUE; } - char *usr_jid = roster_barejid_from_name(contact); + char* usr_jid = roster_barejid_from_name(contact); if (usr_jid == NULL) { usr_jid = contact; } - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); message_send_invite(mucwin->roomjid, usr_jid, reason); if (reason) { cons_show("Room invite sent, contact: %s, room: %s, reason: \"%s\".", - contact, mucwin->roomjid, reason); + contact, mucwin->roomjid, reason); } else { cons_show("Room invite sent, contact: %s, room: %s.", - contact, mucwin->roomjid); + contact, mucwin->roomjid); } } else if (g_strcmp0(args[0], "list") == 0) { - GList *invites = muc_invites(); + GList* invites = muc_invites(); cons_show_room_invites(invites); g_list_free_full(invites, g_free); } else if (g_strcmp0(args[0], "decline") == 0) { @@ -3695,14 +3687,14 @@ cmd_invite(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_form_field(ProfWin *window, char *tag, gchar **args) +cmd_form_field(ProfWin* window, char* tag, gchar** args) { if (window->type != WIN_CONFIG) { return TRUE; } - ProfConfWin *confwin = (ProfConfWin*)window; - DataForm *form = confwin->form; + ProfConfWin* confwin = (ProfConfWin*)window; + DataForm* form = confwin->form; if (form) { if (!form_tag_exists(form, tag)) { win_println(window, THEME_DEFAULT, "-", "Form does not contain a field with tag %s", tag); @@ -3710,8 +3702,8 @@ cmd_form_field(ProfWin *window, char *tag, gchar **args) } form_field_type_t field_type = form_get_field_type(form, tag); - char *cmd = NULL; - char *value = NULL; + char* cmd = NULL; + char* value = NULL; gboolean valid = FALSE; gboolean added = FALSE; gboolean removed = FALSE; @@ -3913,7 +3905,7 @@ cmd_form_field(ProfWin *window, char *tag, gchar **args) } gboolean -cmd_form(ProfWin *window, const char *const command, gchar **args) +cmd_form(ProfWin* window, const char* const command, gchar** args) { jabber_conn_status_t conn_status = connection_get_status(); @@ -3927,15 +3919,12 @@ cmd_form(ProfWin *window, const char *const command, gchar **args) return TRUE; } - if ((g_strcmp0(args[0], "submit") != 0) && - (g_strcmp0(args[0], "cancel") != 0) && - (g_strcmp0(args[0], "show") != 0) && - (g_strcmp0(args[0], "help") != 0)) { + if ((g_strcmp0(args[0], "submit") != 0) && (g_strcmp0(args[0], "cancel") != 0) && (g_strcmp0(args[0], "show") != 0) && (g_strcmp0(args[0], "help") != 0)) { cons_bad_cmd_usage(command); return TRUE; } - ProfConfWin *confwin = (ProfConfWin*)window; + ProfConfWin* confwin = (ProfConfWin*)window; assert(confwin->memcheck == PROFCONFWIN_MEMCHECK); if (g_strcmp0(args[0], "show") == 0) { @@ -3944,20 +3933,20 @@ cmd_form(ProfWin *window, const char *const command, gchar **args) } if (g_strcmp0(args[0], "help") == 0) { - char *tag = args[1]; + char* tag = args[1]; if (tag) { confwin_field_help(confwin, tag); } else { confwin_form_help(confwin); - gchar **help_text = NULL; - Command *command = cmd_get("/form"); + gchar** help_text = NULL; + Command* command = cmd_get("/form"); if (command) { help_text = command->help.synopsis; } - ui_show_lines((ProfWin*) confwin, help_text); + ui_show_lines((ProfWin*)confwin, help_text); } win_println(window, THEME_DEFAULT, "-", ""); return TRUE; @@ -3978,7 +3967,7 @@ cmd_form(ProfWin *window, const char *const command, gchar **args) int num = wins_get_num(window); - ProfWin *new_current = (ProfWin*)wins_get_muc(confwin->roomjid); + ProfWin* new_current = (ProfWin*)wins_get_muc(confwin->roomjid); if (!new_current) { new_current = wins_get_console(); } @@ -3991,7 +3980,7 @@ cmd_form(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_kick(ProfWin *window, const char *const command, gchar **args) +cmd_kick(ProfWin* window, const char* const command, gchar** args) { jabber_conn_status_t conn_status = connection_get_status(); @@ -4005,13 +3994,13 @@ cmd_kick(ProfWin *window, const char *const command, gchar **args) return TRUE; } - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); - char *nick = args[0]; + char* nick = args[0]; if (nick) { if (muc_roster_contains_nick(mucwin->roomjid, nick)) { - char *reason = args[1]; + char* reason = args[1]; iq_room_kick_occupant(mucwin->roomjid, nick, reason); } else { win_println(window, THEME_DEFAULT, "!", "Occupant does not exist: %s", nick); @@ -4024,7 +4013,7 @@ cmd_kick(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_ban(ProfWin *window, const char *const command, gchar **args) +cmd_ban(ProfWin* window, const char* const command, gchar** args) { jabber_conn_status_t conn_status = connection_get_status(); @@ -4038,12 +4027,12 @@ cmd_ban(ProfWin *window, const char *const command, gchar **args) return TRUE; } - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); - char *jid = args[0]; + char* jid = args[0]; if (jid) { - char *reason = args[1]; + char* reason = args[1]; iq_room_affiliation_set(mucwin->roomjid, jid, "outcast", reason); } else { cons_bad_cmd_usage(command); @@ -4052,7 +4041,7 @@ cmd_ban(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_subject(ProfWin *window, const char *const command, gchar **args) +cmd_subject(ProfWin* window, const char* const command, gchar** args) { jabber_conn_status_t conn_status = connection_get_status(); @@ -4066,11 +4055,11 @@ cmd_subject(ProfWin *window, const char *const command, gchar **args) return TRUE; } - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); if (args[0] == NULL) { - char *subject = muc_subject(mucwin->roomjid); + char* subject = muc_subject(mucwin->roomjid); if (subject) { win_print(window, THEME_ROOMINFO, "!", "Room subject: "); win_appendln(window, THEME_DEFAULT, "%s", subject); @@ -4100,9 +4089,9 @@ cmd_subject(ProfWin *window, const char *const command, gchar **args) if (g_strcmp0(args[0], "prepend") == 0) { if (args[1]) { - char *old_subject = muc_subject(mucwin->roomjid); + char* old_subject = muc_subject(mucwin->roomjid); if (old_subject) { - GString *new_subject = g_string_new(args[1]); + GString* new_subject = g_string_new(args[1]); g_string_append(new_subject, old_subject); message_send_groupchat_subject(mucwin->roomjid, new_subject->str); g_string_free(new_subject, TRUE); @@ -4117,9 +4106,9 @@ cmd_subject(ProfWin *window, const char *const command, gchar **args) if (g_strcmp0(args[0], "append") == 0) { if (args[1]) { - char *old_subject = muc_subject(mucwin->roomjid); + char* old_subject = muc_subject(mucwin->roomjid); if (old_subject) { - GString *new_subject = g_string_new(old_subject); + GString* new_subject = g_string_new(old_subject); g_string_append(new_subject, args[1]); message_send_groupchat_subject(mucwin->roomjid, new_subject->str); g_string_free(new_subject, TRUE); @@ -4142,7 +4131,7 @@ cmd_subject(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_affiliation(ProfWin *window, const char *const command, gchar **args) +cmd_affiliation(ProfWin* window, const char* const command, gchar** args) { jabber_conn_status_t conn_status = connection_get_status(); @@ -4156,24 +4145,19 @@ cmd_affiliation(ProfWin *window, const char *const command, gchar **args) return TRUE; } - char *cmd = args[0]; + char* cmd = args[0]; if (cmd == NULL) { cons_bad_cmd_usage(command); return TRUE; } - char *affiliation = args[1]; - if (affiliation && - (g_strcmp0(affiliation, "owner") != 0) && - (g_strcmp0(affiliation, "admin") != 0) && - (g_strcmp0(affiliation, "member") != 0) && - (g_strcmp0(affiliation, "none") != 0) && - (g_strcmp0(affiliation, "outcast") != 0)) { + char* affiliation = args[1]; + if (affiliation && (g_strcmp0(affiliation, "owner") != 0) && (g_strcmp0(affiliation, "admin") != 0) && (g_strcmp0(affiliation, "member") != 0) && (g_strcmp0(affiliation, "none") != 0) && (g_strcmp0(affiliation, "outcast") != 0)) { cons_bad_cmd_usage(command); return TRUE; } - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); if (g_strcmp0(cmd, "list") == 0) { @@ -4196,12 +4180,12 @@ cmd_affiliation(ProfWin *window, const char *const command, gchar **args) return TRUE; } - char *jid = args[2]; + char* jid = args[2]; if (jid == NULL) { cons_bad_cmd_usage(command); return TRUE; } else { - char *reason = args[3]; + char* reason = args[3]; iq_room_affiliation_set(mucwin->roomjid, jid, affiliation, reason); return TRUE; } @@ -4212,7 +4196,7 @@ cmd_affiliation(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_role(ProfWin *window, const char *const command, gchar **args) +cmd_role(ProfWin* window, const char* const command, gchar** args) { jabber_conn_status_t conn_status = connection_get_status(); @@ -4226,23 +4210,19 @@ cmd_role(ProfWin *window, const char *const command, gchar **args) return TRUE; } - char *cmd = args[0]; + char* cmd = args[0]; if (cmd == NULL) { cons_bad_cmd_usage(command); return TRUE; } - char *role = args[1]; - if (role && - (g_strcmp0(role, "visitor") != 0) && - (g_strcmp0(role, "participant") != 0) && - (g_strcmp0(role, "moderator") != 0) && - (g_strcmp0(role, "none") != 0)) { + char* role = args[1]; + if (role && (g_strcmp0(role, "visitor") != 0) && (g_strcmp0(role, "participant") != 0) && (g_strcmp0(role, "moderator") != 0) && (g_strcmp0(role, "none") != 0)) { cons_bad_cmd_usage(command); return TRUE; } - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); if (g_strcmp0(cmd, "list") == 0) { @@ -4264,12 +4244,12 @@ cmd_role(ProfWin *window, const char *const command, gchar **args) return TRUE; } - char *nick = args[2]; + char* nick = args[2]; if (nick == NULL) { cons_bad_cmd_usage(command); return TRUE; } else { - char *reason = args[3]; + char* reason = args[3]; iq_room_role_set(mucwin->roomjid, nick, role, reason); return TRUE; } @@ -4280,7 +4260,7 @@ cmd_role(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_room(ProfWin *window, const char *const command, gchar **args) +cmd_room(ProfWin* window, const char* const command, gchar** args) { jabber_conn_status_t conn_status = connection_get_status(); @@ -4294,7 +4274,7 @@ cmd_room(ProfWin *window, const char *const command, gchar **args) return TRUE; } - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); if (g_strcmp0(args[0], "accept") == 0) { @@ -4312,7 +4292,7 @@ cmd_room(ProfWin *window, const char *const command, gchar **args) iq_destroy_room(mucwin->roomjid); return TRUE; } else if (g_strcmp0(args[0], "config") == 0) { - ProfConfWin *confwin = wins_get_conf(mucwin->roomjid); + ProfConfWin* confwin = wins_get_conf(mucwin->roomjid); if (confwin) { ui_focus_win((ProfWin*)confwin); @@ -4328,7 +4308,7 @@ cmd_room(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_occupants(ProfWin *window, const char *const command, gchar **args) +cmd_occupants(ProfWin* window, const char* const command, gchar** args) { if (g_strcmp0(args[0], "size") == 0) { if (!args[1]) { @@ -4336,7 +4316,7 @@ cmd_occupants(ProfWin *window, const char *const command, gchar **args) return TRUE; } else { int intval = 0; - char *err_msg = NULL; + char* err_msg = NULL; gboolean res = strtoi_range(args[1], &intval, 1, 99, &err_msg); if (res) { prefs_set_occupants_size(intval); @@ -4357,7 +4337,7 @@ cmd_occupants(ProfWin *window, const char *const command, gchar **args) return TRUE; } else { int intval = 0; - char *err_msg = NULL; + char* err_msg = NULL; gboolean res = strtoi_range(args[1], &intval, 0, 10, &err_msg); if (res) { prefs_set_occupants_indent(intval); @@ -4378,7 +4358,7 @@ cmd_occupants(ProfWin *window, const char *const command, gchar **args) return TRUE; } else { _cmd_set_boolean_preference(args[1], command, "Occupants panel line wrap", PREF_OCCUPANTS_WRAP); - occupantswin_occupants_all(); + occupantswin_occupants_all(); return TRUE; } } @@ -4464,7 +4444,7 @@ cmd_occupants(ProfWin *window, const char *const command, gchar **args) return TRUE; } - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); if (g_strcmp0(args[0], "show") == 0) { @@ -4489,7 +4469,7 @@ cmd_occupants(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_rooms(ProfWin *window, const char *const command, gchar **args) +cmd_rooms(ProfWin* window, const char* const command, gchar** args) { jabber_conn_status_t conn_status = connection_get_status(); @@ -4498,8 +4478,8 @@ cmd_rooms(ProfWin *window, const char *const command, gchar **args) return TRUE; } - gchar *service = NULL; - gchar *filter = NULL; + gchar* service = NULL; + gchar* filter = NULL; if (args[0] != NULL) { if (g_strcmp0(args[0], "service") == 0) { if (args[1] == NULL) { @@ -4543,7 +4523,7 @@ cmd_rooms(ProfWin *window, const char *const command, gchar **args) return TRUE; } } - if (g_strv_length(args) >=3 ) { + if (g_strv_length(args) >= 3) { if (g_strcmp0(args[2], "service") == 0) { if (args[3] == NULL) { cons_bad_cmd_usage(command); @@ -4574,7 +4554,7 @@ cmd_rooms(ProfWin *window, const char *const command, gchar **args) } if (service == NULL) { - ProfAccount *account = accounts_get_account(session_get_account_name()); + ProfAccount* account = accounts_get_account(session_get_account_name()); if (account->muc_service) { service = g_strdup(account->muc_service); account_free(account); @@ -4602,7 +4582,7 @@ cmd_rooms(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_bookmark(ProfWin *window, const char *const command, gchar **args) +cmd_bookmark(ProfWin* window, const char* const command, gchar** args) { jabber_conn_status_t conn_status = connection_get_status(); @@ -4613,15 +4593,15 @@ cmd_bookmark(ProfWin *window, const char *const command, gchar **args) } int num_args = g_strv_length(args); - gchar *cmd = args[0]; + gchar* cmd = args[0]; if (window->type == WIN_MUC - && num_args < 2 - && (cmd == NULL || g_strcmp0(cmd, "add") == 0)) { + && num_args < 2 + && (cmd == NULL || g_strcmp0(cmd, "add") == 0)) { // default to current nickname, password, and autojoin "on" - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); - char *nick = muc_nick(mucwin->roomjid); - char *password = muc_password(mucwin->roomjid); + char* nick = muc_nick(mucwin->roomjid); + char* password = muc_password(mucwin->roomjid); gboolean added = bookmark_add(mucwin->roomjid, nick, password, "on", NULL); if (added) { win_println(window, THEME_DEFAULT, "!", "Bookmark added for %s.", mucwin->roomjid); @@ -4632,9 +4612,9 @@ cmd_bookmark(ProfWin *window, const char *const command, gchar **args) } if (window->type == WIN_MUC - && num_args < 2 - && g_strcmp0(cmd, "remove") == 0) { - ProfMucWin *mucwin = (ProfMucWin*)window; + && num_args < 2 + && g_strcmp0(cmd, "remove") == 0) { + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); gboolean removed = bookmark_remove(mucwin->roomjid); if (removed) { @@ -4667,13 +4647,13 @@ cmd_bookmark(ProfWin *window, const char *const command, gchar **args) } if (strcmp(cmd, "list") == 0) { - GList *bookmarks = bookmark_get_list(); + GList* bookmarks = bookmark_get_list(); cons_show_bookmarks(bookmarks); g_list_free(bookmarks); return TRUE; } - char *jid = args[1]; + char* jid = args[1]; if (jid == NULL) { cons_bad_cmd_usage(command); cons_show(""); @@ -4707,10 +4687,10 @@ cmd_bookmark(ProfWin *window, const char *const command, gchar **args) return TRUE; } - gchar *opt_keys[] = { "autojoin", "nick", "password", "name", NULL }; + gchar* opt_keys[] = { "autojoin", "nick", "password", "name", NULL }; gboolean parsed; - GHashTable *options = parse_options(&args[2], opt_keys, &parsed); + GHashTable* options = parse_options(&args[2], opt_keys, &parsed); if (!parsed) { cons_bad_cmd_usage(command); cons_show(""); @@ -4718,7 +4698,7 @@ cmd_bookmark(ProfWin *window, const char *const command, gchar **args) return TRUE; } - char *autojoin = g_hash_table_lookup(options, "autojoin"); + char* autojoin = g_hash_table_lookup(options, "autojoin"); if (autojoin && ((strcmp(autojoin, "on") != 0) && (strcmp(autojoin, "off") != 0))) { cons_bad_cmd_usage(command); @@ -4728,9 +4708,9 @@ cmd_bookmark(ProfWin *window, const char *const command, gchar **args) return TRUE; } - char *nick = g_hash_table_lookup(options, "nick"); - char *password = g_hash_table_lookup(options, "password"); - char *name = g_hash_table_lookup(options, "name"); + char* nick = g_hash_table_lookup(options, "nick"); + char* password = g_hash_table_lookup(options, "password"); + char* name = g_hash_table_lookup(options, "name"); if (strcmp(cmd, "add") == 0) { gboolean added = bookmark_add(jid, nick, password, autojoin, name); @@ -4764,7 +4744,7 @@ cmd_bookmark(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_bookmark_ignore(ProfWin *window, const char *const command, gchar **args) +cmd_bookmark_ignore(ProfWin* window, const char* const command, gchar** args) { jabber_conn_status_t conn_status = connection_get_status(); @@ -4777,7 +4757,7 @@ cmd_bookmark_ignore(ProfWin *window, const char *const command, gchar **args) // `/bookmark ignore` lists them if (args[1] == NULL) { gsize len = 0; - gchar **list = bookmark_ignore_list(&len); + gchar** list = bookmark_ignore_list(&len); cons_show_bookmarks_ignore(list, len); g_strfreev(list); return TRUE; @@ -4800,7 +4780,7 @@ cmd_bookmark_ignore(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_disco(ProfWin *window, const char *const command, gchar **args) +cmd_disco(ProfWin* window, const char* const command, gchar** args) { jabber_conn_status_t conn_status = connection_get_status(); @@ -4809,11 +4789,11 @@ cmd_disco(ProfWin *window, const char *const command, gchar **args) return TRUE; } - GString *jid = g_string_new(""); + GString* jid = g_string_new(""); if (args[1]) { jid = g_string_append(jid, args[1]); } else { - Jid *jidp = jid_create(connection_get_fulljid()); + Jid* jidp = jid_create(connection_get_fulljid()); jid = g_string_append(jid, jidp->domainpart); jid_destroy(jidp); } @@ -4830,14 +4810,14 @@ cmd_disco(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_sendfile(ProfWin *window, const char *const command, gchar **args) +cmd_sendfile(ProfWin* window, const char* const command, gchar** args) { jabber_conn_status_t conn_status = connection_get_status(); - char *filename = args[0]; + char* filename = args[0]; // expand ~ to $HOME if (filename[0] == '~' && filename[1] == '/') { - if (asprintf(&filename, "%s/%s", getenv("HOME"), filename+2) == -1) { + if (asprintf(&filename, "%s/%s", getenv("HOME"), filename + 2) == -1) { return TRUE; } } else { @@ -4857,45 +4837,45 @@ cmd_sendfile(ProfWin *window, const char *const command, gchar **args) } switch (window->type) { - case WIN_MUC: - { - ProfMucWin *mucwin = (ProfMucWin*)window; - assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); + case WIN_MUC: + { + ProfMucWin* mucwin = (ProfMucWin*)window; + assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); - // only omemo, no pgp/otr available in MUCs - if (mucwin->is_omemo && !prefs_get_boolean(PREF_OMEMO_SENDFILE)) { - cons_show_error("Uploading unencrypted files disabled. See /omemo sendfile, /otr sendfile, /pgp sendfile."); - win_println(window, THEME_ERROR, "-", "Sending encrypted files via http_upload is not possible yet."); - free(filename); - return TRUE; - } - break; + // only omemo, no pgp/otr available in MUCs + if (mucwin->is_omemo && !prefs_get_boolean(PREF_OMEMO_SENDFILE)) { + cons_show_error("Uploading unencrypted files disabled. See /omemo sendfile, /otr sendfile, /pgp sendfile."); + win_println(window, THEME_ERROR, "-", "Sending encrypted files via http_upload is not possible yet."); + free(filename); + return TRUE; } - case WIN_CHAT: - { - ProfChatWin *chatwin = (ProfChatWin*)window; - assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); + break; + } + case WIN_CHAT: + { + ProfChatWin* chatwin = (ProfChatWin*)window; + assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); - if ((chatwin->is_omemo && !prefs_get_boolean(PREF_OMEMO_SENDFILE)) - || (chatwin->pgp_send && !prefs_get_boolean(PREF_PGP_SENDFILE)) - || (chatwin->is_otr && !prefs_get_boolean(PREF_OTR_SENDFILE))) { - cons_show_error("Uploading unencrypted files disabled. See /omemo sendfile, /otr sendfile, /pgp sendfile."); - win_println(window, THEME_ERROR, "-", "Sending encrypted files via http_upload is not possible yet."); - free(filename); - return TRUE; - } - break; - } - case WIN_PRIVATE: - { - //we don't support encryption in private muc windows - break; - } - default: - cons_show_error("Unsupported window for file transmission."); - free(filename); - return TRUE; + if ((chatwin->is_omemo && !prefs_get_boolean(PREF_OMEMO_SENDFILE)) + || (chatwin->pgp_send && !prefs_get_boolean(PREF_PGP_SENDFILE)) + || (chatwin->is_otr && !prefs_get_boolean(PREF_OTR_SENDFILE))) { + cons_show_error("Uploading unencrypted files disabled. See /omemo sendfile, /otr sendfile, /pgp sendfile."); + win_println(window, THEME_ERROR, "-", "Sending encrypted files via http_upload is not possible yet."); + free(filename); + return TRUE; } + break; + } + case WIN_PRIVATE: + { + //we don't support encryption in private muc windows + break; + } + default: + cons_show_error("Unsupported window for file transmission."); + free(filename); + return TRUE; + } if (access(filename, R_OK) != 0) { cons_show_error("Uploading '%s' failed: File not found!", filename); @@ -4909,7 +4889,7 @@ cmd_sendfile(ProfWin *window, const char *const command, gchar **args) return TRUE; } - HTTPUpload *upload = malloc(sizeof(HTTPUpload)); + HTTPUpload* upload = malloc(sizeof(HTTPUpload)); upload->window = window; upload->filename = filename; @@ -4922,7 +4902,7 @@ cmd_sendfile(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_lastactivity(ProfWin *window, const char *const command, gchar **args) +cmd_lastactivity(ProfWin* window, const char* const command, gchar** args) { if ((g_strcmp0(args[0], "on") == 0) || (g_strcmp0(args[0], "off") == 0)) { _cmd_set_boolean_preference(args[0], command, "Last activity", PREF_LASTACTIVITY); @@ -4943,8 +4923,8 @@ cmd_lastactivity(ProfWin *window, const char *const command, gchar **args) } if (args[0] == NULL) { - Jid *jidp = jid_create(connection_get_fulljid()); - GString *jid = g_string_new(jidp->domainpart); + Jid* jidp = jid_create(connection_get_fulljid()); + GString* jid = g_string_new(jidp->domainpart); iq_last_activity_request(jid->str); @@ -4959,7 +4939,7 @@ cmd_lastactivity(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_nick(ProfWin *window, const char *const command, gchar **args) +cmd_nick(ProfWin* window, const char* const command, gchar** args) { jabber_conn_status_t conn_status = connection_get_status(); @@ -4972,27 +4952,27 @@ cmd_nick(ProfWin *window, const char *const command, gchar **args) return TRUE; } - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); - char *nick = args[0]; + char* nick = args[0]; presence_change_room_nick(mucwin->roomjid, nick); return TRUE; } gboolean -cmd_alias(ProfWin *window, const char *const command, gchar **args) +cmd_alias(ProfWin* window, const char* const command, gchar** args) { - char *subcmd = args[0]; + char* subcmd = args[0]; if (strcmp(subcmd, "add") == 0) { - char *alias = args[1]; + char* alias = args[1]; if (alias == NULL) { cons_bad_cmd_usage(command); return TRUE; } else { - char *alias_p = alias; - GString *ac_value = g_string_new(""); + char* alias_p = alias; + GString* ac_value = g_string_new(""); if (alias[0] == '/') { g_string_append(ac_value, alias); alias_p = &alias[1]; @@ -5001,7 +4981,7 @@ cmd_alias(ProfWin *window, const char *const command, gchar **args) g_string_append(ac_value, alias); } - char *value = args[2]; + char* value = args[2]; if (value == NULL) { cons_bad_cmd_usage(command); g_string_free(ac_value, TRUE); @@ -5020,7 +5000,7 @@ cmd_alias(ProfWin *window, const char *const command, gchar **args) } } } else if (strcmp(subcmd, "remove") == 0) { - char *alias = args[1]; + char* alias = args[1]; if (alias == NULL) { cons_bad_cmd_usage(command); return TRUE; @@ -5032,7 +5012,7 @@ cmd_alias(ProfWin *window, const char *const command, gchar **args) if (!removed) { cons_show("No such command alias /%s", alias); } else { - GString *ac_value = g_string_new("/"); + GString* ac_value = g_string_new("/"); g_string_append(ac_value, alias); cmd_ac_remove(ac_value->str); cmd_ac_remove_alias_value(alias); @@ -5042,7 +5022,7 @@ cmd_alias(ProfWin *window, const char *const command, gchar **args) return TRUE; } } else if (strcmp(subcmd, "list") == 0) { - GList *aliases = prefs_get_aliases(); + GList* aliases = prefs_get_aliases(); cons_show_aliases(aliases); prefs_free_aliases(aliases); return TRUE; @@ -5053,9 +5033,9 @@ cmd_alias(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_tiny(ProfWin *window, const char *const command, gchar **args) +cmd_tiny(ProfWin* window, const char* const command, gchar** args) { - char *url = args[0]; + char* url = args[0]; if (window->type != WIN_CHAT && window->type != WIN_MUC && window->type != WIN_PRIVATE) { cons_show("/tiny can only be used in chat windows"); @@ -5067,30 +5047,30 @@ cmd_tiny(ProfWin *window, const char *const command, gchar **args) return TRUE; } - char *tiny = tinyurl_get(url); + char* tiny = tinyurl_get(url); if (!tiny) { win_println(window, THEME_ERROR, "-", "Couldn't create tinyurl."); return TRUE; } - switch (window->type){ + switch (window->type) { case WIN_CHAT: { - ProfChatWin *chatwin = (ProfChatWin*)window; + ProfChatWin* chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); cl_ev_send_msg(chatwin, tiny, NULL); break; } case WIN_PRIVATE: { - ProfPrivateWin *privatewin = (ProfPrivateWin*)window; + ProfPrivateWin* privatewin = (ProfPrivateWin*)window; assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK); cl_ev_send_priv_msg(privatewin, tiny, NULL); break; } case WIN_MUC: { - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); cl_ev_send_muc_msg(mucwin, tiny, NULL); break; @@ -5105,13 +5085,13 @@ cmd_tiny(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_clear(ProfWin *window, const char *const command, gchar **args) +cmd_clear(ProfWin* window, const char* const command, gchar** args) { if (args[0] == NULL) { win_clear(window); return TRUE; } else { - if ((g_strcmp0(args[0], "persist_history") == 0) ) { + if ((g_strcmp0(args[0], "persist_history") == 0)) { if (args[1] != NULL) { if ((g_strcmp0(args[1], "on") == 0) || (g_strcmp0(args[1], "off") == 0)) { @@ -5134,7 +5114,7 @@ cmd_clear(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_privileges(ProfWin *window, const char *const command, gchar **args) +cmd_privileges(ProfWin* window, const char* const command, gchar** args) { _cmd_set_boolean_preference(args[0], command, "MUC privileges", PREF_MUC_PRIVILEGES); @@ -5144,10 +5124,10 @@ cmd_privileges(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_charset(ProfWin *window, const char *const command, gchar **args) +cmd_charset(ProfWin* window, const char* const command, gchar** args) { - char *codeset = nl_langinfo(CODESET); - char *lang = getenv("LANG"); + char* codeset = nl_langinfo(CODESET); + char* lang = getenv("LANG"); cons_show("Charset information:"); @@ -5157,28 +5137,28 @@ cmd_charset(ProfWin *window, const char *const command, gchar **args) if (codeset) { cons_show(" CODESET: %s", codeset); } - cons_show(" MB_CUR_MAX: %d", MB_CUR_MAX); - cons_show(" MB_LEN_MAX: %d", MB_LEN_MAX); + cons_show(" MB_CUR_MAX: %d", MB_CUR_MAX); + cons_show(" MB_LEN_MAX: %d", MB_LEN_MAX); return TRUE; } gboolean -cmd_beep(ProfWin *window, const char *const command, gchar **args) +cmd_beep(ProfWin* window, const char* const command, gchar** args) { _cmd_set_boolean_preference(args[0], command, "Sound", PREF_BEEP); return TRUE; } gboolean -cmd_console(ProfWin *window, const char *const command, gchar **args) +cmd_console(ProfWin* window, const char* const command, gchar** args) { if ((g_strcmp0(args[0], "chat") != 0) && (g_strcmp0(args[0], "muc") != 0) && (g_strcmp0(args[0], "private") != 0)) { cons_bad_cmd_usage(command); return TRUE; } - char *setting = args[1]; + char* setting = args[1]; if ((g_strcmp0(setting, "all") != 0) && (g_strcmp0(setting, "first") != 0) && (g_strcmp0(setting, "none") != 0)) { cons_bad_cmd_usage(command); return TRUE; @@ -5206,12 +5186,9 @@ cmd_console(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_presence(ProfWin *window, const char *const command, gchar **args) +cmd_presence(ProfWin* window, const char* const command, gchar** args) { - if (strcmp(args[0], "console") != 0 && - strcmp(args[0], "chat") != 0 && - strcmp(args[0], "room") != 0 && - strcmp(args[0], "titlebar") != 0) { + if (strcmp(args[0], "console") != 0 && strcmp(args[0], "chat") != 0 && strcmp(args[0], "room") != 0 && strcmp(args[0], "titlebar") != 0) { cons_bad_cmd_usage(command); return TRUE; } @@ -5221,9 +5198,7 @@ cmd_presence(ProfWin *window, const char *const command, gchar **args) return TRUE; } - if (strcmp(args[1], "all") != 0 && - strcmp(args[1], "online") != 0 && - strcmp(args[1], "none") != 0) { + if (strcmp(args[1], "all") != 0 && strcmp(args[1], "online") != 0 && strcmp(args[1], "none") != 0) { cons_bad_cmd_usage(command); return TRUE; } @@ -5265,7 +5240,7 @@ cmd_presence(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_wrap(ProfWin *window, const char *const command, gchar **args) +cmd_wrap(ProfWin* window, const char* const command, gchar** args) { _cmd_set_boolean_preference(args[0], command, "Word wrap", PREF_WRAP); @@ -5275,11 +5250,11 @@ cmd_wrap(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_time(ProfWin *window, const char *const command, gchar **args) +cmd_time(ProfWin* window, const char* const command, gchar** args) { if (g_strcmp0(args[0], "lastactivity") == 0) { if (args[1] == NULL) { - char *format = prefs_get_string(PREF_TIME_LASTACTIVITY); + char* format = prefs_get_string(PREF_TIME_LASTACTIVITY); cons_show("Last activity time format: '%s'.", format); g_free(format); return TRUE; @@ -5298,7 +5273,7 @@ cmd_time(ProfWin *window, const char *const command, gchar **args) } } else if (g_strcmp0(args[0], "statusbar") == 0) { if (args[1] == NULL) { - char *format = prefs_get_string(PREF_TIME_STATUSBAR); + char* format = prefs_get_string(PREF_TIME_STATUSBAR); cons_show("Status bar time format: '%s'.", format); g_free(format); return TRUE; @@ -5318,7 +5293,7 @@ cmd_time(ProfWin *window, const char *const command, gchar **args) } } else if (g_strcmp0(args[0], "console") == 0) { if (args[1] == NULL) { - char *format = prefs_get_string(PREF_TIME_CONSOLE); + char* format = prefs_get_string(PREF_TIME_CONSOLE); cons_show("Console time format: '%s'.", format); g_free(format); return TRUE; @@ -5338,7 +5313,7 @@ cmd_time(ProfWin *window, const char *const command, gchar **args) } } else if (g_strcmp0(args[0], "chat") == 0) { if (args[1] == NULL) { - char *format = prefs_get_string(PREF_TIME_CHAT); + char* format = prefs_get_string(PREF_TIME_CHAT); cons_show("Chat time format: '%s'.", format); g_free(format); return TRUE; @@ -5358,7 +5333,7 @@ cmd_time(ProfWin *window, const char *const command, gchar **args) } } else if (g_strcmp0(args[0], "muc") == 0) { if (args[1] == NULL) { - char *format = prefs_get_string(PREF_TIME_MUC); + char* format = prefs_get_string(PREF_TIME_MUC); cons_show("MUC time format: '%s'.", format); g_free(format); return TRUE; @@ -5378,7 +5353,7 @@ cmd_time(ProfWin *window, const char *const command, gchar **args) } } else if (g_strcmp0(args[0], "config") == 0) { if (args[1] == NULL) { - char *format = prefs_get_string(PREF_TIME_CONFIG); + char* format = prefs_get_string(PREF_TIME_CONFIG); cons_show("config time format: '%s'.", format); g_free(format); return TRUE; @@ -5398,7 +5373,7 @@ cmd_time(ProfWin *window, const char *const command, gchar **args) } } else if (g_strcmp0(args[0], "private") == 0) { if (args[1] == NULL) { - char *format = prefs_get_string(PREF_TIME_PRIVATE); + char* format = prefs_get_string(PREF_TIME_PRIVATE); cons_show("Private chat time format: '%s'.", format); g_free(format); return TRUE; @@ -5418,7 +5393,7 @@ cmd_time(ProfWin *window, const char *const command, gchar **args) } } else if (g_strcmp0(args[0], "xml") == 0) { if (args[1] == NULL) { - char *format = prefs_get_string(PREF_TIME_XMLCONSOLE); + char* format = prefs_get_string(PREF_TIME_XMLCONSOLE); cons_show("XML Console time format: '%s'.", format); g_free(format); return TRUE; @@ -5481,7 +5456,7 @@ cmd_time(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_states(ProfWin *window, const char *const command, gchar **args) +cmd_states(ProfWin* window, const char* const command, gchar** args) { if (args[0] == NULL) { return FALSE; @@ -5499,7 +5474,7 @@ cmd_states(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_wintitle(ProfWin *window, const char *const command, gchar **args) +cmd_wintitle(ProfWin* window, const char* const command, gchar** args) { if (g_strcmp0(args[0], "show") != 0 && g_strcmp0(args[0], "goodbye") != 0) { cons_bad_cmd_usage(command); @@ -5518,7 +5493,7 @@ cmd_wintitle(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_outtype(ProfWin *window, const char *const command, gchar **args) +cmd_outtype(ProfWin* window, const char* const command, gchar** args) { if (args[0] == NULL) { return FALSE; @@ -5535,9 +5510,9 @@ cmd_outtype(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_gone(ProfWin *window, const char *const command, gchar **args) +cmd_gone(ProfWin* window, const char* const command, gchar** args) { - char *value = args[0]; + char* value = args[0]; gint period = atoi(value); prefs_set_gone(period); @@ -5557,15 +5532,14 @@ cmd_gone(ProfWin *window, const char *const command, gchar **args) return TRUE; } - gboolean -cmd_notify(ProfWin *window, const char *const command, gchar **args) +cmd_notify(ProfWin* window, const char* const command, gchar** args) { if (!args[0]) { - ProfWin *current = wins_get_current(); + ProfWin* current = wins_get_current(); if (current->type == WIN_MUC) { win_println(current, THEME_DEFAULT, "-", ""); - ProfMucWin *mucwin = (ProfMucWin *)current; + ProfMucWin* mucwin = (ProfMucWin*)current; win_println(window, THEME_DEFAULT, "!", "Notification settings for %s:", mucwin->roomjid); if (prefs_has_room_notify(mucwin->roomjid)) { @@ -5612,7 +5586,6 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) cons_show(""); cons_notify_setting(); cons_bad_cmd_usage(command); - } return TRUE; } @@ -5647,7 +5620,7 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) } } - // chat room settings + // chat room settings } else if (g_strcmp0(args[0], "room") == 0) { if (g_strcmp0(args[1], "on") == 0) { cons_show("Room notifications enabled."); @@ -5721,8 +5694,8 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) } } } else if (g_strcmp0(args[2], "list") == 0) { - GList *triggers = prefs_get_room_notify_triggers(); - GList *curr = triggers; + GList* triggers = prefs_get_room_notify_triggers(); + GList* curr = triggers; if (curr) { cons_show("Room notification triggers:"); } else { @@ -5746,7 +5719,7 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) cons_show("Usage: /notify room on|off|mention"); } - // typing settings + // typing settings } else if (g_strcmp0(args[0], "typing") == 0) { if (g_strcmp0(args[1], "on") == 0) { cons_show("Typing notifications enabled."); @@ -5768,7 +5741,7 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) cons_show("Usage: /notify typing on|off"); } - // invite settings + // invite settings } else if (g_strcmp0(args[0], "invite") == 0) { if (g_strcmp0(args[1], "on") == 0) { cons_show("Chat room invite notifications enabled."); @@ -5780,7 +5753,7 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) cons_show("Usage: /notify invite on|off"); } - // subscription settings + // subscription settings } else if (g_strcmp0(args[0], "sub") == 0) { if (g_strcmp0(args[1], "on") == 0) { cons_show("Subscription notifications enabled."); @@ -5792,7 +5765,7 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) cons_show("Usage: /notify sub on|off"); } - // remind settings + // remind settings } else if (g_strcmp0(args[0], "remind") == 0) { if (!args[1]) { cons_bad_cmd_usage(command); @@ -5808,18 +5781,18 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) } } - // current chat room settings + // current chat room settings } else if (g_strcmp0(args[0], "on") == 0) { jabber_conn_status_t conn_status = connection_get_status(); if (conn_status != JABBER_CONNECTED) { cons_show("You are not currently connected."); } else { - ProfWin *window = wins_get_current(); + ProfWin* window = wins_get_current(); if (window->type != WIN_MUC) { cons_show("You must be in a chat room."); } else { - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; prefs_set_room_notify(mucwin->roomjid, TRUE); win_println(window, THEME_DEFAULT, "!", "Notifications enabled for %s", mucwin->roomjid); } @@ -5830,11 +5803,11 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) if (conn_status != JABBER_CONNECTED) { cons_show("You are not currently connected."); } else { - ProfWin *window = wins_get_current(); + ProfWin* window = wins_get_current(); if (window->type != WIN_MUC) { cons_show("You must be in a chat room."); } else { - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; prefs_set_room_notify(mucwin->roomjid, FALSE); win_println(window, THEME_DEFAULT, "!", "Notifications disabled for %s", mucwin->roomjid); } @@ -5846,20 +5819,20 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) cons_show("You are not currently connected."); } else { if (g_strcmp0(args[1], "on") == 0) { - ProfWin *window = wins_get_current(); + ProfWin* window = wins_get_current(); if (window->type != WIN_MUC) { cons_show("You must be in a chat room."); } else { - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; prefs_set_room_notify_mention(mucwin->roomjid, TRUE); win_println(window, THEME_DEFAULT, "!", "Mention notifications enabled for %s", mucwin->roomjid); } } else if (g_strcmp0(args[1], "off") == 0) { - ProfWin *window = wins_get_current(); + ProfWin* window = wins_get_current(); if (window->type != WIN_MUC) { cons_show("You must be in a chat rooms."); } else { - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; prefs_set_room_notify_mention(mucwin->roomjid, FALSE); win_println(window, THEME_DEFAULT, "!", "Mention notifications disabled for %s", mucwin->roomjid); } @@ -5874,20 +5847,20 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) cons_show("You are not currently connected."); } else { if (g_strcmp0(args[1], "on") == 0) { - ProfWin *window = wins_get_current(); + ProfWin* window = wins_get_current(); if (window->type != WIN_MUC) { cons_show("You must be in a chat room."); } else { - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; prefs_set_room_notify_trigger(mucwin->roomjid, TRUE); win_println(window, THEME_DEFAULT, "!", "Custom trigger notifications enabled for %s", mucwin->roomjid); } } else if (g_strcmp0(args[1], "off") == 0) { - ProfWin *window = wins_get_current(); + ProfWin* window = wins_get_current(); if (window->type != WIN_MUC) { cons_show("You must be in a chat rooms."); } else { - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; prefs_set_room_notify_trigger(mucwin->roomjid, FALSE); win_println(window, THEME_DEFAULT, "!", "Custom trigger notifications disabled for %s", mucwin->roomjid); } @@ -5901,11 +5874,11 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) if (conn_status != JABBER_CONNECTED) { cons_show("You are not currently connected."); } else { - ProfWin *window = wins_get_current(); + ProfWin* window = wins_get_current(); if (window->type != WIN_MUC) { cons_show("You must be in a chat room."); } else { - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; gboolean res = prefs_reset_room_notify(mucwin->roomjid); if (res) { win_println(window, THEME_DEFAULT, "!", "Notification settings set to global defaults for %s", mucwin->roomjid); @@ -5922,10 +5895,10 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_inpblock(ProfWin *window, const char *const command, gchar **args) +cmd_inpblock(ProfWin* window, const char* const command, gchar** args) { - char *subcmd = args[0]; - char *value = args[1]; + char* subcmd = args[0]; + char* value = args[1]; if (g_strcmp0(subcmd, "timeout") == 0) { if (value == NULL) { @@ -5934,7 +5907,7 @@ cmd_inpblock(ProfWin *window, const char *const command, gchar **args) } int intval = 0; - char *err_msg = NULL; + char* err_msg = NULL; gboolean res = strtoi_range(value, &intval, 1, 1000, &err_msg); if (res) { cons_show("Input blocking set to %d milliseconds.", intval); @@ -5969,7 +5942,7 @@ cmd_inpblock(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_titlebar(ProfWin *window, const char *const command, gchar **args) +cmd_titlebar(ProfWin* window, const char* const command, gchar** args) { if (g_strcmp0(args[0], "up") == 0) { gboolean result = prefs_titlebar_pos_up(); @@ -6000,7 +5973,7 @@ cmd_titlebar(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_titlebar_show_hide(ProfWin *window, const char *const command, gchar **args) +cmd_titlebar_show_hide(ProfWin* window, const char* const command, gchar** args) { if (args[1] != NULL) { if (g_strcmp0(args[0], "show") == 0) { @@ -6013,10 +5986,10 @@ cmd_titlebar_show_hide(ProfWin *window, const char *const command, gchar **args) prefs_set_boolean(PREF_ENC_WARN, TRUE); } else if (g_strcmp0(args[1], "resource") == 0) { cons_show("Showing resource in titlebar enabled."); - prefs_set_boolean(PREF_RESOURCE_TITLE , TRUE); + prefs_set_boolean(PREF_RESOURCE_TITLE, TRUE); } else if (g_strcmp0(args[1], "presence") == 0) { cons_show("Showing contact presence in titlebar enabled."); - prefs_set_boolean(PREF_PRESENCE , TRUE); + prefs_set_boolean(PREF_PRESENCE, TRUE); } else if (g_strcmp0(args[1], "jid") == 0) { cons_show("Showing MUC JID in titlebar as title enabled."); prefs_set_boolean(PREF_TITLEBAR_MUC_TITLE_JID, TRUE); @@ -6036,10 +6009,10 @@ cmd_titlebar_show_hide(ProfWin *window, const char *const command, gchar **args) prefs_set_boolean(PREF_ENC_WARN, FALSE); } else if (g_strcmp0(args[1], "resource") == 0) { cons_show("Showing resource in titlebar disabled."); - prefs_set_boolean(PREF_RESOURCE_TITLE , FALSE); + prefs_set_boolean(PREF_RESOURCE_TITLE, FALSE); } else if (g_strcmp0(args[1], "presence") == 0) { cons_show("Showing contact presence in titlebar disabled."); - prefs_set_boolean(PREF_PRESENCE , FALSE); + prefs_set_boolean(PREF_PRESENCE, FALSE); } else if (g_strcmp0(args[1], "jid") == 0) { cons_show("Showing MUC JID in titlebar as title disabled."); prefs_set_boolean(PREF_TITLEBAR_MUC_TITLE_JID, FALSE); @@ -6058,7 +6031,7 @@ cmd_titlebar_show_hide(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_mainwin(ProfWin *window, const char *const command, gchar **args) +cmd_mainwin(ProfWin* window, const char* const command, gchar** args) { if (g_strcmp0(args[0], "up") == 0) { gboolean result = prefs_mainwin_pos_up(); @@ -6089,7 +6062,7 @@ cmd_mainwin(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_statusbar(ProfWin *window, const char *const command, gchar **args) +cmd_statusbar(ProfWin* window, const char* const command, gchar** args) { if (g_strcmp0(args[0], "show") == 0) { if (g_strcmp0(args[1], "name") == 0) { @@ -6153,9 +6126,9 @@ cmd_statusbar(ProfWin *window, const char *const command, gchar **args) return TRUE; } - char *value = args[1]; + char* value = args[1]; int intval = 0; - char *err_msg = NULL; + char* err_msg = NULL; gboolean res = strtoi_range(value, &intval, 0, INT_MAX, &err_msg); if (res) { if (intval < 0 || intval > 10) { @@ -6185,9 +6158,9 @@ cmd_statusbar(ProfWin *window, const char *const command, gchar **args) return TRUE; } - char *value = args[1]; + char* value = args[1]; int intval = 0; - char *err_msg = NULL; + char* err_msg = NULL; gboolean res = strtoi_range(value, &intval, 0, INT_MAX, &err_msg); if (res) { if (intval < 0) { @@ -6303,7 +6276,7 @@ cmd_statusbar(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_inputwin(ProfWin *window, const char *const command, gchar **args) +cmd_inputwin(ProfWin* window, const char* const command, gchar** args) { if (g_strcmp0(args[0], "up") == 0) { gboolean result = prefs_inputwin_pos_up(); @@ -6334,10 +6307,10 @@ cmd_inputwin(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_log(ProfWin *window, const char *const command, gchar **args) +cmd_log(ProfWin* window, const char* const command, gchar** args) { - char *subcmd = args[0]; - char *value = args[1]; + char* subcmd = args[0]; + char* value = args[1]; if (strcmp(subcmd, "maxsize") == 0) { if (value == NULL) { @@ -6346,7 +6319,7 @@ cmd_log(ProfWin *window, const char *const command, gchar **args) } int intval = 0; - char *err_msg = NULL; + char* err_msg = NULL; gboolean res = strtoi_range(value, &intval, PREFS_MIN_LOG_SIZE, INT_MAX, &err_msg); if (res) { prefs_set_max_log_size(intval); @@ -6390,12 +6363,12 @@ cmd_log(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_reconnect(ProfWin *window, const char *const command, gchar **args) +cmd_reconnect(ProfWin* window, const char* const command, gchar** args) { - char *value = args[0]; + char* value = args[0]; int intval = 0; - char *err_msg = NULL; + char* err_msg = NULL; gboolean res = strtoi_range(value, &intval, 0, INT_MAX, &err_msg); if (res) { prefs_set_reconnect(intval); @@ -6414,14 +6387,14 @@ cmd_reconnect(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_autoping(ProfWin *window, const char *const command, gchar **args) +cmd_autoping(ProfWin* window, const char* const command, gchar** args) { - char *cmd = args[0]; - char *value = args[1]; + char* cmd = args[0]; + char* value = args[1]; if (g_strcmp0(cmd, "set") == 0) { int intval = 0; - char *err_msg = NULL; + char* err_msg = NULL; gboolean res = strtoi_range(value, &intval, 0, INT_MAX, &err_msg); if (res) { prefs_set_autoping(intval); @@ -6439,7 +6412,7 @@ cmd_autoping(ProfWin *window, const char *const command, gchar **args) } else if (g_strcmp0(cmd, "timeout") == 0) { int intval = 0; - char *err_msg = NULL; + char* err_msg = NULL; gboolean res = strtoi_range(value, &intval, 0, INT_MAX, &err_msg); if (res) { prefs_set_autoping_timeout(intval); @@ -6462,7 +6435,7 @@ cmd_autoping(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_ping(ProfWin *window, const char *const command, gchar **args) +cmd_ping(ProfWin* window, const char* const command, gchar** args) { jabber_conn_status_t conn_status = connection_get_status(); @@ -6492,17 +6465,15 @@ cmd_ping(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_autoaway(ProfWin *window, const char *const command, gchar **args) +cmd_autoaway(ProfWin* window, const char* const command, gchar** args) { - if ((strcmp(args[0], "mode") != 0) && (strcmp(args[0], "time") != 0) && - (strcmp(args[0], "message") != 0) && (strcmp(args[0], "check") != 0)) { + if ((strcmp(args[0], "mode") != 0) && (strcmp(args[0], "time") != 0) && (strcmp(args[0], "message") != 0) && (strcmp(args[0], "check") != 0)) { cons_show("Setting must be one of 'mode', 'time', 'message' or 'check'"); return TRUE; } if (strcmp(args[0], "mode") == 0) { - if ((strcmp(args[1], "idle") != 0) && (strcmp(args[1], "away") != 0) && - (strcmp(args[1], "off") != 0)) { + if ((strcmp(args[1], "idle") != 0) && (strcmp(args[1], "away") != 0) && (strcmp(args[1], "off") != 0)) { cons_show("Mode must be one of 'idle', 'away' or 'off'"); } else { prefs_set_string(PREF_AUTOAWAY_MODE, args[1]); @@ -6515,7 +6486,7 @@ cmd_autoaway(ProfWin *window, const char *const command, gchar **args) if (strcmp(args[0], "time") == 0) { if (g_strcmp0(args[1], "away") == 0) { int minutesval = 0; - char *err_msg = NULL; + char* err_msg = NULL; gboolean res = strtoi_range(args[2], &minutesval, 1, INT_MAX, &err_msg); if (res) { prefs_set_autoaway_time(minutesval); @@ -6532,7 +6503,7 @@ cmd_autoaway(ProfWin *window, const char *const command, gchar **args) return TRUE; } else if (g_strcmp0(args[1], "xa") == 0) { int minutesval = 0; - char *err_msg = NULL; + char* err_msg = NULL; gboolean res = strtoi_range(args[2], &minutesval, 0, INT_MAX, &err_msg); if (res) { int away_time = prefs_get_autoaway_time(); @@ -6596,7 +6567,7 @@ cmd_autoaway(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_priority(ProfWin *window, const char *const command, gchar **args) +cmd_priority(ProfWin* window, const char* const command, gchar** args) { jabber_conn_status_t conn_status = connection_get_status(); @@ -6605,10 +6576,10 @@ cmd_priority(ProfWin *window, const char *const command, gchar **args) return TRUE; } - char *value = args[0]; + char* value = args[0]; int intval = 0; - char *err_msg = NULL; + char* err_msg = NULL; gboolean res = strtoi_range(value, &intval, -128, 127, &err_msg); if (res) { accounts_set_priority_all(session_get_account_name(), intval); @@ -6624,7 +6595,7 @@ cmd_priority(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_vercheck(ProfWin *window, const char *const command, gchar **args) +cmd_vercheck(ProfWin* window, const char* const command, gchar** args) { int num_args = g_strv_length(args); @@ -6638,13 +6609,13 @@ cmd_vercheck(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_xmlconsole(ProfWin *window, const char *const command, gchar **args) +cmd_xmlconsole(ProfWin* window, const char* const command, gchar** args) { - ProfXMLWin *xmlwin = wins_get_xmlconsole(); + ProfXMLWin* xmlwin = wins_get_xmlconsole(); if (xmlwin) { ui_focus_win((ProfWin*)xmlwin); } else { - ProfWin *window = wins_new_xmlconsole(); + ProfWin* window = wins_new_xmlconsole(); ui_focus_win(window); } @@ -6652,14 +6623,14 @@ cmd_xmlconsole(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_flash(ProfWin *window, const char *const command, gchar **args) +cmd_flash(ProfWin* window, const char* const command, gchar** args) { _cmd_set_boolean_preference(args[0], command, "Screen flash", PREF_FLASH); return TRUE; } gboolean -cmd_tray(ProfWin *window, const char *const command, gchar **args) +cmd_tray(ProfWin* window, const char* const command, gchar** args) { #ifdef HAVE_GTK if (g_strcmp0(args[0], "timer") == 0) { @@ -6674,7 +6645,7 @@ cmd_tray(ProfWin *window, const char *const command, gchar **args) } int intval = 0; - char *err_msg = NULL; + char* err_msg = NULL; gboolean res = strtoi_range(args[1], &intval, 1, 10, &err_msg); if (res) { if (intval == 1) { @@ -6727,21 +6698,21 @@ cmd_tray(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_intype(ProfWin *window, const char *const command, gchar **args) +cmd_intype(ProfWin* window, const char* const command, gchar** args) { _cmd_set_boolean_preference(args[0], command, "Show contact typing", PREF_INTYPE); return TRUE; } gboolean -cmd_splash(ProfWin *window, const char *const command, gchar **args) +cmd_splash(ProfWin* window, const char* const command, gchar** args) { _cmd_set_boolean_preference(args[0], command, "Splash screen", PREF_SPLASH); return TRUE; } gboolean -cmd_autoconnect(ProfWin *window, const char *const command, gchar **args) +cmd_autoconnect(ProfWin* window, const char* const command, gchar** args) { if (strcmp(args[0], "off") == 0) { prefs_set_string(PREF_CONNECT_ACCOUNT, NULL); @@ -6764,14 +6735,13 @@ cmd_autoconnect(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_logging(ProfWin *window, const char *const command, gchar **args) +cmd_logging(ProfWin* window, const char* const command, gchar** args) { if (args[0] == NULL) { cons_logging_setting(); return TRUE; } - if (strcmp(args[0], "chat") == 0 && args[1] != NULL) { _cmd_set_boolean_preference(args[1], command, "Chat logging", PREF_CHLOG); @@ -6793,7 +6763,7 @@ cmd_logging(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_history(ProfWin *window, const char *const command, gchar **args) +cmd_history(ProfWin* window, const char* const command, gchar** args) { if (args[0] == NULL) { return FALSE; @@ -6810,7 +6780,7 @@ cmd_history(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_carbons(ProfWin *window, const char *const command, gchar **args) +cmd_carbons(ProfWin* window, const char* const command, gchar** args) { if (args[0] == NULL) { return FALSE; @@ -6824,8 +6794,7 @@ cmd_carbons(ProfWin *window, const char *const command, gchar **args) // enable carbons if (strcmp(args[0], "on") == 0) { iq_enable_carbons(); - } - else if (strcmp(args[0], "off") == 0){ + } else if (strcmp(args[0], "off") == 0) { iq_disable_carbons(); } } @@ -6834,7 +6803,7 @@ cmd_carbons(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_receipts(ProfWin *window, const char *const command, gchar **args) +cmd_receipts(ProfWin* window, const char* const command, gchar** args) { if (g_strcmp0(args[0], "send") == 0) { _cmd_set_boolean_preference(args[1], command, "Send delivery receipts", PREF_RECEIPTS_SEND); @@ -6854,10 +6823,10 @@ cmd_receipts(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_plugins_sourcepath(ProfWin *window, const char *const command, gchar **args) +cmd_plugins_sourcepath(ProfWin* window, const char* const command, gchar** args) { if (args[1] == NULL) { - char *sourcepath = prefs_get_string(PREF_PLUGINS_SOURCEPATH); + char* sourcepath = prefs_get_string(PREF_PLUGINS_SOURCEPATH); if (sourcepath) { cons_show("Current plugins sourcepath: %s", sourcepath); g_free(sourcepath); @@ -6874,7 +6843,7 @@ cmd_plugins_sourcepath(ProfWin *window, const char *const command, gchar **args) } if (g_strcmp0(args[1], "set") == 0) { - char *path = args[2]; + char* path = args[2]; if (path == NULL) { cons_bad_cmd_usage(command); return TRUE; @@ -6882,7 +6851,7 @@ cmd_plugins_sourcepath(ProfWin *window, const char *const command, gchar **args) // expand ~ to $HOME if (path[0] == '~' && path[1] == '/') { - if (asprintf(&path, "%s/%s", getenv("HOME"), path+2) == -1) { + if (asprintf(&path, "%s/%s", getenv("HOME"), path + 2) == -1) { return TRUE; } } else { @@ -6906,9 +6875,9 @@ cmd_plugins_sourcepath(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_plugins_install(ProfWin *window, const char *const command, gchar **args) +cmd_plugins_install(ProfWin* window, const char* const command, gchar** args) { - char *path = args[1]; + char* path = args[1]; if (path == NULL) { char* sourcepath = prefs_get_string(PREF_PLUGINS_SOURCEPATH); if (sourcepath) { @@ -6919,7 +6888,7 @@ cmd_plugins_install(ProfWin *window, const char *const command, gchar **args) return TRUE; } } else if (path[0] == '~' && path[1] == '/') { - if (asprintf(&path, "%s/%s", getenv("HOME"), path+2) == -1) { + if (asprintf(&path, "%s/%s", getenv("HOME"), path + 2) == -1) { return TRUE; } } else { @@ -6934,7 +6903,7 @@ cmd_plugins_install(ProfWin *window, const char *const command, gchar **args) } GString* error_message = g_string_new(NULL); - gchar *plugin_name = g_path_get_basename(path); + gchar* plugin_name = g_path_get_basename(path); gboolean result = plugins_install(plugin_name, path, error_message); if (result) { cons_show("Plugin installed: %s", plugin_name); @@ -6951,7 +6920,7 @@ cmd_plugins_install(ProfWin *window, const char *const command, gchar **args) if (result->installed) { cons_show(""); cons_show("Installed plugins:"); - GSList *curr = result->installed; + GSList* curr = result->installed; while (curr) { cons_show(" %s", curr->data); curr = g_slist_next(curr); @@ -6960,7 +6929,7 @@ cmd_plugins_install(ProfWin *window, const char *const command, gchar **args) if (result->failed) { cons_show(""); cons_show("Failed installs:"); - GSList *curr = result->failed; + GSList* curr = result->failed; while (curr) { cons_show(" %s", curr->data); curr = g_slist_next(curr); @@ -6981,9 +6950,9 @@ cmd_plugins_install(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_plugins_update(ProfWin *window, const char *const command, gchar **args) +cmd_plugins_update(ProfWin* window, const char* const command, gchar** args) { - char *path = args[1]; + char* path = args[1]; if (path == NULL) { char* sourcepath = prefs_get_string(PREF_PLUGINS_SOURCEPATH); if (sourcepath) { @@ -6994,7 +6963,7 @@ cmd_plugins_update(ProfWin *window, const char *const command, gchar **args) return TRUE; } } else if (path[0] == '~' && path[1] == '/') { - if (asprintf(&path, "%s/%s", getenv("HOME"), path+2) == -1) { + if (asprintf(&path, "%s/%s", getenv("HOME"), path + 2) == -1) { return TRUE; } } else { @@ -7015,7 +6984,7 @@ cmd_plugins_update(ProfWin *window, const char *const command, gchar **args) } GString* error_message = g_string_new(NULL); - gchar *plugin_name = g_path_get_basename(path); + gchar* plugin_name = g_path_get_basename(path); if (plugins_unload(plugin_name)) { if (plugins_uninstall(plugin_name)) { if (plugins_install(plugin_name, path, error_message)) { @@ -7046,7 +7015,7 @@ cmd_plugins_update(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_plugins_uninstall(ProfWin *window, const char *const command, gchar **args) +cmd_plugins_uninstall(ProfWin* window, const char* const command, gchar** args) { if (args[1] == NULL) { return FALSE; @@ -7063,13 +7032,13 @@ cmd_plugins_uninstall(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_plugins_load(ProfWin *window, const char *const command, gchar **args) +cmd_plugins_load(ProfWin* window, const char* const command, gchar** args) { if (args[1] == NULL) { - GSList *loaded = plugins_load_all(); + GSList* loaded = plugins_load_all(); if (loaded) { cons_show("Loaded plugins:"); - GSList *curr = loaded; + GSList* curr = loaded; while (curr) { cons_show(" %s", curr->data); curr = g_slist_next(curr); @@ -7094,7 +7063,7 @@ cmd_plugins_load(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_plugins_unload(ProfWin *window, const char *const command, gchar **args) +cmd_plugins_unload(ProfWin* window, const char* const command, gchar** args) { if (args[1] == NULL) { gboolean res = plugins_unload_all(); @@ -7117,7 +7086,7 @@ cmd_plugins_unload(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_plugins_reload(ProfWin *window, const char *const command, gchar **args) +cmd_plugins_reload(ProfWin* window, const char* const command, gchar** args) { if (args[1] == NULL) { plugins_reload_all(); @@ -7138,10 +7107,10 @@ cmd_plugins_reload(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_plugins_python_version(ProfWin *window, const char *const command, gchar **args) +cmd_plugins_python_version(ProfWin* window, const char* const command, gchar** args) { #ifdef HAVE_PYTHON - const char *version = python_get_version_string(); + const char* version = python_get_version_string(); cons_show("Python version:"); cons_show("%s", version); #else @@ -7151,15 +7120,15 @@ cmd_plugins_python_version(ProfWin *window, const char *const command, gchar **a } gboolean -cmd_plugins(ProfWin *window, const char *const command, gchar **args) +cmd_plugins(ProfWin* window, const char* const command, gchar** args) { - GList *plugins = plugins_loaded_list(); + GList* plugins = plugins_loaded_list(); if (plugins == NULL) { cons_show("No plugins installed."); return TRUE; } - GList *curr = plugins; + GList* curr = plugins; cons_show("Installed plugins:"); while (curr) { cons_show(" %s", curr->data); @@ -7171,7 +7140,7 @@ cmd_plugins(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_pgp(ProfWin *window, const char *const command, gchar **args) +cmd_pgp(ProfWin* window, const char* const command, gchar** args) { #ifdef HAVE_LIBGPGME if (args[0] == NULL) { @@ -7194,7 +7163,7 @@ cmd_pgp(ProfWin *window, const char *const command, gchar **args) cons_bad_cmd_usage(command); return TRUE; } else if (g_strcmp0(args[0], "log") == 0) { - char *choice = args[1]; + char* choice = args[1]; if (g_strcmp0(choice, "on") == 0) { prefs_set_string(PREF_PGP_LOG, "on"); cons_show("PGP messages will be logged as plaintext."); @@ -7217,20 +7186,20 @@ cmd_pgp(ProfWin *window, const char *const command, gchar **args) } if (g_strcmp0(args[0], "keys") == 0) { - GHashTable *keys = p_gpg_list_keys(); + GHashTable* keys = p_gpg_list_keys(); if (!keys || g_hash_table_size(keys) == 0) { cons_show("No keys found"); return TRUE; } cons_show("PGP keys:"); - GList *keylist = g_hash_table_get_keys(keys); - GList *curr = keylist; + GList* keylist = g_hash_table_get_keys(keys); + GList* curr = keylist; while (curr) { - ProfPGPKey *key = g_hash_table_lookup(keys, curr->data); + ProfPGPKey* key = g_hash_table_lookup(keys, curr->data); cons_show(" %s", key->name); cons_show(" ID : %s", key->id); - char *format_fp = p_gpg_format_fp_str(key->fp); + char* format_fp = p_gpg_format_fp_str(key->fp); cons_show(" Fingerprint : %s", format_fp); free(format_fp); if (key->secret) { @@ -7252,13 +7221,13 @@ cmd_pgp(ProfWin *window, const char *const command, gchar **args) return TRUE; } - char *jid = args[1]; + char* jid = args[1]; if (!args[1]) { cons_bad_cmd_usage(command); return TRUE; } - char *keyid = args[2]; + char* keyid = args[2]; if (!args[2]) { cons_bad_cmd_usage(command); return TRUE; @@ -7280,18 +7249,18 @@ cmd_pgp(ProfWin *window, const char *const command, gchar **args) cons_show("You are not currently connected."); return TRUE; } - GHashTable *pubkeys = p_gpg_pubkeys(); - GList *jids = g_hash_table_get_keys(pubkeys); + GHashTable* pubkeys = p_gpg_pubkeys(); + GList* jids = g_hash_table_get_keys(pubkeys); if (!jids) { cons_show("No contacts found with PGP public keys assigned."); return TRUE; } cons_show("Assigned PGP public keys:"); - GList *curr = jids; + GList* curr = jids; while (curr) { - char *jid = curr->data; - ProfPGPPubKeyId *pubkeyid = g_hash_table_lookup(pubkeys, jid); + char* jid = curr->data; + ProfPGPPubKeyId* pubkeyid = g_hash_table_lookup(pubkeys, jid); if (pubkeyid->received) { cons_show(" %s: %s (received)", jid, pubkeyid->id); } else { @@ -7304,13 +7273,13 @@ cmd_pgp(ProfWin *window, const char *const command, gchar **args) } if (g_strcmp0(args[0], "libver") == 0) { - const char *libver = p_gpg_libver(); + const char* libver = p_gpg_libver(); if (!libver) { cons_show("Could not get libgpgme version"); return TRUE; } - GString *fullstr = g_string_new("Using libgpgme version "); + GString* fullstr = g_string_new("Using libgpgme version "); g_string_append(fullstr, libver); cons_show("%s", fullstr->str); g_string_free(fullstr, TRUE); @@ -7330,11 +7299,11 @@ cmd_pgp(ProfWin *window, const char *const command, gchar **args) return TRUE; } - ProfChatWin *chatwin = NULL; + ProfChatWin* chatwin = NULL; if (args[1]) { - char *contact = args[1]; - char *barejid = roster_barejid_from_name(contact); + char* contact = args[1]; + char* barejid = roster_barejid_from_name(contact); if (barejid == NULL) { barejid = contact; } @@ -7364,8 +7333,8 @@ cmd_pgp(ProfWin *window, const char *const command, gchar **args) return TRUE; } - ProfAccount *account = accounts_get_account(session_get_account_name()); - char *err_str = NULL; + ProfAccount* account = accounts_get_account(session_get_account_name()); + char* err_str = NULL; if (!p_gpg_valid_key(account->pgp_keyid, &err_str)) { win_println(window, THEME_DEFAULT, "!", "Invalid PGP key ID %s: %s, cannot start PGP encryption.", account->pgp_keyid, err_str); free(err_str); @@ -7397,7 +7366,7 @@ cmd_pgp(ProfWin *window, const char *const command, gchar **args) return TRUE; } - ProfChatWin *chatwin = (ProfChatWin*)window; + ProfChatWin* chatwin = (ProfChatWin*)window; if (chatwin->pgp_send == FALSE) { win_println(window, THEME_DEFAULT, "!", "PGP encryption is not currently enabled."); return TRUE; @@ -7429,7 +7398,7 @@ cmd_pgp(ProfWin *window, const char *const command, gchar **args) */ gboolean -cmd_ox(ProfWin *window, const char *const command, gchar **args) +cmd_ox(ProfWin* window, const char* const command, gchar** args) { if (args[0] == NULL) { cons_bad_cmd_usage(command); @@ -7440,20 +7409,20 @@ cmd_ox(ProfWin *window, const char *const command, gchar **args) // Should we move this to a common command // e.g. '/openpgp keys'?. else if (g_strcmp0(args[0], "keys") == 0) { - GHashTable *keys = p_gpg_list_keys(); + GHashTable* keys = p_gpg_list_keys(); if (!keys || g_hash_table_size(keys) == 0) { cons_show("No keys found"); return TRUE; } cons_show("OpenPGP keys:"); - GList *keylist = g_hash_table_get_keys(keys); - GList *curr = keylist; + GList* keylist = g_hash_table_get_keys(keys); + GList* curr = keylist; while (curr) { - ProfPGPKey *key = g_hash_table_lookup(keys, curr->data); + ProfPGPKey* key = g_hash_table_lookup(keys, curr->data); cons_show(" %s", key->name); cons_show(" ID : %s", key->id); - char *format_fp = p_gpg_format_fp_str(key->fp); + char* format_fp = p_gpg_format_fp_str(key->fp); cons_show(" Fingerprint : %s", format_fp); free(format_fp); if (key->secret) { @@ -7469,13 +7438,12 @@ cmd_ox(ProfWin *window, const char *const command, gchar **args) } else if (g_strcmp0(args[0], "contacts") == 0) { - GHashTable *keys = ox_gpg_public_keys(); + GHashTable* keys = ox_gpg_public_keys(); cons_show("OpenPGP keys:"); - GList *keylist = g_hash_table_get_keys(keys); - GList *curr = keylist; - + GList* keylist = g_hash_table_get_keys(keys); + GList* curr = keylist; - GSList *roster_list = NULL; + GSList* roster_list = NULL; jabber_conn_status_t conn_status = connection_get_status(); if (conn_status != JABBER_CONNECTED) { cons_show("You are not currently connected."); @@ -7484,23 +7452,23 @@ cmd_ox(ProfWin *window, const char *const command, gchar **args) } while (curr) { - ProfPGPKey *key = g_hash_table_lookup(keys, curr->data); + ProfPGPKey* key = g_hash_table_lookup(keys, curr->data); PContact contact = NULL; if (roster_list) { - GSList *curr_c = roster_list; - while ( !contact && curr_c){ + GSList* curr_c = roster_list; + while (!contact && curr_c) { contact = curr_c->data; - const char *jid = p_contact_barejid(contact); + const char* jid = p_contact_barejid(contact); GString* xmppuri = g_string_new("xmpp:"); g_string_append(xmppuri, jid); - if( g_strcmp0(key->name, xmppuri->str)) { + if (g_strcmp0(key->name, xmppuri->str)) { contact = NULL; } curr_c = g_slist_next(curr_c); } } - if(contact) { + if (contact) { cons_show("%s - %s", key->fp, key->name); } else { cons_show("%s - %s (not in roster)", key->fp, key->name); @@ -7520,11 +7488,11 @@ cmd_ox(ProfWin *window, const char *const command, gchar **args) return TRUE; } - ProfChatWin *chatwin = NULL; + ProfChatWin* chatwin = NULL; if (args[1]) { - char *contact = args[1]; - char *barejid = roster_barejid_from_name(contact); + char* contact = args[1]; + char* barejid = roster_barejid_from_name(contact); if (barejid == NULL) { barejid = contact; } @@ -7554,9 +7522,9 @@ cmd_ox(ProfWin *window, const char *const command, gchar **args) return TRUE; } - ProfAccount *account = accounts_get_account(session_get_account_name()); + ProfAccount* account = accounts_get_account(session_get_account_name()); - if ( !ox_is_private_key_available(account->jid) ) { + if (!ox_is_private_key_available(account->jid)) { win_println(window, THEME_DEFAULT, "!", "No private OpenPGP found, cannot start OX encryption."); account_free(account); return TRUE; @@ -7572,8 +7540,8 @@ cmd_ox(ProfWin *window, const char *const command, gchar **args) win_println(window, THEME_DEFAULT, "!", "OX encryption enabled."); return TRUE; } else if (g_strcmp0(args[0], "announce") == 0) { - if( args[1] ) { - ox_announce_public_key( args[1] ); + if (args[1]) { + ox_announce_public_key(args[1]); } else { cons_show("Filename is required"); } @@ -7585,7 +7553,7 @@ cmd_ox(ProfWin *window, const char *const command, gchar **args) #endif // HAVE_LIBGPGME gboolean -cmd_otr_char(ProfWin *window, const char *const command, gchar **args) +cmd_otr_char(ProfWin* window, const char* const command, gchar** args) { #ifdef HAVE_LIBOTR if (args[1] == NULL) { @@ -7607,10 +7575,10 @@ cmd_otr_char(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_otr_log(ProfWin *window, const char *const command, gchar **args) +cmd_otr_log(ProfWin* window, const char* const command, gchar** args) { #ifdef HAVE_LIBOTR - char *choice = args[1]; + char* choice = args[1]; if (g_strcmp0(choice, "on") == 0) { prefs_set_string(PREF_OTR_LOG, "on"); cons_show("OTR messages will be logged as plaintext."); @@ -7637,10 +7605,10 @@ cmd_otr_log(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_otr_libver(ProfWin *window, const char *const command, gchar **args) +cmd_otr_libver(ProfWin* window, const char* const command, gchar** args) { #ifdef HAVE_LIBOTR - char *version = otr_libotr_version(); + char* version = otr_libotr_version(); cons_show("Using libotr version %s", version); return TRUE; #else @@ -7650,25 +7618,23 @@ cmd_otr_libver(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_otr_policy(ProfWin *window, const char *const command, gchar **args) +cmd_otr_policy(ProfWin* window, const char* const command, gchar** args) { #ifdef HAVE_LIBOTR if (args[1] == NULL) { - char *policy = prefs_get_string(PREF_OTR_POLICY); + char* policy = prefs_get_string(PREF_OTR_POLICY); cons_show("OTR policy is now set to: %s", policy); g_free(policy); return TRUE; } - char *choice = args[1]; - if ((g_strcmp0(choice, "manual") != 0) && - (g_strcmp0(choice, "opportunistic") != 0) && - (g_strcmp0(choice, "always") != 0)) { + char* choice = args[1]; + if ((g_strcmp0(choice, "manual") != 0) && (g_strcmp0(choice, "opportunistic") != 0) && (g_strcmp0(choice, "always") != 0)) { cons_show("OTR policy can be set to: manual, opportunistic or always."); return TRUE; } - char *contact = args[2]; + char* contact = args[2]; if (contact == NULL) { prefs_set_string(PREF_OTR_POLICY, choice); cons_show("OTR policy is now set to: %s", choice); @@ -7680,7 +7646,7 @@ cmd_otr_policy(ProfWin *window, const char *const command, gchar **args) return TRUE; } - char *contact_jid = roster_barejid_from_name(contact); + char* contact_jid = roster_barejid_from_name(contact); if (contact_jid == NULL) { contact_jid = contact; } @@ -7694,7 +7660,7 @@ cmd_otr_policy(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_otr_gen(ProfWin *window, const char *const command, gchar **args) +cmd_otr_gen(ProfWin* window, const char* const command, gchar** args) { #ifdef HAVE_LIBOTR if (connection_get_status() != JABBER_CONNECTED) { @@ -7702,7 +7668,7 @@ cmd_otr_gen(ProfWin *window, const char *const command, gchar **args) return TRUE; } - ProfAccount *account = accounts_get_account(session_get_account_name()); + ProfAccount* account = accounts_get_account(session_get_account_name()); otr_keygen(account); account_free(account); return TRUE; @@ -7713,7 +7679,7 @@ cmd_otr_gen(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_otr_myfp(ProfWin *window, const char *const command, gchar **args) +cmd_otr_myfp(ProfWin* window, const char* const command, gchar** args) { #ifdef HAVE_LIBOTR if (connection_get_status() != JABBER_CONNECTED) { @@ -7726,7 +7692,7 @@ cmd_otr_myfp(ProfWin *window, const char *const command, gchar **args) return TRUE; } - char *fingerprint = otr_get_my_fingerprint(); + char* fingerprint = otr_get_my_fingerprint(); win_println(window, THEME_DEFAULT, "!", "Your OTR fingerprint: %s", fingerprint); free(fingerprint); return TRUE; @@ -7737,7 +7703,7 @@ cmd_otr_myfp(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_otr_theirfp(ProfWin *window, const char *const command, gchar **args) +cmd_otr_theirfp(ProfWin* window, const char* const command, gchar** args) { #ifdef HAVE_LIBOTR if (connection_get_status() != JABBER_CONNECTED) { @@ -7750,14 +7716,14 @@ cmd_otr_theirfp(ProfWin *window, const char *const command, gchar **args) return TRUE; } - ProfChatWin *chatwin = (ProfChatWin*)window; + ProfChatWin* chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); if (chatwin->is_otr == FALSE) { win_println(window, THEME_DEFAULT, "!", "You are not currently in an OTR session."); return TRUE; } - char *fingerprint = otr_get_their_fingerprint(chatwin->barejid); + char* fingerprint = otr_get_their_fingerprint(chatwin->barejid); win_println(window, THEME_DEFAULT, "!", "%s's OTR fingerprint: %s", chatwin->barejid, fingerprint); free(fingerprint); return TRUE; @@ -7768,7 +7734,7 @@ cmd_otr_theirfp(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_otr_start(ProfWin *window, const char *const command, gchar **args) +cmd_otr_start(ProfWin* window, const char* const command, gchar** args) { #ifdef HAVE_LIBOTR if (connection_get_status() != JABBER_CONNECTED) { @@ -7778,13 +7744,13 @@ cmd_otr_start(ProfWin *window, const char *const command, gchar **args) // recipient supplied if (args[1]) { - char *contact = args[1]; - char *barejid = roster_barejid_from_name(contact); + char* contact = args[1]; + char* barejid = roster_barejid_from_name(contact); if (barejid == NULL) { barejid = contact; } - ProfChatWin *chatwin = wins_get_chat(barejid); + ProfChatWin* chatwin = wins_get_chat(barejid); if (!chatwin) { chatwin = chatwin_new(barejid); } @@ -7811,8 +7777,8 @@ cmd_otr_start(ProfWin *window, const char *const command, gchar **args) } if (!otr_is_secure(barejid)) { - char *otr_query_message = otr_start_query(); - char *id = message_send_chat_otr(barejid, otr_query_message, FALSE, NULL); + char* otr_query_message = otr_start_query(); + char* id = message_send_chat_otr(barejid, otr_query_message, FALSE, NULL); free(id); return TRUE; } @@ -7820,14 +7786,14 @@ cmd_otr_start(ProfWin *window, const char *const command, gchar **args) chatwin_otr_secured(chatwin, otr_is_trusted(barejid)); return TRUE; - // no recipient, use current chat + // no recipient, use current chat } else { if (window->type != WIN_CHAT) { win_println(window, THEME_DEFAULT, "-", "You must be in a regular chat window to start an OTR session."); return TRUE; } - ProfChatWin *chatwin = (ProfChatWin*)window; + ProfChatWin* chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); if (chatwin->pgp_send) { win_println(window, THEME_DEFAULT, "!", "You must disable PGP encryption before starting an OTR session."); @@ -7844,8 +7810,8 @@ cmd_otr_start(ProfWin *window, const char *const command, gchar **args) return TRUE; } - char *otr_query_message = otr_start_query(); - char *id = message_send_chat_otr(chatwin->barejid, otr_query_message, FALSE, NULL); + char* otr_query_message = otr_start_query(); + char* id = message_send_chat_otr(chatwin->barejid, otr_query_message, FALSE, NULL); free(id); return TRUE; @@ -7857,7 +7823,7 @@ cmd_otr_start(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_otr_end(ProfWin *window, const char *const command, gchar **args) +cmd_otr_end(ProfWin* window, const char* const command, gchar** args) { #ifdef HAVE_LIBOTR if (connection_get_status() != JABBER_CONNECTED) { @@ -7870,7 +7836,7 @@ cmd_otr_end(ProfWin *window, const char *const command, gchar **args) return TRUE; } - ProfChatWin *chatwin = (ProfChatWin*)window; + ProfChatWin* chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); if (chatwin->is_otr == FALSE) { win_println(window, THEME_DEFAULT, "!", "You are not currently in an OTR session."); @@ -7887,7 +7853,7 @@ cmd_otr_end(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_otr_trust(ProfWin *window, const char *const command, gchar **args) +cmd_otr_trust(ProfWin* window, const char* const command, gchar** args) { #ifdef HAVE_LIBOTR if (connection_get_status() != JABBER_CONNECTED) { @@ -7900,7 +7866,7 @@ cmd_otr_trust(ProfWin *window, const char *const command, gchar **args) return TRUE; } - ProfChatWin *chatwin = (ProfChatWin*)window; + ProfChatWin* chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); if (chatwin->is_otr == FALSE) { win_println(window, THEME_DEFAULT, "!", "You are not currently in an OTR session."); @@ -7917,7 +7883,7 @@ cmd_otr_trust(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_otr_untrust(ProfWin *window, const char *const command, gchar **args) +cmd_otr_untrust(ProfWin* window, const char* const command, gchar** args) { #ifdef HAVE_LIBOTR if (connection_get_status() != JABBER_CONNECTED) { @@ -7930,7 +7896,7 @@ cmd_otr_untrust(ProfWin *window, const char *const command, gchar **args) return TRUE; } - ProfChatWin *chatwin = (ProfChatWin*)window; + ProfChatWin* chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); if (chatwin->is_otr == FALSE) { win_println(window, THEME_DEFAULT, "!", "You are not currently in an OTR session."); @@ -7947,7 +7913,7 @@ cmd_otr_untrust(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_otr_secret(ProfWin *window, const char *const command, gchar **args) +cmd_otr_secret(ProfWin* window, const char* const command, gchar** args) { #ifdef HAVE_LIBOTR if (connection_get_status() != JABBER_CONNECTED) { @@ -7960,14 +7926,14 @@ cmd_otr_secret(ProfWin *window, const char *const command, gchar **args) return TRUE; } - ProfChatWin *chatwin = (ProfChatWin*)window; + ProfChatWin* chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); if (chatwin->is_otr == FALSE) { win_println(window, THEME_DEFAULT, "!", "You are not currently in an OTR session."); return TRUE; } - char *secret = args[1]; + char* secret = args[1]; if (secret == NULL) { cons_bad_cmd_usage(command); return TRUE; @@ -7982,7 +7948,7 @@ cmd_otr_secret(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_otr_question(ProfWin *window, const char *const command, gchar **args) +cmd_otr_question(ProfWin* window, const char* const command, gchar** args) { #ifdef HAVE_LIBOTR if (connection_get_status() != JABBER_CONNECTED) { @@ -7990,8 +7956,8 @@ cmd_otr_question(ProfWin *window, const char *const command, gchar **args) return TRUE; } - char *question = args[1]; - char *answer = args[2]; + char* question = args[1]; + char* answer = args[2]; if (question == NULL || answer == NULL) { cons_bad_cmd_usage(command); return TRUE; @@ -8002,7 +7968,7 @@ cmd_otr_question(ProfWin *window, const char *const command, gchar **args) return TRUE; } - ProfChatWin *chatwin = (ProfChatWin*)window; + ProfChatWin* chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); if (chatwin->is_otr == FALSE) { win_println(window, THEME_DEFAULT, "!", "You are not currently in an OTR session."); @@ -8018,7 +7984,7 @@ cmd_otr_question(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_otr_answer(ProfWin *window, const char *const command, gchar **args) +cmd_otr_answer(ProfWin* window, const char* const command, gchar** args) { #ifdef HAVE_LIBOTR if (connection_get_status() != JABBER_CONNECTED) { @@ -8031,14 +7997,14 @@ cmd_otr_answer(ProfWin *window, const char *const command, gchar **args) return TRUE; } - ProfChatWin *chatwin = (ProfChatWin*)window; + ProfChatWin* chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); if (chatwin->is_otr == FALSE) { win_println(window, THEME_DEFAULT, "!", "You are not currently in an OTR session."); return TRUE; } - char *answer = args[1]; + char* answer = args[1]; if (answer == NULL) { cons_bad_cmd_usage(command); return TRUE; @@ -8053,7 +8019,7 @@ cmd_otr_answer(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_otr_sendfile(ProfWin *window, const char *const command, gchar **args) +cmd_otr_sendfile(ProfWin* window, const char* const command, gchar** args) { #ifdef HAVE_LIBOTR _cmd_set_boolean_preference(args[1], command, "Sending unencrypted files in an OTR session via /sendfile", PREF_OTR_SENDFILE); @@ -8066,7 +8032,7 @@ cmd_otr_sendfile(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_command_list(ProfWin *window, const char *const command, gchar **args) +cmd_command_list(ProfWin* window, const char* const command, gchar** args) { jabber_conn_status_t conn_status = connection_get_status(); @@ -8080,26 +8046,26 @@ cmd_command_list(ProfWin *window, const char *const command, gchar **args) return TRUE; } - char *jid = args[1]; + char* jid = args[1]; if (jid == NULL) { switch (window->type) { case WIN_MUC: { - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); jid = mucwin->roomjid; break; } case WIN_CHAT: { - ProfChatWin *chatwin = (ProfChatWin*)window; + ProfChatWin* chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); jid = chatwin->barejid; break; } case WIN_PRIVATE: { - ProfPrivateWin *privatewin = (ProfPrivateWin*)window; + ProfPrivateWin* privatewin = (ProfPrivateWin*)window; assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK); jid = privatewin->fulljid; break; @@ -8122,7 +8088,7 @@ cmd_command_list(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_command_exec(ProfWin *window, const char *const command, gchar **args) +cmd_command_exec(ProfWin* window, const char* const command, gchar** args) { jabber_conn_status_t conn_status = connection_get_status(); @@ -8141,26 +8107,26 @@ cmd_command_exec(ProfWin *window, const char *const command, gchar **args) return TRUE; } - char *jid = args[2]; + char* jid = args[2]; if (jid == NULL) { switch (window->type) { case WIN_MUC: { - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); jid = mucwin->roomjid; break; } case WIN_CHAT: { - ProfChatWin *chatwin = (ProfChatWin*)window; + ProfChatWin* chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); jid = chatwin->barejid; break; } case WIN_PRIVATE: { - ProfPrivateWin *privatewin = (ProfPrivateWin*)window; + ProfPrivateWin* privatewin = (ProfPrivateWin*)window; assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK); jid = privatewin->fulljid; break; @@ -8183,17 +8149,17 @@ cmd_command_exec(ProfWin *window, const char *const command, gchar **args) } static gboolean -_cmd_execute(ProfWin *window, const char *const command, const char *const inp) +_cmd_execute(ProfWin* window, const char* const command, const char* const inp) { if (g_str_has_prefix(command, "/field") && window->type == WIN_CONFIG) { gboolean result = FALSE; - gchar **args = parse_args_with_freetext(inp, 1, 2, &result); + gchar** args = parse_args_with_freetext(inp, 1, 2, &result); if (!result) { win_println(window, THEME_DEFAULT, "!", "Invalid command, see /form help"); result = TRUE; } else { - gchar **tokens = g_strsplit(inp, " ", 2); - char *field = tokens[0] + 1; + gchar** tokens = g_strsplit(inp, " ", 2); + char* field = tokens[0] + 1; result = cmd_form_field(window, field, args); g_strfreev(tokens); } @@ -8202,11 +8168,11 @@ _cmd_execute(ProfWin *window, const char *const command, const char *const inp) return result; } - Command *cmd = cmd_get(command); + Command* cmd = cmd_get(command); gboolean result = FALSE; if (cmd) { - gchar **args = cmd->parser(inp, cmd->min_args, cmd->max_args, &result); + gchar** args = cmd->parser(inp, cmd->min_args, cmd->max_args, &result); if (result == FALSE) { ui_invalid_command_usage(cmd->cmd, cmd->setting_func); return TRUE; @@ -8215,7 +8181,7 @@ _cmd_execute(ProfWin *window, const char *const command, const char *const inp) int i = 0; while (cmd->sub_funcs[i][0]) { if (g_strcmp0(args[0], (char*)cmd->sub_funcs[i][0]) == 0) { - gboolean (*func)(ProfWin *window, const char *const command, gchar **args) = cmd->sub_funcs[i][1]; + gboolean (*func)(ProfWin * window, const char* const command, gchar** args) = cmd->sub_funcs[i][1]; gboolean result = func(window, command, args); g_strfreev(args); return result; @@ -8244,13 +8210,13 @@ _cmd_execute(ProfWin *window, const char *const command, const char *const inp) } static gboolean -_cmd_execute_default(ProfWin *window, const char *inp) +_cmd_execute_default(ProfWin* window, const char* inp) { // handle escaped commands - treat as normal message if (g_str_has_prefix(inp, "//")) { inp++; - // handle unknown commands + // handle unknown commands } else if ((inp[0] == '/') && (!g_str_has_prefix(inp, "/me "))) { cons_show("Unknown command: %s", inp); cons_alert(); @@ -8265,7 +8231,7 @@ _cmd_execute_default(ProfWin *window, const char *inp) // handle plugin window if (window->type == WIN_PLUGIN) { - ProfPluginWin *pluginwin = (ProfPluginWin*)window; + ProfPluginWin* pluginwin = (ProfPluginWin*)window; plugins_win_process_line(pluginwin->tag, inp); return TRUE; } @@ -8279,21 +8245,21 @@ _cmd_execute_default(ProfWin *window, const char *inp) switch (window->type) { case WIN_CHAT: { - ProfChatWin *chatwin = (ProfChatWin*)window; + ProfChatWin* chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); cl_ev_send_msg(chatwin, inp, NULL); break; } case WIN_PRIVATE: { - ProfPrivateWin *privatewin = (ProfPrivateWin*)window; + ProfPrivateWin* privatewin = (ProfPrivateWin*)window; assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK); cl_ev_send_priv_msg(privatewin, inp, NULL); break; } case WIN_MUC: { - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); cl_ev_send_muc_msg(mucwin, inp, NULL); break; @@ -8311,15 +8277,15 @@ _cmd_execute_default(ProfWin *window, const char *inp) } static gboolean -_cmd_execute_alias(ProfWin *window, const char *const inp, gboolean *ran) +_cmd_execute_alias(ProfWin* window, const char* const inp, gboolean* ran) { if (inp[0] != '/') { *ran = FALSE; return TRUE; } - char *alias = strdup(inp+1); - char *value = prefs_get_alias(alias); + char* alias = strdup(inp + 1); + char* value = prefs_get_alias(alias); free(alias); if (value) { *ran = TRUE; @@ -8335,9 +8301,9 @@ _cmd_execute_alias(ProfWin *window, const char *const inp, gboolean *ran) // helper function for status change commands static void _update_presence(const resource_presence_t resource_presence, - const char *const show, gchar **args) + const char* const show, gchar** args) { - char *msg = NULL; + char* msg = NULL; int num_args = g_strv_length(args); // if no message, use status as message @@ -8360,13 +8326,13 @@ _update_presence(const resource_presence_t resource_presence, // helper function for boolean preference commands static void -_cmd_set_boolean_preference(gchar *arg, const char *const command, - const char *const display, preference_t pref) +_cmd_set_boolean_preference(gchar* arg, const char* const command, + const char* const display, preference_t pref) { if (arg == NULL) { cons_bad_cmd_usage(command); } else if (strcmp(arg, "on") == 0) { - GString *enabled = g_string_new(display); + GString* enabled = g_string_new(display); g_string_append(enabled, " enabled."); cons_show(enabled->str); @@ -8374,7 +8340,7 @@ _cmd_set_boolean_preference(gchar *arg, const char *const command, g_string_free(enabled, TRUE); } else if (strcmp(arg, "off") == 0) { - GString *disabled = g_string_new(display); + GString* disabled = g_string_new(display); g_string_append(disabled, " disabled."); cons_show(disabled->str); @@ -8387,7 +8353,7 @@ _cmd_set_boolean_preference(gchar *arg, const char *const command, } gboolean -cmd_omemo_gen(ProfWin *window, const char *const command, gchar **args) +cmd_omemo_gen(ProfWin* window, const char* const command, gchar** args) { #ifdef HAVE_OMEMO if (connection_get_status() != JABBER_CONNECTED) { @@ -8402,7 +8368,7 @@ cmd_omemo_gen(ProfWin *window, const char *const command, gchar **args) cons_show("Generating OMEMO crytographic materials, it may take a while..."); ui_update(); - ProfAccount *account = accounts_get_account(session_get_account_name()); + ProfAccount* account = accounts_get_account(session_get_account_name()); omemo_generate_crypto_materials(account); cons_show("OMEMO crytographic materials generated."); return TRUE; @@ -8413,7 +8379,7 @@ cmd_omemo_gen(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_omemo_start(ProfWin *window, const char *const command, gchar **args) +cmd_omemo_start(ProfWin* window, const char* const command, gchar** args) { #ifdef HAVE_OMEMO if (connection_get_status() != JABBER_CONNECTED) { @@ -8426,12 +8392,12 @@ cmd_omemo_start(ProfWin *window, const char *const command, gchar **args) return TRUE; } - ProfChatWin *chatwin = NULL; + ProfChatWin* chatwin = NULL; // recipient supplied if (args[1]) { - char *contact = args[1]; - char *barejid = roster_barejid_from_name(contact); + char* contact = args[1]; + char* barejid = roster_barejid_from_name(contact); if (barejid == NULL) { barejid = contact; } @@ -8442,10 +8408,10 @@ cmd_omemo_start(ProfWin *window, const char *const command, gchar **args) } ui_focus_win((ProfWin*)chatwin); } else { - if (window->type == WIN_CHAT) { - chatwin = (ProfChatWin*)window; - assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); - } + if (window->type == WIN_CHAT) { + chatwin = (ProfChatWin*)window; + assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); + } } if (chatwin) { @@ -8468,11 +8434,11 @@ cmd_omemo_start(ProfWin *window, const char *const command, gchar **args) omemo_start_session(chatwin->barejid); chatwin->is_omemo = TRUE; } else if (window->type == WIN_MUC) { - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); if (muc_anonymity_type(mucwin->roomjid) == MUC_ANONYMITY_TYPE_NONANONYMOUS - && muc_member_type(mucwin->roomjid) == MUC_MEMBER_TYPE_MEMBERS_ONLY) { + && muc_member_type(mucwin->roomjid) == MUC_MEMBER_TYPE_MEMBERS_ONLY) { accounts_add_omemo_state(session_get_account_name(), mucwin->roomjid, TRUE); omemo_start_muc_sessions(mucwin->roomjid); mucwin->is_omemo = TRUE; @@ -8491,7 +8457,7 @@ cmd_omemo_start(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_omemo_char(ProfWin *window, const char *const command, gchar **args) +cmd_omemo_char(ProfWin* window, const char* const command, gchar** args) { #ifdef HAVE_OMEMO if (args[1] == NULL) { @@ -8513,10 +8479,10 @@ cmd_omemo_char(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_omemo_log(ProfWin *window, const char *const command, gchar **args) +cmd_omemo_log(ProfWin* window, const char* const command, gchar** args) { #ifdef HAVE_OMEMO - char *choice = args[1]; + char* choice = args[1]; if (g_strcmp0(choice, "on") == 0) { prefs_set_string(PREF_OMEMO_LOG, "on"); cons_show("OMEMO messages will be logged as plaintext."); @@ -8543,7 +8509,7 @@ cmd_omemo_log(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_omemo_end(ProfWin *window, const char *const command, gchar **args) +cmd_omemo_end(ProfWin* window, const char* const command, gchar** args) { #ifdef HAVE_OMEMO if (connection_get_status() != JABBER_CONNECTED) { @@ -8552,7 +8518,7 @@ cmd_omemo_end(ProfWin *window, const char *const command, gchar **args) } if (window->type == WIN_CHAT) { - ProfChatWin *chatwin = (ProfChatWin*)window; + ProfChatWin* chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); if (!chatwin->is_omemo) { @@ -8563,7 +8529,7 @@ cmd_omemo_end(ProfWin *window, const char *const command, gchar **args) chatwin->is_omemo = FALSE; accounts_add_omemo_state(session_get_account_name(), chatwin->barejid, FALSE); } else if (window->type == WIN_MUC) { - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); if (!mucwin->is_omemo) { @@ -8586,7 +8552,7 @@ cmd_omemo_end(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_omemo_fingerprint(ProfWin *window, const char *const command, gchar **args) +cmd_omemo_fingerprint(ProfWin* window, const char* const command, gchar** args) { #ifdef HAVE_OMEMO if (connection_get_status() != JABBER_CONNECTED) { @@ -8599,22 +8565,22 @@ cmd_omemo_fingerprint(ProfWin *window, const char *const command, gchar **args) return TRUE; } - Jid *jid; + Jid* jid; if (!args[1]) { if (window->type == WIN_CONSOLE) { - char *fingerprint = omemo_own_fingerprint(TRUE); + char* fingerprint = omemo_own_fingerprint(TRUE); cons_show("Your OMEMO fingerprint: %s", fingerprint); free(fingerprint); jid = jid_create(connection_get_fulljid()); } else if (window->type == WIN_CHAT) { - ProfChatWin *chatwin = (ProfChatWin*)window; + ProfChatWin* chatwin = (ProfChatWin*)window; jid = jid_create(chatwin->barejid); } else { win_println(window, THEME_DEFAULT, "-", "You must be in a regular chat window to print fingerprint without providing the contact."); return TRUE; } } else { - char *barejid = roster_barejid_from_name(args[1]); + char* barejid = roster_barejid_from_name(args[1]); if (barejid) { jid = jid_create(barejid); } else { @@ -8626,8 +8592,8 @@ cmd_omemo_fingerprint(ProfWin *window, const char *const command, gchar **args) } } - GList *fingerprints = omemo_known_device_identities(jid->barejid); - GList *fingerprint; + GList* fingerprints = omemo_known_device_identities(jid->barejid); + GList* fingerprint; if (!fingerprints) { win_println(window, THEME_DEFAULT, "-", "There is no known fingerprints for %s", jid->barejid); @@ -8635,7 +8601,7 @@ cmd_omemo_fingerprint(ProfWin *window, const char *const command, gchar **args) } for (fingerprint = fingerprints; fingerprint != NULL; fingerprint = fingerprint->next) { - char *formatted_fingerprint = omemo_format_fingerprint(fingerprint->data); + char* formatted_fingerprint = omemo_format_fingerprint(fingerprint->data); gboolean trusted = omemo_is_trusted_identity(jid->barejid, fingerprint->data); win_println(window, THEME_DEFAULT, "-", "%s's OMEMO fingerprint: %s%s", jid->barejid, formatted_fingerprint, trusted ? " (trusted)" : ""); @@ -8656,7 +8622,7 @@ cmd_omemo_fingerprint(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_omemo_trust(ProfWin *window, const char *const command, gchar **args) +cmd_omemo_trust(ProfWin* window, const char* const command, gchar** args) { #ifdef HAVE_OMEMO if (connection_get_status() != JABBER_CONNECTED) { @@ -8674,8 +8640,8 @@ cmd_omemo_trust(ProfWin *window, const char *const command, gchar **args) return TRUE; } - char *fingerprint; - char *barejid; + char* fingerprint; + char* barejid; /* Contact not provided */ if (!args[2]) { @@ -8686,12 +8652,12 @@ cmd_omemo_trust(ProfWin *window, const char *const command, gchar **args) return TRUE; } - ProfChatWin *chatwin = (ProfChatWin*)window; + ProfChatWin* chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); barejid = chatwin->barejid; } else { fingerprint = args[2]; - char *contact = args[1]; + char* contact = args[1]; barejid = roster_barejid_from_name(contact); if (barejid == NULL) { barejid = contact; @@ -8700,7 +8666,7 @@ cmd_omemo_trust(ProfWin *window, const char *const command, gchar **args) omemo_trust(barejid, fingerprint); - char *unformatted_fingerprint = malloc(strlen(fingerprint)); + char* unformatted_fingerprint = malloc(strlen(fingerprint)); int i; int j; for (i = 0, j = 0; fingerprint[i] != '\0'; i++) { @@ -8725,7 +8691,7 @@ cmd_omemo_trust(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_omemo_untrust(ProfWin *window, const char *const command, gchar **args) +cmd_omemo_untrust(ProfWin* window, const char* const command, gchar** args) { #ifdef HAVE_OMEMO if (connection_get_status() != JABBER_CONNECTED) { @@ -8743,8 +8709,8 @@ cmd_omemo_untrust(ProfWin *window, const char *const command, gchar **args) return TRUE; } - char *fingerprint; - char *barejid; + char* fingerprint; + char* barejid; /* Contact not provided */ if (!args[2]) { @@ -8755,12 +8721,12 @@ cmd_omemo_untrust(ProfWin *window, const char *const command, gchar **args) return TRUE; } - ProfChatWin *chatwin = (ProfChatWin*)window; + ProfChatWin* chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); barejid = chatwin->barejid; } else { fingerprint = args[2]; - char *contact = args[1]; + char* contact = args[1]; barejid = roster_barejid_from_name(contact); if (barejid == NULL) { barejid = contact; @@ -8769,7 +8735,7 @@ cmd_omemo_untrust(ProfWin *window, const char *const command, gchar **args) omemo_untrust(barejid, fingerprint); - char *unformatted_fingerprint = malloc(strlen(fingerprint)); + char* unformatted_fingerprint = malloc(strlen(fingerprint)); int i; int j; for (i = 0, j = 0; fingerprint[i] != '\0'; i++) { @@ -8794,7 +8760,7 @@ cmd_omemo_untrust(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_omemo_clear_device_list(ProfWin *window, const char *const command, gchar **args) +cmd_omemo_clear_device_list(ProfWin* window, const char* const command, gchar** args) { #ifdef HAVE_OMEMO if (connection_get_status() != JABBER_CONNECTED) { @@ -8812,20 +8778,18 @@ cmd_omemo_clear_device_list(ProfWin *window, const char *const command, gchar ** } gboolean -cmd_omemo_policy(ProfWin *window, const char *const command, gchar **args) +cmd_omemo_policy(ProfWin* window, const char* const command, gchar** args) { #ifdef HAVE_OMEMO if (args[1] == NULL) { - char *policy = prefs_get_string(PREF_OMEMO_POLICY); + char* policy = prefs_get_string(PREF_OMEMO_POLICY); cons_show("OMEMO policy is now set to: %s", policy); g_free(policy); return TRUE; } - char *choice = args[1]; - if ((g_strcmp0(choice, "manual") != 0) && - (g_strcmp0(choice, "automatic") != 0) && - (g_strcmp0(choice, "always") != 0)) { + char* choice = args[1]; + if ((g_strcmp0(choice, "manual") != 0) && (g_strcmp0(choice, "automatic") != 0) && (g_strcmp0(choice, "always") != 0)) { cons_show("OMEMO policy can be set to: manual, automatic or always."); return TRUE; } @@ -8840,7 +8804,7 @@ cmd_omemo_policy(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_omemo_sendfile(ProfWin *window, const char *const command, gchar **args) +cmd_omemo_sendfile(ProfWin* window, const char* const command, gchar** args) { #ifdef HAVE_OMEMO _cmd_set_boolean_preference(args[1], command, "Sending unencrypted files in an OMEMO session via /sendfile", PREF_OMEMO_SENDFILE); @@ -8853,7 +8817,7 @@ cmd_omemo_sendfile(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_save(ProfWin *window, const char *const command, gchar **args) +cmd_save(ProfWin* window, const char* const command, gchar** args) { log_info("Saving preferences to configuration file"); cons_show("Saving preferences."); @@ -8862,7 +8826,7 @@ cmd_save(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_reload(ProfWin *window, const char *const command, gchar **args) +cmd_reload(ProfWin* window, const char* const command, gchar** args) { log_info("Reloading preferences"); cons_show("Reloading preferences."); @@ -8871,39 +8835,39 @@ cmd_reload(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_paste(ProfWin *window, const char *const command, gchar **args) +cmd_paste(ProfWin* window, const char* const command, gchar** args) { #ifdef HAVE_GTK - char *clipboard_buffer = clipboard_get(); + char* clipboard_buffer = clipboard_get(); if (clipboard_buffer) { switch (window->type) { - case WIN_MUC: - { - ProfMucWin *mucwin = (ProfMucWin*)window; - assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); - cl_ev_send_muc_msg(mucwin, clipboard_buffer, NULL); - break; - } - case WIN_CHAT: - { - ProfChatWin *chatwin = (ProfChatWin*)window; - assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); - cl_ev_send_msg(chatwin, clipboard_buffer, NULL); - break; - } - case WIN_PRIVATE: - { - ProfPrivateWin *privatewin = (ProfPrivateWin*)window; - assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK); - cl_ev_send_priv_msg(privatewin, clipboard_buffer, NULL); - break; - } - case WIN_CONSOLE: - case WIN_XML: - default: - cons_bad_cmd_usage(command); - break; + case WIN_MUC: + { + ProfMucWin* mucwin = (ProfMucWin*)window; + assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); + cl_ev_send_muc_msg(mucwin, clipboard_buffer, NULL); + break; + } + case WIN_CHAT: + { + ProfChatWin* chatwin = (ProfChatWin*)window; + assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); + cl_ev_send_msg(chatwin, clipboard_buffer, NULL); + break; + } + case WIN_PRIVATE: + { + ProfPrivateWin* privatewin = (ProfPrivateWin*)window; + assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK); + cl_ev_send_priv_msg(privatewin, clipboard_buffer, NULL); + break; + } + case WIN_CONSOLE: + case WIN_XML: + default: + cons_bad_cmd_usage(command); + break; } free(clipboard_buffer); @@ -8916,16 +8880,16 @@ cmd_paste(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_color(ProfWin *window, const char *const command, gchar **args) +cmd_color(ProfWin* window, const char* const command, gchar** args) { if (g_strcmp0(args[0], "on") == 0) { - prefs_set_string(PREF_COLOR_NICK, "true"); + prefs_set_string(PREF_COLOR_NICK, "true"); } else if (g_strcmp0(args[0], "off") == 0) { - prefs_set_string(PREF_COLOR_NICK, "false"); + prefs_set_string(PREF_COLOR_NICK, "false"); } else if (g_strcmp0(args[0], "redgreen") == 0) { - prefs_set_string(PREF_COLOR_NICK, "redgreen"); + prefs_set_string(PREF_COLOR_NICK, "redgreen"); } else if (g_strcmp0(args[0], "blue") == 0) { - prefs_set_string(PREF_COLOR_NICK, "blue"); + prefs_set_string(PREF_COLOR_NICK, "blue"); } else if (g_strcmp0(args[0], "own") == 0) { if (g_strcmp0(args[1], "on") == 0) { _cmd_set_boolean_preference(args[1], command, "Color generation for own nick", PREF_COLOR_NICK_OWN); @@ -8937,7 +8901,7 @@ cmd_color(ProfWin *window, const char *const command, gchar **args) cons_show("Consistent color generation for nicks set to: %s", args[0]); - char *theme = prefs_get_string(PREF_THEME); + char* theme = prefs_get_string(PREF_THEME); if (theme) { gboolean res = theme_load(theme, false); @@ -8954,7 +8918,7 @@ cmd_color(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_avatar(ProfWin *window, const char *const command, gchar **args) +cmd_avatar(ProfWin* window, const char* const command, gchar** args) { if (args[1] == NULL) { cons_bad_cmd_usage(command); @@ -8974,7 +8938,7 @@ cmd_avatar(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_os(ProfWin *window, const char *const command, gchar **args) +cmd_os(ProfWin* window, const char* const command, gchar** args) { _cmd_set_boolean_preference(args[0], command, "Revealing OS name", PREF_REVEAL_OS); @@ -8982,7 +8946,7 @@ cmd_os(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_correction(ProfWin *window, const char *const command, gchar **args) +cmd_correction(ProfWin* window, const char* const command, gchar** args) { // enable/disable if (g_strcmp0(args[0], "on") == 0) { @@ -9011,7 +8975,7 @@ cmd_correction(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_correct(ProfWin *window, const char *const command, gchar **args) +cmd_correct(ProfWin* window, const char* const command, gchar** args) { jabber_conn_status_t conn_status = connection_get_status(); if (conn_status != JABBER_CONNECTED) { @@ -9025,7 +8989,7 @@ cmd_correct(ProfWin *window, const char *const command, gchar **args) } if (window->type == WIN_CHAT) { - ProfChatWin *chatwin = (ProfChatWin*)window; + ProfChatWin* chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); if (chatwin->last_msg_id == NULL || chatwin->last_message == NULL) { @@ -9034,13 +8998,13 @@ cmd_correct(ProfWin *window, const char *const command, gchar **args) } // send message again, with replace flag - gchar *message = g_strjoinv(" ", args); + gchar* message = g_strjoinv(" ", args); cl_ev_send_msg_correct(chatwin, message, FALSE, TRUE); free(message); return TRUE; } else if (window->type == WIN_MUC) { - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); if (mucwin->last_msg_id == NULL || mucwin->last_message == NULL) { @@ -9049,7 +9013,7 @@ cmd_correct(ProfWin *window, const char *const command, gchar **args) } // send message again, with replace flag - gchar *message = g_strjoinv(" ", args); + gchar* message = g_strjoinv(" ", args); cl_ev_send_muc_msg_corrected(mucwin, message, FALSE, TRUE); free(message); @@ -9061,7 +9025,7 @@ cmd_correct(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_slashguard(ProfWin *window, const char *const command, gchar **args) +cmd_slashguard(ProfWin* window, const char* const command, gchar** args) { if (args[0] == NULL) { return FALSE; @@ -9073,11 +9037,9 @@ cmd_slashguard(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_url_open(ProfWin *window, const char *const command, gchar **args) +cmd_url_open(ProfWin* window, const char* const command, gchar** args) { - if (window->type != WIN_CHAT && - window->type != WIN_MUC && - window->type != WIN_PRIVATE) { + if (window->type != WIN_CHAT && window->type != WIN_MUC && window->type != WIN_PRIVATE) { cons_show("url open not supported in this window"); return TRUE; } @@ -9089,37 +9051,35 @@ cmd_url_open(ProfWin *window, const char *const command, gchar **args) gboolean require_save = false; - gchar *fileStart = g_strrstr(args[1], "/"); + gchar* fileStart = g_strrstr(args[1], "/"); if (fileStart == NULL) { cons_show("URL '%s' is not valid.", args[1]); return TRUE; } fileStart++; - if (((char*)(fileStart - 2))[0] == '/' && - ((char*)(fileStart - 3))[0] == ':' - ){ - // If the '/' is last character of the '://' string, there will be no suffix - // Therefore, it is considered that there is no file name in the URL and - // fileStart is set to the end of the URL. - fileStart = args[1] + strlen(args[1]); + if (((char*)(fileStart - 2))[0] == '/' && ((char*)(fileStart - 3))[0] == ':') { + // If the '/' is last character of the '://' string, there will be no suffix + // Therefore, it is considered that there is no file name in the URL and + // fileStart is set to the end of the URL. + fileStart = args[1] + strlen(args[1]); } - gchar *suffix = NULL; - gchar *suffixStart = g_strrstr(fileStart, "."); + gchar* suffix = NULL; + gchar* suffixStart = g_strrstr(fileStart, "."); if (suffixStart != NULL) { suffixStart++; - gchar *suffixEnd = g_strrstr(suffixStart, "#"); - if(suffixEnd == NULL) { + gchar* suffixEnd = g_strrstr(suffixStart, "#"); + if (suffixEnd == NULL) { suffix = g_strdup(suffixStart); } else { suffix = g_strndup(suffixStart, suffixEnd - suffixStart); } } - gchar **suffix_cmd_pref = prefs_get_string_list_with_option(PREF_URL_OPEN_CMD, NULL); + gchar** suffix_cmd_pref = prefs_get_string_list_with_option(PREF_URL_OPEN_CMD, NULL); if (suffix != NULL) { - gchar *lowercase_suffix = g_ascii_strdown(suffix, -1); + gchar* lowercase_suffix = g_ascii_strdown(suffix, -1); g_strfreev(suffix_cmd_pref); suffix_cmd_pref = prefs_get_string_list_with_option(PREF_URL_OPEN_CMD, lowercase_suffix); g_free(lowercase_suffix); @@ -9130,21 +9090,21 @@ cmd_url_open(ProfWin *window, const char *const command, gchar **args) require_save = true; } - gchar *suffix_cmd = g_strdup(suffix_cmd_pref[1]); + gchar* suffix_cmd = g_strdup(suffix_cmd_pref[1]); g_strfreev(suffix_cmd_pref); - gchar *scheme = g_uri_parse_scheme(args[1]); - if( 0 == g_strcmp0(scheme, "aesgcm")) { + gchar* scheme = g_uri_parse_scheme(args[1]); + if (0 == g_strcmp0(scheme, "aesgcm")) { require_save = true; } g_free(scheme); if (require_save) { - gchar *save_args[] = { "open", args[1], "/tmp/profanity.tmp", NULL}; + gchar* save_args[] = { "open", args[1], "/tmp/profanity.tmp", NULL }; cmd_url_save(window, command, save_args); } - gchar **argv = g_strsplit(suffix_cmd, " ", 0); + gchar** argv = g_strsplit(suffix_cmd, " ", 0); guint num_args = 0; while (argv[num_args]) { if (0 == g_strcmp0(argv[num_args], "%u")) { @@ -9174,11 +9134,9 @@ cmd_url_open(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_url_save(ProfWin *window, const char *const command, gchar **args) +cmd_url_save(ProfWin* window, const char* const command, gchar** args) { - if (window->type != WIN_CHAT && - window->type != WIN_MUC && - window->type != WIN_PRIVATE) { + if (window->type != WIN_CHAT && window->type != WIN_MUC && window->type != WIN_PRIVATE) { cons_show("url save not supported in this window"); return TRUE; } @@ -9188,27 +9146,25 @@ cmd_url_save(ProfWin *window, const char *const command, gchar **args) return TRUE; } - gchar *uri = args[1]; - gchar *target_path = g_strdup(args[2]); + gchar* uri = args[1]; + gchar* target_path = g_strdup(args[2]); - GFile *file = g_file_new_for_uri(uri); + GFile* file = g_file_new_for_uri(uri); - gchar *target_dir = NULL; - gchar *base_name = NULL; + gchar* target_dir = NULL; + gchar* base_name = NULL; if (target_path == NULL) { target_dir = g_strdup("./"); base_name = g_file_get_basename(file); if (0 == g_strcmp0(base_name, ".")) { - g_free(base_name); - base_name = g_strdup("saved_url_content.html"); + g_free(base_name); + base_name = g_strdup("saved_url_content.html"); } target_path = g_strconcat(target_dir, base_name, NULL); } - if (g_file_test(target_path, G_FILE_TEST_EXISTS) && - g_file_test(target_path, G_FILE_TEST_IS_DIR) - ) { + if (g_file_test(target_path, G_FILE_TEST_EXISTS) && g_file_test(target_path, G_FILE_TEST_IS_DIR)) { target_dir = g_strdup(target_path); base_name = g_file_get_basename(file); g_free(target_path); @@ -9223,8 +9179,7 @@ cmd_url_save(ProfWin *window, const char *const command, gchar **args) target_dir = g_path_get_dirname(target_path); } - if (!g_file_test(target_dir, G_FILE_TEST_EXISTS) || - !g_file_test(target_dir, G_FILE_TEST_IS_DIR)) { + if (!g_file_test(target_dir, G_FILE_TEST_EXISTS) || !g_file_test(target_dir, G_FILE_TEST_IS_DIR)) { cons_show("%s does not exist or is not a directory.", target_dir); g_free(target_path); g_free(target_dir); @@ -9232,7 +9187,7 @@ cmd_url_save(ProfWin *window, const char *const command, gchar **args) return TRUE; } - gchar *scheme = g_uri_parse_scheme(uri); + gchar* scheme = g_uri_parse_scheme(uri); if (scheme == NULL) { cons_show("URL '%s' is not valid.", uri); g_free(target_path); @@ -9241,18 +9196,17 @@ cmd_url_save(ProfWin *window, const char *const command, gchar **args) return TRUE; } - gchar *scheme_cmd = NULL; + gchar* scheme_cmd = NULL; if (0 == g_strcmp0(scheme, "http") || 0 == g_strcmp0(scheme, "https") - || 0 == g_strcmp0(scheme, "aesgcm") - ) { + || 0 == g_strcmp0(scheme, "aesgcm")) { scheme_cmd = prefs_get_string_with_option(PREF_URL_SAVE_CMD, scheme); } g_free(scheme); - gchar **argv = g_strsplit(scheme_cmd, " ", 0); + gchar** argv = g_strsplit(scheme_cmd, " ", 0); g_free(scheme_cmd); guint num_args = 0; @@ -9281,7 +9235,7 @@ cmd_url_save(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_executable(ProfWin *window, const char *const command, gchar **args) +cmd_executable(ProfWin* window, const char* const command, gchar** args) { if (g_strcmp0(args[0], "avatar") == 0) { prefs_set_string(PREF_AVATAR_CMD, args[1]); @@ -9292,8 +9246,8 @@ cmd_executable(ProfWin *window, const char *const command, gchar **args) return TRUE; } - gchar *str = g_strjoinv(" ", &args[3]); - const gchar* const list[] = {args[2], str, NULL}; + gchar* str = g_strjoinv(" ", &args[3]); + const gchar* const list[] = { args[2], str, NULL }; prefs_set_string_list_with_option(PREF_URL_OPEN_CMD, args[1], list); cons_show("`url open` command set to: %s for %s files", str, args[1]); g_free(str); @@ -9303,7 +9257,7 @@ cmd_executable(ProfWin *window, const char *const command, gchar **args) return TRUE; } - gchar *str = g_strjoinv(" ", &args[2]); + gchar* str = g_strjoinv(" ", &args[2]); prefs_set_string_with_option(PREF_URL_SAVE_CMD, args[1], str); cons_show("`url save` command set to: %s for scheme %s", str, args[1]); g_free(str); diff --git a/src/command/cmd_funcs.h b/src/command/cmd_funcs.h index 955a2e39..30059fc2 100644 --- a/src/command/cmd_funcs.h +++ b/src/command/cmd_funcs.h @@ -40,12 +40,13 @@ #include "ui/win_types.h" // Command help strings -typedef struct cmd_help_t { - gchar *tags[20]; - gchar *synopsis[50]; - gchar *desc; - gchar *args[128][2]; - gchar *examples[20]; +typedef struct cmd_help_t +{ + gchar* tags[20]; + gchar* synopsis[50]; + gchar* desc; + gchar* args[128][2]; + gchar* examples[20]; } CommandHelp; /* @@ -60,184 +61,184 @@ typedef struct cmd_help_t { * func - Main function to call when no arguments, or sub_funcs not implemented * help - A help struct containing usage info etc */ -typedef struct cmd_t { - gchar *cmd; - gchar** (*parser)(const char *const inp, int min, int max, gboolean *result); +typedef struct cmd_t +{ + gchar* cmd; + gchar** (*parser)(const char* const inp, int min, int max, gboolean* result); int min_args; int max_args; void (*setting_func)(void); - void *sub_funcs[50][2]; - gboolean (*func)(ProfWin *window, const char *const command, gchar **args); + void* sub_funcs[50][2]; + gboolean (*func)(ProfWin* window, const char* const command, gchar** args); CommandHelp help; } Command; - -gboolean cmd_process_input(ProfWin *window, char *inp); -void cmd_execute_connect(ProfWin *window, const char *const account); - -gboolean cmd_about(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_autoaway(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_autoconnect(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_autoping(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_beep(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_caps(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_logging(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_clear(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_close(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_connect(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_disco(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_sendfile(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_lastactivity(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_disconnect(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_flash(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_tray(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_gone(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_group(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_help(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_history(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_carbons(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_receipts(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_info(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_intype(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_invite(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_join(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_leave(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_log(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_msg(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_nick(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_notify(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_pgp(ProfWin *window, const char *const command, gchar **args); +gboolean cmd_process_input(ProfWin* window, char* inp); +void cmd_execute_connect(ProfWin* window, const char* const account); + +gboolean cmd_about(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_autoaway(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_autoconnect(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_autoping(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_beep(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_caps(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_logging(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_clear(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_close(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_connect(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_disco(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_sendfile(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_lastactivity(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_disconnect(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_flash(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_tray(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_gone(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_group(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_help(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_history(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_carbons(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_receipts(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_info(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_intype(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_invite(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_join(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_leave(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_log(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_msg(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_nick(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_notify(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_pgp(ProfWin* window, const char* const command, gchar** args); #ifdef HAVE_LIBGPGME -gboolean cmd_ox(ProfWin *window, const char *const command, gchar **args); +gboolean cmd_ox(ProfWin* window, const char* const command, gchar** args); #endif // HAVE_LIBGPGME -gboolean cmd_outtype(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_prefs(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_priority(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_quit(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_reconnect(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_room(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_rooms(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_bookmark(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_bookmark_ignore(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_roster(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_software(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_splash(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_states(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_status_get(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_status_set(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_sub(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_theme(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_tiny(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_wintitle(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_vercheck(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_who(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_win(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_alias(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_xmlconsole(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_ping(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_form(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_occupants(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_kick(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_ban(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_subject(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_affiliation(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_role(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_privileges(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_presence(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_wrap(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_time(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_resource(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_inpblock(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_titlebar(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_titlebar_show_hide(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_mainwin(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_statusbar(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_inputwin(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_script(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_export(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_charset(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_console(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_command_list(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_command_exec(ProfWin *window, const char *const command, gchar **args); - -gboolean cmd_plugins(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_plugins_sourcepath(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_plugins_install(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_plugins_update(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_plugins_uninstall(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_plugins_load(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_plugins_unload(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_plugins_reload(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_plugins_python_version(ProfWin *window, const char *const command, gchar **args); - -gboolean cmd_blocked(ProfWin *window, const char *const command, gchar **args); - -gboolean cmd_account(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_account_list(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_account_show(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_account_add(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_account_remove(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_account_enable(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_account_disable(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_account_rename(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_account_default(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_account_set(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_account_clear(ProfWin *window, const char *const command, gchar **args); - -gboolean cmd_tls_certpath(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_tls_trust(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_tls_trusted(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_tls_revoke(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_tls_cert(ProfWin *window, const char *const command, gchar **args); - -gboolean cmd_otr_char(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_otr_log(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_otr_libver(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_otr_policy(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_otr_gen(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_otr_myfp(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_otr_theirfp(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_otr_start(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_otr_end(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_otr_trust(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_otr_untrust(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_otr_secret(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_otr_question(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_otr_answer(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_otr_sendfile(ProfWin *window, const char *const command, gchar **args); - -gboolean cmd_wins(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_wins_unread(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_wins_prune(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_wins_swap(ProfWin *window, const char *const command, gchar **args); - -gboolean cmd_form_field(ProfWin *window, char *tag, gchar **args); - -gboolean cmd_omemo_gen(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_omemo_char(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_omemo_log(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_omemo_start(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_omemo_end(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_omemo_fingerprint(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_omemo_trust(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_omemo_untrust(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_omemo_policy(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_omemo_clear_device_list(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_omemo_sendfile(ProfWin *window, const char *const command, gchar **args); - -gboolean cmd_save(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_reload(ProfWin *window, const char *const command, gchar **args); - -gboolean cmd_paste(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_color(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_avatar(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_os(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_correction(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_correct(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_slashguard(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_serversoftware(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_url_open(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_url_save(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_executable(ProfWin *window, const char *const command, gchar **args); +gboolean cmd_outtype(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_prefs(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_priority(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_quit(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_reconnect(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_room(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_rooms(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_bookmark(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_bookmark_ignore(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_roster(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_software(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_splash(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_states(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_status_get(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_status_set(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_sub(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_theme(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_tiny(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_wintitle(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_vercheck(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_who(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_win(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_alias(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_xmlconsole(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_ping(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_form(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_occupants(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_kick(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_ban(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_subject(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_affiliation(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_role(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_privileges(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_presence(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_wrap(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_time(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_resource(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_inpblock(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_titlebar(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_titlebar_show_hide(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_mainwin(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_statusbar(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_inputwin(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_script(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_export(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_charset(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_console(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_command_list(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_command_exec(ProfWin* window, const char* const command, gchar** args); + +gboolean cmd_plugins(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_plugins_sourcepath(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_plugins_install(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_plugins_update(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_plugins_uninstall(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_plugins_load(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_plugins_unload(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_plugins_reload(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_plugins_python_version(ProfWin* window, const char* const command, gchar** args); + +gboolean cmd_blocked(ProfWin* window, const char* const command, gchar** args); + +gboolean cmd_account(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_account_list(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_account_show(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_account_add(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_account_remove(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_account_enable(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_account_disable(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_account_rename(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_account_default(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_account_set(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_account_clear(ProfWin* window, const char* const command, gchar** args); + +gboolean cmd_tls_certpath(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_tls_trust(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_tls_trusted(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_tls_revoke(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_tls_cert(ProfWin* window, const char* const command, gchar** args); + +gboolean cmd_otr_char(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_otr_log(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_otr_libver(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_otr_policy(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_otr_gen(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_otr_myfp(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_otr_theirfp(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_otr_start(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_otr_end(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_otr_trust(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_otr_untrust(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_otr_secret(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_otr_question(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_otr_answer(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_otr_sendfile(ProfWin* window, const char* const command, gchar** args); + +gboolean cmd_wins(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_wins_unread(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_wins_prune(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_wins_swap(ProfWin* window, const char* const command, gchar** args); + +gboolean cmd_form_field(ProfWin* window, char* tag, gchar** args); + +gboolean cmd_omemo_gen(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_omemo_char(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_omemo_log(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_omemo_start(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_omemo_end(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_omemo_fingerprint(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_omemo_trust(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_omemo_untrust(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_omemo_policy(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_omemo_clear_device_list(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_omemo_sendfile(ProfWin* window, const char* const command, gchar** args); + +gboolean cmd_save(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_reload(ProfWin* window, const char* const command, gchar** args); + +gboolean cmd_paste(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_color(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_avatar(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_os(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_correction(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_correct(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_slashguard(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_serversoftware(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_url_open(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_url_save(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_executable(ProfWin* window, const char* const command, gchar** args); #endif diff --git a/src/common.c b/src/common.c index 27e5aeee..5825c0ca 100644 --- a/src/common.c +++ b/src/common.c @@ -61,14 +61,14 @@ struct curl_data_t { - char *buffer; + char* buffer; size_t size; }; -static size_t _data_callback(void *ptr, size_t size, size_t nmemb, void *data); +static size_t _data_callback(void* ptr, size_t size, size_t nmemb, void* data); gboolean -create_dir(char *name) +create_dir(char* name) { struct stat sb; @@ -87,14 +87,14 @@ create_dir(char *name) } gboolean -mkdir_recursive(const char *dir) +mkdir_recursive(const char* dir) { int i; gboolean result = TRUE; for (i = 1; i <= strlen(dir); i++) { if (dir[i] == '/' || dir[i] == '\0') { - gchar *next_dir = g_strndup(dir, i); + gchar* next_dir = g_strndup(dir, i); result = create_dir(next_dir); g_free(next_dir); if (!result) { @@ -107,13 +107,13 @@ mkdir_recursive(const char *dir) } gboolean -copy_file(const char *const sourcepath, const char *const targetpath, const gboolean overwrite_existing) +copy_file(const char* const sourcepath, const char* const targetpath, const gboolean overwrite_existing) { - GFile *source = g_file_new_for_path(sourcepath); - GFile *dest = g_file_new_for_path(targetpath); - GError *error = NULL; + GFile* source = g_file_new_for_path(sourcepath); + GFile* dest = g_file_new_for_path(targetpath); + GError* error = NULL; GFileCopyFlags flags = overwrite_existing ? G_FILE_COPY_OVERWRITE : G_FILE_COPY_NONE; - gboolean success = g_file_copy (source, dest, flags, NULL, NULL, NULL, &error); + gboolean success = g_file_copy(source, dest, flags, NULL, NULL, NULL, &error); if (error != NULL) g_error_free(error); g_object_unref(source); @@ -122,44 +122,40 @@ copy_file(const char *const sourcepath, const char *const targetpath, const gboo } char* -str_replace(const char *string, const char *substr, - const char *replacement) +str_replace(const char* string, const char* substr, + const char* replacement) { - char *tok = NULL; - char *newstr = NULL; - char *head = NULL; + char* tok = NULL; + char* newstr = NULL; + char* head = NULL; if (string == NULL) return NULL; - if ( substr == NULL || - replacement == NULL || - (strcmp(substr, "") == 0)) - return strdup (string); + if (substr == NULL || replacement == NULL || (strcmp(substr, "") == 0)) + return strdup(string); - newstr = strdup (string); + newstr = strdup(string); head = newstr; - while ( (tok = strstr ( head, substr ))) { - char *oldstr = newstr; - newstr = malloc ( strlen ( oldstr ) - strlen ( substr ) + - strlen ( replacement ) + 1 ); + while ((tok = strstr(head, substr))) { + char* oldstr = newstr; + newstr = malloc(strlen(oldstr) - strlen(substr) + strlen(replacement) + 1); - if ( newstr == NULL ) { - free (oldstr); + if (newstr == NULL) { + free(oldstr); return NULL; } - memcpy ( newstr, oldstr, tok - oldstr ); - memcpy ( newstr + (tok - oldstr), replacement, strlen ( replacement ) ); - memcpy ( newstr + (tok - oldstr) + strlen( replacement ), - tok + strlen ( substr ), - strlen ( oldstr ) - strlen ( substr ) - ( tok - oldstr ) ); - memset ( newstr + strlen ( oldstr ) - strlen ( substr ) + - strlen ( replacement ) , 0, 1 ); + memcpy(newstr, oldstr, tok - oldstr); + memcpy(newstr + (tok - oldstr), replacement, strlen(replacement)); + memcpy(newstr + (tok - oldstr) + strlen(replacement), + tok + strlen(substr), + strlen(oldstr) - strlen(substr) - (tok - oldstr)); + memset(newstr + strlen(oldstr) - strlen(substr) + strlen(replacement), 0, 1); - head = newstr + (tok - oldstr) + strlen( replacement ); - free (oldstr); + head = newstr + (tok - oldstr) + strlen(replacement); + free(oldstr); } return newstr; @@ -178,21 +174,21 @@ str_contains(const char str[], int size, char ch) } gboolean -strtoi_range(char *str, int *saveptr, int min, int max, char **err_msg) +strtoi_range(char* str, int* saveptr, int min, int max, char** err_msg) { - char *ptr; + char* ptr; int val; errno = 0; val = (int)strtol(str, &ptr, 0); if (errno != 0 || *str == '\0' || *ptr != '\0') { - GString *err_str = g_string_new(""); + GString* err_str = g_string_new(""); g_string_printf(err_str, "Could not convert \"%s\" to a number.", str); *err_msg = err_str->str; g_string_free(err_str, FALSE); return FALSE; } else if (val < min || val > max) { - GString *err_str = g_string_new(""); + GString* err_str = g_string_new(""); g_string_printf(err_str, "Value %s out of range. Must be in %d..%d.", str, min, max); *err_msg = err_str->str; g_string_free(err_str, FALSE); @@ -205,20 +201,20 @@ strtoi_range(char *str, int *saveptr, int min, int max, char **err_msg) } int -utf8_display_len(const char *const str) +utf8_display_len(const char* const str) { if (!str) { return 0; } int len = 0; - gchar *curr = g_utf8_offset_to_pointer(str, 0); + gchar* curr = g_utf8_offset_to_pointer(str, 0); while (*curr != '\0') { gunichar curru = g_utf8_get_char(curr); if (g_unichar_iswide(curru)) { len += 2; } else { - len ++; + len++; } curr = g_utf8_next_char(curr); } @@ -229,9 +225,9 @@ utf8_display_len(const char *const str) char* release_get_latest(void) { - char *url = "https://profanity-im.github.io/profanity_version.txt"; + char* url = "https://profanity-im.github.io/profanity_version.txt"; - CURL *handle = curl_easy_init(); + CURL* handle = curl_easy_init(); struct curl_data_t output; output.buffer = NULL; output.size = 0; @@ -239,7 +235,7 @@ release_get_latest(void) curl_easy_setopt(handle, CURLOPT_URL, url); curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, _data_callback); curl_easy_setopt(handle, CURLOPT_TIMEOUT, 2); - curl_easy_setopt(handle, CURLOPT_WRITEDATA, (void *)&output); + curl_easy_setopt(handle, CURLOPT_WRITEDATA, (void*)&output); curl_easy_perform(handle); curl_easy_cleanup(handle); @@ -253,14 +249,14 @@ release_get_latest(void) } gboolean -release_is_new(char *found_version) +release_is_new(char* found_version) { int curr_maj, curr_min, curr_patch, found_maj, found_min, found_patch; int parse_curr = sscanf(PACKAGE_VERSION, "%d.%d.%d", &curr_maj, &curr_min, - &curr_patch); + &curr_patch); int parse_found = sscanf(found_version, "%d.%d.%d", &found_maj, &found_min, - &found_patch); + &found_patch); if (parse_found == 3 && parse_curr == 3) { if (found_maj > curr_maj) { @@ -268,7 +264,7 @@ release_is_new(char *found_version) } else if (found_maj == curr_maj && found_min > curr_min) { return TRUE; } else if (found_maj == curr_maj && found_min == curr_min - && found_patch > curr_patch) { + && found_patch > curr_patch) { return TRUE; } else { return FALSE; @@ -279,26 +275,25 @@ release_is_new(char *found_version) } static size_t -_data_callback(void *ptr, size_t size, size_t nmemb, void *data) +_data_callback(void* ptr, size_t size, size_t nmemb, void* data) { size_t realsize = size * nmemb; - struct curl_data_t *mem = (struct curl_data_t *) data; + struct curl_data_t* mem = (struct curl_data_t*)data; mem->buffer = realloc(mem->buffer, mem->size + realsize + 1); - if ( mem->buffer ) - { - memcpy( &( mem->buffer[ mem->size ] ), ptr, realsize ); + if (mem->buffer) { + memcpy(&(mem->buffer[mem->size]), ptr, realsize); mem->size += realsize; - mem->buffer[ mem->size ] = 0; + mem->buffer[mem->size] = 0; } return realsize; } char* -get_file_or_linked(char *loc, char *basedir) +get_file_or_linked(char* loc, char* basedir) { - char *true_loc = NULL; + char* true_loc = NULL; // check for symlink if (g_file_test(loc, G_FILE_TEST_IS_SYMLINK)) { @@ -306,14 +301,14 @@ get_file_or_linked(char *loc, char *basedir) // if relative, add basedir if (!g_str_has_prefix(true_loc, "/") && !g_str_has_prefix(true_loc, "~")) { - GString *base_str = g_string_new(basedir); + GString* base_str = g_string_new(basedir); g_string_append(base_str, "/"); g_string_append(base_str, true_loc); free(true_loc); true_loc = base_str->str; g_string_free(base_str, FALSE); } - // use given location + // use given location } else { true_loc = strdup(loc); } @@ -322,21 +317,21 @@ get_file_or_linked(char *loc, char *basedir) } char* -strip_arg_quotes(const char *const input) +strip_arg_quotes(const char* const input) { - char *unquoted = strdup(input); + char* unquoted = strdup(input); // Remove starting quote if it exists - if(strchr(unquoted, '"')) { - if(strchr(unquoted, ' ') + 1 == strchr(unquoted, '"')) { - memmove(strchr(unquoted, '"'), strchr(unquoted, '"')+1, strchr(unquoted, '\0') - strchr(unquoted, '"')); + if (strchr(unquoted, '"')) { + if (strchr(unquoted, ' ') + 1 == strchr(unquoted, '"')) { + memmove(strchr(unquoted, '"'), strchr(unquoted, '"') + 1, strchr(unquoted, '\0') - strchr(unquoted, '"')); } } // Remove ending quote if it exists - if(strchr(unquoted, '"')) { - if(strchr(unquoted, '\0') - 1 == strchr(unquoted, '"')) { - memmove(strchr(unquoted, '"'), strchr(unquoted, '"')+1, strchr(unquoted, '\0') - strchr(unquoted, '"')); + if (strchr(unquoted, '"')) { + if (strchr(unquoted, '\0') - 1 == strchr(unquoted, '"')) { + memmove(strchr(unquoted, '"'), strchr(unquoted, '"') + 1, strchr(unquoted, '\0') - strchr(unquoted, '"')); } } @@ -362,23 +357,23 @@ is_notify_enabled(void) } GSList* -prof_occurrences(const char *const needle, const char *const haystack, int offset, gboolean whole_word, GSList **result) +prof_occurrences(const char* const needle, const char* const haystack, int offset, gboolean whole_word, GSList** result) { if (needle == NULL || haystack == NULL) { return *result; } - gchar *haystack_curr = g_utf8_offset_to_pointer(haystack, offset); + gchar* haystack_curr = g_utf8_offset_to_pointer(haystack, offset); if (g_str_has_prefix(haystack_curr, needle)) { if (whole_word) { gunichar before = 0; - gchar *haystack_before_ch = g_utf8_find_prev_char(haystack, haystack_curr); + gchar* haystack_before_ch = g_utf8_find_prev_char(haystack, haystack_curr); if (haystack_before_ch) { before = g_utf8_get_char(haystack_before_ch); } gunichar after = 0; - gchar *haystack_after_ch = haystack_curr + strlen(needle); + gchar* haystack_after_ch = haystack_curr + strlen(needle); if (haystack_after_ch[0] != '\0') { after = g_utf8_get_char(haystack_after_ch); } @@ -400,7 +395,7 @@ prof_occurrences(const char *const needle, const char *const haystack, int offse } int -is_regular_file(const char *path) +is_regular_file(const char* path) { struct stat st; int ret = stat(path, &st); @@ -412,7 +407,7 @@ is_regular_file(const char *path) } int -is_dir(const char *path) +is_dir(const char* path) { struct stat st; int ret = stat(path, &st); @@ -424,16 +419,16 @@ is_dir(const char *path) } void -get_file_paths_recursive(const char *path, GSList **contents) +get_file_paths_recursive(const char* path, GSList** contents) { if (!is_dir(path)) { return; } GDir* directory = g_dir_open(path, 0, NULL); - const gchar *entry = g_dir_read_name(directory); + const gchar* entry = g_dir_read_name(directory); while (entry) { - GString *full = g_string_new(path); + GString* full = g_string_new(path); if (!g_str_has_suffix(full->str, "/")) { g_string_append(full, "/"); } @@ -453,11 +448,11 @@ get_file_paths_recursive(const char *path, GSList **contents) char* get_random_string(int length) { - GRand *prng; - char *rand; + GRand* prng; + char* rand; char alphabet[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; - rand = calloc(length+1, sizeof(char)); + rand = calloc(length + 1, sizeof(char)); prng = g_rand_new(); @@ -471,11 +466,11 @@ get_random_string(int length) } GSList* -get_mentions(gboolean whole_word, gboolean case_sensitive, const char *const message, const char *const nick) +get_mentions(gboolean whole_word, gboolean case_sensitive, const char* const message, const char* const nick) { - GSList *mentions = NULL; - gchar *message_search = case_sensitive ? g_strdup(message) : g_utf8_strdown(message, -1); - gchar *mynick_search = case_sensitive ? g_strdup(nick) : g_utf8_strdown(nick, -1); + GSList* mentions = NULL; + gchar* message_search = case_sensitive ? g_strdup(message) : g_utf8_strdown(message, -1); + gchar* mynick_search = case_sensitive ? g_strdup(nick) : g_utf8_strdown(nick, -1); mentions = prof_occurrences(mynick_search, message_search, 0, whole_word, &mentions); @@ -504,16 +499,16 @@ get_mentions(gboolean whole_word, gboolean case_sensitive, const char *const mes * - FALSE otherwise */ gboolean -call_external(gchar **argv, gchar ***const output_ptr, gchar ***const error_ptr) +call_external(gchar** argv, gchar*** const output_ptr, gchar*** const error_ptr) { - gchar *stdout_str = NULL; - gchar **stdout_str_ptr = &stdout_str; - gchar *stderr_str = NULL; - gchar **stderr_str_ptr = &stderr_str; + gchar* stdout_str = NULL; + gchar** stdout_str_ptr = &stdout_str; + gchar* stderr_str = NULL; + gchar** stderr_str_ptr = &stderr_str; GSpawnFlags flags = G_SPAWN_SEARCH_PATH; gint status; - GError *error = NULL; - gchar *cmd = NULL; + GError* error = NULL; + gchar* cmd = NULL; cmd = g_strjoinv(" ", argv); log_debug("Calling external: %s", cmd); @@ -528,7 +523,7 @@ call_external(gchar **argv, gchar ***const output_ptr, gchar ***const error_ptr) flags |= G_SPAWN_STDERR_TO_DEV_NULL; } - if (!g_spawn_sync (NULL, argv, NULL, flags, NULL, NULL, stdout_str_ptr, stderr_str_ptr, &status, &error)) { + if (!g_spawn_sync(NULL, argv, NULL, flags, NULL, NULL, stdout_str_ptr, stderr_str_ptr, &status, &error)) { log_error("Spawning '%s' failed: %s.", cmd, error->message); g_error_free(error); error = NULL; diff --git a/src/common.h b/src/common.h index 93e4a609..588abd10 100644 --- a/src/common.h +++ b/src/common.h @@ -45,24 +45,23 @@ #define notify_notification_new(summary, body, icon) notify_notification_new(summary, body, icon, NULL) #endif -#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) +#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) // assume malloc stores at most 8 bytes for size of allocated memory // and page size is at least 4KB #define READ_BUF_SIZE 4088 - #define FREE_SET_NULL(resource) \ -do { \ - free(resource); \ - resource = NULL; \ -} while (0) + do { \ + free(resource); \ + resource = NULL; \ + } while (0) #define GFREE_SET_NULL(resource) \ -do { \ - g_free(resource); \ - resource = NULL; \ -} while (0) + do { \ + g_free(resource); \ + resource = NULL; \ + } while (0) typedef enum { CONTACT_OFFLINE, @@ -81,31 +80,31 @@ typedef enum { RESOURCE_XA } resource_presence_t; -gboolean create_dir(char *name); -gboolean mkdir_recursive(const char *dir); -gboolean copy_file(const char *const src, const char *const target, const gboolean overwrite_existing); -char* str_replace(const char *string, const char *substr, const char *replacement); +gboolean create_dir(char* name); +gboolean mkdir_recursive(const char* dir); +gboolean copy_file(const char* const src, const char* const target, const gboolean overwrite_existing); +char* str_replace(const char* string, const char* substr, const char* replacement); int str_contains(const char str[], int size, char ch); -gboolean strtoi_range(char *str, int *saveptr, int min, int max, char **err_msg); -int utf8_display_len(const char *const str); +gboolean strtoi_range(char* str, int* saveptr, int min, int max, char** err_msg); +int utf8_display_len(const char* const str); char* release_get_latest(void); -gboolean release_is_new(char *found_version); +gboolean release_is_new(char* found_version); -char* get_file_or_linked(char *loc, char *basedir); -char* strip_arg_quotes(const char *const input); +char* get_file_or_linked(char* loc, char* basedir); +char* strip_arg_quotes(const char* const input); gboolean is_notify_enabled(void); -GSList* prof_occurrences(const char *const needle, const char *const haystack, int offset, gboolean whole_word, - GSList **result); -GSList* get_mentions(gboolean whole_word, gboolean case_sensitive, const char *const message, const char *const nick); +GSList* prof_occurrences(const char* const needle, const char* const haystack, int offset, gboolean whole_word, + GSList** result); +GSList* get_mentions(gboolean whole_word, gboolean case_sensitive, const char* const message, const char* const nick); -int is_regular_file(const char *path); -int is_dir(const char *path); -void get_file_paths_recursive(const char *directory, GSList **contents); +int is_regular_file(const char* path); +int is_dir(const char* path); +void get_file_paths_recursive(const char* directory, GSList** contents); char* get_random_string(int length); -gboolean call_external(gchar **argv, gchar ***const output_ptr, gchar ***const error_ptr); +gboolean call_external(gchar** argv, gchar*** const output_ptr, gchar*** const error_ptr); #endif diff --git a/src/config/account.c b/src/config/account.c index 54d7b18e..c0f508b4 100644 --- a/src/config/account.c +++ b/src/config/account.c @@ -46,18 +46,18 @@ #include "xmpp/resource.h" ProfAccount* -account_new(const gchar *const name, const gchar *const jid, - const gchar *const password, const gchar *eval_password, gboolean enabled, const gchar *const server, - int port, const gchar *const resource, const gchar *const last_presence, - const gchar *const login_presence, int priority_online, int priority_chat, - int priority_away, int priority_xa, int priority_dnd, - const gchar *const muc_service, const gchar *const muc_nick, - const gchar *const otr_policy, GList *otr_manual, GList *otr_opportunistic, - GList *otr_always, const gchar *const omemo_policy, GList *omemo_enabled, - GList *omemo_disabled, const gchar *const pgp_keyid, const char *const startscript, - const char *const theme, gchar *tls_policy, gchar *auth_policy) +account_new(const gchar* const name, const gchar* const jid, + const gchar* const password, const gchar* eval_password, gboolean enabled, const gchar* const server, + int port, const gchar* const resource, const gchar* const last_presence, + const gchar* const login_presence, int priority_online, int priority_chat, + int priority_away, int priority_xa, int priority_dnd, + const gchar* const muc_service, const gchar* const muc_nick, + const gchar* const otr_policy, GList* otr_manual, GList* otr_opportunistic, + GList* otr_always, const gchar* const omemo_policy, GList* omemo_enabled, + GList* omemo_disabled, const gchar* const pgp_keyid, const char* const startscript, + const char* const theme, gchar* tls_policy, gchar* auth_policy) { - ProfAccount *new_account = malloc(sizeof(ProfAccount)); + ProfAccount* new_account = malloc(sizeof(ProfAccount)); memset(new_account, 0, sizeof(ProfAccount)); new_account->name = strdup(name); @@ -125,7 +125,7 @@ account_new(const gchar *const name, const gchar *const jid, } if (muc_nick == NULL) { - Jid *jidp = jid_create(new_account->jid); + Jid* jidp = jid_create(new_account->jid); new_account->muc_nick = strdup(jidp->domainpart); jid_destroy(jidp); } else { @@ -185,7 +185,7 @@ account_new(const gchar *const name, const gchar *const jid, } char* -account_create_connect_jid(ProfAccount *account) +account_create_connect_jid(ProfAccount* account) { if (account->resource) { return create_fulljid(account->jid, account->resource); @@ -195,15 +195,15 @@ account_create_connect_jid(ProfAccount *account) } gboolean -account_eval_password(ProfAccount *account) +account_eval_password(ProfAccount* account) { assert(account != NULL); assert(account->eval_password != NULL); - gchar **output = NULL; - gchar **error = NULL; + gchar** output = NULL; + gchar** error = NULL; - gchar *argv[] = {"sh", "-c", account->eval_password, NULL}; + gchar* argv[] = { "sh", "-c", account->eval_password, NULL }; if (!call_external(argv, &output, &error)) { return FALSE; } @@ -228,7 +228,7 @@ account_eval_password(ProfAccount *account) } void -account_free(ProfAccount *account) +account_free(ProfAccount* account) { if (account == NULL) { return; @@ -259,24 +259,28 @@ account_free(ProfAccount *account) free(account); } -void account_set_server(ProfAccount *account, const char *server) +void +account_set_server(ProfAccount* account, const char* server) { free(account->server); account->server = strdup(server); } -void account_set_port(ProfAccount *account, int port) +void +account_set_port(ProfAccount* account, int port) { account->port = port; } -void account_set_tls_policy(ProfAccount *account, const char *tls_policy) +void +account_set_tls_policy(ProfAccount* account, const char* tls_policy) { free(account->tls_policy); account->tls_policy = strdup(tls_policy); } -void account_set_auth_policy(ProfAccount *account, const char *auth_policy) +void +account_set_auth_policy(ProfAccount* account, const char* auth_policy) { free(account->auth_policy); account->auth_policy = strdup(auth_policy); diff --git a/src/config/account.h b/src/config/account.h index deb0e31a..dfc7bc12 100644 --- a/src/config/account.h +++ b/src/config/account.h @@ -38,54 +38,55 @@ #include "common.h" -typedef struct prof_account_t { - gchar *name; - gchar *jid; - gchar *password; - gchar *eval_password; - gchar *resource; - gchar *server; +typedef struct prof_account_t +{ + gchar* name; + gchar* jid; + gchar* password; + gchar* eval_password; + gchar* resource; + gchar* server; int port; - gchar *last_presence; - gchar *login_presence; + gchar* last_presence; + gchar* login_presence; gint priority_online; gint priority_chat; gint priority_away; gint priority_xa; gint priority_dnd; - gchar *muc_service; - gchar *muc_nick; + gchar* muc_service; + gchar* muc_nick; gboolean enabled; - gchar *otr_policy; - GList *otr_manual; - GList *otr_opportunistic; - GList *otr_always; - gchar *omemo_policy; - GList *omemo_enabled; - GList *omemo_disabled; - gchar *pgp_keyid; - gchar *startscript; - gchar *theme; - gchar *tls_policy; - gchar *auth_policy; + gchar* otr_policy; + GList* otr_manual; + GList* otr_opportunistic; + GList* otr_always; + gchar* omemo_policy; + GList* omemo_enabled; + GList* omemo_disabled; + gchar* pgp_keyid; + gchar* startscript; + gchar* theme; + gchar* tls_policy; + gchar* auth_policy; } ProfAccount; -ProfAccount* account_new(const gchar *const name, const gchar *const jid, - const gchar *const passord, const gchar *eval_password, gboolean enabled, const gchar *const server, - int port, const gchar *const resource, const gchar *const last_presence, - const gchar *const login_presence, int priority_online, int priority_chat, - int priority_away, int priority_xa, int priority_dnd, - const gchar *const muc_service, const gchar *const muc_nick, - const gchar *const otr_policy, GList *otr_manual, GList *otr_opportunistic, - GList *otr_always, const gchar *const omemo_policy, GList *omemo_enabled, - GList *omemo_disabled, const gchar *const pgp_keyid, const char *const startscript, - const char *const theme, gchar *tls_policy, gchar *auth_policy); -char* account_create_connect_jid(ProfAccount *account); -gboolean account_eval_password(ProfAccount *account); -void account_free(ProfAccount *account); -void account_set_server(ProfAccount *account, const char *server); -void account_set_port(ProfAccount *account, int port); -void account_set_tls_policy(ProfAccount *account, const char *tls_policy); -void account_set_auth_policy(ProfAccount *account, const char *auth_policy); +ProfAccount* account_new(const gchar* const name, const gchar* const jid, + const gchar* const passord, const gchar* eval_password, gboolean enabled, const gchar* const server, + int port, const gchar* const resource, const gchar* const last_presence, + const gchar* const login_presence, int priority_online, int priority_chat, + int priority_away, int priority_xa, int priority_dnd, + const gchar* const muc_service, const gchar* const muc_nick, + const gchar* const otr_policy, GList* otr_manual, GList* otr_opportunistic, + GList* otr_always, const gchar* const omemo_policy, GList* omemo_enabled, + GList* omemo_disabled, const gchar* const pgp_keyid, const char* const startscript, + const char* const theme, gchar* tls_policy, gchar* auth_policy); +char* account_create_connect_jid(ProfAccount* account); +gboolean account_eval_password(ProfAccount* account); +void account_free(ProfAccount* account); +void account_set_server(ProfAccount* account, const char* server); +void account_set_port(ProfAccount* account, int port); +void account_set_tls_policy(ProfAccount* account, const char* tls_policy); +void account_set_auth_policy(ProfAccount* account, const char* auth_policy); #endif diff --git a/src/config/accounts.c b/src/config/accounts.c index 92bf19d0..5539919b 100644 --- a/src/config/accounts.c +++ b/src/config/accounts.c @@ -50,8 +50,8 @@ #include "xmpp/xmpp.h" #include "xmpp/jid.h" -static char *accounts_loc; -static GKeyFile *accounts; +static char* accounts_loc; +static GKeyFile* accounts; static Autocomplete all_ac; static Autocomplete enabled_ac; @@ -75,7 +75,7 @@ accounts_load(void) // create the logins searchable list for autocompletion gsize naccounts; - gchar **account_names = g_key_file_get_groups(accounts, &naccounts); + gchar** account_names = g_key_file_get_groups(accounts, &naccounts); gsize i; for (i = 0; i < naccounts; i++) { @@ -97,13 +97,13 @@ accounts_close(void) } char* -accounts_find_enabled(const char *const prefix, gboolean previous, void *context) +accounts_find_enabled(const char* const prefix, gboolean previous, void* context) { return autocomplete_complete(enabled_ac, prefix, TRUE, previous); } char* -accounts_find_all(const char *const prefix, gboolean previous, void *context) +accounts_find_all(const char* const prefix, gboolean previous, void* context) { return autocomplete_complete(all_ac, prefix, TRUE, previous); } @@ -121,12 +121,12 @@ accounts_reset_enabled_search(void) } void -accounts_add(const char *account_name, const char *altdomain, const int port, const char *const tls_policy, const char *const auth_policy) +accounts_add(const char* account_name, const char* altdomain, const int port, const char* const tls_policy, const char* const auth_policy) { // set account name and resource - const char *barejid = account_name; - char *resource = jid_random_resource(); - Jid *jid = jid_create(account_name); + const char* barejid = account_name; + char* resource = jid_random_resource(); + Jid* jid = jid_create(account_name); if (jid) { barejid = jid->barejid; if (jid->resourcepart) { @@ -156,7 +156,7 @@ accounts_add(const char *account_name, const char *altdomain, const int port, co g_key_file_set_string(accounts, account_name, "auth.policy", auth_policy); } - Jid *jidp = jid_create(barejid); + Jid* jidp = jid_create(barejid); if (jidp->localpart == NULL) { g_key_file_set_string(accounts, account_name, "muc.nick", jidp->domainpart); @@ -183,7 +183,7 @@ accounts_add(const char *account_name, const char *altdomain, const int port, co } int -accounts_remove(const char *account_name) +accounts_remove(const char* account_name) { int r = g_key_file_remove_group(accounts, account_name, NULL); _save_accounts(); @@ -199,12 +199,12 @@ accounts_get_list(void) } ProfAccount* -accounts_get_account(const char *const name) +accounts_get_account(const char* const name) { if (!g_key_file_has_group(accounts, name)) { return NULL; } else { - gchar *jid = g_key_file_get_string(accounts, name, "jid", NULL); + gchar* jid = g_key_file_get_string(accounts, name, "jid", NULL); // fix accounts that have no jid property by setting to name if (jid == NULL) { @@ -212,16 +212,16 @@ accounts_get_account(const char *const name) _save_accounts(); } - gchar *password = g_key_file_get_string(accounts, name, "password", NULL); - gchar *eval_password = g_key_file_get_string(accounts, name, "eval_password", NULL); + gchar* password = g_key_file_get_string(accounts, name, "password", NULL); + gchar* eval_password = g_key_file_get_string(accounts, name, "eval_password", NULL); gboolean enabled = g_key_file_get_boolean(accounts, name, "enabled", NULL); - gchar *server = g_key_file_get_string(accounts, name, "server", NULL); - gchar *resource = g_key_file_get_string(accounts, name, "resource", NULL); + gchar* server = g_key_file_get_string(accounts, name, "server", NULL); + gchar* resource = g_key_file_get_string(accounts, name, "resource", NULL); int port = g_key_file_get_integer(accounts, name, "port", NULL); - gchar *last_presence = g_key_file_get_string(accounts, name, "presence.last", NULL); - gchar *login_presence = g_key_file_get_string(accounts, name, "presence.login", NULL); + gchar* last_presence = g_key_file_get_string(accounts, name, "presence.last", NULL); + gchar* login_presence = g_key_file_get_string(accounts, name, "presence.login", NULL); int priority_online = g_key_file_get_integer(accounts, name, "priority.online", NULL); int priority_chat = g_key_file_get_integer(accounts, name, "priority.chat", NULL); @@ -229,7 +229,7 @@ accounts_get_account(const char *const name) int priority_xa = g_key_file_get_integer(accounts, name, "priority.xa", NULL); int priority_dnd = g_key_file_get_integer(accounts, name, "priority.dnd", NULL); - gchar *muc_service = NULL; + gchar* muc_service = NULL; if (g_key_file_has_key(accounts, name, "muc.service", NULL)) { muc_service = g_key_file_get_string(accounts, name, "muc.service", NULL); } else { @@ -241,16 +241,16 @@ accounts_get_account(const char *const name) } } } - gchar *muc_nick = g_key_file_get_string(accounts, name, "muc.nick", NULL); + gchar* muc_nick = g_key_file_get_string(accounts, name, "muc.nick", NULL); - gchar *otr_policy = NULL; + gchar* otr_policy = NULL; if (g_key_file_has_key(accounts, name, "otr.policy", NULL)) { otr_policy = g_key_file_get_string(accounts, name, "otr.policy", NULL); } gsize length; - GList *otr_manual = NULL; - gchar **manual = g_key_file_get_string_list(accounts, name, "otr.manual", &length, NULL); + GList* otr_manual = NULL; + gchar** manual = g_key_file_get_string_list(accounts, name, "otr.manual", &length, NULL); if (manual) { int i = 0; for (i = 0; i < length; i++) { @@ -259,8 +259,8 @@ accounts_get_account(const char *const name) g_strfreev(manual); } - GList *otr_opportunistic = NULL; - gchar **opportunistic = g_key_file_get_string_list(accounts, name, "otr.opportunistic", &length, NULL); + GList* otr_opportunistic = NULL; + gchar** opportunistic = g_key_file_get_string_list(accounts, name, "otr.opportunistic", &length, NULL); if (opportunistic) { int i = 0; for (i = 0; i < length; i++) { @@ -269,8 +269,8 @@ accounts_get_account(const char *const name) g_strfreev(opportunistic); } - GList *otr_always = NULL; - gchar **always = g_key_file_get_string_list(accounts, name, "otr.always", &length, NULL); + GList* otr_always = NULL; + gchar** always = g_key_file_get_string_list(accounts, name, "otr.always", &length, NULL); if (always) { int i = 0; for (i = 0; i < length; i++) { @@ -279,13 +279,13 @@ accounts_get_account(const char *const name) g_strfreev(always); } - gchar *omemo_policy = NULL; + gchar* omemo_policy = NULL; if (g_key_file_has_key(accounts, name, "omemo.policy", NULL)) { omemo_policy = g_key_file_get_string(accounts, name, "omemo.policy", NULL); } - GList *omemo_enabled = NULL; - gchar **enabled_list = g_key_file_get_string_list(accounts, name, "omemo.enabled", &length, NULL); + GList* omemo_enabled = NULL; + gchar** enabled_list = g_key_file_get_string_list(accounts, name, "omemo.enabled", &length, NULL); if (enabled_list) { int i = 0; for (i = 0; i < length; i++) { @@ -294,8 +294,8 @@ accounts_get_account(const char *const name) g_strfreev(enabled_list); } - GList *omemo_disabled = NULL; - gchar **disabled_list = g_key_file_get_string_list(accounts, name, "omemo.disabled", &length, NULL); + GList* omemo_disabled = NULL; + gchar** disabled_list = g_key_file_get_string_list(accounts, name, "omemo.disabled", &length, NULL); if (disabled_list) { int i = 0; for (i = 0; i < length; i++) { @@ -304,40 +304,36 @@ accounts_get_account(const char *const name) g_strfreev(disabled_list); } - gchar *pgp_keyid = NULL; + gchar* pgp_keyid = NULL; if (g_key_file_has_key(accounts, name, "pgp.keyid", NULL)) { pgp_keyid = g_key_file_get_string(accounts, name, "pgp.keyid", NULL); } - gchar *startscript = NULL; + gchar* startscript = NULL; if (g_key_file_has_key(accounts, name, "script.start", NULL)) { startscript = g_key_file_get_string(accounts, name, "script.start", NULL); } - gchar *theme = NULL; + gchar* theme = NULL; if (g_key_file_has_key(accounts, name, "theme", NULL)) { theme = g_key_file_get_string(accounts, name, "theme", NULL); } - gchar *tls_policy = g_key_file_get_string(accounts, name, "tls.policy", NULL); - if (tls_policy && ((g_strcmp0(tls_policy, "force") != 0) && - (g_strcmp0(tls_policy, "allow") != 0) && - (g_strcmp0(tls_policy, "trust") != 0) && - (g_strcmp0(tls_policy, "disable") != 0) && - (g_strcmp0(tls_policy, "legacy") != 0))) { + gchar* tls_policy = g_key_file_get_string(accounts, name, "tls.policy", NULL); + if (tls_policy && ((g_strcmp0(tls_policy, "force") != 0) && (g_strcmp0(tls_policy, "allow") != 0) && (g_strcmp0(tls_policy, "trust") != 0) && (g_strcmp0(tls_policy, "disable") != 0) && (g_strcmp0(tls_policy, "legacy") != 0))) { g_free(tls_policy); tls_policy = NULL; } - gchar *auth_policy = g_key_file_get_string(accounts, name, "auth.policy", NULL); + gchar* auth_policy = g_key_file_get_string(accounts, name, "auth.policy", NULL); - ProfAccount *new_account = account_new(name, jid, password, eval_password, enabled, - server, port, resource, last_presence, login_presence, - priority_online, priority_chat, priority_away, priority_xa, - priority_dnd, muc_service, muc_nick, otr_policy, otr_manual, - otr_opportunistic, otr_always, omemo_policy, omemo_enabled, - omemo_disabled, pgp_keyid, startscript, theme, tls_policy, - auth_policy); + ProfAccount* new_account = account_new(name, jid, password, eval_password, enabled, + server, port, resource, last_presence, login_presence, + priority_online, priority_chat, priority_away, priority_xa, + priority_dnd, muc_service, muc_nick, otr_policy, otr_manual, + otr_opportunistic, otr_always, omemo_policy, omemo_enabled, + omemo_disabled, pgp_keyid, startscript, theme, tls_policy, + auth_policy); g_free(jid); g_free(password); @@ -361,7 +357,7 @@ accounts_get_account(const char *const name) } gboolean -accounts_enable(const char *const name) +accounts_enable(const char* const name) { if (g_key_file_has_group(accounts, name)) { g_key_file_set_boolean(accounts, name, "enabled", TRUE); @@ -374,7 +370,7 @@ accounts_enable(const char *const name) } gboolean -accounts_disable(const char *const name) +accounts_disable(const char* const name) { if (g_key_file_has_group(accounts, name)) { g_key_file_set_boolean(accounts, name, "enabled", FALSE); @@ -387,7 +383,7 @@ accounts_disable(const char *const name) } gboolean -accounts_rename(const char *const account_name, const char *const new_name) +accounts_rename(const char* const account_name, const char* const new_name) { if (g_key_file_has_group(accounts, new_name)) { return FALSE; @@ -398,7 +394,7 @@ accounts_rename(const char *const account_name, const char *const new_name) } // treat all properties as strings for copy - gchar *string_keys[] = { + gchar* string_keys[] = { "enabled", "jid", "server", @@ -431,7 +427,7 @@ accounts_rename(const char *const account_name, const char *const new_name) int i; for (i = 0; i < ARRAY_SIZE(string_keys); i++) { - char *value = g_key_file_get_string(accounts, account_name, string_keys[i], NULL); + char* value = g_key_file_get_string(accounts, account_name, string_keys[i], NULL); if (value) { g_key_file_set_string(accounts, new_name, string_keys[i], value); g_free(value); @@ -452,16 +448,15 @@ accounts_rename(const char *const account_name, const char *const new_name) } gboolean -accounts_account_exists(const char *const account_name) +accounts_account_exists(const char* const account_name) { return g_key_file_has_group(accounts, account_name); - } void -accounts_set_jid(const char *const account_name, const char *const value) +accounts_set_jid(const char* const account_name, const char* const value) { - Jid *jid = jid_create(value); + Jid* jid = jid_create(value); if (jid) { if (accounts_account_exists(account_name)) { g_key_file_set_string(accounts, account_name, "jid", jid->barejid); @@ -483,7 +478,7 @@ accounts_set_jid(const char *const account_name, const char *const value) } void -accounts_set_server(const char *const account_name, const char *const value) +accounts_set_server(const char* const account_name, const char* const value) { if (accounts_account_exists(account_name)) { g_key_file_set_string(accounts, account_name, "server", value); @@ -492,7 +487,7 @@ accounts_set_server(const char *const account_name, const char *const value) } void -accounts_set_port(const char *const account_name, const int value) +accounts_set_port(const char* const account_name, const int value) { if (value != 0) { g_key_file_set_integer(accounts, account_name, "port", value); @@ -501,7 +496,7 @@ accounts_set_port(const char *const account_name, const int value) } void -accounts_set_resource(const char *const account_name, const char *const value) +accounts_set_resource(const char* const account_name, const char* const value) { if (accounts_account_exists(account_name)) { g_key_file_set_string(accounts, account_name, "resource", value); @@ -510,7 +505,7 @@ accounts_set_resource(const char *const account_name, const char *const value) } void -accounts_set_password(const char *const account_name, const char *const value) +accounts_set_password(const char* const account_name, const char* const value) { if (accounts_account_exists(account_name)) { g_key_file_set_string(accounts, account_name, "password", value); @@ -519,7 +514,7 @@ accounts_set_password(const char *const account_name, const char *const value) } void -accounts_set_eval_password(const char *const account_name, const char *const value) +accounts_set_eval_password(const char* const account_name, const char* const value) { if (accounts_account_exists(account_name)) { g_key_file_set_string(accounts, account_name, "eval_password", value); @@ -528,7 +523,7 @@ accounts_set_eval_password(const char *const account_name, const char *const val } void -accounts_set_pgp_keyid(const char *const account_name, const char *const value) +accounts_set_pgp_keyid(const char* const account_name, const char* const value) { if (accounts_account_exists(account_name)) { g_key_file_set_string(accounts, account_name, "pgp.keyid", value); @@ -537,7 +532,7 @@ accounts_set_pgp_keyid(const char *const account_name, const char *const value) } void -accounts_set_script_start(const char *const account_name, const char *const value) +accounts_set_script_start(const char* const account_name, const char* const value) { if (accounts_account_exists(account_name)) { g_key_file_set_string(accounts, account_name, "script.start", value); @@ -546,7 +541,7 @@ accounts_set_script_start(const char *const account_name, const char *const valu } void -accounts_set_theme(const char *const account_name, const char *const value) +accounts_set_theme(const char* const account_name, const char* const value) { if (accounts_account_exists(account_name)) { g_key_file_set_string(accounts, account_name, "theme", value); @@ -555,7 +550,7 @@ accounts_set_theme(const char *const account_name, const char *const value) } void -accounts_clear_password(const char *const account_name) +accounts_clear_password(const char* const account_name) { if (accounts_account_exists(account_name)) { g_key_file_remove_key(accounts, account_name, "password", NULL); @@ -564,7 +559,7 @@ accounts_clear_password(const char *const account_name) } void -accounts_clear_eval_password(const char *const account_name) +accounts_clear_eval_password(const char* const account_name) { if (accounts_account_exists(account_name)) { g_key_file_remove_key(accounts, account_name, "eval_password", NULL); @@ -573,7 +568,7 @@ accounts_clear_eval_password(const char *const account_name) } void -accounts_clear_server(const char *const account_name) +accounts_clear_server(const char* const account_name) { if (accounts_account_exists(account_name)) { g_key_file_remove_key(accounts, account_name, "server", NULL); @@ -582,7 +577,7 @@ accounts_clear_server(const char *const account_name) } void -accounts_clear_port(const char *const account_name) +accounts_clear_port(const char* const account_name) { if (accounts_account_exists(account_name)) { g_key_file_remove_key(accounts, account_name, "port", NULL); @@ -591,7 +586,7 @@ accounts_clear_port(const char *const account_name) } void -accounts_clear_pgp_keyid(const char *const account_name) +accounts_clear_pgp_keyid(const char* const account_name) { if (accounts_account_exists(account_name)) { g_key_file_remove_key(accounts, account_name, "pgp.keyid", NULL); @@ -600,7 +595,7 @@ accounts_clear_pgp_keyid(const char *const account_name) } void -accounts_clear_script_start(const char *const account_name) +accounts_clear_script_start(const char* const account_name) { if (accounts_account_exists(account_name)) { g_key_file_remove_key(accounts, account_name, "script.start", NULL); @@ -609,7 +604,7 @@ accounts_clear_script_start(const char *const account_name) } void -accounts_clear_theme(const char *const account_name) +accounts_clear_theme(const char* const account_name) { if (accounts_account_exists(account_name)) { g_key_file_remove_key(accounts, account_name, "theme", NULL); @@ -618,7 +613,7 @@ accounts_clear_theme(const char *const account_name) } void -accounts_clear_muc(const char *const account_name) +accounts_clear_muc(const char* const account_name) { if (accounts_account_exists(account_name)) { g_key_file_remove_key(accounts, account_name, "muc.service", NULL); @@ -627,7 +622,7 @@ accounts_clear_muc(const char *const account_name) } void -accounts_clear_resource(const char *const account_name) +accounts_clear_resource(const char* const account_name) { if (accounts_account_exists(account_name)) { g_key_file_remove_key(accounts, account_name, "resource", NULL); @@ -636,7 +631,7 @@ accounts_clear_resource(const char *const account_name) } void -accounts_clear_otr(const char *const account_name) +accounts_clear_otr(const char* const account_name) { if (accounts_account_exists(account_name)) { g_key_file_remove_key(accounts, account_name, "otr.policy", NULL); @@ -645,10 +640,10 @@ accounts_clear_otr(const char *const account_name) } void -accounts_add_otr_policy(const char *const account_name, const char *const contact_jid, const char *const policy) +accounts_add_otr_policy(const char* const account_name, const char* const contact_jid, const char* const policy) { if (accounts_account_exists(account_name)) { - GString *key = g_string_new("otr."); + GString* key = g_string_new("otr."); g_string_append(key, policy); conf_string_list_add(accounts, account_name, key->str, contact_jid); g_string_free(key, TRUE); @@ -672,7 +667,7 @@ accounts_add_otr_policy(const char *const account_name, const char *const contac } void -accounts_add_omemo_state(const char *const account_name, const char *const contact_jid, gboolean enabled) +accounts_add_omemo_state(const char* const account_name, const char* const contact_jid, gboolean enabled) { if (accounts_account_exists(account_name)) { if (enabled) { @@ -688,7 +683,7 @@ accounts_add_omemo_state(const char *const account_name, const char *const conta } void -accounts_clear_omemo_state(const char *const account_name, const char *const contact_jid) +accounts_clear_omemo_state(const char* const account_name, const char* const contact_jid) { if (accounts_account_exists(account_name)) { conf_string_list_remove(accounts, account_name, "omemo.enabled", contact_jid); @@ -698,7 +693,7 @@ accounts_clear_omemo_state(const char *const account_name, const char *const con } void -accounts_set_muc_service(const char *const account_name, const char *const value) +accounts_set_muc_service(const char* const account_name, const char* const value) { if (accounts_account_exists(account_name)) { g_key_file_set_string(accounts, account_name, "muc.service", value); @@ -707,7 +702,7 @@ accounts_set_muc_service(const char *const account_name, const char *const value } void -accounts_set_muc_nick(const char *const account_name, const char *const value) +accounts_set_muc_nick(const char* const account_name, const char* const value) { if (accounts_account_exists(account_name)) { g_key_file_set_string(accounts, account_name, "muc.nick", value); @@ -716,7 +711,7 @@ accounts_set_muc_nick(const char *const account_name, const char *const value) } void -accounts_set_otr_policy(const char *const account_name, const char *const value) +accounts_set_otr_policy(const char* const account_name, const char* const value) { if (accounts_account_exists(account_name)) { g_key_file_set_string(accounts, account_name, "otr.policy", value); @@ -725,7 +720,7 @@ accounts_set_otr_policy(const char *const account_name, const char *const value) } void -accounts_set_omemo_policy(const char *const account_name, const char *const value) +accounts_set_omemo_policy(const char* const account_name, const char* const value) { if (accounts_account_exists(account_name)) { g_key_file_set_string(accounts, account_name, "omemo.policy", value); @@ -734,7 +729,7 @@ accounts_set_omemo_policy(const char *const account_name, const char *const valu } void -accounts_set_tls_policy(const char *const account_name, const char *const value) +accounts_set_tls_policy(const char* const account_name, const char* const value) { if (accounts_account_exists(account_name)) { g_key_file_set_string(accounts, account_name, "tls.policy", value); @@ -743,7 +738,7 @@ accounts_set_tls_policy(const char *const account_name, const char *const value) } void -accounts_set_auth_policy(const char *const account_name, const char *const value) +accounts_set_auth_policy(const char* const account_name, const char* const value) { if (accounts_account_exists(account_name)) { g_key_file_set_string(accounts, account_name, "auth.policy", value); @@ -752,7 +747,7 @@ accounts_set_auth_policy(const char *const account_name, const char *const value } void -accounts_set_priority_online(const char *const account_name, const gint value) +accounts_set_priority_online(const char* const account_name, const gint value) { if (accounts_account_exists(account_name)) { g_key_file_set_integer(accounts, account_name, "priority.online", value); @@ -761,7 +756,7 @@ accounts_set_priority_online(const char *const account_name, const gint value) } void -accounts_set_priority_chat(const char *const account_name, const gint value) +accounts_set_priority_chat(const char* const account_name, const gint value) { if (accounts_account_exists(account_name)) { g_key_file_set_integer(accounts, account_name, "priority.chat", value); @@ -770,7 +765,7 @@ accounts_set_priority_chat(const char *const account_name, const gint value) } void -accounts_set_priority_away(const char *const account_name, const gint value) +accounts_set_priority_away(const char* const account_name, const gint value) { if (accounts_account_exists(account_name)) { g_key_file_set_integer(accounts, account_name, "priority.away", value); @@ -779,7 +774,7 @@ accounts_set_priority_away(const char *const account_name, const gint value) } void -accounts_set_priority_xa(const char *const account_name, const gint value) +accounts_set_priority_xa(const char* const account_name, const gint value) { if (accounts_account_exists(account_name)) { g_key_file_set_integer(accounts, account_name, "priority.xa", value); @@ -788,7 +783,7 @@ accounts_set_priority_xa(const char *const account_name, const gint value) } void -accounts_set_priority_dnd(const char *const account_name, const gint value) +accounts_set_priority_dnd(const char* const account_name, const gint value) { if (accounts_account_exists(account_name)) { g_key_file_set_integer(accounts, account_name, "priority.dnd", value); @@ -797,7 +792,7 @@ accounts_set_priority_dnd(const char *const account_name, const gint value) } void -accounts_set_priority_all(const char *const account_name, const gint value) +accounts_set_priority_all(const char* const account_name, const gint value) { if (accounts_account_exists(account_name)) { accounts_set_priority_online(account_name, value); @@ -810,28 +805,27 @@ accounts_set_priority_all(const char *const account_name, const gint value) } gint -accounts_get_priority_for_presence_type(const char *const account_name, - resource_presence_t presence_type) +accounts_get_priority_for_presence_type(const char* const account_name, + resource_presence_t presence_type) { gint result; - switch (presence_type) - { - case (RESOURCE_ONLINE): - result = g_key_file_get_integer(accounts, account_name, "priority.online", NULL); - break; - case (RESOURCE_CHAT): - result = g_key_file_get_integer(accounts, account_name, "priority.chat", NULL); - break; - case (RESOURCE_AWAY): - result = g_key_file_get_integer(accounts, account_name, "priority.away", NULL); - break; - case (RESOURCE_XA): - result = g_key_file_get_integer(accounts, account_name, "priority.xa", NULL); - break; - default: - result = g_key_file_get_integer(accounts, account_name, "priority.dnd", NULL); - break; + switch (presence_type) { + case (RESOURCE_ONLINE): + result = g_key_file_get_integer(accounts, account_name, "priority.online", NULL); + break; + case (RESOURCE_CHAT): + result = g_key_file_get_integer(accounts, account_name, "priority.chat", NULL); + break; + case (RESOURCE_AWAY): + result = g_key_file_get_integer(accounts, account_name, "priority.away", NULL); + break; + case (RESOURCE_XA): + result = g_key_file_get_integer(accounts, account_name, "priority.xa", NULL); + break; + default: + result = g_key_file_get_integer(accounts, account_name, "priority.dnd", NULL); + break; } if (result < JABBER_PRIORITY_MIN || result > JABBER_PRIORITY_MAX) @@ -841,7 +835,7 @@ accounts_get_priority_for_presence_type(const char *const account_name, } void -accounts_set_last_presence(const char *const account_name, const char *const value) +accounts_set_last_presence(const char* const account_name, const char* const value) { if (accounts_account_exists(account_name)) { g_key_file_set_string(accounts, account_name, "presence.last", value); @@ -850,7 +844,7 @@ accounts_set_last_presence(const char *const account_name, const char *const val } void -accounts_set_last_status(const char *const account_name, const char *const value) +accounts_set_last_status(const char* const account_name, const char* const value) { if (accounts_account_exists(account_name)) { if (value) { @@ -863,16 +857,16 @@ accounts_set_last_status(const char *const account_name, const char *const value } void -accounts_set_last_activity(const char *const account_name) +accounts_set_last_activity(const char* const account_name) { if (accounts_account_exists(account_name)) { - GDateTime *nowdt = g_date_time_new_now_utc(); + GDateTime* nowdt = g_date_time_new_now_utc(); GTimeVal nowtv; gboolean res = g_date_time_to_timeval(nowdt, &nowtv); g_date_time_unref(nowdt); if (res) { - char *timestr = g_time_val_to_iso8601(&nowtv); + char* timestr = g_time_val_to_iso8601(&nowtv); g_key_file_set_string(accounts, account_name, "last.activity", timestr); free(timestr); _save_accounts(); @@ -881,7 +875,7 @@ accounts_set_last_activity(const char *const account_name) } char* -accounts_get_last_activity(const char *const account_name) +accounts_get_last_activity(const char* const account_name) { if (accounts_account_exists(account_name)) { return g_key_file_get_string(accounts, account_name, "last.activity", NULL); @@ -891,7 +885,7 @@ accounts_get_last_activity(const char *const account_name) } void -accounts_set_login_presence(const char *const account_name, const char *const value) +accounts_set_login_presence(const char* const account_name, const char* const value) { if (accounts_account_exists(account_name)) { g_key_file_set_string(accounts, account_name, "presence.login", value); @@ -900,10 +894,10 @@ accounts_set_login_presence(const char *const account_name, const char *const va } resource_presence_t -accounts_get_last_presence(const char *const account_name) +accounts_get_last_presence(const char* const account_name) { resource_presence_t result; - gchar *setting = g_key_file_get_string(accounts, account_name, "presence.last", NULL); + gchar* setting = g_key_file_get_string(accounts, account_name, "presence.last", NULL); if (setting == NULL || (strcmp(setting, "online") == 0)) { result = RESOURCE_ONLINE; @@ -917,7 +911,7 @@ accounts_get_last_presence(const char *const account_name) result = RESOURCE_DND; } else { log_warning("Error reading presence.last for account: '%s', value: '%s', defaulting to 'online'", - account_name, setting); + account_name, setting); result = RESOURCE_ONLINE; } @@ -928,16 +922,16 @@ accounts_get_last_presence(const char *const account_name) } char* -accounts_get_last_status(const char *const account_name) +accounts_get_last_status(const char* const account_name) { return g_key_file_get_string(accounts, account_name, "presence.laststatus", NULL); } resource_presence_t -accounts_get_login_presence(const char *const account_name) +accounts_get_login_presence(const char* const account_name) { resource_presence_t result; - gchar *setting = g_key_file_get_string(accounts, account_name, "presence.login", NULL); + gchar* setting = g_key_file_get_string(accounts, account_name, "presence.login", NULL); if (setting == NULL || (strcmp(setting, "online") == 0)) { result = RESOURCE_ONLINE; @@ -953,7 +947,7 @@ accounts_get_login_presence(const char *const account_name) result = accounts_get_last_presence(account_name); } else { log_warning("Error reading presence.login for account: '%s', value: '%s', defaulting to 'online'", - account_name, setting); + account_name, setting); result = RESOURCE_ONLINE; } @@ -967,10 +961,10 @@ static void _save_accounts(void) { gsize g_data_size; - gchar *g_accounts_data = g_key_file_to_data(accounts, &g_data_size, NULL); + gchar* g_accounts_data = g_key_file_to_data(accounts, &g_data_size, NULL); - gchar *base = g_path_get_dirname(accounts_loc); - gchar *true_loc = get_file_or_linked(accounts_loc, base); + gchar* base = g_path_get_dirname(accounts_loc); + gchar* true_loc = get_file_or_linked(accounts_loc, base); g_file_set_contents(true_loc, g_accounts_data, g_data_size, NULL); g_chmod(accounts_loc, S_IRUSR | S_IWUSR); diff --git a/src/config/accounts.h b/src/config/accounts.h index 2cd4bcf6..4195a82e 100644 --- a/src/config/accounts.h +++ b/src/config/accounts.h @@ -44,61 +44,61 @@ void accounts_load(void); void accounts_close(void); -char* accounts_find_all(const char *const prefix, gboolean previous, void *context); -char* accounts_find_enabled(const char *const prefix, gboolean previous, void *context); +char* accounts_find_all(const char* const prefix, gboolean previous, void* context); +char* accounts_find_enabled(const char* const prefix, gboolean previous, void* context); void accounts_reset_all_search(void); void accounts_reset_enabled_search(void); -void accounts_add(const char *jid, const char *altdomain, const int port, const char *const tls_policy, const char *const auth_policy); -int accounts_remove(const char *jid); +void accounts_add(const char* jid, const char* altdomain, const int port, const char* const tls_policy, const char* const auth_policy); +int accounts_remove(const char* jid); gchar** accounts_get_list(void); -ProfAccount* accounts_get_account(const char *const name); -gboolean accounts_enable(const char *const name); -gboolean accounts_disable(const char *const name); -gboolean accounts_rename(const char *const account_name, - const char *const new_name); -gboolean accounts_account_exists(const char *const account_name); -void accounts_set_jid(const char *const account_name, const char *const value); -void accounts_set_server(const char *const account_name, const char *const value); -void accounts_set_port(const char *const account_name, const int value); -void accounts_set_resource(const char *const account_name, const char *const value); -void accounts_set_password(const char *const account_name, const char *const value); -void accounts_set_eval_password(const char *const account_name, const char *const value); -void accounts_set_muc_service(const char *const account_name, const char *const value); -void accounts_set_muc_nick(const char *const account_name, const char *const value); -void accounts_set_otr_policy(const char *const account_name, const char *const value); -void accounts_set_tls_policy(const char *const account_name, const char *const value); -void accounts_set_auth_policy(const char *const account_name, const char *const value); -void accounts_set_last_presence(const char *const account_name, const char *const value); -void accounts_set_last_status(const char *const account_name, const char *const value); -void accounts_set_last_activity(const char *const account_name); -char* accounts_get_last_activity(const char *const account_name); -void accounts_set_login_presence(const char *const account_name, const char *const value); -resource_presence_t accounts_get_login_presence(const char *const account_name); -char* accounts_get_last_status(const char *const account_name); -resource_presence_t accounts_get_last_presence(const char *const account_name); -void accounts_set_priority_online(const char *const account_name, const gint value); -void accounts_set_priority_chat(const char *const account_name, const gint value); -void accounts_set_priority_away(const char *const account_name, const gint value); -void accounts_set_priority_xa(const char *const account_name, const gint value); -void accounts_set_priority_dnd(const char *const account_name, const gint value); -void accounts_set_priority_all(const char *const account_name, const gint value); -gint accounts_get_priority_for_presence_type(const char *const account_name, - resource_presence_t presence_type); -void accounts_set_pgp_keyid(const char *const account_name, const char *const value); -void accounts_set_script_start(const char *const account_name, const char *const value); -void accounts_set_theme(const char *const account_name, const char *const value); -void accounts_clear_password(const char *const account_name); -void accounts_clear_eval_password(const char *const account_name); -void accounts_clear_server(const char *const account_name); -void accounts_clear_port(const char *const account_name); -void accounts_clear_otr(const char *const account_name); -void accounts_clear_pgp_keyid(const char *const account_name); -void accounts_clear_script_start(const char *const account_name); -void accounts_clear_theme(const char *const account_name); -void accounts_clear_muc(const char *const account_name); -void accounts_clear_resource(const char *const account_name); -void accounts_add_otr_policy(const char *const account_name, const char *const contact_jid, const char *const policy); -void accounts_add_omemo_state(const char *const account_name, const char *const contact_jid, gboolean enabled); -void accounts_clear_omemo_state(const char *const account_name, const char *const contact_jid); +ProfAccount* accounts_get_account(const char* const name); +gboolean accounts_enable(const char* const name); +gboolean accounts_disable(const char* const name); +gboolean accounts_rename(const char* const account_name, + const char* const new_name); +gboolean accounts_account_exists(const char* const account_name); +void accounts_set_jid(const char* const account_name, const char* const value); +void accounts_set_server(const char* const account_name, const char* const value); +void accounts_set_port(const char* const account_name, const int value); +void accounts_set_resource(const char* const account_name, const char* const value); +void accounts_set_password(const char* const account_name, const char* const value); +void accounts_set_eval_password(const char* const account_name, const char* const value); +void accounts_set_muc_service(const char* const account_name, const char* const value); +void accounts_set_muc_nick(const char* const account_name, const char* const value); +void accounts_set_otr_policy(const char* const account_name, const char* const value); +void accounts_set_tls_policy(const char* const account_name, const char* const value); +void accounts_set_auth_policy(const char* const account_name, const char* const value); +void accounts_set_last_presence(const char* const account_name, const char* const value); +void accounts_set_last_status(const char* const account_name, const char* const value); +void accounts_set_last_activity(const char* const account_name); +char* accounts_get_last_activity(const char* const account_name); +void accounts_set_login_presence(const char* const account_name, const char* const value); +resource_presence_t accounts_get_login_presence(const char* const account_name); +char* accounts_get_last_status(const char* const account_name); +resource_presence_t accounts_get_last_presence(const char* const account_name); +void accounts_set_priority_online(const char* const account_name, const gint value); +void accounts_set_priority_chat(const char* const account_name, const gint value); +void accounts_set_priority_away(const char* const account_name, const gint value); +void accounts_set_priority_xa(const char* const account_name, const gint value); +void accounts_set_priority_dnd(const char* const account_name, const gint value); +void accounts_set_priority_all(const char* const account_name, const gint value); +gint accounts_get_priority_for_presence_type(const char* const account_name, + resource_presence_t presence_type); +void accounts_set_pgp_keyid(const char* const account_name, const char* const value); +void accounts_set_script_start(const char* const account_name, const char* const value); +void accounts_set_theme(const char* const account_name, const char* const value); +void accounts_clear_password(const char* const account_name); +void accounts_clear_eval_password(const char* const account_name); +void accounts_clear_server(const char* const account_name); +void accounts_clear_port(const char* const account_name); +void accounts_clear_otr(const char* const account_name); +void accounts_clear_pgp_keyid(const char* const account_name); +void accounts_clear_script_start(const char* const account_name); +void accounts_clear_theme(const char* const account_name); +void accounts_clear_muc(const char* const account_name); +void accounts_clear_resource(const char* const account_name); +void accounts_add_otr_policy(const char* const account_name, const char* const contact_jid, const char* const policy); +void accounts_add_omemo_state(const char* const account_name, const char* const contact_jid, gboolean enabled); +void accounts_clear_omemo_state(const char* const account_name, const char* const contact_jid); #endif diff --git a/src/config/color.c b/src/config/color.c index cb857792..790febc7 100644 --- a/src/config/color.c +++ b/src/config/color.c @@ -52,13 +52,15 @@ #include "config/theme.h" #include "log.h" -static -struct color_pair_cache +static struct color_pair_cache { - struct { int16_t fg, bg; } *pairs; + struct + { + int16_t fg, bg; + } * pairs; int size; int capacity; -} cache = {0}; +} cache = { 0 }; /* * xterm default 256 colors @@ -66,279 +68,281 @@ struct color_pair_cache */ const struct color_def color_names[COLOR_NAME_SIZE] = { - [0] = { 0, 0, 0, "black" }, - [1] = { 0, 100, 25, "red" }, - [2] = { 120, 100, 25, "green" }, - [3] = { 60, 100, 25, "yellow" }, - [4] = { 240, 100, 25, "blue" }, - [5] = { 300, 100, 25, "magenta" }, - [6] = { 180, 100, 25, "cyan" }, - [7] = { 0, 0, 75, "white" }, - [8] = { 0, 0, 50, "lightblack" }, - [9] = { 0, 100, 50, "lightred" }, - [10] = { 120, 100, 50, "lightgreen" }, - [11] = { 60, 100, 50, "lightyellow" }, - [12] = { 240, 100, 50, "lightblue" }, - [13] = { 300, 100, 50, "lightmagenta" }, - [14] = { 180, 100, 50, "lightcyan" }, - [15] = { 0, 0, 100, "lightwhite" }, - [16] = { 0, 0, 0, "grey0" }, - [17] = { 240, 100, 18, "navyblue" }, - [18] = { 240, 100, 26, "darkblue" }, - [19] = { 240, 100, 34, "blue3" }, - [20] = { 240, 100, 42, "blue3" }, - [21] = { 240, 100, 50, "blue1" }, - [22] = { 120, 100, 18, "darkgreen" }, - [23] = { 180, 100, 18, "deepskyblue4" }, - [24] = { 97, 100, 26, "deepskyblue4" }, - [25] = { 7, 100, 34, "deepskyblue4" }, - [26] = { 13, 100, 42, "dodgerblue3" }, - [27] = { 17, 100, 50, "dodgerblue2" }, - [28] = { 120, 100, 26, "green4" }, - [29] = { 62, 100, 26, "springgreen4" }, - [30] = { 180, 100, 26, "turquoise4" }, - [31] = { 93, 100, 34, "deepskyblue3" }, - [32] = { 2, 100, 42, "deepskyblue3" }, - [33] = { 8, 100, 50, "dodgerblue1" }, - [34] = { 120, 100, 34, "green3" }, - [35] = { 52, 100, 34, "springgreen3" }, - [36] = { 66, 100, 34, "darkcyan" }, - [37] = { 180, 100, 34, "lightseagreen" }, - [38] = { 91, 100, 42, "deepskyblue2" }, - [39] = { 98, 100, 50, "deepskyblue1" }, - [40] = { 120, 100, 42, "green3" }, - [41] = { 46, 100, 42, "springgreen3" }, - [42] = { 57, 100, 42, "springgreen2" }, - [43] = { 68, 100, 42, "cyan3" }, - [44] = { 180, 100, 42, "darkturquoise" }, - [45] = { 89, 100, 50, "turquoise2" }, - [46] = { 120, 100, 50, "green1" }, - [47] = { 42, 100, 50, "springgreen2" }, - [48] = { 51, 100, 50, "springgreen1" }, - [49] = { 61, 100, 50, "mediumspringgreen" }, - [50] = { 70, 100, 50, "cyan2" }, - [51] = { 180, 100, 50, "cyan1" }, - [52] = { 0, 100, 18, "darkred" }, - [53] = { 300, 100, 18, "deeppink4" }, - [54] = { 82, 100, 26, "purple4" }, - [55] = { 72, 100, 34, "purple4" }, - [56] = { 66, 100, 42, "purple3" }, - [57] = { 62, 100, 50, "blueviolet" }, - [58] = { 60, 100, 18, "orange4" }, - [59] = { 0, 0, 37, "grey37" }, - [60] = { 240, 17, 45, "mediumpurple4" }, - [61] = { 240, 33, 52, "slateblue3" }, - [62] = { 240, 60, 60, "slateblue3" }, - [63] = { 240, 100, 68, "royalblue1" }, - [64] = { 7, 100, 26, "chartreuse4" }, - [65] = { 120, 17, 45, "darkseagreen4" }, - [66] = { 180, 17, 45, "paleturquoise4" }, - [67] = { 210, 33, 52, "steelblue" }, - [68] = { 220, 60, 60, "steelblue3" }, - [69] = { 225, 100, 68, "cornflowerblue" }, - [70] = { 7, 100, 34, "chartreuse3" }, - [71] = { 120, 33, 52, "darkseagreen4" }, - [72] = { 150, 33, 52, "cadetblue" }, - [73] = { 180, 33, 52, "cadetblue" }, - [74] = { 200, 60, 60, "skyblue3" }, - [75] = { 210, 100, 68, "steelblue1" }, - [76] = { 3, 100, 42, "chartreuse3" }, - [77] = { 120, 60, 60, "palegreen3" }, - [78] = { 140, 60, 60, "seagreen3" }, - [79] = { 160, 60, 60, "aquamarine3" }, - [80] = { 180, 60, 60, "mediumturquoise" }, - [81] = { 195, 100, 68, "steelblue1" }, - [82] = { 7, 100, 50, "chartreuse2" }, - [83] = { 120, 100, 68, "seagreen2" }, - [84] = { 135, 100, 68, "seagreen1" }, - [85] = { 150, 100, 68, "seagreen1" }, - [86] = { 165, 100, 68, "aquamarine1" }, - [87] = { 180, 100, 68, "darkslategray2" }, - [88] = { 0, 100, 26, "darkred" }, - [89] = { 17, 100, 26, "deeppink4" }, - [90] = { 300, 100, 26, "darkmagenta" }, - [91] = { 86, 100, 34, "darkmagenta" }, - [92] = { 77, 100, 42, "darkviolet" }, - [93] = { 71, 100, 50, "purple" }, - [94] = { 2, 100, 26, "orange4" }, - [95] = { 0, 17, 45, "lightpink4" }, - [96] = { 300, 17, 45, "plum4" }, - [97] = { 270, 33, 52, "mediumpurple3" }, - [98] = { 260, 60, 60, "mediumpurple3" }, - [99] = { 255, 100, 68, "slateblue1" }, - [100] = { 60, 100, 26, "yellow4" }, - [101] = { 60, 17, 45, "wheat4" }, - [102] = { 0, 0, 52, "grey53" }, - [103] = { 240, 20, 60, "lightslategrey" }, - [104] = { 240, 50, 68, "mediumpurple" }, - [105] = { 240, 100, 76, "lightslateblue" }, - [106] = { 3, 100, 34, "yellow4" }, - [107] = { 90, 33, 52, "darkolivegreen3" }, - [108] = { 120, 20, 60, "darkseagreen" }, - [109] = { 180, 20, 60, "lightskyblue3" }, - [110] = { 210, 50, 68, "lightskyblue3" }, - [111] = { 220, 100, 76, "skyblue2" }, - [112] = { 2, 100, 42, "chartreuse2" }, - [113] = { 100, 60, 60, "darkolivegreen3" }, - [114] = { 120, 50, 68, "palegreen3" }, - [115] = { 150, 50, 68, "darkseagreen3" }, - [116] = { 180, 50, 68, "darkslategray3" }, - [117] = { 200, 100, 76, "skyblue1" }, - [118] = { 8, 100, 50, "chartreuse1" }, - [119] = { 105, 100, 68, "lightgreen" }, - [120] = { 120, 100, 76, "lightgreen" }, - [121] = { 140, 100, 76, "palegreen1" }, - [122] = { 160, 100, 76, "aquamarine1" }, - [123] = { 180, 100, 76, "darkslategray1" }, - [124] = { 0, 100, 34, "red3" }, - [125] = { 27, 100, 34, "deeppink4" }, - [126] = { 13, 100, 34, "mediumvioletred" }, - [127] = { 300, 100, 34, "magenta3" }, - [128] = { 88, 100, 42, "darkviolet" }, - [129] = { 81, 100, 50, "purple" }, - [130] = { 2, 100, 34, "darkorange3" }, - [131] = { 0, 33, 52, "indianred" }, - [132] = { 330, 33, 52, "hotpink3" }, - [133] = { 300, 33, 52, "mediumorchid3" }, - [134] = { 280, 60, 60, "mediumorchid" }, - [135] = { 270, 100, 68, "mediumpurple2" }, - [136] = { 6, 100, 34, "darkgoldenrod" }, - [137] = { 30, 33, 52, "lightsalmon3" }, - [138] = { 0, 20, 60, "rosybrown" }, - [139] = { 300, 20, 60, "grey63" }, - [140] = { 270, 50, 68, "mediumpurple2" }, - [141] = { 260, 100, 76, "mediumpurple1" }, - [142] = { 60, 100, 34, "gold3" }, - [143] = { 60, 33, 52, "darkkhaki" }, - [144] = { 60, 20, 60, "navajowhite3" }, - [145] = { 0, 0, 68, "grey69" }, - [146] = { 240, 33, 76, "lightsteelblue3" }, - [147] = { 240, 100, 84, "lightsteelblue" }, - [148] = { 1, 100, 42, "yellow3" }, - [149] = { 80, 60, 60, "darkolivegreen3" }, - [150] = { 90, 50, 68, "darkseagreen3" }, - [151] = { 120, 33, 76, "darkseagreen2" }, - [152] = { 180, 33, 76, "lightcyan3" }, - [153] = { 210, 100, 84, "lightskyblue1" }, - [154] = { 8, 100, 50, "greenyellow" }, - [155] = { 90, 100, 68, "darkolivegreen2" }, - [156] = { 100, 100, 76, "palegreen1" }, - [157] = { 120, 100, 84, "darkseagreen2" }, - [158] = { 150, 100, 84, "darkseagreen1" }, - [159] = { 180, 100, 84, "paleturquoise1" }, - [160] = { 0, 100, 42, "red3" }, - [161] = { 33, 100, 42, "deeppink3" }, - [162] = { 22, 100, 42, "deeppink3" }, - [163] = { 11, 100, 42, "magenta3" }, - [164] = { 300, 100, 42, "magenta3" }, - [165] = { 90, 100, 50, "magenta2" }, - [166] = { 6, 100, 42, "darkorange3" }, - [167] = { 0, 60, 60, "indianred" }, - [168] = { 340, 60, 60, "hotpink3" }, - [169] = { 320, 60, 60, "hotpink2" }, - [170] = { 300, 60, 60, "orchid" }, - [171] = { 285, 100, 68, "mediumorchid1" }, - [172] = { 7, 100, 42, "orange3" }, - [173] = { 20, 60, 60, "lightsalmon3" }, - [174] = { 0, 50, 68, "lightpink3" }, - [175] = { 330, 50, 68, "pink3" }, - [176] = { 300, 50, 68, "plum3" }, - [177] = { 280, 100, 76, "violet" }, - [178] = { 8, 100, 42, "gold3" }, - [179] = { 40, 60, 60, "lightgoldenrod3" }, - [180] = { 30, 50, 68, "tan" }, - [181] = { 0, 33, 76, "mistyrose3" }, - [182] = { 300, 33, 76, "thistle3" }, - [183] = { 270, 100, 84, "plum2" }, - [184] = { 60, 100, 42, "yellow3" }, - [185] = { 60, 60, 60, "khaki3" }, - [186] = { 60, 50, 68, "lightgoldenrod2" }, - [187] = { 60, 33, 76, "lightyellow3" }, - [188] = { 0, 0, 84, "grey84" }, - [189] = { 240, 100, 92, "lightsteelblue1" }, - [190] = { 9, 100, 50, "yellow2" }, - [191] = { 75, 100, 68, "darkolivegreen1" }, - [192] = { 80, 100, 76, "darkolivegreen1" }, - [193] = { 90, 100, 84, "darkseagreen1" }, - [194] = { 120, 100, 92, "honeydew2" }, - [195] = { 180, 100, 92, "lightcyan1" }, - [196] = { 0, 100, 50, "red1" }, - [197] = { 37, 100, 50, "deeppink2" }, - [198] = { 28, 100, 50, "deeppink1" }, - [199] = { 18, 100, 50, "deeppink1" }, - [200] = { 9, 100, 50, "magenta2" }, - [201] = { 300, 100, 50, "magenta1" }, - [202] = { 2, 100, 50, "orangered1" }, - [203] = { 0, 100, 68, "indianred1" }, - [204] = { 345, 100, 68, "indianred1" }, - [205] = { 330, 100, 68, "hotpink" }, - [206] = { 315, 100, 68, "hotpink" }, - [207] = { 300, 100, 68, "mediumorchid1" }, - [208] = { 1, 100, 50, "darkorange" }, - [209] = { 15, 100, 68, "salmon1" }, - [210] = { 0, 100, 76, "lightcoral" }, - [211] = { 340, 100, 76, "palevioletred1" }, - [212] = { 320, 100, 76, "orchid2" }, - [213] = { 300, 100, 76, "orchid1" }, - [214] = { 1, 100, 50, "orange1" }, - [215] = { 30, 100, 68, "sandybrown" }, - [216] = { 20, 100, 76, "lightsalmon1" }, - [217] = { 0, 100, 84, "lightpink1" }, - [218] = { 330, 100, 84, "pink1" }, - [219] = { 300, 100, 84, "plum1" }, - [220] = { 0, 100, 50, "gold1" }, - [221] = { 45, 100, 68, "lightgoldenrod2" }, - [222] = { 40, 100, 76, "lightgoldenrod2" }, - [223] = { 30, 100, 84, "navajowhite1" }, - [224] = { 0, 100, 92, "mistyrose1" }, - [225] = { 300, 100, 92, "thistle1" }, - [226] = { 60, 100, 50, "yellow1" }, - [227] = { 60, 100, 68, "lightgoldenrod1" }, - [228] = { 60, 100, 76, "khaki1" }, - [229] = { 60, 100, 84, "wheat1" }, - [230] = { 60, 100, 92, "cornsilk1" }, - [231] = { 0, 0, 100, "grey100" }, - [232] = { 0, 0, 3, "grey3" }, - [233] = { 0, 0, 7, "grey7" }, - [234] = { 0, 0, 10, "grey11" }, - [235] = { 0, 0, 14, "grey15" }, - [236] = { 0, 0, 18, "grey19" }, - [237] = { 0, 0, 22, "grey23" }, - [238] = { 0, 0, 26, "grey27" }, - [239] = { 0, 0, 30, "grey30" }, - [240] = { 0, 0, 34, "grey35" }, - [241] = { 0, 0, 37, "grey39" }, - [242] = { 0, 0, 40, "grey42" }, - [243] = { 0, 0, 46, "grey46" }, - [244] = { 0, 0, 50, "grey50" }, - [245] = { 0, 0, 54, "grey54" }, - [246] = { 0, 0, 58, "grey58" }, - [247] = { 0, 0, 61, "grey62" }, - [248] = { 0, 0, 65, "grey66" }, - [249] = { 0, 0, 69, "grey70" }, - [250] = { 0, 0, 73, "grey74" }, - [251] = { 0, 0, 77, "grey78" }, - [252] = { 0, 0, 81, "grey82" }, - [253] = { 0, 0, 85, "grey85" }, - [254] = { 0, 0, 89, "grey89" }, - [255] = { 0, 0, 93, "grey93" }, + [0] = { 0, 0, 0, "black" }, + [1] = { 0, 100, 25, "red" }, + [2] = { 120, 100, 25, "green" }, + [3] = { 60, 100, 25, "yellow" }, + [4] = { 240, 100, 25, "blue" }, + [5] = { 300, 100, 25, "magenta" }, + [6] = { 180, 100, 25, "cyan" }, + [7] = { 0, 0, 75, "white" }, + [8] = { 0, 0, 50, "lightblack" }, + [9] = { 0, 100, 50, "lightred" }, + [10] = { 120, 100, 50, "lightgreen" }, + [11] = { 60, 100, 50, "lightyellow" }, + [12] = { 240, 100, 50, "lightblue" }, + [13] = { 300, 100, 50, "lightmagenta" }, + [14] = { 180, 100, 50, "lightcyan" }, + [15] = { 0, 0, 100, "lightwhite" }, + [16] = { 0, 0, 0, "grey0" }, + [17] = { 240, 100, 18, "navyblue" }, + [18] = { 240, 100, 26, "darkblue" }, + [19] = { 240, 100, 34, "blue3" }, + [20] = { 240, 100, 42, "blue3" }, + [21] = { 240, 100, 50, "blue1" }, + [22] = { 120, 100, 18, "darkgreen" }, + [23] = { 180, 100, 18, "deepskyblue4" }, + [24] = { 97, 100, 26, "deepskyblue4" }, + [25] = { 7, 100, 34, "deepskyblue4" }, + [26] = { 13, 100, 42, "dodgerblue3" }, + [27] = { 17, 100, 50, "dodgerblue2" }, + [28] = { 120, 100, 26, "green4" }, + [29] = { 62, 100, 26, "springgreen4" }, + [30] = { 180, 100, 26, "turquoise4" }, + [31] = { 93, 100, 34, "deepskyblue3" }, + [32] = { 2, 100, 42, "deepskyblue3" }, + [33] = { 8, 100, 50, "dodgerblue1" }, + [34] = { 120, 100, 34, "green3" }, + [35] = { 52, 100, 34, "springgreen3" }, + [36] = { 66, 100, 34, "darkcyan" }, + [37] = { 180, 100, 34, "lightseagreen" }, + [38] = { 91, 100, 42, "deepskyblue2" }, + [39] = { 98, 100, 50, "deepskyblue1" }, + [40] = { 120, 100, 42, "green3" }, + [41] = { 46, 100, 42, "springgreen3" }, + [42] = { 57, 100, 42, "springgreen2" }, + [43] = { 68, 100, 42, "cyan3" }, + [44] = { 180, 100, 42, "darkturquoise" }, + [45] = { 89, 100, 50, "turquoise2" }, + [46] = { 120, 100, 50, "green1" }, + [47] = { 42, 100, 50, "springgreen2" }, + [48] = { 51, 100, 50, "springgreen1" }, + [49] = { 61, 100, 50, "mediumspringgreen" }, + [50] = { 70, 100, 50, "cyan2" }, + [51] = { 180, 100, 50, "cyan1" }, + [52] = { 0, 100, 18, "darkred" }, + [53] = { 300, 100, 18, "deeppink4" }, + [54] = { 82, 100, 26, "purple4" }, + [55] = { 72, 100, 34, "purple4" }, + [56] = { 66, 100, 42, "purple3" }, + [57] = { 62, 100, 50, "blueviolet" }, + [58] = { 60, 100, 18, "orange4" }, + [59] = { 0, 0, 37, "grey37" }, + [60] = { 240, 17, 45, "mediumpurple4" }, + [61] = { 240, 33, 52, "slateblue3" }, + [62] = { 240, 60, 60, "slateblue3" }, + [63] = { 240, 100, 68, "royalblue1" }, + [64] = { 7, 100, 26, "chartreuse4" }, + [65] = { 120, 17, 45, "darkseagreen4" }, + [66] = { 180, 17, 45, "paleturquoise4" }, + [67] = { 210, 33, 52, "steelblue" }, + [68] = { 220, 60, 60, "steelblue3" }, + [69] = { 225, 100, 68, "cornflowerblue" }, + [70] = { 7, 100, 34, "chartreuse3" }, + [71] = { 120, 33, 52, "darkseagreen4" }, + [72] = { 150, 33, 52, "cadetblue" }, + [73] = { 180, 33, 52, "cadetblue" }, + [74] = { 200, 60, 60, "skyblue3" }, + [75] = { 210, 100, 68, "steelblue1" }, + [76] = { 3, 100, 42, "chartreuse3" }, + [77] = { 120, 60, 60, "palegreen3" }, + [78] = { 140, 60, 60, "seagreen3" }, + [79] = { 160, 60, 60, "aquamarine3" }, + [80] = { 180, 60, 60, "mediumturquoise" }, + [81] = { 195, 100, 68, "steelblue1" }, + [82] = { 7, 100, 50, "chartreuse2" }, + [83] = { 120, 100, 68, "seagreen2" }, + [84] = { 135, 100, 68, "seagreen1" }, + [85] = { 150, 100, 68, "seagreen1" }, + [86] = { 165, 100, 68, "aquamarine1" }, + [87] = { 180, 100, 68, "darkslategray2" }, + [88] = { 0, 100, 26, "darkred" }, + [89] = { 17, 100, 26, "deeppink4" }, + [90] = { 300, 100, 26, "darkmagenta" }, + [91] = { 86, 100, 34, "darkmagenta" }, + [92] = { 77, 100, 42, "darkviolet" }, + [93] = { 71, 100, 50, "purple" }, + [94] = { 2, 100, 26, "orange4" }, + [95] = { 0, 17, 45, "lightpink4" }, + [96] = { 300, 17, 45, "plum4" }, + [97] = { 270, 33, 52, "mediumpurple3" }, + [98] = { 260, 60, 60, "mediumpurple3" }, + [99] = { 255, 100, 68, "slateblue1" }, + [100] = { 60, 100, 26, "yellow4" }, + [101] = { 60, 17, 45, "wheat4" }, + [102] = { 0, 0, 52, "grey53" }, + [103] = { 240, 20, 60, "lightslategrey" }, + [104] = { 240, 50, 68, "mediumpurple" }, + [105] = { 240, 100, 76, "lightslateblue" }, + [106] = { 3, 100, 34, "yellow4" }, + [107] = { 90, 33, 52, "darkolivegreen3" }, + [108] = { 120, 20, 60, "darkseagreen" }, + [109] = { 180, 20, 60, "lightskyblue3" }, + [110] = { 210, 50, 68, "lightskyblue3" }, + [111] = { 220, 100, 76, "skyblue2" }, + [112] = { 2, 100, 42, "chartreuse2" }, + [113] = { 100, 60, 60, "darkolivegreen3" }, + [114] = { 120, 50, 68, "palegreen3" }, + [115] = { 150, 50, 68, "darkseagreen3" }, + [116] = { 180, 50, 68, "darkslategray3" }, + [117] = { 200, 100, 76, "skyblue1" }, + [118] = { 8, 100, 50, "chartreuse1" }, + [119] = { 105, 100, 68, "lightgreen" }, + [120] = { 120, 100, 76, "lightgreen" }, + [121] = { 140, 100, 76, "palegreen1" }, + [122] = { 160, 100, 76, "aquamarine1" }, + [123] = { 180, 100, 76, "darkslategray1" }, + [124] = { 0, 100, 34, "red3" }, + [125] = { 27, 100, 34, "deeppink4" }, + [126] = { 13, 100, 34, "mediumvioletred" }, + [127] = { 300, 100, 34, "magenta3" }, + [128] = { 88, 100, 42, "darkviolet" }, + [129] = { 81, 100, 50, "purple" }, + [130] = { 2, 100, 34, "darkorange3" }, + [131] = { 0, 33, 52, "indianred" }, + [132] = { 330, 33, 52, "hotpink3" }, + [133] = { 300, 33, 52, "mediumorchid3" }, + [134] = { 280, 60, 60, "mediumorchid" }, + [135] = { 270, 100, 68, "mediumpurple2" }, + [136] = { 6, 100, 34, "darkgoldenrod" }, + [137] = { 30, 33, 52, "lightsalmon3" }, + [138] = { 0, 20, 60, "rosybrown" }, + [139] = { 300, 20, 60, "grey63" }, + [140] = { 270, 50, 68, "mediumpurple2" }, + [141] = { 260, 100, 76, "mediumpurple1" }, + [142] = { 60, 100, 34, "gold3" }, + [143] = { 60, 33, 52, "darkkhaki" }, + [144] = { 60, 20, 60, "navajowhite3" }, + [145] = { 0, 0, 68, "grey69" }, + [146] = { 240, 33, 76, "lightsteelblue3" }, + [147] = { 240, 100, 84, "lightsteelblue" }, + [148] = { 1, 100, 42, "yellow3" }, + [149] = { 80, 60, 60, "darkolivegreen3" }, + [150] = { 90, 50, 68, "darkseagreen3" }, + [151] = { 120, 33, 76, "darkseagreen2" }, + [152] = { 180, 33, 76, "lightcyan3" }, + [153] = { 210, 100, 84, "lightskyblue1" }, + [154] = { 8, 100, 50, "greenyellow" }, + [155] = { 90, 100, 68, "darkolivegreen2" }, + [156] = { 100, 100, 76, "palegreen1" }, + [157] = { 120, 100, 84, "darkseagreen2" }, + [158] = { 150, 100, 84, "darkseagreen1" }, + [159] = { 180, 100, 84, "paleturquoise1" }, + [160] = { 0, 100, 42, "red3" }, + [161] = { 33, 100, 42, "deeppink3" }, + [162] = { 22, 100, 42, "deeppink3" }, + [163] = { 11, 100, 42, "magenta3" }, + [164] = { 300, 100, 42, "magenta3" }, + [165] = { 90, 100, 50, "magenta2" }, + [166] = { 6, 100, 42, "darkorange3" }, + [167] = { 0, 60, 60, "indianred" }, + [168] = { 340, 60, 60, "hotpink3" }, + [169] = { 320, 60, 60, "hotpink2" }, + [170] = { 300, 60, 60, "orchid" }, + [171] = { 285, 100, 68, "mediumorchid1" }, + [172] = { 7, 100, 42, "orange3" }, + [173] = { 20, 60, 60, "lightsalmon3" }, + [174] = { 0, 50, 68, "lightpink3" }, + [175] = { 330, 50, 68, "pink3" }, + [176] = { 300, 50, 68, "plum3" }, + [177] = { 280, 100, 76, "violet" }, + [178] = { 8, 100, 42, "gold3" }, + [179] = { 40, 60, 60, "lightgoldenrod3" }, + [180] = { 30, 50, 68, "tan" }, + [181] = { 0, 33, 76, "mistyrose3" }, + [182] = { 300, 33, 76, "thistle3" }, + [183] = { 270, 100, 84, "plum2" }, + [184] = { 60, 100, 42, "yellow3" }, + [185] = { 60, 60, 60, "khaki3" }, + [186] = { 60, 50, 68, "lightgoldenrod2" }, + [187] = { 60, 33, 76, "lightyellow3" }, + [188] = { 0, 0, 84, "grey84" }, + [189] = { 240, 100, 92, "lightsteelblue1" }, + [190] = { 9, 100, 50, "yellow2" }, + [191] = { 75, 100, 68, "darkolivegreen1" }, + [192] = { 80, 100, 76, "darkolivegreen1" }, + [193] = { 90, 100, 84, "darkseagreen1" }, + [194] = { 120, 100, 92, "honeydew2" }, + [195] = { 180, 100, 92, "lightcyan1" }, + [196] = { 0, 100, 50, "red1" }, + [197] = { 37, 100, 50, "deeppink2" }, + [198] = { 28, 100, 50, "deeppink1" }, + [199] = { 18, 100, 50, "deeppink1" }, + [200] = { 9, 100, 50, "magenta2" }, + [201] = { 300, 100, 50, "magenta1" }, + [202] = { 2, 100, 50, "orangered1" }, + [203] = { 0, 100, 68, "indianred1" }, + [204] = { 345, 100, 68, "indianred1" }, + [205] = { 330, 100, 68, "hotpink" }, + [206] = { 315, 100, 68, "hotpink" }, + [207] = { 300, 100, 68, "mediumorchid1" }, + [208] = { 1, 100, 50, "darkorange" }, + [209] = { 15, 100, 68, "salmon1" }, + [210] = { 0, 100, 76, "lightcoral" }, + [211] = { 340, 100, 76, "palevioletred1" }, + [212] = { 320, 100, 76, "orchid2" }, + [213] = { 300, 100, 76, "orchid1" }, + [214] = { 1, 100, 50, "orange1" }, + [215] = { 30, 100, 68, "sandybrown" }, + [216] = { 20, 100, 76, "lightsalmon1" }, + [217] = { 0, 100, 84, "lightpink1" }, + [218] = { 330, 100, 84, "pink1" }, + [219] = { 300, 100, 84, "plum1" }, + [220] = { 0, 100, 50, "gold1" }, + [221] = { 45, 100, 68, "lightgoldenrod2" }, + [222] = { 40, 100, 76, "lightgoldenrod2" }, + [223] = { 30, 100, 84, "navajowhite1" }, + [224] = { 0, 100, 92, "mistyrose1" }, + [225] = { 300, 100, 92, "thistle1" }, + [226] = { 60, 100, 50, "yellow1" }, + [227] = { 60, 100, 68, "lightgoldenrod1" }, + [228] = { 60, 100, 76, "khaki1" }, + [229] = { 60, 100, 84, "wheat1" }, + [230] = { 60, 100, 92, "cornsilk1" }, + [231] = { 0, 0, 100, "grey100" }, + [232] = { 0, 0, 3, "grey3" }, + [233] = { 0, 0, 7, "grey7" }, + [234] = { 0, 0, 10, "grey11" }, + [235] = { 0, 0, 14, "grey15" }, + [236] = { 0, 0, 18, "grey19" }, + [237] = { 0, 0, 22, "grey23" }, + [238] = { 0, 0, 26, "grey27" }, + [239] = { 0, 0, 30, "grey30" }, + [240] = { 0, 0, 34, "grey35" }, + [241] = { 0, 0, 37, "grey39" }, + [242] = { 0, 0, 40, "grey42" }, + [243] = { 0, 0, 46, "grey46" }, + [244] = { 0, 0, 50, "grey50" }, + [245] = { 0, 0, 54, "grey54" }, + [246] = { 0, 0, 58, "grey58" }, + [247] = { 0, 0, 61, "grey62" }, + [248] = { 0, 0, 65, "grey66" }, + [249] = { 0, 0, 69, "grey70" }, + [250] = { 0, 0, 73, "grey74" }, + [251] = { 0, 0, 77, "grey78" }, + [252] = { 0, 0, 81, "grey82" }, + [253] = { 0, 0, 85, "grey85" }, + [254] = { 0, 0, 89, "grey89" }, + [255] = { 0, 0, 93, "grey93" }, }; /* -1 is valid curses color */ #define COL_ERR -2 -static inline int color_distance(const struct color_def *a, const struct color_def *b) +static inline int +color_distance(const struct color_def* a, const struct color_def* b) { - int h = MIN((a->h - b->h)%360, (b->h - a->h)%360); + int h = MIN((a->h - b->h) % 360, (b->h - a->h) % 360); int s = (int)a->s - b->s; int l = (int)a->l - b->l; - return h*h + s*s + l*l; + return h * h + s * s + l * l; } -static int find_closest_col(int h, int s, int l) +static int +find_closest_col(int h, int s, int l) { int i; - struct color_def a = {h, s, l}; + struct color_def a = { h, s, l }; int min = 0; int dmin = color_distance(&a, &color_names[0]); @@ -352,10 +356,11 @@ static int find_closest_col(int h, int s, int l) return min; } -static int find_col(const char *col_name, int n) +static int +find_col(const char* col_name, int n) { int i; - char name[32] = {0}; + char name[32] = { 0 }; /* * make a null terminated version of col_name. we don't want to @@ -366,7 +371,7 @@ static int find_col(const char *col_name, int n) if (n >= sizeof(name)) { /* truncate */ log_error("Color: <%s,%d> bigger than %zu", col_name, n, sizeof(name)); - n = sizeof(name)-1; + n = sizeof(name) - 1; } memcpy(name, col_name, n); @@ -383,10 +388,11 @@ static int find_col(const char *col_name, int n) return COL_ERR; } -static int color_hash(const char *str, color_profile profile) +static int +color_hash(const char* str, color_profile profile) { - GChecksum *cs = NULL; - guint8 buf[256] = {0}; + GChecksum* cs = NULL; + guint8 buf[256] = { 0 }; gsize len = 256; int rc = -1; /* default ncurse color */ @@ -403,27 +409,27 @@ static int color_hash(const char *str, color_profile profile) double h = ((buf[1] << 8) | buf[0]) / 65536. * 360.; - switch(profile) - { - case COLOR_PROFILE_REDGREEN_BLINDNESS: - // red/green blindness correction - h = fmod(fmod(h + 90., 180) - 90., 360.); - break; - case COLOR_PROFILE_BLUE_BLINDNESS: - // blue blindness correction - h = fmod(h, 180.); - default: - break; + switch (profile) { + case COLOR_PROFILE_REDGREEN_BLINDNESS: + // red/green blindness correction + h = fmod(fmod(h + 90., 180) - 90., 360.); + break; + case COLOR_PROFILE_BLUE_BLINDNESS: + // blue blindness correction + h = fmod(h, 180.); + default: + break; } rc = find_closest_col((int)h, 100, 50); - out: +out: g_checksum_free(cs); return rc; } -void color_pair_cache_reset(void) +void +color_pair_cache_reset(void) { if (cache.pairs) { free(cache.pairs); @@ -440,7 +446,7 @@ void color_pair_cache_reset(void) if (cache.capacity < 0) cache.capacity = 8; - cache.pairs = g_malloc0(sizeof(*cache.pairs)*cache.capacity); + cache.pairs = g_malloc0(sizeof(*cache.pairs) * cache.capacity); if (cache.pairs) { /* default_default */ cache.pairs[0].fg = -1; @@ -451,7 +457,8 @@ void color_pair_cache_reset(void) } } -static int _color_pair_cache_get(int fg, int bg) +static int +_color_pair_cache_get(int fg, int bg) { int i; @@ -497,12 +504,13 @@ static int _color_pair_cache_get(int fg, int bg) * hash a string into a color that will be used as fg * check for 'bkgnd' in theme file or use default color as bg */ -int color_pair_cache_hash_str(const char *str, color_profile profile) +int +color_pair_cache_hash_str(const char* str, color_profile profile) { int fg = color_hash(str, profile); int bg = -1; - char *bkgnd = theme_get_bkgnd(); + char* bkgnd = theme_get_bkgnd(); if (bkgnd) { bg = find_col(bkgnd, strlen(bkgnd)); free(bkgnd); @@ -517,9 +525,10 @@ int color_pair_cache_hash_str(const char *str, color_profile profile) * if the pair doesn't exist it will allocate it in curses with init_pair * if the pair exists it returns its id */ -int color_pair_cache_get(const char *pair_name) +int +color_pair_cache_get(const char* pair_name) { - const char *sep; + const char* sep; int fg, bg; sep = strchr(pair_name, '_'); @@ -529,7 +538,7 @@ int color_pair_cache_get(const char *pair_name) } fg = find_col(pair_name, sep - pair_name); - bg = find_col(sep+1, strlen(sep)); + bg = find_col(sep + 1, strlen(sep)); if (fg == COL_ERR || bg == COL_ERR) { log_error("Color: bad color name %s", pair_name); return -1; diff --git a/src/config/color.h b/src/config/color.h index 304e862e..fe0c6e63 100644 --- a/src/config/color.h +++ b/src/config/color.h @@ -47,16 +47,18 @@ typedef enum { COLOR_PROFILE_BLUE_BLINDNESS, } color_profile; -struct color_def { - uint16_t h; uint8_t s, l; - const char *name; +struct color_def +{ + uint16_t h; + uint8_t s, l; + const char* name; }; extern const struct color_def color_names[]; /* hash string to color pair */ -int color_pair_cache_hash_str(const char *str, color_profile profile); +int color_pair_cache_hash_str(const char* str, color_profile profile); /* parse fg_bg string to color pair */ -int color_pair_cache_get(const char *pair_name); +int color_pair_cache_get(const char* pair_name); /* clear cache */ void color_pair_cache_reset(void); diff --git a/src/config/conflists.c b/src/config/conflists.c index d0985669..944ada62 100644 --- a/src/config/conflists.c +++ b/src/config/conflists.c @@ -37,11 +37,11 @@ #include <glib.h> gboolean -conf_string_list_add(GKeyFile *keyfile, const char *const group, const char *const key, const char *const item) +conf_string_list_add(GKeyFile* keyfile, const char* const group, const char* const key, const char* const item) { gsize length; - gchar **list = g_key_file_get_string_list(keyfile, group, key, &length, NULL); - GList *glist = NULL; + gchar** list = g_key_file_get_string_list(keyfile, group, key, &length, NULL); + GList* glist = NULL; // list found if (list) { @@ -61,8 +61,8 @@ conf_string_list_add(GKeyFile *keyfile, const char *const group, const char *con glist = g_list_append(glist, strdup(item)); // create the new list entry - const gchar* new_list[g_list_length(glist)+1]; - GList *curr = glist; + const gchar* new_list[g_list_length(glist) + 1]; + GList* curr = glist; i = 0; while (curr) { new_list[i++] = curr->data; @@ -71,7 +71,7 @@ conf_string_list_add(GKeyFile *keyfile, const char *const group, const char *con new_list[i] = NULL; g_key_file_set_string_list(keyfile, group, key, new_list, g_list_length(glist)); - // list not found + // list not found } else { const gchar* new_list[2]; new_list[0] = item; @@ -86,15 +86,15 @@ conf_string_list_add(GKeyFile *keyfile, const char *const group, const char *con } gboolean -conf_string_list_remove(GKeyFile *keyfile, const char *const group, const char *const key, const char *const item) +conf_string_list_remove(GKeyFile* keyfile, const char* const group, const char* const key, const char* const item) { gsize length; - gchar **list = g_key_file_get_string_list(keyfile, group, key, &length, NULL); + gchar** list = g_key_file_get_string_list(keyfile, group, key, &length, NULL); gboolean deleted = FALSE; if (list) { int i = 0; - GList *glist = NULL; + GList* glist = NULL; for (i = 0; i < length; i++) { // item found, mark as deleted @@ -111,8 +111,8 @@ conf_string_list_remove(GKeyFile *keyfile, const char *const group, const char * g_key_file_remove_key(keyfile, group, key, NULL); } else { // create the new list entry - const gchar* new_list[g_list_length(glist)+1]; - GList *curr = glist; + const gchar* new_list[g_list_length(glist) + 1]; + GList* curr = glist; i = 0; while (curr) { new_list[i++] = curr->data; diff --git a/src/config/conflists.h b/src/config/conflists.h index a939b406..92771875 100644 --- a/src/config/conflists.h +++ b/src/config/conflists.h @@ -38,9 +38,9 @@ #include <glib.h> -gboolean conf_string_list_add(GKeyFile *keyfile, const char *const group, const char *const key, - const char *const item); -gboolean conf_string_list_remove(GKeyFile *keyfile, const char *const group, const char *const key, - const char *const item); +gboolean conf_string_list_add(GKeyFile* keyfile, const char* const group, const char* const key, + const char* const item); +gboolean conf_string_list_remove(GKeyFile* keyfile, const char* const group, const char* const key, + const char* const item); #endif diff --git a/src/config/files.c b/src/config/files.c index 576303fb..72b192e4 100644 --- a/src/config/files.c +++ b/src/config/files.c @@ -51,18 +51,18 @@ static char* _files_get_xdg_data_home(void); void files_create_directories(void) { - gchar *xdg_config = _files_get_xdg_config_home(); - gchar *xdg_data = _files_get_xdg_data_home(); + gchar* xdg_config = _files_get_xdg_config_home(); + gchar* xdg_data = _files_get_xdg_data_home(); - GString *themes_dir = g_string_new(xdg_config); + GString* themes_dir = g_string_new(xdg_config); g_string_append(themes_dir, "/profanity/themes"); - GString *icons_dir = g_string_new(xdg_config); + GString* icons_dir = g_string_new(xdg_config); g_string_append(icons_dir, "/profanity/icons"); - GString *chatlogs_dir = g_string_new(xdg_data); + GString* chatlogs_dir = g_string_new(xdg_data); g_string_append(chatlogs_dir, "/profanity/chatlogs"); - GString *logs_dir = g_string_new(xdg_data); + GString* logs_dir = g_string_new(xdg_data); g_string_append(logs_dir, "/profanity/logs"); - GString *plugins_dir = g_string_new(xdg_data); + GString* plugins_dir = g_string_new(xdg_data); g_string_append(plugins_dir, "/profanity/plugins"); if (!mkdir_recursive(themes_dir->str)) { @@ -94,14 +94,14 @@ files_create_directories(void) gchar* files_get_inputrc_file(void) { - gchar *xdg_config = _files_get_xdg_config_home(); - GString *inputrc_file = g_string_new(xdg_config); + gchar* xdg_config = _files_get_xdg_config_home(); + GString* inputrc_file = g_string_new(xdg_config); g_free(xdg_config); g_string_append(inputrc_file, "/profanity/inputrc"); if (g_file_test(inputrc_file->str, G_FILE_TEST_IS_REGULAR)) { - gchar *result = g_strdup(inputrc_file->str); + gchar* result = g_strdup(inputrc_file->str); g_string_free(inputrc_file, TRUE); return result; @@ -113,10 +113,10 @@ files_get_inputrc_file(void) } char* -files_get_log_file(const char *const log_file) +files_get_log_file(const char* const log_file) { - gchar *xdg_data = _files_get_xdg_data_home(); - GString *logfile = g_string_new(xdg_data); + gchar* xdg_data = _files_get_xdg_data_home(); + GString* logfile = g_string_new(xdg_data); if (log_file) { g_string_append(logfile, "/profanity/logs/"); @@ -131,7 +131,7 @@ files_get_log_file(const char *const log_file) g_string_append(logfile, ".log"); - char *result = g_strdup(logfile->str); + char* result = g_strdup(logfile->str); free(xdg_data); g_string_free(logfile, TRUE); @@ -140,13 +140,13 @@ files_get_log_file(const char *const log_file) } gchar* -files_get_config_path(const char *const config_base) +files_get_config_path(const char* const config_base) { - gchar *xdg_config = _files_get_xdg_config_home(); - GString *file_str = g_string_new(xdg_config); + gchar* xdg_config = _files_get_xdg_config_home(); + GString* file_str = g_string_new(xdg_config); g_string_append(file_str, "/profanity/"); g_string_append(file_str, config_base); - gchar *result = g_strdup(file_str->str); + gchar* result = g_strdup(file_str->str); g_free(xdg_config); g_string_free(file_str, TRUE); @@ -154,13 +154,13 @@ files_get_config_path(const char *const config_base) } gchar* -files_get_data_path(const char *const data_base) +files_get_data_path(const char* const data_base) { - gchar *xdg_data = _files_get_xdg_data_home(); - GString *file_str = g_string_new(xdg_data); + gchar* xdg_data = _files_get_xdg_data_home(); + GString* file_str = g_string_new(xdg_data); g_string_append(file_str, "/profanity/"); g_string_append(file_str, data_base); - gchar *result = g_strdup(file_str->str); + gchar* result = g_strdup(file_str->str); g_free(xdg_data); g_string_free(file_str, TRUE); @@ -168,18 +168,18 @@ files_get_data_path(const char *const data_base) } gchar* -files_get_account_data_path(const char *const specific_dir, const char *const jid) +files_get_account_data_path(const char* const specific_dir, const char* const jid) { - gchar *data_dir = files_get_data_path(specific_dir); - GString *result_dir = g_string_new(data_dir); + gchar* data_dir = files_get_data_path(specific_dir); + GString* result_dir = g_string_new(data_dir); g_free(data_dir); - gchar *account_dir = str_replace(jid, "@", "_at_"); + gchar* account_dir = str_replace(jid, "@", "_at_"); g_string_append(result_dir, "/"); g_string_append(result_dir, account_dir); g_free(account_dir); - gchar *result = g_strdup(result_dir->str); + gchar* result = g_strdup(result_dir->str); g_string_free(result_dir, TRUE); return result; @@ -188,8 +188,8 @@ files_get_account_data_path(const char *const specific_dir, const char *const ji static char* _files_get_xdg_config_home(void) { - gchar *xdg_config_home_env = getenv("XDG_CONFIG_HOME"); - gchar *xdg_config_home = NULL; + gchar* xdg_config_home_env = getenv("XDG_CONFIG_HOME"); + gchar* xdg_config_home = NULL; if (xdg_config_home_env) { xdg_config_home = strdup(xdg_config_home_env); @@ -199,9 +199,9 @@ _files_get_xdg_config_home(void) if (xdg_config_home && (strcmp(xdg_config_home, "") != 0)) { return xdg_config_home; } else { - GString *default_path = g_string_new(getenv("HOME")); + GString* default_path = g_string_new(getenv("HOME")); g_string_append(default_path, "/.config"); - char *result = strdup(default_path->str); + char* result = strdup(default_path->str); g_string_free(default_path, TRUE); return result; @@ -211,8 +211,8 @@ _files_get_xdg_config_home(void) static char* _files_get_xdg_data_home(void) { - gchar *xdg_data_home_env = getenv("XDG_DATA_HOME"); - gchar *xdg_data_home = NULL; + gchar* xdg_data_home_env = getenv("XDG_DATA_HOME"); + gchar* xdg_data_home = NULL; if (xdg_data_home_env) { xdg_data_home = strdup(xdg_data_home_env); @@ -222,9 +222,9 @@ _files_get_xdg_data_home(void) if (xdg_data_home && (strcmp(xdg_data_home, "") != 0)) { return xdg_data_home; } else { - GString *default_path = g_string_new(getenv("HOME")); + GString* default_path = g_string_new(getenv("HOME")); g_string_append(default_path, "/.local/share"); - gchar *result = strdup(default_path->str); + gchar* result = strdup(default_path->str); g_string_free(default_path, TRUE); return result; diff --git a/src/config/files.h b/src/config/files.h index 2a74793f..d5c96b0f 100644 --- a/src/config/files.h +++ b/src/config/files.h @@ -39,32 +39,32 @@ #include <glib.h> -#define FILE_PROFRC "profrc" -#define FILE_ACCOUNTS "accounts" -#define FILE_TLSCERTS "tlscerts" -#define FILE_PLUGIN_SETTINGS "plugin_settings" -#define FILE_PLUGIN_THEMES "plugin_themes" -#define FILE_CAPSCACHE "capscache" -#define FILE_PROFANITY_IDENTIFIER "profident" +#define FILE_PROFRC "profrc" +#define FILE_ACCOUNTS "accounts" +#define FILE_TLSCERTS "tlscerts" +#define FILE_PLUGIN_SETTINGS "plugin_settings" +#define FILE_PLUGIN_THEMES "plugin_themes" +#define FILE_CAPSCACHE "capscache" +#define FILE_PROFANITY_IDENTIFIER "profident" #define FILE_BOOKMARK_AUTOJOIN_IGNORE "bookmark_ignore" -#define DIR_THEMES "themes" -#define DIR_ICONS "icons" -#define DIR_SCRIPTS "scripts" +#define DIR_THEMES "themes" +#define DIR_ICONS "icons" +#define DIR_SCRIPTS "scripts" #define DIR_CHATLOGS "chatlogs" -#define DIR_OTR "otr" -#define DIR_PGP "pgp" -#define DIR_OMEMO "omemo" -#define DIR_PLUGINS "plugins" +#define DIR_OTR "otr" +#define DIR_PGP "pgp" +#define DIR_OMEMO "omemo" +#define DIR_PLUGINS "plugins" #define DIR_DATABASE "database" void files_create_directories(void); -gchar* files_get_config_path(const char *const config_base); -gchar* files_get_data_path(const char *const data_base); -gchar* files_get_account_data_path(const char *const specific_dir, const char *const jid); +gchar* files_get_config_path(const char* const config_base); +gchar* files_get_data_path(const char* const data_base); +gchar* files_get_account_data_path(const char* const specific_dir, const char* const jid); -gchar* files_get_log_file(const char *const log_file); +gchar* files_get_log_file(const char* const log_file); gchar* files_get_inputrc_file(void); #endif diff --git a/src/config/preferences.c b/src/config/preferences.c index a1b1dbb3..00a1e5ce 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -52,25 +52,25 @@ // preference groups refer to the sections in .profrc or theme files // for example [ui] but not [colours] which is handled in theme.c -#define PREF_GROUP_LOGGING "logging" -#define PREF_GROUP_CHATSTATES "chatstates" -#define PREF_GROUP_UI "ui" +#define PREF_GROUP_LOGGING "logging" +#define PREF_GROUP_CHATSTATES "chatstates" +#define PREF_GROUP_UI "ui" #define PREF_GROUP_NOTIFICATIONS "notifications" -#define PREF_GROUP_PRESENCE "presence" -#define PREF_GROUP_CONNECTION "connection" -#define PREF_GROUP_ALIAS "alias" -#define PREF_GROUP_OTR "otr" -#define PREF_GROUP_PGP "pgp" -#define PREF_GROUP_OMEMO "omemo" -#define PREF_GROUP_OX "ox" -#define PREF_GROUP_MUC "muc" -#define PREF_GROUP_PLUGINS "plugins" -#define PREF_GROUP_EXECUTABLES "executables" +#define PREF_GROUP_PRESENCE "presence" +#define PREF_GROUP_CONNECTION "connection" +#define PREF_GROUP_ALIAS "alias" +#define PREF_GROUP_OTR "otr" +#define PREF_GROUP_PGP "pgp" +#define PREF_GROUP_OMEMO "omemo" +#define PREF_GROUP_OX "ox" +#define PREF_GROUP_MUC "muc" +#define PREF_GROUP_PLUGINS "plugins" +#define PREF_GROUP_EXECUTABLES "executables" #define INPBLOCK_DEFAULT 1000 -static gchar *prefs_loc; -static GKeyFile *prefs; +static gchar* prefs_loc; +static GKeyFile* prefs; gint log_maxsize = 0; static Autocomplete boolean_choice_ac; @@ -83,9 +83,10 @@ static gboolean _get_default_boolean(preference_t pref); static char* _get_default_string(preference_t pref); static char** _get_default_string_list(preference_t pref); -static void _prefs_load(void) +static void +_prefs_load(void) { - GError *err = NULL; + GError* err = NULL; log_maxsize = g_key_file_get_integer(prefs, PREF_GROUP_LOGGING, "maxsize", &err); if (err) { log_maxsize = 0; @@ -101,7 +102,7 @@ static void _prefs_load(void) // move pre 0.5.0 autoaway.message to autoaway.awaymessage if (g_key_file_has_key(prefs, PREF_GROUP_PRESENCE, "autoaway.message", NULL)) { - char *message = g_key_file_get_string(prefs, PREF_GROUP_PRESENCE, "autoaway.message", NULL); + char* message = g_key_file_get_string(prefs, PREF_GROUP_PRESENCE, "autoaway.message", NULL); g_key_file_set_string(prefs, PREF_GROUP_PRESENCE, "autoaway.awaymessage", message); g_key_file_remove_key(prefs, PREF_GROUP_PRESENCE, "autoaway.message", NULL); g_free(message); @@ -109,8 +110,8 @@ static void _prefs_load(void) // migrate pre 0.5.0 time settings if (g_key_file_has_key(prefs, PREF_GROUP_UI, "time", NULL)) { - char *time = g_key_file_get_string(prefs, PREF_GROUP_UI, "time", NULL); - char *val = NULL; + char* time = g_key_file_get_string(prefs, PREF_GROUP_UI, "time", NULL); + char* val = NULL; if (time) { val = time; } else { @@ -128,7 +129,7 @@ static void _prefs_load(void) // move pre 0.5.0 notify settings if (g_key_file_has_key(prefs, PREF_GROUP_NOTIFICATIONS, "room", NULL)) { - char *value = g_key_file_get_string(prefs, PREF_GROUP_NOTIFICATIONS, "room", NULL); + char* value = g_key_file_get_string(prefs, PREF_GROUP_NOTIFICATIONS, "room", NULL); if (g_strcmp0(value, "on") == 0) { g_key_file_set_boolean(prefs, PREF_GROUP_NOTIFICATIONS, "room", TRUE); } else if (g_strcmp0(value, "off") == 0) { @@ -154,7 +155,7 @@ static void _prefs_load(void) // after 0.8.1: titlebar use jid|name -> titlebar show|hide jid|name if (g_key_file_has_key(prefs, PREF_GROUP_UI, "titlebar.muc.title", NULL)) { - char *value = g_key_file_get_string(prefs, PREF_GROUP_UI, "titlebar.muc.title", NULL); + char* value = g_key_file_get_string(prefs, PREF_GROUP_UI, "titlebar.muc.title", NULL); if (g_strcmp0(value, "name") == 0) { g_key_file_set_boolean(prefs, PREF_GROUP_UI, "titlebar.muc.title.name", TRUE); } else if (g_strcmp0(value, "jid") == 0) { @@ -164,9 +165,9 @@ static void _prefs_load(void) // 0.9.0 introduced /urlopen. It was saved under "logging" section. Now we have a new "executables" section. if (g_key_file_has_key(prefs, PREF_GROUP_LOGGING, "urlopen.cmd", NULL)) { - char *val = g_key_file_get_string(prefs, PREF_GROUP_LOGGING, "urlopen.cmd", NULL); + char* val = g_key_file_get_string(prefs, PREF_GROUP_LOGGING, "urlopen.cmd", NULL); - GString *value = g_string_new("false;"); + GString* value = g_string_new("false;"); value = g_string_append(value, val); value = g_string_append(value, " %u;"); @@ -178,7 +179,7 @@ static void _prefs_load(void) // 0.9.0 introduced configurable /avatar. It was saved under "logging" section. Now we have a new "executables" section. if (g_key_file_has_key(prefs, PREF_GROUP_LOGGING, "avatar.cmd", NULL)) { - char *value = g_key_file_get_string(prefs, PREF_GROUP_LOGGING, "avatar.cmd", NULL); + char* value = g_key_file_get_string(prefs, PREF_GROUP_LOGGING, "avatar.cmd", NULL); g_key_file_set_string(prefs, PREF_GROUP_EXECUTABLES, "avatar.cmd", value); g_key_file_remove_key(prefs, PREF_GROUP_LOGGING, "avatar.cmd", NULL); } @@ -191,7 +192,7 @@ static void _prefs_load(void) room_trigger_ac = autocomplete_new(); gsize len = 0; - gchar **triggers = g_key_file_get_string_list(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", &len, NULL); + gchar** triggers = g_key_file_get_string_list(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", &len, NULL); int i = 0; for (i = 0; i < len; i++) { @@ -201,7 +202,8 @@ static void _prefs_load(void) } /* Clean up after _prefs_load() */ -static void _prefs_close(void) +static void +_prefs_close(void) { autocomplete_free(boolean_choice_ac); autocomplete_free(room_trigger_ac); @@ -227,7 +229,7 @@ prefs_reload(void) } void -prefs_load(char *config_file) +prefs_load(char* config_file) { if (config_file == NULL) { @@ -265,7 +267,7 @@ prefs_close(void) } char* -prefs_autocomplete_boolean_choice(const char *const prefix, gboolean previous, void *context) +prefs_autocomplete_boolean_choice(const char* const prefix, gboolean previous, void* context) { return autocomplete_complete(boolean_choice_ac, prefix, TRUE, previous); } @@ -277,7 +279,7 @@ prefs_reset_boolean_choice(void) } char* -prefs_autocomplete_room_trigger(const char *const prefix, gboolean previous, void *context) +prefs_autocomplete_room_trigger(const char* const prefix, gboolean previous, void* context) { return autocomplete_complete(room_trigger_ac, prefix, TRUE, previous); } @@ -303,16 +305,16 @@ prefs_do_chat_notify(gboolean current_win) } GList* -prefs_message_get_triggers(const char *const message) +prefs_message_get_triggers(const char* const message) { - GList *result = NULL; + GList* result = NULL; - char *message_lower = g_utf8_strdown(message, -1); + char* message_lower = g_utf8_strdown(message, -1); gsize len = 0; - gchar **triggers = g_key_file_get_string_list(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", &len, NULL); + gchar** triggers = g_key_file_get_string_list(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", &len, NULL); int i; for (i = 0; i < len; i++) { - char *trigger_lower = g_utf8_strdown(triggers[i], -1); + char* trigger_lower = g_utf8_strdown(triggers[i], -1); if (g_strrstr(message_lower, trigger_lower)) { result = g_list_append(result, strdup(triggers[i])); } @@ -325,8 +327,8 @@ prefs_message_get_triggers(const char *const message) } gboolean -prefs_do_room_notify(gboolean current_win, const char *const roomjid, const char *const mynick, - const char *const theirnick, const char *const message, gboolean mention, gboolean trigger_found) +prefs_do_room_notify(gboolean current_win, const char* const roomjid, const char* const mynick, + const char* const theirnick, const char* const message, gboolean mention, gboolean trigger_found) { if (g_strcmp0(mynick, theirnick) == 0) { return FALSE; @@ -334,7 +336,7 @@ prefs_do_room_notify(gboolean current_win, const char *const roomjid, const char gboolean notify_current = prefs_get_boolean(PREF_NOTIFY_ROOM_CURRENT); gboolean notify_window = FALSE; - if (!current_win || (current_win && notify_current) ) { + if (!current_win || (current_win && notify_current)) { notify_window = TRUE; } if (!notify_window) { @@ -375,7 +377,7 @@ prefs_do_room_notify(gboolean current_win, const char *const roomjid, const char } gboolean -prefs_do_room_notify_mention(const char *const roomjid, int unread, gboolean mention, gboolean trigger) +prefs_do_room_notify_mention(const char* const roomjid, int unread, gboolean mention, gboolean trigger) { gboolean notify_room = FALSE; if (g_key_file_has_key(prefs, roomjid, "notify", NULL)) { @@ -411,61 +413,61 @@ prefs_do_room_notify_mention(const char *const roomjid, int unread, gboolean men } void -prefs_set_room_notify(const char *const roomjid, gboolean value) +prefs_set_room_notify(const char* const roomjid, gboolean value) { g_key_file_set_boolean(prefs, roomjid, "notify", value); } void -prefs_set_room_notify_mention(const char *const roomjid, gboolean value) +prefs_set_room_notify_mention(const char* const roomjid, gboolean value) { g_key_file_set_boolean(prefs, roomjid, "notify.mention", value); } void -prefs_set_room_notify_trigger(const char *const roomjid, gboolean value) +prefs_set_room_notify_trigger(const char* const roomjid, gboolean value) { g_key_file_set_boolean(prefs, roomjid, "notify.trigger", value); } gboolean -prefs_has_room_notify(const char *const roomjid) +prefs_has_room_notify(const char* const roomjid) { return g_key_file_has_key(prefs, roomjid, "notify", NULL); } gboolean -prefs_has_room_notify_mention(const char *const roomjid) +prefs_has_room_notify_mention(const char* const roomjid) { return g_key_file_has_key(prefs, roomjid, "notify.mention", NULL); } gboolean -prefs_has_room_notify_trigger(const char *const roomjid) +prefs_has_room_notify_trigger(const char* const roomjid) { return g_key_file_has_key(prefs, roomjid, "notify.trigger", NULL); } gboolean -prefs_get_room_notify(const char *const roomjid) +prefs_get_room_notify(const char* const roomjid) { return g_key_file_get_boolean(prefs, roomjid, "notify", NULL); } gboolean -prefs_get_room_notify_mention(const char *const roomjid) +prefs_get_room_notify_mention(const char* const roomjid) { return g_key_file_get_boolean(prefs, roomjid, "notify.mention", NULL); } gboolean -prefs_get_room_notify_trigger(const char *const roomjid) +prefs_get_room_notify_trigger(const char* const roomjid) { return g_key_file_get_boolean(prefs, roomjid, "notify.trigger", NULL); } gboolean -prefs_reset_room_notify(const char *const roomjid) +prefs_reset_room_notify(const char* const roomjid) { if (g_key_file_has_group(prefs, roomjid)) { g_key_file_remove_group(prefs, roomjid, NULL); @@ -478,8 +480,8 @@ prefs_reset_room_notify(const char *const roomjid) gboolean prefs_get_boolean(preference_t pref) { - const char *group = _get_group(pref); - const char *key = _get_key(pref); + const char* group = _get_group(pref); + const char* key = _get_key(pref); gboolean def = _get_default_boolean(pref); if (!g_key_file_has_key(prefs, group, key, NULL)) { @@ -492,19 +494,19 @@ prefs_get_boolean(preference_t pref) void prefs_set_boolean(preference_t pref, gboolean value) { - const char *group = _get_group(pref); - const char *key = _get_key(pref); + const char* group = _get_group(pref); + const char* key = _get_key(pref); g_key_file_set_boolean(prefs, group, key, value); } char* prefs_get_string(preference_t pref) { - const char *group = _get_group(pref); - const char *key = _get_key(pref); - char *def = _get_default_string(pref); + const char* group = _get_group(pref); + const char* key = _get_key(pref); + char* def = _get_default_string(pref); - char *result = g_key_file_get_string(prefs, group, key, NULL); + char* result = g_key_file_get_string(prefs, group, key, NULL); if (result == NULL) { if (def) { @@ -518,13 +520,13 @@ prefs_get_string(preference_t pref) } char* -prefs_get_string_with_option(preference_t pref, gchar *option) +prefs_get_string_with_option(preference_t pref, gchar* option) { - const char *group = _get_group(pref); - const char *key = _get_key(pref); - char *def = _get_default_string(pref); + const char* group = _get_group(pref); + const char* key = _get_key(pref); + char* def = _get_default_string(pref); - char *result = g_key_file_get_locale_string(prefs, group, key, option, NULL); + char* result = g_key_file_get_locale_string(prefs, group, key, option, NULL); if (result == NULL) { // check for user set default @@ -543,13 +545,13 @@ prefs_get_string_with_option(preference_t pref, gchar *option) } gchar** -prefs_get_string_list_with_option(preference_t pref, gchar *option) +prefs_get_string_list_with_option(preference_t pref, gchar* option) { - const char *group = _get_group(pref); - const char *key = _get_key(pref); - char **def = _get_default_string_list(pref); + const char* group = _get_group(pref); + const char* key = _get_key(pref); + char** def = _get_default_string_list(pref); - gchar **result = g_key_file_get_locale_string_list(prefs, group, key, option, NULL, NULL); + gchar** result = g_key_file_get_locale_string_list(prefs, group, key, option, NULL, NULL); if (result) { g_strfreev(def); return result; @@ -570,10 +572,10 @@ prefs_get_string_list_with_option(preference_t pref, gchar *option) } void -prefs_set_string(preference_t pref, char *value) +prefs_set_string(preference_t pref, char* value) { - const char *group = _get_group(pref); - const char *key = _get_key(pref); + const char* group = _get_group(pref); + const char* key = _get_key(pref); if (value == NULL) { g_key_file_remove_key(prefs, group, key, NULL); } else { @@ -582,10 +584,10 @@ prefs_set_string(preference_t pref, char *value) } void -prefs_set_string_with_option(preference_t pref, char *option, char *value) +prefs_set_string_with_option(preference_t pref, char* option, char* value) { - const char *group = _get_group(pref); - const char *key = _get_key(pref); + const char* group = _get_group(pref); + const char* key = _get_key(pref); if (value == NULL) { g_key_file_remove_key(prefs, group, key, NULL); } else { @@ -594,11 +596,11 @@ prefs_set_string_with_option(preference_t pref, char *option, char *value) } void -prefs_set_string_list_with_option(preference_t pref, char *option, const gchar* const *values) +prefs_set_string_list_with_option(preference_t pref, char* option, const gchar* const* values) { - const char *group = _get_group(pref); - const char *key = _get_key(pref); - if (values == NULL || *values == NULL){ + const char* group = _get_group(pref); + const char* key = _get_key(pref); + if (values == NULL || *values == NULL) { if (g_strcmp0(option, "*") == 0) { g_key_file_set_string_list(prefs, group, key, NULL, 0); } else { @@ -606,7 +608,7 @@ prefs_set_string_list_with_option(preference_t pref, char *option, const gchar* } } else { guint num_values = 0; - while(values[num_values]) { + while (values[num_values]) { num_values++; } if (g_strcmp0(option, "*") == 0) { @@ -620,10 +622,10 @@ prefs_set_string_list_with_option(preference_t pref, char *option, const gchar* char* prefs_get_tls_certpath(void) { - const char *group = _get_group(PREF_TLS_CERTPATH); - const char *key = _get_key(PREF_TLS_CERTPATH); + const char* group = _get_group(PREF_TLS_CERTPATH); + const char* key = _get_key(PREF_TLS_CERTPATH); - char *setting = g_key_file_get_string(prefs, group, key, NULL); + char* setting = g_key_file_get_string(prefs, group, key, NULL); if (g_strcmp0(setting, "none") == 0) { g_free(setting); @@ -631,26 +633,26 @@ prefs_get_tls_certpath(void) } if (setting == NULL) { - if (g_file_test("/etc/ssl/certs", G_FILE_TEST_IS_DIR)) { + if (g_file_test("/etc/ssl/certs", G_FILE_TEST_IS_DIR)) { return strdup("/etc/ssl/certs"); } - if (g_file_test("/etc/pki/tls/certs", G_FILE_TEST_IS_DIR)) { + if (g_file_test("/etc/pki/tls/certs", G_FILE_TEST_IS_DIR)) { return strdup("/etc/pki/tls/certs"); } - if (g_file_test("/etc/ssl", G_FILE_TEST_IS_DIR)) { + if (g_file_test("/etc/ssl", G_FILE_TEST_IS_DIR)) { return strdup("/etc/ssl"); } - if (g_file_test("/etc/pki/tls", G_FILE_TEST_IS_DIR)) { + if (g_file_test("/etc/pki/tls", G_FILE_TEST_IS_DIR)) { return strdup("/etc/pki/tls"); } - if (g_file_test("/system/etc/security/cacerts", G_FILE_TEST_IS_DIR)) { + if (g_file_test("/system/etc/security/cacerts", G_FILE_TEST_IS_DIR)) { return strdup("/system/etc/security/cacerts"); } return NULL; } - char *result = strdup(setting); + char* result = strdup(setting); g_free(setting); return result; @@ -855,21 +857,21 @@ prefs_get_plugins(void) } void -prefs_add_plugin(const char *const name) +prefs_add_plugin(const char* const name) { conf_string_list_add(prefs, PREF_GROUP_PLUGINS, "load", name); _save_prefs(); } void -prefs_remove_plugin(const char *const name) +prefs_remove_plugin(const char* const name) { conf_string_list_remove(prefs, PREF_GROUP_PLUGINS, "load", name); _save_prefs(); } void -prefs_free_plugins(gchar **plugins) +prefs_free_plugins(gchar** plugins) { g_strfreev(plugins); } @@ -897,9 +899,9 @@ prefs_get_occupants_char(void) { char result = 0; - char *resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "occupants.char", NULL); + char* resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "occupants.char", NULL); if (!resultstr) { - result = 0; + result = 0; } else { result = resultstr[0]; } @@ -950,9 +952,9 @@ prefs_get_occupants_header_char(void) { char result = 0; - char *resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "occupants.header.char", NULL); + char* resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "occupants.header.char", NULL); if (!resultstr) { - result = 0; + result = 0; } else { result = resultstr[0]; } @@ -996,11 +998,11 @@ prefs_get_roster_size(void) } static char* -_prefs_get_encryption_char(const char *const ch, const char *const pref_group, const char *const key) +_prefs_get_encryption_char(const char* const ch, const char* const pref_group, const char* const key) { - char *result = NULL; + char* result = NULL; - char *resultstr = g_key_file_get_string(prefs, pref_group, key, NULL); + char* resultstr = g_key_file_get_string(prefs, pref_group, key, NULL); if (!resultstr) { result = strdup(ch); } else { @@ -1011,7 +1013,7 @@ _prefs_get_encryption_char(const char *const ch, const char *const pref_group, c } static gboolean -_prefs_set_encryption_char(const char *const ch, const char *const pref_group, const char *const key) +_prefs_set_encryption_char(const char* const ch, const char* const pref_group, const char* const key) { if (g_utf8_strlen(ch, 4) == 1) { g_key_file_set_string(prefs, pref_group, key, ch); @@ -1029,7 +1031,7 @@ prefs_get_otr_char(void) } gboolean -prefs_set_otr_char(char *ch) +prefs_set_otr_char(char* ch) { return _prefs_set_encryption_char(ch, PREF_GROUP_OTR, "otr.char"); } @@ -1041,7 +1043,7 @@ prefs_get_pgp_char(void) } gboolean -prefs_set_pgp_char(char *ch) +prefs_set_pgp_char(char* ch) { return _prefs_set_encryption_char(ch, PREF_GROUP_PGP, "pgp.char"); } @@ -1053,7 +1055,7 @@ prefs_get_ox_char(void) } gboolean -prefs_set_ox_char(char *ch) +prefs_set_ox_char(char* ch) { return _prefs_set_encryption_char(ch, PREF_GROUP_OX, "ox.char"); } @@ -1065,7 +1067,7 @@ prefs_get_omemo_char(void) } gboolean -prefs_set_omemo_char(char *ch) +prefs_set_omemo_char(char* ch) { return _prefs_set_encryption_char(ch, PREF_GROUP_OMEMO, "omemo.char"); } @@ -1075,9 +1077,9 @@ prefs_get_roster_header_char(void) { char result = 0; - char *resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "roster.header.char", NULL); + char* resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "roster.header.char", NULL); if (!resultstr) { - result = 0; + result = 0; } else { result = resultstr[0]; } @@ -1107,9 +1109,9 @@ prefs_get_roster_contact_char(void) { char result = 0; - char *resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "roster.contact.char", NULL); + char* resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "roster.contact.char", NULL); if (!resultstr) { - result = 0; + result = 0; } else { result = resultstr[0]; } @@ -1139,9 +1141,9 @@ prefs_get_roster_resource_char(void) { char result = 0; - char *resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "roster.resource.char", NULL); + char* resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "roster.resource.char", NULL); if (!resultstr) { - result = 0; + result = 0; } else { result = resultstr[0]; } @@ -1171,9 +1173,9 @@ prefs_get_roster_private_char(void) { char result = 0; - char *resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "roster.private.char", NULL); + char* resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "roster.private.char", NULL); if (!resultstr) { - result = 0; + result = 0; } else { result = resultstr[0]; } @@ -1203,9 +1205,9 @@ prefs_get_roster_room_char(void) { char result = 0; - char *resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "roster.rooms.char", NULL); + char* resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "roster.rooms.char", NULL); if (!resultstr) { - result = 0; + result = 0; } else { result = resultstr[0]; } @@ -1235,9 +1237,9 @@ prefs_get_roster_room_private_char(void) { char result = 0; - char *resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "roster.rooms.private.char", NULL); + char* resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "roster.rooms.private.char", NULL); if (!resultstr) { - result = 0; + result = 0; } else { result = resultstr[0]; } @@ -1328,9 +1330,9 @@ prefs_set_roster_presence_indent(gint value) char* prefs_get_correction_char(void) { - char *result = "+"; + char* result = "+"; - char *resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "correction.char", NULL); + char* resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "correction.char", NULL); if (!resultstr) { result = strdup("+"); } else { @@ -1351,7 +1353,7 @@ prefs_set_correction_char(char ch) } gboolean -prefs_add_room_notify_trigger(const char * const text) +prefs_add_room_notify_trigger(const char* const text) { gboolean res = conf_string_list_add(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", text); @@ -1363,7 +1365,7 @@ prefs_add_room_notify_trigger(const char * const text) } gboolean -prefs_remove_room_notify_trigger(const char * const text) +prefs_remove_room_notify_trigger(const char* const text) { gboolean res = conf_string_list_remove(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", text); _save_prefs(); @@ -1378,9 +1380,9 @@ prefs_remove_room_notify_trigger(const char * const text) GList* prefs_get_room_notify_triggers(void) { - GList *result = NULL; + GList* result = NULL; gsize len = 0; - gchar **triggers = g_key_file_get_string_list(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", &len, NULL); + gchar** triggers = g_key_file_get_string_list(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", &len, NULL); int i; for (i = 0; i < len; i++) { @@ -1395,7 +1397,7 @@ prefs_get_room_notify_triggers(void) ProfWinPlacement* prefs_create_profwin_placement(int titlebar, int mainwin, int statusbar, int inputwin) { - ProfWinPlacement *placement = malloc(sizeof(ProfWinPlacement)); + ProfWinPlacement* placement = malloc(sizeof(ProfWinPlacement)); placement->titlebar_pos = titlebar; placement->mainwin_pos = mainwin; placement->statusbar_pos = statusbar; @@ -1405,7 +1407,7 @@ prefs_create_profwin_placement(int titlebar, int mainwin, int statusbar, int inp } void -prefs_free_win_placement(ProfWinPlacement *placement) +prefs_free_win_placement(ProfWinPlacement* placement) { free(placement); } @@ -1460,7 +1462,7 @@ prefs_get_win_placement(void) } void -prefs_save_win_placement(ProfWinPlacement *placement) +prefs_save_win_placement(ProfWinPlacement* placement) { g_key_file_set_integer(prefs, PREF_GROUP_UI, "titlebar.position", placement->titlebar_pos); g_key_file_set_integer(prefs, PREF_GROUP_UI, "mainwin.position", placement->mainwin_pos); @@ -1472,18 +1474,18 @@ prefs_save_win_placement(ProfWinPlacement *placement) gboolean prefs_titlebar_pos_up(void) { - ProfWinPlacement *placement = prefs_get_win_placement(); + ProfWinPlacement* placement = prefs_get_win_placement(); int pos = 2; - for (pos = 2; pos<5; pos++) { + for (pos = 2; pos < 5; pos++) { if (placement->titlebar_pos == pos) { - placement->titlebar_pos = pos-1; + placement->titlebar_pos = pos - 1; - if (placement->mainwin_pos == pos-1) { + if (placement->mainwin_pos == pos - 1) { placement->mainwin_pos = pos; - } else if (placement->statusbar_pos == pos-1) { + } else if (placement->statusbar_pos == pos - 1) { placement->statusbar_pos = pos; - } else if (placement->inputwin_pos == pos-1) { + } else if (placement->inputwin_pos == pos - 1) { placement->inputwin_pos = pos; } @@ -1500,18 +1502,18 @@ prefs_titlebar_pos_up(void) gboolean prefs_mainwin_pos_up(void) { - ProfWinPlacement *placement = prefs_get_win_placement(); + ProfWinPlacement* placement = prefs_get_win_placement(); int pos = 2; - for (pos = 2; pos<5; pos++) { + for (pos = 2; pos < 5; pos++) { if (placement->mainwin_pos == pos) { - placement->mainwin_pos = pos-1; + placement->mainwin_pos = pos - 1; - if (placement->titlebar_pos == pos-1) { + if (placement->titlebar_pos == pos - 1) { placement->titlebar_pos = pos; - } else if (placement->statusbar_pos == pos-1) { + } else if (placement->statusbar_pos == pos - 1) { placement->statusbar_pos = pos; - } else if (placement->inputwin_pos == pos-1) { + } else if (placement->inputwin_pos == pos - 1) { placement->inputwin_pos = pos; } @@ -1528,18 +1530,18 @@ prefs_mainwin_pos_up(void) gboolean prefs_statusbar_pos_up(void) { - ProfWinPlacement *placement = prefs_get_win_placement(); + ProfWinPlacement* placement = prefs_get_win_placement(); int pos = 2; - for (pos = 2; pos<5; pos++) { + for (pos = 2; pos < 5; pos++) { if (placement->statusbar_pos == pos) { - placement->statusbar_pos = pos-1; + placement->statusbar_pos = pos - 1; - if (placement->titlebar_pos == pos-1) { + if (placement->titlebar_pos == pos - 1) { placement->titlebar_pos = pos; - } else if (placement->mainwin_pos == pos-1) { + } else if (placement->mainwin_pos == pos - 1) { placement->mainwin_pos = pos; - } else if (placement->inputwin_pos == pos-1) { + } else if (placement->inputwin_pos == pos - 1) { placement->inputwin_pos = pos; } @@ -1556,18 +1558,18 @@ prefs_statusbar_pos_up(void) gboolean prefs_inputwin_pos_up(void) { - ProfWinPlacement *placement = prefs_get_win_placement(); + ProfWinPlacement* placement = prefs_get_win_placement(); int pos = 2; - for (pos = 2; pos<5; pos++) { + for (pos = 2; pos < 5; pos++) { if (placement->inputwin_pos == pos) { - placement->inputwin_pos = pos-1; + placement->inputwin_pos = pos - 1; - if (placement->titlebar_pos == pos-1) { + if (placement->titlebar_pos == pos - 1) { placement->titlebar_pos = pos; - } else if (placement->mainwin_pos == pos-1) { + } else if (placement->mainwin_pos == pos - 1) { placement->mainwin_pos = pos; - } else if (placement->statusbar_pos == pos-1) { + } else if (placement->statusbar_pos == pos - 1) { placement->statusbar_pos = pos; } @@ -1584,18 +1586,18 @@ prefs_inputwin_pos_up(void) gboolean prefs_titlebar_pos_down(void) { - ProfWinPlacement *placement = prefs_get_win_placement(); + ProfWinPlacement* placement = prefs_get_win_placement(); int pos = 1; - for (pos = 1; pos<4; pos++) { + for (pos = 1; pos < 4; pos++) { if (placement->titlebar_pos == pos) { - placement->titlebar_pos = pos+1; + placement->titlebar_pos = pos + 1; - if (placement->mainwin_pos == pos+1) { + if (placement->mainwin_pos == pos + 1) { placement->mainwin_pos = pos; - } else if (placement->statusbar_pos == pos+1) { + } else if (placement->statusbar_pos == pos + 1) { placement->statusbar_pos = pos; - } else if (placement->inputwin_pos == pos+1) { + } else if (placement->inputwin_pos == pos + 1) { placement->inputwin_pos = pos; } @@ -1612,18 +1614,18 @@ prefs_titlebar_pos_down(void) gboolean prefs_mainwin_pos_down(void) { - ProfWinPlacement *placement = prefs_get_win_placement(); + ProfWinPlacement* placement = prefs_get_win_placement(); int pos = 1; - for (pos = 1; pos<4; pos++) { + for (pos = 1; pos < 4; pos++) { if (placement->mainwin_pos == pos) { - placement->mainwin_pos = pos+1; + placement->mainwin_pos = pos + 1; - if (placement->titlebar_pos == pos+1) { + if (placement->titlebar_pos == pos + 1) { placement->titlebar_pos = pos; - } else if (placement->statusbar_pos == pos+1) { + } else if (placement->statusbar_pos == pos + 1) { placement->statusbar_pos = pos; - } else if (placement->inputwin_pos == pos+1) { + } else if (placement->inputwin_pos == pos + 1) { placement->inputwin_pos = pos; } @@ -1640,18 +1642,18 @@ prefs_mainwin_pos_down(void) gboolean prefs_statusbar_pos_down(void) { - ProfWinPlacement *placement = prefs_get_win_placement(); + ProfWinPlacement* placement = prefs_get_win_placement(); int pos = 1; - for (pos = 1; pos<4; pos++) { + for (pos = 1; pos < 4; pos++) { if (placement->statusbar_pos == pos) { - placement->statusbar_pos = pos+1; + placement->statusbar_pos = pos + 1; - if (placement->titlebar_pos == pos+1) { + if (placement->titlebar_pos == pos + 1) { placement->titlebar_pos = pos; - } else if (placement->mainwin_pos == pos+1) { + } else if (placement->mainwin_pos == pos + 1) { placement->mainwin_pos = pos; - } else if (placement->inputwin_pos == pos+1) { + } else if (placement->inputwin_pos == pos + 1) { placement->inputwin_pos = pos; } @@ -1668,18 +1670,18 @@ prefs_statusbar_pos_down(void) gboolean prefs_inputwin_pos_down(void) { - ProfWinPlacement *placement = prefs_get_win_placement(); + ProfWinPlacement* placement = prefs_get_win_placement(); int pos = 1; - for (pos = 1; pos<4; pos++) { + for (pos = 1; pos < 4; pos++) { if (placement->inputwin_pos == pos) { - placement->inputwin_pos = pos+1; + placement->inputwin_pos = pos + 1; - if (placement->titlebar_pos == pos+1) { + if (placement->titlebar_pos == pos + 1) { placement->titlebar_pos = pos; - } else if (placement->mainwin_pos == pos+1) { + } else if (placement->mainwin_pos == pos + 1) { placement->mainwin_pos = pos; - } else if (placement->statusbar_pos == pos+1) { + } else if (placement->statusbar_pos == pos + 1) { placement->statusbar_pos = pos; } @@ -1694,7 +1696,7 @@ prefs_inputwin_pos_down(void) } gboolean -prefs_add_alias(const char *const name, const char *const value) +prefs_add_alias(const char* const name, const char* const value) { if (g_key_file_has_key(prefs, PREF_GROUP_ALIAS, name, NULL)) { return FALSE; @@ -1705,14 +1707,13 @@ prefs_add_alias(const char *const name, const char *const value) } char* -prefs_get_alias(const char *const name) +prefs_get_alias(const char* const name) { return g_key_file_get_string(prefs, PREF_GROUP_ALIAS, name, NULL); - } gboolean -prefs_remove_alias(const char *const name) +prefs_remove_alias(const char* const name) { if (!g_key_file_has_key(prefs, PREF_GROUP_ALIAS, name, NULL)) { return FALSE; @@ -1723,10 +1724,10 @@ prefs_remove_alias(const char *const name) } static gint -_alias_cmp(gconstpointer *p1, gconstpointer *p2) +_alias_cmp(gconstpointer* p1, gconstpointer* p2) { - ProfAlias *alias1 = (ProfAlias*)p1; - ProfAlias *alias2 = (ProfAlias*)p2; + ProfAlias* alias1 = (ProfAlias*)p1; + ProfAlias* alias2 = (ProfAlias*)p2; return strcmp(alias1->name, alias2->name); } @@ -1737,16 +1738,16 @@ prefs_get_aliases(void) if (!g_key_file_has_group(prefs, PREF_GROUP_ALIAS)) { return NULL; } else { - GList *result = NULL; + GList* result = NULL; gsize len; - gchar **keys = g_key_file_get_keys(prefs, PREF_GROUP_ALIAS, &len, NULL); + gchar** keys = g_key_file_get_keys(prefs, PREF_GROUP_ALIAS, &len, NULL); int i; for (i = 0; i < len; i++) { - char *name = keys[i]; - char *value = g_key_file_get_string(prefs, PREF_GROUP_ALIAS, name, NULL); + char* name = keys[i]; + char* value = g_key_file_get_string(prefs, PREF_GROUP_ALIAS, name, NULL); if (value) { - ProfAlias *alias = malloc(sizeof(struct prof_alias_t)); + ProfAlias* alias = malloc(sizeof(struct prof_alias_t)); alias->name = strdup(name); alias->value = strdup(value); @@ -1763,7 +1764,7 @@ prefs_get_aliases(void) } void -_free_alias(ProfAlias *alias) +_free_alias(ProfAlias* alias) { FREE_SET_NULL(alias->name); FREE_SET_NULL(alias->value); @@ -1771,7 +1772,7 @@ _free_alias(ProfAlias *alias) } void -prefs_free_aliases(GList *aliases) +prefs_free_aliases(GList* aliases) { g_list_free_full(aliases, (GDestroyNotify)_free_alias); } @@ -1780,9 +1781,9 @@ static void _save_prefs(void) { gsize g_data_size; - gchar *g_prefs_data = g_key_file_to_data(prefs, &g_data_size, NULL); - gchar *base = g_path_get_dirname(prefs_loc); - gchar *true_loc = get_file_or_linked(prefs_loc, base); + gchar* g_prefs_data = g_key_file_to_data(prefs, &g_data_size, NULL); + gchar* base = g_path_get_dirname(prefs_loc); + gchar* true_loc = get_file_or_linked(prefs_loc, base); g_file_set_contents(true_loc, g_prefs_data, g_data_size, NULL); g_chmod(prefs_loc, S_IRUSR | S_IWUSR); @@ -1798,146 +1799,145 @@ _save_prefs(void) static const char* _get_group(preference_t pref) { - switch (pref) - { - case PREF_CLEAR_PERSIST_HISTORY: - case PREF_SPLASH: - case PREF_BEEP: - case PREF_THEME: - case PREF_VERCHECK: - case PREF_WINTITLE_SHOW: - case PREF_WINTITLE_GOODBYE: - case PREF_FLASH: - case PREF_INTYPE: - case PREF_HISTORY: - case PREF_OCCUPANTS: - case PREF_OCCUPANTS_JID: - case PREF_OCCUPANTS_WRAP: - case PREF_STATUSES: - case PREF_STATUSES_CONSOLE: - case PREF_STATUSES_CHAT: - case PREF_STATUSES_MUC: - case PREF_MUC_PRIVILEGES: - case PREF_PRESENCE: - case PREF_WRAP: - case PREF_TIME_CONSOLE: - case PREF_TIME_CHAT: - case PREF_TIME_MUC: - case PREF_TIME_CONFIG: - case PREF_TIME_PRIVATE: - case PREF_TIME_XMLCONSOLE: - case PREF_TIME_STATUSBAR: - case PREF_TIME_LASTACTIVITY: - case PREF_ROSTER: - case PREF_ROSTER_OFFLINE: - case PREF_ROSTER_RESOURCE: - case PREF_ROSTER_PRESENCE: - case PREF_ROSTER_STATUS: - case PREF_ROSTER_EMPTY: - case PREF_ROSTER_BY: - case PREF_ROSTER_ORDER: - case PREF_ROSTER_UNREAD: - case PREF_ROSTER_COUNT: - case PREF_ROSTER_COUNT_ZERO: - case PREF_ROSTER_PRIORITY: - case PREF_ROSTER_WRAP: - case PREF_ROSTER_RESOURCE_JOIN: - case PREF_ROSTER_CONTACTS: - case PREF_ROSTER_UNSUBSCRIBED: - case PREF_ROSTER_ROOMS: - case PREF_ROSTER_ROOMS_POS: - case PREF_ROSTER_ROOMS_BY: - case PREF_ROSTER_ROOMS_ORDER: - case PREF_ROSTER_ROOMS_UNREAD: - case PREF_ROSTER_ROOMS_SERVER: - case PREF_ROSTER_ROOMS_USE_AS_NAME: - case PREF_ROSTER_PRIVATE: - case PREF_RESOURCE_TITLE: - case PREF_RESOURCE_MESSAGE: - case PREF_ENC_WARN: - case PREF_INPBLOCK_DYNAMIC: - case PREF_TLS_SHOW: - case PREF_CONSOLE_MUC: - case PREF_CONSOLE_PRIVATE: - case PREF_CONSOLE_CHAT: - case PREF_COLOR_NICK: - case PREF_COLOR_NICK_OWN: - case PREF_ROSTER_COLOR_NICK: - case PREF_OCCUPANTS_COLOR_NICK: - case PREF_STATUSBAR_SHOW_NAME: - case PREF_STATUSBAR_SHOW_NUMBER: - case PREF_STATUSBAR_SHOW_READ: - case PREF_STATUSBAR_SELF: - case PREF_STATUSBAR_CHAT: - case PREF_STATUSBAR_ROOM: - case PREF_TITLEBAR_MUC_TITLE_JID: - case PREF_TITLEBAR_MUC_TITLE_NAME: - case PREF_SLASH_GUARD: - return PREF_GROUP_UI; - case PREF_STATES: - case PREF_OUTTYPE: - return PREF_GROUP_CHATSTATES; - case PREF_NOTIFY_TYPING: - case PREF_NOTIFY_TYPING_CURRENT: - case PREF_NOTIFY_CHAT: - case PREF_NOTIFY_CHAT_CURRENT: - case PREF_NOTIFY_CHAT_TEXT: - case PREF_NOTIFY_ROOM: - case PREF_NOTIFY_ROOM_MENTION: - case PREF_NOTIFY_ROOM_TRIGGER: - case PREF_NOTIFY_ROOM_CURRENT: - case PREF_NOTIFY_ROOM_TEXT: - case PREF_NOTIFY_INVITE: - case PREF_NOTIFY_SUB: - case PREF_NOTIFY_MENTION_CASE_SENSITIVE: - case PREF_NOTIFY_MENTION_WHOLE_WORD: - case PREF_TRAY: - case PREF_TRAY_READ: - case PREF_ADV_NOTIFY_DISCO_OR_VERSION: - return PREF_GROUP_NOTIFICATIONS; - case PREF_CHLOG: - case PREF_GRLOG: - case PREF_LOG_ROTATE: - case PREF_LOG_SHARED: - return PREF_GROUP_LOGGING; - case PREF_AVATAR_CMD: - case PREF_URL_OPEN_CMD: - case PREF_URL_SAVE_CMD: - return PREF_GROUP_EXECUTABLES; - case PREF_AUTOAWAY_CHECK: - case PREF_AUTOAWAY_MODE: - case PREF_AUTOAWAY_MESSAGE: - case PREF_AUTOXA_MESSAGE: - case PREF_LASTACTIVITY: - return PREF_GROUP_PRESENCE; - case PREF_CONNECT_ACCOUNT: - case PREF_DEFAULT_ACCOUNT: - case PREF_CARBONS: - case PREF_RECEIPTS_SEND: - case PREF_RECEIPTS_REQUEST: - case PREF_REVEAL_OS: - case PREF_TLS_CERTPATH: - case PREF_CORRECTION_ALLOW: - case PREF_MAM: - return PREF_GROUP_CONNECTION; - case PREF_OTR_LOG: - case PREF_OTR_POLICY: - case PREF_OTR_SENDFILE: - return PREF_GROUP_OTR; - case PREF_PGP_LOG: - case PREF_PGP_SENDFILE: - return PREF_GROUP_PGP; - case PREF_BOOKMARK_INVITE: - case PREF_ROOM_LIST_CACHE: - return PREF_GROUP_MUC; - case PREF_PLUGINS_SOURCEPATH: - return PREF_GROUP_PLUGINS; - case PREF_OMEMO_LOG: - case PREF_OMEMO_POLICY: - case PREF_OMEMO_SENDFILE: - return PREF_GROUP_OMEMO; - default: - return NULL; + switch (pref) { + case PREF_CLEAR_PERSIST_HISTORY: + case PREF_SPLASH: + case PREF_BEEP: + case PREF_THEME: + case PREF_VERCHECK: + case PREF_WINTITLE_SHOW: + case PREF_WINTITLE_GOODBYE: + case PREF_FLASH: + case PREF_INTYPE: + case PREF_HISTORY: + case PREF_OCCUPANTS: + case PREF_OCCUPANTS_JID: + case PREF_OCCUPANTS_WRAP: + case PREF_STATUSES: + case PREF_STATUSES_CONSOLE: + case PREF_STATUSES_CHAT: + case PREF_STATUSES_MUC: + case PREF_MUC_PRIVILEGES: + case PREF_PRESENCE: + case PREF_WRAP: + case PREF_TIME_CONSOLE: + case PREF_TIME_CHAT: + case PREF_TIME_MUC: + case PREF_TIME_CONFIG: + case PREF_TIME_PRIVATE: + case PREF_TIME_XMLCONSOLE: + case PREF_TIME_STATUSBAR: + case PREF_TIME_LASTACTIVITY: + case PREF_ROSTER: + case PREF_ROSTER_OFFLINE: + case PREF_ROSTER_RESOURCE: + case PREF_ROSTER_PRESENCE: + case PREF_ROSTER_STATUS: + case PREF_ROSTER_EMPTY: + case PREF_ROSTER_BY: + case PREF_ROSTER_ORDER: + case PREF_ROSTER_UNREAD: + case PREF_ROSTER_COUNT: + case PREF_ROSTER_COUNT_ZERO: + case PREF_ROSTER_PRIORITY: + case PREF_ROSTER_WRAP: + case PREF_ROSTER_RESOURCE_JOIN: + case PREF_ROSTER_CONTACTS: + case PREF_ROSTER_UNSUBSCRIBED: + case PREF_ROSTER_ROOMS: + case PREF_ROSTER_ROOMS_POS: + case PREF_ROSTER_ROOMS_BY: + case PREF_ROSTER_ROOMS_ORDER: + case PREF_ROSTER_ROOMS_UNREAD: + case PREF_ROSTER_ROOMS_SERVER: + case PREF_ROSTER_ROOMS_USE_AS_NAME: + case PREF_ROSTER_PRIVATE: + case PREF_RESOURCE_TITLE: + case PREF_RESOURCE_MESSAGE: + case PREF_ENC_WARN: + case PREF_INPBLOCK_DYNAMIC: + case PREF_TLS_SHOW: + case PREF_CONSOLE_MUC: + case PREF_CONSOLE_PRIVATE: + case PREF_CONSOLE_CHAT: + case PREF_COLOR_NICK: + case PREF_COLOR_NICK_OWN: + case PREF_ROSTER_COLOR_NICK: + case PREF_OCCUPANTS_COLOR_NICK: + case PREF_STATUSBAR_SHOW_NAME: + case PREF_STATUSBAR_SHOW_NUMBER: + case PREF_STATUSBAR_SHOW_READ: + case PREF_STATUSBAR_SELF: + case PREF_STATUSBAR_CHAT: + case PREF_STATUSBAR_ROOM: + case PREF_TITLEBAR_MUC_TITLE_JID: + case PREF_TITLEBAR_MUC_TITLE_NAME: + case PREF_SLASH_GUARD: + return PREF_GROUP_UI; + case PREF_STATES: + case PREF_OUTTYPE: + return PREF_GROUP_CHATSTATES; + case PREF_NOTIFY_TYPING: + case PREF_NOTIFY_TYPING_CURRENT: + case PREF_NOTIFY_CHAT: + case PREF_NOTIFY_CHAT_CURRENT: + case PREF_NOTIFY_CHAT_TEXT: + case PREF_NOTIFY_ROOM: + case PREF_NOTIFY_ROOM_MENTION: + case PREF_NOTIFY_ROOM_TRIGGER: + case PREF_NOTIFY_ROOM_CURRENT: + case PREF_NOTIFY_ROOM_TEXT: + case PREF_NOTIFY_INVITE: + case PREF_NOTIFY_SUB: + case PREF_NOTIFY_MENTION_CASE_SENSITIVE: + case PREF_NOTIFY_MENTION_WHOLE_WORD: + case PREF_TRAY: + case PREF_TRAY_READ: + case PREF_ADV_NOTIFY_DISCO_OR_VERSION: + return PREF_GROUP_NOTIFICATIONS; + case PREF_CHLOG: + case PREF_GRLOG: + case PREF_LOG_ROTATE: + case PREF_LOG_SHARED: + return PREF_GROUP_LOGGING; + case PREF_AVATAR_CMD: + case PREF_URL_OPEN_CMD: + case PREF_URL_SAVE_CMD: + return PREF_GROUP_EXECUTABLES; + case PREF_AUTOAWAY_CHECK: + case PREF_AUTOAWAY_MODE: + case PREF_AUTOAWAY_MESSAGE: + case PREF_AUTOXA_MESSAGE: + case PREF_LASTACTIVITY: + return PREF_GROUP_PRESENCE; + case PREF_CONNECT_ACCOUNT: + case PREF_DEFAULT_ACCOUNT: + case PREF_CARBONS: + case PREF_RECEIPTS_SEND: + case PREF_RECEIPTS_REQUEST: + case PREF_REVEAL_OS: + case PREF_TLS_CERTPATH: + case PREF_CORRECTION_ALLOW: + case PREF_MAM: + return PREF_GROUP_CONNECTION; + case PREF_OTR_LOG: + case PREF_OTR_POLICY: + case PREF_OTR_SENDFILE: + return PREF_GROUP_OTR; + case PREF_PGP_LOG: + case PREF_PGP_SENDFILE: + return PREF_GROUP_PGP; + case PREF_BOOKMARK_INVITE: + case PREF_ROOM_LIST_CACHE: + return PREF_GROUP_MUC; + case PREF_PLUGINS_SOURCEPATH: + return PREF_GROUP_PLUGINS; + case PREF_OMEMO_LOG: + case PREF_OMEMO_POLICY: + case PREF_OMEMO_SENDFILE: + return PREF_GROUP_OMEMO; + default: + return NULL; } } @@ -1946,258 +1946,257 @@ _get_group(preference_t pref) static const char* _get_key(preference_t pref) { - switch (pref) - { - case PREF_CLEAR_PERSIST_HISTORY: - return "clear.persist_history"; - case PREF_SPLASH: - return "splash"; - case PREF_BEEP: - return "beep"; - case PREF_THEME: - return "theme"; - case PREF_VERCHECK: - return "vercheck"; - case PREF_WINTITLE_SHOW: - return "wintitle.show"; - case PREF_WINTITLE_GOODBYE: - return "wintitle.goodbye"; - case PREF_FLASH: - return "flash"; - case PREF_TRAY: - return "tray"; - case PREF_TRAY_READ: - return "tray.read"; - case PREF_ADV_NOTIFY_DISCO_OR_VERSION: - return "adv.notify.discoversion"; - case PREF_INTYPE: - return "intype"; - case PREF_HISTORY: - return "history"; - case PREF_CARBONS: - return "carbons"; - case PREF_RECEIPTS_SEND: - return "receipts.send"; - case PREF_RECEIPTS_REQUEST: - return "receipts.request"; - case PREF_REVEAL_OS: - return "reveal.os"; - case PREF_OCCUPANTS: - return "occupants"; - case PREF_OCCUPANTS_JID: - return "occupants.jid"; - case PREF_OCCUPANTS_WRAP: - return "occupants.wrap"; - case PREF_MUC_PRIVILEGES: - return "privileges"; - case PREF_STATUSES: - return "statuses"; - case PREF_STATUSES_CONSOLE: - return "statuses.console"; - case PREF_STATUSES_CHAT: - return "statuses.chat"; - case PREF_STATUSES_MUC: - return "statuses.muc"; - case PREF_STATES: - return "enabled"; - case PREF_OUTTYPE: - return "outtype"; - case PREF_NOTIFY_TYPING: - return "typing"; - case PREF_NOTIFY_TYPING_CURRENT: - return "typing.current"; - case PREF_NOTIFY_CHAT: - return "message"; - case PREF_NOTIFY_CHAT_CURRENT: - return "message.current"; - case PREF_NOTIFY_CHAT_TEXT: - return "message.text"; - case PREF_NOTIFY_ROOM: - return "room"; - case PREF_NOTIFY_ROOM_TRIGGER: - return "room.trigger"; - case PREF_NOTIFY_ROOM_MENTION: - return "room.mention"; - case PREF_NOTIFY_ROOM_CURRENT: - return "room.current"; - case PREF_NOTIFY_ROOM_TEXT: - return "room.text"; - case PREF_NOTIFY_INVITE: - return "invite"; - case PREF_NOTIFY_SUB: - return "sub"; - case PREF_NOTIFY_MENTION_CASE_SENSITIVE: - return "room.mention.casesensitive"; - case PREF_NOTIFY_MENTION_WHOLE_WORD: - return "room.mention.wholeword"; - case PREF_CHLOG: - return "chlog"; - case PREF_GRLOG: - return "grlog"; - case PREF_AUTOAWAY_CHECK: - return "autoaway.check"; - case PREF_AUTOAWAY_MODE: - return "autoaway.mode"; - case PREF_AUTOAWAY_MESSAGE: - return "autoaway.awaymessage"; - case PREF_AUTOXA_MESSAGE: - return "autoaway.xamessage"; - case PREF_CONNECT_ACCOUNT: - return "account"; - case PREF_DEFAULT_ACCOUNT: - return "defaccount"; - case PREF_OTR_LOG: - return "log"; - case PREF_OTR_POLICY: - return "policy"; - case PREF_OTR_SENDFILE: - return "sendfile"; - case PREF_LOG_ROTATE: - return "rotate"; - case PREF_LOG_SHARED: - return "shared"; - case PREF_PRESENCE: - return "presence"; - case PREF_WRAP: - return "wrap"; - case PREF_TIME_CONSOLE: - return "time.console"; - case PREF_TIME_CHAT: - return "time.chat"; - case PREF_TIME_MUC: - return "time.muc"; - case PREF_TIME_CONFIG: - return "time.config"; - case PREF_TIME_PRIVATE: - return "time.private"; - case PREF_TIME_XMLCONSOLE: - return "time.xmlconsole"; - case PREF_TIME_STATUSBAR: - return "time.statusbar"; - case PREF_TIME_LASTACTIVITY: - return "time.lastactivity"; - case PREF_ROSTER: - return "roster"; - case PREF_ROSTER_OFFLINE: - return "roster.offline"; - case PREF_ROSTER_RESOURCE: - return "roster.resource"; - case PREF_ROSTER_PRESENCE: - return "roster.presence"; - case PREF_ROSTER_STATUS: - return "roster.status"; - case PREF_ROSTER_EMPTY: - return "roster.empty"; - case PREF_ROSTER_BY: - return "roster.by"; - case PREF_ROSTER_ORDER: - return "roster.order"; - case PREF_ROSTER_UNREAD: - return "roster.unread"; - case PREF_ROSTER_COUNT: - return "roster.count"; - case PREF_ROSTER_COUNT_ZERO: - return "roster.count.zero"; - case PREF_ROSTER_PRIORITY: - return "roster.priority"; - case PREF_ROSTER_WRAP: - return "roster.wrap"; - case PREF_ROSTER_RESOURCE_JOIN: - return "roster.resource.join"; - case PREF_ROSTER_CONTACTS: - return "roster.contacts"; - case PREF_ROSTER_UNSUBSCRIBED: - return "roster.unsubscribed"; - case PREF_ROSTER_ROOMS: - return "roster.rooms"; - case PREF_ROSTER_ROOMS_POS: - return "roster.rooms.pos"; - case PREF_ROSTER_ROOMS_BY: - return "roster.rooms.by"; - case PREF_ROSTER_ROOMS_ORDER: - return "roster.rooms.order"; - case PREF_ROSTER_ROOMS_UNREAD: - return "roster.rooms.unread"; - case PREF_ROSTER_ROOMS_SERVER: - return "roster.rooms.server"; - case PREF_ROSTER_ROOMS_USE_AS_NAME: - return "roster.rooms.use.name"; - case PREF_ROSTER_PRIVATE: - return "roster.private"; - case PREF_RESOURCE_TITLE: - return "resource.title"; - case PREF_RESOURCE_MESSAGE: - return "resource.message"; - case PREF_INPBLOCK_DYNAMIC: - return "inpblock.dynamic"; - case PREF_ENC_WARN: - return "enc.warn"; - case PREF_TITLEBAR_MUC_TITLE_JID: - return "titlebar.muc.title.jid"; - case PREF_TITLEBAR_MUC_TITLE_NAME: - return "titlebar.muc.title.name"; - case PREF_PGP_LOG: - return "log"; - case PREF_PGP_SENDFILE: - return "sendfile"; - case PREF_TLS_CERTPATH: - return "tls.certpath"; - case PREF_TLS_SHOW: - return "tls.show"; - case PREF_LASTACTIVITY: - return "lastactivity"; - case PREF_CONSOLE_MUC: - return "console.muc"; - case PREF_CONSOLE_PRIVATE: - return "console.private"; - case PREF_CONSOLE_CHAT: - return "console.chat"; - case PREF_COLOR_NICK: - return "color.nick"; - case PREF_COLOR_NICK_OWN: - return "color.nick.own"; - case PREF_ROSTER_COLOR_NICK: - return "color.roster.nick"; - case PREF_OCCUPANTS_COLOR_NICK: - return "color.occupants.nick"; - case PREF_BOOKMARK_INVITE: - return "bookmark.invite"; - case PREF_PLUGINS_SOURCEPATH: - return "sourcepath"; - case PREF_ROOM_LIST_CACHE: - return "rooms.cache"; - case PREF_STATUSBAR_SHOW_NAME: - return "statusbar.show.name"; - case PREF_STATUSBAR_SHOW_NUMBER: - return "statusbar.show.number"; - case PREF_STATUSBAR_SHOW_READ: - return "statusbar.show.read"; - case PREF_STATUSBAR_SELF: - return "statusbar.self"; - case PREF_STATUSBAR_CHAT: - return "statusbar.chat"; - case PREF_STATUSBAR_ROOM: - return "statusbar.room"; - case PREF_OMEMO_LOG: - return "log"; - case PREF_OMEMO_POLICY: - return "policy"; - case PREF_OMEMO_SENDFILE: - return "sendfile"; - case PREF_CORRECTION_ALLOW: - return "correction.allow"; - case PREF_AVATAR_CMD: - return "avatar.cmd"; - case PREF_SLASH_GUARD: - return "slashguard"; - case PREF_MAM: - return "mam"; - case PREF_URL_OPEN_CMD: - return "url.open.cmd"; - case PREF_URL_SAVE_CMD: - return "url.save.cmd"; - default: - return NULL; + switch (pref) { + case PREF_CLEAR_PERSIST_HISTORY: + return "clear.persist_history"; + case PREF_SPLASH: + return "splash"; + case PREF_BEEP: + return "beep"; + case PREF_THEME: + return "theme"; + case PREF_VERCHECK: + return "vercheck"; + case PREF_WINTITLE_SHOW: + return "wintitle.show"; + case PREF_WINTITLE_GOODBYE: + return "wintitle.goodbye"; + case PREF_FLASH: + return "flash"; + case PREF_TRAY: + return "tray"; + case PREF_TRAY_READ: + return "tray.read"; + case PREF_ADV_NOTIFY_DISCO_OR_VERSION: + return "adv.notify.discoversion"; + case PREF_INTYPE: + return "intype"; + case PREF_HISTORY: + return "history"; + case PREF_CARBONS: + return "carbons"; + case PREF_RECEIPTS_SEND: + return "receipts.send"; + case PREF_RECEIPTS_REQUEST: + return "receipts.request"; + case PREF_REVEAL_OS: + return "reveal.os"; + case PREF_OCCUPANTS: + return "occupants"; + case PREF_OCCUPANTS_JID: + return "occupants.jid"; + case PREF_OCCUPANTS_WRAP: + return "occupants.wrap"; + case PREF_MUC_PRIVILEGES: + return "privileges"; + case PREF_STATUSES: + return "statuses"; + case PREF_STATUSES_CONSOLE: + return "statuses.console"; + case PREF_STATUSES_CHAT: + return "statuses.chat"; + case PREF_STATUSES_MUC: + return "statuses.muc"; + case PREF_STATES: + return "enabled"; + case PREF_OUTTYPE: + return "outtype"; + case PREF_NOTIFY_TYPING: + return "typing"; + case PREF_NOTIFY_TYPING_CURRENT: + return "typing.current"; + case PREF_NOTIFY_CHAT: + return "message"; + case PREF_NOTIFY_CHAT_CURRENT: + return "message.current"; + case PREF_NOTIFY_CHAT_TEXT: + return "message.text"; + case PREF_NOTIFY_ROOM: + return "room"; + case PREF_NOTIFY_ROOM_TRIGGER: + return "room.trigger"; + case PREF_NOTIFY_ROOM_MENTION: + return "room.mention"; + case PREF_NOTIFY_ROOM_CURRENT: + return "room.current"; + case PREF_NOTIFY_ROOM_TEXT: + return "room.text"; + case PREF_NOTIFY_INVITE: + return "invite"; + case PREF_NOTIFY_SUB: + return "sub"; + case PREF_NOTIFY_MENTION_CASE_SENSITIVE: + return "room.mention.casesensitive"; + case PREF_NOTIFY_MENTION_WHOLE_WORD: + return "room.mention.wholeword"; + case PREF_CHLOG: + return "chlog"; + case PREF_GRLOG: + return "grlog"; + case PREF_AUTOAWAY_CHECK: + return "autoaway.check"; + case PREF_AUTOAWAY_MODE: + return "autoaway.mode"; + case PREF_AUTOAWAY_MESSAGE: + return "autoaway.awaymessage"; + case PREF_AUTOXA_MESSAGE: + return "autoaway.xamessage"; + case PREF_CONNECT_ACCOUNT: + return "account"; + case PREF_DEFAULT_ACCOUNT: + return "defaccount"; + case PREF_OTR_LOG: + return "log"; + case PREF_OTR_POLICY: + return "policy"; + case PREF_OTR_SENDFILE: + return "sendfile"; + case PREF_LOG_ROTATE: + return "rotate"; + case PREF_LOG_SHARED: + return "shared"; + case PREF_PRESENCE: + return "presence"; + case PREF_WRAP: + return "wrap"; + case PREF_TIME_CONSOLE: + return "time.console"; + case PREF_TIME_CHAT: + return "time.chat"; + case PREF_TIME_MUC: + return "time.muc"; + case PREF_TIME_CONFIG: + return "time.config"; + case PREF_TIME_PRIVATE: + return "time.private"; + case PREF_TIME_XMLCONSOLE: + return "time.xmlconsole"; + case PREF_TIME_STATUSBAR: + return "time.statusbar"; + case PREF_TIME_LASTACTIVITY: + return "time.lastactivity"; + case PREF_ROSTER: + return "roster"; + case PREF_ROSTER_OFFLINE: + return "roster.offline"; + case PREF_ROSTER_RESOURCE: + return "roster.resource"; + case PREF_ROSTER_PRESENCE: + return "roster.presence"; + case PREF_ROSTER_STATUS: + return "roster.status"; + case PREF_ROSTER_EMPTY: + return "roster.empty"; + case PREF_ROSTER_BY: + return "roster.by"; + case PREF_ROSTER_ORDER: + return "roster.order"; + case PREF_ROSTER_UNREAD: + return "roster.unread"; + case PREF_ROSTER_COUNT: + return "roster.count"; + case PREF_ROSTER_COUNT_ZERO: + return "roster.count.zero"; + case PREF_ROSTER_PRIORITY: + return "roster.priority"; + case PREF_ROSTER_WRAP: + return "roster.wrap"; + case PREF_ROSTER_RESOURCE_JOIN: + return "roster.resource.join"; + case PREF_ROSTER_CONTACTS: + return "roster.contacts"; + case PREF_ROSTER_UNSUBSCRIBED: + return "roster.unsubscribed"; + case PREF_ROSTER_ROOMS: + return "roster.rooms"; + case PREF_ROSTER_ROOMS_POS: + return "roster.rooms.pos"; + case PREF_ROSTER_ROOMS_BY: + return "roster.rooms.by"; + case PREF_ROSTER_ROOMS_ORDER: + return "roster.rooms.order"; + case PREF_ROSTER_ROOMS_UNREAD: + return "roster.rooms.unread"; + case PREF_ROSTER_ROOMS_SERVER: + return "roster.rooms.server"; + case PREF_ROSTER_ROOMS_USE_AS_NAME: + return "roster.rooms.use.name"; + case PREF_ROSTER_PRIVATE: + return "roster.private"; + case PREF_RESOURCE_TITLE: + return "resource.title"; + case PREF_RESOURCE_MESSAGE: + return "resource.message"; + case PREF_INPBLOCK_DYNAMIC: + return "inpblock.dynamic"; + case PREF_ENC_WARN: + return "enc.warn"; + case PREF_TITLEBAR_MUC_TITLE_JID: + return "titlebar.muc.title.jid"; + case PREF_TITLEBAR_MUC_TITLE_NAME: + return "titlebar.muc.title.name"; + case PREF_PGP_LOG: + return "log"; + case PREF_PGP_SENDFILE: + return "sendfile"; + case PREF_TLS_CERTPATH: + return "tls.certpath"; + case PREF_TLS_SHOW: + return "tls.show"; + case PREF_LASTACTIVITY: + return "lastactivity"; + case PREF_CONSOLE_MUC: + return "console.muc"; + case PREF_CONSOLE_PRIVATE: + return "console.private"; + case PREF_CONSOLE_CHAT: + return "console.chat"; + case PREF_COLOR_NICK: + return "color.nick"; + case PREF_COLOR_NICK_OWN: + return "color.nick.own"; + case PREF_ROSTER_COLOR_NICK: + return "color.roster.nick"; + case PREF_OCCUPANTS_COLOR_NICK: + return "color.occupants.nick"; + case PREF_BOOKMARK_INVITE: + return "bookmark.invite"; + case PREF_PLUGINS_SOURCEPATH: + return "sourcepath"; + case PREF_ROOM_LIST_CACHE: + return "rooms.cache"; + case PREF_STATUSBAR_SHOW_NAME: + return "statusbar.show.name"; + case PREF_STATUSBAR_SHOW_NUMBER: + return "statusbar.show.number"; + case PREF_STATUSBAR_SHOW_READ: + return "statusbar.show.read"; + case PREF_STATUSBAR_SELF: + return "statusbar.self"; + case PREF_STATUSBAR_CHAT: + return "statusbar.chat"; + case PREF_STATUSBAR_ROOM: + return "statusbar.room"; + case PREF_OMEMO_LOG: + return "log"; + case PREF_OMEMO_POLICY: + return "policy"; + case PREF_OMEMO_SENDFILE: + return "sendfile"; + case PREF_CORRECTION_ALLOW: + return "correction.allow"; + case PREF_AVATAR_CMD: + return "avatar.cmd"; + case PREF_SLASH_GUARD: + return "slashguard"; + case PREF_MAM: + return "mam"; + case PREF_URL_OPEN_CMD: + return "url.open.cmd"; + case PREF_URL_SAVE_CMD: + return "url.save.cmd"; + default: + return NULL; } } @@ -2206,57 +2205,56 @@ _get_key(preference_t pref) static gboolean _get_default_boolean(preference_t pref) { - switch (pref) - { - case PREF_ENC_WARN: - case PREF_AUTOAWAY_CHECK: - case PREF_LOG_ROTATE: - case PREF_LOG_SHARED: - case PREF_NOTIFY_CHAT: - case PREF_NOTIFY_CHAT_CURRENT: - case PREF_NOTIFY_ROOM: - case PREF_NOTIFY_ROOM_CURRENT: - case PREF_NOTIFY_TYPING: - case PREF_NOTIFY_TYPING_CURRENT: - case PREF_NOTIFY_SUB: - case PREF_NOTIFY_INVITE: - case PREF_SPLASH: - case PREF_OCCUPANTS: - case PREF_MUC_PRIVILEGES: - case PREF_PRESENCE: - case PREF_WRAP: - case PREF_INPBLOCK_DYNAMIC: - case PREF_RESOURCE_TITLE: - case PREF_RESOURCE_MESSAGE: - case PREF_ROSTER: - case PREF_ROSTER_OFFLINE: - case PREF_ROSTER_EMPTY: - case PREF_ROSTER_COUNT_ZERO: - case PREF_ROSTER_PRIORITY: - case PREF_ROSTER_RESOURCE_JOIN: - case PREF_ROSTER_CONTACTS: - case PREF_ROSTER_UNSUBSCRIBED: - case PREF_ROSTER_ROOMS: - case PREF_ROSTER_ROOMS_SERVER: - case PREF_TLS_SHOW: - case PREF_LASTACTIVITY: - case PREF_NOTIFY_MENTION_WHOLE_WORD: - case PREF_TRAY_READ: - case PREF_BOOKMARK_INVITE: - case PREF_ROOM_LIST_CACHE: - case PREF_STATUSBAR_SHOW_NUMBER: - case PREF_STATUSBAR_SHOW_READ: - case PREF_REVEAL_OS: - case PREF_CORRECTION_ALLOW: - case PREF_RECEIPTS_SEND: - case PREF_CARBONS: - case PREF_STATES: - case PREF_OUTTYPE: - case PREF_TITLEBAR_MUC_TITLE_NAME: - case PREF_COLOR_NICK_OWN: - return TRUE; - default: - return FALSE; + switch (pref) { + case PREF_ENC_WARN: + case PREF_AUTOAWAY_CHECK: + case PREF_LOG_ROTATE: + case PREF_LOG_SHARED: + case PREF_NOTIFY_CHAT: + case PREF_NOTIFY_CHAT_CURRENT: + case PREF_NOTIFY_ROOM: + case PREF_NOTIFY_ROOM_CURRENT: + case PREF_NOTIFY_TYPING: + case PREF_NOTIFY_TYPING_CURRENT: + case PREF_NOTIFY_SUB: + case PREF_NOTIFY_INVITE: + case PREF_SPLASH: + case PREF_OCCUPANTS: + case PREF_MUC_PRIVILEGES: + case PREF_PRESENCE: + case PREF_WRAP: + case PREF_INPBLOCK_DYNAMIC: + case PREF_RESOURCE_TITLE: + case PREF_RESOURCE_MESSAGE: + case PREF_ROSTER: + case PREF_ROSTER_OFFLINE: + case PREF_ROSTER_EMPTY: + case PREF_ROSTER_COUNT_ZERO: + case PREF_ROSTER_PRIORITY: + case PREF_ROSTER_RESOURCE_JOIN: + case PREF_ROSTER_CONTACTS: + case PREF_ROSTER_UNSUBSCRIBED: + case PREF_ROSTER_ROOMS: + case PREF_ROSTER_ROOMS_SERVER: + case PREF_TLS_SHOW: + case PREF_LASTACTIVITY: + case PREF_NOTIFY_MENTION_WHOLE_WORD: + case PREF_TRAY_READ: + case PREF_BOOKMARK_INVITE: + case PREF_ROOM_LIST_CACHE: + case PREF_STATUSBAR_SHOW_NUMBER: + case PREF_STATUSBAR_SHOW_READ: + case PREF_REVEAL_OS: + case PREF_CORRECTION_ALLOW: + case PREF_RECEIPTS_SEND: + case PREF_CARBONS: + case PREF_STATES: + case PREF_OUTTYPE: + case PREF_TITLEBAR_MUC_TITLE_NAME: + case PREF_COLOR_NICK_OWN: + return TRUE; + default: + return FALSE; } } @@ -2265,78 +2263,77 @@ _get_default_boolean(preference_t pref) static char* _get_default_string(preference_t pref) { - switch (pref) - { - case PREF_AUTOAWAY_MODE: - return "off"; - case PREF_OTR_LOG: - return "redact"; - case PREF_OTR_POLICY: - return "manual"; - case PREF_STATUSES_CONSOLE: - case PREF_STATUSES_CHAT: - case PREF_STATUSES_MUC: - return "all"; - case PREF_ROSTER_BY: - return "presence"; - case PREF_ROSTER_COUNT: - return "unread"; - case PREF_ROSTER_ORDER: - return "presence"; - case PREF_ROSTER_UNREAD: - return "after"; - case PREF_ROSTER_ROOMS_POS: - return "last"; - case PREF_ROSTER_ROOMS_BY: - return "none"; - case PREF_ROSTER_ROOMS_USE_AS_NAME: - return "name"; - case PREF_ROSTER_ROOMS_ORDER: - return "name"; - case PREF_ROSTER_ROOMS_UNREAD: - return "after"; - case PREF_ROSTER_PRIVATE: - return "room"; - case PREF_TIME_CONSOLE: - return "%H:%M:%S"; - case PREF_TIME_CHAT: - return "%H:%M:%S"; - case PREF_TIME_MUC: - return "%H:%M:%S"; - case PREF_TIME_CONFIG: - return "%H:%M:%S"; - case PREF_TIME_PRIVATE: - return "%H:%M:%S"; - case PREF_TIME_XMLCONSOLE: - return "%H:%M:%S"; - case PREF_TIME_STATUSBAR: - return "%H:%M"; - case PREF_TIME_LASTACTIVITY: - return "%d/%m/%y %H:%M:%S"; - case PREF_PGP_LOG: - return "redact"; - case PREF_CONSOLE_MUC: - case PREF_CONSOLE_PRIVATE: - case PREF_CONSOLE_CHAT: - return "all"; - case PREF_STATUSBAR_SELF: - return "fulljid"; - case PREF_STATUSBAR_CHAT: - return "user"; - case PREF_STATUSBAR_ROOM: - return "room"; - case PREF_OMEMO_LOG: - return "redact"; - case PREF_OMEMO_POLICY: - return "automatic"; - case PREF_COLOR_NICK: - return "false"; - case PREF_AVATAR_CMD: - return "xdg-open"; - case PREF_URL_SAVE_CMD: - return "curl -o %p %u"; - default: - return NULL; + switch (pref) { + case PREF_AUTOAWAY_MODE: + return "off"; + case PREF_OTR_LOG: + return "redact"; + case PREF_OTR_POLICY: + return "manual"; + case PREF_STATUSES_CONSOLE: + case PREF_STATUSES_CHAT: + case PREF_STATUSES_MUC: + return "all"; + case PREF_ROSTER_BY: + return "presence"; + case PREF_ROSTER_COUNT: + return "unread"; + case PREF_ROSTER_ORDER: + return "presence"; + case PREF_ROSTER_UNREAD: + return "after"; + case PREF_ROSTER_ROOMS_POS: + return "last"; + case PREF_ROSTER_ROOMS_BY: + return "none"; + case PREF_ROSTER_ROOMS_USE_AS_NAME: + return "name"; + case PREF_ROSTER_ROOMS_ORDER: + return "name"; + case PREF_ROSTER_ROOMS_UNREAD: + return "after"; + case PREF_ROSTER_PRIVATE: + return "room"; + case PREF_TIME_CONSOLE: + return "%H:%M:%S"; + case PREF_TIME_CHAT: + return "%H:%M:%S"; + case PREF_TIME_MUC: + return "%H:%M:%S"; + case PREF_TIME_CONFIG: + return "%H:%M:%S"; + case PREF_TIME_PRIVATE: + return "%H:%M:%S"; + case PREF_TIME_XMLCONSOLE: + return "%H:%M:%S"; + case PREF_TIME_STATUSBAR: + return "%H:%M"; + case PREF_TIME_LASTACTIVITY: + return "%d/%m/%y %H:%M:%S"; + case PREF_PGP_LOG: + return "redact"; + case PREF_CONSOLE_MUC: + case PREF_CONSOLE_PRIVATE: + case PREF_CONSOLE_CHAT: + return "all"; + case PREF_STATUSBAR_SELF: + return "fulljid"; + case PREF_STATUSBAR_CHAT: + return "user"; + case PREF_STATUSBAR_ROOM: + return "room"; + case PREF_OMEMO_LOG: + return "redact"; + case PREF_OMEMO_POLICY: + return "automatic"; + case PREF_COLOR_NICK: + return "false"; + case PREF_AVATAR_CMD: + return "xdg-open"; + case PREF_URL_SAVE_CMD: + return "curl -o %p %u"; + default: + return NULL; } } @@ -2345,16 +2342,15 @@ _get_default_string(preference_t pref) static char** _get_default_string_list(preference_t pref) { - char **str_array = NULL; + char** str_array = NULL; - switch (pref) - { - case PREF_URL_OPEN_CMD: - str_array = g_malloc0(3); - str_array[0] = g_strdup("false"); - str_array[1] = g_strdup("xdg-open %u"); - return str_array; - default: - return NULL; + switch (pref) { + case PREF_URL_OPEN_CMD: + str_array = g_malloc0(3); + str_array[0] = g_strdup("false"); + str_array[1] = g_strdup("xdg-open %u"); + return str_array; + default: + return NULL; } } diff --git a/src/config/preferences.h b/src/config/preferences.h index 686b9380..a9261853 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -175,30 +175,32 @@ typedef enum { PREF_URL_SAVE_CMD, } preference_t; -typedef struct prof_alias_t { - gchar *name; - gchar *value; +typedef struct prof_alias_t +{ + gchar* name; + gchar* value; } ProfAlias; -typedef struct prof_winplacement_t { +typedef struct prof_winplacement_t +{ int titlebar_pos; int mainwin_pos; int statusbar_pos; int inputwin_pos; } ProfWinPlacement; -void prefs_load(char *config_file); +void prefs_load(char* config_file); void prefs_save(void); void prefs_close(void); void prefs_reload(void); -char* prefs_find_login(char *prefix); +char* prefs_find_login(char* prefix); void prefs_reset_login_search(void); -char* prefs_autocomplete_boolean_choice(const char *const prefix, gboolean previous, void *context); +char* prefs_autocomplete_boolean_choice(const char* const prefix, gboolean previous, void* context); void prefs_reset_boolean_choice(void); -char* prefs_autocomplete_room_trigger(const char *const prefix, gboolean previous, void *context); +char* prefs_autocomplete_room_trigger(const char* const prefix, gboolean previous, void* context); void prefs_reset_room_trigger_ac(void); gint prefs_get_gone(void); @@ -235,19 +237,19 @@ gint prefs_get_autoxa_time(void); void prefs_set_autoxa_time(gint value); gchar** prefs_get_plugins(void); -void prefs_free_plugins(gchar **plugins); -void prefs_add_plugin(const char *const name); -void prefs_remove_plugin(const char *const name); +void prefs_free_plugins(gchar** plugins); +void prefs_add_plugin(const char* const name); +void prefs_remove_plugin(const char* const name); char* prefs_get_otr_char(void); -gboolean prefs_set_otr_char(char *ch); +gboolean prefs_set_otr_char(char* ch); char* prefs_get_pgp_char(void); -gboolean prefs_set_pgp_char(char *ch); +gboolean prefs_set_pgp_char(char* ch); char* prefs_get_omemo_char(void); -gboolean prefs_set_omemo_char(char *ch); +gboolean prefs_set_omemo_char(char* ch); // XEP-0373: OpenPGP for XMPP char* prefs_get_ox_char(void); -gboolean prefs_set_ox_char(char *ch); +gboolean prefs_set_ox_char(char* ch); char prefs_get_roster_header_char(void); void prefs_set_roster_header_char(char ch); @@ -286,23 +288,23 @@ void prefs_set_occupants_indent(gint value); char* prefs_get_correction_char(void); void prefs_set_correction_char(char ch); -void prefs_add_login(const char *jid); +void prefs_add_login(const char* jid); void prefs_set_tray_timer(gint value); gint prefs_get_tray_timer(void); -gboolean prefs_add_alias(const char *const name, const char *const value); -gboolean prefs_remove_alias(const char *const name); -char* prefs_get_alias(const char *const name); +gboolean prefs_add_alias(const char* const name, const char* const value); +gboolean prefs_remove_alias(const char* const name); +char* prefs_get_alias(const char* const name); GList* prefs_get_aliases(void); -void prefs_free_aliases(GList *aliases); +void prefs_free_aliases(GList* aliases); -gboolean prefs_add_room_notify_trigger(const char * const text); -gboolean prefs_remove_room_notify_trigger(const char * const text); +gboolean prefs_add_room_notify_trigger(const char* const text); +gboolean prefs_remove_room_notify_trigger(const char* const text); GList* prefs_get_room_notify_triggers(void); ProfWinPlacement* prefs_get_win_placement(void); -void prefs_free_win_placement(ProfWinPlacement *placement); +void prefs_free_win_placement(ProfWinPlacement* placement); gboolean prefs_titlebar_pos_up(void); gboolean prefs_titlebar_pos_down(void); @@ -313,35 +315,35 @@ gboolean prefs_statusbar_pos_down(void); gboolean prefs_inputwin_pos_up(void); gboolean prefs_inputwin_pos_down(void); ProfWinPlacement* prefs_create_profwin_placement(int titlebar, int mainwin, int statusbar, int inputwin); -void prefs_save_win_placement(ProfWinPlacement *placement); +void prefs_save_win_placement(ProfWinPlacement* placement); gboolean prefs_get_boolean(preference_t pref); void prefs_set_boolean(preference_t pref, gboolean value); char* prefs_get_string(preference_t pref); -char* prefs_get_string_with_option(preference_t pref, gchar *option); -gchar **prefs_get_string_list_with_option(preference_t pref, gchar *option); -void prefs_set_string(preference_t pref, char *value); -void prefs_set_string_with_option(preference_t pref, char *option, char *value); -void prefs_set_string_list_with_option(preference_t pref, char *option, const gchar* const *values); +char* prefs_get_string_with_option(preference_t pref, gchar* option); +gchar** prefs_get_string_list_with_option(preference_t pref, gchar* option); +void prefs_set_string(preference_t pref, char* value); +void prefs_set_string_with_option(preference_t pref, char* option, char* value); +void prefs_set_string_list_with_option(preference_t pref, char* option, const gchar* const* values); char* prefs_get_tls_certpath(void); gboolean prefs_do_chat_notify(gboolean current_win); -gboolean prefs_do_room_notify(gboolean current_win, const char *const roomjid, const char *const mynick, - const char *const theirnick, const char *const message, gboolean mention, gboolean trigger_found); -gboolean prefs_do_room_notify_mention(const char *const roomjid, int unread, gboolean mention, gboolean trigger); -GList* prefs_message_get_triggers(const char *const message); - -void prefs_set_room_notify(const char *const roomjid, gboolean value); -void prefs_set_room_notify_mention(const char *const roomjid, gboolean value); -void prefs_set_room_notify_trigger(const char *const roomjid, gboolean value); -gboolean prefs_reset_room_notify(const char *const roomjid); -gboolean prefs_has_room_notify(const char *const roomjid); -gboolean prefs_has_room_notify_mention(const char *const roomjid); -gboolean prefs_has_room_notify_trigger(const char *const roomjid); -gboolean prefs_get_room_notify(const char *const roomjid); -gboolean prefs_get_room_notify_mention(const char *const roomjid); -gboolean prefs_get_room_notify_trigger(const char *const roomjid); +gboolean prefs_do_room_notify(gboolean current_win, const char* const roomjid, const char* const mynick, + const char* const theirnick, const char* const message, gboolean mention, gboolean trigger_found); +gboolean prefs_do_room_notify_mention(const char* const roomjid, int unread, gboolean mention, gboolean trigger); +GList* prefs_message_get_triggers(const char* const message); + +void prefs_set_room_notify(const char* const roomjid, gboolean value); +void prefs_set_room_notify_mention(const char* const roomjid, gboolean value); +void prefs_set_room_notify_trigger(const char* const roomjid, gboolean value); +gboolean prefs_reset_room_notify(const char* const roomjid); +gboolean prefs_has_room_notify(const char* const roomjid); +gboolean prefs_has_room_notify_mention(const char* const roomjid); +gboolean prefs_has_room_notify_trigger(const char* const roomjid); +gboolean prefs_get_room_notify(const char* const roomjid); +gboolean prefs_get_room_notify_mention(const char* const roomjid); +gboolean prefs_get_room_notify_trigger(const char* const roomjid); gchar* prefs_get_inputrc(void); diff --git a/src/config/scripts.c b/src/config/scripts.c index 81115aec..ec34fdaf 100644 --- a/src/config/scripts.c +++ b/src/config/scripts.c @@ -52,13 +52,13 @@ void scripts_init(void) { - char *scriptsdir = files_get_data_path(DIR_SCRIPTS); + char* scriptsdir = files_get_data_path(DIR_SCRIPTS); // mkdir if doesn't exist errno = 0; int res = g_mkdir_with_parents(scriptsdir, S_IRWXU); if (res == -1) { - char *errmsg = strerror(errno); + char* errmsg = strerror(errno); if (errmsg) { log_error("Error creating directory: %s, %s", scriptsdir, errmsg); } else { @@ -72,14 +72,14 @@ scripts_init(void) GSList* scripts_list(void) { - char *scriptsdir = files_get_data_path(DIR_SCRIPTS); + char* scriptsdir = files_get_data_path(DIR_SCRIPTS); - GSList *result = NULL; - GDir *scripts = g_dir_open(scriptsdir, 0, NULL); + GSList* result = NULL; + GDir* scripts = g_dir_open(scriptsdir, 0, NULL); free(scriptsdir); if (scripts) { - const gchar *script = g_dir_read_name(scripts); + const gchar* script = g_dir_read_name(scripts); while (script) { result = g_slist_append(result, strdup(script)); script = g_dir_read_name(scripts); @@ -91,15 +91,15 @@ scripts_list(void) } GSList* -scripts_read(const char *const script) +scripts_read(const char* const script) { - char *scriptsdir = files_get_data_path(DIR_SCRIPTS); - GString *scriptpath = g_string_new(scriptsdir); + char* scriptsdir = files_get_data_path(DIR_SCRIPTS); + GString* scriptpath = g_string_new(scriptsdir); free(scriptsdir); g_string_append(scriptpath, "/"); g_string_append(scriptpath, script); - FILE *scriptfile = g_fopen(scriptpath->str, "r"); + FILE* scriptfile = g_fopen(scriptpath->str, "r"); if (!scriptfile) { log_info("Script not found: %s", scriptpath->str); g_string_free(scriptpath, TRUE); @@ -108,35 +108,36 @@ scripts_read(const char *const script) g_string_free(scriptpath, TRUE); - char *line = NULL; + char* line = NULL; size_t len = 0; ssize_t read; - GSList *result = NULL; + GSList* result = NULL; while ((read = getline(&line, &len, scriptfile)) != -1) { if (g_str_has_suffix(line, "\n")) { - result = g_slist_append(result, g_strndup(line, strlen(line) -1)); + result = g_slist_append(result, g_strndup(line, strlen(line) - 1)); } else { result = g_slist_append(result, strdup(line)); } } fclose(scriptfile); - if (line) free(line); + if (line) + free(line); return result; } gboolean -scripts_exec(const char *const script) +scripts_exec(const char* const script) { - char *scriptsdir = files_get_data_path(DIR_SCRIPTS); - GString *scriptpath = g_string_new(scriptsdir); + char* scriptsdir = files_get_data_path(DIR_SCRIPTS); + GString* scriptpath = g_string_new(scriptsdir); free(scriptsdir); g_string_append(scriptpath, "/"); g_string_append(scriptpath, script); - FILE *scriptfile = g_fopen(scriptpath->str, "r"); + FILE* scriptfile = g_fopen(scriptpath->str, "r"); if (!scriptfile) { log_info("Script not found: %s", scriptpath->str); g_string_free(scriptpath, TRUE); @@ -145,20 +146,20 @@ scripts_exec(const char *const script) g_string_free(scriptpath, TRUE); - char *line = NULL; + char* line = NULL; size_t len = 0; ssize_t read; while ((read = getline(&line, &len, scriptfile)) != -1) { - ProfWin *win = wins_get_current(); + ProfWin* win = wins_get_current(); cmd_process_input(win, line); session_process_events(); ui_update(); } fclose(scriptfile); - if (line) free(line); + if (line) + free(line); return TRUE; } - diff --git a/src/config/scripts.h b/src/config/scripts.h index 887dc897..5d99e275 100644 --- a/src/config/scripts.h +++ b/src/config/scripts.h @@ -40,7 +40,7 @@ void scripts_init(void); GSList* scripts_list(void); -GSList* scripts_read(const char *const script); -gboolean scripts_exec(const char *const script); +GSList* scripts_read(const char* const script); +gboolean scripts_exec(const char* const script); #endif diff --git a/src/config/theme.c b/src/config/theme.c index 6432e386..147b31c2 100644 --- a/src/config/theme.c +++ b/src/config/theme.c @@ -54,18 +54,18 @@ #include "config/preferences.h" #include "config/color.h" -static GString *theme_loc; -static GKeyFile *theme; -static GHashTable *bold_items; -static GHashTable *defaults; +static GString* theme_loc; +static GKeyFile* theme; +static GHashTable* bold_items; +static GHashTable* defaults; static void _load_preferences(void); -static void _theme_list_dir(const gchar *const dir, GSList **result); -static GString* _theme_find(const char *const theme_name); -static gboolean _theme_load_file(const char *const theme_name); +static void _theme_list_dir(const gchar* const dir, GSList** result); +static GString* _theme_find(const char* const theme_name); +static gboolean _theme_load_file(const char* const theme_name); void -theme_init(const char *const theme_name) +theme_init(const char* const theme_name) { if (!_theme_load_file(theme_name)) { log_error("Loading theme %s failed.", theme_name); @@ -78,98 +78,98 @@ theme_init(const char *const theme_name) defaults = g_hash_table_new_full(g_str_hash, g_str_equal, free, free); // Set default colors - g_hash_table_insert(defaults, strdup("main.text"), strdup("default")); - g_hash_table_insert(defaults, strdup("main.text.history"), strdup("default")); - g_hash_table_insert(defaults, strdup("main.text.me"), strdup("default")); - g_hash_table_insert(defaults, strdup("main.text.them"), strdup("default")); - g_hash_table_insert(defaults, strdup("main.splash"), strdup("cyan")); - g_hash_table_insert(defaults, strdup("main.help.header"), strdup("default")); - g_hash_table_insert(defaults, strdup("error"), strdup("red")); - g_hash_table_insert(defaults, strdup("incoming"), strdup("yellow")); - g_hash_table_insert(defaults, strdup("mention"), strdup("yellow")); - g_hash_table_insert(defaults, strdup("trigger"), strdup("yellow")); - g_hash_table_insert(defaults, strdup("input.text"), strdup("default")); - g_hash_table_insert(defaults, strdup("main.time"), strdup("default")); - g_hash_table_insert(defaults, strdup("titlebar.text"), strdup("white")); - g_hash_table_insert(defaults, strdup("titlebar.brackets"), strdup("cyan")); - g_hash_table_insert(defaults, strdup("titlebar.unencrypted"), strdup("red")); - g_hash_table_insert(defaults, strdup("titlebar.encrypted"), strdup("white")); - g_hash_table_insert(defaults, strdup("titlebar.untrusted"), strdup("yellow")); - g_hash_table_insert(defaults, strdup("titlebar.trusted"), strdup("white")); - g_hash_table_insert(defaults, strdup("titlebar.online"), strdup("white")); - g_hash_table_insert(defaults, strdup("titlebar.offline"), strdup("white")); - g_hash_table_insert(defaults, strdup("titlebar.away"), strdup("white")); - g_hash_table_insert(defaults, strdup("titlebar.chat"), strdup("white")); - g_hash_table_insert(defaults, strdup("titlebar.dnd"), strdup("white")); - g_hash_table_insert(defaults, strdup("titlebar.xa"), strdup("white")); - g_hash_table_insert(defaults, strdup("titlebar.scrolled"), strdup("default")); - g_hash_table_insert(defaults, strdup("statusbar.text"), strdup("white")); - g_hash_table_insert(defaults, strdup("statusbar.brackets"), strdup("cyan")); - g_hash_table_insert(defaults, strdup("statusbar.active"), strdup("cyan")); - g_hash_table_insert(defaults, strdup("statusbar.current"), strdup("cyan")); - g_hash_table_insert(defaults, strdup("statusbar.new"), strdup("white")); - g_hash_table_insert(defaults, strdup("statusbar.time"), strdup("white")); - g_hash_table_insert(defaults, strdup("me"), strdup("yellow")); - g_hash_table_insert(defaults, strdup("them"), strdup("green")); - g_hash_table_insert(defaults, strdup("receipt.sent"), strdup("red")); - g_hash_table_insert(defaults, strdup("roominfo"), strdup("yellow")); - g_hash_table_insert(defaults, strdup("roommention"), strdup("yellow")); - g_hash_table_insert(defaults, strdup("roommention.term"), strdup("yellow")); - g_hash_table_insert(defaults, strdup("roomtrigger"), strdup("yellow")); - g_hash_table_insert(defaults, strdup("roomtrigger.term"), strdup("yellow")); - g_hash_table_insert(defaults, strdup("online"), strdup("green")); - g_hash_table_insert(defaults, strdup("offline"), strdup("red")); - g_hash_table_insert(defaults, strdup("away"), strdup("cyan")); - g_hash_table_insert(defaults, strdup("chat"), strdup("green")); - g_hash_table_insert(defaults, strdup("dnd"), strdup("red")); - g_hash_table_insert(defaults, strdup("xa"), strdup("cyan")); - g_hash_table_insert(defaults, strdup("typing"), strdup("yellow")); - g_hash_table_insert(defaults, strdup("gone"), strdup("red")); - g_hash_table_insert(defaults, strdup("subscribed"), strdup("green")); - g_hash_table_insert(defaults, strdup("unsubscribed"), strdup("red")); - g_hash_table_insert(defaults, strdup("otr.started.trusted"), strdup("green")); - g_hash_table_insert(defaults, strdup("otr.started.untrusted"), strdup("yellow")); - g_hash_table_insert(defaults, strdup("otr.ended"), strdup("red")); - g_hash_table_insert(defaults, strdup("otr.trusted"), strdup("green")); - g_hash_table_insert(defaults, strdup("otr.untrusted"), strdup("yellow")); - g_hash_table_insert(defaults, strdup("roster.header"), strdup("yellow")); - g_hash_table_insert(defaults, strdup("roster.online"), strdup("green")); - g_hash_table_insert(defaults, strdup("roster.offline"), strdup("red")); - g_hash_table_insert(defaults, strdup("roster.chat"), strdup("green")); - g_hash_table_insert(defaults, strdup("roster.away"), strdup("cyan")); - g_hash_table_insert(defaults, strdup("roster.dnd"), strdup("red")); - g_hash_table_insert(defaults, strdup("roster.xa"), strdup("cyan")); - g_hash_table_insert(defaults, strdup("roster.online.active"), strdup("green")); - g_hash_table_insert(defaults, strdup("roster.offline.active"), strdup("red")); - g_hash_table_insert(defaults, strdup("roster.chat.active"), strdup("green")); - g_hash_table_insert(defaults, strdup("roster.away.active"), strdup("cyan")); - g_hash_table_insert(defaults, strdup("roster.dnd.active"), strdup("red")); - g_hash_table_insert(defaults, strdup("roster.xa.active"), strdup("cyan")); - g_hash_table_insert(defaults, strdup("roster.online.unread"), strdup("green")); - g_hash_table_insert(defaults, strdup("roster.offline.unread"), strdup("red")); - g_hash_table_insert(defaults, strdup("roster.chat.unread"), strdup("green")); - g_hash_table_insert(defaults, strdup("roster.away.unread"), strdup("cyan")); - g_hash_table_insert(defaults, strdup("roster.dnd.unread"), strdup("red")); - g_hash_table_insert(defaults, strdup("roster.xa.unread"), strdup("cyan")); - g_hash_table_insert(defaults, strdup("roster.room"), strdup("green")); - g_hash_table_insert(defaults, strdup("roster.room.unread"), strdup("green")); - g_hash_table_insert(defaults, strdup("roster.room.trigger"), strdup("green")); - g_hash_table_insert(defaults, strdup("roster.room.mention"), strdup("green")); - g_hash_table_insert(defaults, strdup("occupants.header"), strdup("yellow")); - g_hash_table_insert(defaults, strdup("untrusted"), strdup("red")); - g_hash_table_insert(defaults, strdup("cmd.wins.unread"), strdup("default")); + g_hash_table_insert(defaults, strdup("main.text"), strdup("default")); + g_hash_table_insert(defaults, strdup("main.text.history"), strdup("default")); + g_hash_table_insert(defaults, strdup("main.text.me"), strdup("default")); + g_hash_table_insert(defaults, strdup("main.text.them"), strdup("default")); + g_hash_table_insert(defaults, strdup("main.splash"), strdup("cyan")); + g_hash_table_insert(defaults, strdup("main.help.header"), strdup("default")); + g_hash_table_insert(defaults, strdup("error"), strdup("red")); + g_hash_table_insert(defaults, strdup("incoming"), strdup("yellow")); + g_hash_table_insert(defaults, strdup("mention"), strdup("yellow")); + g_hash_table_insert(defaults, strdup("trigger"), strdup("yellow")); + g_hash_table_insert(defaults, strdup("input.text"), strdup("default")); + g_hash_table_insert(defaults, strdup("main.time"), strdup("default")); + g_hash_table_insert(defaults, strdup("titlebar.text"), strdup("white")); + g_hash_table_insert(defaults, strdup("titlebar.brackets"), strdup("cyan")); + g_hash_table_insert(defaults, strdup("titlebar.unencrypted"), strdup("red")); + g_hash_table_insert(defaults, strdup("titlebar.encrypted"), strdup("white")); + g_hash_table_insert(defaults, strdup("titlebar.untrusted"), strdup("yellow")); + g_hash_table_insert(defaults, strdup("titlebar.trusted"), strdup("white")); + g_hash_table_insert(defaults, strdup("titlebar.online"), strdup("white")); + g_hash_table_insert(defaults, strdup("titlebar.offline"), strdup("white")); + g_hash_table_insert(defaults, strdup("titlebar.away"), strdup("white")); + g_hash_table_insert(defaults, strdup("titlebar.chat"), strdup("white")); + g_hash_table_insert(defaults, strdup("titlebar.dnd"), strdup("white")); + g_hash_table_insert(defaults, strdup("titlebar.xa"), strdup("white")); + g_hash_table_insert(defaults, strdup("titlebar.scrolled"), strdup("default")); + g_hash_table_insert(defaults, strdup("statusbar.text"), strdup("white")); + g_hash_table_insert(defaults, strdup("statusbar.brackets"), strdup("cyan")); + g_hash_table_insert(defaults, strdup("statusbar.active"), strdup("cyan")); + g_hash_table_insert(defaults, strdup("statusbar.current"), strdup("cyan")); + g_hash_table_insert(defaults, strdup("statusbar.new"), strdup("white")); + g_hash_table_insert(defaults, strdup("statusbar.time"), strdup("white")); + g_hash_table_insert(defaults, strdup("me"), strdup("yellow")); + g_hash_table_insert(defaults, strdup("them"), strdup("green")); + g_hash_table_insert(defaults, strdup("receipt.sent"), strdup("red")); + g_hash_table_insert(defaults, strdup("roominfo"), strdup("yellow")); + g_hash_table_insert(defaults, strdup("roommention"), strdup("yellow")); + g_hash_table_insert(defaults, strdup("roommention.term"), strdup("yellow")); + g_hash_table_insert(defaults, strdup("roomtrigger"), strdup("yellow")); + g_hash_table_insert(defaults, strdup("roomtrigger.term"), strdup("yellow")); + g_hash_table_insert(defaults, strdup("online"), strdup("green")); + g_hash_table_insert(defaults, strdup("offline"), strdup("red")); + g_hash_table_insert(defaults, strdup("away"), strdup("cyan")); + g_hash_table_insert(defaults, strdup("chat"), strdup("green")); + g_hash_table_insert(defaults, strdup("dnd"), strdup("red")); + g_hash_table_insert(defaults, strdup("xa"), strdup("cyan")); + g_hash_table_insert(defaults, strdup("typing"), strdup("yellow")); + g_hash_table_insert(defaults, strdup("gone"), strdup("red")); + g_hash_table_insert(defaults, strdup("subscribed"), strdup("green")); + g_hash_table_insert(defaults, strdup("unsubscribed"), strdup("red")); + g_hash_table_insert(defaults, strdup("otr.started.trusted"), strdup("green")); + g_hash_table_insert(defaults, strdup("otr.started.untrusted"), strdup("yellow")); + g_hash_table_insert(defaults, strdup("otr.ended"), strdup("red")); + g_hash_table_insert(defaults, strdup("otr.trusted"), strdup("green")); + g_hash_table_insert(defaults, strdup("otr.untrusted"), strdup("yellow")); + g_hash_table_insert(defaults, strdup("roster.header"), strdup("yellow")); + g_hash_table_insert(defaults, strdup("roster.online"), strdup("green")); + g_hash_table_insert(defaults, strdup("roster.offline"), strdup("red")); + g_hash_table_insert(defaults, strdup("roster.chat"), strdup("green")); + g_hash_table_insert(defaults, strdup("roster.away"), strdup("cyan")); + g_hash_table_insert(defaults, strdup("roster.dnd"), strdup("red")); + g_hash_table_insert(defaults, strdup("roster.xa"), strdup("cyan")); + g_hash_table_insert(defaults, strdup("roster.online.active"), strdup("green")); + g_hash_table_insert(defaults, strdup("roster.offline.active"), strdup("red")); + g_hash_table_insert(defaults, strdup("roster.chat.active"), strdup("green")); + g_hash_table_insert(defaults, strdup("roster.away.active"), strdup("cyan")); + g_hash_table_insert(defaults, strdup("roster.dnd.active"), strdup("red")); + g_hash_table_insert(defaults, strdup("roster.xa.active"), strdup("cyan")); + g_hash_table_insert(defaults, strdup("roster.online.unread"), strdup("green")); + g_hash_table_insert(defaults, strdup("roster.offline.unread"), strdup("red")); + g_hash_table_insert(defaults, strdup("roster.chat.unread"), strdup("green")); + g_hash_table_insert(defaults, strdup("roster.away.unread"), strdup("cyan")); + g_hash_table_insert(defaults, strdup("roster.dnd.unread"), strdup("red")); + g_hash_table_insert(defaults, strdup("roster.xa.unread"), strdup("cyan")); + g_hash_table_insert(defaults, strdup("roster.room"), strdup("green")); + g_hash_table_insert(defaults, strdup("roster.room.unread"), strdup("green")); + g_hash_table_insert(defaults, strdup("roster.room.trigger"), strdup("green")); + g_hash_table_insert(defaults, strdup("roster.room.mention"), strdup("green")); + g_hash_table_insert(defaults, strdup("occupants.header"), strdup("yellow")); + g_hash_table_insert(defaults, strdup("untrusted"), strdup("red")); + g_hash_table_insert(defaults, strdup("cmd.wins.unread"), strdup("default")); //_load_preferences(); } gboolean -theme_exists(const char *const theme_name) +theme_exists(const char* const theme_name) { if (g_strcmp0(theme_name, "default") == 0) { return TRUE; } - GString *new_theme_file = _theme_find(theme_name); + GString* new_theme_file = _theme_find(theme_name); if (new_theme_file == NULL) { return FALSE; } @@ -179,7 +179,7 @@ theme_exists(const char *const theme_name) } gboolean -theme_load(const char *const theme_name, gboolean load_theme_prefs) +theme_load(const char* const theme_name, gboolean load_theme_prefs) { color_pair_cache_reset(); @@ -194,7 +194,7 @@ theme_load(const char *const theme_name, gboolean load_theme_prefs) } static gboolean -_theme_load_file(const char *const theme_name) +_theme_load_file(const char* const theme_name) { // use default theme if (theme_name == NULL || strcmp(theme_name, "default") == 0) { @@ -203,9 +203,9 @@ _theme_load_file(const char *const theme_name) } theme = g_key_file_new(); - // load theme from file + // load theme from file } else { - GString *new_theme_file = _theme_find(theme_name); + GString* new_theme_file = _theme_find(theme_name); if (new_theme_file == NULL) { log_info("Theme does not exist \"%s\"", theme_name); return FALSE; @@ -221,7 +221,7 @@ _theme_load_file(const char *const theme_name) } theme = g_key_file_new(); g_key_file_load_from_file(theme, theme_loc->str, G_KEY_FILE_KEEP_COMMENTS, - NULL); + NULL); } return TRUE; @@ -230,8 +230,8 @@ _theme_load_file(const char *const theme_name) GSList* theme_list(void) { - GSList *result = NULL; - gchar *themes_dir = files_get_config_path(DIR_THEMES); + GSList* result = NULL; + gchar* themes_dir = files_get_config_path(DIR_THEMES); _theme_list_dir(themes_dir, &result); g_free(themes_dir); @@ -272,17 +272,17 @@ theme_init_colours(void) } static void -_set_string_preference(char *prefstr, preference_t pref) +_set_string_preference(char* prefstr, preference_t pref) { if (g_key_file_has_key(theme, "ui", prefstr, NULL)) { - gchar *val = g_key_file_get_string(theme, "ui", prefstr, NULL); + gchar* val = g_key_file_get_string(theme, "ui", prefstr, NULL); prefs_set_string(pref, val); g_free(val); } } static void -_set_boolean_preference(char *prefstr, preference_t pref) +_set_boolean_preference(char* prefstr, preference_t pref) { if (g_key_file_has_key(theme, "ui", prefstr, NULL)) { gboolean val = g_key_file_get_boolean(theme, "ui", prefstr, NULL); @@ -401,7 +401,7 @@ _load_preferences(void) // load chars from theme and set them to prefs // with custom set functions if (g_key_file_has_key(theme, "ui", "occupants.char", NULL)) { - gchar *ch = g_key_file_get_string(theme, "ui", "occupants.char", NULL); + gchar* ch = g_key_file_get_string(theme, "ui", "occupants.char", NULL); if (ch && strlen(ch) > 0) { prefs_set_occupants_char(ch[0]); g_free(ch); @@ -409,7 +409,7 @@ _load_preferences(void) } if (g_key_file_has_key(theme, "ui", "occupants.header.char", NULL)) { - gchar *ch = g_key_file_get_string(theme, "ui", "occupants.header.char", NULL); + gchar* ch = g_key_file_get_string(theme, "ui", "occupants.header.char", NULL); if (ch && strlen(ch) > 0) { prefs_set_occupants_header_char(ch[0]); g_free(ch); @@ -417,7 +417,7 @@ _load_preferences(void) } if (g_key_file_has_key(theme, "ui", "roster.header.char", NULL)) { - gchar *ch = g_key_file_get_string(theme, "ui", "roster.header.char", NULL); + gchar* ch = g_key_file_get_string(theme, "ui", "roster.header.char", NULL); if (ch && strlen(ch) > 0) { prefs_set_roster_header_char(ch[0]); g_free(ch); @@ -425,7 +425,7 @@ _load_preferences(void) } if (g_key_file_has_key(theme, "ui", "roster.contact.char", NULL)) { - gchar *ch = g_key_file_get_string(theme, "ui", "roster.contact.char", NULL); + gchar* ch = g_key_file_get_string(theme, "ui", "roster.contact.char", NULL); if (ch && strlen(ch) > 0) { prefs_set_roster_contact_char(ch[0]); g_free(ch); @@ -433,7 +433,7 @@ _load_preferences(void) } if (g_key_file_has_key(theme, "ui", "roster.resource.char", NULL)) { - gchar *ch = g_key_file_get_string(theme, "ui", "roster.resource.char", NULL); + gchar* ch = g_key_file_get_string(theme, "ui", "roster.resource.char", NULL); if (ch && strlen(ch) > 0) { prefs_set_roster_resource_char(ch[0]); g_free(ch); @@ -443,7 +443,7 @@ _load_preferences(void) } if (g_key_file_has_key(theme, "ui", "roster.rooms.char", NULL)) { - gchar *ch = g_key_file_get_string(theme, "ui", "roster.rooms.char", NULL); + gchar* ch = g_key_file_get_string(theme, "ui", "roster.rooms.char", NULL); if (ch && strlen(ch) > 0) { prefs_set_roster_room_char(ch[0]); g_free(ch); @@ -451,7 +451,7 @@ _load_preferences(void) } if (g_key_file_has_key(theme, "ui", "roster.rooms.private.char", NULL)) { - gchar *ch = g_key_file_get_string(theme, "ui", "roster.rooms.private.char", NULL); + gchar* ch = g_key_file_get_string(theme, "ui", "roster.rooms.private.char", NULL); if (ch && strlen(ch) > 0) { prefs_set_roster_room_private_char(ch[0]); g_free(ch); @@ -459,7 +459,7 @@ _load_preferences(void) } if (g_key_file_has_key(theme, "ui", "roster.private.char", NULL)) { - gchar *ch = g_key_file_get_string(theme, "ui", "roster.private.char", NULL); + gchar* ch = g_key_file_get_string(theme, "ui", "roster.private.char", NULL); if (ch && strlen(ch) > 0) { prefs_set_roster_private_char(ch[0]); g_free(ch); @@ -467,7 +467,7 @@ _load_preferences(void) } if (g_key_file_has_key(theme, "ui", "otr.char", NULL)) { - gchar *ch = g_key_file_get_string(theme, "ui", "otr.char", NULL); + gchar* ch = g_key_file_get_string(theme, "ui", "otr.char", NULL); if (ch && g_utf8_strlen(ch, 4) == 1) { prefs_set_otr_char(ch); g_free(ch); @@ -475,7 +475,7 @@ _load_preferences(void) } if (g_key_file_has_key(theme, "ui", "pgp.char", NULL)) { - gchar *ch = g_key_file_get_string(theme, "ui", "pgp.char", NULL); + gchar* ch = g_key_file_get_string(theme, "ui", "pgp.char", NULL); if (ch && g_utf8_strlen(ch, 4) == 1) { prefs_set_pgp_char(ch); g_free(ch); @@ -483,7 +483,7 @@ _load_preferences(void) } if (g_key_file_has_key(theme, "ui", "omemo.char", NULL)) { - gchar *ch = g_key_file_get_string(theme, "ui", "omemo.char", NULL); + gchar* ch = g_key_file_get_string(theme, "ui", "omemo.char", NULL); if (ch && g_utf8_strlen(ch, 4) == 1) { prefs_set_omemo_char(ch); g_free(ch); @@ -491,7 +491,7 @@ _load_preferences(void) } if (g_key_file_has_key(theme, "ui", "correction.char", NULL)) { - gchar *ch = g_key_file_get_string(theme, "ui", "correction.char", NULL); + gchar* ch = g_key_file_get_string(theme, "ui", "correction.char", NULL); if (ch && strlen(ch) > 0) { prefs_set_correction_char(ch[0]); g_free(ch); @@ -499,17 +499,14 @@ _load_preferences(void) } // load window positions - if (g_key_file_has_key(theme, "ui", "titlebar.position", NULL) && - g_key_file_has_key(theme, "ui", "mainwin.position", NULL) && - g_key_file_has_key(theme, "ui", "statusbar.position", NULL) && - g_key_file_has_key(theme, "ui", "inputwin.position", NULL)) { + if (g_key_file_has_key(theme, "ui", "titlebar.position", NULL) && g_key_file_has_key(theme, "ui", "mainwin.position", NULL) && g_key_file_has_key(theme, "ui", "statusbar.position", NULL) && g_key_file_has_key(theme, "ui", "inputwin.position", NULL)) { int titlebar_pos = g_key_file_get_integer(theme, "ui", "titlebar.position", NULL); int mainwin_pos = g_key_file_get_integer(theme, "ui", "mainwin.position", NULL); int statusbar_pos = g_key_file_get_integer(theme, "ui", "statusbar.position", NULL); int inputwin_pos = g_key_file_get_integer(theme, "ui", "inputwin.position", NULL); - ProfWinPlacement *placement = prefs_create_profwin_placement(titlebar_pos, mainwin_pos, statusbar_pos, inputwin_pos); + ProfWinPlacement* placement = prefs_create_profwin_placement(titlebar_pos, mainwin_pos, statusbar_pos, inputwin_pos); prefs_save_win_placement(placement); prefs_free_win_placement(placement); @@ -517,11 +514,11 @@ _load_preferences(void) } static void -_theme_list_dir(const gchar *const dir, GSList **result) +_theme_list_dir(const gchar* const dir, GSList** result) { - GDir *themes = g_dir_open(dir, 0, NULL); + GDir* themes = g_dir_open(dir, 0, NULL); if (themes) { - const gchar *theme = g_dir_read_name(themes); + const gchar* theme = g_dir_read_name(themes); while (theme) { *result = g_slist_append(*result, strdup(theme)); theme = g_dir_read_name(themes); @@ -531,10 +528,10 @@ _theme_list_dir(const gchar *const dir, GSList **result) } static GString* -_theme_find(const char *const theme_name) +_theme_find(const char* const theme_name) { - GString *path = NULL; - gchar *themes_dir = files_get_config_path(DIR_THEMES); + GString* path = NULL; + gchar* themes_dir = files_get_config_path(DIR_THEMES); if (themes_dir) { path = g_string_new(themes_dir); @@ -563,7 +560,7 @@ _theme_find(const char *const theme_name) } theme_item_t -theme_roster_unread_presence_attrs(const char *const presence) +theme_roster_unread_presence_attrs(const char* const presence) { if (g_strcmp0(presence, "online") == 0) { return THEME_ROSTER_ONLINE_UNREAD; @@ -581,7 +578,7 @@ theme_roster_unread_presence_attrs(const char *const presence) } theme_item_t -theme_roster_active_presence_attrs(const char *const presence) +theme_roster_active_presence_attrs(const char* const presence) { if (g_strcmp0(presence, "online") == 0) { return THEME_ROSTER_ONLINE_ACTIVE; @@ -599,7 +596,7 @@ theme_roster_active_presence_attrs(const char *const presence) } theme_item_t -theme_roster_presence_attrs(const char *const presence) +theme_roster_presence_attrs(const char* const presence) { if (g_strcmp0(presence, "online") == 0) { return THEME_ROSTER_ONLINE; @@ -617,7 +614,7 @@ theme_roster_presence_attrs(const char *const presence) } theme_item_t -theme_main_presence_attrs(const char *const presence) +theme_main_presence_attrs(const char* const presence) { if (g_strcmp0(presence, "online") == 0) { return THEME_ONLINE; @@ -635,9 +632,9 @@ theme_main_presence_attrs(const char *const presence) } static void -_theme_prep_bgnd(char *setting, char *def, GString *lookup_str) +_theme_prep_bgnd(char* setting, char* def, GString* lookup_str) { - gchar *val = g_key_file_get_string(theme, "colours", setting, NULL); + gchar* val = g_key_file_get_string(theme, "colours", setting, NULL); if (!val) { g_string_append(lookup_str, def); } else { @@ -654,17 +651,17 @@ _theme_prep_bgnd(char *setting, char *def, GString *lookup_str) char* theme_get_bkgnd(void) { - char *val = g_key_file_get_string(theme, "colours", "bkgnd", NULL); + char* val = g_key_file_get_string(theme, "colours", "bkgnd", NULL); return val; } /* gets the foreground color from the theme. or uses the one defined in 'defaults' */ static void -_theme_prep_fgnd(char *setting, GString *lookup_str, gboolean *bold) +_theme_prep_fgnd(char* setting, GString* lookup_str, gboolean* bold) { - gchar *val = g_key_file_get_string(theme, "colours", setting, NULL); + gchar* val = g_key_file_get_string(theme, "colours", setting, NULL); if (!val) { - char *def = g_hash_table_lookup(defaults, setting); + char* def = g_hash_table_lookup(defaults, setting); g_string_append(lookup_str, def); } else { if (g_str_has_prefix(val, "bold_")) { @@ -679,9 +676,9 @@ _theme_prep_fgnd(char *setting, GString *lookup_str, gboolean *bold) } char* -theme_get_string(char *str) +theme_get_string(char* str) { - char *res = g_key_file_get_string(theme, "colours", str, NULL); + char* res = g_key_file_get_string(theme, "colours", str, NULL); if (!res) { return strdup(g_hash_table_lookup(defaults, str)); } else { @@ -690,7 +687,7 @@ theme_get_string(char *str) } void -theme_free_string(char *str) +theme_free_string(char* str) { if (str) { g_free(str); @@ -698,11 +695,11 @@ theme_free_string(char *str) } int -theme_hash_attrs(const char *str) +theme_hash_attrs(const char* str) { color_profile profile = COLOR_PROFILE_DEFAULT; - char *color_pref = prefs_get_string(PREF_COLOR_NICK); + char* color_pref = prefs_get_string(PREF_COLOR_NICK); if (strcmp(color_pref, "redgreen") == 0) { profile = COLOR_PROFILE_REDGREEN_BLINDNESS; } else if (strcmp(color_pref, "blue") == 0) { @@ -719,109 +716,322 @@ theme_attrs(theme_item_t attrs) { int result = 0; - GString *lookup_str = g_string_new(""); + GString* lookup_str = g_string_new(""); gboolean bold = FALSE; // get forground colour switch (attrs) { - case THEME_TEXT: _theme_prep_fgnd("main.text", lookup_str, &bold); break; - case THEME_TEXT_HISTORY: _theme_prep_fgnd("main.text.history", lookup_str, &bold); break; - case THEME_TEXT_ME: _theme_prep_fgnd("main.text.me", lookup_str, &bold); break; - case THEME_TEXT_THEM: _theme_prep_fgnd("main.text.them", lookup_str, &bold); break; - case THEME_SPLASH: _theme_prep_fgnd("main.splash", lookup_str, &bold); break; - case THEME_TRACKBAR: _theme_prep_fgnd("main.trackbar", lookup_str, &bold); break; - case THEME_HELP_HEADER: _theme_prep_fgnd("main.help.header", lookup_str, &bold); break; - case THEME_ERROR: _theme_prep_fgnd("error", lookup_str, &bold); break; - case THEME_INCOMING: _theme_prep_fgnd("incoming", lookup_str, &bold); break; - case THEME_MENTION: _theme_prep_fgnd("mention", lookup_str, &bold); break; - case THEME_TRIGGER: _theme_prep_fgnd("trigger", lookup_str, &bold); break; - case THEME_INPUT_TEXT: _theme_prep_fgnd("input.text", lookup_str, &bold); break; - case THEME_TIME: _theme_prep_fgnd("main.time", lookup_str, &bold); break; - case THEME_TITLE_TEXT: _theme_prep_fgnd("titlebar.text", lookup_str, &bold); break; - case THEME_TITLE_BRACKET: _theme_prep_fgnd("titlebar.brackets", lookup_str, &bold); break; - case THEME_TITLE_SCROLLED: _theme_prep_fgnd("titlebar.scrolled", lookup_str, &bold); break; - case THEME_TITLE_UNENCRYPTED: _theme_prep_fgnd("titlebar.unencrypted", lookup_str, &bold); break; - case THEME_TITLE_ENCRYPTED: _theme_prep_fgnd("titlebar.encrypted", lookup_str, &bold); break; - case THEME_TITLE_UNTRUSTED: _theme_prep_fgnd("titlebar.untrusted", lookup_str, &bold); break; - case THEME_TITLE_TRUSTED: _theme_prep_fgnd("titlebar.trusted", lookup_str, &bold); break; - case THEME_TITLE_ONLINE: _theme_prep_fgnd("titlebar.online", lookup_str, &bold); break; - case THEME_TITLE_OFFLINE: _theme_prep_fgnd("titlebar.offline", lookup_str, &bold); break; - case THEME_TITLE_AWAY: _theme_prep_fgnd("titlebar.away", lookup_str, &bold); break; - case THEME_TITLE_CHAT: _theme_prep_fgnd("titlebar.chat", lookup_str, &bold); break; - case THEME_TITLE_DND: _theme_prep_fgnd("titlebar.dnd", lookup_str, &bold); break; - case THEME_TITLE_XA: _theme_prep_fgnd("titlebar.xa", lookup_str, &bold); break; - case THEME_STATUS_TEXT: _theme_prep_fgnd("statusbar.text", lookup_str, &bold); break; - case THEME_STATUS_BRACKET: _theme_prep_fgnd("statusbar.brackets", lookup_str, &bold); break; - case THEME_STATUS_ACTIVE: _theme_prep_fgnd("statusbar.active", lookup_str, &bold); break; - case THEME_STATUS_CURRENT: _theme_prep_fgnd("statusbar.current", lookup_str, &bold); break; - case THEME_STATUS_NEW: _theme_prep_fgnd("statusbar.new", lookup_str, &bold); break; - case THEME_STATUS_TIME: _theme_prep_fgnd("statusbar.time", lookup_str, &bold); break; - case THEME_ME: _theme_prep_fgnd("me", lookup_str, &bold); break; - case THEME_THEM: _theme_prep_fgnd("them", lookup_str, &bold); break; - case THEME_RECEIPT_SENT: _theme_prep_fgnd("receipt.sent", lookup_str, &bold); break; - case THEME_ROOMINFO: _theme_prep_fgnd("roominfo", lookup_str, &bold); break; - case THEME_ROOMMENTION: _theme_prep_fgnd("roommention", lookup_str, &bold); break; - case THEME_ROOMMENTION_TERM: _theme_prep_fgnd("roommention.term", lookup_str, &bold); break; - case THEME_ROOMTRIGGER: _theme_prep_fgnd("roomtrigger", lookup_str, &bold); break; - case THEME_ROOMTRIGGER_TERM: _theme_prep_fgnd("roomtrigger.term", lookup_str, &bold); break; - case THEME_ONLINE: _theme_prep_fgnd("online", lookup_str, &bold); break; - case THEME_OFFLINE: _theme_prep_fgnd("offline", lookup_str, &bold); break; - case THEME_AWAY: _theme_prep_fgnd("away", lookup_str, &bold); break; - case THEME_CHAT: _theme_prep_fgnd("chat", lookup_str, &bold); break; - case THEME_DND: _theme_prep_fgnd("dnd", lookup_str, &bold); break; - case THEME_XA: _theme_prep_fgnd("xa", lookup_str, &bold); break; - case THEME_TYPING: _theme_prep_fgnd("typing", lookup_str, &bold); break; - case THEME_GONE: _theme_prep_fgnd("gone", lookup_str, &bold); break; - case THEME_SUBSCRIBED: _theme_prep_fgnd("subscribed", lookup_str, &bold); break; - case THEME_UNSUBSCRIBED: _theme_prep_fgnd("unsubscribed", lookup_str, &bold); break; - case THEME_OTR_STARTED_TRUSTED: _theme_prep_fgnd("otr.started.trusted", lookup_str, &bold); break; - case THEME_OTR_STARTED_UNTRUSTED: _theme_prep_fgnd("otr.started.untrusted", lookup_str, &bold); break; - case THEME_OTR_ENDED: _theme_prep_fgnd("otr.ended", lookup_str, &bold); break; - case THEME_OTR_TRUSTED: _theme_prep_fgnd("otr.trusted", lookup_str, &bold); break; - case THEME_OTR_UNTRUSTED: _theme_prep_fgnd("otr.untrusted", lookup_str, &bold); break; - case THEME_ROSTER_HEADER: _theme_prep_fgnd("roster.header", lookup_str, &bold); break; - case THEME_ROSTER_ONLINE: _theme_prep_fgnd("roster.online", lookup_str, &bold); break; - case THEME_ROSTER_OFFLINE: _theme_prep_fgnd("roster.offline", lookup_str, &bold); break; - case THEME_ROSTER_CHAT: _theme_prep_fgnd("roster.chat", lookup_str, &bold); break; - case THEME_ROSTER_AWAY: _theme_prep_fgnd("roster.away", lookup_str, &bold); break; - case THEME_ROSTER_DND: _theme_prep_fgnd("roster.dnd", lookup_str, &bold); break; - case THEME_ROSTER_XA: _theme_prep_fgnd("roster.xa", lookup_str, &bold); break; - case THEME_ROSTER_ONLINE_ACTIVE: _theme_prep_fgnd("roster.online.active", lookup_str, &bold); break; - case THEME_ROSTER_OFFLINE_ACTIVE: _theme_prep_fgnd("roster.offline.active", lookup_str, &bold); break; - case THEME_ROSTER_CHAT_ACTIVE: _theme_prep_fgnd("roster.chat.active", lookup_str, &bold); break; - case THEME_ROSTER_AWAY_ACTIVE: _theme_prep_fgnd("roster.away.active", lookup_str, &bold); break; - case THEME_ROSTER_DND_ACTIVE: _theme_prep_fgnd("roster.dnd.active", lookup_str, &bold); break; - case THEME_ROSTER_XA_ACTIVE: _theme_prep_fgnd("roster.xa.active", lookup_str, &bold); break; - case THEME_ROSTER_ONLINE_UNREAD: _theme_prep_fgnd("roster.online.unread", lookup_str, &bold); break; - case THEME_ROSTER_OFFLINE_UNREAD: _theme_prep_fgnd("roster.offline.unread", lookup_str, &bold); break; - case THEME_ROSTER_CHAT_UNREAD: _theme_prep_fgnd("roster.chat.unread", lookup_str, &bold); break; - case THEME_ROSTER_AWAY_UNREAD: _theme_prep_fgnd("roster.away.unread", lookup_str, &bold); break; - case THEME_ROSTER_DND_UNREAD: _theme_prep_fgnd("roster.dnd.unread", lookup_str, &bold); break; - case THEME_ROSTER_XA_UNREAD: _theme_prep_fgnd("roster.xa.unread", lookup_str, &bold); break; - case THEME_ROSTER_ROOM: _theme_prep_fgnd("roster.room", lookup_str, &bold); break; - case THEME_ROSTER_ROOM_UNREAD: _theme_prep_fgnd("roster.room.unread", lookup_str, &bold); break; - case THEME_ROSTER_ROOM_TRIGGER: _theme_prep_fgnd("roster.room.trigger", lookup_str, &bold); break; - case THEME_ROSTER_ROOM_MENTION: _theme_prep_fgnd("roster.room.mention", lookup_str, &bold); break; - case THEME_OCCUPANTS_HEADER: _theme_prep_fgnd("occupants.header", lookup_str, &bold); break; - case THEME_UNTRUSTED: _theme_prep_fgnd("untrusted", lookup_str, &bold); break; - case THEME_CMD_WINS_UNREAD: _theme_prep_fgnd("cmd.wins.unread", lookup_str, &bold); break; - case THEME_WHITE: g_string_append(lookup_str, "white"); bold = FALSE; break; - case THEME_WHITE_BOLD: g_string_append(lookup_str, "white"); bold = TRUE; break; - case THEME_GREEN: g_string_append(lookup_str, "green"); bold = FALSE; break; - case THEME_GREEN_BOLD: g_string_append(lookup_str, "green"); bold = TRUE; break; - case THEME_RED: g_string_append(lookup_str, "red"); bold = FALSE; break; - case THEME_RED_BOLD: g_string_append(lookup_str, "red"); bold = TRUE; break; - case THEME_YELLOW: g_string_append(lookup_str, "yellow"); bold = FALSE; break; - case THEME_YELLOW_BOLD: g_string_append(lookup_str, "yellow"); bold = TRUE; break; - case THEME_BLUE: g_string_append(lookup_str, "blue"); bold = FALSE; break; - case THEME_BLUE_BOLD: g_string_append(lookup_str, "blue"); bold = TRUE; break; - case THEME_CYAN: g_string_append(lookup_str, "cyan"); bold = FALSE; break; - case THEME_CYAN_BOLD: g_string_append(lookup_str, "cyan"); bold = TRUE; break; - case THEME_BLACK: g_string_append(lookup_str, "black"); bold = FALSE; break; - case THEME_BLACK_BOLD: g_string_append(lookup_str, "black"); bold = TRUE; break; - case THEME_MAGENTA: g_string_append(lookup_str, "magenta"); bold = FALSE; break; - case THEME_MAGENTA_BOLD: g_string_append(lookup_str, "magenta"); bold = TRUE; break; - default: g_string_append(lookup_str, "default"); bold = FALSE; break; + case THEME_TEXT: + _theme_prep_fgnd("main.text", lookup_str, &bold); + break; + case THEME_TEXT_HISTORY: + _theme_prep_fgnd("main.text.history", lookup_str, &bold); + break; + case THEME_TEXT_ME: + _theme_prep_fgnd("main.text.me", lookup_str, &bold); + break; + case THEME_TEXT_THEM: + _theme_prep_fgnd("main.text.them", lookup_str, &bold); + break; + case THEME_SPLASH: + _theme_prep_fgnd("main.splash", lookup_str, &bold); + break; + case THEME_TRACKBAR: + _theme_prep_fgnd("main.trackbar", lookup_str, &bold); + break; + case THEME_HELP_HEADER: + _theme_prep_fgnd("main.help.header", lookup_str, &bold); + break; + case THEME_ERROR: + _theme_prep_fgnd("error", lookup_str, &bold); + break; + case THEME_INCOMING: + _theme_prep_fgnd("incoming", lookup_str, &bold); + break; + case THEME_MENTION: + _theme_prep_fgnd("mention", lookup_str, &bold); + break; + case THEME_TRIGGER: + _theme_prep_fgnd("trigger", lookup_str, &bold); + break; + case THEME_INPUT_TEXT: + _theme_prep_fgnd("input.text", lookup_str, &bold); + break; + case THEME_TIME: + _theme_prep_fgnd("main.time", lookup_str, &bold); + break; + case THEME_TITLE_TEXT: + _theme_prep_fgnd("titlebar.text", lookup_str, &bold); + break; + case THEME_TITLE_BRACKET: + _theme_prep_fgnd("titlebar.brackets", lookup_str, &bold); + break; + case THEME_TITLE_SCROLLED: + _theme_prep_fgnd("titlebar.scrolled", lookup_str, &bold); + break; + case THEME_TITLE_UNENCRYPTED: + _theme_prep_fgnd("titlebar.unencrypted", lookup_str, &bold); + break; + case THEME_TITLE_ENCRYPTED: + _theme_prep_fgnd("titlebar.encrypted", lookup_str, &bold); + break; + case THEME_TITLE_UNTRUSTED: + _theme_prep_fgnd("titlebar.untrusted", lookup_str, &bold); + break; + case THEME_TITLE_TRUSTED: + _theme_prep_fgnd("titlebar.trusted", lookup_str, &bold); + break; + case THEME_TITLE_ONLINE: + _theme_prep_fgnd("titlebar.online", lookup_str, &bold); + break; + case THEME_TITLE_OFFLINE: + _theme_prep_fgnd("titlebar.offline", lookup_str, &bold); + break; + case THEME_TITLE_AWAY: + _theme_prep_fgnd("titlebar.away", lookup_str, &bold); + break; + case THEME_TITLE_CHAT: + _theme_prep_fgnd("titlebar.chat", lookup_str, &bold); + break; + case THEME_TITLE_DND: + _theme_prep_fgnd("titlebar.dnd", lookup_str, &bold); + break; + case THEME_TITLE_XA: + _theme_prep_fgnd("titlebar.xa", lookup_str, &bold); + break; + case THEME_STATUS_TEXT: + _theme_prep_fgnd("statusbar.text", lookup_str, &bold); + break; + case THEME_STATUS_BRACKET: + _theme_prep_fgnd("statusbar.brackets", lookup_str, &bold); + break; + case THEME_STATUS_ACTIVE: + _theme_prep_fgnd("statusbar.active", lookup_str, &bold); + break; + case THEME_STATUS_CURRENT: + _theme_prep_fgnd("statusbar.current", lookup_str, &bold); + break; + case THEME_STATUS_NEW: + _theme_prep_fgnd("statusbar.new", lookup_str, &bold); + break; + case THEME_STATUS_TIME: + _theme_prep_fgnd("statusbar.time", lookup_str, &bold); + break; + case THEME_ME: + _theme_prep_fgnd("me", lookup_str, &bold); + break; + case THEME_THEM: + _theme_prep_fgnd("them", lookup_str, &bold); + break; + case THEME_RECEIPT_SENT: + _theme_prep_fgnd("receipt.sent", lookup_str, &bold); + break; + case THEME_ROOMINFO: + _theme_prep_fgnd("roominfo", lookup_str, &bold); + break; + case THEME_ROOMMENTION: + _theme_prep_fgnd("roommention", lookup_str, &bold); + break; + case THEME_ROOMMENTION_TERM: + _theme_prep_fgnd("roommention.term", lookup_str, &bold); + break; + case THEME_ROOMTRIGGER: + _theme_prep_fgnd("roomtrigger", lookup_str, &bold); + break; + case THEME_ROOMTRIGGER_TERM: + _theme_prep_fgnd("roomtrigger.term", lookup_str, &bold); + break; + case THEME_ONLINE: + _theme_prep_fgnd("online", lookup_str, &bold); + break; + case THEME_OFFLINE: + _theme_prep_fgnd("offline", lookup_str, &bold); + break; + case THEME_AWAY: + _theme_prep_fgnd("away", lookup_str, &bold); + break; + case THEME_CHAT: + _theme_prep_fgnd("chat", lookup_str, &bold); + break; + case THEME_DND: + _theme_prep_fgnd("dnd", lookup_str, &bold); + break; + case THEME_XA: + _theme_prep_fgnd("xa", lookup_str, &bold); + break; + case THEME_TYPING: + _theme_prep_fgnd("typing", lookup_str, &bold); + break; + case THEME_GONE: + _theme_prep_fgnd("gone", lookup_str, &bold); + break; + case THEME_SUBSCRIBED: + _theme_prep_fgnd("subscribed", lookup_str, &bold); + break; + case THEME_UNSUBSCRIBED: + _theme_prep_fgnd("unsubscribed", lookup_str, &bold); + break; + case THEME_OTR_STARTED_TRUSTED: + _theme_prep_fgnd("otr.started.trusted", lookup_str, &bold); + break; + case THEME_OTR_STARTED_UNTRUSTED: + _theme_prep_fgnd("otr.started.untrusted", lookup_str, &bold); + break; + case THEME_OTR_ENDED: + _theme_prep_fgnd("otr.ended", lookup_str, &bold); + break; + case THEME_OTR_TRUSTED: + _theme_prep_fgnd("otr.trusted", lookup_str, &bold); + break; + case THEME_OTR_UNTRUSTED: + _theme_prep_fgnd("otr.untrusted", lookup_str, &bold); + break; + case THEME_ROSTER_HEADER: + _theme_prep_fgnd("roster.header", lookup_str, &bold); + break; + case THEME_ROSTER_ONLINE: + _theme_prep_fgnd("roster.online", lookup_str, &bold); + break; + case THEME_ROSTER_OFFLINE: + _theme_prep_fgnd("roster.offline", lookup_str, &bold); + break; + case THEME_ROSTER_CHAT: + _theme_prep_fgnd("roster.chat", lookup_str, &bold); + break; + case THEME_ROSTER_AWAY: + _theme_prep_fgnd("roster.away", lookup_str, &bold); + break; + case THEME_ROSTER_DND: + _theme_prep_fgnd("roster.dnd", lookup_str, &bold); + break; + case THEME_ROSTER_XA: + _theme_prep_fgnd("roster.xa", lookup_str, &bold); + break; + case THEME_ROSTER_ONLINE_ACTIVE: + _theme_prep_fgnd("roster.online.active", lookup_str, &bold); + break; + case THEME_ROSTER_OFFLINE_ACTIVE: + _theme_prep_fgnd("roster.offline.active", lookup_str, &bold); + break; + case THEME_ROSTER_CHAT_ACTIVE: + _theme_prep_fgnd("roster.chat.active", lookup_str, &bold); + break; + case THEME_ROSTER_AWAY_ACTIVE: + _theme_prep_fgnd("roster.away.active", lookup_str, &bold); + break; + case THEME_ROSTER_DND_ACTIVE: + _theme_prep_fgnd("roster.dnd.active", lookup_str, &bold); + break; + case THEME_ROSTER_XA_ACTIVE: + _theme_prep_fgnd("roster.xa.active", lookup_str, &bold); + break; + case THEME_ROSTER_ONLINE_UNREAD: + _theme_prep_fgnd("roster.online.unread", lookup_str, &bold); + break; + case THEME_ROSTER_OFFLINE_UNREAD: + _theme_prep_fgnd("roster.offline.unread", lookup_str, &bold); + break; + case THEME_ROSTER_CHAT_UNREAD: + _theme_prep_fgnd("roster.chat.unread", lookup_str, &bold); + break; + case THEME_ROSTER_AWAY_UNREAD: + _theme_prep_fgnd("roster.away.unread", lookup_str, &bold); + break; + case THEME_ROSTER_DND_UNREAD: + _theme_prep_fgnd("roster.dnd.unread", lookup_str, &bold); + break; + case THEME_ROSTER_XA_UNREAD: + _theme_prep_fgnd("roster.xa.unread", lookup_str, &bold); + break; + case THEME_ROSTER_ROOM: + _theme_prep_fgnd("roster.room", lookup_str, &bold); + break; + case THEME_ROSTER_ROOM_UNREAD: + _theme_prep_fgnd("roster.room.unread", lookup_str, &bold); + break; + case THEME_ROSTER_ROOM_TRIGGER: + _theme_prep_fgnd("roster.room.trigger", lookup_str, &bold); + break; + case THEME_ROSTER_ROOM_MENTION: + _theme_prep_fgnd("roster.room.mention", lookup_str, &bold); + break; + case THEME_OCCUPANTS_HEADER: + _theme_prep_fgnd("occupants.header", lookup_str, &bold); + break; + case THEME_UNTRUSTED: + _theme_prep_fgnd("untrusted", lookup_str, &bold); + break; + case THEME_CMD_WINS_UNREAD: + _theme_prep_fgnd("cmd.wins.unread", lookup_str, &bold); + break; + case THEME_WHITE: + g_string_append(lookup_str, "white"); + bold = FALSE; + break; + case THEME_WHITE_BOLD: + g_string_append(lookup_str, "white"); + bold = TRUE; + break; + case THEME_GREEN: + g_string_append(lookup_str, "green"); + bold = FALSE; + break; + case THEME_GREEN_BOLD: + g_string_append(lookup_str, "green"); + bold = TRUE; + break; + case THEME_RED: + g_string_append(lookup_str, "red"); + bold = FALSE; + break; + case THEME_RED_BOLD: + g_string_append(lookup_str, "red"); + bold = TRUE; + break; + case THEME_YELLOW: + g_string_append(lookup_str, "yellow"); + bold = FALSE; + break; + case THEME_YELLOW_BOLD: + g_string_append(lookup_str, "yellow"); + bold = TRUE; + break; + case THEME_BLUE: + g_string_append(lookup_str, "blue"); + bold = FALSE; + break; + case THEME_BLUE_BOLD: + g_string_append(lookup_str, "blue"); + bold = TRUE; + break; + case THEME_CYAN: + g_string_append(lookup_str, "cyan"); + bold = FALSE; + break; + case THEME_CYAN_BOLD: + g_string_append(lookup_str, "cyan"); + bold = TRUE; + break; + case THEME_BLACK: + g_string_append(lookup_str, "black"); + bold = FALSE; + break; + case THEME_BLACK_BOLD: + g_string_append(lookup_str, "black"); + bold = TRUE; + break; + case THEME_MAGENTA: + g_string_append(lookup_str, "magenta"); + bold = FALSE; + break; + case THEME_MAGENTA_BOLD: + g_string_append(lookup_str, "magenta"); + bold = TRUE; + break; + default: + g_string_append(lookup_str, "default"); + bold = FALSE; + break; } g_string_append(lookup_str, "_"); diff --git a/src/config/theme.h b/src/config/theme.h index 86fd534e..ef076925 100644 --- a/src/config/theme.h +++ b/src/config/theme.h @@ -143,20 +143,20 @@ typedef enum { THEME_TRACKBAR, } theme_item_t; -void theme_init(const char *const theme_name); +void theme_init(const char* const theme_name); void theme_init_colours(void); -gboolean theme_load(const char *const theme_name, gboolean load_theme_prefs); -gboolean theme_exists(const char *const theme_name); +gboolean theme_load(const char* const theme_name, gboolean load_theme_prefs); +gboolean theme_exists(const char* const theme_name); GSList* theme_list(void); void theme_close(void); -int theme_hash_attrs(const char *str); +int theme_hash_attrs(const char* str); int theme_attrs(theme_item_t attrs); -char* theme_get_string(char *str); -void theme_free_string(char *str); -theme_item_t theme_main_presence_attrs(const char *const presence); -theme_item_t theme_roster_unread_presence_attrs(const char *const presence); -theme_item_t theme_roster_active_presence_attrs(const char *const presence); -theme_item_t theme_roster_presence_attrs(const char *const presence); +char* theme_get_string(char* str); +void theme_free_string(char* str); +theme_item_t theme_main_presence_attrs(const char* const presence); +theme_item_t theme_roster_unread_presence_attrs(const char* const presence); +theme_item_t theme_roster_active_presence_attrs(const char* const presence); +theme_item_t theme_roster_presence_attrs(const char* const presence); char* theme_get_bkgnd(void); #endif diff --git a/src/config/tlscerts.c b/src/config/tlscerts.c index 69c600ce..6b4d759f 100644 --- a/src/config/tlscerts.c +++ b/src/config/tlscerts.c @@ -45,14 +45,14 @@ #include "config/tlscerts.h" #include "tools/autocomplete.h" -static char *tlscerts_loc; -static GKeyFile *tlscerts; +static char* tlscerts_loc; +static GKeyFile* tlscerts; static void _save_tlscerts(void); static Autocomplete certs_ac; -static char *current_fp; +static char* current_fp; void tlscerts_init(void) @@ -69,7 +69,7 @@ tlscerts_init(void) certs_ac = autocomplete_new(); gsize len = 0; - gchar **groups = g_key_file_get_groups(tlscerts, &len); + gchar** groups = g_key_file_get_groups(tlscerts, &len); int i = 0; for (i = 0; i < g_strv_length(groups); i++) { @@ -81,7 +81,7 @@ tlscerts_init(void) } void -tlscerts_set_current(const char *const fp) +tlscerts_set_current(const char* const fp) { if (current_fp) { free(current_fp); @@ -105,7 +105,7 @@ tlscerts_clear_current(void) } gboolean -tlscerts_exists(const char *const fingerprint) +tlscerts_exists(const char* const fingerprint) { return g_key_file_has_group(tlscerts, fingerprint); } @@ -113,24 +113,24 @@ tlscerts_exists(const char *const fingerprint) GList* tlscerts_list(void) { - GList *res = NULL; + GList* res = NULL; gsize len = 0; - gchar **groups = g_key_file_get_groups(tlscerts, &len); + gchar** groups = g_key_file_get_groups(tlscerts, &len); int i = 0; for (i = 0; i < g_strv_length(groups); i++) { - char *fingerprint = strdup(groups[i]); + char* fingerprint = strdup(groups[i]); int version = g_key_file_get_integer(tlscerts, fingerprint, "version", NULL); - char *serialnumber = g_key_file_get_string(tlscerts, fingerprint, "serialnumber", NULL); - char *subjectname = g_key_file_get_string(tlscerts, fingerprint, "subjectname", NULL); - char *issuername = g_key_file_get_string(tlscerts, fingerprint, "issuername", NULL); - char *notbefore = g_key_file_get_string(tlscerts, fingerprint, "start", NULL); - char *notafter = g_key_file_get_string(tlscerts, fingerprint, "end", NULL); - char *keyalg = g_key_file_get_string(tlscerts, fingerprint, "keyalg", NULL); - char *signaturealg = g_key_file_get_string(tlscerts, fingerprint, "signaturealg", NULL); + char* serialnumber = g_key_file_get_string(tlscerts, fingerprint, "serialnumber", NULL); + char* subjectname = g_key_file_get_string(tlscerts, fingerprint, "subjectname", NULL); + char* issuername = g_key_file_get_string(tlscerts, fingerprint, "issuername", NULL); + char* notbefore = g_key_file_get_string(tlscerts, fingerprint, "start", NULL); + char* notafter = g_key_file_get_string(tlscerts, fingerprint, "end", NULL); + char* keyalg = g_key_file_get_string(tlscerts, fingerprint, "keyalg", NULL); + char* signaturealg = g_key_file_get_string(tlscerts, fingerprint, "signaturealg", NULL); - TLSCertificate *cert = tlscerts_new(fingerprint, version, serialnumber, subjectname, issuername, notbefore, - notafter, keyalg, signaturealg); + TLSCertificate* cert = tlscerts_new(fingerprint, version, serialnumber, subjectname, issuername, notbefore, + notafter, keyalg, signaturealg); free(fingerprint); free(serialnumber); @@ -152,11 +152,11 @@ tlscerts_list(void) } TLSCertificate* -tlscerts_new(const char *const fingerprint, int version, const char *const serialnumber, const char *const subjectname, - const char *const issuername, const char *const notbefore, const char *const notafter, - const char *const key_alg, const char *const signature_alg) +tlscerts_new(const char* const fingerprint, int version, const char* const serialnumber, const char* const subjectname, + const char* const issuername, const char* const notbefore, const char* const notafter, + const char* const key_alg, const char* const signature_alg) { - TLSCertificate *cert = malloc(sizeof(TLSCertificate)); + TLSCertificate* cert = malloc(sizeof(TLSCertificate)); if (fingerprint) { cert->fingerprint = strdup(fingerprint); @@ -287,7 +287,7 @@ tlscerts_new(const char *const fingerprint, int version, const char *const seria } void -tlscerts_add(TLSCertificate *cert) +tlscerts_add(TLSCertificate* cert) { if (!cert) { return; @@ -326,9 +326,9 @@ tlscerts_add(TLSCertificate *cert) } gboolean -tlscerts_revoke(const char *const fingerprint) +tlscerts_revoke(const char* const fingerprint) { - gboolean result = g_key_file_remove_group(tlscerts, fingerprint, NULL); + gboolean result = g_key_file_remove_group(tlscerts, fingerprint, NULL); if (result) { autocomplete_remove(certs_ac, fingerprint); } @@ -339,23 +339,23 @@ tlscerts_revoke(const char *const fingerprint) } TLSCertificate* -tlscerts_get_trusted(const char * const fingerprint) +tlscerts_get_trusted(const char* const fingerprint) { if (!g_key_file_has_group(tlscerts, fingerprint)) { return NULL; } int version = g_key_file_get_integer(tlscerts, fingerprint, "version", NULL); - char *serialnumber = g_key_file_get_string(tlscerts, fingerprint, "serialnumber", NULL); - char *subjectname = g_key_file_get_string(tlscerts, fingerprint, "subjectname", NULL); - char *issuername = g_key_file_get_string(tlscerts, fingerprint, "issuername", NULL); - char *notbefore = g_key_file_get_string(tlscerts, fingerprint, "start", NULL); - char *notafter = g_key_file_get_string(tlscerts, fingerprint, "end", NULL); - char *keyalg = g_key_file_get_string(tlscerts, fingerprint, "keyalg", NULL); - char *signaturealg = g_key_file_get_string(tlscerts, fingerprint, "signaturealg", NULL); + char* serialnumber = g_key_file_get_string(tlscerts, fingerprint, "serialnumber", NULL); + char* subjectname = g_key_file_get_string(tlscerts, fingerprint, "subjectname", NULL); + char* issuername = g_key_file_get_string(tlscerts, fingerprint, "issuername", NULL); + char* notbefore = g_key_file_get_string(tlscerts, fingerprint, "start", NULL); + char* notafter = g_key_file_get_string(tlscerts, fingerprint, "end", NULL); + char* keyalg = g_key_file_get_string(tlscerts, fingerprint, "keyalg", NULL); + char* signaturealg = g_key_file_get_string(tlscerts, fingerprint, "signaturealg", NULL); - TLSCertificate *cert = tlscerts_new(fingerprint, version, serialnumber, subjectname, issuername, notbefore, - notafter, keyalg, signaturealg); + TLSCertificate* cert = tlscerts_new(fingerprint, version, serialnumber, subjectname, issuername, notbefore, + notafter, keyalg, signaturealg); free(serialnumber); free(subjectname); @@ -369,7 +369,7 @@ tlscerts_get_trusted(const char * const fingerprint) } char* -tlscerts_complete(const char *const prefix, gboolean previous, void *context) +tlscerts_complete(const char* const prefix, gboolean previous, void* context) { return autocomplete_complete(certs_ac, prefix, TRUE, previous); } @@ -381,7 +381,7 @@ tlscerts_reset_ac(void) } void -tlscerts_free(TLSCertificate *cert) +tlscerts_free(TLSCertificate* cert) { if (cert) { free(cert->serialnumber); @@ -433,7 +433,7 @@ static void _save_tlscerts(void) { gsize g_data_size; - gchar *g_tlscerts_data = g_key_file_to_data(tlscerts, &g_data_size, NULL); + gchar* g_tlscerts_data = g_key_file_to_data(tlscerts, &g_data_size, NULL); g_file_set_contents(tlscerts_loc, g_tlscerts_data, g_data_size, NULL); g_chmod(tlscerts_loc, S_IRUSR | S_IWUSR); g_free(g_tlscerts_data); diff --git a/src/config/tlscerts.h b/src/config/tlscerts.h index 920a8fce..ba3b6894 100644 --- a/src/config/tlscerts.h +++ b/src/config/tlscerts.h @@ -38,59 +38,60 @@ #include <glib.h> -typedef struct tls_cert_t { +typedef struct tls_cert_t +{ int version; - char *serialnumber; - char *subjectname; - char *subject_country; - char *subject_state; - char *subject_distinguishedname; - char *subject_serialnumber; - char *subject_commonname; - char *subject_organisation; - char *subject_organisation_unit; - char *subject_email; - char *issuername; - char *issuer_country; - char *issuer_state; - char *issuer_distinguishedname; - char *issuer_serialnumber; - char *issuer_commonname; - char *issuer_organisation; - char *issuer_organisation_unit; - char *issuer_email; - char *notbefore; - char *notafter; - char *fingerprint; - char *key_alg; - char *signature_alg; + char* serialnumber; + char* subjectname; + char* subject_country; + char* subject_state; + char* subject_distinguishedname; + char* subject_serialnumber; + char* subject_commonname; + char* subject_organisation; + char* subject_organisation_unit; + char* subject_email; + char* issuername; + char* issuer_country; + char* issuer_state; + char* issuer_distinguishedname; + char* issuer_serialnumber; + char* issuer_commonname; + char* issuer_organisation; + char* issuer_organisation_unit; + char* issuer_email; + char* notbefore; + char* notafter; + char* fingerprint; + char* key_alg; + char* signature_alg; } TLSCertificate; void tlscerts_init(void); -TLSCertificate* tlscerts_new(const char *const fingerprint, int version, const char *const serialnumber, const char *const subjectname, - const char *const issuername, const char *const notbefore, const char *const notafter, - const char *const key_alg, const char *const signature_alg); +TLSCertificate* tlscerts_new(const char* const fingerprint, int version, const char* const serialnumber, const char* const subjectname, + const char* const issuername, const char* const notbefore, const char* const notafter, + const char* const key_alg, const char* const signature_alg); -void tlscerts_set_current(const char *const fp); +void tlscerts_set_current(const char* const fp); char* tlscerts_get_current(void); void tlscerts_clear_current(void); -gboolean tlscerts_exists(const char *const fingerprint); +gboolean tlscerts_exists(const char* const fingerprint); -void tlscerts_add(TLSCertificate *cert); +void tlscerts_add(TLSCertificate* cert); -gboolean tlscerts_revoke(const char *const fingerprint); +gboolean tlscerts_revoke(const char* const fingerprint); -TLSCertificate* tlscerts_get_trusted(const char *const fingerprint); +TLSCertificate* tlscerts_get_trusted(const char* const fingerprint); -void tlscerts_free(TLSCertificate *cert); +void tlscerts_free(TLSCertificate* cert); GList* tlscerts_list(void); -char* tlscerts_complete(const char *const prefix, gboolean previous, void *context); +char* tlscerts_complete(const char* const prefix, gboolean previous, void* context); void tlscerts_reset_ac(void); diff --git a/src/database.c b/src/database.c index 3337e8df..45112d50 100644 --- a/src/database.c +++ b/src/database.c @@ -47,20 +47,20 @@ #include "common.h" #include "config/files.h" -static sqlite3 *g_chatlog_database; +static sqlite3* g_chatlog_database; -static void _add_to_db(ProfMessage *message, char *type, const Jid * const from_jid, const Jid * const to_jid); -static char* _get_db_filename(ProfAccount *account); -static prof_msg_type_t _get_message_type_type(const char *const type); +static void _add_to_db(ProfMessage* message, char* type, const Jid* const from_jid, const Jid* const to_jid); +static char* _get_db_filename(ProfAccount* account); +static prof_msg_type_t _get_message_type_type(const char* const type); static char* -_get_db_filename(ProfAccount *account) +_get_db_filename(ProfAccount* account) { - gchar *database_dir = files_get_account_data_path(DIR_DATABASE, account->jid); + gchar* database_dir = files_get_account_data_path(DIR_DATABASE, account->jid); int res = g_mkdir_with_parents(database_dir, S_IRWXU); if (res == -1) { - char *errmsg = strerror(errno); + char* errmsg = strerror(errno); if (errmsg) { log_error("DATABASE: error creating directory: %s, %s", database_dir, errmsg); } else { @@ -70,9 +70,9 @@ _get_db_filename(ProfAccount *account) return NULL; } - GString *chatlog_filename = g_string_new(database_dir); + GString* chatlog_filename = g_string_new(database_dir); g_string_append(chatlog_filename, "/chatlog.db"); - gchar *result = g_strdup(chatlog_filename->str); + gchar* result = g_strdup(chatlog_filename->str); g_string_free(chatlog_filename, TRUE); g_free(database_dir); @@ -80,7 +80,7 @@ _get_db_filename(ProfAccount *account) } gboolean -log_database_init(ProfAccount *account) +log_database_init(ProfAccount* account) { int ret = sqlite3_initialize(); if (ret != SQLITE_OK) { @@ -88,20 +88,20 @@ log_database_init(ProfAccount *account) return FALSE; } - char *filename = _get_db_filename(account); + char* filename = _get_db_filename(account); if (!filename) { return FALSE; } ret = sqlite3_open(filename, &g_chatlog_database); if (ret != SQLITE_OK) { - const char *err_msg = sqlite3_errmsg(g_chatlog_database); + const char* err_msg = sqlite3_errmsg(g_chatlog_database); log_error("Error opening SQLite database: %s", err_msg); free(filename); return FALSE; } - char *err_msg; + char* err_msg; // id is the ID of DB the entry // from_jid is the senders jid // to_jid is the receivers jid @@ -115,18 +115,18 @@ log_database_init(ProfAccount *account) // replace_id is the ID from XEP-0308: Last Message Correction // encryption is to distinguish: none, omemo, otr, pgp // marked_read is 0/1 whether a message has been marked as read via XEP-0333: Chat Markers - char *query = "CREATE TABLE IF NOT EXISTS `ChatLogs` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `from_jid` TEXT NOT NULL, `to_jid` TEXT NOT NULL, `from_resource` TEXT, `to_resource` TEXT, `message` TEXT, `timestamp` TEXT, `type` TEXT, `stanza_id` TEXT, `archive_id` TEXT, `replace_id` TEXT, `encryption` TEXT, `marked_read` INTEGER)"; - if( SQLITE_OK != sqlite3_exec(g_chatlog_database, query, NULL, 0, &err_msg)) { + char* query = "CREATE TABLE IF NOT EXISTS `ChatLogs` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `from_jid` TEXT NOT NULL, `to_jid` TEXT NOT NULL, `from_resource` TEXT, `to_resource` TEXT, `message` TEXT, `timestamp` TEXT, `type` TEXT, `stanza_id` TEXT, `archive_id` TEXT, `replace_id` TEXT, `encryption` TEXT, `marked_read` INTEGER)"; + if (SQLITE_OK != sqlite3_exec(g_chatlog_database, query, NULL, 0, &err_msg)) { goto out; } query = "CREATE TABLE IF NOT EXISTS `DbVersion` ( `dv_id` INTEGER PRIMARY KEY, `version` INTEGER UNIQUE)"; - if( SQLITE_OK != sqlite3_exec(g_chatlog_database, query, NULL, 0, &err_msg)) { + if (SQLITE_OK != sqlite3_exec(g_chatlog_database, query, NULL, 0, &err_msg)) { goto out; } query = "INSERT OR IGNORE INTO `DbVersion` (`version`) VALUES('1')"; - if( SQLITE_OK != sqlite3_exec(g_chatlog_database, query, NULL, 0, &err_msg)) { + if (SQLITE_OK != sqlite3_exec(g_chatlog_database, query, NULL, 0, &err_msg)) { goto out; } @@ -156,13 +156,13 @@ log_database_close(void) } void -log_database_add_incoming(ProfMessage *message) +log_database_add_incoming(ProfMessage* message) { if (message->to_jid) { _add_to_db(message, NULL, message->from_jid, message->to_jid); } else { - const char *jid = connection_get_fulljid(); - Jid *myjid = jid_create(jid); + const char* jid = connection_get_fulljid(); + Jid* myjid = jid_create(jid); _add_to_db(message, NULL, message->from_jid, myjid); @@ -171,9 +171,9 @@ log_database_add_incoming(ProfMessage *message) } static void -_log_database_add_outgoing(char *type, const char * const id, const char * const barejid, const char * const message, const char *const replace_id, prof_enc_t enc) +_log_database_add_outgoing(char* type, const char* const id, const char* const barejid, const char* const message, const char* const replace_id, prof_enc_t enc) { - ProfMessage *msg = message_init(); + ProfMessage* msg = message_init(); msg->id = id ? strdup(id) : NULL; msg->from_jid = jid_create(barejid); @@ -182,8 +182,8 @@ _log_database_add_outgoing(char *type, const char * const id, const char * const msg->timestamp = g_date_time_new_now_local(); //TODO: get from outside. best to have whole ProfMessage from outside msg->enc = enc; - const char *jid = connection_get_fulljid(); - Jid *myjid = jid_create(jid); + const char* jid = connection_get_fulljid(); + Jid* myjid = jid_create(jid); _add_to_db(msg, type, myjid, msg->from_jid); // TODO: myjid now in profmessage @@ -192,30 +192,30 @@ _log_database_add_outgoing(char *type, const char * const id, const char * const } void -log_database_add_outgoing_chat(const char * const id, const char * const barejid, const char * const message, const char *const replace_id, prof_enc_t enc) +log_database_add_outgoing_chat(const char* const id, const char* const barejid, const char* const message, const char* const replace_id, prof_enc_t enc) { _log_database_add_outgoing("chat", id, barejid, message, replace_id, enc); } void -log_database_add_outgoing_muc(const char * const id, const char * const barejid, const char * const message, const char *const replace_id, prof_enc_t enc) +log_database_add_outgoing_muc(const char* const id, const char* const barejid, const char* const message, const char* const replace_id, prof_enc_t enc) { _log_database_add_outgoing("muc", id, barejid, message, replace_id, enc); } void -log_database_add_outgoing_muc_pm(const char * const id, const char * const barejid, const char * const message, const char *const replace_id, prof_enc_t enc) +log_database_add_outgoing_muc_pm(const char* const id, const char* const barejid, const char* const message, const char* const replace_id, prof_enc_t enc) { _log_database_add_outgoing("mucpm", id, barejid, message, replace_id, enc); } GSList* -log_database_get_previous_chat(const gchar *const contact_barejid) +log_database_get_previous_chat(const gchar* const contact_barejid) { - sqlite3_stmt *stmt = NULL; - char *query; - const char *jid = connection_get_fulljid(); - Jid *myjid = jid_create(jid); + sqlite3_stmt* stmt = NULL; + char* query; + const char* jid = connection_get_fulljid(); + Jid* myjid = jid_create(jid); if (asprintf(&query, "SELECT * FROM (SELECT `message`, `timestamp`, `from_jid`, `type` from `ChatLogs` WHERE (`from_jid` = '%s' AND `to_jid` = '%s') OR (`from_jid` = '%s' AND `to_jid` = '%s') ORDER BY `timestamp` DESC LIMIT 10) ORDER BY `timestamp` ASC;", contact_barejid, myjid->barejid, myjid->barejid, contact_barejid) == -1) { log_error("log_database_get_previous_chat(): SQL query. could not allocate memory"); @@ -224,22 +224,22 @@ log_database_get_previous_chat(const gchar *const contact_barejid) jid_destroy(myjid); - int rc = sqlite3_prepare_v2(g_chatlog_database, query, -1, &stmt, NULL); - if( rc!=SQLITE_OK ) { + int rc = sqlite3_prepare_v2(g_chatlog_database, query, -1, &stmt, NULL); + if (rc != SQLITE_OK) { log_error("log_database_get_previous_chat(): unknown SQLite error"); return NULL; } - GSList *history = NULL; + GSList* history = NULL; - while( sqlite3_step(stmt) == SQLITE_ROW ) { + while (sqlite3_step(stmt) == SQLITE_ROW) { // TODO: also save to jid. since now part of profmessage - char *message = (char*)sqlite3_column_text(stmt, 0); - char *date = (char*)sqlite3_column_text(stmt, 1); - char *from = (char*)sqlite3_column_text(stmt, 2); - char *type = (char*)sqlite3_column_text(stmt, 3); + char* message = (char*)sqlite3_column_text(stmt, 0); + char* date = (char*)sqlite3_column_text(stmt, 1); + char* from = (char*)sqlite3_column_text(stmt, 2); + char* type = (char*)sqlite3_column_text(stmt, 3); - ProfMessage *msg = message_init(); + ProfMessage* msg = message_init(); msg->from_jid = jid_create(from); msg->plain = strdup(message); msg->timestamp = g_date_time_new_from_iso8601(date, NULL); @@ -247,14 +247,16 @@ log_database_get_previous_chat(const gchar *const contact_barejid) // TODO: later we can get more fields like 'enc'. then we can display the history like regular chats with all info the user enabled. history = g_slist_append(history, msg); - } - sqlite3_finalize(stmt); + } + sqlite3_finalize(stmt); free(query); return history; } -static const char* _get_message_type_str(prof_msg_type_t type) { +static const char* +_get_message_type_str(prof_msg_type_t type) +{ switch (type) { case PROF_MSG_TYPE_CHAT: return "chat"; @@ -268,7 +270,9 @@ static const char* _get_message_type_str(prof_msg_type_t type) { return NULL; } -static prof_msg_type_t _get_message_type_type(const char *const type) { +static prof_msg_type_t +_get_message_type_type(const char* const type) +{ if (g_strcmp0(type, "chat") == 0) { return PROF_MSG_TYPE_CHAT; } else if (g_strcmp0(type, "muc") == 0) { @@ -280,7 +284,9 @@ static prof_msg_type_t _get_message_type_type(const char *const type) { } } -static const char* _get_message_enc_str(prof_enc_t enc) { +static const char* +_get_message_enc_str(prof_enc_t enc) +{ switch (enc) { case PROF_MSG_ENC_OX: return "ox"; @@ -298,55 +304,56 @@ static const char* _get_message_enc_str(prof_enc_t enc) { } static void -_add_to_db(ProfMessage *message, char *type, const Jid * const from_jid, const Jid * const to_jid) +_add_to_db(ProfMessage* message, char* type, const Jid* const from_jid, const Jid* const to_jid) { if (!g_chatlog_database) { log_debug("log_database_add() called but db is not initialized"); return; } - char *err_msg; - char *query; - gchar *date_fmt; + char* err_msg; + char* query; + gchar* date_fmt; if (message->timestamp) { // g_date_time_format_iso8601() is only availble from glib 2.62 on. // To still support Debian buster lets use g_date_time_format() for now. //date_fmt = g_date_time_format_iso8601(message->timestamp); - date_fmt = g_date_time_format(message->timestamp,"%FT%T%:::z"); + date_fmt = g_date_time_format(message->timestamp, "%FT%T%:::z"); } else { // g_date_time_format_iso8601() is only availble from glib 2.62 on. // To still support Debian buster lets use g_date_time_format() for now. //date_fmt = g_date_time_format_iso8601(g_date_time_new_now_local()); - date_fmt = g_date_time_format(g_date_time_new_now_local(), "%FT%T%:::z" ); + date_fmt = g_date_time_format(g_date_time_new_now_local(), "%FT%T%:::z"); } - const char *enc = _get_message_enc_str(message->enc); + const char* enc = _get_message_enc_str(message->enc); if (!type) { type = (char*)_get_message_type_str(message->type); } - char *escaped_message = str_replace(message->plain, "'", "''"); + char* escaped_message = str_replace(message->plain, "'", "''"); if (asprintf(&query, "INSERT INTO `ChatLogs` (`from_jid`, `from_resource`, `to_jid`, `to_resource`, `message`, `timestamp`, `stanza_id`, `replace_id`, `type`, `encryption`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", - from_jid->barejid, - from_jid->resourcepart ? from_jid->resourcepart : "", - to_jid->barejid, - to_jid->resourcepart ? to_jid->resourcepart : "", - escaped_message, - date_fmt, - message->id ? message->id : "", - message->replace_id ? message->replace_id : "", - type, - enc) == -1) { + from_jid->barejid, + from_jid->resourcepart ? from_jid->resourcepart : "", + to_jid->barejid, + to_jid->resourcepart ? to_jid->resourcepart : "", + escaped_message, + date_fmt, + message->id ? message->id : "", + message->replace_id ? message->replace_id : "", + type, + enc) + == -1) { log_error("log_database_add(): SQL query. could not allocate memory"); return; } free(escaped_message); g_free(date_fmt); - if( SQLITE_OK != sqlite3_exec(g_chatlog_database, query, NULL, 0, &err_msg)) { + if (SQLITE_OK != sqlite3_exec(g_chatlog_database, query, NULL, 0, &err_msg)) { if (err_msg) { log_error("SQLite error: %s", err_msg); sqlite3_free(err_msg); diff --git a/src/database.h b/src/database.h index 4ad3fc9c..3c1e4f99 100644 --- a/src/database.h +++ b/src/database.h @@ -40,13 +40,12 @@ #include "config/account.h" #include "xmpp/xmpp.h" -gboolean log_database_init(ProfAccount *account); -void log_database_add_incoming(ProfMessage *message); -void log_database_add_outgoing_chat(const char * const id, const char * const barejid, const char * const message, const char *const replace_id, prof_enc_t enc); -void log_database_add_outgoing_muc(const char * const id, const char * const barejid, const char * const message, const char *const replace_id, prof_enc_t enc); -void log_database_add_outgoing_muc_pm(const char * const id, const char * const barejid, const char * const message, const char *const replace_id, prof_enc_t enc); -GSList* log_database_get_previous_chat(const gchar *const contact_barejid); +gboolean log_database_init(ProfAccount* account); +void log_database_add_incoming(ProfMessage* message); +void log_database_add_outgoing_chat(const char* const id, const char* const barejid, const char* const message, const char* const replace_id, prof_enc_t enc); +void log_database_add_outgoing_muc(const char* const id, const char* const barejid, const char* const message, const char* const replace_id, prof_enc_t enc); +void log_database_add_outgoing_muc_pm(const char* const id, const char* const barejid, const char* const message, const char* const replace_id, prof_enc_t enc); +GSList* log_database_get_previous_chat(const gchar* const contact_barejid); void log_database_close(void); #endif // DATABASE_H - diff --git a/src/event/client_events.c b/src/event/client_events.c index 15261760..046c6607 100644 --- a/src/event/client_events.c +++ b/src/event/client_events.c @@ -61,14 +61,14 @@ #endif jabber_conn_status_t -cl_ev_connect_jid(const char *const jid, const char *const passwd, const char *const altdomain, const int port, const char *const tls_policy, const char *const auth_policy) +cl_ev_connect_jid(const char* const jid, const char* const passwd, const char* const altdomain, const int port, const char* const tls_policy, const char* const auth_policy) { cons_show("Connecting as %s", jid); return session_connect_with_details(jid, passwd, altdomain, port, tls_policy, auth_policy); } jabber_conn_status_t -cl_ev_connect_account(ProfAccount *account) +cl_ev_connect_account(ProfAccount* account) { if (account->resource) { cons_show("Connecting with account %s as %s/%s", account->name, account->jid, account->resource); @@ -84,7 +84,7 @@ cl_ev_connect_account(ProfAccount *account) void cl_ev_disconnect(void) { - char *mybarejid = connection_get_barejid(); + char* mybarejid = connection_get_barejid(); cons_show("%s logged out successfully.", mybarejid); free(mybarejid); @@ -97,13 +97,13 @@ cl_ev_disconnect(void) void cl_ev_presence_send(const resource_presence_t presence_type, const int idle_secs) { - char *signed_status = NULL; + char* signed_status = NULL; #ifdef HAVE_LIBGPGME - char *account_name = session_get_account_name(); - ProfAccount *account = accounts_get_account(account_name); + char* account_name = session_get_account_name(); + ProfAccount* account = accounts_get_account(account_name); if (account->pgp_keyid) { - char *msg = connection_get_presence_msg(); + char* msg = connection_get_presence_msg(); signed_status = p_gpg_sign(msg, account->pgp_keyid); } account_free(account); @@ -115,25 +115,25 @@ cl_ev_presence_send(const resource_presence_t presence_type, const int idle_secs } void -cl_ev_send_msg_correct(ProfChatWin *chatwin, const char *const msg, const char *const oob_url, gboolean correct_last_msg) +cl_ev_send_msg_correct(ProfChatWin* chatwin, const char* const msg, const char* const oob_url, gboolean correct_last_msg) { chat_state_active(chatwin->state); gboolean request_receipt = prefs_get_boolean(PREF_RECEIPTS_REQUEST); - char *plugin_msg = plugins_pre_chat_message_send(chatwin->barejid, msg); + char* plugin_msg = plugins_pre_chat_message_send(chatwin->barejid, msg); if (plugin_msg == NULL) { return; } - char *replace_id = NULL; + char* replace_id = NULL; if (correct_last_msg) { replace_id = chatwin->last_msg_id; } if (chatwin->is_omemo) { #ifdef HAVE_OMEMO - char *id = omemo_on_message_send((ProfWin *)chatwin, plugin_msg, request_receipt, FALSE, replace_id); + char* id = omemo_on_message_send((ProfWin*)chatwin, plugin_msg, request_receipt, FALSE, replace_id); chat_log_omemo_msg_out(chatwin->barejid, plugin_msg, NULL); log_database_add_outgoing_chat(id, chatwin->barejid, plugin_msg, replace_id, PROF_MSG_ENC_OMEMO); chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_OMEMO, request_receipt, replace_id); @@ -142,7 +142,7 @@ cl_ev_send_msg_correct(ProfChatWin *chatwin, const char *const msg, const char * } else if (chatwin->is_ox) { #ifdef HAVE_LIBGPGME // XEP-0373: OpenPGP for XMPP - char *id = message_send_chat_ox(chatwin->barejid, plugin_msg, request_receipt, replace_id); + char* id = message_send_chat_ox(chatwin->barejid, plugin_msg, request_receipt, replace_id); chat_log_pgp_msg_out(chatwin->barejid, plugin_msg, NULL); log_database_add_outgoing_chat(id, chatwin->barejid, plugin_msg, replace_id, PROF_MSG_ENC_OX); chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_OX, request_receipt, replace_id); @@ -150,7 +150,7 @@ cl_ev_send_msg_correct(ProfChatWin *chatwin, const char *const msg, const char * #endif } else if (chatwin->pgp_send) { #ifdef HAVE_LIBGPGME - char *id = message_send_chat_pgp(chatwin->barejid, plugin_msg, request_receipt, replace_id); + char* id = message_send_chat_pgp(chatwin->barejid, plugin_msg, request_receipt, replace_id); chat_log_pgp_msg_out(chatwin->barejid, plugin_msg, NULL); log_database_add_outgoing_chat(id, chatwin->barejid, plugin_msg, replace_id, PROF_MSG_ENC_PGP); chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_PGP, request_receipt, replace_id); @@ -159,10 +159,10 @@ cl_ev_send_msg_correct(ProfChatWin *chatwin, const char *const msg, const char * } else { gboolean handled = FALSE; #ifdef HAVE_LIBOTR - handled = otr_on_message_send(chatwin, plugin_msg, request_receipt, replace_id); + handled = otr_on_message_send(chatwin, plugin_msg, request_receipt, replace_id); #endif if (!handled) { - char *id = message_send_chat(chatwin->barejid, plugin_msg, oob_url, request_receipt, replace_id); + char* id = message_send_chat(chatwin->barejid, plugin_msg, oob_url, request_receipt, replace_id); chat_log_msg_out(chatwin->barejid, plugin_msg, NULL); log_database_add_outgoing_chat(id, chatwin->barejid, plugin_msg, replace_id, PROF_MSG_ENC_NONE); chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_NONE, request_receipt, replace_id); @@ -176,33 +176,33 @@ cl_ev_send_msg_correct(ProfChatWin *chatwin, const char *const msg, const char * } void -cl_ev_send_msg(ProfChatWin *chatwin, const char *const msg, const char *const oob_url) +cl_ev_send_msg(ProfChatWin* chatwin, const char* const msg, const char* const oob_url) { cl_ev_send_msg_correct(chatwin, msg, oob_url, FALSE); } void -cl_ev_send_muc_msg_corrected(ProfMucWin *mucwin, const char *const msg, const char *const oob_url, gboolean correct_last_msg) +cl_ev_send_muc_msg_corrected(ProfMucWin* mucwin, const char* const msg, const char* const oob_url, gboolean correct_last_msg) { - char *plugin_msg = plugins_pre_room_message_send(mucwin->roomjid, msg); + char* plugin_msg = plugins_pre_room_message_send(mucwin->roomjid, msg); if (plugin_msg == NULL) { return; } - char *replace_id = NULL; + char* replace_id = NULL; if (correct_last_msg) { replace_id = mucwin->last_msg_id; } #ifdef HAVE_OMEMO if (mucwin->is_omemo) { - char *id = omemo_on_message_send((ProfWin *)mucwin, plugin_msg, FALSE, TRUE, replace_id); + char* id = omemo_on_message_send((ProfWin*)mucwin, plugin_msg, FALSE, TRUE, replace_id); groupchat_log_omemo_msg_out(mucwin->roomjid, plugin_msg); log_database_add_outgoing_muc(id, mucwin->roomjid, plugin_msg, replace_id, PROF_MSG_ENC_OMEMO); mucwin_outgoing_msg(mucwin, plugin_msg, id, PROF_MSG_ENC_OMEMO, replace_id); free(id); } else { - char *id = message_send_groupchat(mucwin->roomjid, plugin_msg, oob_url, replace_id); + char* id = message_send_groupchat(mucwin->roomjid, plugin_msg, oob_url, replace_id); groupchat_log_msg_out(mucwin->roomjid, plugin_msg); log_database_add_outgoing_muc(id, mucwin->roomjid, plugin_msg, replace_id, PROF_MSG_ENC_NONE); mucwin_outgoing_msg(mucwin, plugin_msg, id, PROF_MSG_ENC_NONE, replace_id); @@ -215,7 +215,7 @@ cl_ev_send_muc_msg_corrected(ProfMucWin *mucwin, const char *const msg, const ch #endif #ifndef HAVE_OMEMO - char *id = message_send_groupchat(mucwin->roomjid, plugin_msg, oob_url, replace_id); + char* id = message_send_groupchat(mucwin->roomjid, plugin_msg, oob_url, replace_id); groupchat_log_msg_out(mucwin->roomjid, plugin_msg); log_database_add_outgoing_muc(id, mucwin->roomjid, plugin_msg, replace_id, PROF_MSG_ENC_NONE); mucwin_outgoing_msg(mucwin, plugin_msg, id, PROF_MSG_ENC_NONE, replace_id); @@ -228,23 +228,23 @@ cl_ev_send_muc_msg_corrected(ProfMucWin *mucwin, const char *const msg, const ch } void -cl_ev_send_muc_msg(ProfMucWin *mucwin, const char *const msg, const char *const oob_url) +cl_ev_send_muc_msg(ProfMucWin* mucwin, const char* const msg, const char* const oob_url) { cl_ev_send_muc_msg_corrected(mucwin, msg, oob_url, FALSE); } void -cl_ev_send_priv_msg(ProfPrivateWin *privwin, const char *const msg, const char *const oob_url) +cl_ev_send_priv_msg(ProfPrivateWin* privwin, const char* const msg, const char* const oob_url) { if (privwin->occupant_offline) { privwin_message_occupant_offline(privwin); } else if (privwin->room_left) { privwin_message_left_room(privwin); } else { - char *plugin_msg = plugins_pre_priv_message_send(privwin->fulljid, msg); - Jid *jidp = jid_create(privwin->fulljid); + char* plugin_msg = plugins_pre_priv_message_send(privwin->fulljid, msg); + Jid* jidp = jid_create(privwin->fulljid); - char *id = message_send_private(privwin->fulljid, plugin_msg, oob_url); + char* id = message_send_private(privwin->fulljid, plugin_msg, oob_url); chat_log_msg_out(jidp->barejid, plugin_msg, jidp->resourcepart); log_database_add_outgoing_muc_pm(id, privwin->fulljid, plugin_msg, NULL, PROF_MSG_ENC_NONE); privwin_outgoing_msg(privwin, plugin_msg); diff --git a/src/event/client_events.h b/src/event/client_events.h index 3c0da3d9..fed2bb37 100644 --- a/src/event/client_events.h +++ b/src/event/client_events.h @@ -38,17 +38,17 @@ #include "xmpp/xmpp.h" -jabber_conn_status_t cl_ev_connect_jid(const char *const jid, const char *const passwd, const char *const altdomain, const int port, const char *const tls_policy, const char *const auth_policy); -jabber_conn_status_t cl_ev_connect_account(ProfAccount *account); +jabber_conn_status_t cl_ev_connect_jid(const char* const jid, const char* const passwd, const char* const altdomain, const int port, const char* const tls_policy, const char* const auth_policy); +jabber_conn_status_t cl_ev_connect_account(ProfAccount* account); void cl_ev_disconnect(void); void cl_ev_presence_send(const resource_presence_t presence_type, const int idle_secs); -void cl_ev_send_msg_correct(ProfChatWin *chatwin, const char *const msg, const char *const oob_url, gboolean correct_last_msg); -void cl_ev_send_msg(ProfChatWin *chatwin, const char *const msg, const char *const oob_url); -void cl_ev_send_muc_msg_corrected(ProfMucWin *mucwin, const char *const msg, const char *const oob_url, gboolean correct_last_msg); -void cl_ev_send_muc_msg(ProfMucWin *mucwin, const char *const msg, const char *const oob_url); -void cl_ev_send_priv_msg(ProfPrivateWin *privwin, const char *const msg, const char *const oob_url); +void cl_ev_send_msg_correct(ProfChatWin* chatwin, const char* const msg, const char* const oob_url, gboolean correct_last_msg); +void cl_ev_send_msg(ProfChatWin* chatwin, const char* const msg, const char* const oob_url); +void cl_ev_send_muc_msg_corrected(ProfMucWin* mucwin, const char* const msg, const char* const oob_url, gboolean correct_last_msg); +void cl_ev_send_muc_msg(ProfMucWin* mucwin, const char* const msg, const char* const oob_url); +void cl_ev_send_priv_msg(ProfPrivateWin* privwin, const char* const msg, const char* const oob_url); #endif diff --git a/src/event/server_events.c b/src/event/server_events.c index 303f4fc7..27357683 100644 --- a/src/event/server_events.c +++ b/src/event/server_events.c @@ -72,13 +72,13 @@ #include "ui/ui.h" -static void _clean_incoming_message(ProfMessage *message); -static void _sv_ev_incoming_plain(ProfChatWin *chatwin, gboolean new_win, ProfMessage *message, gboolean logit); +static void _clean_incoming_message(ProfMessage* message); +static void _sv_ev_incoming_plain(ProfChatWin* chatwin, gboolean new_win, ProfMessage* message, gboolean logit); void -sv_ev_login_account_success(char *account_name, gboolean secured) +sv_ev_login_account_success(char* account_name, gboolean secured) { - ProfAccount *account = accounts_get_account(account_name); + ProfAccount* account = accounts_get_account(account_name); bookmark_ignore_on_connect(account->jid); @@ -103,11 +103,11 @@ sv_ev_login_account_success(char *account_name, gboolean secured) ui_handle_login_account_success(account, secured); // attempt to rejoin all rooms - GList *rooms = muc_rooms(); - GList *curr = rooms; + GList* rooms = muc_rooms(); + GList* curr = rooms; while (curr) { - char *password = muc_password(curr->data); - char *nick = muc_nick(curr->data); + char* password = muc_password(curr->data); + char* nick = muc_nick(curr->data); presence_join_room(curr->data, nick, password); curr = g_list_next(curr); } @@ -116,8 +116,7 @@ sv_ev_login_account_success(char *account_name, gboolean secured) log_info("%s logged in successfully", account->jid); // if we have been connected before - if (ev_was_connected_already()) - { + if (ev_was_connected_already()) { cons_show("Connection re-established."); wins_reestablished_connection(); } @@ -140,21 +139,21 @@ sv_ev_roster_received(void) ui_show_roster(); } - char *account_name = session_get_account_name(); + char* account_name = session_get_account_name(); #ifdef HAVE_LIBGPGME // check pgp key valid if specified - ProfAccount *account = accounts_get_account(account_name); + ProfAccount* account = accounts_get_account(account_name); if (account && account->pgp_keyid) { - char *err_str = NULL; + char* err_str = NULL; if (!p_gpg_valid_key(account->pgp_keyid, &err_str)) { cons_show_error("Invalid PGP key ID specified: %s, %s", account->pgp_keyid, err_str); } free(err_str); // Redraw the screen after entry of the PGP secret key, but not init - ProfWin *win = wins_get_current(); - char *theme = prefs_get_string(PREF_THEME); + ProfWin* win = wins_get_current(); + char* theme = prefs_get_string(PREF_THEME); win_clear(win); theme_init(theme); g_free(theme); @@ -166,15 +165,15 @@ sv_ev_roster_received(void) // send initial presence resource_presence_t conn_presence = accounts_get_login_presence(account_name); - char *last_activity_str = accounts_get_last_activity(account_name); + char* last_activity_str = accounts_get_last_activity(account_name); if (prefs_get_boolean(PREF_LASTACTIVITY) && last_activity_str) { GTimeVal lasttv; - GDateTime *nowdt = g_date_time_new_now_utc(); + GDateTime* nowdt = g_date_time_new_now_utc(); gboolean res = g_time_val_from_iso8601(last_activity_str, &lasttv); if (res) { - GDateTime *lastdt = g_date_time_new_from_timeval_utc(&lasttv); + GDateTime* lastdt = g_date_time_new_from_timeval_utc(&lasttv); GTimeSpan diff_micros = g_date_time_difference(nowdt, lastdt); int diff_secs = (diff_micros / 1000) / 1000; @@ -194,7 +193,7 @@ sv_ev_roster_received(void) free(last_activity_str); - const char *fulljid = connection_get_fulljid(); + const char* fulljid = connection_get_fulljid(); plugins_on_connect(account_name, fulljid); #ifdef HAVE_OMEMO @@ -216,11 +215,11 @@ sv_ev_lost_connection(void) cons_show_error("Lost connection."); #ifdef HAVE_LIBOTR - GSList *recipients = wins_get_chat_recipients(); - GSList *curr = recipients; + GSList* recipients = wins_get_chat_recipients(); + GSList* curr = recipients; while (curr) { - char *barejid = curr->data; - ProfChatWin *chatwin = wins_get_chat(barejid); + char* barejid = curr->data; + ProfChatWin* chatwin = wins_get_chat(barejid); if (chatwin && otr_is_secure(barejid)) { chatwin_otr_unsecured(chatwin); otr_end_session(barejid); @@ -244,8 +243,8 @@ sv_ev_failed_login(void) } void -sv_ev_room_invite(jabber_invite_t invite_type, const char *const invitor, const char *const room, - const char *const reason, const char *const password) +sv_ev_room_invite(jabber_invite_t invite_type, const char* const invitor, const char* const room, + const char* const reason, const char* const password) { if (!muc_active(room) && !muc_invites_contain(room)) { cons_show_room_invite(invitor, room, reason); @@ -254,10 +253,10 @@ sv_ev_room_invite(jabber_invite_t invite_type, const char *const invitor, const } void -sv_ev_room_broadcast(const char *const room_jid, const char *const message) +sv_ev_room_broadcast(const char* const room_jid, const char* const message) { if (muc_roster_complete(room_jid)) { - ProfMucWin *mucwin = wins_get_muc(room_jid); + ProfMucWin* mucwin = wins_get_muc(room_jid); if (mucwin) { mucwin_broadcast(mucwin, message); } @@ -267,19 +266,19 @@ sv_ev_room_broadcast(const char *const room_jid, const char *const message) } void -sv_ev_room_subject(const char *const room, const char *const nick, const char *const subject) +sv_ev_room_subject(const char* const room, const char* const nick, const char* const subject) { muc_set_subject(room, subject); - ProfMucWin *mucwin = wins_get_muc(room); + ProfMucWin* mucwin = wins_get_muc(room); if (mucwin && muc_roster_complete(room) && ev_is_first_connect()) { mucwin_subject(mucwin, nick, subject); } } void -sv_ev_room_history(ProfMessage *message) +sv_ev_room_history(ProfMessage* message) { - ProfMucWin *mucwin = wins_get_muc(message->from_jid->barejid); + ProfMucWin* mucwin = wins_get_muc(message->from_jid->barejid); if (mucwin) { // if this is the first successful connection if (ev_is_first_connect()) { @@ -288,17 +287,18 @@ sv_ev_room_history(ProfMessage *message) if (mucwin->last_msg_timestamp) { g_date_time_unref(mucwin->last_msg_timestamp); } - mucwin->last_msg_timestamp = g_date_time_new_now_local(); + mucwin->last_msg_timestamp = g_date_time_new_now_local(); } gboolean younger = g_date_time_compare(mucwin->last_msg_timestamp, message->timestamp) < 0 ? TRUE : FALSE; - if (ev_is_first_connect() || younger ) { + if (ev_is_first_connect() || younger) { mucwin_history(mucwin, message); } } } -static void _log_muc(ProfMessage *message) +static void +_log_muc(ProfMessage* message) { if (message->enc == PROF_MSG_ENC_OMEMO) { groupchat_log_omemo_msg_in(message->from_jid->barejid, message->from_jid->resourcepart, message->plain); @@ -309,14 +309,14 @@ static void _log_muc(ProfMessage *message) } void -sv_ev_room_message(ProfMessage *message) +sv_ev_room_message(ProfMessage* message) { - ProfMucWin *mucwin = wins_get_muc(message->from_jid->barejid); + ProfMucWin* mucwin = wins_get_muc(message->from_jid->barejid); if (!mucwin) { return; } - char *mynick = muc_nick(mucwin->roomjid); + char* mynick = muc_nick(mucwin->roomjid); // only log message not coming from this client (but maybe same account, different client) // our messages are logged when outgoing @@ -324,19 +324,19 @@ sv_ev_room_message(ProfMessage *message) _log_muc(message); } - char *old_plain = message->plain; + char* old_plain = message->plain; message->plain = plugins_pre_room_message_display(message->from_jid->barejid, message->from_jid->resourcepart, message->plain); - GSList *mentions = get_mentions(prefs_get_boolean(PREF_NOTIFY_MENTION_WHOLE_WORD), prefs_get_boolean(PREF_NOTIFY_MENTION_CASE_SENSITIVE), message->plain, mynick); + GSList* mentions = get_mentions(prefs_get_boolean(PREF_NOTIFY_MENTION_WHOLE_WORD), prefs_get_boolean(PREF_NOTIFY_MENTION_CASE_SENSITIVE), message->plain, mynick); gboolean mention = g_slist_length(mentions) > 0; - GList *triggers = prefs_message_get_triggers(message->plain); + GList* triggers = prefs_message_get_triggers(message->plain); _clean_incoming_message(message); mucwin_incoming_msg(mucwin, message, mentions, triggers, TRUE); g_slist_free(mentions); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; int num = wins_get_num(window); gboolean is_current = FALSE; @@ -349,7 +349,7 @@ sv_ev_room_message(ProfMessage *message) beep(); } - // not currently on groupchat window + // not currently on groupchat window } else { status_bar_new(num, WIN_MUC, mucwin->roomjid); @@ -373,10 +373,10 @@ sv_ev_room_message(ProfMessage *message) if (mucwin->last_msg_timestamp) { g_date_time_unref(mucwin->last_msg_timestamp); } - mucwin->last_msg_timestamp = g_date_time_new_now_local(); + mucwin->last_msg_timestamp = g_date_time_new_now_local(); if (prefs_do_room_notify(is_current, mucwin->roomjid, mynick, message->from_jid->resourcepart, message->plain, mention, triggers != NULL)) { - Jid *jidp = jid_create(mucwin->roomjid); + Jid* jidp = jid_create(mucwin->roomjid); notify_room_message(message->from_jid->resourcepart, jidp->localpart, num, message->plain); jid_destroy(jidp); } @@ -393,14 +393,14 @@ sv_ev_room_message(ProfMessage *message) } void -sv_ev_incoming_private_message(ProfMessage *message) +sv_ev_incoming_private_message(ProfMessage* message) { - char *old_plain = message->plain; + char* old_plain = message->plain; message->plain = plugins_pre_priv_message_display(message->from_jid->fulljid, message->plain); - ProfPrivateWin *privatewin = wins_get_private(message->from_jid->fulljid); + ProfPrivateWin* privatewin = wins_get_private(message->from_jid->fulljid); if (privatewin == NULL) { - ProfWin *window = wins_new_private(message->from_jid->fulljid); + ProfWin* window = wins_new_private(message->from_jid->fulljid); privatewin = (ProfPrivateWin*)window; } @@ -417,14 +417,14 @@ sv_ev_incoming_private_message(ProfMessage *message) } void -sv_ev_delayed_private_message(ProfMessage *message) +sv_ev_delayed_private_message(ProfMessage* message) { - char *old_plain = message->plain; + char* old_plain = message->plain; message->plain = plugins_pre_priv_message_display(message->from_jid->fulljid, message->plain); - ProfPrivateWin *privatewin = wins_get_private(message->from_jid->fulljid); + ProfPrivateWin* privatewin = wins_get_private(message->from_jid->fulljid); if (privatewin == NULL) { - ProfWin *window = wins_new_private(message->from_jid->fulljid); + ProfWin* window = wins_new_private(message->from_jid->fulljid); privatewin = (ProfPrivateWin*)window; } @@ -439,9 +439,9 @@ sv_ev_delayed_private_message(ProfMessage *message) } void -sv_ev_outgoing_carbon(ProfMessage *message) +sv_ev_outgoing_carbon(ProfMessage* message) { - ProfChatWin *chatwin = wins_get_chat(message->to_jid->barejid); + ProfChatWin* chatwin = wins_get_chat(message->to_jid->barejid); if (!chatwin) { chatwin = chatwin_new(message->to_jid->barejid); } @@ -482,11 +482,10 @@ sv_ev_outgoing_carbon(ProfMessage *message) chatwin_outgoing_carbon(chatwin, message); } return; - } static void -_sv_ev_incoming_pgp(ProfChatWin *chatwin, gboolean new_win, ProfMessage *message, gboolean logit) +_sv_ev_incoming_pgp(ProfChatWin* chatwin, gboolean new_win, ProfMessage* message, gboolean logit) { #ifdef HAVE_LIBGPGME message->plain = p_gpg_decrypt(message->encrypted); @@ -518,23 +517,23 @@ _sv_ev_incoming_pgp(ProfChatWin *chatwin, gboolean new_win, ProfMessage *message } static void -_sv_ev_incoming_ox(ProfChatWin *chatwin, gboolean new_win, ProfMessage *message, gboolean logit) +_sv_ev_incoming_ox(ProfChatWin* chatwin, gboolean new_win, ProfMessage* message, gboolean logit) { #ifdef HAVE_LIBGPGME - //_clean_incoming_message(message); - chatwin_incoming_msg(chatwin, message, new_win); - log_database_add_incoming(message); - if (logit) { - chat_log_pgp_msg_in(message); - } - chatwin->pgp_recv = TRUE; - //p_gpg_free_decrypted(message->plain); - message->plain = NULL; + //_clean_incoming_message(message); + chatwin_incoming_msg(chatwin, message, new_win); + log_database_add_incoming(message); + if (logit) { + chat_log_pgp_msg_in(message); + } + chatwin->pgp_recv = TRUE; + //p_gpg_free_decrypted(message->plain); + message->plain = NULL; #endif } static void -_sv_ev_incoming_otr(ProfChatWin *chatwin, gboolean new_win, ProfMessage *message) +_sv_ev_incoming_otr(ProfChatWin* chatwin, gboolean new_win, ProfMessage* message) { #ifdef HAVE_LIBOTR gboolean decrypted = FALSE; @@ -557,12 +556,12 @@ _sv_ev_incoming_otr(ProfChatWin *chatwin, gboolean new_win, ProfMessage *message chatwin->pgp_recv = FALSE; } #else - _sv_ev_incoming_plain(chatwin, new_win, message, TRUE); + _sv_ev_incoming_plain(chatwin, new_win, message, TRUE); #endif } static void -_sv_ev_incoming_omemo(ProfChatWin *chatwin, gboolean new_win, ProfMessage *message, gboolean logit) +_sv_ev_incoming_omemo(ProfChatWin* chatwin, gboolean new_win, ProfMessage* message, gboolean logit) { #ifdef HAVE_OMEMO _clean_incoming_message(message); @@ -576,7 +575,7 @@ _sv_ev_incoming_omemo(ProfChatWin *chatwin, gboolean new_win, ProfMessage *messa } static void -_sv_ev_incoming_plain(ProfChatWin *chatwin, gboolean new_win, ProfMessage *message, gboolean logit) +_sv_ev_incoming_plain(ProfChatWin* chatwin, gboolean new_win, ProfMessage* message, gboolean logit) { if (message->body) { message->enc = PROF_MSG_ENC_NONE; @@ -592,14 +591,14 @@ _sv_ev_incoming_plain(ProfChatWin *chatwin, gboolean new_win, ProfMessage *messa } void -sv_ev_incoming_message(ProfMessage *message) +sv_ev_incoming_message(ProfMessage* message) { gboolean new_win = FALSE; - ProfChatWin *chatwin; - char *looking_for_jid = message->from_jid->barejid; + ProfChatWin* chatwin; + char* looking_for_jid = message->from_jid->barejid; if (message->is_mam) { - char *mybarejid = connection_get_barejid(); + char* mybarejid = connection_get_barejid(); if (g_strcmp0(mybarejid, message->from_jid->barejid) == 0) { looking_for_jid = message->to_jid->barejid; } @@ -609,7 +608,7 @@ sv_ev_incoming_message(ProfMessage *message) chatwin = wins_get_chat(looking_for_jid); if (!chatwin) { - ProfWin *window = wins_new_chat(looking_for_jid); + ProfWin* window = wins_new_chat(looking_for_jid); chatwin = (ProfChatWin*)window; new_win = TRUE; @@ -623,11 +622,11 @@ sv_ev_incoming_message(ProfMessage *message) #endif } - if( message->enc == PROF_MSG_ENC_OX) { + if (message->enc == PROF_MSG_ENC_OX) { _sv_ev_incoming_ox(chatwin, new_win, message, TRUE); - } else if (message->enc == PROF_MSG_ENC_OMEMO) { + } else if (message->enc == PROF_MSG_ENC_OMEMO) { _sv_ev_incoming_omemo(chatwin, new_win, message, TRUE); - } else if (message->encrypted) { + } else if (message->encrypted) { if (chatwin->is_otr) { win_println((ProfWin*)chatwin, THEME_DEFAULT, "-", "PGP encrypted message received whilst in OTR session."); } else { @@ -640,16 +639,15 @@ sv_ev_incoming_message(ProfMessage *message) rosterwin_roster(); return; - } void -sv_ev_incoming_carbon(ProfMessage *message) +sv_ev_incoming_carbon(ProfMessage* message) { gboolean new_win = FALSE; - ProfChatWin *chatwin = wins_get_chat(message->from_jid->barejid); + ProfChatWin* chatwin = wins_get_chat(message->from_jid->barejid); if (!chatwin) { - ProfWin *window = wins_new_chat(message->from_jid->barejid); + ProfWin* window = wins_new_chat(message->from_jid->barejid); chatwin = (ProfChatWin*)window; new_win = TRUE; @@ -672,13 +670,12 @@ sv_ev_incoming_carbon(ProfMessage *message) } rosterwin_roster(); return; - } void -sv_ev_message_receipt(const char *const barejid, const char *const id) +sv_ev_message_receipt(const char* const barejid, const char* const id) { - ProfChatWin *chatwin = wins_get_chat(barejid); + ProfChatWin* chatwin = wins_get_chat(barejid); if (!chatwin) return; @@ -686,7 +683,7 @@ sv_ev_message_receipt(const char *const barejid, const char *const id) } void -sv_ev_typing(char *barejid, char *resource) +sv_ev_typing(char* barejid, char* resource) { ui_contact_typing(barejid, resource); if (wins_chat_exists(barejid)) { @@ -695,7 +692,7 @@ sv_ev_typing(char *barejid, char *resource) } void -sv_ev_paused(char *barejid, char *resource) +sv_ev_paused(char* barejid, char* resource) { if (wins_chat_exists(barejid)) { chat_session_recipient_paused(barejid, resource); @@ -703,7 +700,7 @@ sv_ev_paused(char *barejid, char *resource) } void -sv_ev_inactive(char *barejid, char *resource) +sv_ev_inactive(char* barejid, char* resource) { if (wins_chat_exists(barejid)) { chat_session_recipient_inactive(barejid, resource); @@ -711,14 +708,14 @@ sv_ev_inactive(char *barejid, char *resource) } void -sv_ev_gone(const char *const barejid, const char *const resource) +sv_ev_gone(const char* const barejid, const char* const resource) { if (barejid && resource) { gboolean show_message = TRUE; - ProfChatWin *chatwin = wins_get_chat(barejid); + ProfChatWin* chatwin = wins_get_chat(barejid); if (chatwin) { - ChatSession *session = chat_session_get(barejid); + ChatSession* session = chat_session_get(barejid); if (session && g_strcmp0(session->resource, resource) != 0) { show_message = FALSE; } @@ -734,7 +731,7 @@ sv_ev_gone(const char *const barejid, const char *const resource) } void -sv_ev_activity(const char *const barejid, const char *const resource, gboolean send_states) +sv_ev_activity(const char* const barejid, const char* const resource, gboolean send_states) { if (wins_chat_exists(barejid)) { chat_session_recipient_active(barejid, resource, send_states); @@ -742,7 +739,7 @@ sv_ev_activity(const char *const barejid, const char *const resource, gboolean s } void -sv_ev_subscription(const char *barejid, jabber_subscr_t type) +sv_ev_subscription(const char* barejid, jabber_subscr_t type) { switch (type) { case PRESENCE_SUBSCRIBE: @@ -775,7 +772,7 @@ sv_ev_subscription(const char *barejid, jabber_subscr_t type) } void -sv_ev_contact_offline(char *barejid, char *resource, char *status) +sv_ev_contact_offline(char* barejid, char* resource, char* status) { gboolean updated = roster_contact_offline(barejid, resource, status); @@ -785,7 +782,7 @@ sv_ev_contact_offline(char *barejid, char *resource, char *status) } #ifdef HAVE_LIBOTR - ProfChatWin *chatwin = wins_get_chat(barejid); + ProfChatWin* chatwin = wins_get_chat(barejid); if (chatwin && otr_is_secure(barejid)) { chatwin_otr_unsecured(chatwin); otr_end_session(chatwin->barejid); @@ -797,13 +794,13 @@ sv_ev_contact_offline(char *barejid, char *resource, char *status) } void -sv_ev_contact_online(char *barejid, Resource *resource, GDateTime *last_activity, char *pgpsig) +sv_ev_contact_online(char* barejid, Resource* resource, GDateTime* last_activity, char* pgpsig) { gboolean updated = roster_update_presence(barejid, resource, last_activity); if (updated) { plugins_on_contact_presence(barejid, resource->name, string_from_resource_presence(resource->presence), - resource->status, resource->priority); + resource->status, resource->priority); ui_contact_online(barejid, resource, last_activity); } @@ -818,56 +815,56 @@ sv_ev_contact_online(char *barejid, Resource *resource, GDateTime *last_activity } void -sv_ev_leave_room(const char *const room) +sv_ev_leave_room(const char* const room) { muc_leave(room); ui_leave_room(room); } void -sv_ev_room_destroy(const char *const room) +sv_ev_room_destroy(const char* const room) { muc_leave(room); ui_room_destroy(room); } void -sv_ev_room_destroyed(const char *const room, const char *const new_jid, const char *const password, - const char *const reason) +sv_ev_room_destroyed(const char* const room, const char* const new_jid, const char* const password, + const char* const reason) { muc_leave(room); ui_room_destroyed(room, reason, new_jid, password); } void -sv_ev_room_kicked(const char *const room, const char *const actor, const char *const reason) +sv_ev_room_kicked(const char* const room, const char* const actor, const char* const reason) { muc_leave(room); ui_room_kicked(room, actor, reason); } void -sv_ev_room_banned(const char *const room, const char *const actor, const char *const reason) +sv_ev_room_banned(const char* const room, const char* const actor, const char* const reason) { muc_leave(room); ui_room_banned(room, actor, reason); } void -sv_ev_room_occupant_offline(const char *const room, const char *const nick, - const char *const show, const char *const status) +sv_ev_room_occupant_offline(const char* const room, const char* const nick, + const char* const show, const char* const status) { muc_roster_remove(room, nick); - char *muc_status_pref = prefs_get_string(PREF_STATUSES_MUC); - ProfMucWin *mucwin = wins_get_muc(room); + char* muc_status_pref = prefs_get_string(PREF_STATUSES_MUC); + ProfMucWin* mucwin = wins_get_muc(room); if (mucwin && (g_strcmp0(muc_status_pref, "none") != 0)) { mucwin_occupant_offline(mucwin, nick); } g_free(muc_status_pref); - Jid *jidp = jid_create_from_bare_and_resource(room, nick); - ProfPrivateWin *privwin = wins_get_private(jidp->fulljid); + Jid* jidp = jid_create_from_bare_and_resource(room, nick); + ProfPrivateWin* privwin = wins_get_private(jidp->fulljid); jid_destroy(jidp); if (privwin != NULL) { privwin_occupant_offline(privwin); @@ -878,17 +875,17 @@ sv_ev_room_occupant_offline(const char *const room, const char *const nick, } void -sv_ev_room_occupent_kicked(const char *const room, const char *const nick, const char *const actor, - const char *const reason) +sv_ev_room_occupent_kicked(const char* const room, const char* const nick, const char* const actor, + const char* const reason) { muc_roster_remove(room, nick); - ProfMucWin *mucwin = wins_get_muc(room); + ProfMucWin* mucwin = wins_get_muc(room); if (mucwin) { mucwin_occupant_kicked(mucwin, nick, actor, reason); } - Jid *jidp = jid_create_from_bare_and_resource(room, nick); - ProfPrivateWin *privwin = wins_get_private(jidp->fulljid); + Jid* jidp = jid_create_from_bare_and_resource(room, nick); + ProfPrivateWin* privwin = wins_get_private(jidp->fulljid); jid_destroy(jidp); if (privwin != NULL) { privwin_occupant_kicked(privwin, actor, reason); @@ -899,17 +896,17 @@ sv_ev_room_occupent_kicked(const char *const room, const char *const nick, const } void -sv_ev_room_occupent_banned(const char *const room, const char *const nick, const char *const actor, - const char *const reason) +sv_ev_room_occupent_banned(const char* const room, const char* const nick, const char* const actor, + const char* const reason) { muc_roster_remove(room, nick); - ProfMucWin *mucwin = wins_get_muc(room); + ProfMucWin* mucwin = wins_get_muc(room); if (mucwin) { mucwin_occupant_banned(mucwin, nick, actor, reason); } - Jid *jidp = jid_create_from_bare_and_resource(room, nick); - ProfPrivateWin *privwin = wins_get_private(jidp->fulljid); + Jid* jidp = jid_create_from_bare_and_resource(room, nick); + ProfPrivateWin* privwin = wins_get_private(jidp->fulljid); jid_destroy(jidp); if (privwin != NULL) { privwin_occupant_banned(privwin, actor, reason); @@ -920,42 +917,42 @@ sv_ev_room_occupent_banned(const char *const room, const char *const nick, const } void -sv_ev_roster_update(const char *const barejid, const char *const name, - GSList *groups, const char *const subscription, gboolean pending_out) +sv_ev_roster_update(const char* const barejid, const char* const name, + GSList* groups, const char* const subscription, gboolean pending_out) { roster_update(barejid, name, groups, subscription, pending_out); rosterwin_roster(); } void -sv_ev_xmpp_stanza(const char *const msg) +sv_ev_xmpp_stanza(const char* const msg) { - ProfXMLWin *xmlwin = wins_get_xmlconsole(); + ProfXMLWin* xmlwin = wins_get_xmlconsole(); if (xmlwin) { xmlwin_show(xmlwin, msg); } } void -sv_ev_muc_self_online(const char *const room, const char *const nick, gboolean config_required, - const char *const role, const char *const affiliation, const char *const actor, const char *const reason, - const char *const jid, const char *const show, const char *const status) +sv_ev_muc_self_online(const char* const room, const char* const nick, gboolean config_required, + const char* const role, const char* const affiliation, const char* const actor, const char* const reason, + const char* const jid, const char* const show, const char* const status) { muc_roster_add(room, nick, jid, role, affiliation, show, status); - char *old_role = muc_role_str(room); - char *old_affiliation = muc_affiliation_str(room); + char* old_role = muc_role_str(room); + char* old_affiliation = muc_affiliation_str(room); muc_set_role(room, role); muc_set_affiliation(room, affiliation); // handle self nick change if (muc_nick_change_pending(room)) { muc_nick_change_complete(room, nick); - ProfMucWin *mucwin = wins_get_muc(room); + ProfMucWin* mucwin = wins_get_muc(room); if (mucwin) { mucwin_nick_change(mucwin, nick); } - // handle roster complete + // handle roster complete } else if (!muc_roster_complete(room)) { if (muc_autojoin(room)) { ui_room_join(room, FALSE); @@ -963,7 +960,7 @@ sv_ev_muc_self_online(const char *const room, const char *const nick, gboolean c ui_room_join(room, TRUE); } - Jid *jidp = jid_create(room); + Jid* jidp = jid_create(room); if (jidp->domainpart) { muc_confserver_add(jidp->domainpart); } @@ -981,21 +978,21 @@ sv_ev_muc_self_online(const char *const room, const char *const nick, gboolean c muc_roster_set_complete(room); // show roster if occupants list disabled by default - ProfMucWin *mucwin = wins_get_muc(room); + ProfMucWin* mucwin = wins_get_muc(room); if (mucwin && !prefs_get_boolean(PREF_OCCUPANTS)) { - GList *occupants = muc_roster(room); + GList* occupants = muc_roster(room); mucwin_roster(mucwin, occupants, NULL); g_list_free(occupants); } - char *subject = muc_subject(room); + char* subject = muc_subject(room); if (mucwin && subject) { mucwin_subject(mucwin, NULL, subject); } - GList *pending_broadcasts = muc_pending_broadcasts(room); + GList* pending_broadcasts = muc_pending_broadcasts(room); if (mucwin && pending_broadcasts) { - GList *curr = pending_broadcasts; + GList* curr = pending_broadcasts; while (curr) { mucwin_broadcast(mucwin, curr->data); curr = g_list_next(curr); @@ -1012,19 +1009,19 @@ sv_ev_muc_self_online(const char *const room, const char *const nick, gboolean c rosterwin_roster(); - // check for change in role/affiliation + // check for change in role/affiliation } else { - ProfMucWin *mucwin = wins_get_muc(room); + ProfMucWin* mucwin = wins_get_muc(room); if (mucwin && prefs_get_boolean(PREF_MUC_PRIVILEGES)) { // both changed if ((g_strcmp0(role, old_role) != 0) && (g_strcmp0(affiliation, old_affiliation) != 0)) { mucwin_role_and_affiliation_change(mucwin, role, affiliation, actor, reason); - // role changed + // role changed } else if (g_strcmp0(role, old_role) != 0) { mucwin_role_change(mucwin, role, actor, reason); - // affiliation changed + // affiliation changed } else if (g_strcmp0(affiliation, old_affiliation) != 0) { mucwin_affiliation_change(mucwin, affiliation, actor, reason); } @@ -1035,14 +1032,14 @@ sv_ev_muc_self_online(const char *const room, const char *const nick, gboolean c } void -sv_ev_muc_occupant_online(const char *const room, const char *const nick, const char *const jid, - const char *const role, const char *const affiliation, const char *const actor, const char *const reason, - const char *const show, const char *const status) +sv_ev_muc_occupant_online(const char* const room, const char* const nick, const char* const jid, + const char* const role, const char* const affiliation, const char* const actor, const char* const reason, + const char* const show, const char* const status) { - Occupant *occupant = muc_roster_item(room, nick); + Occupant* occupant = muc_roster_item(room, nick); - const char *old_role = NULL; - const char *old_affiliation = NULL; + const char* old_role = NULL; + const char* old_affiliation = NULL; if (occupant) { old_role = muc_occupant_role_str(occupant); old_affiliation = muc_occupant_affiliation_str(occupant); @@ -1060,9 +1057,9 @@ sv_ev_muc_occupant_online(const char *const room, const char *const nick, const } // handle nickname change - char *old_nick = muc_roster_nick_change_complete(room, nick); + char* old_nick = muc_roster_nick_change_complete(room, nick); if (old_nick) { - ProfMucWin *mucwin = wins_get_muc(room); + ProfMucWin* mucwin = wins_get_muc(room); if (mucwin) { mucwin_occupant_nick_change(mucwin, old_nick, nick); wins_private_nick_change(mucwin->roomjid, old_nick, nick); @@ -1076,16 +1073,16 @@ sv_ev_muc_occupant_online(const char *const room, const char *const nick, const // joined room if (!occupant) { - char *muc_status_pref = prefs_get_string(PREF_STATUSES_MUC); - ProfMucWin *mucwin = wins_get_muc(room); + char* muc_status_pref = prefs_get_string(PREF_STATUSES_MUC); + ProfMucWin* mucwin = wins_get_muc(room); if (mucwin && g_strcmp0(muc_status_pref, "none") != 0) { mucwin_occupant_online(mucwin, nick, role, affiliation, show, status); } g_free(muc_status_pref); if (mucwin) { - Jid *jidp = jid_create_from_bare_and_resource(mucwin->roomjid, nick); - ProfPrivateWin *privwin = wins_get_private(jidp->fulljid); + Jid* jidp = jid_create_from_bare_and_resource(mucwin->roomjid, nick); + ProfPrivateWin* privwin = wins_get_private(jidp->fulljid); jid_destroy(jidp); if (privwin) { privwin_occupant_online(privwin); @@ -1099,27 +1096,27 @@ sv_ev_muc_occupant_online(const char *const room, const char *const nick, const // presence updated if (updated) { - char *muc_status_pref = prefs_get_string(PREF_STATUSES_MUC); - ProfMucWin *mucwin = wins_get_muc(room); + char* muc_status_pref = prefs_get_string(PREF_STATUSES_MUC); + ProfMucWin* mucwin = wins_get_muc(room); if (mucwin && (g_strcmp0(muc_status_pref, "all") == 0)) { mucwin_occupant_presence(mucwin, nick, show, status); } g_free(muc_status_pref); occupantswin_occupants(room); - // presence unchanged, check for role/affiliation change + // presence unchanged, check for role/affiliation change } else { - ProfMucWin *mucwin = wins_get_muc(room); + ProfMucWin* mucwin = wins_get_muc(room); if (mucwin && prefs_get_boolean(PREF_MUC_PRIVILEGES)) { // both changed if ((g_strcmp0(role, old_role) != 0) && (g_strcmp0(affiliation, old_affiliation) != 0)) { mucwin_occupant_role_and_affiliation_change(mucwin, nick, role, affiliation, actor, reason); - // role changed + // role changed } else if (g_strcmp0(role, old_role) != 0) { mucwin_occupant_role_change(mucwin, nick, role, actor, reason); - // affiliation changed + // affiliation changed } else if (g_strcmp0(affiliation, old_affiliation) != 0) { mucwin_occupant_affiliation_change(mucwin, nick, affiliation, actor, reason); } @@ -1131,7 +1128,7 @@ sv_ev_muc_occupant_online(const char *const room, const char *const nick, const } int -sv_ev_certfail(const char *const errormsg, TLSCertificate *cert) +sv_ev_certfail(const char* const errormsg, TLSCertificate* cert) { // check profanity trusted certs if (tlscerts_exists(cert->fingerprint)) { @@ -1139,7 +1136,7 @@ sv_ev_certfail(const char *const errormsg, TLSCertificate *cert) } // check current cert - char *current_fp = tlscerts_get_current(); + char* current_fp = tlscerts_get_current(); if (current_fp && g_strcmp0(current_fp, cert->fingerprint) == 0) { return 1; } @@ -1154,12 +1151,12 @@ sv_ev_certfail(const char *const errormsg, TLSCertificate *cert) cons_show(""); ui_update(); - char *cmd = ui_get_line(); + char* cmd = ui_get_line(); while ((g_strcmp0(cmd, "/tls allow") != 0) - && (g_strcmp0(cmd, "/tls always") != 0) - && (g_strcmp0(cmd, "/tls deny") != 0) - && (g_strcmp0(cmd, "/quit") != 0)) { + && (g_strcmp0(cmd, "/tls always") != 0) + && (g_strcmp0(cmd, "/tls deny") != 0) + && (g_strcmp0(cmd, "/quit") != 0)) { cons_show("Use '/tls allow' to accept this certificate."); cons_show("Use '/tls always' to accept this certificate permanently."); cons_show("Use '/tls deny' to reject this certificate."); @@ -1193,19 +1190,19 @@ sv_ev_certfail(const char *const errormsg, TLSCertificate *cert) } void -sv_ev_lastactivity_response(const char *const from, const int seconds, const char *const msg) +sv_ev_lastactivity_response(const char* const from, const int seconds, const char* const msg) { - Jid *jidp = jid_create(from); + Jid* jidp = jid_create(from); if (!jidp) { return; } - GDateTime *now = g_date_time_new_now_local(); - GDateTime *active = g_date_time_add_seconds(now, 0 - seconds); + GDateTime* now = g_date_time_new_now_local(); + GDateTime* active = g_date_time_add_seconds(now, 0 - seconds); - gchar *date_fmt = NULL; - char *time_pref = prefs_get_string(PREF_TIME_LASTACTIVITY); + gchar* date_fmt = NULL; + char* time_pref = prefs_get_string(PREF_TIME_LASTACTIVITY); date_fmt = g_date_time_format(active, time_pref); g_free(time_pref); assert(date_fmt != NULL); @@ -1226,7 +1223,7 @@ sv_ev_lastactivity_response(const char *const from, const int seconds, const cha } } - // barejid - last logged in + // barejid - last logged in } else if (jidp->localpart) { if (seconds == 0) { if (msg) { @@ -1242,7 +1239,7 @@ sv_ev_lastactivity_response(const char *const from, const int seconds, const cha } } - // domain only - uptime + // domain only - uptime } else { int left = seconds; int days = seconds / 86400; @@ -1263,19 +1260,19 @@ sv_ev_lastactivity_response(const char *const from, const int seconds, const cha } void -sv_ev_bookmark_autojoin(Bookmark *bookmark) +sv_ev_bookmark_autojoin(Bookmark* bookmark) { if (bookmark_ignored(bookmark)) { return; } - char *nick = NULL; + char* nick = NULL; if (bookmark->nick) { nick = strdup(bookmark->nick); } else { - char *account_name = session_get_account_name(); - ProfAccount *account = accounts_get_account(account_name); + char* account_name = session_get_account_name(); + ProfAccount* account = accounts_get_account(account_name); nick = strdup(account->muc_nick); account_free(account); } @@ -1293,10 +1290,10 @@ sv_ev_bookmark_autojoin(Bookmark *bookmark) } static void -_cut(ProfMessage *message, const char *cut) +_cut(ProfMessage* message, const char* cut) { if (strstr(message->plain, cut)) { - char **split = g_strsplit(message->plain, cut, -1); + char** split = g_strsplit(message->plain, cut, -1); free(message->plain); message->plain = g_strjoinv("", split); g_strfreev(split); @@ -1304,7 +1301,7 @@ _cut(ProfMessage *message, const char *cut) } static void -_clean_incoming_message(ProfMessage *message) +_clean_incoming_message(ProfMessage* message) { _cut(message, "\u200E"); _cut(message, "\u200F"); diff --git a/src/event/server_events.h b/src/event/server_events.h index 0292daf4..b377e2af 100644 --- a/src/event/server_events.h +++ b/src/event/server_events.h @@ -39,55 +39,55 @@ #include "xmpp/xmpp.h" #include "xmpp/message.h" -void sv_ev_login_account_success(char *account_name, gboolean secured); +void sv_ev_login_account_success(char* account_name, gboolean secured); void sv_ev_lost_connection(void); void sv_ev_failed_login(void); void sv_ev_room_invite(jabber_invite_t invite_type, - const char *const invitor, const char *const room, - const char *const reason, const char *const password); -void sv_ev_room_broadcast(const char *const room_jid, const char *const message); -void sv_ev_room_subject(const char *const room, const char *const nick, const char *const subject); -void sv_ev_room_history(ProfMessage *message); -void sv_ev_room_message(ProfMessage *message); -void sv_ev_incoming_message(ProfMessage *message); -void sv_ev_incoming_private_message(ProfMessage *message); -void sv_ev_delayed_private_message(ProfMessage *message); -void sv_ev_typing(char *barejid, char *resource); -void sv_ev_paused(char *barejid, char *resource); -void sv_ev_inactive(char *barejid, char *resource); -void sv_ev_activity(char *barejid, char *resource, gboolean send_states); -void sv_ev_gone(const char *const barejid, const char *const resource); -void sv_ev_subscription(const char *from, jabber_subscr_t type); -void sv_ev_message_receipt(const char *const barejid, const char *const id); -void sv_ev_contact_offline(char *contact, char *resource, char *status); -void sv_ev_contact_online(char *contact, Resource *resource, GDateTime *last_activity, char *pgpkey); -void sv_ev_leave_room(const char *const room); -void sv_ev_room_destroy(const char *const room); -void sv_ev_room_occupant_offline(const char *const room, const char *const nick, - const char *const show, const char *const status); -void sv_ev_room_destroyed(const char *const room, const char *const new_jid, const char *const password, - const char *const reason); -void sv_ev_room_kicked(const char *const room, const char *const actor, const char *const reason); -void sv_ev_room_occupent_kicked(const char *const room, const char *const nick, const char *const actor, - const char *const reason); -void sv_ev_room_banned(const char *const room, const char *const actor, const char *const reason); -void sv_ev_room_occupent_banned(const char *const room, const char *const nick, const char *const actor, - const char *const reason); -void sv_ev_outgoing_carbon(ProfMessage *message); -void sv_ev_incoming_carbon(ProfMessage *message); -void sv_ev_xmpp_stanza(const char *const msg); -void sv_ev_muc_self_online(const char *const room, const char *const nick, gboolean config_required, - const char *const role, const char *const affiliation, const char *const actor, const char *const reason, - const char *const jid, const char *const show, const char *const status); -void sv_ev_muc_occupant_online(const char *const room, const char *const nick, const char *const jid, - const char *const role, const char *const affiliation, const char *const actor, const char *const reason, - const char *const show_str, const char *const status_str); -void sv_ev_roster_update(const char *const barejid, const char *const name, - GSList *groups, const char *const subscription, gboolean pending_out); + const char* const invitor, const char* const room, + const char* const reason, const char* const password); +void sv_ev_room_broadcast(const char* const room_jid, const char* const message); +void sv_ev_room_subject(const char* const room, const char* const nick, const char* const subject); +void sv_ev_room_history(ProfMessage* message); +void sv_ev_room_message(ProfMessage* message); +void sv_ev_incoming_message(ProfMessage* message); +void sv_ev_incoming_private_message(ProfMessage* message); +void sv_ev_delayed_private_message(ProfMessage* message); +void sv_ev_typing(char* barejid, char* resource); +void sv_ev_paused(char* barejid, char* resource); +void sv_ev_inactive(char* barejid, char* resource); +void sv_ev_activity(char* barejid, char* resource, gboolean send_states); +void sv_ev_gone(const char* const barejid, const char* const resource); +void sv_ev_subscription(const char* from, jabber_subscr_t type); +void sv_ev_message_receipt(const char* const barejid, const char* const id); +void sv_ev_contact_offline(char* contact, char* resource, char* status); +void sv_ev_contact_online(char* contact, Resource* resource, GDateTime* last_activity, char* pgpkey); +void sv_ev_leave_room(const char* const room); +void sv_ev_room_destroy(const char* const room); +void sv_ev_room_occupant_offline(const char* const room, const char* const nick, + const char* const show, const char* const status); +void sv_ev_room_destroyed(const char* const room, const char* const new_jid, const char* const password, + const char* const reason); +void sv_ev_room_kicked(const char* const room, const char* const actor, const char* const reason); +void sv_ev_room_occupent_kicked(const char* const room, const char* const nick, const char* const actor, + const char* const reason); +void sv_ev_room_banned(const char* const room, const char* const actor, const char* const reason); +void sv_ev_room_occupent_banned(const char* const room, const char* const nick, const char* const actor, + const char* const reason); +void sv_ev_outgoing_carbon(ProfMessage* message); +void sv_ev_incoming_carbon(ProfMessage* message); +void sv_ev_xmpp_stanza(const char* const msg); +void sv_ev_muc_self_online(const char* const room, const char* const nick, gboolean config_required, + const char* const role, const char* const affiliation, const char* const actor, const char* const reason, + const char* const jid, const char* const show, const char* const status); +void sv_ev_muc_occupant_online(const char* const room, const char* const nick, const char* const jid, + const char* const role, const char* const affiliation, const char* const actor, const char* const reason, + const char* const show_str, const char* const status_str); +void sv_ev_roster_update(const char* const barejid, const char* const name, + GSList* groups, const char* const subscription, gboolean pending_out); void sv_ev_roster_received(void); void sv_ev_connection_features_received(void); -int sv_ev_certfail(const char *const errormsg, TLSCertificate *cert); -void sv_ev_lastactivity_response(const char *const from, const int seconds, const char *const msg); -void sv_ev_bookmark_autojoin(Bookmark *bookmark); +int sv_ev_certfail(const char* const errormsg, TLSCertificate* cert); +void sv_ev_lastactivity_response(const char* const from, const int seconds, const char* const msg); +void sv_ev_bookmark_autojoin(Bookmark* bookmark); #endif diff --git a/src/log.c b/src/log.c index f8ef6bf6..38971f26 100644 --- a/src/log.c +++ b/src/log.c @@ -54,54 +54,55 @@ #define PROF "prof" -static FILE *logp; -static gchar *mainlogfile = NULL; +static FILE* logp; +static gchar* mainlogfile = NULL; -static GTimeZone *tz; -static GDateTime *dt; +static GTimeZone* tz; +static GDateTime* dt; static log_level_t level_filter; -static GHashTable *logs; -static GHashTable *groupchat_logs; -static GDateTime *session_started; +static GHashTable* logs; +static GHashTable* groupchat_logs; +static GDateTime* session_started; static int stderr_inited; static log_level_t stderr_level; static int stderr_pipe[2]; -static char *stderr_buf; -static GString *stderr_msg; +static char* stderr_buf; +static GString* stderr_msg; enum { STDERR_BUFSIZE = 4000, STDERR_RETRY_NR = 5, }; -struct dated_chat_log { - gchar *filename; - GDateTime *date; +struct dated_chat_log +{ + gchar* filename; + GDateTime* date; }; -static gboolean _log_roll_needed(struct dated_chat_log *dated_log); -static struct dated_chat_log* _create_log(const char *const other, const char *const login); -static struct dated_chat_log* _create_groupchat_log(const char *const room, const char *const login); -static void _free_chat_log(struct dated_chat_log *dated_log); -static gboolean _key_equals(void *key1, void *key2); -static char* _get_log_filename(const char *const other, const char *const login, GDateTime *dt, gboolean create); -static char* _get_groupchat_log_filename(const char *const room, const char *const login, GDateTime *dt, - gboolean create); +static gboolean _log_roll_needed(struct dated_chat_log* dated_log); +static struct dated_chat_log* _create_log(const char* const other, const char* const login); +static struct dated_chat_log* _create_groupchat_log(const char* const room, const char* const login); +static void _free_chat_log(struct dated_chat_log* dated_log); +static gboolean _key_equals(void* key1, void* key2); +static char* _get_log_filename(const char* const other, const char* const login, GDateTime* dt, gboolean create); +static char* _get_groupchat_log_filename(const char* const room, const char* const login, GDateTime* dt, + gboolean create); static void _rotate_log_file(void); static char* _log_string_from_level(log_level_t level); -static void _chat_log_chat(const char *const login, const char *const other, const gchar *const msg, - chat_log_direction_t direction, GDateTime *timestamp, const char *const resourcepart); -static void _groupchat_log_chat(const gchar *const login, const gchar *const room, const gchar *const nick, - const gchar *const msg); +static void _chat_log_chat(const char* const login, const char* const other, const gchar* const msg, + chat_log_direction_t direction, GDateTime* timestamp, const char* const resourcepart); +static void _groupchat_log_chat(const gchar* const login, const gchar* const room, const gchar* const nick, + const gchar* const msg); void -log_debug(const char *const msg, ...) +log_debug(const char* const msg, ...) { va_list arg; va_start(arg, msg); - GString *fmt_msg = g_string_new(NULL); + GString* fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, msg, arg); log_msg(PROF_LEVEL_DEBUG, PROF, fmt_msg->str); g_string_free(fmt_msg, TRUE); @@ -109,11 +110,11 @@ log_debug(const char *const msg, ...) } void -log_info(const char *const msg, ...) +log_info(const char* const msg, ...) { va_list arg; va_start(arg, msg); - GString *fmt_msg = g_string_new(NULL); + GString* fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, msg, arg); log_msg(PROF_LEVEL_INFO, PROF, fmt_msg->str); g_string_free(fmt_msg, TRUE); @@ -121,11 +122,11 @@ log_info(const char *const msg, ...) } void -log_warning(const char *const msg, ...) +log_warning(const char* const msg, ...) { va_list arg; va_start(arg, msg); - GString *fmt_msg = g_string_new(NULL); + GString* fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, msg, arg); log_msg(PROF_LEVEL_WARN, PROF, fmt_msg->str); g_string_free(fmt_msg, TRUE); @@ -133,11 +134,11 @@ log_warning(const char *const msg, ...) } void -log_error(const char *const msg, ...) +log_error(const char* const msg, ...) { va_list arg; va_start(arg, msg); - GString *fmt_msg = g_string_new(NULL); + GString* fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, msg, arg); log_msg(PROF_LEVEL_ERROR, PROF, fmt_msg->str); g_string_free(fmt_msg, TRUE); @@ -145,11 +146,11 @@ log_error(const char *const msg, ...) } void -log_init(log_level_t filter, char *log_file) +log_init(log_level_t filter, char* log_file) { level_filter = filter; tz = g_time_zone_new_local(); - gchar *lf = files_get_log_file(log_file); + gchar* lf = files_get_log_file(log_file); logp = fopen(lf, "a"); g_chmod(lf, S_IRUSR | S_IWUSR); @@ -161,9 +162,9 @@ log_init(log_level_t filter, char *log_file) void log_reinit(void) { - char *lf = strdup(mainlogfile); - char *start = strrchr(lf, '/') +1; - char *end = strstr(start, ".log"); + char* lf = strdup(mainlogfile); + char* start = strrchr(lf, '/') + 1; + char* end = strstr(start, ".log"); *end = '\0'; log_close(); @@ -196,14 +197,14 @@ log_close(void) } void -log_msg(log_level_t level, const char *const area, const char *const msg) +log_msg(log_level_t level, const char* const area, const char* const msg) { if (level >= level_filter && logp) { dt = g_date_time_new_now(tz); - char *level_str = _log_string_from_level(level); + char* level_str = _log_string_from_level(level); - gchar *date_fmt = g_date_time_format(dt, "%d/%m/%Y %H:%M:%S"); + gchar* date_fmt = g_date_time_format(dt, "%d/%m/%Y %H:%M:%S"); fprintf(logp, "%s: %s: %s: %s\n", date_fmt, area, level_str, msg); g_date_time_unref(dt); @@ -221,7 +222,7 @@ log_msg(log_level_t level, const char *const area, const char *const msg) } log_level_t -log_level_from_string(char *log_level) +log_level_from_string(char* log_level) { assert(log_level != NULL); if (strcmp(log_level, "DEBUG") == 0) { @@ -240,21 +241,21 @@ log_level_from_string(char *log_level) static void _rotate_log_file(void) { - gchar *log_file = g_strdup(mainlogfile); + gchar* log_file = g_strdup(mainlogfile); size_t len = strlen(log_file); - gchar *log_file_new = malloc(len + 4); + gchar* log_file_new = malloc(len + 4); int i = 1; // find an empty name. from .log -> log.01 -> log.99 - for(; i<100; i++) { + for (; i < 100; i++) { g_sprintf(log_file_new, "%s.%02d", log_file, i); if (!g_file_test(log_file_new, G_FILE_TEST_EXISTS)) break; } - char *lf = strdup(mainlogfile); - char *start = strrchr(lf, '/') +1; - char *end = strstr(start, ".log"); + char* lf = strdup(mainlogfile); + char* start = strrchr(lf, '/') + 1; + char* end = strstr(start, ".log"); *end = '\0'; log_close(); @@ -274,34 +275,34 @@ chat_log_init(void) { session_started = g_date_time_new_now_local(); log_info("Initialising chat logs"); - logs = g_hash_table_new_full(g_str_hash, (GEqualFunc) _key_equals, free, - (GDestroyNotify)_free_chat_log); + logs = g_hash_table_new_full(g_str_hash, (GEqualFunc)_key_equals, free, + (GDestroyNotify)_free_chat_log); } void groupchat_log_init(void) { log_info("Initialising groupchat logs"); - groupchat_logs = g_hash_table_new_full(g_str_hash, (GEqualFunc) _key_equals, free, - (GDestroyNotify)_free_chat_log); + groupchat_logs = g_hash_table_new_full(g_str_hash, (GEqualFunc)_key_equals, free, + (GDestroyNotify)_free_chat_log); } void -chat_log_msg_out(const char *const barejid, const char *const msg, const char *const resource) +chat_log_msg_out(const char* const barejid, const char* const msg, const char* const resource) { if (prefs_get_boolean(PREF_CHLOG)) { - char *mybarejid = connection_get_barejid(); + char* mybarejid = connection_get_barejid(); _chat_log_chat(mybarejid, barejid, msg, PROF_OUT_LOG, NULL, resource); free(mybarejid); } } void -chat_log_otr_msg_out(const char *const barejid, const char *const msg, const char *const resource) +chat_log_otr_msg_out(const char* const barejid, const char* const msg, const char* const resource) { if (prefs_get_boolean(PREF_CHLOG)) { - char *mybarejid = connection_get_barejid(); - char *pref_otr_log = prefs_get_string(PREF_OTR_LOG); + char* mybarejid = connection_get_barejid(); + char* pref_otr_log = prefs_get_string(PREF_OTR_LOG); if (strcmp(pref_otr_log, "on") == 0) { _chat_log_chat(mybarejid, barejid, msg, PROF_OUT_LOG, NULL, resource); } else if (strcmp(pref_otr_log, "redact") == 0) { @@ -313,11 +314,11 @@ chat_log_otr_msg_out(const char *const barejid, const char *const msg, const cha } void -chat_log_pgp_msg_out(const char *const barejid, const char *const msg, const char *const resource) +chat_log_pgp_msg_out(const char* const barejid, const char* const msg, const char* const resource) { if (prefs_get_boolean(PREF_CHLOG)) { - char *mybarejid = connection_get_barejid(); - char *pref_pgp_log = prefs_get_string(PREF_PGP_LOG); + char* mybarejid = connection_get_barejid(); + char* pref_pgp_log = prefs_get_string(PREF_PGP_LOG); if (strcmp(pref_pgp_log, "on") == 0) { _chat_log_chat(mybarejid, barejid, msg, PROF_OUT_LOG, NULL, resource); } else if (strcmp(pref_pgp_log, "redact") == 0) { @@ -329,11 +330,11 @@ chat_log_pgp_msg_out(const char *const barejid, const char *const msg, const cha } void -chat_log_omemo_msg_out(const char *const barejid, const char *const msg, const char *const resource) +chat_log_omemo_msg_out(const char* const barejid, const char* const msg, const char* const resource) { if (prefs_get_boolean(PREF_CHLOG)) { - char *mybarejid = connection_get_barejid(); - char *pref_omemo_log = prefs_get_string(PREF_OMEMO_LOG); + char* mybarejid = connection_get_barejid(); + char* pref_omemo_log = prefs_get_string(PREF_OMEMO_LOG); if (strcmp(pref_omemo_log, "on") == 0) { _chat_log_chat(mybarejid, barejid, msg, PROF_OUT_LOG, NULL, resource); } else if (strcmp(pref_omemo_log, "redact") == 0) { @@ -345,11 +346,11 @@ chat_log_omemo_msg_out(const char *const barejid, const char *const msg, const c } void -chat_log_otr_msg_in(ProfMessage *message) +chat_log_otr_msg_in(ProfMessage* message) { if (prefs_get_boolean(PREF_CHLOG)) { - char *mybarejid = connection_get_barejid(); - char *pref_otr_log = prefs_get_string(PREF_OTR_LOG); + char* mybarejid = connection_get_barejid(); + char* pref_otr_log = prefs_get_string(PREF_OTR_LOG); if (message->enc == PROF_MSG_ENC_NONE || (strcmp(pref_otr_log, "on") == 0)) { if (message->type == PROF_MSG_TYPE_MUCPM) { _chat_log_chat(mybarejid, message->from_jid->barejid, message->plain, PROF_IN_LOG, message->timestamp, message->from_jid->resourcepart); @@ -369,11 +370,11 @@ chat_log_otr_msg_in(ProfMessage *message) } void -chat_log_pgp_msg_in(ProfMessage *message) +chat_log_pgp_msg_in(ProfMessage* message) { if (prefs_get_boolean(PREF_CHLOG)) { - char *mybarejid = connection_get_barejid(); - char *pref_pgp_log = prefs_get_string(PREF_PGP_LOG); + char* mybarejid = connection_get_barejid(); + char* pref_pgp_log = prefs_get_string(PREF_PGP_LOG); if (strcmp(pref_pgp_log, "on") == 0) { if (message->type == PROF_MSG_TYPE_MUCPM) { _chat_log_chat(mybarejid, message->from_jid->barejid, message->plain, PROF_IN_LOG, message->timestamp, message->from_jid->resourcepart); @@ -393,11 +394,11 @@ chat_log_pgp_msg_in(ProfMessage *message) } void -chat_log_omemo_msg_in(ProfMessage *message) +chat_log_omemo_msg_in(ProfMessage* message) { if (prefs_get_boolean(PREF_CHLOG)) { - char *mybarejid = connection_get_barejid(); - char *pref_omemo_log = prefs_get_string(PREF_OMEMO_LOG); + char* mybarejid = connection_get_barejid(); + char* pref_omemo_log = prefs_get_string(PREF_OMEMO_LOG); if (strcmp(pref_omemo_log, "on") == 0) { if (message->type == PROF_MSG_TYPE_MUCPM) { _chat_log_chat(mybarejid, message->from_jid->barejid, message->plain, PROF_IN_LOG, message->timestamp, message->from_jid->resourcepart); @@ -417,10 +418,10 @@ chat_log_omemo_msg_in(ProfMessage *message) } void -chat_log_msg_in(ProfMessage *message) +chat_log_msg_in(ProfMessage* message) { if (prefs_get_boolean(PREF_CHLOG)) { - char *mybarejid = connection_get_barejid(); + char* mybarejid = connection_get_barejid(); if (message->type == PROF_MSG_TYPE_MUCPM) { _chat_log_chat(mybarejid, message->from_jid->barejid, message->plain, PROF_IN_LOG, message->timestamp, message->from_jid->resourcepart); @@ -433,11 +434,11 @@ chat_log_msg_in(ProfMessage *message) } static void -_chat_log_chat(const char *const login, const char *const other, const char *const msg, - chat_log_direction_t direction, GDateTime *timestamp, const char *const resourcepart) +_chat_log_chat(const char* const login, const char* const other, const char* const msg, + chat_log_direction_t direction, GDateTime* timestamp, const char* const resourcepart) { - char *other_name; - GString *other_str = NULL; + char* other_name; + GString* other_str = NULL; if (resourcepart) { other_str = g_string_new(other); @@ -449,26 +450,26 @@ _chat_log_chat(const char *const login, const char *const other, const char *con other_name = (char*)other; } - struct dated_chat_log *dated_log = g_hash_table_lookup(logs, other_name); + struct dated_chat_log* dated_log = g_hash_table_lookup(logs, other_name); // no log for user if (dated_log == NULL) { dated_log = _create_log(other_name, login); g_hash_table_insert(logs, strdup(other_name), dated_log); - // log entry exists but file removed + // log entry exists but file removed } else if (!g_file_test(dated_log->filename, G_FILE_TEST_EXISTS)) { dated_log = _create_log(other_name, login); g_hash_table_replace(logs, strdup(other_name), dated_log); - // log file needs rolling + // log file needs rolling } else if (_log_roll_needed(dated_log)) { dated_log = _create_log(other_name, login); g_hash_table_replace(logs, strdup(other_name), dated_log); } if (resourcepart) { - g_string_free(other_str, TRUE); + g_string_free(other_str, TRUE); } if (timestamp == NULL) { @@ -477,8 +478,8 @@ _chat_log_chat(const char *const login, const char *const other, const char *con g_date_time_ref(timestamp); } - gchar *date_fmt = g_date_time_format(timestamp, "%H:%M:%S"); - FILE *chatlogp = fopen(dated_log->filename, "a"); + gchar* date_fmt = g_date_time_format(timestamp, "%H:%M:%S"); + FILE* chatlogp = fopen(dated_log->filename, "a"); g_chmod(dated_log->filename, S_IRUSR | S_IWUSR); if (chatlogp) { if (direction == PROF_IN_LOG) { @@ -514,33 +515,33 @@ _chat_log_chat(const char *const login, const char *const other, const char *con } void -groupchat_log_msg_out(const gchar *const room, const gchar *const msg) +groupchat_log_msg_out(const gchar* const room, const gchar* const msg) { if (prefs_get_boolean(PREF_GRLOG)) { - char *mybarejid = connection_get_barejid(); - char *mynick = muc_nick(room); + char* mybarejid = connection_get_barejid(); + char* mynick = muc_nick(room); _groupchat_log_chat(mybarejid, room, mynick, msg); free(mybarejid); } } void -groupchat_log_msg_in(const gchar *const room, const gchar *const nick, const gchar *const msg) +groupchat_log_msg_in(const gchar* const room, const gchar* const nick, const gchar* const msg) { if (prefs_get_boolean(PREF_GRLOG)) { - char *mybarejid = connection_get_barejid(); + char* mybarejid = connection_get_barejid(); _groupchat_log_chat(mybarejid, room, nick, msg); free(mybarejid); } } void -groupchat_log_omemo_msg_out(const gchar *const room, const gchar *const msg) +groupchat_log_omemo_msg_out(const gchar* const room, const gchar* const msg) { if (prefs_get_boolean(PREF_CHLOG)) { - char *mybarejid = connection_get_barejid(); - char *pref_omemo_log = prefs_get_string(PREF_OMEMO_LOG); - char *mynick = muc_nick(room); + char* mybarejid = connection_get_barejid(); + char* pref_omemo_log = prefs_get_string(PREF_OMEMO_LOG); + char* mynick = muc_nick(room); if (strcmp(pref_omemo_log, "on") == 0) { _groupchat_log_chat(mybarejid, room, mynick, msg); @@ -554,11 +555,11 @@ groupchat_log_omemo_msg_out(const gchar *const room, const gchar *const msg) } void -groupchat_log_omemo_msg_in(const gchar *const room, const gchar *const nick, const gchar *const msg) +groupchat_log_omemo_msg_in(const gchar* const room, const gchar* const nick, const gchar* const msg) { if (prefs_get_boolean(PREF_CHLOG)) { - char *mybarejid = connection_get_barejid(); - char *pref_omemo_log = prefs_get_string(PREF_OMEMO_LOG); + char* mybarejid = connection_get_barejid(); + char* pref_omemo_log = prefs_get_string(PREF_OMEMO_LOG); if (strcmp(pref_omemo_log, "on") == 0) { _groupchat_log_chat(mybarejid, room, nick, msg); @@ -572,27 +573,27 @@ groupchat_log_omemo_msg_in(const gchar *const room, const gchar *const nick, con } void -_groupchat_log_chat(const gchar *const login, const gchar *const room, const gchar *const nick, - const gchar *const msg) +_groupchat_log_chat(const gchar* const login, const gchar* const room, const gchar* const nick, + const gchar* const msg) { - struct dated_chat_log *dated_log = g_hash_table_lookup(groupchat_logs, room); + struct dated_chat_log* dated_log = g_hash_table_lookup(groupchat_logs, room); // no log for room if (dated_log == NULL) { dated_log = _create_groupchat_log(room, login); g_hash_table_insert(groupchat_logs, strdup(room), dated_log); - // log exists but needs rolling + // log exists but needs rolling } else if (_log_roll_needed(dated_log)) { dated_log = _create_groupchat_log(room, login); g_hash_table_replace(logs, strdup(room), dated_log); } - GDateTime *dt_tmp = g_date_time_new_now_local(); + GDateTime* dt_tmp = g_date_time_new_now_local(); - gchar *date_fmt = g_date_time_format(dt_tmp, "%H:%M:%S"); + gchar* date_fmt = g_date_time_format(dt_tmp, "%H:%M:%S"); - FILE *grpchatlogp = fopen(dated_log->filename, "a"); + FILE* grpchatlogp = fopen(dated_log->filename, "a"); g_chmod(dated_log->filename, S_IRUSR | S_IWUSR); if (grpchatlogp) { if (strncmp(msg, "/me ", 4) == 0) { @@ -621,12 +622,12 @@ chat_log_close(void) } static struct dated_chat_log* -_create_log(const char *const other, const char *const login) +_create_log(const char* const other, const char* const login) { - GDateTime *now = g_date_time_new_now_local(); - char *filename = _get_log_filename(other, login, now, TRUE); + GDateTime* now = g_date_time_new_now_local(); + char* filename = _get_log_filename(other, login, now, TRUE); - struct dated_chat_log *new_log = malloc(sizeof(struct dated_chat_log)); + struct dated_chat_log* new_log = malloc(sizeof(struct dated_chat_log)); new_log->filename = strdup(filename); new_log->date = now; @@ -636,12 +637,12 @@ _create_log(const char *const other, const char *const login) } static struct dated_chat_log* -_create_groupchat_log(const char * const room, const char *const login) +_create_groupchat_log(const char* const room, const char* const login) { - GDateTime *now = g_date_time_new_now_local(); - char *filename = _get_groupchat_log_filename(room, login, now, TRUE); + GDateTime* now = g_date_time_new_now_local(); + char* filename = _get_groupchat_log_filename(room, login, now, TRUE); - struct dated_chat_log *new_log = malloc(sizeof(struct dated_chat_log)); + struct dated_chat_log* new_log = malloc(sizeof(struct dated_chat_log)); new_log->filename = strdup(filename); new_log->date = now; @@ -651,12 +652,11 @@ _create_groupchat_log(const char * const room, const char *const login) } static gboolean -_log_roll_needed(struct dated_chat_log *dated_log) +_log_roll_needed(struct dated_chat_log* dated_log) { gboolean result = FALSE; - GDateTime *now = g_date_time_new_now_local(); - if (g_date_time_get_day_of_year(dated_log->date) != - g_date_time_get_day_of_year(now)) { + GDateTime* now = g_date_time_new_now_local(); + if (g_date_time_get_day_of_year(dated_log->date) != g_date_time_get_day_of_year(now)) { result = TRUE; } g_date_time_unref(now); @@ -665,7 +665,7 @@ _log_roll_needed(struct dated_chat_log *dated_log) } static void -_free_chat_log(struct dated_chat_log *dated_log) +_free_chat_log(struct dated_chat_log* dated_log) { if (dated_log) { if (dated_log->filename) { @@ -681,53 +681,53 @@ _free_chat_log(struct dated_chat_log *dated_log) } static gboolean -_key_equals(void *key1, void *key2) +_key_equals(void* key1, void* key2) { - gchar *str1 = (gchar *) key1; - gchar *str2 = (gchar *) key2; + gchar* str1 = (gchar*)key1; + gchar* str2 = (gchar*)key2; return (g_strcmp0(str1, str2) == 0); } static char* -_get_log_filename(const char *const other, const char *const login, GDateTime *dt, gboolean create) +_get_log_filename(const char* const other, const char* const login, GDateTime* dt, gboolean create) { - char *chatlogs_dir = files_get_data_path(DIR_CHATLOGS); - GString *log_file = g_string_new(chatlogs_dir); + char* chatlogs_dir = files_get_data_path(DIR_CHATLOGS); + GString* log_file = g_string_new(chatlogs_dir); free(chatlogs_dir); - gchar *login_dir = str_replace(login, "@", "_at_"); + gchar* login_dir = str_replace(login, "@", "_at_"); g_string_append_printf(log_file, "/%s", login_dir); if (create) { create_dir(log_file->str); } free(login_dir); - gchar *other_file = str_replace(other, "@", "_at_"); + gchar* other_file = str_replace(other, "@", "_at_"); g_string_append_printf(log_file, "/%s", other_file); if (create) { create_dir(log_file->str); } free(other_file); - gchar *date = g_date_time_format(dt, "/%Y_%m_%d.log"); + gchar* date = g_date_time_format(dt, "/%Y_%m_%d.log"); g_string_append(log_file, date); g_free(date); - char *result = strdup(log_file->str); + char* result = strdup(log_file->str); g_string_free(log_file, TRUE); return result; } static char* -_get_groupchat_log_filename(const char *const room, const char *const login, GDateTime *dt, gboolean create) +_get_groupchat_log_filename(const char* const room, const char* const login, GDateTime* dt, gboolean create) { - char *chatlogs_dir = files_get_data_path(DIR_CHATLOGS); - GString *log_file = g_string_new(chatlogs_dir); + char* chatlogs_dir = files_get_data_path(DIR_CHATLOGS); + GString* log_file = g_string_new(chatlogs_dir); free(chatlogs_dir); - gchar *login_dir = str_replace(login, "@", "_at_"); + gchar* login_dir = str_replace(login, "@", "_at_"); g_string_append_printf(log_file, "/%s", login_dir); if (create) { create_dir(log_file->str); @@ -739,18 +739,18 @@ _get_groupchat_log_filename(const char *const room, const char *const login, GDa create_dir(log_file->str); } - gchar *room_file = str_replace(room, "@", "_at_"); + gchar* room_file = str_replace(room, "@", "_at_"); g_string_append_printf(log_file, "/%s", room_file); if (create) { create_dir(log_file->str); } free(room_file); - gchar *date = g_date_time_format(dt, "/%Y_%m_%d.log"); + gchar* date = g_date_time_format(dt, "/%Y_%m_%d.log"); g_string_append(log_file, date); g_free(date); - char *result = strdup(log_file->str); + char* result = strdup(log_file->str); g_string_free(log_file, TRUE); return result; @@ -759,26 +759,25 @@ _get_groupchat_log_filename(const char *const room, const char *const login, GDa static char* _log_string_from_level(log_level_t level) { - switch (level) - { - case PROF_LEVEL_ERROR: - return "ERR"; - case PROF_LEVEL_WARN: - return "WRN"; - case PROF_LEVEL_INFO: - return "INF"; - case PROF_LEVEL_DEBUG: - return "DBG"; - default: - return "LOG"; + switch (level) { + case PROF_LEVEL_ERROR: + return "ERR"; + case PROF_LEVEL_WARN: + return "WRN"; + case PROF_LEVEL_INFO: + return "INF"; + case PROF_LEVEL_DEBUG: + return "DBG"; + default: + return "LOG"; } } void log_stderr_handler(void) { - GString * const s = stderr_msg; - char * const buf = stderr_buf; + GString* const s = stderr_msg; + char* const buf = stderr_buf; ssize_t size; int retry = 0; int i; @@ -835,7 +834,7 @@ log_stderr_init(log_level_t level) goto err_close; rc = log_stderr_nonblock_set(stderr_pipe[0]) - ?: log_stderr_nonblock_set(stderr_pipe[1]); + ?: log_stderr_nonblock_set(stderr_pipe[1]); if (rc != 0) goto err_close; diff --git a/src/log.h b/src/log.h index 3e29e8ca..ae3d5c6b 100644 --- a/src/log.h +++ b/src/log.h @@ -53,17 +53,17 @@ typedef enum { PROF_OUT_LOG } chat_log_direction_t; -void log_init(log_level_t filter, char *log_file); +void log_init(log_level_t filter, char* log_file); log_level_t log_get_filter(void); void log_close(void); void log_reinit(void); const char* get_log_file_location(void); -void log_debug(const char *const msg, ...); -void log_info(const char *const msg, ...); -void log_warning(const char *const msg, ...); -void log_error(const char *const msg, ...); -void log_msg(log_level_t level, const char *const area, const char *const msg); -log_level_t log_level_from_string(char *log_level); +void log_debug(const char* const msg, ...); +void log_info(const char* const msg, ...); +void log_warning(const char* const msg, ...); +void log_error(const char* const msg, ...); +void log_msg(log_level_t level, const char* const area, const char* const msg); +log_level_t log_level_from_string(char* log_level); void log_stderr_init(log_level_t level); void log_stderr_close(void); @@ -71,23 +71,23 @@ void log_stderr_handler(void); void chat_log_init(void); -void chat_log_msg_out(const char *const barejid, const char *const msg, const char *resource); -void chat_log_otr_msg_out(const char *const barejid, const char *const msg, const char *resource); -void chat_log_pgp_msg_out(const char *const barejid, const char *const msg, const char *resource); -void chat_log_omemo_msg_out(const char *const barejid, const char *const msg, const char *resource); +void chat_log_msg_out(const char* const barejid, const char* const msg, const char* resource); +void chat_log_otr_msg_out(const char* const barejid, const char* const msg, const char* resource); +void chat_log_pgp_msg_out(const char* const barejid, const char* const msg, const char* resource); +void chat_log_omemo_msg_out(const char* const barejid, const char* const msg, const char* resource); -void chat_log_msg_in(ProfMessage *message); -void chat_log_otr_msg_in(ProfMessage *message); -void chat_log_pgp_msg_in(ProfMessage *message); -void chat_log_omemo_msg_in(ProfMessage *message); +void chat_log_msg_in(ProfMessage* message); +void chat_log_otr_msg_in(ProfMessage* message); +void chat_log_pgp_msg_in(ProfMessage* message); +void chat_log_omemo_msg_in(ProfMessage* message); void chat_log_close(void); void groupchat_log_init(void); -void groupchat_log_msg_out(const gchar *const room, const gchar *const msg); -void groupchat_log_msg_in(const gchar *const room, const gchar *const nick, const gchar *const msg); -void groupchat_log_omemo_msg_out(const gchar *const room, const gchar *const msg); -void groupchat_log_omemo_msg_in(const gchar *const room, const gchar *const nick, const gchar *const msg); +void groupchat_log_msg_out(const gchar* const room, const gchar* const msg); +void groupchat_log_msg_in(const gchar* const room, const gchar* const nick, const gchar* const msg); +void groupchat_log_omemo_msg_out(const gchar* const room, const gchar* const msg); +void groupchat_log_omemo_msg_in(const gchar* const room, const gchar* const nick, const gchar* const msg); #endif diff --git a/src/main.c b/src/main.c index ef6dd26e..b7e2f6dd 100644 --- a/src/main.c +++ b/src/main.c @@ -60,22 +60,21 @@ #include "command/cmd_defs.h" static gboolean version = FALSE; -static char *log = NULL; -static char *log_file = NULL; -static char *account_name = NULL; -static char *config_file = NULL; -static char *theme_name = NULL; +static char* log = NULL; +static char* log_file = NULL; +static char* account_name = NULL; +static char* config_file = NULL; +static char* theme_name = NULL; int -main(int argc, char **argv) +main(int argc, char** argv) { if (argc == 2 && g_strcmp0(argv[1], "docgen") == 0 && g_strcmp0(PACKAGE_STATUS, "development") == 0) { command_docgen(); return 0; } - static GOptionEntry entries[] = - { + static GOptionEntry entries[] = { { "version", 'v', 0, G_OPTION_ARG_NONE, &version, "Show version information", NULL }, { "account", 'a', 0, G_OPTION_ARG_STRING, &account_name, "Auto connect to an account on startup" }, { "log", 'l', 0, G_OPTION_ARG_STRING, &log, "Set logging levels, DEBUG, INFO, WARN (default), ERROR", "LEVEL" }, @@ -85,8 +84,8 @@ main(int argc, char **argv) { NULL } }; - GError *error = NULL; - GOptionContext *context; + GError* error = NULL; + GOptionContext* context; context = g_option_context_new(NULL); g_option_context_add_main_entries(context, entries, NULL); @@ -135,14 +134,14 @@ main(int argc, char **argv) } #ifdef HAVE_LIBOTR - char *otr_version = otr_libotr_version(); + char* otr_version = otr_libotr_version(); g_print("OTR support: Enabled (libotr %s)\n", otr_version); #else g_print("OTR support: Disabled\n"); #endif #ifdef HAVE_LIBGPGME - const char *pgp_version = p_gpg_libver(); + const char* pgp_version = p_gpg_libver(); g_print("PGP support: Enabled (libgpgme %s)\n", pgp_version); #else g_print("PGP support: Disabled\n"); @@ -161,7 +160,7 @@ main(int argc, char **argv) #endif #ifdef HAVE_PYTHON - gchar *python_version = python_get_version_number(); + gchar* python_version = python_get_version_number(); g_print("Python plugins: Enabled (%s)\n", python_version); g_free(python_version); #else diff --git a/src/omemo/crypto.c b/src/omemo/crypto.c index d062e058..316f6f63 100644 --- a/src/omemo/crypto.c +++ b/src/omemo/crypto.c @@ -65,14 +65,14 @@ omemo_crypto_init(void) } int -omemo_random_func(uint8_t *data, size_t len, void *user_data) +omemo_random_func(uint8_t* data, size_t len, void* user_data) { gcry_randomize(data, len, GCRY_VERY_STRONG_RANDOM); return 0; } int -omemo_hmac_sha256_init_func(void **hmac_context, const uint8_t *key, size_t key_len, void *user_data) +omemo_hmac_sha256_init_func(void** hmac_context, const uint8_t* key, size_t key_len, void* user_data) { gcry_error_t res; gcry_mac_hd_t hd; @@ -94,7 +94,7 @@ omemo_hmac_sha256_init_func(void **hmac_context, const uint8_t *key, size_t key_ } int -omemo_hmac_sha256_update_func(void *hmac_context, const uint8_t *data, size_t data_len, void *user_data) +omemo_hmac_sha256_update_func(void* hmac_context, const uint8_t* data, size_t data_len, void* user_data) { gcry_error_t res; @@ -108,7 +108,7 @@ omemo_hmac_sha256_update_func(void *hmac_context, const uint8_t *data, size_t da } int -omemo_hmac_sha256_final_func(void *hmac_context, signal_buffer **output, void *user_data) +omemo_hmac_sha256_final_func(void* hmac_context, signal_buffer** output, void* user_data) { gcry_error_t res; size_t mac_len = 32; @@ -125,13 +125,13 @@ omemo_hmac_sha256_final_func(void *hmac_context, signal_buffer **output, void *u } void -omemo_hmac_sha256_cleanup_func(void *hmac_context, void *user_data) +omemo_hmac_sha256_cleanup_func(void* hmac_context, void* user_data) { gcry_mac_close(hmac_context); } int -omemo_sha512_digest_init_func(void **digest_context, void *user_data) +omemo_sha512_digest_init_func(void** digest_context, void* user_data) { gcry_error_t res; gcry_md_hd_t hd; @@ -148,7 +148,7 @@ omemo_sha512_digest_init_func(void **digest_context, void *user_data) } int -omemo_sha512_digest_update_func(void *digest_context, const uint8_t *data, size_t data_len, void *user_data) +omemo_sha512_digest_update_func(void* digest_context, const uint8_t* data, size_t data_len, void* user_data) { gcry_md_write(digest_context, data, data_len); @@ -156,7 +156,7 @@ omemo_sha512_digest_update_func(void *digest_context, const uint8_t *data, size_ } int -omemo_sha512_digest_final_func(void *digest_context, signal_buffer **output, void *user_data) +omemo_sha512_digest_final_func(void* digest_context, signal_buffer** output, void* user_data) { gcry_error_t res; unsigned char out[64]; @@ -172,37 +172,37 @@ omemo_sha512_digest_final_func(void *digest_context, signal_buffer **output, voi } void -omemo_sha512_digest_cleanup_func(void *digest_context, void *user_data) +omemo_sha512_digest_cleanup_func(void* digest_context, void* user_data) { gcry_md_close(digest_context); } int -omemo_encrypt_func(signal_buffer **output, int cipher, const uint8_t *key, size_t key_len, const uint8_t *iv, size_t iv_len, - const uint8_t *plaintext, size_t plaintext_len, void *user_data) +omemo_encrypt_func(signal_buffer** output, int cipher, const uint8_t* key, size_t key_len, const uint8_t* iv, size_t iv_len, + const uint8_t* plaintext, size_t plaintext_len, void* user_data) { gcry_cipher_hd_t hd; - unsigned char *padded_plaintext; - unsigned char *ciphertext; + unsigned char* padded_plaintext; + unsigned char* ciphertext; size_t ciphertext_len; int mode; int algo; uint8_t padding = 0; switch (key_len) { - case 32: - algo = GCRY_CIPHER_AES256; - break; - default: - return OMEMO_ERR_UNSUPPORTED_CRYPTO; + case 32: + algo = GCRY_CIPHER_AES256; + break; + default: + return OMEMO_ERR_UNSUPPORTED_CRYPTO; } switch (cipher) { - case SG_CIPHER_AES_CBC_PKCS5: - mode = GCRY_CIPHER_MODE_CBC; - break; - default: - return OMEMO_ERR_UNSUPPORTED_CRYPTO; + case SG_CIPHER_AES_CBC_PKCS5: + mode = GCRY_CIPHER_MODE_CBC; + break; + default: + return OMEMO_ERR_UNSUPPORTED_CRYPTO; } gcry_cipher_open(&hd, algo, mode, GCRY_CIPHER_SECURE); @@ -210,12 +210,12 @@ omemo_encrypt_func(signal_buffer **output, int cipher, const uint8_t *key, size_ gcry_cipher_setkey(hd, key, key_len); switch (cipher) { - case SG_CIPHER_AES_CBC_PKCS5: - gcry_cipher_setiv(hd, iv, iv_len); - padding = 16 - (plaintext_len % 16); - break; - default: - assert(FALSE); + case SG_CIPHER_AES_CBC_PKCS5: + gcry_cipher_setiv(hd, iv, iv_len); + padding = 16 - (plaintext_len % 16); + break; + default: + assert(FALSE); } padded_plaintext = malloc(plaintext_len + padding); @@ -236,31 +236,31 @@ omemo_encrypt_func(signal_buffer **output, int cipher, const uint8_t *key, size_ } int -omemo_decrypt_func(signal_buffer **output, int cipher, const uint8_t *key, size_t key_len, const uint8_t *iv, size_t iv_len, - const uint8_t *ciphertext, size_t ciphertext_len, void *user_data) +omemo_decrypt_func(signal_buffer** output, int cipher, const uint8_t* key, size_t key_len, const uint8_t* iv, size_t iv_len, + const uint8_t* ciphertext, size_t ciphertext_len, void* user_data) { int ret = SG_SUCCESS; gcry_cipher_hd_t hd; - unsigned char *plaintext; + unsigned char* plaintext; size_t plaintext_len; int mode; int algo; uint8_t padding = 0; switch (key_len) { - case 32: - algo = GCRY_CIPHER_AES256; - break; - default: - return OMEMO_ERR_UNSUPPORTED_CRYPTO; + case 32: + algo = GCRY_CIPHER_AES256; + break; + default: + return OMEMO_ERR_UNSUPPORTED_CRYPTO; } switch (cipher) { - case SG_CIPHER_AES_CBC_PKCS5: - mode = GCRY_CIPHER_MODE_CBC; - break; - default: - return OMEMO_ERR_UNSUPPORTED_CRYPTO; + case SG_CIPHER_AES_CBC_PKCS5: + mode = GCRY_CIPHER_MODE_CBC; + break; + default: + return OMEMO_ERR_UNSUPPORTED_CRYPTO; } gcry_cipher_open(&hd, algo, mode, GCRY_CIPHER_SECURE); @@ -268,11 +268,11 @@ omemo_decrypt_func(signal_buffer **output, int cipher, const uint8_t *key, size_ gcry_cipher_setkey(hd, key, key_len); switch (cipher) { - case SG_CIPHER_AES_CBC_PKCS5: - gcry_cipher_setiv(hd, iv, iv_len); - break; - default: - assert(FALSE); + case SG_CIPHER_AES_CBC_PKCS5: + gcry_cipher_setiv(hd, iv, iv_len); + break; + default: + assert(FALSE); } plaintext_len = ciphertext_len; @@ -280,11 +280,11 @@ omemo_decrypt_func(signal_buffer **output, int cipher, const uint8_t *key, size_ gcry_cipher_decrypt(hd, plaintext, plaintext_len, ciphertext, ciphertext_len); switch (cipher) { - case SG_CIPHER_AES_CBC_PKCS5: - padding = plaintext[plaintext_len - 1]; - break; - default: - assert(FALSE); + case SG_CIPHER_AES_CBC_PKCS5: + padding = plaintext[plaintext_len - 1]; + break; + default: + assert(FALSE); } int i; @@ -306,7 +306,7 @@ out: } int -aes128gcm_encrypt(unsigned char *ciphertext, size_t *ciphertext_len, unsigned char *tag, size_t *tag_len, const unsigned char *const plaintext, size_t plaintext_len, const unsigned char *const iv, const unsigned char *const key) +aes128gcm_encrypt(unsigned char* ciphertext, size_t* ciphertext_len, unsigned char* tag, size_t* tag_len, const unsigned char* const plaintext, size_t plaintext_len, const unsigned char* const iv, const unsigned char* const key) { gcry_error_t res; gcry_cipher_hd_t hd; @@ -340,7 +340,7 @@ out: } int -aes128gcm_decrypt(unsigned char *plaintext, size_t *plaintext_len, const unsigned char *const ciphertext, size_t ciphertext_len, const unsigned char *const iv, size_t iv_len, const unsigned char *const key, const unsigned char *const tag) +aes128gcm_decrypt(unsigned char* plaintext, size_t* plaintext_len, const unsigned char* const ciphertext, size_t ciphertext_len, const unsigned char* const iv, size_t iv_len, const unsigned char* const key, const unsigned char* const tag) { gcry_error_t res; gcry_cipher_hd_t hd; diff --git a/src/omemo/crypto.h b/src/omemo/crypto.h index d0cfdd05..4fb6283e 100644 --- a/src/omemo/crypto.h +++ b/src/omemo/crypto.h @@ -35,7 +35,7 @@ #include <signal/signal_protocol_types.h> #define AES128_GCM_KEY_LENGTH 16 -#define AES128_GCM_IV_LENGTH 12 +#define AES128_GCM_IV_LENGTH 12 #define AES128_GCM_TAG_LENGTH 16 int omemo_crypto_init(void); @@ -47,7 +47,7 @@ int omemo_crypto_init(void); * @param len size of the output buffer * @return 0 on success, negative on failure */ -int omemo_random_func(uint8_t *data, size_t len, void *user_data); +int omemo_random_func(uint8_t* data, size_t len, void* user_data); /** * Callback for an HMAC-SHA256 implementation. @@ -58,7 +58,7 @@ int omemo_random_func(uint8_t *data, size_t len, void *user_data); * @param key_len length of the key * @return 0 on success, negative on failure */ -int omemo_hmac_sha256_init_func(void **hmac_context, const uint8_t *key, size_t key_len, void *user_data); +int omemo_hmac_sha256_init_func(void** hmac_context, const uint8_t* key, size_t key_len, void* user_data); /** * Callback for an HMAC-SHA256 implementation. @@ -69,7 +69,7 @@ int omemo_hmac_sha256_init_func(void **hmac_context, const uint8_t *key, size_t * @param data_len length of the data * @return 0 on success, negative on failure */ -int omemo_hmac_sha256_update_func(void *hmac_context, const uint8_t *data, size_t data_len, void *user_data); +int omemo_hmac_sha256_update_func(void* hmac_context, const uint8_t* data, size_t data_len, void* user_data); /** * Callback for an HMAC-SHA256 implementation. @@ -80,7 +80,7 @@ int omemo_hmac_sha256_update_func(void *hmac_context, const uint8_t *data, size_ * @param output buffer to be allocated and populated with the result * @return 0 on success, negative on failure */ -int omemo_hmac_sha256_final_func(void *hmac_context, signal_buffer **output, void *user_data); +int omemo_hmac_sha256_final_func(void* hmac_context, signal_buffer** output, void* user_data); /** * Callback for an HMAC-SHA256 implementation. @@ -89,7 +89,7 @@ int omemo_hmac_sha256_final_func(void *hmac_context, signal_buffer **output, voi * * @param hmac_context private HMAC context pointer */ -void omemo_hmac_sha256_cleanup_func(void *hmac_context, void *user_data); +void omemo_hmac_sha256_cleanup_func(void* hmac_context, void* user_data); /** * Callback for a SHA512 message digest implementation. @@ -98,7 +98,7 @@ void omemo_hmac_sha256_cleanup_func(void *hmac_context, void *user_data); * @param digest_context private digest context pointer * @return 0 on success, negative on failure */ -int omemo_sha512_digest_init_func(void **digest_context, void *user_data); +int omemo_sha512_digest_init_func(void** digest_context, void* user_data); /** * Callback for a SHA512 message digest implementation. @@ -109,7 +109,7 @@ int omemo_sha512_digest_init_func(void **digest_context, void *user_data); * @param data_len length of the data * @return 0 on success, negative on failure */ -int omemo_sha512_digest_update_func(void *digest_context, const uint8_t *data, size_t data_len, void *user_data); +int omemo_sha512_digest_update_func(void* digest_context, const uint8_t* data, size_t data_len, void* user_data); /** * Callback for a SHA512 message digest implementation. @@ -120,7 +120,7 @@ int omemo_sha512_digest_update_func(void *digest_context, const uint8_t *data, s * @param output buffer to be allocated and populated with the result * @return 0 on success, negative on failure */ -int omemo_sha512_digest_final_func(void *digest_context, signal_buffer **output, void *user_data); +int omemo_sha512_digest_final_func(void* digest_context, signal_buffer** output, void* user_data); /** * Callback for a SHA512 message digest implementation. @@ -129,7 +129,7 @@ int omemo_sha512_digest_final_func(void *digest_context, signal_buffer **output, * * @param digest_context private digest context pointer */ -void omemo_sha512_digest_cleanup_func(void *digest_context, void *user_data); +void omemo_sha512_digest_cleanup_func(void* digest_context, void* user_data); /** * Callback for an AES encryption implementation. @@ -144,12 +144,12 @@ void omemo_sha512_digest_cleanup_func(void *digest_context, void *user_data); * @param plaintext_len length of the plaintext * @return 0 on success, negative on failure */ -int omemo_encrypt_func(signal_buffer **output, - int cipher, - const uint8_t *key, size_t key_len, - const uint8_t *iv, size_t iv_len, - const uint8_t *plaintext, size_t plaintext_len, - void *user_data); +int omemo_encrypt_func(signal_buffer** output, + int cipher, + const uint8_t* key, size_t key_len, + const uint8_t* iv, size_t iv_len, + const uint8_t* plaintext, size_t plaintext_len, + void* user_data); /** * Callback for an AES decryption implementation. @@ -164,19 +164,19 @@ int omemo_encrypt_func(signal_buffer **output, * @param ciphertext_len length of the ciphertext * @return 0 on success, negative on failure */ -int omemo_decrypt_func(signal_buffer **output, - int cipher, - const uint8_t *key, size_t key_len, - const uint8_t *iv, size_t iv_len, - const uint8_t *ciphertext, size_t ciphertext_len, - void *user_data); +int omemo_decrypt_func(signal_buffer** output, + int cipher, + const uint8_t* key, size_t key_len, + const uint8_t* iv, size_t iv_len, + const uint8_t* ciphertext, size_t ciphertext_len, + void* user_data); -int aes128gcm_encrypt(unsigned char *ciphertext, size_t *ciphertext_len, - unsigned char *tag, size_t *tag_len, - const unsigned char *const plaintext, size_t plaintext_len, - const unsigned char *const iv, const unsigned char *const key); +int aes128gcm_encrypt(unsigned char* ciphertext, size_t* ciphertext_len, + unsigned char* tag, size_t* tag_len, + const unsigned char* const plaintext, size_t plaintext_len, + const unsigned char* const iv, const unsigned char* const key); -int aes128gcm_decrypt(unsigned char *plaintext, - size_t *plaintext_len, const unsigned char *const ciphertext, - size_t ciphertext_len, const unsigned char *const iv, size_t iv_len, - const unsigned char *const key, const unsigned char *const tag); +int aes128gcm_decrypt(unsigned char* plaintext, + size_t* plaintext_len, const unsigned char* const ciphertext, + size_t ciphertext_len, const unsigned char* const iv, size_t iv_len, + const unsigned char* const key, const unsigned char* const tag); diff --git a/src/omemo/omemo.c b/src/omemo/omemo.c index 09782d66..997eddae 100644 --- a/src/omemo/omemo.c +++ b/src/omemo/omemo.c @@ -70,44 +70,45 @@ static gboolean _load_identity(void); static void _load_trust(void); static void _load_sessions(void); static void _load_known_devices(void); -static void _lock(void *user_data); -static void _unlock(void *user_data); -static void _omemo_log(int level, const char *message, size_t len, void *user_data); -static gboolean _handle_own_device_list(const char *const jid, GList *device_list); -static gboolean _handle_device_list_start_session(const char *const jid, GList *device_list); -static char * _omemo_fingerprint(ec_public_key *identity, gboolean formatted); -static unsigned char *_omemo_fingerprint_decode(const char *const fingerprint, size_t *len); -static char * _omemo_unformat_fingerprint(const char *const fingerprint_formatted); -static void _cache_device_identity(const char *const jid, uint32_t device_id, ec_public_key *identity); -static void _g_hash_table_free(GHashTable *hash_table); - -typedef gboolean (*OmemoDeviceListHandler)(const char *const jid, GList *device_list); - -struct omemo_context_t { +static void _lock(void* user_data); +static void _unlock(void* user_data); +static void _omemo_log(int level, const char* message, size_t len, void* user_data); +static gboolean _handle_own_device_list(const char* const jid, GList* device_list); +static gboolean _handle_device_list_start_session(const char* const jid, GList* device_list); +static char* _omemo_fingerprint(ec_public_key* identity, gboolean formatted); +static unsigned char* _omemo_fingerprint_decode(const char* const fingerprint, size_t* len); +static char* _omemo_unformat_fingerprint(const char* const fingerprint_formatted); +static void _cache_device_identity(const char* const jid, uint32_t device_id, ec_public_key* identity); +static void _g_hash_table_free(GHashTable* hash_table); + +typedef gboolean (*OmemoDeviceListHandler)(const char* const jid, GList* device_list); + +struct omemo_context_t +{ pthread_mutexattr_t attr; pthread_mutex_t lock; - signal_context *signal; + signal_context* signal; uint32_t device_id; - GHashTable *device_list; - GHashTable *device_list_handler; - ratchet_identity_key_pair *identity_key_pair; + GHashTable* device_list; + GHashTable* device_list_handler; + ratchet_identity_key_pair* identity_key_pair; uint32_t registration_id; uint32_t signed_pre_key_id; - signal_protocol_store_context *store; - GHashTable *session_store; - GHashTable *pre_key_store; - GHashTable *signed_pre_key_store; + signal_protocol_store_context* store; + GHashTable* session_store; + GHashTable* pre_key_store; + GHashTable* signed_pre_key_store; identity_key_store_t identity_key_store; - GString *identity_filename; - GKeyFile *identity_keyfile; - GString *trust_filename; - GKeyFile *trust_keyfile; - GString *sessions_filename; - GKeyFile *sessions_keyfile; - GHashTable *known_devices; - GString *known_devices_filename; - GKeyFile *known_devices_keyfile; - GHashTable *fingerprint_ac; + GString* identity_filename; + GKeyFile* identity_keyfile; + GString* trust_filename; + GKeyFile* trust_keyfile; + GString* sessions_filename; + GKeyFile* sessions_keyfile; + GHashTable* known_devices; + GString* known_devices_filename; + GKeyFile* known_devices_keyfile; + GHashTable* fingerprint_ac; }; static omemo_context omemo_ctx; @@ -137,9 +138,9 @@ omemo_close(void) } void -omemo_on_connect(ProfAccount *account) +omemo_on_connect(ProfAccount* account) { - GError *error = NULL; + GError* error = NULL; if (signal_context_create(&omemo_ctx.signal, &omemo_ctx) != 0) { cons_show("Error initializing OMEMO context"); @@ -220,13 +221,12 @@ omemo_on_connect(ProfAccount *account) }; signal_protocol_store_context_set_identity_key_store(omemo_ctx.store, &identity_key_store); - loaded = FALSE; omemo_ctx.device_list = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)g_list_free); omemo_ctx.device_list_handler = g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL); omemo_ctx.known_devices = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)_g_hash_table_free); - gchar *omemo_dir = files_get_account_data_path(DIR_OMEMO, account->jid); + gchar* omemo_dir = files_get_account_data_path(DIR_OMEMO, account->jid); omemo_ctx.identity_filename = g_string_new(omemo_dir); g_string_append(omemo_ctx.identity_filename, "/identity.txt"); @@ -237,11 +237,10 @@ omemo_on_connect(ProfAccount *account) omemo_ctx.known_devices_filename = g_string_new(omemo_dir); g_string_append(omemo_ctx.known_devices_filename, "/known_devices.txt"); - errno = 0; int res = g_mkdir_with_parents(omemo_dir, S_IRWXU); if (res == -1) { - char *errmsg = strerror(errno); + char* errmsg = strerror(errno); if (errmsg) { log_error("OMEMO: error creating directory: %s, %s", omemo_dir, errmsg); } else { @@ -312,7 +311,7 @@ omemo_on_disconnect(void) } void -omemo_generate_crypto_materials(ProfAccount *account) +omemo_generate_crypto_materials(ProfAccount* account) { if (loaded) { return; @@ -330,12 +329,12 @@ omemo_generate_crypto_materials(ProfAccount *account) signal_protocol_key_helper_generate_identity_key_pair(&omemo_ctx.identity_key_pair, omemo_ctx.signal); ec_public_key_serialize(&omemo_ctx.identity_key_store.public, ratchet_identity_key_pair_get_public(omemo_ctx.identity_key_pair)); - char *identity_key_public = g_base64_encode(signal_buffer_data(omemo_ctx.identity_key_store.public), signal_buffer_len(omemo_ctx.identity_key_store.public)); + char* identity_key_public = g_base64_encode(signal_buffer_data(omemo_ctx.identity_key_store.public), signal_buffer_len(omemo_ctx.identity_key_store.public)); g_key_file_set_string(omemo_ctx.identity_keyfile, OMEMO_STORE_GROUP_IDENTITY, OMEMO_STORE_KEY_IDENTITY_KEY_PUBLIC, identity_key_public); g_free(identity_key_public); ec_private_key_serialize(&omemo_ctx.identity_key_store.private, ratchet_identity_key_pair_get_private(omemo_ctx.identity_key_pair)); - char *identity_key_private = g_base64_encode(signal_buffer_data(omemo_ctx.identity_key_store.private), signal_buffer_len(omemo_ctx.identity_key_store.private)); + char* identity_key_private = g_base64_encode(signal_buffer_data(omemo_ctx.identity_key_store.private), signal_buffer_len(omemo_ctx.identity_key_store.private)); g_key_file_set_string(omemo_ctx.identity_keyfile, OMEMO_STORE_GROUP_IDENTITY, OMEMO_STORE_KEY_IDENTITY_KEY_PRIVATE, identity_key_private); g_free(identity_key_private); @@ -365,7 +364,7 @@ omemo_publish_crypto_materials(void) return; } - char *barejid = connection_get_barejid(); + char* barejid = connection_get_barejid(); /* Ensure we get our current device list, and it gets updated with our * device_id */ @@ -380,12 +379,12 @@ omemo_publish_crypto_materials(void) void omemo_start_sessions(void) { - GSList *contacts = roster_get_contacts(ROSTER_ORD_NAME); + GSList* contacts = roster_get_contacts(ROSTER_ORD_NAME); if (contacts) { - GSList *curr; - for (curr = contacts; curr != NULL; curr = g_slist_next(curr)){ + GSList* curr; + for (curr = contacts; curr != NULL; curr = g_slist_next(curr)) { PContact contact = curr->data; - const char *jid = p_contact_barejid(contact); + const char* jid = p_contact_barejid(contact); omemo_start_session(jid); } g_slist_free(contacts); @@ -393,11 +392,11 @@ omemo_start_sessions(void) } void -omemo_start_session(const char *const barejid) +omemo_start_session(const char* const barejid) { - if( omemo_loaded() ) { + if (omemo_loaded()) { log_info("OMEMO: start session with %s", barejid); - GList *device_list = g_hash_table_lookup(omemo_ctx.device_list, barejid); + GList* device_list = g_hash_table_lookup(omemo_ctx.device_list, barejid); if (!device_list) { log_info("OMEMO: missing device list for %s", barejid); omemo_devicelist_request(barejid); @@ -405,7 +404,7 @@ omemo_start_session(const char *const barejid) return; } - GList *device_id; + GList* device_id; for (device_id = device_list; device_id != NULL; device_id = device_id->next) { omemo_bundle_request(barejid, GPOINTER_TO_INT(device_id->data), omemo_start_device_session_handle_bundle, free, strdup(barejid)); } @@ -413,12 +412,12 @@ omemo_start_session(const char *const barejid) } void -omemo_start_muc_sessions(const char *const roomjid) +omemo_start_muc_sessions(const char* const roomjid) { - GList *members = muc_members(roomjid); - GList *iter; + GList* members = muc_members(roomjid); + GList* iter; for (iter = members; iter != NULL; iter = iter->next) { - Jid *jid = jid_create(iter->data); + Jid* jid = jid_create(iter->data); omemo_start_session(jid->barejid); jid_destroy(jid); } @@ -438,9 +437,9 @@ omemo_device_id(void) } void -omemo_identity_key(unsigned char **output, size_t *length) +omemo_identity_key(unsigned char** output, size_t* length) { - signal_buffer *buffer = NULL; + signal_buffer* buffer = NULL; ec_public_key_serialize(&buffer, ratchet_identity_key_pair_get_public(omemo_ctx.identity_key_pair)); *length = signal_buffer_len(buffer); *output = malloc(*length); @@ -449,10 +448,10 @@ omemo_identity_key(unsigned char **output, size_t *length) } void -omemo_signed_prekey(unsigned char **output, size_t *length) +omemo_signed_prekey(unsigned char** output, size_t* length) { - session_signed_pre_key *signed_pre_key; - signal_buffer *buffer = NULL; + session_signed_pre_key* signed_pre_key; + signal_buffer* buffer = NULL; if (signal_protocol_signed_pre_key_load_key(omemo_ctx.store, &signed_pre_key, omemo_ctx.signed_pre_key_id) != SG_SUCCESS) { *output = NULL; @@ -469,9 +468,9 @@ omemo_signed_prekey(unsigned char **output, size_t *length) } void -omemo_signed_prekey_signature(unsigned char **output, size_t *length) +omemo_signed_prekey_signature(unsigned char** output, size_t* length) { - session_signed_pre_key *signed_pre_key; + session_signed_pre_key* signed_pre_key; if (signal_protocol_signed_pre_key_load_key(omemo_ctx.store, &signed_pre_key, omemo_ctx.signed_pre_key_id) != SG_SUCCESS) { *output = NULL; @@ -486,25 +485,25 @@ omemo_signed_prekey_signature(unsigned char **output, size_t *length) } void -omemo_prekeys(GList **prekeys, GList **ids, GList **lengths) +omemo_prekeys(GList** prekeys, GList** ids, GList** lengths) { GHashTableIter iter; gpointer id; g_hash_table_iter_init(&iter, omemo_ctx.pre_key_store); while (g_hash_table_iter_next(&iter, &id, NULL)) { - session_pre_key *pre_key; + session_pre_key* pre_key; int ret; ret = signal_protocol_pre_key_load_key(omemo_ctx.store, &pre_key, GPOINTER_TO_INT(id)); if (ret != SG_SUCCESS) { continue; } - signal_buffer *public_key; + signal_buffer* public_key; ec_public_key_serialize(&public_key, ec_key_pair_get_public(session_pre_key_get_key_pair(pre_key))); SIGNAL_UNREF(pre_key); size_t length = signal_buffer_len(public_key); - unsigned char *prekey_value = malloc(length); + unsigned char* prekey_value = malloc(length); memcpy(prekey_value, signal_buffer_data(public_key), length); signal_buffer_free(public_key); @@ -515,9 +514,9 @@ omemo_prekeys(GList **prekeys, GList **ids, GList **lengths) } void -omemo_set_device_list(const char *const from, GList * device_list) +omemo_set_device_list(const char* const from, GList* device_list) { - Jid *jid; + Jid* jid; if (from) { jid = jid_create(from); } else { @@ -537,7 +536,7 @@ omemo_set_device_list(const char *const from, GList * device_list) jid_destroy(jid); } -GKeyFile * +GKeyFile* omemo_identity_keyfile(void) { return omemo_ctx.identity_keyfile; @@ -546,14 +545,14 @@ omemo_identity_keyfile(void) void omemo_identity_keyfile_save(void) { - GError *error = NULL; + GError* error = NULL; if (!g_key_file_save_to_file(omemo_ctx.identity_keyfile, omemo_ctx.identity_filename->str, &error)) { log_error("OMEMO: error saving identity to: %s, %s", omemo_ctx.identity_filename->str, error->message); } } -GKeyFile * +GKeyFile* omemo_trust_keyfile(void) { return omemo_ctx.trust_keyfile; @@ -562,14 +561,14 @@ omemo_trust_keyfile(void) void omemo_trust_keyfile_save(void) { - GError *error = NULL; + GError* error = NULL; if (!g_key_file_save_to_file(omemo_ctx.trust_keyfile, omemo_ctx.trust_filename->str, &error)) { log_error("OMEMO: error saving trust to: %s, %s", omemo_ctx.trust_filename->str, error->message); } } -GKeyFile * +GKeyFile* omemo_sessions_keyfile(void) { return omemo_ctx.sessions_keyfile; @@ -578,7 +577,7 @@ omemo_sessions_keyfile(void) void omemo_sessions_keyfile_save(void) { - GError *error = NULL; + GError* error = NULL; if (!g_key_file_save_to_file(omemo_ctx.sessions_keyfile, omemo_ctx.sessions_filename->str, &error)) { log_error("OMEMO: error saving sessions to: %s, %s", omemo_ctx.sessions_filename->str, error->message); @@ -588,7 +587,7 @@ omemo_sessions_keyfile_save(void) void omemo_known_devices_keyfile_save(void) { - GError *error = NULL; + GError* error = NULL; if (!g_key_file_save_to_file(omemo_ctx.known_devices_keyfile, omemo_ctx.known_devices_filename->str, &error)) { log_error("OMEMO: error saving known devices to: %s, %s", omemo_ctx.known_devices_filename->str, error->message); @@ -596,11 +595,11 @@ omemo_known_devices_keyfile_save(void) } void -omemo_start_device_session(const char *const jid, uint32_t device_id, - GList *prekeys, uint32_t signed_prekey_id, - const unsigned char *const signed_prekey_raw, size_t signed_prekey_len, - const unsigned char *const signature, size_t signature_len, - const unsigned char *const identity_key_raw, size_t identity_key_len) +omemo_start_device_session(const char* const jid, uint32_t device_id, + GList* prekeys, uint32_t signed_prekey_id, + const unsigned char* const signed_prekey_raw, size_t signed_prekey_len, + const unsigned char* const signature, size_t signature_len, + const unsigned char* const identity_key_raw, size_t identity_key_len) { signal_protocol_address address = { .name = jid, @@ -608,11 +607,11 @@ omemo_start_device_session(const char *const jid, uint32_t device_id, .device_id = device_id, }; - ec_public_key *identity_key; + ec_public_key* identity_key; curve_decode_point(&identity_key, identity_key_raw, identity_key_len, omemo_ctx.signal); _cache_device_identity(jid, device_id, identity_key); - gboolean trusted = is_trusted_identity(&address, (uint8_t *)identity_key_raw, identity_key_len, &omemo_ctx.identity_key_store); + gboolean trusted = is_trusted_identity(&address, (uint8_t*)identity_key_raw, identity_key_len, &omemo_ctx.identity_key_store); if (!trusted) { goto out; @@ -620,15 +619,15 @@ omemo_start_device_session(const char *const jid, uint32_t device_id, if (!contains_session(&address, omemo_ctx.session_store)) { int res; - session_pre_key_bundle *bundle; - signal_protocol_address *address; + session_pre_key_bundle* bundle; + signal_protocol_address* address; address = malloc(sizeof(signal_protocol_address)); address->name = strdup(jid); address->name_len = strlen(jid); address->device_id = device_id; - session_builder *builder; + session_builder* builder; res = session_builder_create(&builder, omemo_ctx.store, address, omemo_ctx.signal); if (res != 0) { log_error("OMEMO: cannot create session builder for %s device %d", jid, device_id); @@ -638,11 +637,11 @@ omemo_start_device_session(const char *const jid, uint32_t device_id, int prekey_index; gcry_randomize(&prekey_index, sizeof(int), GCRY_STRONG_RANDOM); prekey_index %= g_list_length(prekeys); - omemo_key_t *prekey = g_list_nth_data(prekeys, prekey_index); + omemo_key_t* prekey = g_list_nth_data(prekeys, prekey_index); - ec_public_key *prekey_public; + ec_public_key* prekey_public; curve_decode_point(&prekey_public, prekey->data, prekey->length, omemo_ctx.signal); - ec_public_key *signed_prekey; + ec_public_key* signed_prekey; curve_decode_point(&signed_prekey, signed_prekey_raw, signed_prekey_len, omemo_ctx.signal); res = session_pre_key_bundle_create(&bundle, 0, device_id, prekey->id, prekey_public, signed_prekey_id, signed_prekey, signature, signature_len, identity_key); @@ -664,19 +663,19 @@ out: SIGNAL_UNREF(identity_key); } -char * -omemo_on_message_send(ProfWin *win, const char *const message, gboolean request_receipt, gboolean muc, const char *const replace_id) +char* +omemo_on_message_send(ProfWin* win, const char* const message, gboolean request_receipt, gboolean muc, const char* const replace_id) { - char *id = NULL; + char* id = NULL; int res; - Jid *jid = jid_create(connection_get_fulljid()); - GList *keys = NULL; - - unsigned char *key; - unsigned char *iv; - unsigned char *ciphertext; - unsigned char *tag; - unsigned char *key_tag; + Jid* jid = jid_create(connection_get_fulljid()); + GList* keys = NULL; + + unsigned char* key; + unsigned char* iv; + unsigned char* ciphertext; + unsigned char* tag; + unsigned char* key_tag; size_t ciphertext_len, tag_len; ciphertext_len = strlen(message); @@ -688,7 +687,7 @@ omemo_on_message_send(ProfWin *win, const char *const message, gboolean request_ key = gcry_random_bytes_secure(AES128_GCM_KEY_LENGTH, GCRY_VERY_STRONG_RANDOM); iv = gcry_random_bytes_secure(AES128_GCM_IV_LENGTH, GCRY_VERY_STRONG_RANDOM); - res = aes128gcm_encrypt(ciphertext, &ciphertext_len, tag, &tag_len, (const unsigned char * const)message, strlen(message), iv, key); + res = aes128gcm_encrypt(ciphertext, &ciphertext_len, tag, &tag_len, (const unsigned char* const)message, strlen(message), iv, key); if (res != 0) { log_error("OMEMO: cannot encrypt message"); goto out; @@ -697,31 +696,31 @@ omemo_on_message_send(ProfWin *win, const char *const message, gboolean request_ memcpy(key_tag, key, AES128_GCM_KEY_LENGTH); memcpy(key_tag + AES128_GCM_KEY_LENGTH, tag, AES128_GCM_TAG_LENGTH); - GList *recipients = NULL; + GList* recipients = NULL; if (muc) { - ProfMucWin *mucwin = (ProfMucWin *)win; + ProfMucWin* mucwin = (ProfMucWin*)win; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); - GList *members = muc_members(mucwin->roomjid); - GList *iter; + GList* members = muc_members(mucwin->roomjid); + GList* iter; for (iter = members; iter != NULL; iter = iter->next) { - Jid *jid = jid_create(iter->data); + Jid* jid = jid_create(iter->data); recipients = g_list_append(recipients, strdup(jid->barejid)); jid_destroy(jid); } g_list_free(members); } else { - ProfChatWin *chatwin = (ProfChatWin *)win; + ProfChatWin* chatwin = (ProfChatWin*)win; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); recipients = g_list_append(recipients, strdup(chatwin->barejid)); } - GList *device_ids_iter; + GList* device_ids_iter; omemo_ctx.identity_key_store.recv = false; - GList *recipients_iter; + GList* recipients_iter; for (recipients_iter = recipients; recipients_iter != NULL; recipients_iter = recipients_iter->next) { - GList *recipient_device_id = NULL; + GList* recipient_device_id = NULL; recipient_device_id = g_hash_table_lookup(omemo_ctx.device_list, recipients_iter->data); if (!recipient_device_id) { log_warning("OMEMO: cannot find device ids for %s", recipients_iter->data); @@ -730,8 +729,8 @@ omemo_on_message_send(ProfWin *win, const char *const message, gboolean request_ for (device_ids_iter = recipient_device_id; device_ids_iter != NULL; device_ids_iter = device_ids_iter->next) { int res; - ciphertext_message *ciphertext; - session_cipher *cipher; + ciphertext_message* ciphertext; + session_cipher* cipher; signal_protocol_address address = { .name = recipients_iter->data, .name_len = strlen(recipients_iter->data), @@ -750,8 +749,8 @@ omemo_on_message_send(ProfWin *win, const char *const message, gboolean request_ log_error("OMEMO: cannot encrypt key for %s device id %d", address.name, address.device_id); continue; } - signal_buffer *buffer = ciphertext_message_get_serialized(ciphertext); - omemo_key_t *key = malloc(sizeof(omemo_key_t)); + signal_buffer* buffer = ciphertext_message_get_serialized(ciphertext); + omemo_key_t* key = malloc(sizeof(omemo_key_t)); key->length = signal_buffer_len(buffer); key->data = malloc(key->length); memcpy(key->data, signal_buffer_data(buffer), key->length); @@ -765,11 +764,11 @@ omemo_on_message_send(ProfWin *win, const char *const message, gboolean request_ g_list_free_full(recipients, free); if (!muc) { - GList *sender_device_id = g_hash_table_lookup(omemo_ctx.device_list, jid->barejid); + GList* sender_device_id = g_hash_table_lookup(omemo_ctx.device_list, jid->barejid); for (device_ids_iter = sender_device_id; device_ids_iter != NULL; device_ids_iter = device_ids_iter->next) { int res; - ciphertext_message *ciphertext; - session_cipher *cipher; + ciphertext_message* ciphertext; + session_cipher* cipher; signal_protocol_address address = { .name = jid->barejid, .name_len = strlen(jid->barejid), @@ -788,8 +787,8 @@ omemo_on_message_send(ProfWin *win, const char *const message, gboolean request_ log_error("OMEMO: cannot encrypt key for %s device id %d", address.name, address.device_id); continue; } - signal_buffer *buffer = ciphertext_message_get_serialized(ciphertext); - omemo_key_t *key = malloc(sizeof(omemo_key_t)); + signal_buffer* buffer = ciphertext_message_get_serialized(ciphertext); + omemo_key_t* key = malloc(sizeof(omemo_key_t)); key->length = signal_buffer_len(buffer); key->data = malloc(key->length); memcpy(key->data, signal_buffer_data(buffer), key->length); @@ -801,11 +800,11 @@ omemo_on_message_send(ProfWin *win, const char *const message, gboolean request_ } if (muc) { - ProfMucWin *mucwin = (ProfMucWin *)win; + ProfMucWin* mucwin = (ProfMucWin*)win; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); id = message_send_chat_omemo(mucwin->roomjid, omemo_ctx.device_id, keys, iv, AES128_GCM_IV_LENGTH, ciphertext, ciphertext_len, request_receipt, TRUE, replace_id); } else { - ProfChatWin *chatwin = (ProfChatWin *)win; + ProfChatWin* chatwin = (ProfChatWin*)win; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); id = message_send_chat_omemo(chatwin->barejid, omemo_ctx.device_id, keys, iv, AES128_GCM_IV_LENGTH, ciphertext, ciphertext_len, request_receipt, FALSE, replace_id); } @@ -822,24 +821,24 @@ out: return id; } -char * -omemo_on_message_recv(const char *const from_jid, uint32_t sid, - const unsigned char *const iv, size_t iv_len, GList *keys, - const unsigned char *const payload, size_t payload_len, gboolean muc, gboolean *trusted) +char* +omemo_on_message_recv(const char* const from_jid, uint32_t sid, + const unsigned char* const iv, size_t iv_len, GList* keys, + const unsigned char* const payload, size_t payload_len, gboolean muc, gboolean* trusted) { - unsigned char *plaintext = NULL; - Jid *sender = NULL; - Jid *from = jid_create(from_jid); + unsigned char* plaintext = NULL; + Jid* sender = NULL; + Jid* from = jid_create(from_jid); if (!from) { log_error("Invalid jid %s", from_jid); goto out; } int res; - GList *key_iter; - omemo_key_t *key = NULL; + GList* key_iter; + omemo_key_t* key = NULL; for (key_iter = keys; key_iter != NULL; key_iter = key_iter->next) { - if (((omemo_key_t *)key_iter->data)->device_id == omemo_ctx.device_id) { + if (((omemo_key_t*)key_iter->data)->device_id == omemo_ctx.device_id) { key = key_iter->data; break; } @@ -851,10 +850,10 @@ omemo_on_message_recv(const char *const from_jid, uint32_t sid, } if (muc) { - GList *roster = muc_roster(from->barejid); - GList *iter; + GList* roster = muc_roster(from->barejid); + GList* iter; for (iter = roster; iter != NULL; iter = iter->next) { - Occupant *occupant = (Occupant *)iter->data; + Occupant* occupant = (Occupant*)iter->data; if (g_strcmp0(occupant->nick, from->resourcepart) == 0) { sender = jid_create(occupant->jid); break; @@ -869,8 +868,8 @@ omemo_on_message_recv(const char *const from_jid, uint32_t sid, sender = jid_create(from->barejid); } - session_cipher *cipher; - signal_buffer *plaintext_key; + session_cipher* cipher; + signal_buffer* plaintext_key; signal_protocol_address address = { .name = sender->barejid, .name_len = strlen(sender->barejid), @@ -885,9 +884,9 @@ omemo_on_message_recv(const char *const from_jid, uint32_t sid, if (key->prekey) { log_debug("OMEMO: decrypting message with prekey"); - pre_key_signal_message *message; - ec_public_key *their_identity_key; - signal_buffer *identity_buffer = NULL; + pre_key_signal_message* message; + ec_public_key* their_identity_key; + signal_buffer* identity_buffer = NULL; omemo_ctx.identity_key_store.recv = true; @@ -901,12 +900,12 @@ omemo_on_message_recv(const char *const from_jid, uint32_t sid, /* Perform a real check of the identity */ ec_public_key_serialize(&identity_buffer, their_identity_key); *trusted = is_trusted_identity(&address, signal_buffer_data(identity_buffer), - signal_buffer_len(identity_buffer), &omemo_ctx.identity_key_store); + signal_buffer_len(identity_buffer), &omemo_ctx.identity_key_store); /* Replace used pre_key in bundle */ uint32_t pre_key_id = pre_key_signal_message_get_pre_key_id(message); - ec_key_pair *ec_pair; - session_pre_key *new_pre_key; + ec_key_pair* ec_pair; + session_pre_key* new_pre_key; curve_generate_key_pair(omemo_ctx.signal, &ec_pair); session_pre_key_create(&new_pre_key, pre_key_id, ec_pair); signal_protocol_pre_key_store_key(omemo_ctx.store, new_pre_key); @@ -921,7 +920,7 @@ omemo_on_message_recv(const char *const from_jid, uint32_t sid, } } else { log_debug("OMEMO: decrypting message with existing session"); - signal_message *message = NULL; + signal_message* message = NULL; res = signal_message_deserialize(&message, key->data, key->length, omemo_ctx.signal); @@ -949,8 +948,8 @@ omemo_on_message_recv(const char *const from_jid, uint32_t sid, size_t plaintext_len = payload_len; plaintext = malloc(plaintext_len + 1); res = aes128gcm_decrypt(plaintext, &plaintext_len, payload, payload_len, iv, - iv_len, signal_buffer_data(plaintext_key), - signal_buffer_data(plaintext_key) + AES128_GCM_KEY_LENGTH); + iv_len, signal_buffer_data(plaintext_key), + signal_buffer_data(plaintext_key) + AES128_GCM_KEY_LENGTH); signal_buffer_free(plaintext_key); if (res != 0) { log_error("OMEMO: cannot decrypt message: %s", gcry_strerror(res)); @@ -964,13 +963,13 @@ omemo_on_message_recv(const char *const from_jid, uint32_t sid, out: jid_destroy(from); jid_destroy(sender); - return (char *)plaintext; + return (char*)plaintext; } -char * -omemo_format_fingerprint(const char *const fingerprint) +char* +omemo_format_fingerprint(const char* const fingerprint) { - char *output = malloc(strlen(fingerprint) + strlen(fingerprint) / 8); + char* output = malloc(strlen(fingerprint) + strlen(fingerprint) / 8); int i, j; for (i = 0, j = 0; i < strlen(fingerprint); i++) { @@ -985,11 +984,11 @@ omemo_format_fingerprint(const char *const fingerprint) return output; } -static char * -_omemo_unformat_fingerprint(const char *const fingerprint_formatted) +static char* +_omemo_unformat_fingerprint(const char* const fingerprint_formatted) { /* Unformat fingerprint */ - char *fingerprint = malloc(strlen(fingerprint_formatted)); + char* fingerprint = malloc(strlen(fingerprint_formatted)); int i; int j; for (i = 0, j = 0; fingerprint_formatted[i] != '\0'; i++) { @@ -1004,17 +1003,17 @@ _omemo_unformat_fingerprint(const char *const fingerprint_formatted) return fingerprint; } -char * +char* omemo_own_fingerprint(gboolean formatted) { - ec_public_key *identity = ratchet_identity_key_pair_get_public(omemo_ctx.identity_key_pair); + ec_public_key* identity = ratchet_identity_key_pair_get_public(omemo_ctx.identity_key_pair); return _omemo_fingerprint(identity, formatted); } -GList * -omemo_known_device_identities(const char *const jid) +GList* +omemo_known_device_identities(const char* const jid) { - GHashTable *known_identities = g_hash_table_lookup(omemo_ctx.known_devices, jid); + GHashTable* known_identities = g_hash_table_lookup(omemo_ctx.known_devices, jid); if (!known_identities) { return NULL; } @@ -1023,14 +1022,14 @@ omemo_known_device_identities(const char *const jid) } gboolean -omemo_is_trusted_identity(const char *const jid, const char *const fingerprint) +omemo_is_trusted_identity(const char* const jid, const char* const fingerprint) { - GHashTable *known_identities = g_hash_table_lookup(omemo_ctx.known_devices, jid); + GHashTable* known_identities = g_hash_table_lookup(omemo_ctx.known_devices, jid); if (!known_identities) { return FALSE; } - void *device_id = g_hash_table_lookup(known_identities, fingerprint); + void* device_id = g_hash_table_lookup(known_identities, fingerprint); if (!device_id) { return FALSE; } @@ -1042,9 +1041,9 @@ omemo_is_trusted_identity(const char *const jid, const char *const fingerprint) }; size_t fingerprint_len; - unsigned char *fingerprint_raw = _omemo_fingerprint_decode(fingerprint, &fingerprint_len); - unsigned char djb_type[] = {'\x05'}; - signal_buffer *buffer = signal_buffer_create(djb_type, 1); + unsigned char* fingerprint_raw = _omemo_fingerprint_decode(fingerprint, &fingerprint_len); + unsigned char djb_type[] = { '\x05' }; + signal_buffer* buffer = signal_buffer_create(djb_type, 1); buffer = signal_buffer_append(buffer, fingerprint_raw, fingerprint_len); gboolean trusted = is_trusted_identity(&address, signal_buffer_data(buffer), signal_buffer_len(buffer), &omemo_ctx.identity_key_store); @@ -1055,21 +1054,21 @@ omemo_is_trusted_identity(const char *const jid, const char *const fingerprint) return trusted; } -static char * -_omemo_fingerprint(ec_public_key *identity, gboolean formatted) +static char* +_omemo_fingerprint(ec_public_key* identity, gboolean formatted) { int i; - signal_buffer *identity_public_key; + signal_buffer* identity_public_key; ec_public_key_serialize(&identity_public_key, identity); size_t identity_public_key_len = signal_buffer_len(identity_public_key); - unsigned char *identity_public_key_data = signal_buffer_data(identity_public_key); + unsigned char* identity_public_key_data = signal_buffer_data(identity_public_key); /* Skip first byte corresponding to signal DJB_TYPE */ identity_public_key_len--; identity_public_key_data = &identity_public_key_data[1]; - char *fingerprint = malloc(identity_public_key_len * 2 + 1); + char* fingerprint = malloc(identity_public_key_len * 2 + 1); for (i = 0; i < identity_public_key_len; i++) { fingerprint[i * 2] = (identity_public_key_data[i] & 0xf0) >> 4; @@ -1091,16 +1090,16 @@ _omemo_fingerprint(ec_public_key *identity, gboolean formatted) if (!formatted) { return fingerprint; } else { - char *formatted_fingerprint = omemo_format_fingerprint(fingerprint); + char* formatted_fingerprint = omemo_format_fingerprint(fingerprint); free(fingerprint); return formatted_fingerprint; } } -static unsigned char * -_omemo_fingerprint_decode(const char *const fingerprint, size_t *len) +static unsigned char* +_omemo_fingerprint_decode(const char* const fingerprint, size_t* len) { - unsigned char *output = malloc(strlen(fingerprint) / 2 + 1); + unsigned char* output = malloc(strlen(fingerprint) / 2 + 1); int i; int j; @@ -1121,18 +1120,18 @@ _omemo_fingerprint_decode(const char *const fingerprint, size_t *len) } void -omemo_trust(const char *const jid, const char *const fingerprint_formatted) +omemo_trust(const char* const jid, const char* const fingerprint_formatted) { size_t len; - GHashTable *known_identities = g_hash_table_lookup(omemo_ctx.known_devices, jid); + GHashTable* known_identities = g_hash_table_lookup(omemo_ctx.known_devices, jid); if (!known_identities) { log_warning("OMEMO: cannot trust unknown device: %s", fingerprint_formatted); cons_show("Cannot trust unknown device: %s", fingerprint_formatted); return; } - char *fingerprint = _omemo_unformat_fingerprint(fingerprint_formatted); + char* fingerprint = _omemo_unformat_fingerprint(fingerprint_formatted); uint32_t device_id = GPOINTER_TO_INT(g_hash_table_lookup(known_identities, fingerprint)); free(fingerprint); @@ -1152,9 +1151,9 @@ omemo_trust(const char *const jid, const char *const fingerprint_formatted) .device_id = device_id, }; - unsigned char *fingerprint_raw = _omemo_fingerprint_decode(fingerprint_formatted, &len); - unsigned char djb_type[] = {'\x05'}; - signal_buffer *buffer = signal_buffer_create(djb_type, 1); + unsigned char* fingerprint_raw = _omemo_fingerprint_decode(fingerprint_formatted, &len); + unsigned char djb_type[] = { '\x05' }; + signal_buffer* buffer = signal_buffer_create(djb_type, 1); buffer = signal_buffer_append(buffer, fingerprint_raw, len); save_identity(&address, signal_buffer_data(buffer), signal_buffer_len(buffer), &omemo_ctx.identity_key_store); free(fingerprint_raw); @@ -1164,15 +1163,15 @@ omemo_trust(const char *const jid, const char *const fingerprint_formatted) } void -omemo_untrust(const char *const jid, const char *const fingerprint_formatted) +omemo_untrust(const char* const jid, const char* const fingerprint_formatted) { size_t len; - unsigned char *identity = _omemo_fingerprint_decode(fingerprint_formatted, &len); + unsigned char* identity = _omemo_fingerprint_decode(fingerprint_formatted, &len); GHashTableIter iter; gpointer key, value; - GHashTable *trusted = g_hash_table_lookup(omemo_ctx.identity_key_store.trusted, jid); + GHashTable* trusted = g_hash_table_lookup(omemo_ctx.identity_key_store.trusted, jid); if (!trusted) { free(identity); return; @@ -1180,8 +1179,8 @@ omemo_untrust(const char *const jid, const char *const fingerprint_formatted) g_hash_table_iter_init(&iter, trusted); while (g_hash_table_iter_next(&iter, &key, &value)) { - signal_buffer *buffer = value; - unsigned char *original = signal_buffer_data(buffer); + signal_buffer* buffer = value; + unsigned char* original = signal_buffer_data(buffer); /* Skip DJB_TYPE byte */ original++; if ((signal_buffer_len(buffer) - 1) == len && memcmp(original, identity, len) == 0) { @@ -1190,10 +1189,10 @@ omemo_untrust(const char *const jid, const char *const fingerprint_formatted) } free(identity); - char *fingerprint = _omemo_unformat_fingerprint(fingerprint_formatted); + char* fingerprint = _omemo_unformat_fingerprint(fingerprint_formatted); /* Remove existing session */ - GHashTable *known_identities = g_hash_table_lookup(omemo_ctx.known_devices, jid); + GHashTable* known_identities = g_hash_table_lookup(omemo_ctx.known_devices, jid); if (!known_identities) { log_error("OMEMO: cannot find known device while untrusting a fingerprint"); goto out; @@ -1213,7 +1212,7 @@ omemo_untrust(const char *const jid, const char *const fingerprint_formatted) delete_session(&address, omemo_ctx.session_store); /* Remove from keyfile */ - char *device_id_str = g_strdup_printf("%d", device_id); + char* device_id_str = g_strdup_printf("%d", device_id); g_key_file_remove_key(omemo_ctx.trust_keyfile, jid, device_id_str, NULL); g_free(device_id_str); omemo_trust_keyfile_save(); @@ -1223,41 +1222,41 @@ out: } static void -_lock(void *user_data) +_lock(void* user_data) { - omemo_context *ctx = (omemo_context *)user_data; + omemo_context* ctx = (omemo_context*)user_data; pthread_mutex_lock(&ctx->lock); } static void -_unlock(void *user_data) +_unlock(void* user_data) { - omemo_context *ctx = (omemo_context *)user_data; + omemo_context* ctx = (omemo_context*)user_data; pthread_mutex_unlock(&ctx->lock); } static void -_omemo_log(int level, const char *message, size_t len, void *user_data) +_omemo_log(int level, const char* message, size_t len, void* user_data) { switch (level) { - case SG_LOG_ERROR: - log_error("OMEMO: %s", message); - break; - case SG_LOG_WARNING: - log_warning("OMEMO: %s", message); - break; - case SG_LOG_NOTICE: - case SG_LOG_INFO: - log_info("OMEMO: %s", message); - break; - case SG_LOG_DEBUG: - log_debug("OMEMO: %s", message); - break; + case SG_LOG_ERROR: + log_error("OMEMO: %s", message); + break; + case SG_LOG_WARNING: + log_warning("OMEMO: %s", message); + break; + case SG_LOG_NOTICE: + case SG_LOG_INFO: + log_info("OMEMO: %s", message); + break; + case SG_LOG_DEBUG: + log_debug("OMEMO: %s", message); + break; } } static gboolean -_handle_own_device_list(const char *const jid, GList *device_list) +_handle_own_device_list(const char* const jid, GList* device_list) { if (!g_list_find(device_list, GINT_TO_POINTER(omemo_ctx.device_id))) { device_list = g_list_copy(device_list); @@ -1266,7 +1265,7 @@ _handle_own_device_list(const char *const jid, GList *device_list) omemo_devicelist_publish(device_list); } - GList *device_id; + GList* device_id; for (device_id = device_list; device_id != NULL; device_id = device_id->next) { omemo_bundle_request(jid, GPOINTER_TO_INT(device_id->data), omemo_start_device_session_handle_bundle, free, strdup(jid)); } @@ -1275,7 +1274,7 @@ _handle_own_device_list(const char *const jid, GList *device_list) } static gboolean -_handle_device_list_start_session(const char *const jid, GList *device_list) +_handle_device_list_start_session(const char* const jid, GList* device_list) { omemo_start_session(jid); @@ -1283,7 +1282,7 @@ _handle_device_list_start_session(const char *const jid, GList *device_list) } void -omemo_key_free(omemo_key_t *key) +omemo_key_free(omemo_key_t* key) { if (key == NULL) { return; @@ -1294,7 +1293,7 @@ omemo_key_free(omemo_key_t *key) } char* -omemo_fingerprint_autocomplete(const char *const search_str, gboolean previous, void *context) +omemo_fingerprint_autocomplete(const char* const search_str, gboolean previous, void* context) { Autocomplete ac = g_hash_table_lookup(omemo_ctx.fingerprint_ac, context); if (ac != NULL) { @@ -1318,11 +1317,11 @@ omemo_fingerprint_autocomplete_reset(void) } gboolean -omemo_automatic_start(const char *const recipient) +omemo_automatic_start(const char* const recipient) { gboolean result = FALSE; - char *account_name = session_get_account_name(); - ProfAccount *account = accounts_get_account(account_name); + char* account_name = session_get_account_name(); + ProfAccount* account = accounts_get_account(account_name); prof_omemopolicy_t policy; if (account->omemo_policy) { @@ -1338,7 +1337,7 @@ omemo_automatic_start(const char *const recipient) } } else { // check global setting - char *pref_omemo_policy = prefs_get_string(PREF_OMEMO_POLICY); + char* pref_omemo_policy = prefs_get_string(PREF_OMEMO_POLICY); // pref defaults to manual policy = PROF_OMEMOPOLICY_AUTOMATIC; @@ -1353,25 +1352,25 @@ omemo_automatic_start(const char *const recipient) } switch (policy) { - case PROF_OMEMOPOLICY_MANUAL: + case PROF_OMEMOPOLICY_MANUAL: + result = FALSE; + break; + case PROF_OMEMOPOLICY_AUTOMATIC: + if (g_list_find_custom(account->omemo_enabled, recipient, (GCompareFunc)g_strcmp0)) { + result = TRUE; + } else if (g_list_find_custom(account->omemo_disabled, recipient, (GCompareFunc)g_strcmp0)) { result = FALSE; - break; - case PROF_OMEMOPOLICY_AUTOMATIC: - if (g_list_find_custom(account->omemo_enabled, recipient, (GCompareFunc)g_strcmp0)) { - result = TRUE; - } else if (g_list_find_custom(account->omemo_disabled, recipient, (GCompareFunc)g_strcmp0)) { - result = FALSE; - } else { - result = FALSE; - } - break; - case PROF_OMEMOPOLICY_ALWAYS: - if (g_list_find_custom(account->omemo_disabled, recipient, (GCompareFunc)g_strcmp0)) { - result = FALSE; - } else { - result = TRUE; - } - break; + } else { + result = FALSE; + } + break; + case PROF_OMEMOPOLICY_ALWAYS: + if (g_list_find_custom(account->omemo_disabled, recipient, (GCompareFunc)g_strcmp0)) { + result = FALSE; + } else { + result = TRUE; + } + break; } account_free(account); @@ -1381,7 +1380,7 @@ omemo_automatic_start(const char *const recipient) static gboolean _load_identity(void) { - GError *error = NULL; + GError* error = NULL; log_info("Loading OMEMO identity"); /* Device ID */ @@ -1403,50 +1402,50 @@ _load_identity(void) /* Identity key */ error = NULL; - char *identity_key_public_b64 = g_key_file_get_string(omemo_ctx.identity_keyfile, OMEMO_STORE_GROUP_IDENTITY, OMEMO_STORE_KEY_IDENTITY_KEY_PUBLIC, &error); + char* identity_key_public_b64 = g_key_file_get_string(omemo_ctx.identity_keyfile, OMEMO_STORE_GROUP_IDENTITY, OMEMO_STORE_KEY_IDENTITY_KEY_PUBLIC, &error); if (!identity_key_public_b64) { log_error("OMEMO: cannot load identity public key: %s", error->message); return FALSE; } size_t identity_key_public_len; - unsigned char *identity_key_public = g_base64_decode(identity_key_public_b64, &identity_key_public_len); + unsigned char* identity_key_public = g_base64_decode(identity_key_public_b64, &identity_key_public_len); g_free(identity_key_public_b64); omemo_ctx.identity_key_store.public = signal_buffer_create(identity_key_public, identity_key_public_len); error = NULL; - char *identity_key_private_b64 = g_key_file_get_string(omemo_ctx.identity_keyfile, OMEMO_STORE_GROUP_IDENTITY, OMEMO_STORE_KEY_IDENTITY_KEY_PRIVATE, &error); + char* identity_key_private_b64 = g_key_file_get_string(omemo_ctx.identity_keyfile, OMEMO_STORE_GROUP_IDENTITY, OMEMO_STORE_KEY_IDENTITY_KEY_PRIVATE, &error); if (!identity_key_private_b64) { log_error("OMEMO: cannot load identity private key: %s", error->message); return FALSE; } size_t identity_key_private_len; - unsigned char *identity_key_private = g_base64_decode(identity_key_private_b64, &identity_key_private_len); + unsigned char* identity_key_private = g_base64_decode(identity_key_private_b64, &identity_key_private_len); g_free(identity_key_private_b64); omemo_ctx.identity_key_store.private = signal_buffer_create(identity_key_private, identity_key_private_len); - ec_public_key *public_key; + ec_public_key* public_key; curve_decode_point(&public_key, identity_key_public, identity_key_public_len, omemo_ctx.signal); - ec_private_key *private_key; + ec_private_key* private_key; curve_decode_private_point(&private_key, identity_key_private, identity_key_private_len, omemo_ctx.signal); ratchet_identity_key_pair_create(&omemo_ctx.identity_key_pair, public_key, private_key); g_free(identity_key_public); g_free(identity_key_private); - char **keys = NULL; + char** keys = NULL; int i; /* Pre keys */ i = 0; keys = g_key_file_get_keys(omemo_ctx.identity_keyfile, OMEMO_STORE_GROUP_PREKEYS, NULL, NULL); if (keys) { for (i = 0; keys[i] != NULL; i++) { - char *pre_key_b64 = g_key_file_get_string(omemo_ctx.identity_keyfile, OMEMO_STORE_GROUP_PREKEYS, keys[i], NULL); + char* pre_key_b64 = g_key_file_get_string(omemo_ctx.identity_keyfile, OMEMO_STORE_GROUP_PREKEYS, keys[i], NULL); size_t pre_key_len; - unsigned char *pre_key = g_base64_decode(pre_key_b64, &pre_key_len); + unsigned char* pre_key = g_base64_decode(pre_key_b64, &pre_key_len); g_free(pre_key_b64); - signal_buffer *buffer = signal_buffer_create(pre_key, pre_key_len); + signal_buffer* buffer = signal_buffer_create(pre_key, pre_key_len); g_free(pre_key); g_hash_table_insert(omemo_ctx.pre_key_store, GINT_TO_POINTER(strtoul(keys[i], NULL, 10)), buffer); } @@ -1464,11 +1463,11 @@ _load_identity(void) keys = g_key_file_get_keys(omemo_ctx.identity_keyfile, OMEMO_STORE_GROUP_SIGNED_PREKEYS, NULL, NULL); if (keys) { for (i = 0; keys[i] != NULL; i++) { - char *signed_pre_key_b64 = g_key_file_get_string(omemo_ctx.identity_keyfile, OMEMO_STORE_GROUP_SIGNED_PREKEYS, keys[i], NULL); + char* signed_pre_key_b64 = g_key_file_get_string(omemo_ctx.identity_keyfile, OMEMO_STORE_GROUP_SIGNED_PREKEYS, keys[i], NULL); size_t signed_pre_key_len; - unsigned char *signed_pre_key = g_base64_decode(signed_pre_key_b64, &signed_pre_key_len); + unsigned char* signed_pre_key = g_base64_decode(signed_pre_key_b64, &signed_pre_key_len); g_free(signed_pre_key_b64); - signal_buffer *buffer = signal_buffer_create(signed_pre_key, signed_pre_key_len); + signal_buffer* buffer = signal_buffer_create(signed_pre_key, signed_pre_key_len); g_free(signed_pre_key); g_hash_table_insert(omemo_ctx.signed_pre_key_store, GINT_TO_POINTER(strtoul(keys[i], NULL, 10)), buffer); omemo_ctx.signed_pre_key_id = strtoul(keys[i], NULL, 10); @@ -1491,12 +1490,12 @@ _load_identity(void) static void _load_trust(void) { - char **keys = NULL; - char **groups = g_key_file_get_groups(omemo_ctx.trust_keyfile, NULL); + char** keys = NULL; + char** groups = g_key_file_get_groups(omemo_ctx.trust_keyfile, NULL); if (groups) { int i; for (i = 0; groups[i] != NULL; i++) { - GHashTable *trusted; + GHashTable* trusted; trusted = g_hash_table_lookup(omemo_ctx.identity_key_store.trusted, groups[i]); if (!trusted) { @@ -1507,11 +1506,11 @@ _load_trust(void) keys = g_key_file_get_keys(omemo_ctx.trust_keyfile, groups[i], NULL, NULL); int j; for (j = 0; keys[j] != NULL; j++) { - char *key_b64 = g_key_file_get_string(omemo_ctx.trust_keyfile, groups[i], keys[j], NULL); + char* key_b64 = g_key_file_get_string(omemo_ctx.trust_keyfile, groups[i], keys[j], NULL); size_t key_len; - unsigned char *key = g_base64_decode(key_b64, &key_len); + unsigned char* key = g_base64_decode(key_b64, &key_len); g_free(key_b64); - signal_buffer *buffer = signal_buffer_create(key, key_len); + signal_buffer* buffer = signal_buffer_create(key, key_len); g_free(key); uint32_t device_id = strtoul(keys[j], NULL, 10); g_hash_table_insert(trusted, GINT_TO_POINTER(device_id), buffer); @@ -1526,11 +1525,11 @@ static void _load_sessions(void) { int i; - char **groups = g_key_file_get_groups(omemo_ctx.sessions_keyfile, NULL); + char** groups = g_key_file_get_groups(omemo_ctx.sessions_keyfile, NULL); if (groups) { for (i = 0; groups[i] != NULL; i++) { int j; - GHashTable *device_store = NULL; + GHashTable* device_store = NULL; device_store = g_hash_table_lookup(omemo_ctx.session_store, groups[i]); if (!device_store) { @@ -1538,14 +1537,14 @@ _load_sessions(void) g_hash_table_insert(omemo_ctx.session_store, strdup(groups[i]), device_store); } - char **keys = g_key_file_get_keys(omemo_ctx.sessions_keyfile, groups[i], NULL, NULL); + char** keys = g_key_file_get_keys(omemo_ctx.sessions_keyfile, groups[i], NULL, NULL); for (j = 0; keys[j] != NULL; j++) { uint32_t id = strtoul(keys[j], NULL, 10); - char *record_b64 = g_key_file_get_string(omemo_ctx.sessions_keyfile, groups[i], keys[j], NULL); + char* record_b64 = g_key_file_get_string(omemo_ctx.sessions_keyfile, groups[i], keys[j], NULL); size_t record_len; - unsigned char *record = g_base64_decode(record_b64, &record_len); + unsigned char* record = g_base64_decode(record_b64, &record_len); g_free(record_b64); - signal_buffer *buffer = signal_buffer_create(record, record_len); + signal_buffer* buffer = signal_buffer_create(record, record_len); g_free(record); g_hash_table_insert(device_store, GINT_TO_POINTER(id), buffer); } @@ -1559,11 +1558,11 @@ static void _load_known_devices(void) { int i; - char **groups = g_key_file_get_groups(omemo_ctx.known_devices_keyfile, NULL); + char** groups = g_key_file_get_groups(omemo_ctx.known_devices_keyfile, NULL); if (groups) { for (i = 0; groups[i] != NULL; i++) { int j; - GHashTable *known_identities = NULL; + GHashTable* known_identities = NULL; known_identities = g_hash_table_lookup(omemo_ctx.known_devices, groups[i]); if (!known_identities) { @@ -1571,10 +1570,10 @@ _load_known_devices(void) g_hash_table_insert(omemo_ctx.known_devices, strdup(groups[i]), known_identities); } - char **keys = g_key_file_get_keys(omemo_ctx.known_devices_keyfile, groups[i], NULL, NULL); + char** keys = g_key_file_get_keys(omemo_ctx.known_devices_keyfile, groups[i], NULL, NULL); for (j = 0; keys[j] != NULL; j++) { uint32_t device_id = strtoul(keys[j], NULL, 10); - char *fingerprint = g_key_file_get_string(omemo_ctx.known_devices_keyfile, groups[i], keys[j], NULL); + char* fingerprint = g_key_file_get_string(omemo_ctx.known_devices_keyfile, groups[i], keys[j], NULL); g_hash_table_insert(known_identities, strdup(fingerprint), GINT_TO_POINTER(device_id)); g_free(fingerprint); } @@ -1585,19 +1584,19 @@ _load_known_devices(void) } static void -_cache_device_identity(const char *const jid, uint32_t device_id, ec_public_key *identity) +_cache_device_identity(const char* const jid, uint32_t device_id, ec_public_key* identity) { - GHashTable *known_identities = g_hash_table_lookup(omemo_ctx.known_devices, jid); + GHashTable* known_identities = g_hash_table_lookup(omemo_ctx.known_devices, jid); if (!known_identities) { known_identities = g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL); g_hash_table_insert(omemo_ctx.known_devices, strdup(jid), known_identities); } - char *fingerprint = _omemo_fingerprint(identity, FALSE); + char* fingerprint = _omemo_fingerprint(identity, FALSE); log_info("OMEMO: cache identity for %s:%d: %s", jid, device_id, fingerprint); g_hash_table_insert(known_identities, strdup(fingerprint), GINT_TO_POINTER(device_id)); - char *device_id_str = g_strdup_printf("%d", device_id); + char* device_id_str = g_strdup_printf("%d", device_id); g_key_file_set_string(omemo_ctx.known_devices_keyfile, jid, device_id_str, fingerprint); g_free(device_id_str); omemo_known_devices_keyfile_save(); @@ -1608,14 +1607,14 @@ _cache_device_identity(const char *const jid, uint32_t device_id, ec_public_key g_hash_table_insert(omemo_ctx.fingerprint_ac, strdup(jid), ac); } - char *formatted_fingerprint = omemo_format_fingerprint(fingerprint); + char* formatted_fingerprint = omemo_format_fingerprint(fingerprint); autocomplete_add(ac, formatted_fingerprint); free(formatted_fingerprint); free(fingerprint); } static void -_g_hash_table_free(GHashTable *hash_table) +_g_hash_table_free(GHashTable* hash_table) { g_hash_table_remove_all(hash_table); g_hash_table_unref(hash_table); @@ -1626,12 +1625,12 @@ _generate_pre_keys(int count) { unsigned int start; gcry_randomize(&start, sizeof(unsigned int), GCRY_VERY_STRONG_RANDOM); - signal_protocol_key_helper_pre_key_list_node *pre_keys_head; + signal_protocol_key_helper_pre_key_list_node* pre_keys_head; signal_protocol_key_helper_generate_pre_keys(&pre_keys_head, start, count, omemo_ctx.signal); - signal_protocol_key_helper_pre_key_list_node *p; + signal_protocol_key_helper_pre_key_list_node* p; for (p = pre_keys_head; p != NULL; p = signal_protocol_key_helper_key_list_next(p)) { - session_pre_key *prekey = signal_protocol_key_helper_key_list_element(p); + session_pre_key* prekey = signal_protocol_key_helper_key_list_element(p); signal_protocol_pre_key_store_key(omemo_ctx.store, prekey); } signal_protocol_key_helper_key_list_free(pre_keys_head); @@ -1640,7 +1639,7 @@ _generate_pre_keys(int count) static void _generate_signed_pre_key(void) { - session_signed_pre_key *signed_pre_key; + session_signed_pre_key* signed_pre_key; struct timeval tv; gettimeofday(&tv, NULL); unsigned long long timestamp = (unsigned long long)(tv.tv_sec) * 1000 + (unsigned long long)(tv.tv_usec) / 1000; diff --git a/src/omemo/omemo.h b/src/omemo/omemo.h index 740654a2..ecfc42d9 100644 --- a/src/omemo/omemo.h +++ b/src/omemo/omemo.h @@ -38,7 +38,7 @@ #include "config/account.h" #define OMEMO_ERR_UNSUPPORTED_CRYPTO -10000 -#define OMEMO_ERR_GCRYPT -20000 +#define OMEMO_ERR_GCRYPT -20000 typedef enum { PROF_OMEMOPOLICY_MANUAL, @@ -48,8 +48,9 @@ typedef enum { typedef struct omemo_context_t omemo_context; -typedef struct omemo_key { - unsigned char *data; +typedef struct omemo_key +{ + unsigned char* data; size_t length; gboolean prekey; uint32_t device_id; @@ -58,39 +59,39 @@ typedef struct omemo_key { void omemo_init(void); void omemo_close(void); -void omemo_on_connect(ProfAccount *account); +void omemo_on_connect(ProfAccount* account); void omemo_on_disconnect(void); -void omemo_generate_crypto_materials(ProfAccount *account); -void omemo_key_free(omemo_key_t *key); +void omemo_generate_crypto_materials(ProfAccount* account); +void omemo_key_free(omemo_key_t* key); void omemo_publish_crypto_materials(void); uint32_t omemo_device_id(void); -void omemo_identity_key(unsigned char **output, size_t *length); -void omemo_signed_prekey(unsigned char **output, size_t *length); -void omemo_signed_prekey_signature(unsigned char **output, size_t *length); -void omemo_prekeys(GList **prekeys, GList **ids, GList **lengths); -void omemo_set_device_list(const char *const jid, GList * device_list); -GKeyFile *omemo_identity_keyfile(void); +void omemo_identity_key(unsigned char** output, size_t* length); +void omemo_signed_prekey(unsigned char** output, size_t* length); +void omemo_signed_prekey_signature(unsigned char** output, size_t* length); +void omemo_prekeys(GList** prekeys, GList** ids, GList** lengths); +void omemo_set_device_list(const char* const jid, GList* device_list); +GKeyFile* omemo_identity_keyfile(void); void omemo_identity_keyfile_save(void); -GKeyFile *omemo_trust_keyfile(void); +GKeyFile* omemo_trust_keyfile(void); void omemo_trust_keyfile_save(void); -GKeyFile *omemo_sessions_keyfile(void); +GKeyFile* omemo_sessions_keyfile(void); void omemo_sessions_keyfile_save(void); -char *omemo_format_fingerprint(const char *const fingerprint); -char *omemo_own_fingerprint(gboolean formatted); -void omemo_trust(const char *const jid, const char *const fingerprint); -void omemo_untrust(const char *const jid, const char *const fingerprint); -GList *omemo_known_device_identities(const char *const jid); -gboolean omemo_is_trusted_identity(const char *const jid, const char *const fingerprint); -char *omemo_fingerprint_autocomplete(const char *const search_str, gboolean previous, void *context); +char* omemo_format_fingerprint(const char* const fingerprint); +char* omemo_own_fingerprint(gboolean formatted); +void omemo_trust(const char* const jid, const char* const fingerprint); +void omemo_untrust(const char* const jid, const char* const fingerprint); +GList* omemo_known_device_identities(const char* const jid); +gboolean omemo_is_trusted_identity(const char* const jid, const char* const fingerprint); +char* omemo_fingerprint_autocomplete(const char* const search_str, gboolean previous, void* context); void omemo_fingerprint_autocomplete_reset(void); -gboolean omemo_automatic_start(const char *const recipient); +gboolean omemo_automatic_start(const char* const recipient); void omemo_start_sessions(void); -void omemo_start_session(const char *const barejid); -void omemo_start_muc_sessions(const char *const roomjid); -void omemo_start_device_session(const char *const jid, uint32_t device_id, GList *prekeys, uint32_t signed_prekey_id, const unsigned char *const signed_prekey, size_t signed_prekey_len, const unsigned char *const signature, size_t signature_len, const unsigned char *const identity_key, size_t identity_key_len); +void omemo_start_session(const char* const barejid); +void omemo_start_muc_sessions(const char* const roomjid); +void omemo_start_device_session(const char* const jid, uint32_t device_id, GList* prekeys, uint32_t signed_prekey_id, const unsigned char* const signed_prekey, size_t signed_prekey_len, const unsigned char* const signature, size_t signature_len, const unsigned char* const identity_key, size_t identity_key_len); gboolean omemo_loaded(void); -char * omemo_on_message_send(ProfWin *win, const char *const message, gboolean request_receipt, gboolean muc, const char *const replace_id); -char * omemo_on_message_recv(const char *const from, uint32_t sid, const unsigned char *const iv, size_t iv_len, GList *keys, const unsigned char *const payload, size_t payload_len, gboolean muc, gboolean *trusted); +char* omemo_on_message_send(ProfWin* win, const char* const message, gboolean request_receipt, gboolean muc, const char* const replace_id); +char* omemo_on_message_recv(const char* const from, uint32_t sid, const unsigned char* const iv, size_t iv_len, GList* keys, const unsigned char* const payload, size_t payload_len, gboolean muc, gboolean* trusted); diff --git a/src/omemo/store.c b/src/omemo/store.c index ec39ed1b..434483ed 100644 --- a/src/omemo/store.c +++ b/src/omemo/store.c @@ -39,28 +39,28 @@ #include "omemo/omemo.h" #include "omemo/store.h" -static void _g_hash_table_free(GHashTable *hash_table); +static void _g_hash_table_free(GHashTable* hash_table); -GHashTable * +GHashTable* session_store_new(void) { return g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)_g_hash_table_free); } -GHashTable * +GHashTable* pre_key_store_new(void) { return g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)signal_buffer_free); } -GHashTable * +GHashTable* signed_pre_key_store_new(void) { return g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)signal_buffer_free); } void -identity_key_store_new(identity_key_store_t *identity_key_store) +identity_key_store_new(identity_key_store_t* identity_key_store) { identity_key_store->trusted = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)signal_buffer_free); identity_key_store->private = NULL; @@ -69,16 +69,16 @@ identity_key_store_new(identity_key_store_t *identity_key_store) #ifdef HAVE_LIBSIGNAL_LT_2_3_2 int -load_session(signal_buffer **record, const signal_protocol_address *address, - void *user_data) +load_session(signal_buffer** record, const signal_protocol_address* address, + void* user_data) #else int -load_session(signal_buffer **record, signal_buffer **user_record, - const signal_protocol_address *address, void *user_data) +load_session(signal_buffer** record, signal_buffer** user_record, + const signal_protocol_address* address, void* user_data) #endif { - GHashTable *session_store = (GHashTable *)user_data; - GHashTable *device_store = NULL; + GHashTable* session_store = (GHashTable*)user_data; + GHashTable* device_store = NULL; device_store = g_hash_table_lookup(session_store, address->name); if (!device_store) { @@ -86,7 +86,7 @@ load_session(signal_buffer **record, signal_buffer **user_record, return 0; } - signal_buffer *original = g_hash_table_lookup(device_store, GINT_TO_POINTER(address->device_id)); + signal_buffer* original = g_hash_table_lookup(device_store, GINT_TO_POINTER(address->device_id)); if (!original) { *record = NULL; return 0; @@ -96,11 +96,11 @@ load_session(signal_buffer **record, signal_buffer **user_record, } int -get_sub_device_sessions(signal_int_list **sessions, const char *name, - size_t name_len, void *user_data) +get_sub_device_sessions(signal_int_list** sessions, const char* name, + size_t name_len, void* user_data) { - GHashTable *session_store = (GHashTable *)user_data; - GHashTable *device_store = NULL; + GHashTable* session_store = (GHashTable*)user_data; + GHashTable* device_store = NULL; GHashTableIter iter; gpointer key, value; @@ -115,37 +115,35 @@ get_sub_device_sessions(signal_int_list **sessions, const char *name, signal_int_list_push_back(*sessions, GPOINTER_TO_INT(key)); } - return SG_SUCCESS; } #ifdef HAVE_LIBSIGNAL_LT_2_3_2 int -store_session(const signal_protocol_address *address, uint8_t *record, - size_t record_len, void *user_data) +store_session(const signal_protocol_address* address, uint8_t* record, + size_t record_len, void* user_data) #else int -store_session(const signal_protocol_address *address, - uint8_t *record, size_t record_len, - uint8_t *user_record, size_t user_record_len, - void *user_data) +store_session(const signal_protocol_address* address, + uint8_t* record, size_t record_len, + uint8_t* user_record, size_t user_record_len, + void* user_data) #endif { - GHashTable *session_store = (GHashTable *)user_data; - GHashTable *device_store = NULL; + GHashTable* session_store = (GHashTable*)user_data; + GHashTable* device_store = NULL; - device_store = g_hash_table_lookup(session_store, (void *)address->name); + device_store = g_hash_table_lookup(session_store, (void*)address->name); if (!device_store) { device_store = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)signal_buffer_free); g_hash_table_insert(session_store, strdup(address->name), device_store); } - signal_buffer *buffer = signal_buffer_create(record, record_len); + signal_buffer* buffer = signal_buffer_create(record, record_len); g_hash_table_insert(device_store, GINT_TO_POINTER(address->device_id), buffer); - - char *record_b64 = g_base64_encode(record, record_len); - char *device_id = g_strdup_printf("%d", address->device_id); + char* record_b64 = g_base64_encode(record, record_len); + char* device_id = g_strdup_printf("%d", address->device_id); g_key_file_set_string(omemo_sessions_keyfile(), address->name, device_id, record_b64); free(device_id); g_free(record_b64); @@ -156,10 +154,10 @@ store_session(const signal_protocol_address *address, } int -contains_session(const signal_protocol_address *address, void *user_data) +contains_session(const signal_protocol_address* address, void* user_data) { - GHashTable *session_store = (GHashTable *)user_data; - GHashTable *device_store = NULL; + GHashTable* session_store = (GHashTable*)user_data; + GHashTable* device_store = NULL; device_store = g_hash_table_lookup(session_store, address->name); if (!device_store) { @@ -174,10 +172,10 @@ contains_session(const signal_protocol_address *address, void *user_data) } int -delete_session(const signal_protocol_address *address, void *user_data) +delete_session(const signal_protocol_address* address, void* user_data) { - GHashTable *session_store = (GHashTable *)user_data; - GHashTable *device_store = NULL; + GHashTable* session_store = (GHashTable*)user_data; + GHashTable* device_store = NULL; device_store = g_hash_table_lookup(session_store, address->name); if (!device_store) { @@ -186,7 +184,7 @@ delete_session(const signal_protocol_address *address, void *user_data) g_hash_table_remove(device_store, GINT_TO_POINTER(address->device_id)); - char *device_id_str = g_strdup_printf("%d", address->device_id); + char* device_id_str = g_strdup_printf("%d", address->device_id); g_key_file_remove_key(omemo_sessions_keyfile(), address->name, device_id_str, NULL); g_free(device_id_str); omemo_sessions_keyfile_save(); @@ -195,10 +193,10 @@ delete_session(const signal_protocol_address *address, void *user_data) } int -delete_all_sessions(const char *name, size_t name_len, void *user_data) +delete_all_sessions(const char* name, size_t name_len, void* user_data) { - GHashTable *session_store = (GHashTable *)user_data; - GHashTable *device_store = NULL; + GHashTable* session_store = (GHashTable*)user_data; + GHashTable* device_store = NULL; device_store = g_hash_table_lookup(session_store, name); if (!device_store) { @@ -211,10 +209,10 @@ delete_all_sessions(const char *name, size_t name_len, void *user_data) } int -load_pre_key(signal_buffer **record, uint32_t pre_key_id, void *user_data) +load_pre_key(signal_buffer** record, uint32_t pre_key_id, void* user_data) { - signal_buffer *original; - GHashTable *pre_key_store = (GHashTable *)user_data; + signal_buffer* original; + GHashTable* pre_key_store = (GHashTable*)user_data; original = g_hash_table_lookup(pre_key_store, GINT_TO_POINTER(pre_key_id)); if (original == NULL) { @@ -226,17 +224,17 @@ load_pre_key(signal_buffer **record, uint32_t pre_key_id, void *user_data) } int -store_pre_key(uint32_t pre_key_id, uint8_t *record, size_t record_len, - void *user_data) +store_pre_key(uint32_t pre_key_id, uint8_t* record, size_t record_len, + void* user_data) { - GHashTable *pre_key_store = (GHashTable *)user_data; + GHashTable* pre_key_store = (GHashTable*)user_data; - signal_buffer *buffer = signal_buffer_create(record, record_len); + signal_buffer* buffer = signal_buffer_create(record, record_len); g_hash_table_insert(pre_key_store, GINT_TO_POINTER(pre_key_id), buffer); /* Long term storage */ - char *pre_key_id_str = g_strdup_printf("%d", pre_key_id); - char *record_b64 = g_base64_encode(record, record_len); + char* pre_key_id_str = g_strdup_printf("%d", pre_key_id); + char* record_b64 = g_base64_encode(record, record_len); g_key_file_set_string(omemo_identity_keyfile(), OMEMO_STORE_GROUP_PREKEYS, pre_key_id_str, record_b64); g_free(pre_key_id_str); g_free(record_b64); @@ -247,22 +245,22 @@ store_pre_key(uint32_t pre_key_id, uint8_t *record, size_t record_len, } int -contains_pre_key(uint32_t pre_key_id, void *user_data) +contains_pre_key(uint32_t pre_key_id, void* user_data) { - GHashTable *pre_key_store = (GHashTable *)user_data; + GHashTable* pre_key_store = (GHashTable*)user_data; return g_hash_table_lookup(pre_key_store, GINT_TO_POINTER(pre_key_id)) != NULL; } int -remove_pre_key(uint32_t pre_key_id, void *user_data) +remove_pre_key(uint32_t pre_key_id, void* user_data) { - GHashTable *pre_key_store = (GHashTable *)user_data; + GHashTable* pre_key_store = (GHashTable*)user_data; int ret = g_hash_table_remove(pre_key_store, GINT_TO_POINTER(pre_key_id)); /* Long term storage */ - char *pre_key_id_str = g_strdup_printf("%d", pre_key_id); + char* pre_key_id_str = g_strdup_printf("%d", pre_key_id); g_key_file_remove_key(omemo_identity_keyfile(), OMEMO_STORE_GROUP_PREKEYS, pre_key_id_str, NULL); g_free(pre_key_id_str); @@ -276,11 +274,11 @@ remove_pre_key(uint32_t pre_key_id, void *user_data) } int -load_signed_pre_key(signal_buffer **record, uint32_t signed_pre_key_id, - void *user_data) +load_signed_pre_key(signal_buffer** record, uint32_t signed_pre_key_id, + void* user_data) { - signal_buffer *original; - GHashTable *signed_pre_key_store = (GHashTable *)user_data; + signal_buffer* original; + GHashTable* signed_pre_key_store = (GHashTable*)user_data; original = g_hash_table_lookup(signed_pre_key_store, GINT_TO_POINTER(signed_pre_key_id)); if (!original) { @@ -292,17 +290,17 @@ load_signed_pre_key(signal_buffer **record, uint32_t signed_pre_key_id, } int -store_signed_pre_key(uint32_t signed_pre_key_id, uint8_t *record, - size_t record_len, void *user_data) +store_signed_pre_key(uint32_t signed_pre_key_id, uint8_t* record, + size_t record_len, void* user_data) { - GHashTable *signed_pre_key_store = (GHashTable *)user_data; + GHashTable* signed_pre_key_store = (GHashTable*)user_data; - signal_buffer *buffer = signal_buffer_create(record, record_len); + signal_buffer* buffer = signal_buffer_create(record, record_len); g_hash_table_insert(signed_pre_key_store, GINT_TO_POINTER(signed_pre_key_id), buffer); /* Long term storage */ - char *signed_pre_key_id_str = g_strdup_printf("%d", signed_pre_key_id); - char *record_b64 = g_base64_encode(record, record_len); + char* signed_pre_key_id_str = g_strdup_printf("%d", signed_pre_key_id); + char* record_b64 = g_base64_encode(record, record_len); g_key_file_set_string(omemo_identity_keyfile(), OMEMO_STORE_GROUP_SIGNED_PREKEYS, signed_pre_key_id_str, record_b64); g_free(signed_pre_key_id_str); g_free(record_b64); @@ -313,22 +311,22 @@ store_signed_pre_key(uint32_t signed_pre_key_id, uint8_t *record, } int -contains_signed_pre_key(uint32_t signed_pre_key_id, void *user_data) +contains_signed_pre_key(uint32_t signed_pre_key_id, void* user_data) { - GHashTable *signed_pre_key_store = (GHashTable *)user_data; + GHashTable* signed_pre_key_store = (GHashTable*)user_data; return g_hash_table_lookup(signed_pre_key_store, GINT_TO_POINTER(signed_pre_key_id)) != NULL; } int -remove_signed_pre_key(uint32_t signed_pre_key_id, void *user_data) +remove_signed_pre_key(uint32_t signed_pre_key_id, void* user_data) { - GHashTable *signed_pre_key_store = (GHashTable *)user_data; + GHashTable* signed_pre_key_store = (GHashTable*)user_data; int ret = g_hash_table_remove(signed_pre_key_store, GINT_TO_POINTER(signed_pre_key_id)); /* Long term storage */ - char *signed_pre_key_id_str = g_strdup_printf("%d", signed_pre_key_id); + char* signed_pre_key_id_str = g_strdup_printf("%d", signed_pre_key_id); g_key_file_remove_key(omemo_identity_keyfile(), OMEMO_STORE_GROUP_PREKEYS, signed_pre_key_id_str, NULL); g_free(signed_pre_key_id_str); @@ -338,10 +336,10 @@ remove_signed_pre_key(uint32_t signed_pre_key_id, void *user_data) } int -get_identity_key_pair(signal_buffer **public_data, signal_buffer **private_data, - void *user_data) +get_identity_key_pair(signal_buffer** public_data, signal_buffer** private_data, + void* user_data) { - identity_key_store_t *identity_key_store = (identity_key_store_t *)user_data; + identity_key_store_t* identity_key_store = (identity_key_store_t*)user_data; *public_data = signal_buffer_copy(identity_key_store->public); *private_data = signal_buffer_copy(identity_key_store->private); @@ -350,9 +348,9 @@ get_identity_key_pair(signal_buffer **public_data, signal_buffer **private_data, } int -get_local_registration_id(void *user_data, uint32_t *registration_id) +get_local_registration_id(void* user_data, uint32_t* registration_id) { - identity_key_store_t *identity_key_store = (identity_key_store_t *)user_data; + identity_key_store_t* identity_key_store = (identity_key_store_t*)user_data; *registration_id = identity_key_store->registration_id; @@ -360,10 +358,10 @@ get_local_registration_id(void *user_data, uint32_t *registration_id) } int -save_identity(const signal_protocol_address *address, uint8_t *key_data, - size_t key_len, void *user_data) +save_identity(const signal_protocol_address* address, uint8_t* key_data, + size_t key_len, void* user_data) { - identity_key_store_t *identity_key_store = (identity_key_store_t *)user_data; + identity_key_store_t* identity_key_store = (identity_key_store_t*)user_data; if (identity_key_store->recv) { /* Do not trust identity automatically */ @@ -377,9 +375,9 @@ save_identity(const signal_protocol_address *address, uint8_t *key_data, } } - signal_buffer *buffer = signal_buffer_create(key_data, key_len); + signal_buffer* buffer = signal_buffer_create(key_data, key_len); - GHashTable *trusted = g_hash_table_lookup(identity_key_store->trusted, address->name); + GHashTable* trusted = g_hash_table_lookup(identity_key_store->trusted, address->name); if (!trusted) { trusted = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)signal_buffer_free); g_hash_table_insert(identity_key_store->trusted, strdup(address->name), trusted); @@ -387,8 +385,8 @@ save_identity(const signal_protocol_address *address, uint8_t *key_data, g_hash_table_insert(trusted, GINT_TO_POINTER(address->device_id), buffer); /* Long term storage */ - char *key_b64 = g_base64_encode(key_data, key_len); - char *device_id = g_strdup_printf("%d", address->device_id); + char* key_b64 = g_base64_encode(key_data, key_len); + char* device_id = g_strdup_printf("%d", address->device_id); g_key_file_set_string(omemo_trust_keyfile(), address->name, device_id, key_b64); g_free(device_id); g_free(key_b64); @@ -399,13 +397,13 @@ save_identity(const signal_protocol_address *address, uint8_t *key_data, } int -is_trusted_identity(const signal_protocol_address *address, uint8_t *key_data, - size_t key_len, void *user_data) +is_trusted_identity(const signal_protocol_address* address, uint8_t* key_data, + size_t key_len, void* user_data) { int ret; - identity_key_store_t *identity_key_store = (identity_key_store_t *)user_data; + identity_key_store_t* identity_key_store = (identity_key_store_t*)user_data; - GHashTable *trusted = g_hash_table_lookup(identity_key_store->trusted, address->name); + GHashTable* trusted = g_hash_table_lookup(identity_key_store->trusted, address->name); if (!trusted) { if (identity_key_store->recv) { return 1; @@ -414,14 +412,13 @@ is_trusted_identity(const signal_protocol_address *address, uint8_t *key_data, } } - signal_buffer *buffer = signal_buffer_create(key_data, key_len); - signal_buffer *original = g_hash_table_lookup(trusted, GINT_TO_POINTER(address->device_id)); + signal_buffer* buffer = signal_buffer_create(key_data, key_len); + signal_buffer* original = g_hash_table_lookup(trusted, GINT_TO_POINTER(address->device_id)); ret = original != NULL && signal_buffer_compare(buffer, original) == 0; signal_buffer_free(buffer); - if (identity_key_store->recv) { return 1; } else { @@ -430,23 +427,23 @@ is_trusted_identity(const signal_protocol_address *address, uint8_t *key_data, } int -store_sender_key(const signal_protocol_sender_key_name *sender_key_name, - uint8_t *record, size_t record_len, uint8_t *user_record, - size_t user_record_len, void *user_data) +store_sender_key(const signal_protocol_sender_key_name* sender_key_name, + uint8_t* record, size_t record_len, uint8_t* user_record, + size_t user_record_len, void* user_data) { return SG_SUCCESS; } int -load_sender_key(signal_buffer **record, signal_buffer **user_record, - const signal_protocol_sender_key_name *sender_key_name, - void *user_data) +load_sender_key(signal_buffer** record, signal_buffer** user_record, + const signal_protocol_sender_key_name* sender_key_name, + void* user_data) { return SG_SUCCESS; } static void -_g_hash_table_free(GHashTable *hash_table) +_g_hash_table_free(GHashTable* hash_table) { g_hash_table_remove_all(hash_table); g_hash_table_unref(hash_table); diff --git a/src/omemo/store.h b/src/omemo/store.h index 9b523fb6..f84db5ed 100644 --- a/src/omemo/store.h +++ b/src/omemo/store.h @@ -36,26 +36,27 @@ #include "config.h" -#define OMEMO_STORE_GROUP_IDENTITY "identity" -#define OMEMO_STORE_GROUP_PREKEYS "prekeys" -#define OMEMO_STORE_GROUP_SIGNED_PREKEYS "signed_prekeys" -#define OMEMO_STORE_KEY_DEVICE_ID "device_id" -#define OMEMO_STORE_KEY_REGISTRATION_ID "registration_id" -#define OMEMO_STORE_KEY_IDENTITY_KEY_PUBLIC "identity_key_public" +#define OMEMO_STORE_GROUP_IDENTITY "identity" +#define OMEMO_STORE_GROUP_PREKEYS "prekeys" +#define OMEMO_STORE_GROUP_SIGNED_PREKEYS "signed_prekeys" +#define OMEMO_STORE_KEY_DEVICE_ID "device_id" +#define OMEMO_STORE_KEY_REGISTRATION_ID "registration_id" +#define OMEMO_STORE_KEY_IDENTITY_KEY_PUBLIC "identity_key_public" #define OMEMO_STORE_KEY_IDENTITY_KEY_PRIVATE "identity_key_private" -typedef struct { - signal_buffer *public; - signal_buffer *private; - uint32_t registration_id; - GHashTable *trusted; - bool recv; +typedef struct +{ + signal_buffer* public; + signal_buffer* private; + uint32_t registration_id; + GHashTable* trusted; + bool recv; } identity_key_store_t; -GHashTable * session_store_new(void); -GHashTable * pre_key_store_new(void); -GHashTable * signed_pre_key_store_new(void); -void identity_key_store_new(identity_key_store_t *identity_key_store); +GHashTable* session_store_new(void); +GHashTable* pre_key_store_new(void); +GHashTable* signed_pre_key_store_new(void); +void identity_key_store_new(identity_key_store_t* identity_key_store); /** * Returns a copy of the serialized session record corresponding to the @@ -68,9 +69,9 @@ void identity_key_store_new(identity_key_store_t *identity_key_store); * @return 1 if the session was loaded, 0 if the session was not found, negative on failure */ #ifdef HAVE_LIBSIGNAL_LT_2_3_2 -int load_session(signal_buffer **record, const signal_protocol_address *address, void *user_data); +int load_session(signal_buffer** record, const signal_protocol_address* address, void* user_data); #else -int load_session(signal_buffer **record, signal_buffer **user_record, const signal_protocol_address *address, void *user_data); +int load_session(signal_buffer** record, signal_buffer** user_record, const signal_protocol_address* address, void* user_data); #endif /** @@ -81,7 +82,7 @@ int load_session(signal_buffer **record, signal_buffer **user_record, const sign * @param name_len the length of the name * @return size of the sessions array, or negative on failure */ -int get_sub_device_sessions(signal_int_list **sessions, const char *name, size_t name_len, void *user_data); +int get_sub_device_sessions(signal_int_list** sessions, const char* name, size_t name_len, void* user_data); /** * Commit to storage the session record for a given @@ -94,9 +95,9 @@ int get_sub_device_sessions(signal_int_list **sessions, const char *name, size_t * @return 0 on success, negative on failure */ #ifdef HAVE_LIBSIGNAL_LT_2_3_2 -int store_session(const signal_protocol_address *address, uint8_t *record, size_t record_len, void *user_data); +int store_session(const signal_protocol_address* address, uint8_t* record, size_t record_len, void* user_data); #else -int store_session(const signal_protocol_address *address, uint8_t *record, size_t record_len, uint8_t *user_record, size_t user_record_len, void *user_data); +int store_session(const signal_protocol_address* address, uint8_t* record, size_t record_len, uint8_t* user_record, size_t user_record_len, void* user_data); #endif /** @@ -106,7 +107,7 @@ int store_session(const signal_protocol_address *address, uint8_t *record, size_ * @param address the address of the remote client * @return 1 if a session record exists, 0 otherwise. */ -int contains_session(const signal_protocol_address *address, void *user_data); +int contains_session(const signal_protocol_address* address, void* user_data); /** * Remove a session record for a recipient ID + device ID tuple. @@ -114,7 +115,7 @@ int contains_session(const signal_protocol_address *address, void *user_data); * @param address the address of the remote client * @return 1 if a session was deleted, 0 if a session was not deleted, negative on error */ -int delete_session(const signal_protocol_address *address, void *user_data); +int delete_session(const signal_protocol_address* address, void* user_data); /** * Remove the session records corresponding to all devices of a recipient ID. @@ -123,7 +124,7 @@ int delete_session(const signal_protocol_address *address, void *user_data); * @param name_len the length of the name * @return the number of deleted sessions on success, negative on failure */ -int delete_all_sessions(const char *name, size_t name_len, void *user_data); +int delete_all_sessions(const char* name, size_t name_len, void* user_data); /** * Load a local serialized PreKey record. @@ -135,7 +136,7 @@ int delete_all_sessions(const char *name, size_t name_len, void *user_data); * @retval SG_SUCCESS if the key was found * @retval SG_ERR_INVALID_KEY_ID if the key could not be found */ -int load_pre_key(signal_buffer **record, uint32_t pre_key_id, void *user_data); +int load_pre_key(signal_buffer** record, uint32_t pre_key_id, void* user_data); /** * Store a local serialized PreKey record. @@ -145,7 +146,7 @@ int load_pre_key(signal_buffer **record, uint32_t pre_key_id, void *user_data); * @param record_len length of the serialized record * @return 0 on success, negative on failure */ -int store_pre_key(uint32_t pre_key_id, uint8_t *record, size_t record_len, void *user_data); +int store_pre_key(uint32_t pre_key_id, uint8_t* record, size_t record_len, void* user_data); /** * Determine whether there is a committed PreKey record matching the @@ -154,7 +155,7 @@ int store_pre_key(uint32_t pre_key_id, uint8_t *record, size_t record_len, void * @param pre_key_id A PreKey record ID. * @return 1 if the store has a record for the PreKey ID, 0 otherwise */ -int contains_pre_key(uint32_t pre_key_id, void *user_data); +int contains_pre_key(uint32_t pre_key_id, void* user_data); /** * Delete a PreKey record from local storage. @@ -162,7 +163,7 @@ int contains_pre_key(uint32_t pre_key_id, void *user_data); * @param pre_key_id The ID of the PreKey record to remove. * @return 0 on success, negative on failure */ -int remove_pre_key(uint32_t pre_key_id, void *user_data); +int remove_pre_key(uint32_t pre_key_id, void* user_data); /** * Load a local serialized signed PreKey record. @@ -174,7 +175,7 @@ int remove_pre_key(uint32_t pre_key_id, void *user_data); * @retval SG_SUCCESS if the key was found * @retval SG_ERR_INVALID_KEY_ID if the key could not be found */ -int load_signed_pre_key(signal_buffer **record, uint32_t signed_pre_key_id, void *user_data); +int load_signed_pre_key(signal_buffer** record, uint32_t signed_pre_key_id, void* user_data); /** * Store a local serialized signed PreKey record. @@ -184,7 +185,7 @@ int load_signed_pre_key(signal_buffer **record, uint32_t signed_pre_key_id, void * @param record_len length of the serialized record * @return 0 on success, negative on failure */ -int store_signed_pre_key(uint32_t signed_pre_key_id, uint8_t *record, size_t record_len, void *user_data); +int store_signed_pre_key(uint32_t signed_pre_key_id, uint8_t* record, size_t record_len, void* user_data); /** * Determine whether there is a committed signed PreKey record matching @@ -193,7 +194,7 @@ int store_signed_pre_key(uint32_t signed_pre_key_id, uint8_t *record, size_t rec * @param signed_pre_key_id A signed PreKey record ID. * @return 1 if the store has a record for the signed PreKey ID, 0 otherwise */ -int contains_signed_pre_key(uint32_t signed_pre_key_id, void *user_data); +int contains_signed_pre_key(uint32_t signed_pre_key_id, void* user_data); /** * Delete a SignedPreKeyRecord from local storage. @@ -201,7 +202,7 @@ int contains_signed_pre_key(uint32_t signed_pre_key_id, void *user_data); * @param signed_pre_key_id The ID of the signed PreKey record to remove. * @return 0 on success, negative on failure */ -int remove_signed_pre_key(uint32_t signed_pre_key_id, void *user_data); +int remove_signed_pre_key(uint32_t signed_pre_key_id, void* user_data); /** * Get the local client's identity key pair. @@ -214,7 +215,7 @@ int remove_signed_pre_key(uint32_t signed_pre_key_id, void *user_data); * The Signal Protocol library is responsible for freeing this buffer. * @return 0 on success, negative on failure */ -int get_identity_key_pair(signal_buffer **public_data, signal_buffer **private_data, void *user_data); +int get_identity_key_pair(signal_buffer** public_data, signal_buffer** private_data, void* user_data); /** * Return the local client's registration ID. @@ -226,7 +227,7 @@ int get_identity_key_pair(signal_buffer **public_data, signal_buffer **private_d * registration ID, if it was successfully retrieved. * @return 0 on success, negative on failure */ -int get_local_registration_id(void *user_data, uint32_t *registration_id); +int get_local_registration_id(void* user_data, uint32_t* registration_id); /** * Save a remote client's identity key @@ -241,7 +242,7 @@ int get_local_registration_id(void *user_data, uint32_t *registration_id); * @param key_len Length of the remote client's identity key * @return 0 on success, negative on failure */ -int save_identity(const signal_protocol_address *address, uint8_t *key_data, size_t key_len, void *user_data); +int save_identity(const signal_protocol_address* address, uint8_t* key_data, size_t key_len, void* user_data); /** * Verify a remote client's identity key. @@ -259,7 +260,7 @@ int save_identity(const signal_protocol_address *address, uint8_t *key_data, siz * @param key_len Length of the identity key to verify * @return 1 if trusted, 0 if untrusted, negative on failure */ -int is_trusted_identity(const signal_protocol_address *address, uint8_t *key_data, size_t key_len, void *user_data); +int is_trusted_identity(const signal_protocol_address* address, uint8_t* key_data, size_t key_len, void* user_data); /** * Store a serialized sender key record for a given @@ -270,7 +271,7 @@ int is_trusted_identity(const signal_protocol_address *address, uint8_t *key_dat * @param record_len length of the serialized record * @return 0 on success, negative on failure */ -int store_sender_key(const signal_protocol_sender_key_name *sender_key_name, uint8_t *record, size_t record_len, uint8_t *user_record, size_t user_record_len, void *user_data); +int store_sender_key(const signal_protocol_sender_key_name* sender_key_name, uint8_t* record, size_t record_len, uint8_t* user_record, size_t user_record_len, void* user_data); /** * Returns a copy of the sender key record corresponding to the @@ -282,4 +283,4 @@ int store_sender_key(const signal_protocol_sender_key_name *sender_key_name, uin * @param sender_key_name the (groupId + senderId + deviceId) tuple * @return 1 if the record was loaded, 0 if the record was not found, negative on failure */ -int load_sender_key(signal_buffer **record, signal_buffer **user_record, const signal_protocol_sender_key_name *sender_key_name, void *user_data); +int load_sender_key(signal_buffer** record, signal_buffer** user_record, const signal_protocol_sender_key_name* sender_key_name, void* user_data); diff --git a/src/otr/otr.c b/src/otr/otr.c index 5c9f11be..0b925642 100644 --- a/src/otr/otr.c +++ b/src/otr/otr.c @@ -52,15 +52,15 @@ #include "xmpp/contact.h" #include "xmpp/xmpp.h" -#define PRESENCE_ONLINE 1 +#define PRESENCE_ONLINE 1 #define PRESENCE_OFFLINE 0 #define PRESENCE_UNKNOWN -1 static OtrlUserState user_state; static OtrlMessageAppOps ops; -static char *jid; +static char* jid; static gboolean data_loaded; -static GHashTable *smp_initiators; +static GHashTable* smp_initiators; OtrlUserState otr_userstate(void) @@ -82,13 +82,13 @@ otr_smpinitators(void) // ops callbacks static OtrlPolicy -cb_policy(void *opdata, ConnContext *context) +cb_policy(void* opdata, ConnContext* context) { return otrlib_policy(); } static int -cb_is_logged_in(void *opdata, const char *accountname, const char *protocol, const char *recipient) +cb_is_logged_in(void* opdata, const char* accountname, const char* protocol, const char* recipient) { jabber_conn_status_t conn_status = connection_get_status(); if (conn_status != JABBER_CONNECTED) { @@ -116,20 +116,20 @@ cb_is_logged_in(void *opdata, const char *accountname, const char *protocol, con } static void -cb_inject_message(void *opdata, const char *accountname, - const char *protocol, const char *recipient, const char *message) +cb_inject_message(void* opdata, const char* accountname, + const char* protocol, const char* recipient, const char* message) { - char *id = message_send_chat_otr(recipient, message, FALSE, NULL); + char* id = message_send_chat_otr(recipient, message, FALSE, NULL); free(id); } static void -cb_write_fingerprints(void *opdata) +cb_write_fingerprints(void* opdata) { gcry_error_t err = 0; - gchar *otr_dir = files_get_account_data_path(DIR_OTR, jid); + gchar* otr_dir = files_get_account_data_path(DIR_OTR, jid); - GString *fpsfilename = g_string_new(otr_dir); + GString* fpsfilename = g_string_new(otr_dir); g_string_append(fpsfilename, "/fingerprints.txt"); err = otrl_privkey_write_fingerprints(user_state, fpsfilename->str); @@ -143,11 +143,11 @@ cb_write_fingerprints(void *opdata) } static void -cb_gone_secure(void *opdata, ConnContext *context) +cb_gone_secure(void* opdata, ConnContext* context) { - ProfChatWin *chatwin = wins_get_chat(context->username); + ProfChatWin* chatwin = wins_get_chat(context->username); if (!chatwin) { - chatwin = (ProfChatWin*) wins_new_chat(context->username); + chatwin = (ProfChatWin*)wins_new_chat(context->username); } chatwin_otr_secured(chatwin, otr_is_trusted(context->username)); @@ -202,7 +202,7 @@ otr_poll(void) } void -otr_on_connect(ProfAccount *account) +otr_on_connect(ProfAccount* account) { if (jid) { free(jid); @@ -210,7 +210,7 @@ otr_on_connect(ProfAccount *account) jid = strdup(account->jid); log_info("Loading OTR key for %s", jid); - gchar *otr_dir = files_get_account_data_path(DIR_OTR, jid); + gchar* otr_dir = files_get_account_data_path(DIR_OTR, jid); if (!mkdir_recursive(otr_dir)) { log_error("Could not create %s for account %s.", otr_dir, jid); @@ -226,7 +226,7 @@ otr_on_connect(ProfAccount *account) gcry_error_t err = 0; - GString *keysfilename = g_string_new(otr_dir); + GString* keysfilename = g_string_new(otr_dir); g_string_append(keysfilename, "/keys.txt"); if (!g_file_test(keysfilename->str, G_FILE_TEST_IS_REGULAR)) { log_info("No OTR private key file found %s", keysfilename->str); @@ -254,7 +254,7 @@ otr_on_connect(ProfAccount *account) data_loaded = TRUE; } - GString *fpsfilename = g_string_new(otr_dir); + GString* fpsfilename = g_string_new(otr_dir); g_string_append(fpsfilename, "/fingerprints.txt"); if (!g_file_test(fpsfilename->str, G_FILE_TEST_IS_REGULAR)) { log_info("No OTR fingerprints file found %s", fpsfilename->str); @@ -285,10 +285,10 @@ otr_on_connect(ProfAccount *account) } char* -otr_on_message_recv(const char *const barejid, const char *const resource, const char *const message, gboolean *decrypted) +otr_on_message_recv(const char* const barejid, const char* const resource, const char* const message, gboolean* decrypted) { prof_otrpolicy_t policy = otr_get_policy(barejid); - char *whitespace_base = strstr(message, OTRL_MESSAGE_TAG_BASE); + char* whitespace_base = strstr(message, OTRL_MESSAGE_TAG_BASE); //check for OTR whitespace (opportunistic or always) if (policy == PROF_OTRPOLICY_OPPORTUNISTIC || policy == PROF_OTRPOLICY_ALWAYS) { @@ -300,24 +300,24 @@ otr_on_message_recv(const char *const barejid, const char *const resource, const if (strstr(message, OTRL_MESSAGE_TAG_V2) && strstr(message, OTRL_MESSAGE_TAG_V1)) { tag_length = 32; } - memmove(whitespace_base, whitespace_base+tag_length, tag_length); - char *otr_query_message = otr_start_query(); + memmove(whitespace_base, whitespace_base + tag_length, tag_length); + char* otr_query_message = otr_start_query(); cons_show("OTR Whitespace pattern detected. Attempting to start OTR session..."); - char *id = message_send_chat_otr(barejid, otr_query_message, FALSE, NULL); + char* id = message_send_chat_otr(barejid, otr_query_message, FALSE, NULL); free(id); } } } - char *newmessage = otr_decrypt_message(barejid, message, decrypted); + char* newmessage = otr_decrypt_message(barejid, message, decrypted); if (!newmessage) { // internal OTR message return NULL; } if (policy == PROF_OTRPOLICY_ALWAYS && *decrypted == FALSE && !whitespace_base) { - char *otr_query_message = otr_start_query(); + char* otr_query_message = otr_start_query(); cons_show("Attempting to start OTR session..."); - char *id = message_send_chat_otr(barejid, otr_query_message, FALSE, NULL); + char* id = message_send_chat_otr(barejid, otr_query_message, FALSE, NULL); free(id); } @@ -325,14 +325,14 @@ otr_on_message_recv(const char *const barejid, const char *const resource, const } gboolean -otr_on_message_send(ProfChatWin *chatwin, const char *const message, gboolean request_receipt, const char *const replace_id) +otr_on_message_send(ProfChatWin* chatwin, const char* const message, gboolean request_receipt, const char* const replace_id) { - char *id = NULL; + char* id = NULL; prof_otrpolicy_t policy = otr_get_policy(chatwin->barejid); // Send encrypted message if (otr_is_secure(chatwin->barejid)) { - char *encrypted = otr_encrypt_message(chatwin->barejid, message); + char* encrypted = otr_encrypt_message(chatwin->barejid, message); if (encrypted) { id = message_send_chat_otr(chatwin->barejid, encrypted, request_receipt, replace_id); chat_log_otr_msg_out(chatwin->barejid, message, NULL); @@ -355,7 +355,7 @@ otr_on_message_send(ProfChatWin *chatwin, const char *const message, gboolean re // tag and send for policy opportunistic if (policy == PROF_OTRPOLICY_OPPORTUNISTIC) { - char *otr_tagged_msg = otr_tag_message(message); + char* otr_tagged_msg = otr_tag_message(message); id = message_send_chat_otr(chatwin->barejid, otr_tagged_msg, request_receipt, replace_id); chatwin_outgoing_msg(chatwin, message, id, PROF_MSG_ENC_NONE, request_receipt, replace_id); chat_log_msg_out(chatwin->barejid, message, NULL); @@ -368,7 +368,7 @@ otr_on_message_send(ProfChatWin *chatwin, const char *const message, gboolean re } void -otr_keygen(ProfAccount *account) +otr_keygen(ProfAccount* account) { if (data_loaded) { cons_show("OTR key already generated."); @@ -379,7 +379,7 @@ otr_keygen(ProfAccount *account) jid = strdup(account->jid); log_info("Generating OTR key for %s", jid); - gchar *otr_dir = files_get_account_data_path(DIR_OTR, jid); + gchar* otr_dir = files_get_account_data_path(DIR_OTR, jid); if (!mkdir_recursive(otr_dir)) { log_error("Could not create %s for account %s.", otr_dir, jid); @@ -390,7 +390,7 @@ otr_keygen(ProfAccount *account) gcry_error_t err = 0; - GString *keysfilename = g_string_new(otr_dir); + GString* keysfilename = g_string_new(otr_dir); g_string_append(keysfilename, "/keys.txt"); log_debug("Generating private key file %s for %s", keysfilename->str, jid); cons_show("Generating private key, this may take some time."); @@ -408,7 +408,7 @@ otr_keygen(ProfAccount *account) cons_show(""); cons_show("Private key generation complete."); - GString *fpsfilename = g_string_new(otr_dir); + GString* fpsfilename = g_string_new(otr_dir); g_string_append(fpsfilename, "/fingerprints.txt"); log_debug("Generating fingerprints file %s for %s", fpsfilename->str, jid); err = otrl_privkey_write_fingerprints(user_state, fpsfilename->str); @@ -454,21 +454,21 @@ otr_key_loaded(void) } char* -otr_tag_message(const char *const msg) +otr_tag_message(const char* const msg) { - GString *otr_message = g_string_new(msg); + GString* otr_message = g_string_new(msg); g_string_append(otr_message, OTRL_MESSAGE_TAG_BASE); g_string_append(otr_message, OTRL_MESSAGE_TAG_V2); - char *result = otr_message->str; + char* result = otr_message->str; g_string_free(otr_message, FALSE); return result; } gboolean -otr_is_secure(const char *const recipient) +otr_is_secure(const char* const recipient) { - ConnContext *context = otrlib_context_find(user_state, recipient, jid); + ConnContext* context = otrlib_context_find(user_state, recipient, jid); if (context == NULL) { return FALSE; @@ -482,9 +482,9 @@ otr_is_secure(const char *const recipient) } gboolean -otr_is_trusted(const char *const recipient) +otr_is_trusted(const char* const recipient) { - ConnContext *context = otrlib_context_find(user_state, recipient, jid); + ConnContext* context = otrlib_context_find(user_state, recipient, jid); if (context == NULL) { return FALSE; @@ -508,9 +508,9 @@ otr_is_trusted(const char *const recipient) } void -otr_trust(const char *const recipient) +otr_trust(const char* const recipient) { - ConnContext *context = otrlib_context_find(user_state, recipient, jid); + ConnContext* context = otrlib_context_find(user_state, recipient, jid); if (context == NULL) { return; @@ -532,9 +532,9 @@ otr_trust(const char *const recipient) } void -otr_untrust(const char *const recipient) +otr_untrust(const char* const recipient) { - ConnContext *context = otrlib_context_find(user_state, recipient, jid); + ConnContext* context = otrlib_context_find(user_state, recipient, jid); if (context == NULL) { return; @@ -556,9 +556,9 @@ otr_untrust(const char *const recipient) } void -otr_smp_secret(const char *const recipient, const char *secret) +otr_smp_secret(const char* const recipient, const char* secret) { - ConnContext *context = otrlib_context_find(user_state, recipient, jid); + ConnContext* context = otrlib_context_find(user_state, recipient, jid); if (context == NULL) { return; @@ -569,7 +569,7 @@ otr_smp_secret(const char *const recipient, const char *secret) } // if recipient initiated SMP, send response, else initialise - ProfChatWin *chatwin = wins_get_chat(recipient); + ProfChatWin* chatwin = wins_get_chat(recipient); if (g_hash_table_contains(smp_initiators, recipient)) { otrl_message_respond_smp(user_state, &ops, NULL, context, (const unsigned char*)secret, strlen(secret)); if (chatwin) { @@ -585,9 +585,9 @@ otr_smp_secret(const char *const recipient, const char *secret) } void -otr_smp_question(const char *const recipient, const char *question, const char *answer) +otr_smp_question(const char* const recipient, const char* question, const char* answer) { - ConnContext *context = otrlib_context_find(user_state, recipient, jid); + ConnContext* context = otrlib_context_find(user_state, recipient, jid); if (context == NULL) { return; @@ -598,16 +598,16 @@ otr_smp_question(const char *const recipient, const char *question, const char * } otrl_message_initiate_smp_q(user_state, &ops, NULL, context, question, (const unsigned char*)answer, strlen(answer)); - ProfChatWin *chatwin = wins_get_chat(recipient); + ProfChatWin* chatwin = wins_get_chat(recipient); if (chatwin) { chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_AUTH_WAIT, NULL); } } void -otr_smp_answer(const char *const recipient, const char *answer) +otr_smp_answer(const char* const recipient, const char* answer) { - ConnContext *context = otrlib_context_find(user_state, recipient, jid); + ConnContext* context = otrlib_context_find(user_state, recipient, jid); if (context == NULL) { return; @@ -622,7 +622,7 @@ otr_smp_answer(const char *const recipient, const char *answer) } void -otr_end_session(const char *const recipient) +otr_end_session(const char* const recipient) { otrlib_end_session(user_state, recipient, jid, &ops); } @@ -632,18 +632,18 @@ otr_get_my_fingerprint(void) { char fingerprint[45]; otrl_privkey_fingerprint(user_state, fingerprint, jid, "xmpp"); - char *result = strdup(fingerprint); + char* result = strdup(fingerprint); return result; } char* -otr_get_their_fingerprint(const char *const recipient) +otr_get_their_fingerprint(const char* const recipient) { - ConnContext *context = otrlib_context_find(user_state, recipient, jid); + ConnContext* context = otrlib_context_find(user_state, recipient, jid); if (context) { - Fingerprint *fingerprint = context->active_fingerprint; + Fingerprint* fingerprint = context->active_fingerprint; char readable[45]; otrl_privkey_hash_to_human(readable, fingerprint->fingerprint); return strdup(readable); @@ -653,10 +653,10 @@ otr_get_their_fingerprint(const char *const recipient) } prof_otrpolicy_t -otr_get_policy(const char *const recipient) +otr_get_policy(const char* const recipient) { - char *account_name = session_get_account_name(); - ProfAccount *account = accounts_get_account(account_name); + char* account_name = session_get_account_name(); + ProfAccount* account = accounts_get_account(account_name); // check contact specific setting if (g_list_find_custom(account->otr_manual, recipient, (GCompareFunc)g_strcmp0)) { account_free(account); @@ -689,7 +689,7 @@ otr_get_policy(const char *const recipient) account_free(account); // check global setting - char *pref_otr_policy = prefs_get_string(PREF_OTR_POLICY); + char* pref_otr_policy = prefs_get_string(PREF_OTR_POLICY); // pref defaults to manual prof_otrpolicy_t result = PROF_OTRPOLICY_MANUAL; @@ -706,9 +706,9 @@ otr_get_policy(const char *const recipient) } char* -otr_encrypt_message(const char *const to, const char *const message) +otr_encrypt_message(const char* const to, const char* const message) { - char *newmessage = NULL; + char* newmessage = NULL; gcry_error_t err = otrlib_encrypt_message(user_state, &ops, jid, to, message, &newmessage); if (err != 0) { @@ -719,7 +719,7 @@ otr_encrypt_message(const char *const to, const char *const message) } static void -_otr_tlv_free(OtrlTLV *tlvs) +_otr_tlv_free(OtrlTLV* tlvs) { if (tlvs) { otrl_tlv_free(tlvs); @@ -727,23 +727,23 @@ _otr_tlv_free(OtrlTLV *tlvs) } char* -otr_decrypt_message(const char *const from, const char *const message, gboolean *decrypted) +otr_decrypt_message(const char* const from, const char* const message, gboolean* decrypted) { - char *newmessage = NULL; - OtrlTLV *tlvs = NULL; + char* newmessage = NULL; + OtrlTLV* tlvs = NULL; int result = otrlib_decrypt_message(user_state, &ops, jid, from, message, &newmessage, &tlvs); // internal libotr message if (result == 1) { - ConnContext *context = otrlib_context_find(user_state, from, jid); + ConnContext* context = otrlib_context_find(user_state, from, jid); // common tlv handling - OtrlTLV *tlv = otrl_tlv_find(tlvs, OTRL_TLV_DISCONNECTED); + OtrlTLV* tlv = otrl_tlv_find(tlvs, OTRL_TLV_DISCONNECTED); if (tlv) { if (context) { otrl_context_force_plaintext(context); - ProfChatWin *chatwin = wins_get_chat(from); + ProfChatWin* chatwin = wins_get_chat(from); if (chatwin) { chatwin_otr_unsecured(chatwin); } @@ -756,7 +756,7 @@ otr_decrypt_message(const char *const from, const char *const message, gboolean return NULL; - // message was processed, return to user + // message was processed, return to user } else if (newmessage) { _otr_tlv_free(tlvs); if (g_str_has_prefix(message, "?OTR:")) { @@ -764,7 +764,7 @@ otr_decrypt_message(const char *const from, const char *const message, gboolean } return newmessage; - // normal non OTR message + // normal non OTR message } else { _otr_tlv_free(tlvs); *decrypted = FALSE; @@ -773,7 +773,7 @@ otr_decrypt_message(const char *const from, const char *const message, gboolean } void -otr_free_message(char *message) +otr_free_message(char* message) { otrl_message_free(message); } diff --git a/src/otr/otr.h b/src/otr/otr.h index 58b6decf..c909c721 100644 --- a/src/otr/otr.h +++ b/src/otr/otr.h @@ -70,37 +70,37 @@ void otr_shutdown(void); char* otr_libotr_version(void); char* otr_start_query(void); void otr_poll(void); -void otr_on_connect(ProfAccount *account); +void otr_on_connect(ProfAccount* account); -char* otr_on_message_recv(const char *const barejid, const char *const resource, const char *const message, gboolean *decrypted); -gboolean otr_on_message_send(ProfChatWin *chatwin, const char *const message, gboolean request_receipt, const char *const replace_id); +char* otr_on_message_recv(const char* const barejid, const char* const resource, const char* const message, gboolean* decrypted); +gboolean otr_on_message_send(ProfChatWin* chatwin, const char* const message, gboolean request_receipt, const char* const replace_id); -void otr_keygen(ProfAccount *account); +void otr_keygen(ProfAccount* account); -char* otr_tag_message(const char *const msg); +char* otr_tag_message(const char* const msg); gboolean otr_key_loaded(void); -gboolean otr_is_secure(const char *const recipient); +gboolean otr_is_secure(const char* const recipient); -gboolean otr_is_trusted(const char *const recipient); -void otr_trust(const char *const recipient); -void otr_untrust(const char *const recipient); +gboolean otr_is_trusted(const char* const recipient); +void otr_trust(const char* const recipient); +void otr_untrust(const char* const recipient); -void otr_smp_secret(const char *const recipient, const char *secret); -void otr_smp_question(const char *const recipient, const char *question, const char *answer); -void otr_smp_answer(const char *const recipient, const char *answer); +void otr_smp_secret(const char* const recipient, const char* secret); +void otr_smp_question(const char* const recipient, const char* question, const char* answer); +void otr_smp_answer(const char* const recipient, const char* answer); -void otr_end_session(const char *const recipient); +void otr_end_session(const char* const recipient); char* otr_get_my_fingerprint(void); -char* otr_get_their_fingerprint(const char *const recipient); +char* otr_get_their_fingerprint(const char* const recipient); -char* otr_encrypt_message(const char *const to, const char *const message); -char* otr_decrypt_message(const char *const from, const char *const message, - gboolean *decrypted); +char* otr_encrypt_message(const char* const to, const char* const message); +char* otr_decrypt_message(const char* const from, const char* const message, + gboolean* decrypted); -void otr_free_message(char *message); +void otr_free_message(char* message); -prof_otrpolicy_t otr_get_policy(const char *const recipient); +prof_otrpolicy_t otr_get_policy(const char* const recipient); #endif diff --git a/src/otr/otrlib.h b/src/otr/otrlib.h index 3c6e02f8..454013e3 100644 --- a/src/otr/otrlib.h +++ b/src/otr/otrlib.h @@ -40,21 +40,21 @@ OtrlPolicy otrlib_policy(void); char* otrlib_start_query(void); -void otrlib_init_ops(OtrlMessageAppOps *ops); +void otrlib_init_ops(OtrlMessageAppOps* ops); void otrlib_init_timer(void); void otrlib_poll(void); -ConnContext* otrlib_context_find(OtrlUserState user_state, const char *const recipient, char *jid); +ConnContext* otrlib_context_find(OtrlUserState user_state, const char* const recipient, char* jid); -void otrlib_end_session(OtrlUserState user_state, const char *const recipient, char *jid, OtrlMessageAppOps *ops); +void otrlib_end_session(OtrlUserState user_state, const char* const recipient, char* jid, OtrlMessageAppOps* ops); -gcry_error_t otrlib_encrypt_message(OtrlUserState user_state, OtrlMessageAppOps *ops, char *jid, const char *const to, - const char *const message, char **newmessage); +gcry_error_t otrlib_encrypt_message(OtrlUserState user_state, OtrlMessageAppOps* ops, char* jid, const char* const to, + const char* const message, char** newmessage); -int otrlib_decrypt_message(OtrlUserState user_state, OtrlMessageAppOps *ops, char *jid, const char *const from, - const char *const message, char **decrypted, OtrlTLV **tlvs); +int otrlib_decrypt_message(OtrlUserState user_state, OtrlMessageAppOps* ops, char* jid, const char* const from, + const char* const message, char** decrypted, OtrlTLV** tlvs); -void otrlib_handle_tlvs(OtrlUserState user_state, OtrlMessageAppOps *ops, ConnContext *context, OtrlTLV *tlvs, GHashTable *smp_initiators); +void otrlib_handle_tlvs(OtrlUserState user_state, OtrlMessageAppOps* ops, ConnContext* context, OtrlTLV* tlvs, GHashTable* smp_initiators); #endif diff --git a/src/otr/otrlibv3.c b/src/otr/otrlibv3.c index 2628b728..0d1389f7 100644 --- a/src/otr/otrlibv3.c +++ b/src/otr/otrlibv3.c @@ -44,7 +44,7 @@ OtrlPolicy otrlib_policy(void) { - return OTRL_POLICY_ALLOW_V1 | OTRL_POLICY_ALLOW_V2 ; + return OTRL_POLICY_ALLOW_V1 | OTRL_POLICY_ALLOW_V2; } void @@ -64,30 +64,30 @@ otrlib_start_query(void) } static int -cb_display_otr_message(void *opdata, const char *accountname, - const char *protocol, const char *username, const char *msg) +cb_display_otr_message(void* opdata, const char* accountname, + const char* protocol, const char* username, const char* msg) { cons_show_error("%s", msg); return 0; } void -otrlib_init_ops(OtrlMessageAppOps *ops) +otrlib_init_ops(OtrlMessageAppOps* ops) { ops->display_otr_message = cb_display_otr_message; } ConnContext* -otrlib_context_find(OtrlUserState user_state, const char *const recipient, char *jid) +otrlib_context_find(OtrlUserState user_state, const char* const recipient, char* jid) { return otrl_context_find(user_state, recipient, jid, "xmpp", 0, NULL, NULL, NULL); } void -otrlib_end_session(OtrlUserState user_state, const char *const recipient, char *jid, OtrlMessageAppOps *ops) +otrlib_end_session(OtrlUserState user_state, const char* const recipient, char* jid, OtrlMessageAppOps* ops) { - ConnContext *context = otrl_context_find(user_state, recipient, jid, "xmpp", - 0, NULL, NULL, NULL); + ConnContext* context = otrl_context_find(user_state, recipient, jid, "xmpp", + 0, NULL, NULL, NULL); if (context) { otrl_message_disconnect(user_state, ops, NULL, jid, "xmpp", recipient); @@ -95,8 +95,8 @@ otrlib_end_session(OtrlUserState user_state, const char *const recipient, char * } gcry_error_t -otrlib_encrypt_message(OtrlUserState user_state, OtrlMessageAppOps *ops, char *jid, const char *const to, - const char *const message, char **newmessage) +otrlib_encrypt_message(OtrlUserState user_state, OtrlMessageAppOps* ops, char* jid, const char* const to, + const char* const message, char** newmessage) { gcry_error_t err; err = otrl_message_sending( @@ -116,8 +116,8 @@ otrlib_encrypt_message(OtrlUserState user_state, OtrlMessageAppOps *ops, char *j } int -otrlib_decrypt_message(OtrlUserState user_state, OtrlMessageAppOps *ops, char *jid, const char *const from, - const char *const message, char **decrypted, OtrlTLV **tlvs) +otrlib_decrypt_message(OtrlUserState user_state, OtrlMessageAppOps* ops, char* jid, const char* const from, + const char* const message, char** decrypted, OtrlTLV** tlvs) { return otrl_message_receiving( user_state, @@ -134,15 +134,15 @@ otrlib_decrypt_message(OtrlUserState user_state, OtrlMessageAppOps *ops, char *j } void -otrlib_handle_tlvs(OtrlUserState user_state, OtrlMessageAppOps *ops, ConnContext *context, OtrlTLV *tlvs, GHashTable *smp_initiators) +otrlib_handle_tlvs(OtrlUserState user_state, OtrlMessageAppOps* ops, ConnContext* context, OtrlTLV* tlvs, GHashTable* smp_initiators) { NextExpectedSMP nextMsg = context->smstate->nextExpected; - OtrlTLV *tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP1); + OtrlTLV* tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP1); if (tlv) { if (nextMsg != OTRL_SMP_EXPECT1) { otrl_message_abort_smp(user_state, ops, NULL, context); } else { - ProfChatWin *chatwin = wins_get_chat(context->username); + ProfChatWin* chatwin = wins_get_chat(context->username); if (chatwin) { chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_INIT, NULL); } @@ -154,10 +154,10 @@ otrlib_handle_tlvs(OtrlUserState user_state, OtrlMessageAppOps *ops, ConnContext if (nextMsg != OTRL_SMP_EXPECT1) { otrl_message_abort_smp(user_state, ops, NULL, context); } else { - ProfChatWin *chatwin = wins_get_chat(context->username); + ProfChatWin* chatwin = wins_get_chat(context->username); if (chatwin) { - char *question = (char *)tlv->data; - char *eoq = memchr(question, '\0', tlv->len); + char* question = (char*)tlv->data; + char* eoq = memchr(question, '\0', tlv->len); if (eoq) { chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_INIT_Q, question); } @@ -178,7 +178,7 @@ otrlib_handle_tlvs(OtrlUserState user_state, OtrlMessageAppOps *ops, ConnContext otrl_message_abort_smp(user_state, ops, NULL, context); } else { context->smstate->nextExpected = OTRL_SMP_EXPECT1; - ProfChatWin *chatwin = wins_get_chat(context->username); + ProfChatWin* chatwin = wins_get_chat(context->username); if (chatwin) { if (context->smstate->received_question == 0) { if (context->active_fingerprint->trust && (context->active_fingerprint->trust[0] != '\0')) { @@ -204,7 +204,7 @@ otrlib_handle_tlvs(OtrlUserState user_state, OtrlMessageAppOps *ops, ConnContext otrl_message_abort_smp(user_state, ops, NULL, context); } else { context->smstate->nextExpected = OTRL_SMP_EXPECT1; - ProfChatWin *chatwin = wins_get_chat(context->username); + ProfChatWin* chatwin = wins_get_chat(context->username); if (chatwin) { if (context->active_fingerprint->trust && (context->active_fingerprint->trust[0] != '\0')) { chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_SUCCESS, NULL); @@ -219,7 +219,7 @@ otrlib_handle_tlvs(OtrlUserState user_state, OtrlMessageAppOps *ops, ConnContext tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP_ABORT); if (tlv) { context->smstate->nextExpected = OTRL_SMP_EXPECT1; - ProfChatWin *chatwin = wins_get_chat(context->username); + ProfChatWin* chatwin = wins_get_chat(context->username); if (chatwin) { chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_ABORT, NULL); chatwin_otr_untrust(chatwin); diff --git a/src/otr/otrlibv4.c b/src/otr/otrlibv4.c index fbe24a47..38b39df4 100644 --- a/src/otr/otrlibv4.c +++ b/src/otr/otrlibv4.c @@ -43,7 +43,7 @@ #include "ui/ui.h" #include "ui/window_list.h" -static GTimer *timer; +static GTimer* timer; static unsigned int current_interval; OtrlPolicy @@ -67,7 +67,7 @@ otrlib_poll(void) if (current_interval != 0 && elapsed > current_interval) { OtrlUserState user_state = otr_userstate(); - OtrlMessageAppOps *ops = otr_messageops(); + OtrlMessageAppOps* ops = otr_messageops(); otrl_message_poll(user_state, ops, NULL); g_timer_start(timer); } @@ -80,172 +80,169 @@ otrlib_start_query(void) } static const char* -cb_otr_error_message(void *opdata, ConnContext *context, OtrlErrorCode err_code) +cb_otr_error_message(void* opdata, ConnContext* context, OtrlErrorCode err_code) { - switch(err_code) - { - case OTRL_ERRCODE_ENCRYPTION_ERROR: - return strdup("OTR Error: occurred while encrypting a message"); - case OTRL_ERRCODE_MSG_NOT_IN_PRIVATE: - return strdup("OTR Error: Sent encrypted message to somebody who is not in a mutual OTR session"); - case OTRL_ERRCODE_MSG_UNREADABLE: - return strdup("OTR Error: sent an unreadable encrypted message"); - case OTRL_ERRCODE_MSG_MALFORMED: - return strdup("OTR Error: message sent is malformed"); - default: - return strdup("OTR Error: unknown"); + switch (err_code) { + case OTRL_ERRCODE_ENCRYPTION_ERROR: + return strdup("OTR Error: occurred while encrypting a message"); + case OTRL_ERRCODE_MSG_NOT_IN_PRIVATE: + return strdup("OTR Error: Sent encrypted message to somebody who is not in a mutual OTR session"); + case OTRL_ERRCODE_MSG_UNREADABLE: + return strdup("OTR Error: sent an unreadable encrypted message"); + case OTRL_ERRCODE_MSG_MALFORMED: + return strdup("OTR Error: message sent is malformed"); + default: + return strdup("OTR Error: unknown"); } } static void -cb_otr_error_message_free(void *opdata, const char *err_msg) +cb_otr_error_message_free(void* opdata, const char* err_msg) { - free((char *)err_msg); + free((char*)err_msg); } static void -cb_timer_control(void *opdata, unsigned int interval) +cb_timer_control(void* opdata, unsigned int interval) { current_interval = interval; } static void -cb_handle_msg_event(void *opdata, OtrlMessageEvent msg_event, - ConnContext *context, const char *message, - gcry_error_t err) +cb_handle_msg_event(void* opdata, OtrlMessageEvent msg_event, + ConnContext* context, const char* message, + gcry_error_t err) { - GString *err_msg; - switch (msg_event) - { - case OTRL_MSGEVENT_ENCRYPTION_REQUIRED: - ui_handle_otr_error(context->username, "OTR: Policy requires encryption, but attempting to send an unencrypted message."); - break; - case OTRL_MSGEVENT_ENCRYPTION_ERROR: - ui_handle_otr_error(context->username, "OTR: Error occurred while encrypting a message, message not sent."); - break; - case OTRL_MSGEVENT_CONNECTION_ENDED: - ui_handle_otr_error(context->username, "OTR: Message not sent because contact has ended the private conversation."); - break; - case OTRL_MSGEVENT_SETUP_ERROR: - ui_handle_otr_error(context->username, "OTR: A private conversation could not be set up."); - break; - case OTRL_MSGEVENT_MSG_REFLECTED: - ui_handle_otr_error(context->username, "OTR: Received our own OTR message."); - break; - case OTRL_MSGEVENT_MSG_RESENT: - ui_handle_otr_error(context->username, "OTR: The previous message was resent."); - break; - case OTRL_MSGEVENT_RCVDMSG_NOT_IN_PRIVATE: - ui_handle_otr_error(context->username, "OTR: Received an encrypted message but no private connection established."); - break; - case OTRL_MSGEVENT_RCVDMSG_UNREADABLE: - ui_handle_otr_error(context->username, "OTR: Cannot read the received message."); - break; - case OTRL_MSGEVENT_RCVDMSG_MALFORMED: - ui_handle_otr_error(context->username, "OTR: The message received contains malformed data."); - break; - case OTRL_MSGEVENT_RCVDMSG_GENERAL_ERR: - err_msg = g_string_new("OTR: Received error: "); - g_string_append(err_msg, message); - g_string_append(err_msg, "."); - ui_handle_otr_error(context->username, err_msg->str); - g_string_free(err_msg, TRUE); - break; - case OTRL_MSGEVENT_RCVDMSG_UNENCRYPTED: - err_msg = g_string_new("OTR: Received an unencrypted message: "); - g_string_append(err_msg, message); - ui_handle_otr_error(context->username, err_msg->str); - g_string_free(err_msg, TRUE); - break; - case OTRL_MSGEVENT_RCVDMSG_UNRECOGNIZED: - ui_handle_otr_error(context->username, "OTR: Cannot recognize the type of message received."); - break; - case OTRL_MSGEVENT_RCVDMSG_FOR_OTHER_INSTANCE: - ui_handle_otr_error(context->username, "OTR: Received and discarded a message intended for another instance."); - break; - default: - break; + GString* err_msg; + switch (msg_event) { + case OTRL_MSGEVENT_ENCRYPTION_REQUIRED: + ui_handle_otr_error(context->username, "OTR: Policy requires encryption, but attempting to send an unencrypted message."); + break; + case OTRL_MSGEVENT_ENCRYPTION_ERROR: + ui_handle_otr_error(context->username, "OTR: Error occurred while encrypting a message, message not sent."); + break; + case OTRL_MSGEVENT_CONNECTION_ENDED: + ui_handle_otr_error(context->username, "OTR: Message not sent because contact has ended the private conversation."); + break; + case OTRL_MSGEVENT_SETUP_ERROR: + ui_handle_otr_error(context->username, "OTR: A private conversation could not be set up."); + break; + case OTRL_MSGEVENT_MSG_REFLECTED: + ui_handle_otr_error(context->username, "OTR: Received our own OTR message."); + break; + case OTRL_MSGEVENT_MSG_RESENT: + ui_handle_otr_error(context->username, "OTR: The previous message was resent."); + break; + case OTRL_MSGEVENT_RCVDMSG_NOT_IN_PRIVATE: + ui_handle_otr_error(context->username, "OTR: Received an encrypted message but no private connection established."); + break; + case OTRL_MSGEVENT_RCVDMSG_UNREADABLE: + ui_handle_otr_error(context->username, "OTR: Cannot read the received message."); + break; + case OTRL_MSGEVENT_RCVDMSG_MALFORMED: + ui_handle_otr_error(context->username, "OTR: The message received contains malformed data."); + break; + case OTRL_MSGEVENT_RCVDMSG_GENERAL_ERR: + err_msg = g_string_new("OTR: Received error: "); + g_string_append(err_msg, message); + g_string_append(err_msg, "."); + ui_handle_otr_error(context->username, err_msg->str); + g_string_free(err_msg, TRUE); + break; + case OTRL_MSGEVENT_RCVDMSG_UNENCRYPTED: + err_msg = g_string_new("OTR: Received an unencrypted message: "); + g_string_append(err_msg, message); + ui_handle_otr_error(context->username, err_msg->str); + g_string_free(err_msg, TRUE); + break; + case OTRL_MSGEVENT_RCVDMSG_UNRECOGNIZED: + ui_handle_otr_error(context->username, "OTR: Cannot recognize the type of message received."); + break; + case OTRL_MSGEVENT_RCVDMSG_FOR_OTHER_INSTANCE: + ui_handle_otr_error(context->username, "OTR: Received and discarded a message intended for another instance."); + break; + default: + break; } } static void -cb_handle_smp_event(void *opdata, OtrlSMPEvent smp_event, - ConnContext *context, unsigned short progress_percent, - char *question) +cb_handle_smp_event(void* opdata, OtrlSMPEvent smp_event, + ConnContext* context, unsigned short progress_percent, + char* question) { NextExpectedSMP nextMsg = context->smstate->nextExpected; OtrlUserState user_state = otr_userstate(); - OtrlMessageAppOps *ops = otr_messageops(); - GHashTable *smp_initiators = otr_smpinitators(); - - ProfChatWin *chatwin = wins_get_chat(context->username); - - switch(smp_event) - { - case OTRL_SMPEVENT_ASK_FOR_SECRET: - if (chatwin) { - chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_INIT, NULL); + OtrlMessageAppOps* ops = otr_messageops(); + GHashTable* smp_initiators = otr_smpinitators(); + + ProfChatWin* chatwin = wins_get_chat(context->username); + + switch (smp_event) { + case OTRL_SMPEVENT_ASK_FOR_SECRET: + if (chatwin) { + chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_INIT, NULL); + } + g_hash_table_insert(smp_initiators, strdup(context->username), strdup(context->username)); + break; + + case OTRL_SMPEVENT_ASK_FOR_ANSWER: + if (chatwin) { + chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_INIT_Q, question); + } + break; + + case OTRL_SMPEVENT_SUCCESS: + if (chatwin) { + if (context->smstate->received_question == 0) { + chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_SUCCESS, NULL); + chatwin_otr_trust(chatwin); + } else { + chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_SUCCESS_Q, NULL); } - g_hash_table_insert(smp_initiators, strdup(context->username), strdup(context->username)); - break; - - case OTRL_SMPEVENT_ASK_FOR_ANSWER: - if (chatwin) { - chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_INIT_Q, question); - } - break; - - case OTRL_SMPEVENT_SUCCESS: - if (chatwin) { - if (context->smstate->received_question == 0) { - chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_SUCCESS, NULL); - chatwin_otr_trust(chatwin); - } else { - chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_SUCCESS_Q, NULL); - } - } - break; - - case OTRL_SMPEVENT_FAILURE: - if (chatwin) { - if (context->smstate->received_question == 0) { - if (nextMsg == OTRL_SMP_EXPECT3) { - chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_SENDER_FAIL, NULL); - } else if (nextMsg == OTRL_SMP_EXPECT4) { - chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_RECEIVER_FAIL, NULL); - } - chatwin_otr_untrust(chatwin); - } else { - chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_FAIL_Q, NULL); + } + break; + + case OTRL_SMPEVENT_FAILURE: + if (chatwin) { + if (context->smstate->received_question == 0) { + if (nextMsg == OTRL_SMP_EXPECT3) { + chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_SENDER_FAIL, NULL); + } else if (nextMsg == OTRL_SMP_EXPECT4) { + chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_RECEIVER_FAIL, NULL); } + chatwin_otr_untrust(chatwin); + } else { + chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_FAIL_Q, NULL); } - break; + } + break; - case OTRL_SMPEVENT_ERROR: - otrl_message_abort_smp(user_state, ops, NULL, context); - break; + case OTRL_SMPEVENT_ERROR: + otrl_message_abort_smp(user_state, ops, NULL, context); + break; - case OTRL_SMPEVENT_CHEATED: - otrl_message_abort_smp(user_state, ops, NULL, context); - break; + case OTRL_SMPEVENT_CHEATED: + otrl_message_abort_smp(user_state, ops, NULL, context); + break; - case OTRL_SMPEVENT_ABORT: - if (chatwin) { - chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_ABORT, NULL); - chatwin_otr_untrust(chatwin); - } - break; + case OTRL_SMPEVENT_ABORT: + if (chatwin) { + chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_ABORT, NULL); + chatwin_otr_untrust(chatwin); + } + break; - case OTRL_SMPEVENT_IN_PROGRESS: - break; + case OTRL_SMPEVENT_IN_PROGRESS: + break; - default: - break; + default: + break; } } void -otrlib_init_ops(OtrlMessageAppOps *ops) +otrlib_init_ops(OtrlMessageAppOps* ops) { ops->otr_error_message = cb_otr_error_message; ops->otr_error_message_free = cb_otr_error_message_free; @@ -255,16 +252,16 @@ otrlib_init_ops(OtrlMessageAppOps *ops) } ConnContext* -otrlib_context_find(OtrlUserState user_state, const char *const recipient, char *jid) +otrlib_context_find(OtrlUserState user_state, const char* const recipient, char* jid) { return otrl_context_find(user_state, recipient, jid, "xmpp", OTRL_INSTAG_MASTER, 0, NULL, NULL, NULL); } void -otrlib_end_session(OtrlUserState user_state, const char *const recipient, char *jid, OtrlMessageAppOps *ops) +otrlib_end_session(OtrlUserState user_state, const char* const recipient, char* jid, OtrlMessageAppOps* ops) { - ConnContext *context = otrl_context_find(user_state, recipient, jid, "xmpp", - OTRL_INSTAG_MASTER, 0, NULL, NULL, NULL); + ConnContext* context = otrl_context_find(user_state, recipient, jid, "xmpp", + OTRL_INSTAG_MASTER, 0, NULL, NULL, NULL); if (context) { otrl_message_disconnect(user_state, ops, NULL, jid, "xmpp", recipient, 0); @@ -272,8 +269,8 @@ otrlib_end_session(OtrlUserState user_state, const char *const recipient, char * } gcry_error_t -otrlib_encrypt_message(OtrlUserState user_state, OtrlMessageAppOps *ops, char *jid, const char *const to, - const char *const message, char **newmessage) +otrlib_encrypt_message(OtrlUserState user_state, OtrlMessageAppOps* ops, char* jid, const char* const to, + const char* const message, char** newmessage) { gcry_error_t err; @@ -297,8 +294,8 @@ otrlib_encrypt_message(OtrlUserState user_state, OtrlMessageAppOps *ops, char *j } int -otrlib_decrypt_message(OtrlUserState user_state, OtrlMessageAppOps *ops, char *jid, const char *const from, - const char *const message, char **decrypted, OtrlTLV **tlvs) +otrlib_decrypt_message(OtrlUserState user_state, OtrlMessageAppOps* ops, char* jid, const char* const from, + const char* const message, char** decrypted, OtrlTLV** tlvs) { return otrl_message_receiving( user_state, @@ -316,6 +313,6 @@ otrlib_decrypt_message(OtrlUserState user_state, OtrlMessageAppOps *ops, char *j } void -otrlib_handle_tlvs(OtrlUserState user_state, OtrlMessageAppOps *ops, ConnContext *context, OtrlTLV *tlvs, GHashTable *smp_initiators) +otrlib_handle_tlvs(OtrlUserState user_state, OtrlMessageAppOps* ops, ConnContext* context, OtrlTLV* tlvs, GHashTable* smp_initiators) { } diff --git a/src/pgp/gpg.c b/src/pgp/gpg.c index b9be1d71..ca70367a 100644 --- a/src/pgp/gpg.c +++ b/src/pgp/gpg.c @@ -54,29 +54,29 @@ #define PGP_SIGNATURE_HEADER "-----BEGIN PGP SIGNATURE-----" #define PGP_SIGNATURE_FOOTER "-----END PGP SIGNATURE-----" -#define PGP_MESSAGE_HEADER "-----BEGIN PGP MESSAGE-----" -#define PGP_MESSAGE_FOOTER "-----END PGP MESSAGE-----" +#define PGP_MESSAGE_HEADER "-----BEGIN PGP MESSAGE-----" +#define PGP_MESSAGE_FOOTER "-----END PGP MESSAGE-----" -static const char *libversion = NULL; -static GHashTable *pubkeys; +static const char* libversion = NULL; +static GHashTable* pubkeys; -static gchar *pubsloc; -static GKeyFile *pubkeyfile; +static gchar* pubsloc; +static GKeyFile* pubkeyfile; -static char *passphrase; -static char *passphrase_attempt; +static char* passphrase; +static char* passphrase_attempt; static Autocomplete key_ac; -static char* _remove_header_footer(char *str, const char *const footer); -static char* _add_header_footer(const char *const str, const char *const header, const char *const footer); +static char* _remove_header_footer(char* str, const char* const footer); +static char* _add_header_footer(const char* const str, const char* const header, const char* const footer); static void _save_pubkeys(void); -static gpgme_key_t _ox_key_lookup(const char *const barejid, gboolean secret_only); -static gboolean _ox_key_is_usable(gpgme_key_t key, const char *const barejid, gboolean secret); +static gpgme_key_t _ox_key_lookup(const char* const barejid, gboolean secret_only); +static gboolean _ox_key_is_usable(gpgme_key_t key, const char* const barejid, gboolean secret); void -_p_gpg_free_pubkeyid(ProfPGPPubKeyId *pubkeyid) +_p_gpg_free_pubkeyid(ProfPGPPubKeyId* pubkeyid) { if (pubkeyid) { free(pubkeyid->id); @@ -85,14 +85,14 @@ _p_gpg_free_pubkeyid(ProfPGPPubKeyId *pubkeyid) } static gpgme_error_t* -_p_gpg_passphrase_cb(void *hook, const char *uid_hint, const char *passphrase_info, int prev_was_bad, int fd) +_p_gpg_passphrase_cb(void* hook, const char* uid_hint, const char* passphrase_info, int prev_was_bad, int fd) { if (passphrase) { gpgme_io_write(fd, passphrase, strlen(passphrase)); } else { - GString *pass_term = g_string_new(""); + GString* pass_term = g_string_new(""); - char *password = ui_ask_pgp_passphrase(uid_hint, prev_was_bad); + char* password = ui_ask_pgp_passphrase(uid_hint, prev_was_bad); if (password) { g_string_append(pass_term, password); free(password); @@ -121,7 +121,7 @@ p_gpg_init(void) pubkeys = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)_p_gpg_free_pubkeyid); key_ac = autocomplete_new(); - GHashTable *keys = p_gpg_list_keys(); + GHashTable* keys = p_gpg_list_keys(); p_gpg_free_keys(keys); passphrase = NULL; @@ -159,7 +159,7 @@ p_gpg_close(void) } void -p_gpg_on_connect(const char *const barejid) +p_gpg_on_connect(const char* const barejid) { gchar* pubsfile = files_get_account_data_path(DIR_PGP, barejid); @@ -167,7 +167,7 @@ p_gpg_on_connect(const char *const barejid) errno = 0; int res = g_mkdir_with_parents(pubsfile, S_IRWXU); if (res == -1) { - char *errmsg = strerror(errno); + char* errmsg = strerror(errno); if (errmsg) { log_error("Error creating directory: %s, %s", pubsfile, errmsg); } else { @@ -176,7 +176,7 @@ p_gpg_on_connect(const char *const barejid) } // create or read publickeys - GString *pubtmp = g_string_new(pubsfile); + GString* pubtmp = g_string_new(pubsfile); g_string_append(pubtmp, "/pubkeys"); pubsloc = pubtmp->str; g_string_free(pubtmp, FALSE); @@ -191,7 +191,7 @@ p_gpg_on_connect(const char *const barejid) // load each keyid gsize len = 0; - gchar **jids = g_key_file_get_groups(pubkeyfile, &len); + gchar** jids = g_key_file_get_groups(pubkeyfile, &len); gpgme_ctx_t ctx; gpgme_error_t error = gpgme_new(&ctx); @@ -204,9 +204,9 @@ p_gpg_on_connect(const char *const barejid) int i = 0; for (i = 0; i < len; i++) { - GError *gerr = NULL; - gchar *jid = jids[i]; - gchar *keyid = g_key_file_get_string(pubkeyfile, jid, "keyid", &gerr); + GError* gerr = NULL; + gchar* jid = jids[i]; + gchar* keyid = g_key_file_get_string(pubkeyfile, jid, "keyid", &gerr); if (gerr) { log_error("Error loading PGP key id for %s", jid); g_error_free(gerr); @@ -219,7 +219,7 @@ p_gpg_on_connect(const char *const barejid) continue; } - ProfPGPPubKeyId *pubkeyid = malloc(sizeof(ProfPGPPubKeyId)); + ProfPGPPubKeyId* pubkeyid = malloc(sizeof(ProfPGPPubKeyId)); pubkeyid->id = strdup(keyid); pubkeyid->received = FALSE; g_hash_table_replace(pubkeys, strdup(jid), pubkeyid); @@ -262,7 +262,7 @@ p_gpg_on_disconnect(void) } gboolean -p_gpg_addkey(const char *const jid, const char *const keyid) +p_gpg_addkey(const char* const jid, const char* const keyid) { gpgme_ctx_t ctx; gpgme_error_t error = gpgme_new(&ctx); @@ -285,7 +285,7 @@ p_gpg_addkey(const char *const jid, const char *const keyid) _save_pubkeys(); // update in memory pubkeys list - ProfPGPPubKeyId *pubkeyid = malloc(sizeof(ProfPGPPubKeyId)); + ProfPGPPubKeyId* pubkeyid = malloc(sizeof(ProfPGPPubKeyId)); pubkeyid->id = strdup(keyid); pubkeyid->received = FALSE; g_hash_table_replace(pubkeys, strdup(jid), pubkeyid); @@ -297,7 +297,7 @@ p_gpg_addkey(const char *const jid, const char *const keyid) static ProfPGPKey* _p_gpg_key_new(void) { - ProfPGPKey *p_pgpkey = malloc(sizeof(ProfPGPKey)); + ProfPGPKey* p_pgpkey = malloc(sizeof(ProfPGPKey)); p_pgpkey->id = NULL; p_pgpkey->name = NULL; p_pgpkey->fp = NULL; @@ -311,7 +311,7 @@ _p_gpg_key_new(void) } static void -_p_gpg_free_key(ProfPGPKey *key) +_p_gpg_free_key(ProfPGPKey* key) { if (key) { free(key->id); @@ -325,7 +325,7 @@ GHashTable* p_gpg_list_keys(void) { gpgme_error_t error; - GHashTable *result = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)_p_gpg_free_key); + GHashTable* result = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)_p_gpg_free_key); gpgme_ctx_t ctx; error = gpgme_new(&ctx); @@ -342,21 +342,29 @@ p_gpg_list_keys(void) while (!error) { gpgme_subkey_t sub = key->subkeys; - ProfPGPKey *p_pgpkey = _p_gpg_key_new(); + ProfPGPKey* p_pgpkey = _p_gpg_key_new(); p_pgpkey->id = strdup(sub->keyid); p_pgpkey->name = strdup(key->uids->uid); p_pgpkey->fp = strdup(sub->fpr); - if (sub->can_encrypt) p_pgpkey->encrypt = TRUE; - if (sub->can_authenticate) p_pgpkey->authenticate = TRUE; - if (sub->can_certify) p_pgpkey->certify = TRUE; - if (sub->can_sign) p_pgpkey->sign = TRUE; + if (sub->can_encrypt) + p_pgpkey->encrypt = TRUE; + if (sub->can_authenticate) + p_pgpkey->authenticate = TRUE; + if (sub->can_certify) + p_pgpkey->certify = TRUE; + if (sub->can_sign) + p_pgpkey->sign = TRUE; sub = sub->next; while (sub) { - if (sub->can_encrypt) p_pgpkey->encrypt = TRUE; - if (sub->can_authenticate) p_pgpkey->authenticate = TRUE; - if (sub->can_certify) p_pgpkey->certify = TRUE; - if (sub->can_sign) p_pgpkey->sign = TRUE; + if (sub->can_encrypt) + p_pgpkey->encrypt = TRUE; + if (sub->can_authenticate) + p_pgpkey->authenticate = TRUE; + if (sub->can_certify) + p_pgpkey->certify = TRUE; + if (sub->can_sign) + p_pgpkey->sign = TRUE; sub = sub->next; } @@ -376,7 +384,7 @@ p_gpg_list_keys(void) gpgme_subkey_t sub = key->subkeys; while (sub) { if (sub->secret) { - ProfPGPKey *p_pgpkey = g_hash_table_lookup(result, key->uids->uid); + ProfPGPKey* p_pgpkey = g_hash_table_lookup(result, key->uids->uid); if (p_pgpkey) { p_pgpkey->secret = TRUE; } @@ -392,10 +400,10 @@ p_gpg_list_keys(void) gpgme_release(ctx); autocomplete_clear(key_ac); - GList *ids = g_hash_table_get_keys(result); - GList *curr = ids; + GList* ids = g_hash_table_get_keys(result); + GList* curr = ids; while (curr) { - ProfPGPKey *key = g_hash_table_lookup(result, curr->data); + ProfPGPKey* key = g_hash_table_lookup(result, curr->data); autocomplete_add(key_ac, key->id); curr = curr->next; } @@ -405,12 +413,11 @@ p_gpg_list_keys(void) } void -p_gpg_free_keys(GHashTable *keys) +p_gpg_free_keys(GHashTable* keys) { g_hash_table_destroy(keys); } - GHashTable* p_gpg_pubkeys(void) { @@ -427,7 +434,7 @@ p_gpg_libver(void) } gboolean -p_gpg_valid_key(const char *const keyid, char **err_str) +p_gpg_valid_key(const char* const keyid, char** err_str) { gpgme_ctx_t ctx; gpgme_error_t error = gpgme_new(&ctx); @@ -456,18 +463,17 @@ p_gpg_valid_key(const char *const keyid, char **err_str) gpgme_release(ctx); gpgme_key_unref(key); return TRUE; - } gboolean -p_gpg_available(const char *const barejid) +p_gpg_available(const char* const barejid) { - char *pubkey = g_hash_table_lookup(pubkeys, barejid); + char* pubkey = g_hash_table_lookup(pubkeys, barejid); return (pubkey != NULL); } void -p_gpg_verify(const char *const barejid, const char *const sign) +p_gpg_verify(const char* const barejid, const char* const sign) { if (!sign) { return; @@ -481,7 +487,7 @@ p_gpg_verify(const char *const barejid, const char *const sign) return; } - char *sign_with_header_footer = _add_header_footer(sign, PGP_SIGNATURE_HEADER, PGP_SIGNATURE_FOOTER); + char* sign_with_header_footer = _add_header_footer(sign, PGP_SIGNATURE_HEADER, PGP_SIGNATURE_FOOTER); gpgme_data_t sign_data; gpgme_data_new_from_mem(&sign_data, sign_with_header_footer, strlen(sign_with_header_footer), 1); free(sign_with_header_footer); @@ -508,7 +514,7 @@ p_gpg_verify(const char *const barejid, const char *const sign) log_debug("Could not find PGP key with ID %s for %s", result->signatures->fpr, barejid); } else { log_debug("Fingerprint found for %s: %s ", barejid, key->subkeys->fpr); - ProfPGPPubKeyId *pubkeyid = malloc(sizeof(ProfPGPPubKeyId)); + ProfPGPPubKeyId* pubkeyid = malloc(sizeof(ProfPGPPubKeyId)); pubkeyid->id = strdup(key->subkeys->keyid); pubkeyid->received = TRUE; g_hash_table_replace(pubkeys, strdup(barejid), pubkeyid); @@ -522,7 +528,7 @@ p_gpg_verify(const char *const barejid, const char *const sign) } char* -p_gpg_sign(const char *const str, const char *const fp) +p_gpg_sign(const char* const str, const char* const fp) { gpgme_ctx_t ctx; gpgme_error_t error = gpgme_new(&ctx); @@ -552,7 +558,7 @@ p_gpg_sign(const char *const str, const char *const fp) return NULL; } - char *str_or_empty = NULL; + char* str_or_empty = NULL; if (str) { str_or_empty = strdup(str); } else { @@ -565,7 +571,7 @@ p_gpg_sign(const char *const str, const char *const fp) gpgme_data_t signed_data; gpgme_data_new(&signed_data); - gpgme_set_armor(ctx,1); + gpgme_set_armor(ctx, 1); error = gpgme_op_sign(ctx, str_data, signed_data, GPGME_SIG_MODE_DETACH); gpgme_data_release(str_data); gpgme_release(ctx); @@ -576,12 +582,12 @@ p_gpg_sign(const char *const str, const char *const fp) return NULL; } - char *result = NULL; + char* result = NULL; size_t len = 0; - char *signed_str = gpgme_data_release_and_get_mem(signed_data, &len); + char* signed_str = gpgme_data_release_and_get_mem(signed_data, &len); if (signed_str) { - GString *signed_gstr = g_string_new(""); + GString* signed_gstr = g_string_new(""); g_string_append_len(signed_gstr, signed_str, len); result = _remove_header_footer(signed_gstr->str, PGP_SIGNATURE_FOOTER); g_string_free(signed_gstr, TRUE); @@ -596,9 +602,9 @@ p_gpg_sign(const char *const str, const char *const fp) } char* -p_gpg_encrypt(const char *const barejid, const char *const message, const char *const fp) +p_gpg_encrypt(const char* const barejid, const char* const message, const char* const fp) { - ProfPGPPubKeyId *pubkeyid = g_hash_table_lookup(pubkeys, barejid); + ProfPGPPubKeyId* pubkeyid = g_hash_table_lookup(pubkeys, barejid); if (!pubkeyid) { return NULL; } @@ -656,11 +662,11 @@ p_gpg_encrypt(const char *const barejid, const char *const message, const char * } size_t len; - char *cipher_str = gpgme_data_release_and_get_mem(cipher, &len); + char* cipher_str = gpgme_data_release_and_get_mem(cipher, &len); - char *result = NULL; + char* result = NULL; if (cipher_str) { - GString *cipher_gstr = g_string_new(""); + GString* cipher_gstr = g_string_new(""); g_string_append_len(cipher_gstr, cipher_str, len); result = _remove_header_footer(cipher_gstr->str, PGP_MESSAGE_FOOTER); g_string_free(cipher_gstr, TRUE); @@ -671,7 +677,7 @@ p_gpg_encrypt(const char *const barejid, const char *const message, const char * } char* -p_gpg_decrypt(const char *const cipher) +p_gpg_decrypt(const char* const cipher) { gpgme_ctx_t ctx; gpgme_error_t error = gpgme_new(&ctx); @@ -683,7 +689,7 @@ p_gpg_decrypt(const char *const cipher) gpgme_set_passphrase_cb(ctx, (gpgme_passphrase_cb_t)_p_gpg_passphrase_cb, NULL); - char *cipher_with_headers = _add_header_footer(cipher, PGP_MESSAGE_HEADER, PGP_MESSAGE_FOOTER); + char* cipher_with_headers = _add_header_footer(cipher, PGP_MESSAGE_HEADER, PGP_MESSAGE_FOOTER); gpgme_data_t cipher_data; gpgme_data_new_from_mem(&cipher_data, cipher_with_headers, strlen(cipher_with_headers), 1); free(cipher_with_headers); @@ -703,14 +709,14 @@ p_gpg_decrypt(const char *const cipher) gpgme_decrypt_result_t res = gpgme_op_decrypt_result(ctx); if (res) { - GString *recipients_str = g_string_new(""); + GString* recipients_str = g_string_new(""); gpgme_recipient_t recipient = res->recipients; while (recipient) { gpgme_key_t key; error = gpgme_get_key(ctx, recipient->keyid, &key, 1); if (!error && key) { - const char *addr = gpgme_key_get_string_attr(key, GPGME_ATTR_EMAIL, NULL, 0); + const char* addr = gpgme_key_get_string_attr(key, GPGME_ATTR_EMAIL, NULL, 0); if (addr) { g_string_append(recipients_str, addr); } @@ -730,8 +736,8 @@ p_gpg_decrypt(const char *const cipher) gpgme_release(ctx); size_t len = 0; - char *plain_str = gpgme_data_release_and_get_mem(plain_data, &len); - char *result = NULL; + char* plain_str = gpgme_data_release_and_get_mem(plain_data, &len); + char* result = NULL; if (plain_str) { plain_str[len] = 0; result = g_strdup(plain_str); @@ -746,13 +752,13 @@ p_gpg_decrypt(const char *const cipher) } void -p_gpg_free_decrypted(char *decrypted) +p_gpg_free_decrypted(char* decrypted) { g_free(decrypted); } char* -p_gpg_autocomplete_key(const char *const search_str, gboolean previous, void *context) +p_gpg_autocomplete_key(const char* const search_str, gboolean previous, void* context) { return autocomplete_complete(key_ac, search_str, TRUE, previous); } @@ -764,23 +770,23 @@ p_gpg_autocomplete_key_reset(void) } char* -p_gpg_format_fp_str(char *fp) +p_gpg_format_fp_str(char* fp) { if (!fp) { return NULL; } - GString *format = g_string_new(""); + GString* format = g_string_new(""); int i; int len = strlen(fp); for (i = 0; i < len; i++) { g_string_append_c(format, fp[i]); - if (((i+1) % 4 == 0) && (i+1 < len)) { + if (((i + 1) % 4 == 0) && (i + 1 < len)) { g_string_append_c(format, ' '); } } - char *result = format->str; + char* result = format->str; g_string_free(format, FALSE); return result; @@ -793,9 +799,10 @@ p_gpg_format_fp_str(char *fp) * */ GHashTable* -ox_gpg_public_keys(void) { +ox_gpg_public_keys(void) +{ gpgme_error_t error; - GHashTable *result = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)_p_gpg_free_key); + GHashTable* result = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)_p_gpg_free_key); gpgme_ctx_t ctx; error = gpgme_new(&ctx); @@ -809,7 +816,7 @@ ox_gpg_public_keys(void) { if (error == GPG_ERR_NO_ERROR) { gpgme_key_t key; error = gpgme_op_keylist_next(ctx, &key); - if ( error != GPG_ERR_EOF && error != GPG_ERR_NO_ERROR) { + if (error != GPG_ERR_EOF && error != GPG_ERR_NO_ERROR) { log_error("OX: gpgme_op_keylist_next %s %s", gpgme_strsource(error), gpgme_strerror(error)); g_hash_table_destroy(result); return NULL; @@ -819,39 +826,46 @@ ox_gpg_public_keys(void) { gpgme_user_id_t uid = key->uids; gpgme_user_id_t xmppid = NULL; while (!xmppid && uid) { - if( uid->name && strlen(uid->name) >= 10 ) { - if( strstr(uid->name, "xmpp:") == uid->name ) { + if (uid->name && strlen(uid->name) >= 10) { + if (strstr(uid->name, "xmpp:") == uid->name) { xmppid = uid; } } uid = uid->next; } - if(xmppid) { + if (xmppid) { // Build Key information about all subkey gpgme_subkey_t sub = key->subkeys; - ProfPGPKey *p_pgpkey = _p_gpg_key_new(); + ProfPGPKey* p_pgpkey = _p_gpg_key_new(); p_pgpkey->id = strdup(sub->keyid); p_pgpkey->name = strdup(xmppid->uid); p_pgpkey->fp = strdup(sub->fpr); - if (sub->can_encrypt) p_pgpkey->encrypt = TRUE; - if (sub->can_authenticate) p_pgpkey->authenticate = TRUE; - if (sub->can_certify) p_pgpkey->certify = TRUE; - if (sub->can_sign) p_pgpkey->sign = TRUE; + if (sub->can_encrypt) + p_pgpkey->encrypt = TRUE; + if (sub->can_authenticate) + p_pgpkey->authenticate = TRUE; + if (sub->can_certify) + p_pgpkey->certify = TRUE; + if (sub->can_sign) + p_pgpkey->sign = TRUE; sub = sub->next; while (sub) { - if (sub->can_encrypt) p_pgpkey->encrypt = TRUE; - if (sub->can_authenticate) p_pgpkey->authenticate = TRUE; - if (sub->can_certify) p_pgpkey->certify = TRUE; - if (sub->can_sign) p_pgpkey->sign = TRUE; + if (sub->can_encrypt) + p_pgpkey->encrypt = TRUE; + if (sub->can_authenticate) + p_pgpkey->authenticate = TRUE; + if (sub->can_certify) + p_pgpkey->certify = TRUE; + if (sub->can_sign) + p_pgpkey->sign = TRUE; sub = sub->next; } g_hash_table_insert(result, strdup(p_pgpkey->name), p_pgpkey); - } gpgme_key_unref(key); error = gpgme_op_keylist_next(ctx, &key); @@ -870,147 +884,143 @@ ox_gpg_public_keys(void) { // g_list_free(ids); return result; - } char* -p_ox_gpg_signcrypt(const char* const sender_barejid, const char* const recipient_barejid , const char* const message) +p_ox_gpg_signcrypt(const char* const sender_barejid, const char* const recipient_barejid, const char* const message) { - setlocale (LC_ALL, ""); - gpgme_check_version (NULL); - gpgme_set_locale (NULL, LC_CTYPE, setlocale (LC_CTYPE, NULL)); - gpgme_ctx_t ctx; - - gpgme_error_t error = gpgme_new (&ctx); - if(GPG_ERR_NO_ERROR != error ) { - printf("gpgme_new: %d\n", error); - return NULL; - } - - error = gpgme_set_protocol(ctx, GPGME_PROTOCOL_OPENPGP); - if(error != 0) { - log_error("GpgME Error: %s", gpgme_strerror(error)); - } - - gpgme_set_armor(ctx,0); - gpgme_set_textmode(ctx,0); - gpgme_set_offline(ctx,1); - gpgme_set_keylist_mode(ctx, GPGME_KEYLIST_MODE_LOCAL); - if(error != 0) { - log_error("GpgME Error: %s", gpgme_strerror(error)); - } - - gpgme_key_t recp[3]; - recp[0] = NULL, - recp[1] = NULL; - - char* xmpp_jid_me = alloca( (strlen(sender_barejid)+6) * sizeof(char) ); - char* xmpp_jid_recipient = alloca( (strlen(recipient_barejid)+6) * sizeof(char) ); - - strcpy(xmpp_jid_me, "xmpp:"); - strcpy(xmpp_jid_recipient, "xmpp:"); - strcat(xmpp_jid_me, sender_barejid); - strcat(xmpp_jid_recipient,recipient_barejid); - - gpgme_signers_clear(ctx); - - // lookup own key - recp[0] = _ox_key_lookup(sender_barejid, TRUE); - if(error != 0) { - log_error("Key not found for %s. GpgME Error: %s", xmpp_jid_me, gpgme_strerror(error)); - return NULL; - } - - error = gpgme_signers_add(ctx,recp[0]); - if(error != 0) { - log_error("gpgme_signers_add %s. GpgME Error: %s", xmpp_jid_me, gpgme_strerror(error)); - return NULL; - } - - - // lookup key of recipient - recp[1] = _ox_key_lookup(recipient_barejid, FALSE); - if(error != 0) { - log_error("Key not found for %s. GpgME Error: %s", xmpp_jid_recipient, gpgme_strerror(error)); - return NULL; - } - recp[2] = NULL; - log_debug("%s <%s>", recp[0]->uids->name, recp[0]->uids->email); - log_debug("%s <%s>", recp[1]->uids->name, recp[1]->uids->email); - - gpgme_encrypt_flags_t flags = 0; - - gpgme_data_t plain; - gpgme_data_t cipher; - - error = gpgme_data_new (&plain); - if(error != 0) { - log_error("GpgME Error: %s", gpgme_strerror(error)); - return NULL; - } - - error = gpgme_data_new_from_mem(&plain, message, strlen(message),0); - if(error != 0) { - log_error("GpgME Error: %s", gpgme_strerror(error)); - return NULL; - } - error = gpgme_data_new (&cipher); - if(error != 0) { - log_error("GpgME Error: %s", gpgme_strerror(error)); - return NULL; - } - - error = gpgme_op_encrypt_sign ( ctx, recp, flags, plain, cipher); - if(error != 0) { - log_error("GpgME Error: %s", gpgme_strerror(error)); - return NULL; - } - - size_t len; - char *cipher_str = gpgme_data_release_and_get_mem(cipher, &len); - char* result = g_base64_encode( (unsigned char*) cipher_str,len); - gpgme_key_release (recp[0]); - gpgme_key_release (recp[1]); - gpgme_release (ctx); - return result; + setlocale(LC_ALL, ""); + gpgme_check_version(NULL); + gpgme_set_locale(NULL, LC_CTYPE, setlocale(LC_CTYPE, NULL)); + gpgme_ctx_t ctx; + + gpgme_error_t error = gpgme_new(&ctx); + if (GPG_ERR_NO_ERROR != error) { + printf("gpgme_new: %d\n", error); + return NULL; + } + + error = gpgme_set_protocol(ctx, GPGME_PROTOCOL_OPENPGP); + if (error != 0) { + log_error("GpgME Error: %s", gpgme_strerror(error)); + } + + gpgme_set_armor(ctx, 0); + gpgme_set_textmode(ctx, 0); + gpgme_set_offline(ctx, 1); + gpgme_set_keylist_mode(ctx, GPGME_KEYLIST_MODE_LOCAL); + if (error != 0) { + log_error("GpgME Error: %s", gpgme_strerror(error)); + } + + gpgme_key_t recp[3]; + recp[0] = NULL, + recp[1] = NULL; + + char* xmpp_jid_me = alloca((strlen(sender_barejid) + 6) * sizeof(char)); + char* xmpp_jid_recipient = alloca((strlen(recipient_barejid) + 6) * sizeof(char)); + strcpy(xmpp_jid_me, "xmpp:"); + strcpy(xmpp_jid_recipient, "xmpp:"); + strcat(xmpp_jid_me, sender_barejid); + strcat(xmpp_jid_recipient, recipient_barejid); + + gpgme_signers_clear(ctx); + + // lookup own key + recp[0] = _ox_key_lookup(sender_barejid, TRUE); + if (error != 0) { + log_error("Key not found for %s. GpgME Error: %s", xmpp_jid_me, gpgme_strerror(error)); + return NULL; + } + + error = gpgme_signers_add(ctx, recp[0]); + if (error != 0) { + log_error("gpgme_signers_add %s. GpgME Error: %s", xmpp_jid_me, gpgme_strerror(error)); + return NULL; + } + + // lookup key of recipient + recp[1] = _ox_key_lookup(recipient_barejid, FALSE); + if (error != 0) { + log_error("Key not found for %s. GpgME Error: %s", xmpp_jid_recipient, gpgme_strerror(error)); + return NULL; + } + recp[2] = NULL; + log_debug("%s <%s>", recp[0]->uids->name, recp[0]->uids->email); + log_debug("%s <%s>", recp[1]->uids->name, recp[1]->uids->email); + + gpgme_encrypt_flags_t flags = 0; + + gpgme_data_t plain; + gpgme_data_t cipher; + + error = gpgme_data_new(&plain); + if (error != 0) { + log_error("GpgME Error: %s", gpgme_strerror(error)); + return NULL; + } + + error = gpgme_data_new_from_mem(&plain, message, strlen(message), 0); + if (error != 0) { + log_error("GpgME Error: %s", gpgme_strerror(error)); + return NULL; + } + error = gpgme_data_new(&cipher); + if (error != 0) { + log_error("GpgME Error: %s", gpgme_strerror(error)); + return NULL; + } + + error = gpgme_op_encrypt_sign(ctx, recp, flags, plain, cipher); + if (error != 0) { + log_error("GpgME Error: %s", gpgme_strerror(error)); + return NULL; + } + + size_t len; + char* cipher_str = gpgme_data_release_and_get_mem(cipher, &len); + char* result = g_base64_encode((unsigned char*)cipher_str, len); + gpgme_key_release(recp[0]); + gpgme_key_release(recp[1]); + gpgme_release(ctx); + return result; } gboolean -ox_is_private_key_available(const char *const barejid) +ox_is_private_key_available(const char* const barejid) { g_assert(barejid); gboolean result = FALSE; gpgme_key_t key = _ox_key_lookup(barejid, TRUE); - if(key) { - if (_ox_key_is_usable(key, barejid, TRUE) ) { + if (key) { + if (_ox_key_is_usable(key, barejid, TRUE)) { result = TRUE; } - gpgme_key_unref(key); + gpgme_key_unref(key); } return result; } gboolean -ox_is_public_key_available(const char *const barejid) +ox_is_public_key_available(const char* const barejid) { g_assert(barejid); gboolean result = FALSE; gpgme_key_t key = _ox_key_lookup(barejid, FALSE); - if(key) { - if (_ox_key_is_usable(key, barejid, FALSE) ) { + if (key) { + if (_ox_key_is_usable(key, barejid, FALSE)) { result = TRUE; } - gpgme_key_unref(key); + gpgme_key_unref(key); } return result; } - static char* -_remove_header_footer(char *str, const char *const footer) +_remove_header_footer(char* str, const char* const footer) { int pos = 0; int newlines = 0; @@ -1026,17 +1036,17 @@ _remove_header_footer(char *str, const char *const footer) } } - char *stripped = strdup(&str[pos]); - char *footer_start = g_strrstr(stripped, footer); + char* stripped = strdup(&str[pos]); + char* footer_start = g_strrstr(stripped, footer); footer_start[0] = '\0'; return stripped; } static char* -_add_header_footer(const char *const str, const char *const header, const char *const footer) +_add_header_footer(const char* const str, const char* const header, const char* const footer) { - GString *result_str = g_string_new(""); + GString* result_str = g_string_new(""); g_string_append(result_str, header); g_string_append(result_str, "\n\n"); @@ -1044,7 +1054,7 @@ _add_header_footer(const char *const str, const char *const header, const char * g_string_append(result_str, "\n"); g_string_append(result_str, footer); - char *result = result_str->str; + char* result = result_str->str; g_string_free(result_str, FALSE); return result; @@ -1054,17 +1064,17 @@ static void _save_pubkeys(void) { gsize g_data_size; - gchar *g_pubkeys_data = g_key_file_to_data(pubkeyfile, &g_data_size, NULL); + gchar* g_pubkeys_data = g_key_file_to_data(pubkeyfile, &g_data_size, NULL); g_file_set_contents(pubsloc, g_pubkeys_data, g_data_size, NULL); g_chmod(pubsloc, S_IRUSR | S_IWUSR); g_free(g_pubkeys_data); } static gpgme_key_t -_ox_key_lookup(const char *const barejid, gboolean secret_only) +_ox_key_lookup(const char* const barejid, gboolean secret_only) { g_assert(barejid); - log_debug("Looking for %s key: %s", secret_only == TRUE ? "Private" : "Public", barejid); + log_debug("Looking for %s key: %s", secret_only == TRUE ? "Private" : "Public", barejid); gpgme_key_t key = NULL; gpgme_error_t error; @@ -1079,21 +1089,21 @@ _ox_key_lookup(const char *const barejid, gboolean secret_only) error = gpgme_op_keylist_start(ctx, NULL, secret_only); if (error == GPG_ERR_NO_ERROR) { error = gpgme_op_keylist_next(ctx, &key); - if ( error != GPG_ERR_EOF && error != GPG_ERR_NO_ERROR) { + if (error != GPG_ERR_EOF && error != GPG_ERR_NO_ERROR) { log_error("OX: gpgme_op_keylist_next %s %s", gpgme_strsource(error), gpgme_strerror(error)); return NULL; } GString* xmppuri = g_string_new("xmpp:"); - g_string_append(xmppuri,barejid); + g_string_append(xmppuri, barejid); while (!error) { // Looking for XMPP URI UID gpgme_user_id_t uid = key->uids; - while ( uid ) { - if( uid->name && strlen(uid->name) >= 10 ) { - if( g_strcmp0(uid->name, xmppuri->str) == 0 ) { + while (uid) { + if (uid->name && strlen(uid->name) >= 10) { + if (g_strcmp0(uid->name, xmppuri->str) == 0) { gpgme_release(ctx); return key; } @@ -1110,11 +1120,11 @@ _ox_key_lookup(const char *const barejid, gboolean secret_only) } static gboolean -_ox_key_is_usable(gpgme_key_t key, const char *const barejid, gboolean secret) +_ox_key_is_usable(gpgme_key_t key, const char* const barejid, gboolean secret) { gboolean result = TRUE; - if(key->revoked || key->expired || key->disabled ) { + if (key->revoked || key->expired || key->disabled) { result = FALSE; } @@ -1133,61 +1143,61 @@ _ox_key_is_usable(gpgme_key_t key, const char *const barejid, gboolean secret) char* p_ox_gpg_decrypt(char* base64) { - setlocale (LC_ALL, ""); - gpgme_check_version (NULL); - gpgme_set_locale (NULL, LC_CTYPE, setlocale (LC_CTYPE, NULL)); - gpgme_ctx_t ctx; - gpgme_error_t error = gpgme_new (&ctx); - - if(GPG_ERR_NO_ERROR != error ) { - printf("gpgme_new: %d\n", error); - return NULL; - } - - error = gpgme_set_protocol(ctx, GPGME_PROTOCOL_OPENPGP); - if(error != 0) { - log_error("GpgME Error: %s", gpgme_strerror(error)); - } - - gpgme_set_armor(ctx,0); - gpgme_set_textmode(ctx,0); - gpgme_set_offline(ctx,1); - gpgme_set_keylist_mode(ctx, GPGME_KEYLIST_MODE_LOCAL); - if(error != 0) { - log_error("GpgME Error: %s", gpgme_strerror(error)); - } - - gpgme_data_t plain = NULL; - gpgme_data_t cipher = NULL; - - gsize s; - guchar* encypted = g_base64_decode(base64, &s); - error = gpgme_data_new_from_mem(&cipher, (char*)encypted, s,0); - if(error != 0) { - log_error("GpgME Error gpgme_data_new_from_mem: %s", gpgme_strerror(error)); - return NULL; - } - - error = gpgme_data_new (&plain); - if(error != 0) { - log_error("GpgME Error: %s", gpgme_strerror(error)); - return NULL; - } - - error = gpgme_op_decrypt_verify(ctx, cipher, plain); - if(error != 0) { - log_error("GpgME Error gpgme_op_decrypt: %s", gpgme_strerror(error)); - error = gpgme_op_decrypt(ctx, cipher, plain); - if ( error != 0 ) { + setlocale(LC_ALL, ""); + gpgme_check_version(NULL); + gpgme_set_locale(NULL, LC_CTYPE, setlocale(LC_CTYPE, NULL)); + gpgme_ctx_t ctx; + gpgme_error_t error = gpgme_new(&ctx); + + if (GPG_ERR_NO_ERROR != error) { + printf("gpgme_new: %d\n", error); + return NULL; + } + + error = gpgme_set_protocol(ctx, GPGME_PROTOCOL_OPENPGP); + if (error != 0) { + log_error("GpgME Error: %s", gpgme_strerror(error)); + } + + gpgme_set_armor(ctx, 0); + gpgme_set_textmode(ctx, 0); + gpgme_set_offline(ctx, 1); + gpgme_set_keylist_mode(ctx, GPGME_KEYLIST_MODE_LOCAL); + if (error != 0) { + log_error("GpgME Error: %s", gpgme_strerror(error)); + } + + gpgme_data_t plain = NULL; + gpgme_data_t cipher = NULL; + + gsize s; + guchar* encypted = g_base64_decode(base64, &s); + error = gpgme_data_new_from_mem(&cipher, (char*)encypted, s, 0); + if (error != 0) { + log_error("GpgME Error gpgme_data_new_from_mem: %s", gpgme_strerror(error)); + return NULL; + } + + error = gpgme_data_new(&plain); + if (error != 0) { + log_error("GpgME Error: %s", gpgme_strerror(error)); return NULL; } - } - size_t len; - char *plain_str = gpgme_data_release_and_get_mem(plain, &len); - char* result = malloc(len+1); - strcpy(result, plain_str); - result[len] = '\0'; - return result; + + error = gpgme_op_decrypt_verify(ctx, cipher, plain); + if (error != 0) { + log_error("GpgME Error gpgme_op_decrypt: %s", gpgme_strerror(error)); + error = gpgme_op_decrypt(ctx, cipher, plain); + if (error != 0) { + return NULL; + } + } + size_t len; + char* plain_str = gpgme_data_release_and_get_mem(plain, &len); + char* result = malloc(len + 1); + strcpy(result, plain_str); + result[len] = '\0'; + return result; } /*! @@ -1214,7 +1224,8 @@ p_ox_gpg_decrypt(char* base64) */ void -p_ox_gpg_readkey(const char* const filename, char** key, char** fp){ +p_ox_gpg_readkey(const char* const filename, char** key, char** fp) +{ log_info("Read OpenPGP Key from file %s", filename); @@ -1222,75 +1233,74 @@ p_ox_gpg_readkey(const char* const filename, char** key, char** fp){ gchar* data = NULL; gsize size = -1; - gboolean success = g_file_get_contents (filename, - &data, - &size, - &error); - if ( success ) { - setlocale (LC_ALL, ""); - gpgme_check_version (NULL); - gpgme_set_locale (NULL, LC_CTYPE, setlocale (LC_CTYPE, NULL)); + gboolean success = g_file_get_contents(filename, + &data, + &size, + &error); + if (success) { + setlocale(LC_ALL, ""); + gpgme_check_version(NULL); + gpgme_set_locale(NULL, LC_CTYPE, setlocale(LC_CTYPE, NULL)); gpgme_ctx_t ctx; - gpgme_error_t error = gpgme_new (&ctx); + gpgme_error_t error = gpgme_new(&ctx); - if(GPG_ERR_NO_ERROR != error ) { + if (GPG_ERR_NO_ERROR != error) { log_error("Read OpenPGP key from file: gpgme_new failed: %s", gpgme_strerror(error)); return; } error = gpgme_set_protocol(ctx, GPGME_PROTOCOL_OPENPGP); - if( error != GPG_ERR_NO_ERROR ) { + if (error != GPG_ERR_NO_ERROR) { log_error("Read OpenPGP key from file: set GPGME_PROTOCOL_OPENPGP: %s", gpgme_strerror(error)); return; } - gpgme_set_armor(ctx,0); - gpgme_set_textmode(ctx,0); - gpgme_set_offline(ctx,1); + gpgme_set_armor(ctx, 0); + gpgme_set_textmode(ctx, 0); + gpgme_set_offline(ctx, 1); gpgme_set_keylist_mode(ctx, GPGME_KEYLIST_MODE_LOCAL); gpgme_data_t gpgme_data = NULL; - error = gpgme_data_new (&gpgme_data); - if ( error != GPG_ERR_NO_ERROR ) { + error = gpgme_data_new(&gpgme_data); + if (error != GPG_ERR_NO_ERROR) { log_error("Read OpenPGP key from file: gpgme_data_new %s", gpgme_strerror(error)); return; } - error = gpgme_data_new_from_mem(&gpgme_data, (char*)data, size,0); - if ( error != GPG_ERR_NO_ERROR ) { + error = gpgme_data_new_from_mem(&gpgme_data, (char*)data, size, 0); + if (error != GPG_ERR_NO_ERROR) { log_error("Read OpenPGP key from file: gpgme_data_new_from_mem %s", gpgme_strerror(error)); return; } - error = gpgme_op_keylist_from_data_start ( ctx, gpgme_data, 0); - if ( error != GPG_ERR_NO_ERROR ) { + error = gpgme_op_keylist_from_data_start(ctx, gpgme_data, 0); + if (error != GPG_ERR_NO_ERROR) { log_error("Read OpenPGP key from file: gpgme_op_keylist_from_data_start %s", gpgme_strerror(error)); return; } gpgme_key_t gkey; - error = gpgme_op_keylist_next (ctx, &gkey); - if ( error != GPG_ERR_NO_ERROR ) { + error = gpgme_op_keylist_next(ctx, &gkey); + if (error != GPG_ERR_NO_ERROR) { log_error("Read OpenPGP key from file: gpgme_op_keylist_next %s", gpgme_strerror(error)); return; } gpgme_key_t end; - error = gpgme_op_keylist_next (ctx, &end); - if( error == GPG_ERR_NO_ERROR ) { + error = gpgme_op_keylist_next(ctx, &end); + if (error == GPG_ERR_NO_ERROR) { log_error("Read OpenPGP key from file: ambiguous key"); return; } - if(gkey->revoked || gkey->expired || gkey->disabled || gkey->invalid || gkey->secret ) { + if (gkey->revoked || gkey->expired || gkey->disabled || gkey->invalid || gkey->secret) { log_error("Read OpenPGP key from file: Key is not valid"); return; } - gchar* keybase64 = g_base64_encode( (const guchar*) data, size ); - + gchar* keybase64 = g_base64_encode((const guchar*)data, size); + *key = strdup(keybase64); *fp = strdup(gkey->fpr); } else { log_error("Read OpenPGP key from file: Unable to read file: %s", error->message); } - } diff --git a/src/pgp/gpg.h b/src/pgp/gpg.h index b3202505..c7ca7e8f 100644 --- a/src/pgp/gpg.h +++ b/src/pgp/gpg.h @@ -36,10 +36,11 @@ #ifndef PGP_GPG_H #define PGP_GPG_H -typedef struct pgp_key_t { - char *id; - char *name; - char *fp; +typedef struct pgp_key_t +{ + char* id; + char* name; + char* fp; gboolean encrypt; gboolean sign; gboolean certify; @@ -47,32 +48,33 @@ typedef struct pgp_key_t { gboolean secret; } ProfPGPKey; -typedef struct pgp_pubkeyid_t { - char *id; +typedef struct pgp_pubkeyid_t +{ + char* id; gboolean received; } ProfPGPPubKeyId; void p_gpg_init(void); void p_gpg_close(void); -void p_gpg_on_connect(const char *const barejid); +void p_gpg_on_connect(const char* const barejid); void p_gpg_on_disconnect(void); GHashTable* p_gpg_list_keys(void); -void p_gpg_free_keys(GHashTable *keys); -gboolean p_gpg_addkey(const char *const jid, const char *const keyid); +void p_gpg_free_keys(GHashTable* keys); +gboolean p_gpg_addkey(const char* const jid, const char* const keyid); GHashTable* p_gpg_pubkeys(void); -gboolean p_gpg_valid_key(const char *const keyid, char **err_str); -gboolean p_gpg_available(const char *const barejid); +gboolean p_gpg_valid_key(const char* const keyid, char** err_str); +gboolean p_gpg_available(const char* const barejid); const char* p_gpg_libver(void); -char* p_gpg_sign(const char *const str, const char *const fp); -void p_gpg_verify(const char *const barejid, const char *const sign); -char* p_gpg_encrypt(const char *const barejid, const char *const message, const char *const fp); -char* p_gpg_decrypt(const char *const cipher); -void p_gpg_free_decrypted(char *decrypted); -char* p_gpg_autocomplete_key(const char *const search_str, gboolean previous, void *context); +char* p_gpg_sign(const char* const str, const char* const fp); +void p_gpg_verify(const char* const barejid, const char* const sign); +char* p_gpg_encrypt(const char* const barejid, const char* const message, const char* const fp); +char* p_gpg_decrypt(const char* const cipher); +void p_gpg_free_decrypted(char* decrypted); +char* p_gpg_autocomplete_key(const char* const search_str, gboolean previous, void* context); void p_gpg_autocomplete_key_reset(void); -char* p_gpg_format_fp_str(char *fp); +char* p_gpg_format_fp_str(char* fp); -char* p_ox_gpg_signcrypt(const char* const sender_barejid, const char* const recipient_barejid , const char* const message); +char* p_ox_gpg_signcrypt(const char* const sender_barejid, const char* const recipient_barejid, const char* const message); char* p_ox_gpg_decrypt(char* base64); @@ -87,7 +89,7 @@ void p_ox_gpg_readkey(const char* const filename, char** key, char** fp); */ GHashTable* ox_gpg_public_keys(void); -gboolean ox_is_private_key_available(const char *const barejid); -gboolean ox_is_public_key_available(const char *const barejid); +gboolean ox_is_private_key_available(const char* const barejid); +gboolean ox_is_public_key_available(const char* const barejid); #endif diff --git a/src/plugins/api.c b/src/plugins/api.c index 59d1694a..2464c820 100644 --- a/src/plugins/api.c +++ b/src/plugins/api.c @@ -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); diff --git a/src/plugins/api.h b/src/plugins/api.h index e8dbb8fe..f0842c4e 100644 --- a/src/plugins/api.h +++ b/src/plugins/api.h @@ -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); - -char * api_get_current_recipient(void); -char * api_get_current_muc(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); + +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); - -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); - -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_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_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); + 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); + +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_disco_add_feature(char* plugin_name, char* feature); + +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_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); #endif diff --git a/src/plugins/autocompleters.c b/src/plugins/autocompleters.c index 410f57ce..f5686eb0 100644 --- a/src/plugins/autocompleters.c +++ b/src/plugins/autocompleters.c @@ -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); diff --git a/src/plugins/autocompleters.h b/src/plugins/autocompleters.h index 7dc2d41a..b8878f72 100644 --- a/src/plugins/autocompleters.h +++ b/src/plugins/autocompleters.h @@ -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); diff --git a/src/plugins/c_api.c b/src/plugins/c_api.c index 5f3c8792..0aa1a49e 100644 --- a/src/plugins/c_api.c +++ b/src/plugins/c_api.c @@ -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; diff --git a/src/plugins/c_api.h b/src/plugins/c_api.h index 062f76f9..71b04e82 100644 --- a/src/plugins/c_api.h +++ b/src/plugins/c_api.h @@ -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 diff --git a/src/plugins/c_plugins.c b/src/plugins/c_plugins.c index c7c1a523..ba731cf3 100644 --- a/src/plugins/c_plugins.c +++ b/src/plugins/c_plugins.c @@ -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) { - } diff --git a/src/plugins/c_plugins.h b/src/plugins/c_plugins.h index 3a603364..6440e670 100644 --- a/src/plugins/c_plugins.h +++ b/src/plugins/c_plugins.h @@ -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); - -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); - -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_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_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); - -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_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); + +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_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_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_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_chat_win_focus_hook(ProfPlugin* plugin, const char* const barejid); +void c_on_room_win_focus_hook(ProfPlugin* plugin, const char* const barejid); #endif diff --git a/src/plugins/callbacks.c b/src/plugins/callbacks.c index f82a4c9b..3d5d6e48 100644 --- a/src/plugins/callbacks.c +++ b/src/plugins/callbacks.c @@ -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); } diff --git a/src/plugins/callbacks.h b/src/plugins/callbacks.h index 782f152b..99ba76eb 100644 --- a/src/plugins/callbacks.h +++ b/src/plugins/callbacks.h @@ -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 diff --git a/src/plugins/disco.c b/src/plugins/disco.c index af0823f5..40dcde38 100644 --- a/src/plugins/disco.c +++ b/src/plugins/disco.c @@ -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* diff --git a/src/plugins/disco.h b/src/plugins/disco.h index 7ea89b0d..09f4c57f 100644 --- a/src/plugins/disco.h +++ b/src/plugins/disco.h @@ -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 - diff --git a/src/plugins/plugins.c b/src/plugins/plugins.c index d25b0b6e..a225c78a 100644 --- a/src/plugins/plugins.c +++ b/src/plugins/plugins.c @@ -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, ×tamp_tv); if (res) { timestamp_str = g_time_val_to_iso8601(×tamp_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 diff --git a/src/plugins/plugins.h b/src/plugins/plugins.h index 4dfcc7aa..48423b64 100644 --- a/src/plugins/plugins.h +++ b/src/plugins/plugins.h @@ -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); - - 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_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_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); - - 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_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_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* (*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_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_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); diff --git a/src/plugins/python_api.c b/src/plugins/python_api.c index 834bd3e8..fe66d99e 100644 --- a/src/plugins/python_api.c +++ b/src/plugins/python_api.c @@ -50,7 +50,7 @@ static char* _python_plugin_name(void); static PyObject* -python_api_cons_alert(PyObject *self, PyObject *args) +python_api_cons_alert(PyObject* self, PyObject* args) { allow_python_threads(); api_cons_alert(); @@ -60,14 +60,14 @@ python_api_cons_alert(PyObject *self, PyObject *args) } static PyObject* -python_api_cons_show(PyObject *self, PyObject *args) +python_api_cons_show(PyObject* self, PyObject* args) { PyObject* message = NULL; if (!PyArg_ParseTuple(args, "O", &message)) { Py_RETURN_NONE; } - char *message_str = python_str_or_unicode_to_string(message); + char* message_str = python_str_or_unicode_to_string(message); allow_python_threads(); api_cons_show(message_str); @@ -78,20 +78,20 @@ python_api_cons_show(PyObject *self, PyObject *args) } static PyObject* -python_api_cons_show_themed(PyObject *self, PyObject *args) +python_api_cons_show_themed(PyObject* self, PyObject* args) { - PyObject *group = NULL; - PyObject *key = NULL; - PyObject *def = NULL; - PyObject *message = NULL; + PyObject* group = NULL; + PyObject* key = NULL; + PyObject* def = NULL; + PyObject* message = NULL; if (!PyArg_ParseTuple(args, "OOOO", &group, &key, &def, &message)) { Py_RETURN_NONE; } - char *group_str = python_str_or_unicode_to_string(group); - char *key_str = python_str_or_unicode_to_string(key); - char *def_str = python_str_or_unicode_to_string(def); - char *message_str = python_str_or_unicode_to_string(message); + char* group_str = python_str_or_unicode_to_string(group); + char* key_str = python_str_or_unicode_to_string(key); + char* def_str = python_str_or_unicode_to_string(def); + char* message_str = python_str_or_unicode_to_string(message); allow_python_threads(); api_cons_show_themed(group_str, key_str, def_str, message_str); @@ -105,14 +105,14 @@ python_api_cons_show_themed(PyObject *self, PyObject *args) } static PyObject* -python_api_cons_bad_cmd_usage(PyObject *self, PyObject *args) +python_api_cons_bad_cmd_usage(PyObject* self, PyObject* args) { - PyObject *cmd = NULL; + PyObject* cmd = NULL; if (!PyArg_ParseTuple(args, "O", &cmd)) { Py_RETURN_NONE; } - char *cmd_str = python_str_or_unicode_to_string(cmd); + char* cmd_str = python_str_or_unicode_to_string(cmd); allow_python_threads(); api_cons_bad_cmd_usage(cmd_str); @@ -123,53 +123,53 @@ python_api_cons_bad_cmd_usage(PyObject *self, PyObject *args) } static PyObject* -python_api_register_command(PyObject *self, PyObject *args) +python_api_register_command(PyObject* self, PyObject* args) { - PyObject *command_name = NULL; + PyObject* command_name = NULL; int min_args = 0; int max_args = 0; - PyObject *synopsis = NULL; - PyObject *description = NULL; - PyObject *arguments = NULL; - PyObject *examples = NULL; - PyObject *p_callback = NULL; + PyObject* synopsis = NULL; + PyObject* description = NULL; + PyObject* arguments = NULL; + PyObject* examples = NULL; + PyObject* p_callback = NULL; if (!PyArg_ParseTuple(args, "OiiOOOOO", &command_name, &min_args, &max_args, - &synopsis, &description, &arguments, &examples, &p_callback)) { + &synopsis, &description, &arguments, &examples, &p_callback)) { Py_RETURN_NONE; } - char *command_name_str = python_str_or_unicode_to_string(command_name); - char *description_str = python_str_or_unicode_to_string(description); + char* command_name_str = python_str_or_unicode_to_string(command_name); + char* description_str = python_str_or_unicode_to_string(description); - char *plugin_name = _python_plugin_name(); + char* plugin_name = _python_plugin_name(); log_debug("Register command %s for %s", command_name_str, plugin_name); if (p_callback && PyCallable_Check(p_callback)) { Py_ssize_t len = PyList_Size(synopsis); - char *c_synopsis[len == 0 ? 0 : len+1]; + char* c_synopsis[len == 0 ? 0 : len + 1]; Py_ssize_t i = 0; for (i = 0; i < len; i++) { - PyObject *item = PyList_GetItem(synopsis, i); - char *c_item = python_str_or_unicode_to_string(item); + PyObject* item = PyList_GetItem(synopsis, i); + char* c_item = python_str_or_unicode_to_string(item); c_synopsis[i] = c_item; } c_synopsis[len] = NULL; Py_ssize_t args_len = PyList_Size(arguments); - char *c_arguments[args_len == 0 ? 0 : args_len+1][2]; + char* c_arguments[args_len == 0 ? 0 : args_len + 1][2]; for (i = 0; i < args_len; i++) { - PyObject *item = PyList_GetItem(arguments, i); + PyObject* item = PyList_GetItem(arguments, i); Py_ssize_t len2 = PyList_Size(item); if (len2 != 2) { Py_RETURN_NONE; } - PyObject *arg = PyList_GetItem(item, 0); - char *c_arg = python_str_or_unicode_to_string(arg); + PyObject* arg = PyList_GetItem(item, 0); + char* c_arg = python_str_or_unicode_to_string(arg); c_arguments[i][0] = c_arg; - PyObject *desc = PyList_GetItem(item, 1); - char *c_desc = python_str_or_unicode_to_string(desc); + PyObject* desc = PyList_GetItem(item, 1); + char* c_desc = python_str_or_unicode_to_string(desc); c_arguments[i][1] = c_desc; } @@ -177,17 +177,17 @@ python_api_register_command(PyObject *self, PyObject *args) c_arguments[args_len][1] = NULL; len = PyList_Size(examples); - char *c_examples[len == 0 ? 0 : len+1]; + char* c_examples[len == 0 ? 0 : len + 1]; for (i = 0; i < len; i++) { - PyObject *item = PyList_GetItem(examples, i); - char *c_item = python_str_or_unicode_to_string(item); + PyObject* item = PyList_GetItem(examples, i); + char* c_item = python_str_or_unicode_to_string(item); c_examples[i] = c_item; } c_examples[len] = NULL; allow_python_threads(); api_register_command(plugin_name, command_name_str, min_args, max_args, c_synopsis, - description_str, c_arguments, c_examples, p_callback, python_command_callback, NULL); + description_str, c_arguments, c_examples, p_callback, python_command_callback, NULL); free(command_name_str); free(description_str); i = 0; @@ -212,17 +212,17 @@ python_api_register_command(PyObject *self, PyObject *args) Py_RETURN_NONE; } -static PyObject * -python_api_register_timed(PyObject *self, PyObject *args) +static PyObject* +python_api_register_timed(PyObject* self, PyObject* args) { - PyObject *p_callback = NULL; + PyObject* p_callback = NULL; int interval_seconds = 0; if (!PyArg_ParseTuple(args, "Oi", &p_callback, &interval_seconds)) { Py_RETURN_NONE; } - char *plugin_name = _python_plugin_name(); + char* plugin_name = _python_plugin_name(); log_debug("Register timed for %s", plugin_name); if (p_callback && PyCallable_Check(p_callback)) { @@ -236,28 +236,28 @@ python_api_register_timed(PyObject *self, PyObject *args) Py_RETURN_NONE; } -static PyObject * -python_api_completer_add(PyObject *self, PyObject *args) +static PyObject* +python_api_completer_add(PyObject* self, PyObject* args) { - PyObject *key = NULL; - PyObject *items = NULL; + PyObject* key = NULL; + PyObject* items = NULL; if (!PyArg_ParseTuple(args, "OO", &key, &items)) { Py_RETURN_NONE; } - char *key_str = python_str_or_unicode_to_string(key); + char* key_str = python_str_or_unicode_to_string(key); - char *plugin_name = _python_plugin_name(); + char* plugin_name = _python_plugin_name(); log_debug("Autocomplete add %s for %s", key_str, plugin_name); Py_ssize_t len = PyList_Size(items); - char *c_items[len]; + char* c_items[len]; Py_ssize_t i = 0; for (i = 0; i < len; i++) { - PyObject *item = PyList_GetItem(items, i); - char *c_item = python_str_or_unicode_to_string(item); + PyObject* item = PyList_GetItem(items, i); + char* c_item = python_str_or_unicode_to_string(item); c_items[i] = c_item; } c_items[len] = NULL; @@ -276,28 +276,28 @@ python_api_completer_add(PyObject *self, PyObject *args) Py_RETURN_NONE; } -static PyObject * -python_api_completer_remove(PyObject *self, PyObject *args) +static PyObject* +python_api_completer_remove(PyObject* self, PyObject* args) { - PyObject *key = NULL; - PyObject *items = NULL; + PyObject* key = NULL; + PyObject* items = NULL; if (!PyArg_ParseTuple(args, "OO", &key, &items)) { Py_RETURN_NONE; } - char *key_str = python_str_or_unicode_to_string(key); + char* key_str = python_str_or_unicode_to_string(key); - char *plugin_name = _python_plugin_name(); + char* plugin_name = _python_plugin_name(); log_debug("Autocomplete remove %s for %s", key_str, plugin_name); Py_ssize_t len = PyList_Size(items); - char *c_items[len]; + char* c_items[len]; Py_ssize_t i = 0; for (i = 0; i < len; i++) { - PyObject *item = PyList_GetItem(items, i); - char *c_item = python_str_or_unicode_to_string(item); + PyObject* item = PyList_GetItem(items, i); + char* c_item = python_str_or_unicode_to_string(item); c_items[i] = c_item; } c_items[len] = NULL; @@ -312,18 +312,18 @@ python_api_completer_remove(PyObject *self, PyObject *args) Py_RETURN_NONE; } -static PyObject * -python_api_completer_clear(PyObject *self, PyObject *args) +static PyObject* +python_api_completer_clear(PyObject* self, PyObject* args) { - PyObject *key = NULL; + PyObject* key = NULL; if (!PyArg_ParseTuple(args, "O", &key)) { Py_RETURN_NONE; } - char *key_str = python_str_or_unicode_to_string(key); + char* key_str = python_str_or_unicode_to_string(key); - char *plugin_name = _python_plugin_name(); + char* plugin_name = _python_plugin_name(); log_debug("Autocomplete clear %s for %s", key_str, plugin_name); allow_python_threads(); @@ -337,17 +337,17 @@ python_api_completer_clear(PyObject *self, PyObject *args) } static PyObject* -python_api_filepath_completer_add(PyObject *self, PyObject *args) +python_api_filepath_completer_add(PyObject* self, PyObject* args) { - PyObject *prefix = NULL; + PyObject* prefix = NULL; if (!PyArg_ParseTuple(args, "O", &prefix)) { Py_RETURN_NONE; } - char *prefix_str = python_str_or_unicode_to_string(prefix); + char* prefix_str = python_str_or_unicode_to_string(prefix); - char *plugin_name = _python_plugin_name(); + char* plugin_name = _python_plugin_name(); log_debug("Filepath autocomplete added '%s' for %s", prefix_str, plugin_name); allow_python_threads(); @@ -361,18 +361,18 @@ python_api_filepath_completer_add(PyObject *self, PyObject *args) } static PyObject* -python_api_notify(PyObject *self, PyObject *args) +python_api_notify(PyObject* self, PyObject* args) { - PyObject *message = NULL; - PyObject *category = NULL; + PyObject* message = NULL; + PyObject* category = NULL; int timeout_ms = 5000; if (!PyArg_ParseTuple(args, "OiO", &message, &timeout_ms, &category)) { Py_RETURN_NONE; } - char *message_str = python_str_or_unicode_to_string(message); - char *category_str = python_str_or_unicode_to_string(category); + char* message_str = python_str_or_unicode_to_string(message); + char* category_str = python_str_or_unicode_to_string(category); allow_python_threads(); api_notify(message_str, category_str, timeout_ms); @@ -384,14 +384,14 @@ python_api_notify(PyObject *self, PyObject *args) } static PyObject* -python_api_send_line(PyObject *self, PyObject *args) +python_api_send_line(PyObject* self, PyObject* args) { - PyObject *line = NULL; + PyObject* line = NULL; if (!PyArg_ParseTuple(args, "O", &line)) { Py_RETURN_NONE; } - char *line_str = python_str_or_unicode_to_string(line); + char* line_str = python_str_or_unicode_to_string(line); allow_python_threads(); api_send_line(line_str); @@ -401,11 +401,11 @@ python_api_send_line(PyObject *self, PyObject *args) Py_RETURN_NONE; } -static PyObject * -python_api_get_current_recipient(PyObject *self, PyObject *args) +static PyObject* +python_api_get_current_recipient(PyObject* self, PyObject* args) { allow_python_threads(); - char *recipient = api_get_current_recipient(); + char* recipient = api_get_current_recipient(); disable_python_threads(); if (recipient) { return Py_BuildValue("s", recipient); @@ -414,11 +414,11 @@ python_api_get_current_recipient(PyObject *self, PyObject *args) } } -static PyObject * -python_api_get_current_muc(PyObject *self, PyObject *args) +static PyObject* +python_api_get_current_muc(PyObject* self, PyObject* args) { allow_python_threads(); - char *room = api_get_current_muc(); + char* room = api_get_current_muc(); disable_python_threads(); if (room) { return Py_BuildValue("s", room); @@ -427,11 +427,11 @@ python_api_get_current_muc(PyObject *self, PyObject *args) } } -static PyObject * -python_api_get_current_nick(PyObject *self, PyObject *args) +static PyObject* +python_api_get_current_nick(PyObject* self, PyObject* args) { allow_python_threads(); - char *nick = api_get_current_nick(); + char* nick = api_get_current_nick(); disable_python_threads(); if (nick) { return Py_BuildValue("s", nick); @@ -441,12 +441,12 @@ python_api_get_current_nick(PyObject *self, PyObject *args) } static PyObject* -python_api_get_current_occupants(PyObject *self, PyObject *args) +python_api_get_current_occupants(PyObject* self, PyObject* args) { allow_python_threads(); - char **occupants = api_get_current_occupants(); + char** occupants = api_get_current_occupants(); disable_python_threads(); - PyObject *result = PyList_New(0); + PyObject* result = PyList_New(0); if (occupants) { int len = g_strv_length(occupants); int i = 0; @@ -460,7 +460,7 @@ python_api_get_current_occupants(PyObject *self, PyObject *args) } static PyObject* -python_api_current_win_is_console(PyObject *self, PyObject *args) +python_api_current_win_is_console(PyObject* self, PyObject* args) { allow_python_threads(); int res = api_current_win_is_console(); @@ -473,17 +473,17 @@ python_api_current_win_is_console(PyObject *self, PyObject *args) } static PyObject* -python_api_get_room_nick(PyObject *self, PyObject *args) +python_api_get_room_nick(PyObject* self, PyObject* args) { - PyObject *barejid = NULL; + PyObject* barejid = NULL; if (!PyArg_ParseTuple(args, "O", &barejid)) { Py_RETURN_NONE; } - char *barejid_str = python_str_or_unicode_to_string(barejid); + char* barejid_str = python_str_or_unicode_to_string(barejid); allow_python_threads(); - char *nick = api_get_room_nick(barejid_str); + char* nick = api_get_room_nick(barejid_str); free(barejid_str); disable_python_threads(); if (nick) { @@ -493,15 +493,15 @@ python_api_get_room_nick(PyObject *self, PyObject *args) } } -static PyObject * -python_api_log_debug(PyObject *self, PyObject *args) +static PyObject* +python_api_log_debug(PyObject* self, PyObject* args) { - PyObject *message = NULL; + PyObject* message = NULL; if (!PyArg_ParseTuple(args, "O", &message)) { Py_RETURN_NONE; } - char *message_str = python_str_or_unicode_to_string(message); + char* message_str = python_str_or_unicode_to_string(message); allow_python_threads(); api_log_debug(message_str); @@ -511,15 +511,15 @@ python_api_log_debug(PyObject *self, PyObject *args) Py_RETURN_NONE; } -static PyObject * -python_api_log_info(PyObject *self, PyObject *args) +static PyObject* +python_api_log_info(PyObject* self, PyObject* args) { - PyObject *message = NULL; + PyObject* message = NULL; if (!PyArg_ParseTuple(args, "O", &message)) { Py_RETURN_NONE; } - char *message_str = python_str_or_unicode_to_string(message); + char* message_str = python_str_or_unicode_to_string(message); allow_python_threads(); api_log_info(message_str); @@ -529,15 +529,15 @@ python_api_log_info(PyObject *self, PyObject *args) Py_RETURN_NONE; } -static PyObject * -python_api_log_warning(PyObject *self, PyObject *args) +static PyObject* +python_api_log_warning(PyObject* self, PyObject* args) { - PyObject *message = NULL; + PyObject* message = NULL; if (!PyArg_ParseTuple(args, "O", &message)) { Py_RETURN_NONE; } - char *message_str = python_str_or_unicode_to_string(message); + char* message_str = python_str_or_unicode_to_string(message); allow_python_threads(); api_log_warning(message_str); @@ -547,15 +547,15 @@ python_api_log_warning(PyObject *self, PyObject *args) Py_RETURN_NONE; } -static PyObject * -python_api_log_error(PyObject *self, PyObject *args) +static PyObject* +python_api_log_error(PyObject* self, PyObject* args) { - PyObject *message = NULL; + PyObject* message = NULL; if (!PyArg_ParseTuple(args, "O", &message)) { Py_RETURN_NONE; } - char *message_str = python_str_or_unicode_to_string(message); + char* message_str = python_str_or_unicode_to_string(message); allow_python_threads(); api_log_error(message_str); @@ -565,15 +565,15 @@ python_api_log_error(PyObject *self, PyObject *args) Py_RETURN_NONE; } -static PyObject * -python_api_win_exists(PyObject *self, PyObject *args) +static PyObject* +python_api_win_exists(PyObject* self, PyObject* args) { - PyObject *tag = NULL; + PyObject* tag = NULL; if (!PyArg_ParseTuple(args, "O", &tag)) { Py_RETURN_NONE; } - char *tag_str = python_str_or_unicode_to_string(tag); + char* tag_str = python_str_or_unicode_to_string(tag); allow_python_threads(); gboolean exists = api_win_exists(tag_str); @@ -587,19 +587,19 @@ python_api_win_exists(PyObject *self, PyObject *args) } } -static PyObject * -python_api_win_create(PyObject *self, PyObject *args) +static PyObject* +python_api_win_create(PyObject* self, PyObject* args) { - PyObject *tag = NULL; - PyObject *p_callback = NULL; + PyObject* tag = NULL; + PyObject* p_callback = NULL; if (!PyArg_ParseTuple(args, "OO", &tag, &p_callback)) { Py_RETURN_NONE; } - char *tag_str = python_str_or_unicode_to_string(tag); + char* tag_str = python_str_or_unicode_to_string(tag); - char *plugin_name = _python_plugin_name(); + char* plugin_name = _python_plugin_name(); if (p_callback && PyCallable_Check(p_callback)) { allow_python_threads(); @@ -613,16 +613,16 @@ python_api_win_create(PyObject *self, PyObject *args) Py_RETURN_NONE; } -static PyObject * -python_api_win_focus(PyObject *self, PyObject *args) +static PyObject* +python_api_win_focus(PyObject* self, PyObject* args) { - PyObject *tag = NULL; + PyObject* tag = NULL; if (!PyArg_ParseTuple(args, "O", &tag)) { Py_RETURN_NONE; } - char *tag_str = python_str_or_unicode_to_string(tag); + char* tag_str = python_str_or_unicode_to_string(tag); allow_python_threads(); api_win_focus(tag_str); @@ -632,18 +632,18 @@ python_api_win_focus(PyObject *self, PyObject *args) Py_RETURN_NONE; } -static PyObject * -python_api_win_show(PyObject *self, PyObject *args) +static PyObject* +python_api_win_show(PyObject* self, PyObject* args) { - PyObject *tag = NULL; - PyObject *line = NULL; + PyObject* tag = NULL; + PyObject* line = NULL; if (!PyArg_ParseTuple(args, "OO", &tag, &line)) { Py_RETURN_NONE; } - char *tag_str = python_str_or_unicode_to_string(tag); - char *line_str = python_str_or_unicode_to_string(line); + char* tag_str = python_str_or_unicode_to_string(tag); + char* line_str = python_str_or_unicode_to_string(line); allow_python_threads(); api_win_show(tag_str, line_str); @@ -654,25 +654,25 @@ python_api_win_show(PyObject *self, PyObject *args) Py_RETURN_NONE; } -static PyObject * -python_api_win_show_themed(PyObject *self, PyObject *args) +static PyObject* +python_api_win_show_themed(PyObject* self, PyObject* args) { - PyObject *tag = NULL; - PyObject *group = NULL; - PyObject *key = NULL; - PyObject *def = NULL; - PyObject *line = NULL; + PyObject* tag = NULL; + PyObject* group = NULL; + PyObject* key = NULL; + PyObject* def = NULL; + PyObject* line = NULL; if (!PyArg_ParseTuple(args, "OOOOO", &tag, &group, &key, &def, &line)) { python_check_error(); Py_RETURN_NONE; } - char *tag_str = python_str_or_unicode_to_string(tag); - char *group_str = python_str_or_unicode_to_string(group); - char *key_str = python_str_or_unicode_to_string(key); - char *def_str = python_str_or_unicode_to_string(def); - char *line_str = python_str_or_unicode_to_string(line); + char* tag_str = python_str_or_unicode_to_string(tag); + char* group_str = python_str_or_unicode_to_string(group); + char* key_str = python_str_or_unicode_to_string(key); + char* def_str = python_str_or_unicode_to_string(def); + char* line_str = python_str_or_unicode_to_string(line); allow_python_threads(); api_win_show_themed(tag_str, group_str, key_str, def_str, line_str); @@ -687,14 +687,14 @@ python_api_win_show_themed(PyObject *self, PyObject *args) } static PyObject* -python_api_send_stanza(PyObject *self, PyObject *args) +python_api_send_stanza(PyObject* self, PyObject* args) { - PyObject *stanza = NULL; + PyObject* stanza = NULL; if (!PyArg_ParseTuple(args, "O", &stanza)) { return Py_BuildValue("O", Py_False); } - char *stanza_str = python_str_or_unicode_to_string(stanza); + char* stanza_str = python_str_or_unicode_to_string(stanza); allow_python_threads(); int res = api_send_stanza(stanza_str); @@ -708,18 +708,18 @@ python_api_send_stanza(PyObject *self, PyObject *args) } static PyObject* -python_api_settings_boolean_get(PyObject *self, PyObject *args) +python_api_settings_boolean_get(PyObject* self, PyObject* args) { - PyObject *group = NULL; - PyObject *key = NULL; - PyObject *defobj = NULL; + PyObject* group = NULL; + PyObject* key = NULL; + PyObject* defobj = NULL; if (!PyArg_ParseTuple(args, "OOO!", &group, &key, &PyBool_Type, &defobj)) { Py_RETURN_NONE; } - char *group_str = python_str_or_unicode_to_string(group); - char *key_str = python_str_or_unicode_to_string(key); + char* group_str = python_str_or_unicode_to_string(group); + char* key_str = python_str_or_unicode_to_string(key); int def = PyObject_IsTrue(defobj); allow_python_threads(); @@ -736,18 +736,18 @@ python_api_settings_boolean_get(PyObject *self, PyObject *args) } static PyObject* -python_api_settings_boolean_set(PyObject *self, PyObject *args) +python_api_settings_boolean_set(PyObject* self, PyObject* args) { - PyObject *group = NULL; - PyObject *key = NULL; - PyObject *valobj = NULL; + PyObject* group = NULL; + PyObject* key = NULL; + PyObject* valobj = NULL; if (!PyArg_ParseTuple(args, "OOO!", &group, &key, &PyBool_Type, &valobj)) { Py_RETURN_NONE; } - char *group_str = python_str_or_unicode_to_string(group); - char *key_str = python_str_or_unicode_to_string(key); + char* group_str = python_str_or_unicode_to_string(group); + char* key_str = python_str_or_unicode_to_string(key); int val = PyObject_IsTrue(valobj); allow_python_threads(); @@ -760,29 +760,29 @@ python_api_settings_boolean_set(PyObject *self, PyObject *args) } static PyObject* -python_api_settings_string_get(PyObject *self, PyObject *args) +python_api_settings_string_get(PyObject* self, PyObject* args) { - PyObject *group = NULL; - PyObject *key = NULL; - PyObject *def = NULL; + PyObject* group = NULL; + PyObject* key = NULL; + PyObject* def = NULL; if (!PyArg_ParseTuple(args, "OOO", &group, &key, &def)) { Py_RETURN_NONE; } - char *group_str = python_str_or_unicode_to_string(group); - char *key_str = python_str_or_unicode_to_string(key); - char *def_str = python_str_or_unicode_to_string(def); + char* group_str = python_str_or_unicode_to_string(group); + char* key_str = python_str_or_unicode_to_string(key); + char* def_str = python_str_or_unicode_to_string(def); allow_python_threads(); - char *res = api_settings_string_get(group_str, key_str, def_str); + char* res = api_settings_string_get(group_str, key_str, def_str); free(group_str); free(key_str); free(def_str); disable_python_threads(); if (res) { - PyObject *pyres = Py_BuildValue("s", res); + PyObject* pyres = Py_BuildValue("s", res); free(res); return pyres; } else { @@ -791,19 +791,19 @@ python_api_settings_string_get(PyObject *self, PyObject *args) } static PyObject* -python_api_settings_string_set(PyObject *self, PyObject *args) +python_api_settings_string_set(PyObject* self, PyObject* args) { - PyObject *group = NULL; - PyObject *key = NULL; - PyObject *val = NULL; + PyObject* group = NULL; + PyObject* key = NULL; + PyObject* val = NULL; if (!PyArg_ParseTuple(args, "OOO", &group, &key, &val)) { Py_RETURN_NONE; } - char *group_str = python_str_or_unicode_to_string(group); - char *key_str = python_str_or_unicode_to_string(key); - char *val_str = python_str_or_unicode_to_string(val); + char* group_str = python_str_or_unicode_to_string(group); + char* key_str = python_str_or_unicode_to_string(key); + char* val_str = python_str_or_unicode_to_string(val); allow_python_threads(); api_settings_string_set(group_str, key_str, val_str); @@ -816,18 +816,18 @@ python_api_settings_string_set(PyObject *self, PyObject *args) } static PyObject* -python_api_settings_int_get(PyObject *self, PyObject *args) +python_api_settings_int_get(PyObject* self, PyObject* args) { - PyObject *group = NULL; - PyObject *key = NULL; + PyObject* group = NULL; + PyObject* key = NULL; int def = 0; if (!PyArg_ParseTuple(args, "OOi", &group, &key, &def)) { Py_RETURN_NONE; } - char *group_str = python_str_or_unicode_to_string(group); - char *key_str = python_str_or_unicode_to_string(key); + char* group_str = python_str_or_unicode_to_string(group); + char* key_str = python_str_or_unicode_to_string(key); allow_python_threads(); int res = api_settings_int_get(group_str, key_str, def); @@ -839,18 +839,18 @@ python_api_settings_int_get(PyObject *self, PyObject *args) } static PyObject* -python_api_settings_int_set(PyObject *self, PyObject *args) +python_api_settings_int_set(PyObject* self, PyObject* args) { - PyObject *group = NULL; - PyObject *key = NULL; + PyObject* group = NULL; + PyObject* key = NULL; int val = 0; if (!PyArg_ParseTuple(args, "OOi", &group, &key, &val)) { Py_RETURN_NONE; } - char *group_str = python_str_or_unicode_to_string(group); - char *key_str = python_str_or_unicode_to_string(key); + char* group_str = python_str_or_unicode_to_string(group); + char* key_str = python_str_or_unicode_to_string(key); allow_python_threads(); api_settings_int_set(group_str, key_str, val); @@ -862,17 +862,17 @@ python_api_settings_int_set(PyObject *self, PyObject *args) } static PyObject* -python_api_settings_string_list_get(PyObject *self, PyObject *args) +python_api_settings_string_list_get(PyObject* self, PyObject* args) { - PyObject *group = NULL; - PyObject *key = NULL; + PyObject* group = NULL; + PyObject* key = NULL; if (!PyArg_ParseTuple(args, "OO", &group, &key)) { Py_RETURN_NONE; } - char *group_str = python_str_or_unicode_to_string(group); - char *key_str = python_str_or_unicode_to_string(key); + char* group_str = python_str_or_unicode_to_string(group); + char* key_str = python_str_or_unicode_to_string(key); allow_python_threads(); char** c_list = api_settings_string_list_get(group_str, key_str); @@ -884,12 +884,11 @@ python_api_settings_string_list_get(PyObject *self, PyObject *args) Py_RETURN_NONE; } - int len = g_strv_length(c_list); - PyObject *py_list = PyList_New(0); + PyObject* py_list = PyList_New(0); int i = 0; for (i = 0; i < len; i++) { - PyObject *py_curr = Py_BuildValue("s", c_list[i]); + PyObject* py_curr = Py_BuildValue("s", c_list[i]); int res = PyList_Append(py_list, py_curr); if (res != 0) { g_strfreev(c_list); @@ -903,19 +902,19 @@ python_api_settings_string_list_get(PyObject *self, PyObject *args) } static PyObject* -python_api_settings_string_list_add(PyObject *self, PyObject *args) +python_api_settings_string_list_add(PyObject* self, PyObject* args) { - PyObject *group = NULL; - PyObject *key = NULL; - PyObject *val = NULL; + PyObject* group = NULL; + PyObject* key = NULL; + PyObject* val = NULL; if (!PyArg_ParseTuple(args, "OOO", &group, &key, &val)) { Py_RETURN_NONE; } - char *group_str = python_str_or_unicode_to_string(group); - char *key_str = python_str_or_unicode_to_string(key); - char *val_str = python_str_or_unicode_to_string(val); + char* group_str = python_str_or_unicode_to_string(group); + char* key_str = python_str_or_unicode_to_string(key); + char* val_str = python_str_or_unicode_to_string(val); allow_python_threads(); api_settings_string_list_add(group_str, key_str, val_str); @@ -928,19 +927,19 @@ python_api_settings_string_list_add(PyObject *self, PyObject *args) } static PyObject* -python_api_settings_string_list_remove(PyObject *self, PyObject *args) +python_api_settings_string_list_remove(PyObject* self, PyObject* args) { - PyObject *group = NULL; - PyObject *key = NULL; - PyObject *val = NULL; + PyObject* group = NULL; + PyObject* key = NULL; + PyObject* val = NULL; if (!PyArg_ParseTuple(args, "OOO", &group, &key, &val)) { Py_RETURN_NONE; } - char *group_str = python_str_or_unicode_to_string(group); - char *key_str = python_str_or_unicode_to_string(key); - char *val_str = python_str_or_unicode_to_string(val); + char* group_str = python_str_or_unicode_to_string(group); + char* key_str = python_str_or_unicode_to_string(key); + char* val_str = python_str_or_unicode_to_string(val); allow_python_threads(); int res = api_settings_string_list_remove(group_str, key_str, val_str); @@ -957,17 +956,17 @@ python_api_settings_string_list_remove(PyObject *self, PyObject *args) } static PyObject* -python_api_settings_string_list_clear(PyObject *self, PyObject *args) +python_api_settings_string_list_clear(PyObject* self, PyObject* args) { - PyObject *group = NULL; - PyObject *key = NULL; + PyObject* group = NULL; + PyObject* key = NULL; if (!PyArg_ParseTuple(args, "OO", &group, &key)) { return Py_BuildValue("O", Py_False); } - char *group_str = python_str_or_unicode_to_string(group); - char *key_str = python_str_or_unicode_to_string(key); + char* group_str = python_str_or_unicode_to_string(group); + char* key_str = python_str_or_unicode_to_string(key); allow_python_threads(); int res = api_settings_string_list_clear(group_str, key_str); @@ -983,19 +982,19 @@ python_api_settings_string_list_clear(PyObject *self, PyObject *args) } static PyObject* -python_api_incoming_message(PyObject *self, PyObject *args) +python_api_incoming_message(PyObject* self, PyObject* args) { - PyObject *barejid = NULL; - PyObject *resource = NULL; - PyObject *message = NULL; + PyObject* barejid = NULL; + PyObject* resource = NULL; + PyObject* message = NULL; if (!PyArg_ParseTuple(args, "OOO", &barejid, &resource, &message)) { Py_RETURN_NONE; } - char *barejid_str = python_str_or_unicode_to_string(barejid); - char *resource_str = python_str_or_unicode_to_string(resource); - char *message_str = python_str_or_unicode_to_string(message); + char* barejid_str = python_str_or_unicode_to_string(barejid); + char* resource_str = python_str_or_unicode_to_string(resource); + char* message_str = python_str_or_unicode_to_string(message); allow_python_threads(); api_incoming_message(barejid_str, resource_str, message_str); @@ -1008,15 +1007,15 @@ python_api_incoming_message(PyObject *self, PyObject *args) } static PyObject* -python_api_disco_add_feature(PyObject *self, PyObject *args) +python_api_disco_add_feature(PyObject* self, PyObject* args) { - PyObject *feature = NULL; + PyObject* feature = NULL; if (!PyArg_ParseTuple(args, "O", &feature)) { Py_RETURN_NONE; } - char *feature_str = python_str_or_unicode_to_string(feature); - char *plugin_name = _python_plugin_name(); + char* feature_str = python_str_or_unicode_to_string(feature); + char* plugin_name = _python_plugin_name(); allow_python_threads(); api_disco_add_feature(plugin_name, feature_str); @@ -1029,14 +1028,14 @@ python_api_disco_add_feature(PyObject *self, PyObject *args) } static PyObject* -python_api_encryption_reset(PyObject *self, PyObject *args) +python_api_encryption_reset(PyObject* self, PyObject* args) { - PyObject *barejid = NULL; + PyObject* barejid = NULL; if (!PyArg_ParseTuple(args, "O", &barejid)) { Py_RETURN_NONE; } - char *barejid_str = python_str_or_unicode_to_string(barejid); + char* barejid_str = python_str_or_unicode_to_string(barejid); allow_python_threads(); api_encryption_reset(barejid_str); @@ -1047,16 +1046,16 @@ python_api_encryption_reset(PyObject *self, PyObject *args) } static PyObject* -python_api_chat_set_titlebar_enctext(PyObject *self, PyObject *args) +python_api_chat_set_titlebar_enctext(PyObject* self, PyObject* args) { - PyObject *barejid = NULL; - PyObject *enctext = NULL; + PyObject* barejid = NULL; + PyObject* enctext = NULL; if (!PyArg_ParseTuple(args, "OO", &barejid, &enctext)) { Py_RETURN_NONE; } - char *barejid_str = python_str_or_unicode_to_string(barejid); - char *enctext_str = python_str_or_unicode_to_string(enctext); + char* barejid_str = python_str_or_unicode_to_string(barejid); + char* enctext_str = python_str_or_unicode_to_string(enctext); allow_python_threads(); int res = api_chat_set_titlebar_enctext(barejid_str, enctext_str); @@ -1072,14 +1071,14 @@ python_api_chat_set_titlebar_enctext(PyObject *self, PyObject *args) } static PyObject* -python_api_chat_unset_titlebar_enctext(PyObject *self, PyObject *args) +python_api_chat_unset_titlebar_enctext(PyObject* self, PyObject* args) { - PyObject *barejid = NULL; + PyObject* barejid = NULL; if (!PyArg_ParseTuple(args, "O", &barejid)) { Py_RETURN_NONE; } - char *barejid_str = python_str_or_unicode_to_string(barejid); + char* barejid_str = python_str_or_unicode_to_string(barejid); allow_python_threads(); int res = api_chat_unset_titlebar_enctext(barejid_str); @@ -1094,16 +1093,16 @@ python_api_chat_unset_titlebar_enctext(PyObject *self, PyObject *args) } static PyObject* -python_api_chat_set_incoming_char(PyObject *self, PyObject *args) +python_api_chat_set_incoming_char(PyObject* self, PyObject* args) { - PyObject *barejid = NULL; - PyObject *ch = NULL; + PyObject* barejid = NULL; + PyObject* ch = NULL; if (!PyArg_ParseTuple(args, "OO", &barejid, &ch)) { Py_RETURN_NONE; } - char *barejid_str = python_str_or_unicode_to_string(barejid); - char *ch_str = python_str_or_unicode_to_string(ch); + char* barejid_str = python_str_or_unicode_to_string(barejid); + char* ch_str = python_str_or_unicode_to_string(ch); allow_python_threads(); int res = api_chat_set_incoming_char(barejid_str, ch_str); @@ -1119,14 +1118,14 @@ python_api_chat_set_incoming_char(PyObject *self, PyObject *args) } static PyObject* -python_api_chat_unset_incoming_char(PyObject *self, PyObject *args) +python_api_chat_unset_incoming_char(PyObject* self, PyObject* args) { - PyObject *barejid = NULL; + PyObject* barejid = NULL; if (!PyArg_ParseTuple(args, "O", &barejid)) { Py_RETURN_NONE; } - char *barejid_str = python_str_or_unicode_to_string(barejid); + char* barejid_str = python_str_or_unicode_to_string(barejid); allow_python_threads(); int res = api_chat_unset_incoming_char(barejid_str); @@ -1141,16 +1140,16 @@ python_api_chat_unset_incoming_char(PyObject *self, PyObject *args) } static PyObject* -python_api_chat_set_outgoing_char(PyObject *self, PyObject *args) +python_api_chat_set_outgoing_char(PyObject* self, PyObject* args) { - PyObject *barejid = NULL; - PyObject *ch = NULL; + PyObject* barejid = NULL; + PyObject* ch = NULL; if (!PyArg_ParseTuple(args, "OO", &barejid, &ch)) { Py_RETURN_NONE; } - char *barejid_str = python_str_or_unicode_to_string(barejid); - char *ch_str = python_str_or_unicode_to_string(ch); + char* barejid_str = python_str_or_unicode_to_string(barejid); + char* ch_str = python_str_or_unicode_to_string(ch); allow_python_threads(); int res = api_chat_set_outgoing_char(barejid_str, ch_str); @@ -1166,14 +1165,14 @@ python_api_chat_set_outgoing_char(PyObject *self, PyObject *args) } static PyObject* -python_api_chat_unset_outgoing_char(PyObject *self, PyObject *args) +python_api_chat_unset_outgoing_char(PyObject* self, PyObject* args) { - PyObject *barejid = NULL; + PyObject* barejid = NULL; if (!PyArg_ParseTuple(args, "O", &barejid)) { Py_RETURN_NONE; } - char *barejid_str = python_str_or_unicode_to_string(barejid); + char* barejid_str = python_str_or_unicode_to_string(barejid); allow_python_threads(); int res = api_chat_unset_outgoing_char(barejid_str); @@ -1188,16 +1187,16 @@ python_api_chat_unset_outgoing_char(PyObject *self, PyObject *args) } static PyObject* -python_api_room_set_titlebar_enctext(PyObject *self, PyObject *args) +python_api_room_set_titlebar_enctext(PyObject* self, PyObject* args) { - PyObject *roomjid = NULL; - PyObject *enctext = NULL; + PyObject* roomjid = NULL; + PyObject* enctext = NULL; if (!PyArg_ParseTuple(args, "OO", &roomjid, &enctext)) { Py_RETURN_NONE; } - char *roomjid_str = python_str_or_unicode_to_string(roomjid); - char *enctext_str = python_str_or_unicode_to_string(enctext); + char* roomjid_str = python_str_or_unicode_to_string(roomjid); + char* enctext_str = python_str_or_unicode_to_string(enctext); allow_python_threads(); int res = api_room_set_titlebar_enctext(roomjid_str, enctext_str); @@ -1213,14 +1212,14 @@ python_api_room_set_titlebar_enctext(PyObject *self, PyObject *args) } static PyObject* -python_api_room_unset_titlebar_enctext(PyObject *self, PyObject *args) +python_api_room_unset_titlebar_enctext(PyObject* self, PyObject* args) { - PyObject *roomjid = NULL; + PyObject* roomjid = NULL; if (!PyArg_ParseTuple(args, "O", &roomjid)) { Py_RETURN_NONE; } - char *roomjid_str = python_str_or_unicode_to_string(roomjid); + char* roomjid_str = python_str_or_unicode_to_string(roomjid); allow_python_threads(); int res = api_room_unset_titlebar_enctext(roomjid_str); @@ -1235,16 +1234,16 @@ python_api_room_unset_titlebar_enctext(PyObject *self, PyObject *args) } static PyObject* -python_api_room_set_message_char(PyObject *self, PyObject *args) +python_api_room_set_message_char(PyObject* self, PyObject* args) { - PyObject *roomjid = NULL; - PyObject *ch = NULL; + PyObject* roomjid = NULL; + PyObject* ch = NULL; if (!PyArg_ParseTuple(args, "OO", &roomjid, &ch)) { Py_RETURN_NONE; } - char *roomjid_str = python_str_or_unicode_to_string(roomjid); - char *ch_str = python_str_or_unicode_to_string(ch); + char* roomjid_str = python_str_or_unicode_to_string(roomjid); + char* ch_str = python_str_or_unicode_to_string(ch); allow_python_threads(); int res = api_room_set_message_char(roomjid_str, ch_str); @@ -1260,14 +1259,14 @@ python_api_room_set_message_char(PyObject *self, PyObject *args) } static PyObject* -python_api_room_unset_message_char(PyObject *self, PyObject *args) +python_api_room_unset_message_char(PyObject* self, PyObject* args) { - PyObject *roomjid = NULL; + PyObject* roomjid = NULL; if (!PyArg_ParseTuple(args, "O", &roomjid)) { Py_RETURN_NONE; } - char *roomjid_str = python_str_or_unicode_to_string(roomjid); + char* roomjid_str = python_str_or_unicode_to_string(roomjid); allow_python_threads(); int res = api_room_unset_message_char(roomjid_str); @@ -1282,16 +1281,16 @@ python_api_room_unset_message_char(PyObject *self, PyObject *args) } static PyObject* -python_api_chat_show(PyObject *self, PyObject *args) +python_api_chat_show(PyObject* self, PyObject* args) { - PyObject *barejid = NULL; - PyObject *message = NULL; + PyObject* barejid = NULL; + PyObject* message = NULL; if (!PyArg_ParseTuple(args, "OO", &barejid, &message)) { Py_RETURN_NONE; } - char *barejid_str = python_str_or_unicode_to_string(barejid); - char *message_str = python_str_or_unicode_to_string(message); + char* barejid_str = python_str_or_unicode_to_string(barejid); + char* message_str = python_str_or_unicode_to_string(message); allow_python_threads(); int res = api_chat_show(barejid_str, message_str); @@ -1307,24 +1306,24 @@ python_api_chat_show(PyObject *self, PyObject *args) } static PyObject* -python_api_chat_show_themed(PyObject *self, PyObject *args) +python_api_chat_show_themed(PyObject* self, PyObject* args) { - PyObject *barejid = NULL; - PyObject *group = NULL; - PyObject *key = NULL; - PyObject *def = NULL; - PyObject *ch = NULL; - PyObject *message = NULL; + PyObject* barejid = NULL; + PyObject* group = NULL; + PyObject* key = NULL; + PyObject* def = NULL; + PyObject* ch = NULL; + PyObject* message = NULL; if (!PyArg_ParseTuple(args, "OOOOOO", &barejid, &group, &key, &def, &ch, &message)) { Py_RETURN_NONE; } - char *barejid_str = python_str_or_unicode_to_string(barejid); - char *group_str = python_str_or_unicode_to_string(group); - char *key_str = python_str_or_unicode_to_string(key); - char *def_str = python_str_or_unicode_to_string(def); - char *ch_str = python_str_or_unicode_to_string(ch); - char *message_str = python_str_or_unicode_to_string(message); + char* barejid_str = python_str_or_unicode_to_string(barejid); + char* group_str = python_str_or_unicode_to_string(group); + char* key_str = python_str_or_unicode_to_string(key); + char* def_str = python_str_or_unicode_to_string(def); + char* ch_str = python_str_or_unicode_to_string(ch); + char* message_str = python_str_or_unicode_to_string(message); allow_python_threads(); int res = api_chat_show_themed(barejid_str, group_str, key_str, def_str, ch_str, message_str); @@ -1344,16 +1343,16 @@ python_api_chat_show_themed(PyObject *self, PyObject *args) } static PyObject* -python_api_room_show(PyObject *self, PyObject *args) +python_api_room_show(PyObject* self, PyObject* args) { - PyObject *roomjid = NULL; - PyObject *message = NULL; + PyObject* roomjid = NULL; + PyObject* message = NULL; if (!PyArg_ParseTuple(args, "OO", &roomjid, &message)) { Py_RETURN_NONE; } - char *roomjid_str = python_str_or_unicode_to_string(roomjid); - char *message_str = python_str_or_unicode_to_string(message); + char* roomjid_str = python_str_or_unicode_to_string(roomjid); + char* message_str = python_str_or_unicode_to_string(message); allow_python_threads(); int res = api_room_show(roomjid_str, message_str); @@ -1369,24 +1368,24 @@ python_api_room_show(PyObject *self, PyObject *args) } static PyObject* -python_api_room_show_themed(PyObject *self, PyObject *args) +python_api_room_show_themed(PyObject* self, PyObject* args) { - PyObject *roomjid = NULL; - PyObject *group = NULL; - PyObject *key = NULL; - PyObject *def = NULL; - PyObject *ch = NULL; - PyObject *message = NULL; + PyObject* roomjid = NULL; + PyObject* group = NULL; + PyObject* key = NULL; + PyObject* def = NULL; + PyObject* ch = NULL; + PyObject* message = NULL; if (!PyArg_ParseTuple(args, "OOOOOO", &roomjid, &group, &key, &def, &ch, &message)) { Py_RETURN_NONE; } - char *roomjid_str = python_str_or_unicode_to_string(roomjid); - char *group_str = python_str_or_unicode_to_string(group); - char *key_str = python_str_or_unicode_to_string(key); - char *def_str = python_str_or_unicode_to_string(def); - char *ch_str = python_str_or_unicode_to_string(ch); - char *message_str = python_str_or_unicode_to_string(message); + char* roomjid_str = python_str_or_unicode_to_string(roomjid); + char* group_str = python_str_or_unicode_to_string(group); + char* key_str = python_str_or_unicode_to_string(key); + char* def_str = python_str_or_unicode_to_string(def); + char* ch_str = python_str_or_unicode_to_string(ch); + char* message_str = python_str_or_unicode_to_string(message); allow_python_threads(); int res = api_room_show_themed(roomjid_str, group_str, key_str, def_str, ch_str, message_str); @@ -1406,10 +1405,10 @@ python_api_room_show_themed(PyObject *self, PyObject *args) } void -python_command_callback(PluginCommand *command, gchar **args) +python_command_callback(PluginCommand* command, gchar** args) { disable_python_threads(); - PyObject *p_args = NULL; + PyObject* p_args = NULL; int num_args = g_strv_length(args); if (num_args == 0) { if (command->max_args == 1) { @@ -1449,7 +1448,7 @@ python_command_callback(PluginCommand *command, gchar **args) } void -python_timed_callback(PluginTimedFunction *timed_function) +python_timed_callback(PluginTimedFunction* timed_function) { disable_python_threads(); PyObject_CallObject(timed_function->callback, NULL); @@ -1457,10 +1456,10 @@ python_timed_callback(PluginTimedFunction *timed_function) } void -python_window_callback(PluginWindowCallback *window_callback, char *tag, char *line) +python_window_callback(PluginWindowCallback* window_callback, char* tag, char* line) { disable_python_threads(); - PyObject *p_args = NULL; + PyObject* p_args = NULL; p_args = Py_BuildValue("ss", tag, line); PyObject_CallObject(window_callback->callback, p_args); Py_XDECREF(p_args); @@ -1532,8 +1531,7 @@ static PyMethodDef apiMethods[] = { }; #if PY_MAJOR_VERSION >= 3 -static struct PyModuleDef profModule = -{ +static struct PyModuleDef profModule = { PyModuleDef_HEAD_INIT, "prof", "", @@ -1546,7 +1544,7 @@ PyMODINIT_FUNC python_api_init(void) { #if PY_MAJOR_VERSION >= 3 - PyObject *result = PyModule_Create(&profModule); + PyObject* result = PyModule_Create(&profModule); if (!result) { log_debug("Failed to initialise prof module"); } else { @@ -1575,32 +1573,32 @@ python_init_prof(void) static char* _python_plugin_name(void) { - PyThreadState *ts = PyThreadState_Get(); - PyFrameObject *frame = ts->frame; + PyThreadState* ts = PyThreadState_Get(); + PyFrameObject* frame = ts->frame; char* filename = python_str_or_unicode_to_string(frame->f_code->co_filename); - gchar **split = g_strsplit(filename, "/", 0); + gchar** split = g_strsplit(filename, "/", 0); free(filename); - char *plugin_name = strdup(split[g_strv_length(split)-1]); + char* plugin_name = strdup(split[g_strv_length(split) - 1]); g_strfreev(split); return plugin_name; } char* -python_str_or_unicode_to_string(void *obj) +python_str_or_unicode_to_string(void* obj) { if (!obj) { return NULL; } - PyObject *pyobj = (PyObject*)obj; + PyObject* pyobj = (PyObject*)obj; if (pyobj == Py_None) { return NULL; } #if PY_MAJOR_VERSION >= 3 if (PyUnicode_Check(pyobj)) { - PyObject *utf8_str = PyUnicode_AsUTF8String(pyobj); - char *result = strdup(PyBytes_AS_STRING(utf8_str)); + PyObject* utf8_str = PyUnicode_AsUTF8String(pyobj); + char* result = strdup(PyBytes_AS_STRING(utf8_str)); Py_XDECREF(utf8_str); return result; } else { @@ -1608,8 +1606,8 @@ python_str_or_unicode_to_string(void *obj) } #else if (PyUnicode_Check(pyobj)) { - PyObject *utf8_str = PyUnicode_AsUTF8String(pyobj); - char *result = strdup(PyString_AsString(utf8_str)); + PyObject* utf8_str = PyUnicode_AsUTF8String(pyobj); + char* result = strdup(PyString_AsString(utf8_str)); Py_XDECREF(utf8_str); return result; } else { diff --git a/src/plugins/python_api.h b/src/plugins/python_api.h index 67ffb45a..c4a38c15 100644 --- a/src/plugins/python_api.h +++ b/src/plugins/python_api.h @@ -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 diff --git a/src/plugins/python_plugins.c b/src/plugins/python_plugins.c index aaee0a14..94c77e99 100644 --- a/src/plugins/python_plugins.c +++ b/src/plugins/python_plugins.c @@ -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(); diff --git a/src/plugins/python_plugins.h b/src/plugins/python_plugins.h index 139c4157..67a67341 100644 --- a/src/plugins/python_plugins.h +++ b/src/plugins/python_plugins.h @@ -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 diff --git a/src/plugins/settings.c b/src/plugins/settings.c index 386c80a0..75ca2feb 100644 --- a/src/plugins/settings.c +++ b/src/plugins/settings.c @@ -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); diff --git a/src/plugins/settings.h b/src/plugins/settings.h index 8ddb0856..e05e543a 100644 --- a/src/plugins/settings.h +++ b/src/plugins/settings.h @@ -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 diff --git a/src/plugins/themes.c b/src/plugins/themes.c index 31131017..f75e41c7 100644 --- a/src/plugins/themes.c +++ b/src/plugins/themes.c @@ -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; - - 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; + 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 + 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; - - else return THEME_TEXT; + 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; } } diff --git a/src/plugins/themes.h b/src/plugins/themes.h index a87d042e..9e23329f 100644 --- a/src/plugins/themes.h +++ b/src/plugins/themes.h @@ -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 diff --git a/src/profanity.c b/src/profanity.c index 45cef2d0..7b3da306 100644 --- a/src/profanity.c +++ b/src/profanity.c @@ -86,16 +86,16 @@ #include "omemo/omemo.h" #endif -static void _init(char *log_level, char *config_file, char *log_file, char *theme_name); +static void _init(char* log_level, char* config_file, char* log_file, char* theme_name); static void _shutdown(void); -static void _connect_default(const char * const account); +static void _connect_default(const char* const account); pthread_mutex_t lock; static gboolean cont = TRUE; static gboolean force_quit = FALSE; void -prof_run(char *log_level, char *account_name, char *config_file, char *log_file, char *theme_name) +prof_run(char* log_level, char* account_name, char* config_file, char* log_file, char* theme_name) { _init(log_level, config_file, log_file, theme_name); plugins_on_start(); @@ -107,14 +107,14 @@ prof_run(char *log_level, char *account_name, char *config_file, char *log_file, session_init_activity(); - char *line = NULL; - while(cont && !force_quit) { + char* line = NULL; + while (cont && !force_quit) { log_stderr_handler(); session_check_autoaway(); line = inp_readline(); if (line) { - ProfWin *window = wins_get_current(); + ProfWin* window = wins_get_current(); cont = cmd_process_input(window, line); free(line); line = NULL; @@ -143,13 +143,13 @@ prof_set_quit(void) } static void -_connect_default(const char *const account) +_connect_default(const char* const account) { - ProfWin *window = wins_get_current(); + ProfWin* window = wins_get_current(); if (account) { cmd_execute_connect(window, account); } else { - char *pref_connect_account = prefs_get_string(PREF_CONNECT_ACCOUNT); + char* pref_connect_account = prefs_get_string(PREF_CONNECT_ACCOUNT); if (pref_connect_account) { cmd_execute_connect(window, pref_connect_account); g_free(pref_connect_account); @@ -158,7 +158,7 @@ _connect_default(const char *const account) } static void -_init(char *log_level, char *config_file, char *log_file, char *theme_name) +_init(char* log_level, char* config_file, char* log_file, char* theme_name) { setlocale(LC_ALL, ""); // ignore SIGPIPE @@ -180,9 +180,9 @@ _init(char *log_level, char *config_file, char *log_file, char *theme_name) if (strcmp(PACKAGE_STATUS, "development") == 0) { #ifdef HAVE_GIT_VERSION - log_info("Starting Profanity (%sdev.%s.%s)...", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION); + log_info("Starting Profanity (%sdev.%s.%s)...", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION); #else - log_info("Starting Profanity (%sdev)...", PACKAGE_VERSION); + log_info("Starting Profanity (%sdev)...", PACKAGE_VERSION); #endif } else { log_info("Starting Profanity (%s)...", PACKAGE_VERSION); @@ -195,7 +195,7 @@ _init(char *log_level, char *config_file, char *log_file, char *theme_name) if (theme_name) { theme_init(theme_name); } else { - char *theme = prefs_get_string(PREF_THEME); + char* theme = prefs_get_string(PREF_THEME); theme_init(theme); g_free(theme); } diff --git a/src/profanity.h b/src/profanity.h index bc4d45f5..87be90b8 100644 --- a/src/profanity.h +++ b/src/profanity.h @@ -40,7 +40,7 @@ #include <pthread.h> #include <glib.h> -void prof_run(char *log_level, char *account_name, char *config_file, char *log_file, char *theme_name); +void prof_run(char* log_level, char* account_name, char* config_file, char* log_file, char* theme_name); void prof_set_quit(void); extern pthread_mutex_t lock; diff --git a/src/tools/autocomplete.c b/src/tools/autocomplete.c index 2f8cde3e..a3763bfb 100644 --- a/src/tools/autocomplete.c +++ b/src/tools/autocomplete.c @@ -43,14 +43,15 @@ #include "tools/parser.h" #include "ui/ui.h" -struct autocomplete_t { - GList *items; - GList *last_found; - gchar *search_str; +struct autocomplete_t +{ + GList* items; + GList* last_found; + gchar* search_str; }; -static gchar* _search_next(Autocomplete ac, GList *curr, gboolean quote); -static gchar* _search_prev(Autocomplete ac, GList *curr, gboolean quote); +static gchar* _search_next(Autocomplete ac, GList* curr, gboolean quote); +static gchar* _search_prev(Autocomplete ac, GList* curr, gboolean quote); Autocomplete autocomplete_new(void) @@ -105,10 +106,10 @@ autocomplete_length(Autocomplete ac) } void -autocomplete_update(Autocomplete ac, char **items) +autocomplete_update(Autocomplete ac, char** items) { - gchar *last_found = NULL; - gchar *search_str = NULL; + gchar* last_found = NULL; + gchar* search_str = NULL; if (ac->last_found) { last_found = strdup(ac->last_found->data); @@ -134,11 +135,11 @@ autocomplete_update(Autocomplete ac, char **items) } void -autocomplete_add_reverse(Autocomplete ac, const char *item) +autocomplete_add_reverse(Autocomplete ac, const char* item) { if (ac) { - char *item_cpy; - GList *curr = g_list_find_custom(ac->items, item, (GCompareFunc)strcmp); + char* item_cpy; + GList* curr = g_list_find_custom(ac->items, item, (GCompareFunc)strcmp); // if item already exists if (curr) { @@ -151,11 +152,11 @@ autocomplete_add_reverse(Autocomplete ac, const char *item) } void -autocomplete_add(Autocomplete ac, const char *item) +autocomplete_add(Autocomplete ac, const char* item) { if (ac) { - char *item_cpy; - GList *curr = g_list_find_custom(ac->items, item, (GCompareFunc)strcmp); + char* item_cpy; + GList* curr = g_list_find_custom(ac->items, item, (GCompareFunc)strcmp); // if item already exists if (curr) { @@ -168,7 +169,7 @@ autocomplete_add(Autocomplete ac, const char *item) } void -autocomplete_add_all(Autocomplete ac, char **items) +autocomplete_add_all(Autocomplete ac, char** items) { int i = 0; for (i = 0; i < g_strv_length(items); i++) { @@ -177,10 +178,10 @@ autocomplete_add_all(Autocomplete ac, char **items) } void -autocomplete_remove(Autocomplete ac, const char *const item) +autocomplete_remove(Autocomplete ac, const char* const item) { if (ac) { - GList *curr = g_list_find_custom(ac->items, item, (GCompareFunc)strcmp); + GList* curr = g_list_find_custom(ac->items, item, (GCompareFunc)strcmp); if (!curr) { return; @@ -199,7 +200,7 @@ autocomplete_remove(Autocomplete ac, const char *const item) } void -autocomplete_remove_all(Autocomplete ac, char **items) +autocomplete_remove_all(Autocomplete ac, char** items) { int i = 0; for (i = 0; i < g_strv_length(items); i++) { @@ -210,10 +211,10 @@ autocomplete_remove_all(Autocomplete ac, char **items) GList* autocomplete_create_list(Autocomplete ac) { - GList *copy = NULL; - GList *curr = ac->items; + GList* copy = NULL; + GList* curr = ac->items; - while(curr) { + while (curr) { copy = g_list_append(copy, strdup(curr->data)); curr = g_list_next(curr); } @@ -222,11 +223,11 @@ autocomplete_create_list(Autocomplete ac) } gboolean -autocomplete_contains(Autocomplete ac, const char *value) +autocomplete_contains(Autocomplete ac, const char* value) { - GList *curr = ac->items; + GList* curr = ac->items; - while(curr) { + while (curr) { if (strcmp(curr->data, value) == 0) { return TRUE; } @@ -237,9 +238,9 @@ autocomplete_contains(Autocomplete ac, const char *value) } gchar* -autocomplete_complete(Autocomplete ac, const gchar *search_str, gboolean quote, gboolean previous) +autocomplete_complete(Autocomplete ac, const gchar* search_str, gboolean quote, gboolean previous) { - gchar *found = NULL; + gchar* found = NULL; // no autocomplete to search if (!ac) { @@ -262,7 +263,7 @@ autocomplete_complete(Autocomplete ac, const gchar *search_str, gboolean quote, return found; - // subsequent search attempt + // subsequent search attempt } else { if (previous) { // search from here-1 to beginning @@ -300,10 +301,10 @@ autocomplete_complete(Autocomplete ac, const gchar *search_str, gboolean quote, } char* -autocomplete_param_with_func(const char *const input, char *command, autocomplete_func func, gboolean previous, void *context) +autocomplete_param_with_func(const char* const input, char* command, autocomplete_func func, gboolean previous, void* context) { - GString *auto_msg = NULL; - char *result = NULL; + GString* auto_msg = NULL; + char* result = NULL; char command_cpy[strlen(command) + 2]; sprintf(command_cpy, "%s ", command); int len = strlen(command_cpy); @@ -312,12 +313,12 @@ autocomplete_param_with_func(const char *const input, char *command, autocomplet int i; int inp_len = strlen(input); char prefix[inp_len]; - for(i = len; i < inp_len; i++) { - prefix[i-len] = input[i]; + for (i = len; i < inp_len; i++) { + prefix[i - len] = input[i]; } prefix[inp_len - len] = '\0'; - char *found = func(prefix, previous, context); + char* found = func(prefix, previous, context); if (found) { auto_msg = g_string_new(command_cpy); g_string_append(auto_msg, found); @@ -331,23 +332,23 @@ autocomplete_param_with_func(const char *const input, char *command, autocomplet } char* -autocomplete_param_with_ac(const char *const input, char *command, Autocomplete ac, gboolean quote, gboolean previous) +autocomplete_param_with_ac(const char* const input, char* command, Autocomplete ac, gboolean quote, gboolean previous) { - GString *auto_msg = NULL; - char *result = NULL; - char *command_cpy = malloc(strlen(command) + 2); + GString* auto_msg = NULL; + char* result = NULL; + char* command_cpy = malloc(strlen(command) + 2); sprintf(command_cpy, "%s ", command); int len = strlen(command_cpy); int inp_len = strlen(input); if (strncmp(input, command_cpy, len) == 0) { int i; char prefix[inp_len]; - for(i = len; i < inp_len; i++) { - prefix[i-len] = input[i]; + for (i = len; i < inp_len; i++) { + prefix[i - len] = input[i]; } prefix[inp_len - len] = '\0'; - char *found = autocomplete_complete(ac, prefix, quote, previous); + char* found = autocomplete_complete(ac, prefix, quote, previous); if (found) { auto_msg = g_string_new(command_cpy); g_string_append(auto_msg, found); @@ -362,22 +363,22 @@ autocomplete_param_with_ac(const char *const input, char *command, Autocomplete } char* -autocomplete_param_no_with_func(const char *const input, char *command, int arg_number, autocomplete_func func, gboolean previous, void *context) +autocomplete_param_no_with_func(const char* const input, char* command, int arg_number, autocomplete_func func, gboolean previous, void* context) { if (strncmp(input, command, strlen(command)) == 0) { - GString *result_str = NULL; + GString* result_str = NULL; // count tokens properly int num_tokens = count_tokens(input); // if correct number of tokens, then candidate for autocompletion of last param if (num_tokens == arg_number) { - gchar *start_str = get_start(input, arg_number); - gchar *comp_str = g_strdup(&input[strlen(start_str)]); + gchar* start_str = get_start(input, arg_number); + gchar* comp_str = g_strdup(&input[strlen(start_str)]); // autocomplete param if (comp_str) { - char *found = func(comp_str, previous, context); + char* found = func(comp_str, previous, context); if (found) { result_str = g_string_new(""); g_string_append(result_str, start_str); @@ -386,7 +387,7 @@ autocomplete_param_no_with_func(const char *const input, char *command, int arg_ free(start_str); free(comp_str); - char *result = result_str->str; + char* result = result_str->str; g_string_free(result_str, FALSE); return result; @@ -405,7 +406,7 @@ void autocomplete_remove_older_than_max_reverse(Autocomplete ac, int maxsize) { if (autocomplete_length(ac) > maxsize) { - GList *last = g_list_last(ac->items); + GList* last = g_list_last(ac->items); if (last) { free(last->data); ac->items = g_list_delete_link(ac->items, last); @@ -414,15 +415,15 @@ autocomplete_remove_older_than_max_reverse(Autocomplete ac, int maxsize) } static gchar* -_search_next(Autocomplete ac, GList *curr, gboolean quote) +_search_next(Autocomplete ac, GList* curr, gboolean quote) { - gchar *search_str_ascii = g_str_to_ascii(ac->search_str, NULL); - gchar *search_str_lower = g_ascii_strdown(search_str_ascii, -1); + gchar* search_str_ascii = g_str_to_ascii(ac->search_str, NULL); + gchar* search_str_lower = g_ascii_strdown(search_str_ascii, -1); g_free(search_str_ascii); - while(curr) { - gchar *curr_ascii = g_str_to_ascii(curr->data, NULL); - gchar *curr_lower = g_ascii_strdown(curr_ascii, -1); + while (curr) { + gchar* curr_ascii = g_str_to_ascii(curr->data, NULL); + gchar* curr_lower = g_ascii_strdown(curr_ascii, -1); g_free(curr_ascii); // match found @@ -433,18 +434,18 @@ _search_next(Autocomplete ac, GList *curr, gboolean quote) // if contains space, quote before returning if (quote && g_strrstr(curr->data, " ")) { - GString *quoted = g_string_new("\""); + GString* quoted = g_string_new("\""); g_string_append(quoted, curr->data); g_string_append(quoted, "\""); - gchar *result = quoted->str; + gchar* result = quoted->str; g_string_free(quoted, FALSE); g_free(search_str_lower); g_free(curr_lower); return result; - // otherwise just return the string + // otherwise just return the string } else { g_free(search_str_lower); g_free(curr_lower); @@ -461,15 +462,15 @@ _search_next(Autocomplete ac, GList *curr, gboolean quote) } static gchar* -_search_prev(Autocomplete ac, GList *curr, gboolean quote) +_search_prev(Autocomplete ac, GList* curr, gboolean quote) { - gchar *search_str_ascii = g_str_to_ascii(ac->search_str, NULL); - gchar *search_str_lower = g_ascii_strdown(search_str_ascii, -1); + gchar* search_str_ascii = g_str_to_ascii(ac->search_str, NULL); + gchar* search_str_lower = g_ascii_strdown(search_str_ascii, -1); g_free(search_str_ascii); - while(curr) { - gchar *curr_ascii = g_str_to_ascii(curr->data, NULL); - gchar *curr_lower = g_ascii_strdown(curr_ascii, -1); + while (curr) { + gchar* curr_ascii = g_str_to_ascii(curr->data, NULL); + gchar* curr_lower = g_ascii_strdown(curr_ascii, -1); g_free(curr_ascii); // match found @@ -480,18 +481,18 @@ _search_prev(Autocomplete ac, GList *curr, gboolean quote) // if contains space, quote before returning if (quote && g_strrstr(curr->data, " ")) { - GString *quoted = g_string_new("\""); + GString* quoted = g_string_new("\""); g_string_append(quoted, curr->data); g_string_append(quoted, "\""); - gchar *result = quoted->str; + gchar* result = quoted->str; g_string_free(quoted, FALSE); g_free(search_str_lower); g_free(curr_lower); return result; - // otherwise just return the string + // otherwise just return the string } else { g_free(search_str_lower); g_free(curr_lower); diff --git a/src/tools/autocomplete.h b/src/tools/autocomplete.h index 6f4fe9c7..697a551f 100644 --- a/src/tools/autocomplete.h +++ b/src/tools/autocomplete.h @@ -38,8 +38,8 @@ #include <glib.h> -typedef char* (*autocomplete_func)(const char *const, gboolean, void *); -typedef struct autocomplete_t *Autocomplete; +typedef char* (*autocomplete_func)(const char* const, gboolean, void*); +typedef struct autocomplete_t* Autocomplete; // allocate new autocompleter with no items Autocomplete autocomplete_new(void); @@ -50,31 +50,31 @@ void autocomplete_clear(Autocomplete ac); // free all memory used by the autocompleter void autocomplete_free(Autocomplete ac); -void autocomplete_add(Autocomplete ac, const char *item); -void autocomplete_add_all(Autocomplete ac, char **items); -void autocomplete_update(Autocomplete ac, char **items); -void autocomplete_remove(Autocomplete ac, const char *const item); -void autocomplete_remove_all(Autocomplete ac, char **items); -void autocomplete_add_reverse(Autocomplete ac, const char *item); +void autocomplete_add(Autocomplete ac, const char* item); +void autocomplete_add_all(Autocomplete ac, char** items); +void autocomplete_update(Autocomplete ac, char** items); +void autocomplete_remove(Autocomplete ac, const char* const item); +void autocomplete_remove_all(Autocomplete ac, char** items); +void autocomplete_add_reverse(Autocomplete ac, const char* item); // find the next item prefixed with search string -gchar* autocomplete_complete(Autocomplete ac, const gchar *search_str, gboolean quote, gboolean previous); +gchar* autocomplete_complete(Autocomplete ac, const gchar* search_str, gboolean quote, gboolean previous); GList* autocomplete_create_list(Autocomplete ac); gint autocomplete_length(Autocomplete ac); -char* autocomplete_param_with_func(const char *const input, char *command, - autocomplete_func func, gboolean previous, void *context); +char* autocomplete_param_with_func(const char* const input, char* command, + autocomplete_func func, gboolean previous, void* context); -char* autocomplete_param_with_ac(const char *const input, char *command, - Autocomplete ac, gboolean quote, gboolean previous); +char* autocomplete_param_with_ac(const char* const input, char* command, + Autocomplete ac, gboolean quote, gboolean previous); -char* autocomplete_param_no_with_func(const char *const input, char *command, - int arg_number, autocomplete_func func, gboolean previous, void *context); +char* autocomplete_param_no_with_func(const char* const input, char* command, + int arg_number, autocomplete_func func, gboolean previous, void* context); void autocomplete_reset(Autocomplete ac); -gboolean autocomplete_contains(Autocomplete ac, const char *value); +gboolean autocomplete_contains(Autocomplete ac, const char* value); void autocomplete_remove_older_than_max_reverse(Autocomplete ac, int maxsize); #endif diff --git a/src/tools/bookmark_ignore.c b/src/tools/bookmark_ignore.c index 09053e5b..4f251c05 100644 --- a/src/tools/bookmark_ignore.c +++ b/src/tools/bookmark_ignore.c @@ -44,13 +44,13 @@ #include "log.h" -static GKeyFile *bookmark_ignore_keyfile = NULL; -static char *account_jid = NULL; +static GKeyFile* bookmark_ignore_keyfile = NULL; +static char* account_jid = NULL; static void _bookmark_ignore_load() { - char *bi_loc; + char* bi_loc; bi_loc = files_get_data_path(FILE_BOOKMARK_AUTOJOIN_IGNORE); @@ -68,9 +68,9 @@ static void _bookmark_save() { gsize g_data_size; - gchar *g_bookmark_ignore_data = g_key_file_to_data(bookmark_ignore_keyfile, &g_data_size, NULL); + gchar* g_bookmark_ignore_data = g_key_file_to_data(bookmark_ignore_keyfile, &g_data_size, NULL); - char *bi_loc; + char* bi_loc; bi_loc = files_get_data_path(FILE_BOOKMARK_AUTOJOIN_IGNORE); g_file_set_contents(bi_loc, g_bookmark_ignore_data, g_data_size, NULL); @@ -81,9 +81,9 @@ _bookmark_save() } void -bookmark_ignore_on_connect(const char *const barejid) +bookmark_ignore_on_connect(const char* const barejid) { - if(bookmark_ignore_keyfile == NULL) { + if (bookmark_ignore_keyfile == NULL) { _bookmark_ignore_load(); account_jid = strdup(barejid); } @@ -98,26 +98,26 @@ bookmark_ignore_on_disconnect() } gboolean -bookmark_ignored(Bookmark *bookmark) +bookmark_ignored(Bookmark* bookmark) { return g_key_file_get_boolean(bookmark_ignore_keyfile, account_jid, bookmark->barejid, NULL); } -gchar ** -bookmark_ignore_list(gsize *len) +gchar** +bookmark_ignore_list(gsize* len) { return g_key_file_get_keys(bookmark_ignore_keyfile, account_jid, len, NULL); } void -bookmark_ignore_add(const char *const barejid) +bookmark_ignore_add(const char* const barejid) { g_key_file_set_boolean(bookmark_ignore_keyfile, account_jid, barejid, TRUE); _bookmark_save(); } void -bookmark_ignore_remove(const char *const barejid) +bookmark_ignore_remove(const char* const barejid) { g_key_file_remove_key(bookmark_ignore_keyfile, account_jid, barejid, NULL); _bookmark_save(); diff --git a/src/tools/bookmark_ignore.h b/src/tools/bookmark_ignore.h index 9b0fda36..a618ea6b 100644 --- a/src/tools/bookmark_ignore.h +++ b/src/tools/bookmark_ignore.h @@ -38,9 +38,9 @@ void bookmark_ignore_on_connect(); void bookmark_ignore_on_disconnect(); -gboolean bookmark_ignored(Bookmark *bookmark); -gchar ** bookmark_ignore_list(gsize *len); -void bookmark_ignore_add(const char *const barejid); -void bookmark_ignore_remove(const char *const barejid); +gboolean bookmark_ignored(Bookmark* bookmark); +gchar** bookmark_ignore_list(gsize* len); +void bookmark_ignore_add(const char* const barejid); +void bookmark_ignore_remove(const char* const barejid); #endif diff --git a/src/tools/clipboard.c b/src/tools/clipboard.c index 9454915c..95b76465 100644 --- a/src/tools/clipboard.c +++ b/src/tools/clipboard.c @@ -50,13 +50,15 @@ void clipboard_init(int argc, char **argv) { } */ -char *clipboard_get(void) { - gchar *clip; +char* +clipboard_get(void) +{ + gchar* clip; - GtkClipboard *cl = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); + GtkClipboard* cl = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); gtk_clipboard_clear(cl); - if(cl==NULL) { + if (cl == NULL) { log_error("Could not get clipboard"); return NULL; } diff --git a/src/tools/clipboard.h b/src/tools/clipboard.h index d6cfee9a..addb60e0 100644 --- a/src/tools/clipboard.h +++ b/src/tools/clipboard.h @@ -37,7 +37,7 @@ #define UI_CLIPBOARD_H #ifdef HAVE_GTK -char *clipboard_get(void); +char* clipboard_get(void); #endif #endif diff --git a/src/tools/http_upload.c b/src/tools/http_upload.c index f52706e5..312fad46 100644 --- a/src/tools/http_upload.c +++ b/src/tools/http_upload.c @@ -55,22 +55,23 @@ #include "ui/window.h" #include "common.h" -#define FALLBACK_MIMETYPE "application/octet-stream" +#define FALLBACK_MIMETYPE "application/octet-stream" #define FALLBACK_CONTENTTYPE_HEADER "Content-Type: application/octet-stream" -#define FALLBACK_MSG "" -#define FILE_HEADER_BYTES 512 +#define FALLBACK_MSG "" +#define FILE_HEADER_BYTES 512 -struct curl_data_t { - char *buffer; +struct curl_data_t +{ + char* buffer; size_t size; }; -GSList *upload_processes = NULL; +GSList* upload_processes = NULL; static int -_xferinfo(void *userdata, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) +_xferinfo(void* userdata, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) { - HTTPUpload *upload = (HTTPUpload *)userdata; + HTTPUpload* upload = (HTTPUpload*)userdata; pthread_mutex_lock(&lock); @@ -91,7 +92,7 @@ _xferinfo(void *userdata, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultot ulperc = (100 * ulnow) / ultotal; } - char *msg; + char* msg; if (asprintf(&msg, "Uploading '%s': %d%%", upload->filename, ulperc) == -1) { msg = strdup(FALLBACK_MSG); } @@ -105,40 +106,39 @@ _xferinfo(void *userdata, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultot #if LIBCURL_VERSION_NUM < 0x072000 static int -_older_progress(void *p, double dltotal, double dlnow, double ultotal, double ulnow) +_older_progress(void* p, double dltotal, double dlnow, double ultotal, double ulnow) { return _xferinfo(p, (curl_off_t)dltotal, (curl_off_t)dlnow, (curl_off_t)ultotal, (curl_off_t)ulnow); } #endif static size_t -_data_callback(void *ptr, size_t size, size_t nmemb, void *data) +_data_callback(void* ptr, size_t size, size_t nmemb, void* data) { size_t realsize = size * nmemb; - struct curl_data_t *mem = (struct curl_data_t *) data; + struct curl_data_t* mem = (struct curl_data_t*)data; mem->buffer = realloc(mem->buffer, mem->size + realsize + 1); - if (mem->buffer) - { - memcpy( &( mem->buffer[ mem->size ] ), ptr, realsize ); + if (mem->buffer) { + memcpy(&(mem->buffer[mem->size]), ptr, realsize); mem->size += realsize; - mem->buffer[ mem->size ] = 0; + mem->buffer[mem->size] = 0; } return realsize; } -void * -http_file_put(void *userdata) +void* +http_file_put(void* userdata) { - HTTPUpload *upload = (HTTPUpload *)userdata; + HTTPUpload* upload = (HTTPUpload*)userdata; - FILE *fd = NULL; + FILE* fd = NULL; - char *err = NULL; - char *content_type_header; + char* err = NULL; + char* content_type_header; - CURL *curl; + CURL* curl; CURLcode res; upload->cancel = 0; @@ -152,7 +152,7 @@ http_file_put(void *userdata) win_print_http_upload(upload->window, msg, upload->put_url); free(msg); - char *cert_path = prefs_get_string(PREF_TLS_CERTPATH); + char* cert_path = prefs_get_string(PREF_TLS_CERTPATH); pthread_mutex_unlock(&lock); curl_global_init(CURL_GLOBAL_ALL); @@ -161,7 +161,7 @@ http_file_put(void *userdata) curl_easy_setopt(curl, CURLOPT_URL, upload->put_url); curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PUT"); - struct curl_slist *headers = NULL; + struct curl_slist* headers = NULL; if (asprintf(&content_type_header, "Content-Type: %s", upload->mime_type) == -1) { content_type_header = strdup(FALLBACK_CONTENTTYPE_HEADER); } @@ -169,20 +169,20 @@ http_file_put(void *userdata) headers = curl_slist_append(headers, "Expect:"); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); - #if LIBCURL_VERSION_NUM >= 0x072000 +#if LIBCURL_VERSION_NUM >= 0x072000 curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, _xferinfo); curl_easy_setopt(curl, CURLOPT_XFERINFODATA, upload); - #else +#else curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, _older_progress); curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, upload); - #endif +#endif curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L); struct curl_data_t output; output.buffer = NULL; output.size = 0; curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, _data_callback); - curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&output); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&output); curl_easy_setopt(curl, CURLOPT_USERAGENT, "profanity"); @@ -218,11 +218,11 @@ http_file_put(void *userdata) } } - #if 0 +#if 0 printf("HTTP Status: %lu\n", http_code); printf("%s\n", output.buffer); printf("%lu bytes retrieved\n", (long)output.size); - #endif +#endif } end: @@ -239,7 +239,7 @@ end: g_free(cert_path); if (err) { - char *msg; + char* msg; if (upload->cancel) { if (asprintf(&msg, "Uploading '%s' failed: Upload was canceled", upload->filename) == -1) { msg = strdup(FALLBACK_MSG); @@ -265,21 +265,21 @@ end: switch (upload->window->type) { case WIN_CHAT: { - ProfChatWin *chatwin = (ProfChatWin*)(upload->window); + ProfChatWin* chatwin = (ProfChatWin*)(upload->window); assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); cl_ev_send_msg(chatwin, upload->get_url, upload->get_url); break; } case WIN_PRIVATE: { - ProfPrivateWin *privatewin = (ProfPrivateWin*)(upload->window); + ProfPrivateWin* privatewin = (ProfPrivateWin*)(upload->window); assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK); cl_ev_send_priv_msg(privatewin, upload->get_url, upload->get_url); break; } case WIN_MUC: { - ProfMucWin *mucwin = (ProfMucWin*)(upload->window); + ProfMucWin* mucwin = (ProfMucWin*)(upload->window); assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); cl_ev_send_muc_msg(mucwin, upload->get_url, upload->get_url); break; @@ -305,29 +305,29 @@ end: char* file_mime_type(const char* const file_name) { - char *out_mime_type; + char* out_mime_type; char file_header[FILE_HEADER_BYTES]; - FILE *fd; + FILE* fd; if (!(fd = fopen(file_name, "rb"))) { return strdup(FALLBACK_MIMETYPE); } size_t file_header_size = fread(file_header, 1, FILE_HEADER_BYTES, fd); fclose(fd); - char *content_type = g_content_type_guess(file_name, (unsigned char*)file_header, file_header_size, NULL); + char* content_type = g_content_type_guess(file_name, (unsigned char*)file_header, file_header_size, NULL); if (content_type != NULL) { - char *mime_type = g_content_type_get_mime_type(content_type); + char* mime_type = g_content_type_get_mime_type(content_type); out_mime_type = strdup(mime_type); g_free(mime_type); - } - else { + } else { return strdup(FALLBACK_MIMETYPE); } g_free(content_type); return out_mime_type; } -off_t file_size(const char* const filename) +off_t +file_size(const char* const filename) { struct stat st; stat(filename, &st); @@ -335,11 +335,11 @@ off_t file_size(const char* const filename) } void -http_upload_cancel_processes(ProfWin *window) +http_upload_cancel_processes(ProfWin* window) { - GSList *upload_process = upload_processes; + GSList* upload_process = upload_processes; while (upload_process) { - HTTPUpload *upload = upload_process->data; + HTTPUpload* upload = upload_process->data; if (upload->window == window) { upload->cancel = 1; break; @@ -349,7 +349,7 @@ http_upload_cancel_processes(ProfWin *window) } void -http_upload_add_upload(HTTPUpload *upload) +http_upload_add_upload(HTTPUpload* upload) { upload_processes = g_slist_append(upload_processes, upload); } diff --git a/src/tools/http_upload.h b/src/tools/http_upload.h index 60b1ea82..3838a5e8 100644 --- a/src/tools/http_upload.h +++ b/src/tools/http_upload.h @@ -45,24 +45,25 @@ #include "ui/win_types.h" -typedef struct http_upload_t { - char *filename; +typedef struct http_upload_t +{ + char* filename; off_t filesize; curl_off_t bytes_sent; - char *mime_type; - char *get_url; - char *put_url; - ProfWin *window; + char* mime_type; + char* get_url; + char* put_url; + ProfWin* window; pthread_t worker; int cancel; } HTTPUpload; -void* http_file_put(void *userdata); +void* http_file_put(void* userdata); char* file_mime_type(const char* const file_name); off_t file_size(const char* const file_name); -void http_upload_cancel_processes(ProfWin *window); -void http_upload_add_upload(HTTPUpload *upload); +void http_upload_cancel_processes(ProfWin* window); +void http_upload_add_upload(HTTPUpload* upload); #endif diff --git a/src/tools/parser.c b/src/tools/parser.c index fb21571c..2099a071 100644 --- a/src/tools/parser.c +++ b/src/tools/parser.c @@ -63,7 +63,7 @@ * */ gchar** -parse_args(const char *const inp, int min, int max, gboolean *result) +parse_args(const char* const inp, int min, int max, gboolean* result) { if (inp == NULL) { *result = FALSE; @@ -71,31 +71,31 @@ parse_args(const char *const inp, int min, int max, gboolean *result) } // copy and strip input of leading/trailing whitespace - char *copy = strdup(inp); + char* copy = strdup(inp); g_strstrip(copy); int inp_size = g_utf8_strlen(copy, -1); gboolean in_token = FALSE; gboolean in_quotes = FALSE; - char *token_start = ©[0]; + char* token_start = ©[0]; int token_size = 0; - GSList *tokens = NULL; + GSList* tokens = NULL; // add tokens to GSList int i; for (i = 0; i < inp_size; i++) { - gchar *curr_ch = g_utf8_offset_to_pointer(copy, i); + gchar* curr_ch = g_utf8_offset_to_pointer(copy, i); gunichar curr_uni = g_utf8_get_char(curr_ch); if (!in_token) { - if (curr_uni == ' ') { + if (curr_uni == ' ') { continue; } else { in_token = TRUE; if (curr_uni == '"') { in_quotes = TRUE; i++; - gchar *next_ch = g_utf8_next_char(curr_ch); + gchar* next_ch = g_utf8_next_char(curr_ch); gunichar next_uni = g_utf8_get_char(next_ch); token_start = next_ch; token_size += g_unichar_to_utf8(next_uni, NULL); @@ -108,7 +108,7 @@ parse_args(const char *const inp, int min, int max, gboolean *result) if (in_quotes) { if (curr_uni == '"') { tokens = g_slist_append(tokens, g_strndup(token_start, - token_size)); + token_size)); token_size = 0; in_token = FALSE; in_quotes = FALSE; @@ -118,7 +118,7 @@ parse_args(const char *const inp, int min, int max, gboolean *result) } else { if (curr_uni == ' ') { tokens = g_slist_append(tokens, g_strndup(token_start, - token_size)); + token_size)); token_size = 0; in_token = FALSE; } else { @@ -141,19 +141,19 @@ parse_args(const char *const inp, int min, int max, gboolean *result) *result = FALSE; return NULL; - // if min allowed is 0 and 0 found, return empty char* array + // if min allowed is 0 and 0 found, return empty char* array } else if (min == 0 && num == 0) { g_slist_free_full(tokens, free); - gchar **args = malloc((num + 1) * sizeof(*args)); + gchar** args = malloc((num + 1) * sizeof(*args)); args[0] = NULL; g_free(copy); *result = TRUE; return args; - // otherwise return args array + // otherwise return args array } else { - gchar **args = malloc((num + 1) * sizeof(*args)); - GSList *token = tokens; + gchar** args = malloc((num + 1) * sizeof(*args)); + GSList* token = tokens; token = g_slist_next(token); int arg_count = 0; @@ -197,7 +197,7 @@ parse_args(const char *const inp, int min, int max, gboolean *result) * */ gchar** -parse_args_with_freetext(const char *const inp, int min, int max, gboolean *result) +parse_args_with_freetext(const char* const inp, int min, int max, gboolean* result) { if (inp == NULL) { *result = FALSE; @@ -205,22 +205,22 @@ parse_args_with_freetext(const char *const inp, int min, int max, gboolean *resu } // copy and strip input of leading/trailing whitepsace - char *copy = strdup(inp); + char* copy = strdup(inp); g_strstrip(copy); int inp_size = g_utf8_strlen(copy, -1); gboolean in_token = FALSE; gboolean in_freetext = FALSE; gboolean in_quotes = FALSE; - char *token_start = ©[0]; + char* token_start = ©[0]; int token_size = 0; int num_tokens = 0; - GSList *tokens = NULL; + GSList* tokens = NULL; // add tokens to GSList int i; for (i = 0; i < inp_size; i++) { - gchar *curr_ch = g_utf8_offset_to_pointer(copy, i); + gchar* curr_ch = g_utf8_offset_to_pointer(copy, i); gunichar curr_uni = g_utf8_get_char(curr_ch); if (!in_token) { @@ -234,13 +234,13 @@ parse_args_with_freetext(const char *const inp, int min, int max, gboolean *resu } else if (curr_uni == '"') { in_quotes = TRUE; i++; - gchar *next_ch = g_utf8_next_char(curr_ch); + gchar* next_ch = g_utf8_next_char(curr_ch); gunichar next_uni = g_utf8_get_char(next_ch); token_start = next_ch; token_size += g_unichar_to_utf8(next_uni, NULL); } if (curr_uni == '"') { - gchar *next_ch = g_utf8_next_char(curr_ch); + gchar* next_ch = g_utf8_next_char(curr_ch); token_start = next_ch; } else { token_start = curr_ch; @@ -251,7 +251,7 @@ parse_args_with_freetext(const char *const inp, int min, int max, gboolean *resu if (in_quotes) { if (curr_uni == '"') { tokens = g_slist_append(tokens, g_strndup(token_start, - token_size)); + token_size)); token_size = 0; in_token = FALSE; in_quotes = FALSE; @@ -265,7 +265,7 @@ parse_args_with_freetext(const char *const inp, int min, int max, gboolean *resu token_size += g_unichar_to_utf8(curr_uni, NULL); } else if (curr_uni == ' ') { tokens = g_slist_append(tokens, g_strndup(token_start, - token_size)); + token_size)); token_size = 0; in_token = FALSE; } else if (curr_uni != '"') { @@ -289,18 +289,18 @@ parse_args_with_freetext(const char *const inp, int min, int max, gboolean *resu *result = FALSE; return NULL; - // if min allowed is 0 and 0 found, return empty char* array + // if min allowed is 0 and 0 found, return empty char* array } else if (min == 0 && num == 0) { g_slist_free_full(tokens, free); - gchar **args = malloc((num + 1) * sizeof(*args)); + gchar** args = malloc((num + 1) * sizeof(*args)); args[0] = NULL; *result = TRUE; return args; - // otherwise return args array + // otherwise return args array } else { - gchar **args = malloc((num + 1) * sizeof(*args)); - GSList *token = tokens; + gchar** args = malloc((num + 1) * sizeof(*args)); + GSList* token = tokens; token = g_slist_next(token); int arg_count = 0; @@ -317,7 +317,7 @@ parse_args_with_freetext(const char *const inp, int min, int max, gboolean *resu } int -count_tokens(const char *const string) +count_tokens(const char* const string) { int length = g_utf8_strlen(string, -1); gboolean in_quotes = FALSE; @@ -328,7 +328,7 @@ count_tokens(const char *const string) num_tokens++; for (i = 0; i < length; i++) { - gchar *curr_ch = g_utf8_offset_to_pointer(string, i); + gchar* curr_ch = g_utf8_offset_to_pointer(string, i); gunichar curr_uni = g_utf8_get_char(curr_ch); if (curr_uni == ' ') { @@ -348,12 +348,12 @@ count_tokens(const char *const string) } char* -get_start(const char *const string, int tokens) +get_start(const char* const string, int tokens) { - GString *result = g_string_new(""); + GString* result = g_string_new(""); int length = g_utf8_strlen(string, -1); gboolean in_quotes = FALSE; - char *result_str = NULL; + char* result_str = NULL; int num_tokens = 0; int i = 0; @@ -361,11 +361,11 @@ get_start(const char *const string, int tokens) num_tokens++; for (i = 0; i < length; i++) { - gchar *curr_ch = g_utf8_offset_to_pointer(string, i); + gchar* curr_ch = g_utf8_offset_to_pointer(string, i); gunichar curr_uni = g_utf8_get_char(curr_ch); if (num_tokens < tokens) { - gchar *uni_char = malloc(7); + gchar* uni_char = malloc(7); int len = g_unichar_to_utf8(curr_uni, uni_char); uni_char[len] = '\0'; g_string_append(result, uni_char); @@ -391,15 +391,15 @@ get_start(const char *const string, int tokens) } GHashTable* -parse_options(gchar **args, gchar **opt_keys, gboolean *res) +parse_options(gchar** args, gchar** opt_keys, gboolean* res) { - GList *keys = NULL; + GList* keys = NULL; int i; for (i = 0; i < g_strv_length(opt_keys); i++) { keys = g_list_append(keys, opt_keys[i]); } - GHashTable *options = NULL; + GHashTable* options = NULL; // no options found, success if (args[0] == NULL) { @@ -411,8 +411,8 @@ parse_options(gchar **args, gchar **opt_keys, gboolean *res) // validate options int curr; - GList *found_keys = NULL; - for (curr = 0; curr < g_strv_length(args); curr+= 2) { + GList* found_keys = NULL; + for (curr = 0; curr < g_strv_length(args); curr += 2) { // check if option valid if (g_list_find_custom(keys, args[curr], (GCompareFunc)g_strcmp0) == NULL) { *res = FALSE; @@ -430,7 +430,7 @@ parse_options(gchar **args, gchar **opt_keys, gboolean *res) } // check value given - if (args[curr+1] == NULL) { + if (args[curr + 1] == NULL) { *res = FALSE; g_list_free(found_keys); g_list_free(keys); @@ -445,15 +445,15 @@ parse_options(gchar **args, gchar **opt_keys, gboolean *res) // create map options = g_hash_table_new(g_str_hash, g_str_equal); *res = TRUE; - for (curr = 0; curr < g_strv_length(args); curr+=2) { - g_hash_table_insert(options, args[curr], args[curr+1]); + for (curr = 0; curr < g_strv_length(args); curr += 2) { + g_hash_table_insert(options, args[curr], args[curr + 1]); } return options; } void -options_destroy(GHashTable *options) +options_destroy(GHashTable* options) { if (options) { g_hash_table_destroy(options); diff --git a/src/tools/parser.h b/src/tools/parser.h index 4787b148..d1b6f7bf 100644 --- a/src/tools/parser.h +++ b/src/tools/parser.h @@ -38,11 +38,11 @@ #include <glib.h> -gchar** parse_args(const char *const inp, int min, int max, gboolean *result); -gchar** parse_args_with_freetext(const char *const inp, int min, int max, gboolean *result); -int count_tokens(const char *const string); -char* get_start(const char *const string, int tokens); -GHashTable* parse_options(gchar **args, gchar **keys, gboolean *res); -void options_destroy(GHashTable *options); +gchar** parse_args(const char* const inp, int min, int max, gboolean* result); +gchar** parse_args_with_freetext(const char* const inp, int min, int max, gboolean* result); +int count_tokens(const char* const string); +char* get_start(const char* const string, int tokens); +GHashTable* parse_options(gchar** args, gchar** keys, gboolean* res); +void options_destroy(GHashTable* options); #endif diff --git a/src/tools/tinyurl.c b/src/tools/tinyurl.c index 955ce030..41ff43ec 100644 --- a/src/tools/tinyurl.c +++ b/src/tools/tinyurl.c @@ -43,33 +43,32 @@ struct curl_data_t { - char *buffer; + char* buffer; size_t size; }; -static size_t _data_callback(void *ptr, size_t size, size_t nmemb, void *data); +static size_t _data_callback(void* ptr, size_t size, size_t nmemb, void* data); gboolean -tinyurl_valid(char *url) +tinyurl_valid(char* url) { - return (g_str_has_prefix(url, "http://") || - g_str_has_prefix(url, "https://")); + return (g_str_has_prefix(url, "http://") || g_str_has_prefix(url, "https://")); } char* -tinyurl_get(char *url) +tinyurl_get(char* url) { - GString *full_url = g_string_new("http://tinyurl.com/api-create.php?url="); + GString* full_url = g_string_new("http://tinyurl.com/api-create.php?url="); g_string_append(full_url, url); - CURL *handle = curl_easy_init(); + CURL* handle = curl_easy_init(); struct curl_data_t output; output.buffer = NULL; output.size = 0; curl_easy_setopt(handle, CURLOPT_URL, full_url->str); curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, _data_callback); - curl_easy_setopt(handle, CURLOPT_WRITEDATA, (void *)&output); + curl_easy_setopt(handle, CURLOPT_WRITEDATA, (void*)&output); curl_easy_perform(handle); curl_easy_cleanup(handle); @@ -85,17 +84,16 @@ tinyurl_get(char *url) } static size_t -_data_callback(void *ptr, size_t size, size_t nmemb, void *data) +_data_callback(void* ptr, size_t size, size_t nmemb, void* data) { size_t realsize = size * nmemb; - struct curl_data_t *mem = (struct curl_data_t *) data; + struct curl_data_t* mem = (struct curl_data_t*)data; mem->buffer = realloc(mem->buffer, mem->size + realsize + 1); - if ( mem->buffer ) - { - memcpy( &( mem->buffer[ mem->size ] ), ptr, realsize ); + if (mem->buffer) { + memcpy(&(mem->buffer[mem->size]), ptr, realsize); mem->size += realsize; - mem->buffer[ mem->size ] = 0; + mem->buffer[mem->size] = 0; } return realsize; diff --git a/src/tools/tinyurl.h b/src/tools/tinyurl.h index 14ac6e35..67222cd0 100644 --- a/src/tools/tinyurl.h +++ b/src/tools/tinyurl.h @@ -38,7 +38,7 @@ #include <glib.h> -gboolean tinyurl_valid(char *url); -char* tinyurl_get(char *url); +gboolean tinyurl_valid(char* url); +char* tinyurl_get(char* url); #endif diff --git a/src/ui/buffer.c b/src/ui/buffer.c index 54178632..f78168ac 100644 --- a/src/ui/buffer.c +++ b/src/ui/buffer.c @@ -53,11 +53,12 @@ #define BUFF_SIZE 1200 -struct prof_buff_t { - GSList *entries; +struct prof_buff_t +{ + GSList* entries; }; -static void _free_entry(ProfBuffEntry *entry); +static void _free_entry(ProfBuffEntry* entry); ProfBuff buffer_create(void) @@ -81,9 +82,9 @@ buffer_free(ProfBuff buffer) } void -buffer_append(ProfBuff buffer, const char *show_char, int pad_indent, GDateTime *time, int flags, theme_item_t theme_item, const char *const display_from, const char *const from_jid, const char *const message, DeliveryReceipt *receipt, const char *const id) +buffer_append(ProfBuff buffer, const char* show_char, int pad_indent, GDateTime* time, int flags, theme_item_t theme_item, const char* const display_from, const char* const from_jid, const char* const message, DeliveryReceipt* receipt, const char* const id) { - ProfBuffEntry *e = malloc(sizeof(struct prof_buff_entry_t)); + ProfBuffEntry* e = malloc(sizeof(struct prof_buff_entry_t)); e->show_char = strdup(show_char); e->pad_indent = pad_indent; e->flags = flags; @@ -108,11 +109,11 @@ buffer_append(ProfBuff buffer, const char *show_char, int pad_indent, GDateTime } void -buffer_remove_entry_by_id(ProfBuff buffer, const char *const id) +buffer_remove_entry_by_id(ProfBuff buffer, const char* const id) { - GSList *entries = buffer->entries; + GSList* entries = buffer->entries; while (entries) { - ProfBuffEntry *entry = entries->data; + ProfBuffEntry* entry = entries->data; if (entry->id && (g_strcmp0(entry->id, id) == 0)) { _free_entry(entry); buffer->entries = g_slist_delete_link(buffer->entries, entries); @@ -123,11 +124,11 @@ buffer_remove_entry_by_id(ProfBuff buffer, const char *const id) } gboolean -buffer_mark_received(ProfBuff buffer, const char *const id) +buffer_mark_received(ProfBuff buffer, const char* const id) { - GSList *entries = buffer->entries; + GSList* entries = buffer->entries; while (entries) { - ProfBuffEntry *entry = entries->data; + ProfBuffEntry* entry = entries->data; if (entry->receipt && g_strcmp0(entry->id, id) == 0) { if (!entry->receipt->received) { entry->receipt->received = TRUE; @@ -143,16 +144,16 @@ buffer_mark_received(ProfBuff buffer, const char *const id) ProfBuffEntry* buffer_get_entry(ProfBuff buffer, int entry) { - GSList *node = g_slist_nth(buffer->entries, entry); + GSList* node = g_slist_nth(buffer->entries, entry); return node->data; } ProfBuffEntry* -buffer_get_entry_by_id(ProfBuff buffer, const char *const id) +buffer_get_entry_by_id(ProfBuff buffer, const char* const id) { - GSList *entries = buffer->entries; + GSList* entries = buffer->entries; while (entries) { - ProfBuffEntry *entry = entries->data; + ProfBuffEntry* entry = entries->data; if (g_strcmp0(entry->id, id) == 0) { return entry; } @@ -163,7 +164,7 @@ buffer_get_entry_by_id(ProfBuff buffer, const char *const id) } static void -_free_entry(ProfBuffEntry *entry) +_free_entry(ProfBuffEntry* entry) { free(entry->show_char); free(entry->message); diff --git a/src/ui/buffer.h b/src/ui/buffer.h index 997e2a49..02e04d4a 100644 --- a/src/ui/buffer.h +++ b/src/ui/buffer.h @@ -42,36 +42,38 @@ #include "config.h" #include "config/theme.h" -typedef struct delivery_receipt_t { +typedef struct delivery_receipt_t +{ gboolean received; } DeliveryReceipt; -typedef struct prof_buff_entry_t { +typedef struct prof_buff_entry_t +{ // pointer because it could be a unicode symbol as well - char *show_char; + char* show_char; int pad_indent; - GDateTime *time; + GDateTime* time; int flags; theme_item_t theme_item; // from as it is displayed // might be nick, jid.. - char *display_from; - char *from_jid; - char *message; - DeliveryReceipt *receipt; + char* display_from; + char* from_jid; + char* message; + DeliveryReceipt* receipt; // message id, in case we have it - char *id; + char* id; } ProfBuffEntry; -typedef struct prof_buff_t *ProfBuff; +typedef struct prof_buff_t* ProfBuff; ProfBuff buffer_create(); void buffer_free(ProfBuff buffer); -void buffer_append(ProfBuff buffer, const char *show_char, int pad_indent, GDateTime *time, int flags, theme_item_t theme_item, const char *const display_from, const char *const barejid, const char *const message, DeliveryReceipt *receipt, const char *const id); -void buffer_remove_entry_by_id(ProfBuff buffer, const char *const id); +void buffer_append(ProfBuff buffer, const char* show_char, int pad_indent, GDateTime* time, int flags, theme_item_t theme_item, const char* const display_from, const char* const barejid, const char* const message, DeliveryReceipt* receipt, const char* const id); +void buffer_remove_entry_by_id(ProfBuff buffer, const char* const id); int buffer_size(ProfBuff buffer); ProfBuffEntry* buffer_get_entry(ProfBuff buffer, int entry); -ProfBuffEntry* buffer_get_entry_by_id(ProfBuff buffer, const char *const id); -gboolean buffer_mark_received(ProfBuff buffer, const char *const id); +ProfBuffEntry* buffer_get_entry_by_id(ProfBuff buffer, const char* const id); +gboolean buffer_mark_received(ProfBuff buffer, const char* const id); #endif diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c index 35ad803f..f204e821 100644 --- a/src/ui/chatwin.c +++ b/src/ui/chatwin.c @@ -57,14 +57,14 @@ #include "omemo/omemo.h" #endif -static void _chatwin_history(ProfChatWin *chatwin, const char *const contact_barejid); -static void _chatwin_set_last_message(ProfChatWin *chatwin, const char *const id, const char *const message); +static void _chatwin_history(ProfChatWin* chatwin, const char* const contact_barejid); +static void _chatwin_set_last_message(ProfChatWin* chatwin, const char* const id, const char* const message); ProfChatWin* -chatwin_new(const char *const barejid) +chatwin_new(const char* const barejid) { - ProfWin *window = wins_new_chat(barejid); - ProfChatWin *chatwin = (ProfChatWin *)window; + ProfWin* window = wins_new_chat(barejid); + ProfChatWin* chatwin = (ProfChatWin*)window; if (!prefs_get_boolean(PREF_MAM) && prefs_get_boolean(PREF_CHLOG) && prefs_get_boolean(PREF_HISTORY)) { _chatwin_history(chatwin, barejid); @@ -74,8 +74,8 @@ chatwin_new(const char *const barejid) PContact contact = roster_get_contact(barejid); if (contact) { if (strcmp(p_contact_presence(contact), "offline") == 0) { - const char * const show = p_contact_presence(contact); - const char * const status = p_contact_status(contact); + const char* const show = p_contact_presence(contact); + const char* const status = p_contact_status(contact); win_show_status_string(window, barejid, show, status, NULL, "--", "offline"); } } @@ -97,24 +97,24 @@ chatwin_new(const char *const barejid) } void -chatwin_receipt_received(ProfChatWin *chatwin, const char *const id) +chatwin_receipt_received(ProfChatWin* chatwin, const char* const id) { assert(chatwin != NULL); - ProfWin *win = (ProfWin*) chatwin; + ProfWin* win = (ProfWin*)chatwin; win_mark_received(win, id); } #ifdef HAVE_LIBOTR void -chatwin_otr_secured(ProfChatWin *chatwin, gboolean trusted) +chatwin_otr_secured(ProfChatWin* chatwin, gboolean trusted) { assert(chatwin != NULL); chatwin->is_otr = TRUE; chatwin->otr_is_trusted = trusted; - ProfWin *window = (ProfWin*) chatwin; + ProfWin* window = (ProfWin*)chatwin; if (trusted) { win_println(window, THEME_OTR_STARTED_TRUSTED, "!", "OTR session started (trusted)."); } else { @@ -122,7 +122,7 @@ chatwin_otr_secured(ProfChatWin *chatwin, gboolean trusted) } if (wins_is_current(window)) { - title_bar_switch(); + title_bar_switch(); } else { int num = wins_get_num(window); status_bar_new(num, WIN_CHAT, chatwin->barejid); @@ -137,14 +137,14 @@ chatwin_otr_secured(ProfChatWin *chatwin, gboolean trusted) } void -chatwin_otr_unsecured(ProfChatWin *chatwin) +chatwin_otr_unsecured(ProfChatWin* chatwin) { assert(chatwin != NULL); chatwin->is_otr = FALSE; chatwin->otr_is_trusted = FALSE; - ProfWin *window = (ProfWin*)chatwin; + ProfWin* window = (ProfWin*)chatwin; win_println(window, THEME_OTR_ENDED, "!", "OTR session ended."); if (wins_is_current(window)) { title_bar_switch(); @@ -152,62 +152,62 @@ chatwin_otr_unsecured(ProfChatWin *chatwin) } void -chatwin_otr_smp_event(ProfChatWin *chatwin, prof_otr_smp_event_t event, void *data) +chatwin_otr_smp_event(ProfChatWin* chatwin, prof_otr_smp_event_t event, void* data) { assert(chatwin != NULL); switch (event) { - case PROF_OTR_SMP_INIT: - win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", - "%s wants to authenticate your identity, use '/otr secret <secret>'.", chatwin->barejid); - break; - case PROF_OTR_SMP_INIT_Q: - win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", - "%s wants to authenticate your identity with the following question:", chatwin->barejid); - win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", " %s", (char*)data); - win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "use '/otr answer <answer>'."); - break; - case PROF_OTR_SMP_SENDER_FAIL: - win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", - "Authentication failed, the secret you entered does not match the secret entered by %s.", - chatwin->barejid); - break; - case PROF_OTR_SMP_RECEIVER_FAIL: - win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", - "Authentication failed, the secret entered by %s does not match yours.", chatwin->barejid); - break; - case PROF_OTR_SMP_ABORT: - win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "SMP session aborted."); - break; - case PROF_OTR_SMP_SUCCESS: - win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "Authentication successful."); - break; - case PROF_OTR_SMP_SUCCESS_Q: - win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "%s successfully authenticated you.", chatwin->barejid); - break; - case PROF_OTR_SMP_FAIL_Q: - win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "%s failed to authenticate you.", chatwin->barejid); - break; - case PROF_OTR_SMP_AUTH: - win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "Authenticating %s...", chatwin->barejid); - break; - case PROF_OTR_SMP_AUTH_WAIT: - win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "Awaiting authentication from %s...", chatwin->barejid); - break; - default: - break; + case PROF_OTR_SMP_INIT: + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", + "%s wants to authenticate your identity, use '/otr secret <secret>'.", chatwin->barejid); + break; + case PROF_OTR_SMP_INIT_Q: + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", + "%s wants to authenticate your identity with the following question:", chatwin->barejid); + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", " %s", (char*)data); + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "use '/otr answer <answer>'."); + break; + case PROF_OTR_SMP_SENDER_FAIL: + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", + "Authentication failed, the secret you entered does not match the secret entered by %s.", + chatwin->barejid); + break; + case PROF_OTR_SMP_RECEIVER_FAIL: + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", + "Authentication failed, the secret entered by %s does not match yours.", chatwin->barejid); + break; + case PROF_OTR_SMP_ABORT: + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "SMP session aborted."); + break; + case PROF_OTR_SMP_SUCCESS: + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "Authentication successful."); + break; + case PROF_OTR_SMP_SUCCESS_Q: + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "%s successfully authenticated you.", chatwin->barejid); + break; + case PROF_OTR_SMP_FAIL_Q: + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "%s failed to authenticate you.", chatwin->barejid); + break; + case PROF_OTR_SMP_AUTH: + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "Authenticating %s...", chatwin->barejid); + break; + case PROF_OTR_SMP_AUTH_WAIT: + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "Awaiting authentication from %s...", chatwin->barejid); + break; + default: + break; } } void -chatwin_otr_trust(ProfChatWin *chatwin) +chatwin_otr_trust(ProfChatWin* chatwin) { assert(chatwin != NULL); chatwin->is_otr = TRUE; chatwin->otr_is_trusted = TRUE; - ProfWin *window = (ProfWin*)chatwin; + ProfWin* window = (ProfWin*)chatwin; win_println(window, THEME_OTR_TRUSTED, "!", "OTR session trusted."); if (wins_is_current(window)) { title_bar_switch(); @@ -215,14 +215,14 @@ chatwin_otr_trust(ProfChatWin *chatwin) } void -chatwin_otr_untrust(ProfChatWin *chatwin) +chatwin_otr_untrust(ProfChatWin* chatwin) { assert(chatwin != NULL); chatwin->is_otr = TRUE; chatwin->otr_is_trusted = FALSE; - ProfWin *window = (ProfWin*)chatwin; + ProfWin* window = (ProfWin*)chatwin; win_println(window, THEME_OTR_UNTRUSTED, "!", "OTR session untrusted."); if (wins_is_current(window)) { title_bar_switch(); @@ -231,11 +231,11 @@ chatwin_otr_untrust(ProfChatWin *chatwin) #endif void -chatwin_recipient_gone(ProfChatWin *chatwin) +chatwin_recipient_gone(ProfChatWin* chatwin) { assert(chatwin != NULL); - const char *display_usr = NULL; + const char* display_usr = NULL; PContact contact = roster_get_contact(chatwin->barejid); if (contact) { if (p_contact_name(contact)) { @@ -251,18 +251,18 @@ chatwin_recipient_gone(ProfChatWin *chatwin) } void -chatwin_incoming_msg(ProfChatWin *chatwin, ProfMessage *message, gboolean win_created) +chatwin_incoming_msg(ProfChatWin* chatwin, ProfMessage* message, gboolean win_created) { assert(chatwin != NULL); - char *old_plain = message->plain; + char* old_plain = message->plain; message->plain = plugins_pre_chat_message_display(message->from_jid->barejid, message->from_jid->resourcepart, message->plain); - ProfWin *window = (ProfWin*)chatwin; + ProfWin* window = (ProfWin*)chatwin; int num = wins_get_num(window); - char *display_name; - char *mybarejid = connection_get_barejid(); + char* display_name; + char* mybarejid = connection_get_barejid(); if (g_strcmp0(mybarejid, message->from_jid->barejid) == 0) { display_name = strdup("me"); } else { @@ -279,7 +279,7 @@ chatwin_incoming_msg(ProfChatWin *chatwin, ProfMessage *message, gboolean win_cr title_bar_set_typing(FALSE); status_bar_active(num, WIN_CHAT, chatwin->barejid); - // not currently viewing chat window with sender + // not currently viewing chat window with sender } else { status_bar_new(num, WIN_CHAT, chatwin->barejid); cons_show_incoming_message(display_name, num, chatwin->unread); @@ -333,12 +333,12 @@ chatwin_incoming_msg(ProfChatWin *chatwin, ProfMessage *message, gboolean win_cr } void -chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id, prof_enc_t enc_mode, - gboolean request_receipt, const char *const replace_id) +chatwin_outgoing_msg(ProfChatWin* chatwin, const char* const message, char* id, prof_enc_t enc_mode, + gboolean request_receipt, const char* const replace_id) { assert(chatwin != NULL); - char *enc_char; + char* enc_char; if (chatwin->outgoing_char) { enc_char = chatwin->outgoing_char; } else if (enc_mode == PROF_MSG_ENC_OTR) { @@ -368,11 +368,11 @@ chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id, } void -chatwin_outgoing_carbon(ProfChatWin *chatwin, ProfMessage *message) +chatwin_outgoing_carbon(ProfChatWin* chatwin, ProfMessage* message) { assert(chatwin != NULL); - char *enc_char; + char* enc_char; if (message->enc == PROF_MSG_ENC_PGP) { enc_char = prefs_get_pgp_char(); } else if (message->enc == PROF_MSG_ENC_OMEMO) { @@ -381,7 +381,7 @@ chatwin_outgoing_carbon(ProfChatWin *chatwin, ProfMessage *message) enc_char = strdup("-"); } - ProfWin *window = (ProfWin*)chatwin; + ProfWin* window = (ProfWin*)chatwin; win_print_outgoing(window, enc_char, message->id, message->replace_id, message->plain); int num = wins_get_num(window); @@ -391,13 +391,13 @@ chatwin_outgoing_carbon(ProfChatWin *chatwin, ProfMessage *message) } void -chatwin_contact_online(ProfChatWin *chatwin, Resource *resource, GDateTime *last_activity) +chatwin_contact_online(ProfChatWin* chatwin, Resource* resource, GDateTime* last_activity) { assert(chatwin != NULL); - const char *show = string_from_resource_presence(resource->presence); + const char* show = string_from_resource_presence(resource->presence); PContact contact = roster_get_contact(chatwin->barejid); - char *display_str = p_contact_create_display_string(contact, resource->name); + char* display_str = p_contact_create_display_string(contact, resource->name); win_show_status_string((ProfWin*)chatwin, display_str, show, resource->status, last_activity, "++", "online"); @@ -405,12 +405,12 @@ chatwin_contact_online(ProfChatWin *chatwin, Resource *resource, GDateTime *last } void -chatwin_contact_offline(ProfChatWin *chatwin, char *resource, char *status) +chatwin_contact_offline(ProfChatWin* chatwin, char* resource, char* status) { assert(chatwin != NULL); PContact contact = roster_get_contact(chatwin->barejid); - char *display_str = p_contact_create_display_string(contact, resource); + char* display_str = p_contact_create_display_string(contact, resource); win_show_status_string((ProfWin*)chatwin, display_str, "offline", status, NULL, "--", "offline"); @@ -418,11 +418,11 @@ chatwin_contact_offline(ProfChatWin *chatwin, char *resource, char *status) } char* -chatwin_get_string(ProfChatWin *chatwin) +chatwin_get_string(ProfChatWin* chatwin) { assert(chatwin != NULL); - GString *res = g_string_new("Chat "); + GString* res = g_string_new("Chat "); jabber_conn_status_t conn_status = connection_get_status(); if (conn_status == JABBER_CONNECTED) { @@ -430,7 +430,7 @@ chatwin_get_string(ProfChatWin *chatwin) if (contact == NULL) { g_string_append(res, chatwin->barejid); } else { - const char *display_name = p_contact_name_or_jid(contact); + const char* display_name = p_contact_name_or_jid(contact); g_string_append(res, display_name); g_string_append_printf(res, " - %s", p_contact_presence(contact)); } @@ -442,14 +442,14 @@ chatwin_get_string(ProfChatWin *chatwin) g_string_append_printf(res, ", %d unread", chatwin->unread); } - char *resstr = res->str; + char* resstr = res->str; g_string_free(res, FALSE); return resstr; } void -chatwin_set_enctext(ProfChatWin *chatwin, const char *const enctext) +chatwin_set_enctext(ProfChatWin* chatwin, const char* const enctext) { if (chatwin->enctext) { free(chatwin->enctext); @@ -458,7 +458,7 @@ chatwin_set_enctext(ProfChatWin *chatwin, const char *const enctext) } void -chatwin_unset_enctext(ProfChatWin *chatwin) +chatwin_unset_enctext(ProfChatWin* chatwin) { if (chatwin->enctext) { free(chatwin->enctext); @@ -467,7 +467,7 @@ chatwin_unset_enctext(ProfChatWin *chatwin) } void -chatwin_set_incoming_char(ProfChatWin *chatwin, const char *const ch) +chatwin_set_incoming_char(ProfChatWin* chatwin, const char* const ch) { if (chatwin->incoming_char) { free(chatwin->incoming_char); @@ -476,7 +476,7 @@ chatwin_set_incoming_char(ProfChatWin *chatwin, const char *const ch) } void -chatwin_unset_incoming_char(ProfChatWin *chatwin) +chatwin_unset_incoming_char(ProfChatWin* chatwin) { if (chatwin->incoming_char) { free(chatwin->incoming_char); @@ -485,7 +485,7 @@ chatwin_unset_incoming_char(ProfChatWin *chatwin) } void -chatwin_set_outgoing_char(ProfChatWin *chatwin, const char *const ch) +chatwin_set_outgoing_char(ProfChatWin* chatwin, const char* const ch) { if (chatwin->outgoing_char) { free(chatwin->outgoing_char); @@ -494,7 +494,7 @@ chatwin_set_outgoing_char(ProfChatWin *chatwin, const char *const ch) } void -chatwin_unset_outgoing_char(ProfChatWin *chatwin) +chatwin_unset_outgoing_char(ProfChatWin* chatwin) { if (chatwin->outgoing_char) { free(chatwin->outgoing_char); @@ -503,14 +503,14 @@ chatwin_unset_outgoing_char(ProfChatWin *chatwin) } static void -_chatwin_history(ProfChatWin *chatwin, const char *const contact_barejid) +_chatwin_history(ProfChatWin* chatwin, const char* const contact_barejid) { if (!chatwin->history_shown) { - GSList *history = log_database_get_previous_chat(contact_barejid); - GSList *curr = history; + GSList* history = log_database_get_previous_chat(contact_barejid); + GSList* curr = history; while (curr) { - ProfMessage *msg = curr->data; + ProfMessage* msg = curr->data; win_print_history((ProfWin*)chatwin, msg); curr = g_slist_next(curr); } @@ -521,7 +521,7 @@ _chatwin_history(ProfChatWin *chatwin, const char *const contact_barejid) } static void -_chatwin_set_last_message(ProfChatWin *chatwin, const char *const id, const char *const message) +_chatwin_set_last_message(ProfChatWin* chatwin, const char* const id, const char* const message) { free(chatwin->last_message); chatwin->last_message = strdup(message); diff --git a/src/ui/confwin.c b/src/ui/confwin.c index af37a640..5dc57923 100644 --- a/src/ui/confwin.c +++ b/src/ui/confwin.c @@ -41,12 +41,12 @@ #include "ui/win_types.h" #include "ui/window_list.h" -static void _confwin_form_field(ProfWin *window, char *tag, FormField *field); +static void _confwin_form_field(ProfWin* window, char* tag, FormField* field); void -confwin_show_form(ProfConfWin *confwin) +confwin_show_form(ProfConfWin* confwin) { - ProfWin *window = (ProfWin*) confwin; + ProfWin* window = (ProfWin*)confwin; if (confwin->form->title) { win_print(window, THEME_DEFAULT, "-", "Form title: "); win_appendln(window, THEME_DEFAULT, "%s", confwin->form->title); @@ -57,18 +57,18 @@ confwin_show_form(ProfConfWin *confwin) confwin_form_help(confwin); - GSList *fields = confwin->form->fields; - GSList *curr_field = fields; + GSList* fields = confwin->form->fields; + GSList* curr_field = fields; while (curr_field) { - FormField *field = curr_field->data; + FormField* field = curr_field->data; if ((g_strcmp0(field->type, "fixed") == 0) && field->values) { if (field->values) { - char *value = field->values->data; + char* value = field->values->data; win_println(window, THEME_DEFAULT, "-", "%s", value); } } else if (g_strcmp0(field->type, "hidden") != 0 && field->var) { - char *tag = g_hash_table_lookup(confwin->form->var_to_tag, field->var); + char* tag = g_hash_table_lookup(confwin->form->var_to_tag, field->var); _confwin_form_field(window, tag, field); } @@ -77,22 +77,22 @@ confwin_show_form(ProfConfWin *confwin) } void -confwin_show_form_field(ProfConfWin *confwin, DataForm *form, char *tag) +confwin_show_form_field(ProfConfWin* confwin, DataForm* form, char* tag) { assert(confwin != NULL); - FormField *field = form_get_field_by_tag(form, tag); - ProfWin *window = (ProfWin*)confwin; + FormField* field = form_get_field_by_tag(form, tag); + ProfWin* window = (ProfWin*)confwin; _confwin_form_field(window, tag, field); win_println(window, THEME_DEFAULT, "-", ""); } void -confwin_handle_configuration(ProfConfWin *confwin, DataForm *form) +confwin_handle_configuration(ProfConfWin* confwin, DataForm* form) { assert(confwin != NULL); - ProfWin *window = (ProfWin*)confwin; + ProfWin* window = (ProfWin*)confwin; ui_focus_win(window); confwin_show_form(confwin); @@ -107,12 +107,12 @@ confwin_handle_configuration(ProfConfWin *confwin, DataForm *form) } void -confwin_field_help(ProfConfWin *confwin, char *tag) +confwin_field_help(ProfConfWin* confwin, char* tag) { assert(confwin != NULL); - ProfWin *window = (ProfWin*) confwin; - FormField *field = form_get_field_by_tag(confwin->form, tag); + ProfWin* window = (ProfWin*)confwin; + FormField* field = form_get_field_by_tag(confwin->form, tag); if (field) { win_print(window, THEME_DEFAULT, "-", "%s", field->label); if (field->required) { @@ -126,8 +126,8 @@ confwin_field_help(ProfConfWin *confwin, char *tag) win_println(window, THEME_DEFAULT, "-", " Type : %s", field->type); int num_values = 0; - GSList *curr_option = NULL; - FormOption *option = NULL; + GSList* curr_option = NULL; + FormOption* option = NULL; switch (field->type_t) { case FIELD_TEXT_SINGLE: @@ -190,12 +190,12 @@ confwin_field_help(ProfConfWin *confwin, char *tag) } void -confwin_form_help(ProfConfWin *confwin) +confwin_form_help(ProfConfWin* confwin) { assert(confwin != NULL); if (confwin->form->instructions) { - ProfWin *window = (ProfWin*) confwin; + ProfWin* window = (ProfWin*)confwin; win_println(window, THEME_DEFAULT, "-", "Supplied instructions:"); win_println(window, THEME_DEFAULT, "-", "%s", confwin->form->instructions); win_println(window, THEME_DEFAULT, "-", ""); @@ -203,7 +203,7 @@ confwin_form_help(ProfConfWin *confwin) } static void -_confwin_form_field(ProfWin *window, char *tag, FormField *field) +_confwin_form_field(ProfWin* window, char* tag, FormField* field) { win_print(window, THEME_AWAY, "-", "[%s] ", tag); win_append(window, THEME_DEFAULT, "%s", field->label); @@ -213,15 +213,15 @@ _confwin_form_field(ProfWin *window, char *tag, FormField *field) win_append(window, THEME_DEFAULT, ": "); } - GSList *values = field->values; - GSList *curr_value = values; + GSList* values = field->values; + GSList* curr_value = values; switch (field->type_t) { case FIELD_HIDDEN: break; case FIELD_TEXT_SINGLE: if (curr_value) { - char *value = curr_value->data; + char* value = curr_value->data; if (value) { if (g_strcmp0(field->var, "muc#roomconfig_roomsecret") == 0) { win_append(window, THEME_ONLINE, "[hidden]"); @@ -234,7 +234,7 @@ _confwin_form_field(ProfWin *window, char *tag, FormField *field) break; case FIELD_TEXT_PRIVATE: if (curr_value) { - char *value = curr_value->data; + char* value = curr_value->data; if (value) { win_append(window, THEME_ONLINE, "[hidden]"); } @@ -245,8 +245,8 @@ _confwin_form_field(ProfWin *window, char *tag, FormField *field) win_newline(window); int index = 1; while (curr_value) { - char *value = curr_value->data; - GString *val_tag = g_string_new(""); + char* value = curr_value->data; + GString* val_tag = g_string_new(""); g_string_printf(val_tag, "val%d", index++); win_println(window, THEME_ONLINE, "-", " [%s] %s", val_tag->str, value); g_string_free(val_tag, TRUE); @@ -257,7 +257,7 @@ _confwin_form_field(ProfWin *window, char *tag, FormField *field) if (curr_value == NULL) { win_appendln(window, THEME_OFFLINE, "FALSE"); } else { - char *value = curr_value->data; + char* value = curr_value->data; if (value == NULL) { win_appendln(window, THEME_OFFLINE, "FALSE"); } else { @@ -272,11 +272,11 @@ _confwin_form_field(ProfWin *window, char *tag, FormField *field) case FIELD_LIST_SINGLE: if (curr_value) { win_newline(window); - char *value = curr_value->data; - GSList *options = field->options; - GSList *curr_option = options; + char* value = curr_value->data; + GSList* options = field->options; + GSList* curr_option = options; while (curr_option) { - FormOption *option = curr_option->data; + FormOption* option = curr_option->data; if (g_strcmp0(option->value, value) == 0) { win_println(window, THEME_ONLINE, "-", " [%s] %s", option->value, option->label); } else { @@ -289,10 +289,10 @@ _confwin_form_field(ProfWin *window, char *tag, FormField *field) case FIELD_LIST_MULTI: if (curr_value) { win_newline(window); - GSList *options = field->options; - GSList *curr_option = options; + GSList* options = field->options; + GSList* curr_option = options; while (curr_option) { - FormOption *option = curr_option->data; + FormOption* option = curr_option->data; if (g_slist_find_custom(curr_value, option->value, (GCompareFunc)g_strcmp0)) { win_println(window, THEME_ONLINE, "-", " [%s] %s", option->value, option->label); } else { @@ -304,7 +304,7 @@ _confwin_form_field(ProfWin *window, char *tag, FormField *field) break; case FIELD_JID_SINGLE: if (curr_value) { - char *value = curr_value->data; + char* value = curr_value->data; if (value) { win_append(window, THEME_ONLINE, "%s", value); } @@ -314,14 +314,14 @@ _confwin_form_field(ProfWin *window, char *tag, FormField *field) case FIELD_JID_MULTI: win_newline(window); while (curr_value) { - char *value = curr_value->data; + char* value = curr_value->data; win_println(window, THEME_ONLINE, "-", " %s", value); curr_value = g_slist_next(curr_value); } break; case FIELD_FIXED: if (curr_value) { - char *value = curr_value->data; + char* value = curr_value->data; if (value) { win_append(window, THEME_DEFAULT, "%s", value); } @@ -334,17 +334,17 @@ _confwin_form_field(ProfWin *window, char *tag, FormField *field) } char* -confwin_get_string(ProfConfWin *confwin) +confwin_get_string(ProfConfWin* confwin) { assert(confwin != NULL); - GString *res = g_string_new(""); + GString* res = g_string_new(""); - char *title = win_get_title((ProfWin*)confwin); + char* title = win_get_title((ProfWin*)confwin); g_string_append(res, title); free(title); - char *resstr = res->str; + char* resstr = res->str; g_string_free(res, FALSE); return resstr; diff --git a/src/ui/console.c b/src/ui/console.c index 3696de81..2a52f9ea 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -34,7 +34,6 @@ * */ - #include <string.h> #include <stdlib.h> #include <assert.h> @@ -63,16 +62,16 @@ #endif static void _cons_splash_logo(void); -void _show_roster_contacts(GSList *list, gboolean show_groups); +void _show_roster_contacts(GSList* list, gboolean show_groups); void -cons_debug(const char *const msg, ...) +cons_debug(const char* const msg, ...) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); if (strcmp(PACKAGE_STATUS, "development") == 0) { va_list arg; va_start(arg, msg); - GString *fmt_msg = g_string_new(NULL); + GString* fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, msg, arg); win_println(console, THEME_DEFAULT, "-", "%s", fmt_msg->str); g_string_free(fmt_msg, TRUE); @@ -81,12 +80,12 @@ cons_debug(const char *const msg, ...) } void -cons_show(const char *const msg, ...) +cons_show(const char* const msg, ...) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); va_list arg; va_start(arg, msg); - GString *fmt_msg = g_string_new(NULL); + GString* fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, msg, arg); win_println(console, THEME_DEFAULT, "-", "%s", fmt_msg->str); g_string_free(fmt_msg, TRUE); @@ -94,12 +93,12 @@ cons_show(const char *const msg, ...) } void -cons_show_padded(int pad, const char *const msg, ...) +cons_show_padded(int pad, const char* const msg, ...) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); va_list arg; va_start(arg, msg); - GString *fmt_msg = g_string_new(NULL); + GString* fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, msg, arg); win_println_indent(console, pad, "%s", fmt_msg->str); g_string_free(fmt_msg, TRUE); @@ -107,15 +106,15 @@ cons_show_padded(int pad, const char *const msg, ...) } void -cons_show_help(const char *const cmd, CommandHelp *help) +cons_show_help(const char* const cmd, CommandHelp* help) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); cons_show(""); win_println(console, THEME_HELP_HEADER, "-", "%s", &cmd[1]); win_print(console, THEME_HELP_HEADER, "-", ""); int i; - for (i = 0; i < strlen(cmd) - 1 ; i++) { + for (i = 0; i < strlen(cmd) - 1; i++) { win_append(console, THEME_HELP_HEADER, "-"); } win_appendln(console, THEME_HELP_HEADER, ""); @@ -150,9 +149,9 @@ cons_show_help(const char *const cmd, CommandHelp *help) } void -cons_bad_cmd_usage(const char *const cmd) +cons_bad_cmd_usage(const char* const cmd) { - GString *msg = g_string_new(""); + GString* msg = g_string_new(""); g_string_printf(msg, "Invalid usage, see '/help %s' for details.", &cmd[1]); cons_show(""); @@ -162,12 +161,12 @@ cons_bad_cmd_usage(const char *const cmd) } void -cons_show_error(const char *const msg, ...) +cons_show_error(const char* const msg, ...) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); va_list arg; va_start(arg, msg); - GString *fmt_msg = g_string_new(NULL); + GString* fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, msg, arg); win_println(console, THEME_ERROR, "-", "%s", fmt_msg->str); g_string_free(fmt_msg, TRUE); @@ -177,7 +176,7 @@ cons_show_error(const char *const msg, ...) } void -cons_show_tlscert_summary(TLSCertificate *cert) +cons_show_tlscert_summary(TLSCertificate* cert) { if (!cert) { return; @@ -189,7 +188,7 @@ cons_show_tlscert_summary(TLSCertificate *cert) } void -cons_show_tlscert(TLSCertificate *cert) +cons_show_tlscert(TLSCertificate* cert) { if (!cert) { return; @@ -269,10 +268,10 @@ cons_show_tlscert(TLSCertificate *cert) } void -cons_show_typing(const char *const barejid) +cons_show_typing(const char* const barejid) { - ProfWin *console = wins_get_console(); - const char * display_usr = NULL; + ProfWin* console = wins_get_console(); + const char* display_usr = NULL; PContact contact = roster_get_contact(barejid); if (contact) { if (p_contact_name(contact)) { @@ -289,10 +288,10 @@ cons_show_typing(const char *const barejid) } char* -_room_triggers_to_string(GList *triggers) +_room_triggers_to_string(GList* triggers) { - GString *triggers_str = g_string_new(""); - GList *curr = triggers; + GString* triggers_str = g_string_new(""); + GList* curr = triggers; while (curr) { g_string_append_printf(triggers_str, "\"%s\"", (char*)curr->data); curr = g_list_next(curr); @@ -301,29 +300,29 @@ _room_triggers_to_string(GList *triggers) } } - char *result = triggers_str->str; + char* result = triggers_str->str; g_string_free(triggers_str, FALSE); return result; } void -cons_show_incoming_room_message(const char *const nick, const char *const room, const int win_index, gboolean mention, - GList *triggers, int unread) +cons_show_incoming_room_message(const char* const nick, const char* const room, const int win_index, gboolean mention, + GList* triggers, int unread) { - ProfWin *const console = wins_get_console(); + ProfWin* const console = wins_get_console(); int ui_index = win_index; if (ui_index == 10) { ui_index = 0; } - char *muc_show = prefs_get_string(PREF_CONSOLE_MUC); + char* muc_show = prefs_get_string(PREF_CONSOLE_MUC); if (g_strcmp0(muc_show, "all") == 0) { if (mention) { win_println(console, THEME_MENTION, "-", "<< room mention: %s in %s (win %d)", nick, room, ui_index); } else if (triggers) { - char *triggers_str = _room_triggers_to_string(triggers); + char* triggers_str = _room_triggers_to_string(triggers); win_println(console, THEME_TRIGGER, "-", "<< room trigger %s: %s in %s (win %d)", triggers_str, nick, room, ui_index); free(triggers_str); } else { @@ -336,7 +335,7 @@ cons_show_incoming_room_message(const char *const nick, const char *const room, win_println(console, THEME_MENTION, "-", "<< room mention: %s in %s (win %d)", nick, room, ui_index); cons_alert(); } else if (triggers) { - char *triggers_str = _room_triggers_to_string(triggers); + char* triggers_str = _room_triggers_to_string(triggers); win_println(console, THEME_TRIGGER, "-", "<< room trigger %s: %s in %s (win %d)", triggers_str, nick, room, ui_index); free(triggers_str); cons_alert(); @@ -349,16 +348,16 @@ cons_show_incoming_room_message(const char *const nick, const char *const room, } void -cons_show_incoming_message(const char *const short_from, const int win_index, int unread) +cons_show_incoming_message(const char* const short_from, const int win_index, int unread) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); int ui_index = win_index; if (ui_index == 10) { ui_index = 0; } - char *chat_show = prefs_get_string(PREF_CONSOLE_CHAT); + char* chat_show = prefs_get_string(PREF_CONSOLE_CHAT); if (g_strcmp0(chat_show, "all") == 0) { win_println(console, THEME_INCOMING, "-", "<< chat message: %s (win %d)", short_from, ui_index); cons_alert(); @@ -371,16 +370,16 @@ cons_show_incoming_message(const char *const short_from, const int win_index, in } void -cons_show_incoming_private_message(const char *const nick, const char *const room, const int win_index, int unread) +cons_show_incoming_private_message(const char* const nick, const char* const room, const int win_index, int unread) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); int ui_index = win_index; if (ui_index == 10) { ui_index = 0; } - char *priv_show = prefs_get_string(PREF_CONSOLE_PRIVATE); + char* priv_show = prefs_get_string(PREF_CONSOLE_PRIVATE); if (g_strcmp0(priv_show, "all") == 0) { win_println(console, THEME_INCOMING, "-", "<< private message: %s in %s (win %d)", nick, room, ui_index); cons_alert(); @@ -395,7 +394,7 @@ cons_show_incoming_private_message(const char *const nick, const char *const roo void cons_about(void) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); int rows, cols; getmaxyx(stdscr, rows, cols); @@ -428,7 +427,7 @@ cons_about(void) cons_check_version(FALSE); } - pnoutrefresh(console->layout->win, 0, 0, 1, 0, rows-3, cols-1); + pnoutrefresh(console->layout->win, 0, 0, 1, 0, rows - 3, cols - 1); cons_alert(); } @@ -436,8 +435,8 @@ cons_about(void) void cons_check_version(gboolean not_available_msg) { - ProfWin *console = wins_get_console(); - char *latest_release = release_get_latest(); + ProfWin* console = wins_get_console(); + char* latest_release = release_get_latest(); if (latest_release) { gboolean relase_valid = g_regex_match_simple("^\\d+\\.\\d+\\.\\d+$", latest_release, 0, 0); @@ -461,15 +460,15 @@ cons_check_version(gboolean not_available_msg) } void -cons_show_login_success(ProfAccount *account, gboolean secured) +cons_show_login_success(ProfAccount* account, gboolean secured) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); - const char *fulljid = connection_get_fulljid(); + const char* fulljid = connection_get_fulljid(); win_print(console, THEME_DEFAULT, "-", "%s logged in successfully, ", fulljid); resource_presence_t presence = accounts_get_login_presence(account->name); - const char *presence_str = string_from_resource_presence(presence); + const char* presence_str = string_from_resource_presence(presence); theme_item_t presence_colour = theme_main_presence_attrs(presence_str); win_append(console, presence_colour, "%s", presence_str); @@ -484,9 +483,9 @@ cons_show_login_success(ProfAccount *account, gboolean secured) void cons_show_wins(gboolean unread) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); cons_show(""); - GSList *window_strings = wins_create_summary(unread); + GSList* window_strings = wins_create_summary(unread); if (unread && window_strings == NULL) { cons_show("No windows with unread messages."); @@ -497,7 +496,7 @@ cons_show_wins(gboolean unread) cons_show("Active windows:"); } - GSList *curr = window_strings; + GSList* curr = window_strings; while (curr) { if (g_strstr_len(curr->data, strlen(curr->data), " unread") > 0) { win_println(console, THEME_CMD_WINS_UNREAD, "-", "%s", curr->data); @@ -512,7 +511,7 @@ cons_show_wins(gboolean unread) } void -cons_show_room_invites(GList *invites) +cons_show_room_invites(GList* invites) { cons_show(""); if (invites == NULL) { @@ -531,21 +530,21 @@ cons_show_room_invites(GList *invites) void cons_show_info(PContact pcontact) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); win_show_info(console, pcontact); cons_alert(); } void -cons_show_caps(const char *const fulljid, resource_presence_t presence) +cons_show_caps(const char* const fulljid, resource_presence_t presence) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); cons_show(""); - EntityCapabilities *caps = caps_lookup(fulljid); + EntityCapabilities* caps = caps_lookup(fulljid); if (caps) { - const char *resource_presence = string_from_resource_presence(presence); + const char* resource_presence = string_from_resource_presence(presence); theme_item_t presence_colour = theme_main_presence_attrs(resource_presence); win_print(console, presence_colour, "-", "%s", fulljid); @@ -553,7 +552,7 @@ cons_show_caps(const char *const fulljid, resource_presence_t presence) // show identity if (caps->identity) { - DiscoIdentity *identity = caps->identity; + DiscoIdentity* identity = caps->identity; win_print(console, THEME_DEFAULT, "-", "Identity: "); if (identity->name) { win_append(console, THEME_DEFAULT, "%s", identity->name); @@ -574,7 +573,7 @@ cons_show_caps(const char *const fulljid, resource_presence_t presence) } if (caps->software_version) { - SoftwareVersion *software_version = caps->software_version; + SoftwareVersion* software_version = caps->software_version; if (software_version->software) { win_print(console, THEME_DEFAULT, "-", "Software: %s", software_version->software); } @@ -597,7 +596,7 @@ cons_show_caps(const char *const fulljid, resource_presence_t presence) if (caps->features) { win_println(console, THEME_DEFAULT, "-", "Features:"); - GSList *feature = caps->features; + GSList* feature = caps->features; while (feature) { win_println(console, THEME_DEFAULT, "-", " %s", feature->data); feature = g_slist_next(feature); @@ -615,12 +614,12 @@ cons_show_caps(const char *const fulljid, resource_presence_t presence) void cons_show_received_subs(void) { - GList *received = presence_get_subscription_requests(); + GList* received = presence_get_subscription_requests(); if (received == NULL) { cons_show("No outstanding subscription requests."); } else { cons_show("Outstanding subscription requests from:", - g_list_length(received)); + g_list_length(received)); while (received) { cons_show(" %s", received->data); received = g_list_next(received); @@ -634,13 +633,13 @@ cons_show_received_subs(void) void cons_show_sent_subs(void) { - if (roster_has_pending_subscriptions()) { - GSList *contacts = roster_get_contacts(ROSTER_ORD_NAME); + if (roster_has_pending_subscriptions()) { + GSList* contacts = roster_get_contacts(ROSTER_ORD_NAME); PContact contact = NULL; cons_show("Awaiting subscription responses from:"); - GSList *curr = contacts; + GSList* curr = contacts; while (curr) { - contact = (PContact) curr->data; + contact = (PContact)curr->data; if (p_contact_pending_out(contact)) { cons_show(" %s", p_contact_barejid(contact)); } @@ -654,13 +653,13 @@ cons_show_sent_subs(void) } void -cons_show_room_list(GSList *rooms, const char *const conference_node) +cons_show_room_list(GSList* rooms, const char* const conference_node) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); if (rooms && (g_slist_length(rooms) > 0)) { cons_show("Chat rooms at %s:", conference_node); while (rooms) { - DiscoItem *room = rooms->data; + DiscoItem* room = rooms->data; win_print(console, THEME_DEFAULT, "-", " %s", room->jid); if (room->name) { win_append(console, THEME_DEFAULT, ", (%s)", room->name); @@ -676,9 +675,9 @@ cons_show_room_list(GSList *rooms, const char *const conference_node) } void -cons_show_bookmarks(const GList *list) +cons_show_bookmarks(const GList* list) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); if (list == NULL) { cons_show(""); @@ -688,10 +687,10 @@ cons_show_bookmarks(const GList *list) cons_show("Bookmarks:"); while (list) { - Bookmark *item = list->data; + Bookmark* item = list->data; theme_item_t presence_colour = THEME_TEXT; - ProfWin *roomwin = (ProfWin*)wins_get_muc(item->barejid); + ProfWin* roomwin = (ProfWin*)wins_get_muc(item->barejid); if (muc_active(item->barejid) && roomwin) { presence_colour = THEME_ONLINE; @@ -730,10 +729,9 @@ cons_show_bookmarks(const GList *list) } void -cons_show_disco_info(const char *jid, GSList *identities, GSList *features) +cons_show_disco_info(const char* jid, GSList* identities, GSList* features) { - if ((identities && (g_slist_length(identities) > 0)) || - (features && (g_slist_length(features) > 0))) { + if ((identities && (g_slist_length(identities) > 0)) || (features && (g_slist_length(features) > 0))) { cons_show(""); cons_show("Service discovery info for %s", jid); @@ -741,8 +739,8 @@ cons_show_disco_info(const char *jid, GSList *identities, GSList *features) cons_show(" Identities"); } while (identities) { - DiscoIdentity *identity = identities->data; // anme trpe, cat - GString *identity_str = g_string_new(" "); + DiscoIdentity* identity = identities->data; // anme trpe, cat + GString* identity_str = g_string_new(" "); if (identity->name) { identity_str = g_string_append(identity_str, identity->name); identity_str = g_string_append(identity_str, " "); @@ -772,14 +770,14 @@ cons_show_disco_info(const char *jid, GSList *identities, GSList *features) } void -cons_show_disco_items(GSList *items, const char *const jid) +cons_show_disco_items(GSList* items, const char* const jid) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); if (items && (g_slist_length(items) > 0)) { cons_show(""); cons_show("Service discovery items for %s:", jid); while (items) { - DiscoItem *item = items->data; + DiscoItem* item = items->data; win_print(console, THEME_DEFAULT, "-", " %s", item->jid); if (item->name) { win_append(console, THEME_DEFAULT, ", (%s)", item->name); @@ -796,9 +794,9 @@ cons_show_disco_items(GSList *items, const char *const jid) } void -cons_show_status(const char *const barejid) +cons_show_status(const char* const barejid) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); PContact pcontact = roster_get_contact(barejid); if (pcontact) { @@ -811,9 +809,9 @@ cons_show_status(const char *const barejid) } void -cons_show_room_invite(const char *const invitor, const char * const room, const char *const reason) +cons_show_room_invite(const char* const invitor, const char* const room, const char* const reason) { - char *display_from = NULL; + char* display_from = NULL; PContact contact = roster_get_contact(invitor); if (contact) { if (p_contact_name(contact)) { @@ -847,16 +845,15 @@ cons_show_room_invite(const char *const invitor, const char * const room, const } void -cons_show_account_list(gchar **accounts) +cons_show_account_list(gchar** accounts) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); int size = g_strv_length(accounts); if (size > 0) { cons_show("Accounts:"); int i = 0; for (i = 0; i < size; i++) { - if ((connection_get_status() == JABBER_CONNECTED) && - (g_strcmp0(session_get_account_name(), accounts[i]) == 0)) { + if ((connection_get_status() == JABBER_CONNECTED) && (g_strcmp0(session_get_account_name(), accounts[i]) == 0)) { resource_presence_t presence = accounts_get_last_presence(accounts[i]); theme_item_t presence_colour = theme_main_presence_attrs(string_from_resource_presence(presence)); win_println(console, presence_colour, "-", "%s", accounts[i]); @@ -874,61 +871,61 @@ cons_show_account_list(gchar **accounts) } void -cons_show_account(ProfAccount *account) +cons_show_account(ProfAccount* account) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); cons_show(""); cons_show("Account %s:", account->name); if (account->enabled) { - cons_show ("enabled : TRUE"); + cons_show("enabled : TRUE"); } else { - cons_show ("enabled : FALSE"); + cons_show("enabled : FALSE"); } - cons_show ("jid : %s", account->jid); + cons_show("jid : %s", account->jid); if (account->eval_password) { - cons_show ("eval_password : %s", account->eval_password); + cons_show("eval_password : %s", account->eval_password); } else if (account->password) { - cons_show ("password : [redacted]"); + cons_show("password : [redacted]"); } if (account->resource) { - cons_show ("resource : %s", account->resource); + cons_show("resource : %s", account->resource); } if (account->server) { - cons_show ("server : %s", account->server); + cons_show("server : %s", account->server); } if (account->port != 0) { - cons_show ("port : %d", account->port); + cons_show("port : %d", account->port); } if (account->muc_service) { - cons_show ("muc service : %s", account->muc_service); + cons_show("muc service : %s", account->muc_service); } if (account->muc_nick) { - cons_show ("muc nick : %s", account->muc_nick); + cons_show("muc nick : %s", account->muc_nick); } if (account->tls_policy) { - cons_show ("TLS policy : %s", account->tls_policy); + cons_show("TLS policy : %s", account->tls_policy); } if (account->auth_policy) { - cons_show ("Auth policy : %s", account->auth_policy); + cons_show("Auth policy : %s", account->auth_policy); } if (account->last_presence) { - cons_show ("Last presence : %s", account->last_presence); + cons_show("Last presence : %s", account->last_presence); } if (account->login_presence) { - cons_show ("Login presence : %s", account->login_presence); + cons_show("Login presence : %s", account->login_presence); } if (account->startscript) { - cons_show ("Start script : %s", account->startscript); + cons_show("Start script : %s", account->startscript); } if (account->theme) { - cons_show ("Theme : %s", account->theme); + cons_show("Theme : %s", account->theme); } if (account->otr_policy) { - cons_show ("OTR policy : %s", account->otr_policy); + cons_show("OTR policy : %s", account->otr_policy); } if (g_list_length(account->otr_manual) > 0) { - GString *manual = g_string_new("OTR manual : "); - GList *curr = account->otr_manual; + GString* manual = g_string_new("OTR manual : "); + GList* curr = account->otr_manual; while (curr) { g_string_append(manual, curr->data); if (curr->next) { @@ -940,8 +937,8 @@ cons_show_account(ProfAccount *account) g_string_free(manual, TRUE); } if (g_list_length(account->otr_opportunistic) > 0) { - GString *opportunistic = g_string_new("OTR opportunistic : "); - GList *curr = account->otr_opportunistic; + GString* opportunistic = g_string_new("OTR opportunistic : "); + GList* curr = account->otr_opportunistic; while (curr) { g_string_append(opportunistic, curr->data); if (curr->next) { @@ -953,8 +950,8 @@ cons_show_account(ProfAccount *account) g_string_free(opportunistic, TRUE); } if (g_list_length(account->otr_always) > 0) { - GString *always = g_string_new("OTR always : "); - GList *curr = account->otr_always; + GString* always = g_string_new("OTR always : "); + GList* curr = account->otr_always; while (curr) { g_string_append(always, curr->data); if (curr->next) { @@ -967,27 +964,26 @@ cons_show_account(ProfAccount *account) } if (account->pgp_keyid) { - cons_show ("PGP Key ID : %s", account->pgp_keyid); + cons_show("PGP Key ID : %s", account->pgp_keyid); } - cons_show ("Priority : chat:%d, online:%d, away:%d, xa:%d, dnd:%d", - account->priority_chat, account->priority_online, account->priority_away, - account->priority_xa, account->priority_dnd); + cons_show("Priority : chat:%d, online:%d, away:%d, xa:%d, dnd:%d", + account->priority_chat, account->priority_online, account->priority_away, + account->priority_xa, account->priority_dnd); - if ((connection_get_status() == JABBER_CONNECTED) && - (g_strcmp0(session_get_account_name(), account->name) == 0)) { - GList *resources = connection_get_available_resources(); - GList *ordered_resources = NULL; + if ((connection_get_status() == JABBER_CONNECTED) && (g_strcmp0(session_get_account_name(), account->name) == 0)) { + GList* resources = connection_get_available_resources(); + GList* ordered_resources = NULL; - GList *curr = resources; + GList* curr = resources; if (curr) { win_println(console, THEME_DEFAULT, "-", "Resources:"); // sort in order of availability while (curr) { - Resource *resource = curr->data; + Resource* resource = curr->data; ordered_resources = g_list_insert_sorted(ordered_resources, - resource, (GCompareFunc)resource_compare_availability); + resource, (GCompareFunc)resource_compare_availability); curr = g_list_next(curr); } } @@ -996,8 +992,8 @@ cons_show_account(ProfAccount *account) curr = ordered_resources; while (curr) { - Resource *resource = curr->data; - const char *resource_presence = string_from_resource_presence(resource->presence); + Resource* resource = curr->data; + const char* resource_presence = string_from_resource_presence(resource->presence); theme_item_t presence_colour = theme_main_presence_attrs(resource_presence); win_print(console, presence_colour, "-", " %s (%d), %s", resource->name, resource->priority, resource_presence); @@ -1005,14 +1001,14 @@ cons_show_account(ProfAccount *account) win_append(console, presence_colour, ", \"%s\"", resource->status); } win_appendln(console, THEME_DEFAULT, ""); - Jid *jidp = jid_create_from_bare_and_resource(account->jid, resource->name); - EntityCapabilities *caps = caps_lookup(jidp->fulljid); + Jid* jidp = jid_create_from_bare_and_resource(account->jid, resource->name); + EntityCapabilities* caps = caps_lookup(jidp->fulljid); jid_destroy(jidp); if (caps) { // show identity if (caps->identity) { - DiscoIdentity *identity = caps->identity; + DiscoIdentity* identity = caps->identity; win_print(console, THEME_DEFAULT, "-", " Identity: "); if (identity->name) { win_append(console, THEME_DEFAULT, "%s", identity->name); @@ -1033,7 +1029,7 @@ cons_show_account(ProfAccount *account) } if (caps->software_version) { - SoftwareVersion *software_version = caps->software_version; + SoftwareVersion* software_version = caps->software_version; if (software_version->software) { win_print(console, THEME_DEFAULT, "-", " Software: %s", software_version->software); } @@ -1066,17 +1062,17 @@ cons_show_account(ProfAccount *account) } void -cons_show_aliases(GList *aliases) +cons_show_aliases(GList* aliases) { if (aliases == NULL) { cons_show("No aliases configured."); return; } - GList *curr = aliases; + GList* curr = aliases; cons_show("Command aliases:"); while (curr) { - ProfAlias *alias = curr->data; + ProfAlias* alias = curr->data; cons_show(" /%s -> %s", alias->name, alias->value); curr = g_list_next(curr); } @@ -1086,7 +1082,7 @@ cons_show_aliases(GList *aliases) void cons_theme_setting(void) { - char *theme = prefs_get_string(PREF_THEME); + char* theme = prefs_get_string(PREF_THEME); if (theme == NULL) { cons_show("Theme (/theme) : default"); } else { @@ -1180,15 +1176,15 @@ cons_titlebar_setting(void) void cons_console_setting(void) { - char *chatsetting = prefs_get_string(PREF_CONSOLE_CHAT); + char* chatsetting = prefs_get_string(PREF_CONSOLE_CHAT); cons_show("Console chat messages (/console) : %s", chatsetting); g_free(chatsetting); - char *mucsetting = prefs_get_string(PREF_CONSOLE_MUC); + char* mucsetting = prefs_get_string(PREF_CONSOLE_MUC); cons_show("Console MUC messages (/console) : %s", mucsetting); g_free(mucsetting); - char *privsetting = prefs_get_string(PREF_CONSOLE_PRIVATE); + char* privsetting = prefs_get_string(PREF_CONSOLE_PRIVATE); cons_show("Console private messages (/console) : %s", privsetting); g_free(privsetting); } @@ -1201,9 +1197,9 @@ cons_presence_setting(void) else cons_show("Titlebar presence (/presence) : OFF"); - char *console = prefs_get_string(PREF_STATUSES_CONSOLE); - char *chat = prefs_get_string(PREF_STATUSES_CHAT); - char *room = prefs_get_string(PREF_STATUSES_MUC); + char* console = prefs_get_string(PREF_STATUSES_CONSOLE); + char* chat = prefs_get_string(PREF_STATUSES_CHAT); + char* room = prefs_get_string(PREF_STATUSES_MUC); cons_show("Console presence (/presence) : %s", console); cons_show("Chat presence (/presence) : %s", chat); @@ -1303,7 +1299,7 @@ cons_rooms_cache_setting(void) void cons_autoconnect_setting(void) { - char *pref_connect_account = prefs_get_string(PREF_CONNECT_ACCOUNT); + char* pref_connect_account = prefs_get_string(PREF_CONNECT_ACCOUNT); if (pref_connect_account) cons_show("Autoconnect (/autoconnect) : %s", pref_connect_account); else @@ -1315,56 +1311,56 @@ cons_autoconnect_setting(void) void cons_time_setting(void) { - char *pref_time_console = prefs_get_string(PREF_TIME_CONSOLE); + char* pref_time_console = prefs_get_string(PREF_TIME_CONSOLE); if (g_strcmp0(pref_time_console, "off") == 0) cons_show("Time console (/time) : OFF"); else cons_show("Time console (/time) : %s", pref_time_console); g_free(pref_time_console); - char *pref_time_chat = prefs_get_string(PREF_TIME_CHAT); + char* pref_time_chat = prefs_get_string(PREF_TIME_CHAT); if (g_strcmp0(pref_time_chat, "off") == 0) cons_show("Time chat (/time) : OFF"); else cons_show("Time chat (/time) : %s", pref_time_chat); g_free(pref_time_chat); - char *pref_time_muc = prefs_get_string(PREF_TIME_MUC); + char* pref_time_muc = prefs_get_string(PREF_TIME_MUC); if (g_strcmp0(pref_time_muc, "off") == 0) cons_show("Time MUC (/time) : OFF"); else cons_show("Time MUC (/time) : %s", pref_time_muc); g_free(pref_time_muc); - char *pref_time_conf = prefs_get_string(PREF_TIME_CONFIG); + char* pref_time_conf = prefs_get_string(PREF_TIME_CONFIG); if (g_strcmp0(pref_time_conf, "off") == 0) cons_show("Time config (/time) : OFF"); else cons_show("Time config (/time) : %s", pref_time_conf); g_free(pref_time_conf); - char *pref_time_private = prefs_get_string(PREF_TIME_PRIVATE); + char* pref_time_private = prefs_get_string(PREF_TIME_PRIVATE); if (g_strcmp0(pref_time_private, "off") == 0) cons_show("Time private (/time) : OFF"); else cons_show("Time private (/time) : %s", pref_time_private); g_free(pref_time_private); - char *pref_time_xml = prefs_get_string(PREF_TIME_XMLCONSOLE); + char* pref_time_xml = prefs_get_string(PREF_TIME_XMLCONSOLE); if (g_strcmp0(pref_time_xml, "off") == 0) cons_show("Time XML Console (/time) : OFF"); else cons_show("Time XML Console (/time) : %s", pref_time_xml); g_free(pref_time_xml); - char *pref_time_statusbar = prefs_get_string(PREF_TIME_STATUSBAR); + char* pref_time_statusbar = prefs_get_string(PREF_TIME_STATUSBAR); if (g_strcmp0(pref_time_statusbar, "off") == 0) cons_show("Time statusbar (/time) : OFF"); else cons_show("Time statusbar (/time) : %s", pref_time_statusbar); g_free(pref_time_statusbar); - char *pref_time_lastactivity = prefs_get_string(PREF_TIME_LASTACTIVITY); + char* pref_time_lastactivity = prefs_get_string(PREF_TIME_LASTACTIVITY); cons_show("Time last activity (/time) : %s", pref_time_lastactivity); g_free(pref_time_lastactivity); } @@ -1491,7 +1487,7 @@ cons_roster_setting(void) else cons_show("Roster unsubscribed (/roster) : hide"); - char *count = prefs_get_string(PREF_ROSTER_COUNT); + char* count = prefs_get_string(PREF_ROSTER_COUNT); if (g_strcmp0(count, "off") == 0) { cons_show("Roster count (/roster) : OFF"); } else { @@ -1504,15 +1500,15 @@ cons_roster_setting(void) else cons_show("Roster count zero (/roster) : OFF"); - char *by = prefs_get_string(PREF_ROSTER_BY); + char* by = prefs_get_string(PREF_ROSTER_BY); cons_show("Roster by (/roster) : %s", by); g_free(by); - char *order = prefs_get_string(PREF_ROSTER_ORDER); + char* order = prefs_get_string(PREF_ROSTER_ORDER); cons_show("Roster order (/roster) : %s", order); g_free(order); - char *unread = prefs_get_string(PREF_ROSTER_UNREAD); + char* unread = prefs_get_string(PREF_ROSTER_UNREAD); if (g_strcmp0(unread, "before") == 0) { cons_show("Roster unread (/roster) : before"); } else if (g_strcmp0(unread, "after") == 0) { @@ -1527,7 +1523,7 @@ cons_roster_setting(void) else cons_show("Roster rooms (/roster) : hide"); - char *priv = prefs_get_string(PREF_ROSTER_PRIVATE); + char* priv = prefs_get_string(PREF_ROSTER_PRIVATE); if (g_strcmp0(priv, "room") == 0) { cons_show("Roster private (/roster) : room"); } else if (g_strcmp0(priv, "group") == 0) { @@ -1537,23 +1533,23 @@ cons_roster_setting(void) } g_free(priv); - char *rooms_pos = prefs_get_string(PREF_ROSTER_ROOMS_POS); + char* rooms_pos = prefs_get_string(PREF_ROSTER_ROOMS_POS); cons_show("Roster rooms position (/roster) : %s", rooms_pos); g_free(rooms_pos); - char *rooms_by = prefs_get_string(PREF_ROSTER_ROOMS_BY); + char* rooms_by = prefs_get_string(PREF_ROSTER_ROOMS_BY); cons_show("Roster rooms by (/roster) : %s", rooms_by); g_free(rooms_by); - char *rooms_use = prefs_get_string(PREF_ROSTER_ROOMS_USE_AS_NAME); + char* rooms_use = prefs_get_string(PREF_ROSTER_ROOMS_USE_AS_NAME); cons_show("Roster rooms use (/roster) : %s", rooms_use); g_free(rooms_use); - char *rooms_order = prefs_get_string(PREF_ROSTER_ROOMS_ORDER); + char* rooms_order = prefs_get_string(PREF_ROSTER_ROOMS_ORDER); cons_show("Roster rooms order (/roster) : %s", rooms_order); g_free(rooms_order); - char *roomsunread = prefs_get_string(PREF_ROSTER_ROOMS_UNREAD); + char* roomsunread = prefs_get_string(PREF_ROSTER_ROOMS_UNREAD); if (g_strcmp0(roomsunread, "before") == 0) { cons_show("Roster rooms unread (/roster) : before"); } else if (g_strcmp0(roomsunread, "after") == 0) { @@ -1768,7 +1764,6 @@ cons_receipts_setting(void) cons_show("Send receipts (/receipts) : ON"); else cons_show("Send receipts (/receipts) : OFF"); - } void @@ -1827,7 +1822,7 @@ cons_statusbar_setting(void) cons_show("Max tab length (/statusbar) : %d", pref_len); } - char *pref_self = prefs_get_string(PREF_STATUSBAR_SELF); + char* pref_self = prefs_get_string(PREF_STATUSBAR_SELF); if (g_strcmp0(pref_self, "off") == 0) { cons_show("Self statusbar display (/statusbar) : OFF"); } else { @@ -1835,11 +1830,11 @@ cons_statusbar_setting(void) } g_free(pref_self); - char *pref_chat = prefs_get_string(PREF_STATUSBAR_CHAT); + char* pref_chat = prefs_get_string(PREF_STATUSBAR_CHAT); cons_show("Chat tab display (/statusbar) : %s", pref_chat); g_free(pref_chat); - char *pref_room = prefs_get_string(PREF_STATUSBAR_ROOM); + char* pref_room = prefs_get_string(PREF_STATUSBAR_ROOM); cons_show("Room tab display (/statusbar) : %s", pref_room); g_free(pref_room); } @@ -1847,7 +1842,7 @@ cons_statusbar_setting(void) void cons_winpos_setting(void) { - ProfWinPlacement *placement = prefs_get_win_placement(); + ProfWinPlacement* placement = prefs_get_win_placement(); cons_show("Title bar postion (/titlebar) : %d", placement->titlebar_pos); cons_show("Main window postion (/mainwin) : %d", placement->mainwin_pos); cons_show("Status bar postion (/statusbar) : %d", placement->statusbar_pos); @@ -1900,7 +1895,7 @@ cons_show_log_prefs(void) void cons_autoaway_setting(void) { - char *pref_autoaway_mode = prefs_get_string(PREF_AUTOAWAY_MODE); + char* pref_autoaway_mode = prefs_get_string(PREF_AUTOAWAY_MODE); if (strcmp(pref_autoaway_mode, "off") == 0) { cons_show("Autoaway (/autoaway mode) : OFF"); } else { @@ -1924,7 +1919,7 @@ cons_autoaway_setting(void) cons_show("Autoaway xa minutes (/autoaway time) : %d minutes", xa_time); } - char *pref_autoaway_message = prefs_get_string(PREF_AUTOAWAY_MESSAGE); + char* pref_autoaway_message = prefs_get_string(PREF_AUTOAWAY_MESSAGE); if ((pref_autoaway_message == NULL) || (strcmp(pref_autoaway_message, "") == 0)) { cons_show("Autoaway away message (/autoaway message) : OFF"); } else { @@ -1932,7 +1927,7 @@ cons_autoaway_setting(void) } g_free(pref_autoaway_message); - char *pref_autoxa_message = prefs_get_string(PREF_AUTOXA_MESSAGE); + char* pref_autoxa_message = prefs_get_string(PREF_AUTOXA_MESSAGE); if ((pref_autoxa_message == NULL) || (strcmp(pref_autoxa_message, "") == 0)) { cons_show("Autoaway xa message (/autoaway message) : OFF"); } else { @@ -2001,7 +1996,7 @@ cons_autoping_setting(void) void cons_color_setting(void) { - char *color_pref = prefs_get_string(PREF_COLOR_NICK); + char* color_pref = prefs_get_string(PREF_COLOR_NICK); if (!color_pref) { cons_show("Consistent color generation for nicks (/color) : OFF"); @@ -2058,7 +2053,7 @@ cons_correction_setting(void) cons_show("Last Message Correction (XEP-0308) (/correction) : OFF"); } - char *cc = prefs_get_correction_char(); + char* cc = prefs_get_correction_char(); cons_show("LMC indication char (/correction char) : %s", cc); free(cc); } @@ -2066,17 +2061,17 @@ cons_correction_setting(void) void cons_executable_setting(void) { - char *avatar = prefs_get_string(PREF_AVATAR_CMD); + char* avatar = prefs_get_string(PREF_AVATAR_CMD); cons_show("Default '/avatar open' command (/executable avatar) : %s", avatar); g_free(avatar); //TODO: there needs to be a way to get all the "locales"/schemes so we can //display the defualt openers for all filetypes - gchar **urlopen = prefs_get_string_list_with_option(PREF_URL_OPEN_CMD, ""); + gchar** urlopen = prefs_get_string_list_with_option(PREF_URL_OPEN_CMD, ""); cons_show("Default '/url open' command (/executable urlopen) : %s", urlopen[1]); g_strfreev(urlopen); - char *urlsave = prefs_get_string(PREF_URL_SAVE_CMD); + char* urlsave = prefs_get_string(PREF_URL_SAVE_CMD); cons_show("Default '/url save' command (/executable urlsave) : %s", urlsave); g_free(urlsave); } @@ -2110,11 +2105,11 @@ cons_show_otr_prefs(void) cons_show("OTR preferences:"); cons_show(""); - char *policy_value = prefs_get_string(PREF_OTR_POLICY); + char* policy_value = prefs_get_string(PREF_OTR_POLICY); cons_show("OTR policy (/otr policy) : %s", policy_value); g_free(policy_value); - char *log_value = prefs_get_string(PREF_OTR_LOG); + char* log_value = prefs_get_string(PREF_OTR_LOG); if (strcmp(log_value, "on") == 0) { cons_show("OTR logging (/otr log) : ON"); } else if (strcmp(log_value, "off") == 0) { @@ -2124,7 +2119,7 @@ cons_show_otr_prefs(void) } g_free(log_value); - char *ch = prefs_get_otr_char(); + char* ch = prefs_get_otr_char(); cons_show("OTR char (/otr char) : %s", ch); free(ch); @@ -2143,7 +2138,7 @@ cons_show_pgp_prefs(void) cons_show("PGP preferences:"); cons_show(""); - char *log_value = prefs_get_string(PREF_PGP_LOG); + char* log_value = prefs_get_string(PREF_PGP_LOG); if (strcmp(log_value, "on") == 0) { cons_show("PGP logging (/pgp log) : ON"); } else if (strcmp(log_value, "off") == 0) { @@ -2153,7 +2148,7 @@ cons_show_pgp_prefs(void) } g_free(log_value); - char *ch = prefs_get_pgp_char(); + char* ch = prefs_get_pgp_char(); cons_show("PGP char (/pgp char) : %s", ch); free(ch); @@ -2172,11 +2167,11 @@ cons_show_omemo_prefs(void) cons_show("OMEMO preferences:"); cons_show(""); - char *policy_value = prefs_get_string(PREF_OMEMO_POLICY); + char* policy_value = prefs_get_string(PREF_OMEMO_POLICY); cons_show("OMEMO policy (/omemo policy) : %s", policy_value); g_free(policy_value); - char *log_value = prefs_get_string(PREF_OMEMO_LOG); + char* log_value = prefs_get_string(PREF_OMEMO_LOG); if (strcmp(log_value, "on") == 0) { cons_show("OMEMO logging (/omemo log) : ON"); } else if (strcmp(log_value, "off") == 0) { @@ -2186,7 +2181,7 @@ cons_show_omemo_prefs(void) } g_free(log_value); - char *ch = prefs_get_omemo_char(); + char* ch = prefs_get_omemo_char(); cons_show("OMEMO char (/omemo char) : %s", ch); free(ch); @@ -2200,7 +2195,7 @@ cons_show_omemo_prefs(void) } void -cons_show_themes(GSList *themes) +cons_show_themes(GSList* themes) { cons_show(""); @@ -2218,7 +2213,7 @@ cons_show_themes(GSList *themes) } void -cons_show_scripts(GSList *scripts) +cons_show_scripts(GSList* scripts) { cons_show(""); @@ -2236,7 +2231,7 @@ cons_show_scripts(GSList *scripts) } void -cons_show_script(const char *const script, GSList *commands) +cons_show_script(const char* const script, GSList* commands) { cons_show(""); @@ -2306,7 +2301,7 @@ cons_help(void) void cons_navigation_help(void) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); cons_show(""); win_println(console, THEME_HELP_HEADER, "-", "Navigation"); cons_show("Alt-1..Alt-0, F1..F10 : Choose window."); @@ -2323,7 +2318,7 @@ cons_navigation_help(void) } void -cons_show_roster_group(const char *const group, GSList *list) +cons_show_roster_group(const char* const group, GSList* list) { cons_show(""); @@ -2339,7 +2334,7 @@ cons_show_roster_group(const char *const group, GSList *list) } void -cons_show_roster(GSList *list) +cons_show_roster(GSList* list) { cons_show(""); cons_show("Roster: jid (nick) - subscription - groups"); @@ -2350,39 +2345,38 @@ cons_show_roster(GSList *list) } void -cons_show_contact_online(PContact contact, Resource *resource, GDateTime *last_activity) +cons_show_contact_online(PContact contact, Resource* resource, GDateTime* last_activity) { - const char *show = string_from_resource_presence(resource->presence); - char *display_str = p_contact_create_display_string(contact, resource->name); + const char* show = string_from_resource_presence(resource->presence); + char* display_str = p_contact_create_display_string(contact, resource->name); - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); win_show_status_string(console, display_str, show, resource->status, last_activity, - "++", "online"); + "++", "online"); free(display_str); } void -cons_show_contact_offline(PContact contact, char *resource, char *status) +cons_show_contact_offline(PContact contact, char* resource, char* status) { - char *display_str = p_contact_create_display_string(contact, resource); + char* display_str = p_contact_create_display_string(contact, resource); - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); win_show_status_string(console, display_str, "offline", status, NULL, "--", - "offline"); + "offline"); free(display_str); } void -cons_show_contacts(GSList *list) +cons_show_contacts(GSList* list) { - ProfWin *console = wins_get_console(); - GSList *curr = list; + ProfWin* console = wins_get_console(); + GSList* curr = list; - while(curr) { + while (curr) { PContact contact = curr->data; - if ((strcmp(p_contact_subscription(contact), "to") == 0) || - (strcmp(p_contact_subscription(contact), "both") == 0)) { + if ((strcmp(p_contact_subscription(contact), "to") == 0) || (strcmp(p_contact_subscription(contact), "both") == 0)) { win_show_contact(console, contact); } curr = g_slist_next(curr); @@ -2393,14 +2387,14 @@ cons_show_contacts(GSList *list) void cons_alert(void) { - ProfWin *current = wins_get_current(); + ProfWin* current = wins_get_current(); if (current->type != WIN_CONSOLE) { status_bar_new(1, WIN_CONSOLE, "console"); } } char* -cons_get_string(ProfConsoleWin *conswin) +cons_get_string(ProfConsoleWin* conswin) { assert(conswin != NULL); @@ -2408,17 +2402,17 @@ cons_get_string(ProfConsoleWin *conswin) } void -_cons_theme_bar_prop(theme_item_t theme, char *prop) +_cons_theme_bar_prop(theme_item_t theme, char* prop) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); - GString *propstr = g_string_new(" "); + GString* propstr = g_string_new(" "); g_string_append_printf(propstr, "%-24s", prop); win_print(console, THEME_TEXT, "-", "%s", propstr->str); g_string_free(propstr, TRUE); - GString *valstr = g_string_new(" "); - char *setting = theme_get_string(prop); + GString* valstr = g_string_new(" "); + char* setting = theme_get_string(prop); g_string_append_printf(valstr, "%s ", setting); theme_free_string(setting); win_append(console, theme, "%s", valstr->str); @@ -2427,17 +2421,17 @@ _cons_theme_bar_prop(theme_item_t theme, char *prop) } void -_cons_theme_prop(theme_item_t theme, char *prop) +_cons_theme_prop(theme_item_t theme, char* prop) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); - GString *propstr = g_string_new(" "); + GString* propstr = g_string_new(" "); g_string_append_printf(propstr, "%-24s", prop); win_print(console, THEME_TEXT, "-", "%s", propstr->str); g_string_free(propstr, TRUE); - GString *valstr = g_string_new(""); - char *setting = theme_get_string(prop); + GString* valstr = g_string_new(""); + char* setting = theme_get_string(prop); g_string_append_printf(valstr, "%s", setting); theme_free_string(setting); win_appendln(console, theme, "%s", valstr->str); @@ -2558,32 +2552,32 @@ cons_theme_colours(void) */ - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); cons_show("Available colours:"); - win_print(console, THEME_WHITE, "-", " white "); - win_appendln(console, THEME_WHITE_BOLD, " bold_white"); + win_print(console, THEME_WHITE, "-", " white "); + win_appendln(console, THEME_WHITE_BOLD, " bold_white"); - win_print(console, THEME_GREEN, "-", " green "); - win_appendln(console, THEME_GREEN_BOLD, " bold_green"); + win_print(console, THEME_GREEN, "-", " green "); + win_appendln(console, THEME_GREEN_BOLD, " bold_green"); - win_print(console, THEME_RED, "-", " red "); - win_appendln(console, THEME_RED_BOLD, " bold_red"); + win_print(console, THEME_RED, "-", " red "); + win_appendln(console, THEME_RED_BOLD, " bold_red"); - win_print(console, THEME_YELLOW, "-", " yellow "); - win_appendln(console, THEME_YELLOW_BOLD, " bold_yellow"); + win_print(console, THEME_YELLOW, "-", " yellow "); + win_appendln(console, THEME_YELLOW_BOLD, " bold_yellow"); - win_print(console, THEME_BLUE, "-", " blue "); - win_appendln(console, THEME_BLUE_BOLD, " bold_blue"); + win_print(console, THEME_BLUE, "-", " blue "); + win_appendln(console, THEME_BLUE_BOLD, " bold_blue"); - win_print(console, THEME_CYAN, "-", " cyan "); - win_appendln(console, THEME_CYAN_BOLD, " bold_cyan"); + win_print(console, THEME_CYAN, "-", " cyan "); + win_appendln(console, THEME_CYAN_BOLD, " bold_cyan"); - win_print(console, THEME_MAGENTA, "-", " magenta "); - win_appendln(console, THEME_MAGENTA_BOLD, " bold_magenta"); + win_print(console, THEME_MAGENTA, "-", " magenta "); + win_appendln(console, THEME_MAGENTA_BOLD, " bold_magenta"); - win_print(console, THEME_BLACK, "-", " black "); - win_appendln(console, THEME_BLACK_BOLD, " bold_black"); + win_print(console, THEME_BLACK, "-", " black "); + win_appendln(console, THEME_BLACK_BOLD, " bold_black"); if (COLORS >= 256) { cons_show("Your terminal supports 256 colours."); @@ -2598,7 +2592,7 @@ cons_theme_colours(void) static void _cons_splash_logo(void) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); win_println(console, THEME_DEFAULT, "-", "Welcome to"); win_println(console, THEME_SPLASH, "-", " ___ _ "); @@ -2622,14 +2616,14 @@ _cons_splash_logo(void) } void -_show_roster_contacts(GSList *list, gboolean show_groups) +_show_roster_contacts(GSList* list, gboolean show_groups) { - ProfWin *console = wins_get_console(); - GSList *curr = list; - while(curr) { + ProfWin* console = wins_get_console(); + GSList* curr = list; + while (curr) { PContact contact = curr->data; - GString *title = g_string_new(" "); + GString* title = g_string_new(" "); title = g_string_append(title, p_contact_barejid(contact)); if (p_contact_name(contact)) { title = g_string_append(title, " ("); @@ -2637,7 +2631,7 @@ _show_roster_contacts(GSList *list, gboolean show_groups) title = g_string_append(title, ")"); } - const char *presence = p_contact_presence(contact); + const char* presence = p_contact_presence(contact); theme_item_t presence_colour = THEME_TEXT; if (p_contact_subscribed(contact)) { presence_colour = theme_main_presence_attrs(presence); @@ -2649,7 +2643,7 @@ _show_roster_contacts(GSList *list, gboolean show_groups) g_string_free(title, TRUE); win_append(console, THEME_DEFAULT, " - "); - GString *sub = g_string_new(""); + GString* sub = g_string_new(""); sub = g_string_append(sub, p_contact_subscription(contact)); if (p_contact_pending_out(contact)) { sub = g_string_append(sub, ", request sent"); @@ -2672,9 +2666,9 @@ _show_roster_contacts(GSList *list, gboolean show_groups) g_string_free(sub, TRUE); if (show_groups) { - GSList *groups = p_contact_groups(contact); + GSList* groups = p_contact_groups(contact); if (groups) { - GString *groups_str = g_string_new(" - "); + GString* groups_str = g_string_new(" - "); while (groups) { g_string_append(groups_str, groups->data); if (g_slist_next(groups)) { @@ -2694,7 +2688,7 @@ _show_roster_contacts(GSList *list, gboolean show_groups) } void -cons_show_bookmarks_ignore(gchar **list, gsize len) +cons_show_bookmarks_ignore(gchar** list, gsize len) { if (len == 0) { cons_show(""); @@ -2703,12 +2697,12 @@ cons_show_bookmarks_ignore(gchar **list, gsize len) } int i; - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); cons_show(""); cons_show("Ignored bookmarks:"); - for(i=0; i<len; i++) { + for (i = 0; i < len; i++) { win_print(console, THEME_DEFAULT, "-", " %s", list[i]); win_newline(console); } diff --git a/src/ui/core.c b/src/ui/core.c index b2256c56..e61de7e7 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -80,13 +80,13 @@ #include "otr/otr.h" #endif -static char *win_title; +static char* win_title; static int inp_size; static gboolean perform_resize = FALSE; -static GTimer *ui_idle_time; +static GTimer* ui_idle_time; #ifdef HAVE_LIBXSS -static Display *display; +static Display* display; #endif static void _ui_draw_term_title(void); @@ -114,7 +114,7 @@ ui_init(void) #endif ui_idle_time = g_timer_new(); inp_size = 0; - ProfWin *window = wins_get_current(); + ProfWin* window = wins_get_current(); win_update_virtual(window); } @@ -127,7 +127,7 @@ ui_sigwinch_handler(int sig) void ui_update(void) { - ProfWin *current = wins_get_current(); + ProfWin* current = wins_get_current(); if (current->layout->paged == 0) { win_move_to_end(current); } @@ -155,7 +155,7 @@ ui_get_idle_time(void) { // if compiled with libxss, get the x sessions idle time #ifdef HAVE_LIBXSS - XScreenSaverInfo *info = XScreenSaverAllocInfo(); + XScreenSaverInfo* info = XScreenSaverAllocInfo(); if (info && display) { XScreenSaverQueryInfo(display, DefaultRootWindow(display), info); unsigned long result = info->idle; @@ -202,7 +202,7 @@ ui_resize(void) wins_resize_all(); status_bar_resize(); inp_win_resize(); - ProfWin *window = wins_get_current(); + ProfWin* window = wins_get_current(); win_update_virtual(window); } @@ -226,10 +226,10 @@ ui_load_colours(void) } void -ui_contact_online(char *barejid, Resource *resource, GDateTime *last_activity) +ui_contact_online(char* barejid, Resource* resource, GDateTime* last_activity) { - char *show_console = prefs_get_string(PREF_STATUSES_CONSOLE); - char *show_chat_win = prefs_get_string(PREF_STATUSES_CHAT); + char* show_console = prefs_get_string(PREF_STATUSES_CONSOLE); + char* show_chat_win = prefs_get_string(PREF_STATUSES_CHAT); PContact contact = roster_get_contact(barejid); // show nothing @@ -243,21 +243,21 @@ ui_contact_online(char *barejid, Resource *resource, GDateTime *last_activity) if (g_strcmp0(show_console, "all") == 0) { cons_show_contact_online(contact, resource, last_activity); - // show in console of "online" and presence online + // show in console of "online" and presence online } else if (g_strcmp0(show_console, "online") == 0 && resource->presence == RESOURCE_ONLINE) { cons_show_contact_online(contact, resource, last_activity); } // show in chat win if "all" if (g_strcmp0(show_chat_win, "all") == 0) { - ProfChatWin *chatwin = wins_get_chat(barejid); + ProfChatWin* chatwin = wins_get_chat(barejid); if (chatwin) { chatwin_contact_online(chatwin, resource, last_activity); } - // show in char win if "online" and presence online + // show in char win if "online" and presence online } else if (g_strcmp0(show_chat_win, "online") == 0 && resource->presence == RESOURCE_ONLINE) { - ProfChatWin *chatwin = wins_get_chat(barejid); + ProfChatWin* chatwin = wins_get_chat(barejid); if (chatwin) { chatwin_contact_online(chatwin, resource, last_activity); } @@ -268,28 +268,28 @@ ui_contact_online(char *barejid, Resource *resource, GDateTime *last_activity) } void -ui_contact_typing(const char *const barejid, const char *const resource) +ui_contact_typing(const char* const barejid, const char* const resource) { - ProfChatWin *chatwin = wins_get_chat(barejid); - ProfWin *window = (ProfWin*) chatwin; - ChatSession *session = chat_session_get(barejid); + ProfChatWin* chatwin = wins_get_chat(barejid); + ProfWin* window = (ProfWin*)chatwin; + ChatSession* session = chat_session_get(barejid); if (prefs_get_boolean(PREF_INTYPE)) { // no chat window for user if (chatwin == NULL) { cons_show_typing(barejid); - // have chat window but not currently in it + // have chat window but not currently in it } else if (!wins_is_current(window)) { cons_show_typing(barejid); - // in chat window with user, no session or session with resource + // in chat window with user, no session or session with resource } else if (!session || (session && g_strcmp0(session->resource, resource) == 0)) { title_bar_set_typing(TRUE); int num = wins_get_num(window); status_bar_active(num, WIN_CHAT, chatwin->barejid); - } + } } if (prefs_get_boolean(PREF_NOTIFY_TYPING)) { @@ -297,9 +297,9 @@ ui_contact_typing(const char *const barejid, const char *const resource) if (window) { is_current = wins_is_current(window); } - if ( !is_current || (is_current && prefs_get_boolean(PREF_NOTIFY_TYPING_CURRENT)) ) { + if (!is_current || (is_current && prefs_get_boolean(PREF_NOTIFY_TYPING_CURRENT))) { PContact contact = roster_get_contact(barejid); - char const *display_usr = NULL; + char const* display_usr = NULL; if (contact) { if (p_contact_name(contact)) { display_usr = p_contact_name(contact); @@ -315,7 +315,7 @@ ui_contact_typing(const char *const barejid, const char *const resource) } void -ui_roster_add(const char *const barejid, const char *const name) +ui_roster_add(const char* const barejid, const char* const name) { if (name) { cons_show("Roster item added: %s (%s)", barejid, name); @@ -326,42 +326,42 @@ ui_roster_add(const char *const barejid, const char *const name) } void -ui_roster_remove(const char *const barejid) +ui_roster_remove(const char* const barejid) { cons_show("Roster item removed: %s", barejid); rosterwin_roster(); } void -ui_contact_already_in_group(const char *const contact, const char *const group) +ui_contact_already_in_group(const char* const contact, const char* const group) { cons_show("%s already in group %s", contact, group); rosterwin_roster(); } void -ui_contact_not_in_group(const char *const contact, const char *const group) +ui_contact_not_in_group(const char* const contact, const char* const group) { cons_show("%s is not currently in group %s", contact, group); rosterwin_roster(); } void -ui_group_added(const char *const contact, const char *const group) +ui_group_added(const char* const contact, const char* const group) { cons_show("%s added to group %s", contact, group); rosterwin_roster(); } void -ui_group_removed(const char *const contact, const char *const group) +ui_group_removed(const char* const contact, const char* const group) { cons_show("%s removed from group %s", contact, group); rosterwin_roster(); } void -ui_handle_login_account_success(ProfAccount *account, gboolean secured) +ui_handle_login_account_success(ProfAccount* account, gboolean secured) { if (account->theme) { if (theme_load(account->theme, false)) { @@ -394,7 +394,7 @@ ui_handle_login_account_success(ProfAccount *account, gboolean secured) void ui_update_presence(const resource_presence_t resource_presence, - const char *const message, const char *const show) + const char* const message, const char* const show) { contact_presence_t contact_presence = contact_presence_from_resource_presence(resource_presence); title_bar_set_presence(contact_presence); @@ -407,24 +407,24 @@ ui_update_presence(const resource_presence_t resource_presence, } void -ui_handle_recipient_error(const char *const recipient, const char *const err_msg) +ui_handle_recipient_error(const char* const recipient, const char* const err_msg) { // always show in console cons_show_error("Error from %s: %s", recipient, err_msg); - ProfChatWin *chatwin = wins_get_chat(recipient); + ProfChatWin* chatwin = wins_get_chat(recipient); if (chatwin) { win_println((ProfWin*)chatwin, THEME_ERROR, "!", "Error from %s: %s", recipient, err_msg); return; } - ProfMucWin *mucwin = wins_get_muc(recipient); + ProfMucWin* mucwin = wins_get_muc(recipient); if (mucwin) { win_println((ProfWin*)mucwin, THEME_ERROR, "!", "Error from %s: %s", recipient, err_msg); return; } - ProfPrivateWin *privatewin = wins_get_private(recipient); + ProfPrivateWin* privatewin = wins_get_private(recipient); if (privatewin) { win_println((ProfWin*)privatewin, THEME_ERROR, "!", "Error from %s: %s", recipient, err_msg); return; @@ -432,9 +432,9 @@ ui_handle_recipient_error(const char *const recipient, const char *const err_msg } void -ui_handle_otr_error(const char *const barejid, const char *const message) +ui_handle_otr_error(const char* const barejid, const char* const message) { - ProfChatWin *chatwin = wins_get_chat(barejid); + ProfChatWin* chatwin = wins_get_chat(barejid); if (chatwin) { win_println((ProfWin*)chatwin, THEME_ERROR, "!", "%s", message); } else { @@ -443,9 +443,9 @@ ui_handle_otr_error(const char *const barejid, const char *const message) } void -ui_handle_error(const char *const err_msg) +ui_handle_error(const char* const err_msg) { - GString *msg = g_string_new(""); + GString* msg = g_string_new(""); g_string_printf(msg, "Error %s", err_msg); cons_show_error(msg->str); @@ -454,9 +454,9 @@ ui_handle_error(const char *const err_msg) } void -ui_invalid_command_usage(const char *const cmd, void (*setting_func)(void)) +ui_invalid_command_usage(const char* const cmd, void (*setting_func)(void)) { - GString *msg = g_string_new(""); + GString* msg = g_string_new(""); g_string_printf(msg, "Invalid usage, see '/help %s' for details.", &cmd[1]); if (setting_func) { @@ -465,7 +465,7 @@ ui_invalid_command_usage(const char *const cmd, void (*setting_func)(void)) } else { cons_show(""); cons_show(msg->str); - ProfWin *current = wins_get_current(); + ProfWin* current = wins_get_current(); if (current->type == WIN_CHAT) { win_println(current, THEME_DEFAULT, "-", "%s", msg->str); } @@ -488,16 +488,16 @@ ui_disconnected(void) void ui_close_connected_win(int index) { - ProfWin *window = wins_get_by_num(index); + ProfWin* window = wins_get_by_num(index); if (window) { if (window->type == WIN_MUC) { - ProfMucWin *mucwin = (ProfMucWin*) window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); presence_leave_chat_room(mucwin->roomjid); muc_leave(mucwin->roomjid); ui_leave_room(mucwin->roomjid); } else if (window->type == WIN_CHAT) { - ProfChatWin *chatwin = (ProfChatWin*) window; + ProfChatWin* chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); #ifdef HAVE_LIBOTR if (chatwin->is_otr) { @@ -516,8 +516,8 @@ ui_close_all_wins(void) int count = 0; jabber_conn_status_t conn_status = connection_get_status(); - GList *win_nums = wins_get_nums(); - GList *curr = win_nums; + GList* win_nums = wins_get_nums(); + GList* curr = win_nums; while (curr) { int num = GPOINTER_TO_INT(curr->data); @@ -543,8 +543,8 @@ ui_close_read_wins(void) int count = 0; jabber_conn_status_t conn_status = connection_get_status(); - GList *win_nums = wins_get_nums(); - GList *curr = win_nums; + GList* win_nums = wins_get_nums(); + GList* curr = win_nums; while (curr) { int num = GPOINTER_TO_INT(curr->data); @@ -567,14 +567,14 @@ ui_close_read_wins(void) void ui_redraw_all_room_rosters(void) { - GList *win_nums = wins_get_nums(); - GList *curr = win_nums; + GList* win_nums = wins_get_nums(); + GList* curr = win_nums; while (curr) { int num = GPOINTER_TO_INT(curr->data); - ProfWin *window = wins_get_by_num(num); + ProfWin* window = wins_get_by_num(num); if (window->type == WIN_MUC && win_has_active_subwin(window)) { - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); occupantswin_occupants(mucwin->roomjid); } @@ -588,14 +588,14 @@ ui_redraw_all_room_rosters(void) void ui_hide_all_room_rosters(void) { - GList *win_nums = wins_get_nums(); - GList *curr = win_nums; + GList* win_nums = wins_get_nums(); + GList* curr = win_nums; while (curr) { int num = GPOINTER_TO_INT(curr->data); - ProfWin *window = wins_get_by_num(num); + ProfWin* window = wins_get_by_num(num); if (window->type == WIN_MUC && win_has_active_subwin(window)) { - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); mucwin_hide_occupants(mucwin); } @@ -609,14 +609,14 @@ ui_hide_all_room_rosters(void) void ui_show_all_room_rosters(void) { - GList *win_nums = wins_get_nums(); - GList *curr = win_nums; + GList* win_nums = wins_get_nums(); + GList* curr = win_nums; while (curr) { int num = GPOINTER_TO_INT(curr->data); - ProfWin *window = wins_get_by_num(num); + ProfWin* window = wins_get_by_num(num); if (window->type == WIN_MUC && !win_has_active_subwin(window)) { - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); mucwin_show_occupants(mucwin); } @@ -630,10 +630,10 @@ ui_show_all_room_rosters(void) gboolean ui_win_has_unsaved_form(int num) { - ProfWin *window = wins_get_by_num(num); + ProfWin* window = wins_get_by_num(num); if (window->type == WIN_CONFIG) { - ProfConfWin *confwin = (ProfConfWin*)window; + ProfConfWin* confwin = (ProfConfWin*)window; assert(confwin->memcheck == PROFCONFWIN_MEMCHECK); return confwin->form->modified; } else { @@ -642,7 +642,7 @@ ui_win_has_unsaved_form(int num) } void -ui_focus_win(ProfWin *window) +ui_focus_win(ProfWin* window) { assert(window != NULL); @@ -650,35 +650,34 @@ ui_focus_win(ProfWin *window) return; } - ProfWin *old_current = wins_get_current(); + ProfWin* old_current = wins_get_current(); if (old_current->type == WIN_CONFIG) { - ProfConfWin *confwin = (ProfConfWin*)old_current; + ProfConfWin* confwin = (ProfConfWin*)old_current; cmd_ac_remove_form_fields(confwin->form); } if (window->type == WIN_CONFIG) { - ProfConfWin *confwin = (ProfConfWin*)window; + ProfConfWin* confwin = (ProfConfWin*)window; cmd_ac_add_form_fields(confwin->form); } // check for trackbar last position separator - switch (old_current->type) - { + switch (old_current->type) { case WIN_CHAT: { - ProfChatWin *chatwin = (ProfChatWin*)old_current; + ProfChatWin* chatwin = (ProfChatWin*)old_current; win_remove_entry_message(old_current, chatwin->barejid); break; } case WIN_MUC: { - ProfMucWin *mucwin = (ProfMucWin*)old_current; + ProfMucWin* mucwin = (ProfMucWin*)old_current; win_remove_entry_message(old_current, mucwin->roomjid); break; } case WIN_PRIVATE: { - ProfPrivateWin *privwin = (ProfPrivateWin*)old_current; + ProfPrivateWin* privwin = (ProfPrivateWin*)old_current; win_remove_entry_message(old_current, privwin->fulljid); break; } @@ -697,7 +696,7 @@ ui_focus_win(ProfWin *window) } status_bar_current(i); - char *identifier = win_get_tab_identifier(window); + char* identifier = win_get_tab_identifier(window); status_bar_active(i, window->type, identifier); free(identifier); } @@ -705,9 +704,9 @@ ui_focus_win(ProfWin *window) void ui_close_win(int index) { - ProfWin *window = wins_get_by_num(index); + ProfWin* window = wins_get_by_num(index); if (window && window->type == WIN_CONFIG) { - ProfConfWin *confwin = (ProfConfWin*)window; + ProfConfWin* confwin = (ProfConfWin*)window; if (confwin->form) { cmd_ac_remove_form_fields(confwin->form); } @@ -725,17 +724,17 @@ ui_prune_wins(void) jabber_conn_status_t conn_status = connection_get_status(); gboolean pruned = FALSE; - GSList *wins = wins_get_prune_wins(); + GSList* wins = wins_get_prune_wins(); if (wins) { pruned = TRUE; } - GSList *curr = wins; + GSList* curr = wins; while (curr) { - ProfWin *window = curr->data; + ProfWin* window = curr->data; if (window->type == WIN_CHAT) { if (conn_status == JABBER_CONNECTED) { - ProfChatWin *chatwin = (ProfChatWin*)window; + ProfChatWin* chatwin = (ProfChatWin*)window; chat_session_remove(chatwin->barejid); } } @@ -759,13 +758,13 @@ ui_prune_wins(void) } void -ui_print_system_msg_from_recipient(const char *const barejid, const char *message) +ui_print_system_msg_from_recipient(const char* const barejid, const char* message) { if (barejid == NULL || message == NULL) return; - ProfChatWin *chatwin = wins_get_chat(barejid); - ProfWin *window = (ProfWin*)chatwin; + ProfChatWin* chatwin = wins_get_chat(barejid); + ProfWin* window = (ProfWin*)chatwin; if (window == NULL) { window = wins_new_chat(barejid); if (window) { @@ -782,19 +781,19 @@ ui_print_system_msg_from_recipient(const char *const barejid, const char *messag } void -ui_room_join(const char *const roomjid, gboolean focus) +ui_room_join(const char* const roomjid, gboolean focus) { - ProfMucWin *mucwin = wins_get_muc(roomjid); + ProfMucWin* mucwin = wins_get_muc(roomjid); if (mucwin == NULL) { mucwin = mucwin_new(roomjid); } - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; - char *nick = muc_nick(roomjid); + char* nick = muc_nick(roomjid); win_print(window, THEME_ROOMINFO, "!", "-> You have joined the room as %s", nick); if (prefs_get_boolean(PREF_MUC_PRIVILEGES)) { - char *role = muc_role_str(roomjid); - char *affiliation = muc_affiliation_str(roomjid); + char* role = muc_role_str(roomjid); + char* affiliation = muc_affiliation_str(roomjid); if (role) { win_append(window, THEME_ROOMINFO, ", role: %s", role); } @@ -809,14 +808,14 @@ ui_room_join(const char *const roomjid, gboolean focus) } else { int num = wins_get_num(window); status_bar_active(num, WIN_MUC, mucwin->roomjid); - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); win_println(console, THEME_TYPING, "!", "-> Autojoined %s as %s (%d).", roomjid, nick, num); } - GList *privwins = wins_get_private_chats(roomjid); - GList *curr = privwins; + GList* privwins = wins_get_private_chats(roomjid); + GList* curr = privwins; while (curr) { - ProfPrivateWin *privwin = curr->data; + ProfPrivateWin* privwin = curr->data; privwin_room_joined(privwin); curr = g_list_next(curr); } @@ -824,17 +823,17 @@ ui_room_join(const char *const roomjid, gboolean focus) } void -ui_switch_to_room(const char *const roomjid) +ui_switch_to_room(const char* const roomjid) { - ProfWin *window = (ProfWin*)wins_get_muc(roomjid); + ProfWin* window = (ProfWin*)wins_get_muc(roomjid); ui_focus_win(window); } void -ui_room_destroy(const char *const roomjid) +ui_room_destroy(const char* const roomjid) { - ProfWin *window = (ProfWin*)wins_get_muc(roomjid); - GList *privwins = wins_get_private_chats(roomjid); + ProfWin* window = (ProfWin*)wins_get_muc(roomjid); + GList* privwins = wins_get_private_chats(roomjid); if (window == NULL) { log_error("Received room destroy result, but no window open for %s.", roomjid); } else { @@ -843,9 +842,9 @@ ui_room_destroy(const char *const roomjid) cons_show("Room destroyed: %s", roomjid); } - GList *curr = privwins; + GList* curr = privwins; while (curr) { - ProfPrivateWin *privwin = curr->data; + ProfPrivateWin* privwin = curr->data; privwin_room_destroyed(privwin); curr = g_list_next(curr); } @@ -853,37 +852,36 @@ ui_room_destroy(const char *const roomjid) } void -ui_leave_room(const char *const roomjid) +ui_leave_room(const char* const roomjid) { - ProfWin *window = (ProfWin*)wins_get_muc(roomjid); - GList *privwins = wins_get_private_chats(roomjid); + ProfWin* window = (ProfWin*)wins_get_muc(roomjid); + GList* privwins = wins_get_private_chats(roomjid); if (window) { int num = wins_get_num(window); ui_close_win(num); } - GList *curr = privwins; + GList* curr = privwins; while (curr) { - ProfPrivateWin *privwin = curr->data; + ProfPrivateWin* privwin = curr->data; privwin_room_left(privwin); curr = g_list_next(curr); } g_list_free(privwins); - } void -ui_room_destroyed(const char *const roomjid, const char *const reason, const char *const new_jid, - const char *const password) +ui_room_destroyed(const char* const roomjid, const char* const reason, const char* const new_jid, + const char* const password) { - ProfWin *window = (ProfWin*)wins_get_muc(roomjid); - GList *privwins = wins_get_private_chats(roomjid); + ProfWin* window = (ProfWin*)wins_get_muc(roomjid); + GList* privwins = wins_get_private_chats(roomjid); if (window == NULL) { log_error("Received room destroy, but no window open for %s.", roomjid); } else { int num = wins_get_num(window); ui_close_win(num); - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); if (reason) { win_println(console, THEME_TYPING, "!", "<- Room destroyed: %s, reason: %s", roomjid, reason); @@ -900,9 +898,9 @@ ui_room_destroyed(const char *const roomjid, const char *const reason, const cha } } - GList *curr = privwins; + GList* curr = privwins; while (curr) { - ProfPrivateWin *privwin = curr->data; + ProfPrivateWin* privwin = curr->data; privwin_room_destroyed(privwin); curr = g_list_next(curr); } @@ -910,17 +908,17 @@ ui_room_destroyed(const char *const roomjid, const char *const reason, const cha } void -ui_room_kicked(const char *const roomjid, const char *const actor, const char *const reason) +ui_room_kicked(const char* const roomjid, const char* const actor, const char* const reason) { - ProfWin *window = (ProfWin*)wins_get_muc(roomjid); - GList *privwins = wins_get_private_chats(roomjid); + ProfWin* window = (ProfWin*)wins_get_muc(roomjid); + GList* privwins = wins_get_private_chats(roomjid); if (window == NULL) { log_error("Received kick, but no window open for %s.", roomjid); } else { int num = wins_get_num(window); ui_close_win(num); - GString *message = g_string_new("Kicked from "); + GString* message = g_string_new("Kicked from "); g_string_append(message, roomjid); if (actor) { g_string_append(message, " by "); @@ -931,14 +929,14 @@ ui_room_kicked(const char *const roomjid, const char *const actor, const char *c g_string_append(message, reason); } - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); win_println(console, THEME_TYPING, "!", "<- %s", message->str); g_string_free(message, TRUE); } - GList *curr = privwins; + GList* curr = privwins; while (curr) { - ProfPrivateWin *privwin = curr->data; + ProfPrivateWin* privwin = curr->data; privwin_room_kicked(privwin, actor, reason); curr = g_list_next(curr); } @@ -946,17 +944,17 @@ ui_room_kicked(const char *const roomjid, const char *const actor, const char *c } void -ui_room_banned(const char *const roomjid, const char *const actor, const char *const reason) +ui_room_banned(const char* const roomjid, const char* const actor, const char* const reason) { - ProfWin *window = (ProfWin*)wins_get_muc(roomjid); - GList *privwins = wins_get_private_chats(roomjid); + ProfWin* window = (ProfWin*)wins_get_muc(roomjid); + GList* privwins = wins_get_private_chats(roomjid); if (window == NULL) { log_error("Received ban, but no window open for %s.", roomjid); } else { int num = wins_get_num(window); ui_close_win(num); - GString *message = g_string_new("Banned from "); + GString* message = g_string_new("Banned from "); g_string_append(message, roomjid); if (actor) { g_string_append(message, " by "); @@ -967,14 +965,14 @@ ui_room_banned(const char *const roomjid, const char *const actor, const char *c g_string_append(message, reason); } - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); win_println(console, THEME_TYPING, "!", "<- %s", message->str); g_string_free(message, TRUE); } - GList *curr = privwins; + GList* curr = privwins; while (curr) { - ProfPrivateWin *privwin = curr->data; + ProfPrivateWin* privwin = curr->data; privwin_room_banned(privwin, actor, reason); curr = g_list_next(curr); } @@ -984,7 +982,7 @@ ui_room_banned(const char *const roomjid, const char *const actor, const char *c int ui_win_unread(int index) { - ProfWin *window = wins_get_by_num(index); + ProfWin* window = wins_get_by_num(index); if (window) { return win_unread(window); } else { @@ -1007,9 +1005,9 @@ ui_get_line(void) } char* -ui_ask_pgp_passphrase(const char *hint, int prev_fail) +ui_ask_pgp_passphrase(const char* hint, int prev_fail) { - ProfWin *current = wins_get_current(); + ProfWin* current = wins_get_current(); win_println(current, THEME_DEFAULT, "-", ""); @@ -1030,11 +1028,11 @@ ui_ask_pgp_passphrase(const char *hint, int prev_fail) } void -ui_contact_offline(char *barejid, char *resource, char *status) +ui_contact_offline(char* barejid, char* resource, char* status) { - char *show_console = prefs_get_string(PREF_STATUSES_CONSOLE); - char *show_chat_win = prefs_get_string(PREF_STATUSES_CHAT); - Jid *jid = jid_create_from_bare_and_resource(barejid, resource); + char* show_console = prefs_get_string(PREF_STATUSES_CONSOLE); + char* show_chat_win = prefs_get_string(PREF_STATUSES_CHAT); + Jid* jid = jid_create_from_bare_and_resource(barejid, resource); PContact contact = roster_get_contact(barejid); if (p_contact_subscription(contact)) { if (strcmp(p_contact_subscription(contact), "none") != 0) { @@ -1043,21 +1041,21 @@ ui_contact_offline(char *barejid, char *resource, char *status) if (g_strcmp0(show_console, "all") == 0) { cons_show_contact_offline(contact, resource, status); - // show in console of "online" + // show in console of "online" } else if (g_strcmp0(show_console, "online") == 0) { cons_show_contact_offline(contact, resource, status); } // show in chat win if "all" if (g_strcmp0(show_chat_win, "all") == 0) { - ProfChatWin *chatwin = wins_get_chat(barejid); + ProfChatWin* chatwin = wins_get_chat(barejid); if (chatwin) { chatwin_contact_offline(chatwin, resource, status); } - // show in chat win if "online" and presence online + // show in chat win if "online" and presence online } else if (g_strcmp0(show_chat_win, "online") == 0) { - ProfChatWin *chatwin = wins_get_chat(barejid); + ProfChatWin* chatwin = wins_get_chat(barejid); if (chatwin) { chatwin_contact_offline(chatwin, resource, status); } @@ -1065,7 +1063,7 @@ ui_contact_offline(char *barejid, char *resource, char *status) } } - ProfChatWin *chatwin = wins_get_chat(barejid); + ProfChatWin* chatwin = wins_get_chat(barejid); if (chatwin && chatwin->resource_override && (g_strcmp0(resource, chatwin->resource_override) == 0)) { FREE_SET_NULL(chatwin->resource_override); } @@ -1085,7 +1083,8 @@ void ui_goodbye_title(void) { int result = system("/bin/echo -ne \"\033]0;Thanks for using Profanity\007\""); - if(result == -1) log_error("Error printing title on shutdown"); + if (result == -1) + log_error("Error printing title on shutdown"); } static void @@ -1095,21 +1094,21 @@ _ui_draw_term_title(void) jabber_conn_status_t status = connection_get_status(); if (status == JABBER_CONNECTED) { - const char * const jid = connection_get_fulljid(); + const char* const jid = connection_get_fulljid(); gint unread = wins_get_total_unread(); if (unread != 0) { snprintf(new_win_title, sizeof(new_win_title), - "/bin/echo -n \"%c]0;%s (%d) - %s%c\"", '\033', "Profanity", - unread, jid, '\007'); + "/bin/echo -n \"%c]0;%s (%d) - %s%c\"", '\033', "Profanity", + unread, jid, '\007'); } else { snprintf(new_win_title, sizeof(new_win_title), - "/bin/echo -n \"%c]0;%s - %s%c\"", '\033', "Profanity", jid, - '\007'); + "/bin/echo -n \"%c]0;%s - %s%c\"", '\033', "Profanity", jid, + '\007'); } } else { snprintf(new_win_title, sizeof(new_win_title), "/bin/echo -n \"%c]0;%s%c\"", '\033', - "Profanity", '\007'); + "Profanity", '\007'); } if (g_strcmp0(win_title, new_win_title) != 0) { // print to x-window title bar @@ -1125,10 +1124,10 @@ _ui_draw_term_title(void) } void -ui_handle_room_configuration_form_error(const char *const roomjid, const char *const message) +ui_handle_room_configuration_form_error(const char* const roomjid, const char* const message) { - ProfWin *window = NULL; - GString *message_str = g_string_new(""); + ProfWin* window = NULL; + GString* message_str = g_string_new(""); if (roomjid) { window = (ProfWin*)wins_get_muc(roomjid); @@ -1149,15 +1148,15 @@ ui_handle_room_configuration_form_error(const char *const roomjid, const char *c } void -ui_handle_room_config_submit_result(const char *const roomjid) +ui_handle_room_config_submit_result(const char* const roomjid) { if (roomjid) { - ProfWin *form_window = NULL; - ProfWin *muc_window = (ProfWin*)wins_get_muc(roomjid); + ProfWin* form_window = NULL; + ProfWin* muc_window = (ProfWin*)wins_get_muc(roomjid); - GString *form_recipient = g_string_new(roomjid); + GString* form_recipient = g_string_new(roomjid); g_string_append(form_recipient, " config"); - form_window = (ProfWin*) wins_get_conf(form_recipient->str); + form_window = (ProfWin*)wins_get_conf(form_recipient->str); g_string_free(form_recipient, TRUE); if (form_window) { @@ -1169,7 +1168,7 @@ ui_handle_room_config_submit_result(const char *const roomjid) ui_focus_win((ProfWin*)muc_window); win_println(muc_window, THEME_ROOMINFO, "!", "Room configuration successful"); } else { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); ui_focus_win(console); cons_show("Room configuration successful: %s", roomjid); } @@ -1179,17 +1178,17 @@ ui_handle_room_config_submit_result(const char *const roomjid) } void -ui_handle_room_config_submit_result_error(const char *const roomjid, const char *const message) +ui_handle_room_config_submit_result_error(const char* const roomjid, const char* const message) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); if (roomjid) { - ProfWin *muc_window = NULL; - ProfWin *form_window = NULL; + ProfWin* muc_window = NULL; + ProfWin* form_window = NULL; muc_window = (ProfWin*)wins_get_muc(roomjid); - GString *form_recipient = g_string_new(roomjid); + GString* form_recipient = g_string_new(roomjid); g_string_append(form_recipient, " config"); - form_window = (ProfWin*) wins_get_conf(form_recipient->str); + form_window = (ProfWin*)wins_get_conf(form_recipient->str); g_string_free(form_recipient, TRUE); if (form_window) { @@ -1217,7 +1216,7 @@ ui_handle_room_config_submit_result_error(const char *const roomjid, const char } void -ui_show_lines(ProfWin *window, gchar** lines) +ui_show_lines(ProfWin* window, gchar** lines) { if (lines) { int i; @@ -1230,7 +1229,7 @@ ui_show_lines(ProfWin *window, gchar** lines) void ui_show_roster(void) { - ProfWin *window = wins_get_console(); + ProfWin* window = wins_get_console(); if (window && !win_has_active_subwin(window)) { wins_show_subwin(window); rosterwin_roster(); @@ -1240,18 +1239,18 @@ ui_show_roster(void) void ui_hide_roster(void) { - ProfWin *window = wins_get_console(); + ProfWin* window = wins_get_console(); if (window && win_has_active_subwin(window)) { wins_hide_subwin(window); } } void -ui_handle_software_version_error(const char *const roomjid, const char *const message) +ui_handle_software_version_error(const char* const roomjid, const char* const message) { - GString *message_str = g_string_new(""); + GString* message_str = g_string_new(""); - ProfWin *window = wins_get_console(); + ProfWin* window = wins_get_console(); g_string_printf(message_str, "Could not get software version"); if (message) { @@ -1265,15 +1264,15 @@ ui_handle_software_version_error(const char *const roomjid, const char *const me } void -ui_show_software_version(const char *const jid, const char *const presence, - const char *const name, const char *const version, const char *const os) +ui_show_software_version(const char* const jid, const char* const presence, + const char* const name, const char* const version, const char* const os) { - Jid *jidp = jid_create(jid); - ProfWin *window = NULL; - ProfWin *chatwin = (ProfWin*)wins_get_chat(jidp->barejid); - ProfWin *mucwin = (ProfWin*)wins_get_muc(jidp->barejid); - ProfWin *privwin = (ProfWin*)wins_get_private(jidp->fulljid); - ProfWin *console = wins_get_console(); + Jid* jidp = jid_create(jid); + ProfWin* window = NULL; + ProfWin* chatwin = (ProfWin*)wins_get_chat(jidp->barejid); + ProfWin* mucwin = (ProfWin*)wins_get_muc(jidp->barejid); + ProfWin* privwin = (ProfWin*)wins_get_private(jidp->fulljid); + ProfWin* console = wins_get_console(); jid_destroy(jidp); if (chatwin) { diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c index 6a1a6f48..45cd3313 100644 --- a/src/ui/inputwin.c +++ b/src/ui/inputwin.c @@ -73,7 +73,7 @@ #include "xmpp/roster_list.h" #include "xmpp/chat_state.h" -static WINDOW *inp_win; +static WINDOW* inp_win; static int pad_start = 0; static struct timeval p_rl_timeout; @@ -81,21 +81,21 @@ static struct timeval p_rl_timeout; static gint inp_timeout = 0; static gint no_input_count = 0; -static FILE *discard; +static FILE* discard; static fd_set fds; static int r; -static char *inp_line = NULL; +static char* inp_line = NULL; static gboolean get_password = FALSE; static void _inp_win_update_virtual(void); static int _inp_edited(const wint_t ch); static void _inp_win_handle_scroll(void); -static int _inp_offset_to_col(char *str, int offset); -static void _inp_write(char *line, int offset); +static int _inp_offset_to_col(char* str, int offset); +static void _inp_write(char* line, int offset); static void _inp_rl_addfuncs(void); -static int _inp_rl_getc(FILE *stream); -static void _inp_rl_linehandler(char *line); +static int _inp_rl_getc(FILE* stream); +static void _inp_rl_linehandler(char* line); static int _inp_rl_tab_handler(int count, int key); static int _inp_rl_shift_tab_handler(int count, int key); static int _inp_rl_win_clear_handler(int count, int key); @@ -147,7 +147,8 @@ create_input_window(void) rl_callback_handler_install(NULL, _inp_rl_linehandler); inp_win = newpad(1, INP_WIN_MAX); - wbkgd(inp_win, theme_attrs(THEME_INPUT_TEXT));; + wbkgd(inp_win, theme_attrs(THEME_INPUT_TEXT)); + ; keypad(inp_win, TRUE); wmove(inp_win, 0, 0); @@ -169,7 +170,7 @@ inp_readline(void) pthread_mutex_lock(&lock); if (r < 0) { if (errno != EINTR) { - char *err_msg = strerror(errno); + char* err_msg = strerror(errno); log_error("Readline failed: %s", err_msg); } return NULL; @@ -178,10 +179,7 @@ inp_readline(void) if (FD_ISSET(fileno(rl_instream), &fds)) { rl_callback_read_char(); - if (rl_line_buffer && - rl_line_buffer[0] != '/' && - rl_line_buffer[0] != '\0' && - rl_line_buffer[0] != '\n') { + if (rl_line_buffer && rl_line_buffer[0] != '/' && rl_line_buffer[0] != '\0' && rl_line_buffer[0] != '\n') { chat_state_activity(); } @@ -198,7 +196,7 @@ inp_readline(void) if (inp_line) { if (!get_password && prefs_get_boolean(PREF_SLASH_GUARD)) { if (strlen(inp_line) > 1) { - char *res = (char*) memchr (inp_line+1, '/', 3); + char* res = (char*)memchr(inp_line + 1, '/', 3); if (res) { cons_show("Your text contains a slash in the first 4 characters"); return NULL; @@ -225,14 +223,15 @@ inp_win_resize(void) } } - wbkgd(inp_win, theme_attrs(THEME_INPUT_TEXT));; + wbkgd(inp_win, theme_attrs(THEME_INPUT_TEXT)); + ; _inp_win_update_virtual(); } void inp_nonblocking(gboolean reset) { - if (! prefs_get_boolean(PREF_INPBLOCK_DYNAMIC)) { + if (!prefs_get_boolean(PREF_INPBLOCK_DYNAMIC)) { inp_timeout = prefs_get_inpblock(); return; } @@ -269,7 +268,7 @@ inp_get_line(void) wmove(inp_win, 0, 0); _inp_win_update_virtual(); doupdate(); - char *line = NULL; + char* line = NULL; while (!line) { line = inp_readline(); ui_update(); @@ -285,7 +284,7 @@ inp_get_password(void) wmove(inp_win, 0, 0); _inp_win_update_virtual(); doupdate(); - char *password = NULL; + char* password = NULL; get_password = TRUE; while (!password) { password = inp_readline(); @@ -307,11 +306,11 @@ _inp_win_update_virtual(void) { int wcols = getmaxx(stdscr); int row = screen_inputwin_row(); - pnoutrefresh(inp_win, 0, pad_start, row, 0, row, wcols-2); + pnoutrefresh(inp_win, 0, pad_start, row, 0, row, wcols - 2); } static void -_inp_write(char *line, int offset) +_inp_write(char* line, int offset) { int col = _inp_offset_to_col(line, offset); werase(inp_win); @@ -346,7 +345,7 @@ _inp_edited(const wint_t ch) } // printable - char bytes[MB_CUR_MAX+1]; + char bytes[MB_CUR_MAX + 1]; size_t utf_len = wcrtomb(bytes, ch, &mbstate); if (utf_len == (size_t)-1) { return 0; @@ -358,7 +357,7 @@ _inp_edited(const wint_t ch) } static int -_inp_offset_to_col(char *str, int offset) +_inp_offset_to_col(char* str, int offset) { int i = 0; int col = 0; @@ -384,7 +383,7 @@ _inp_win_handle_scroll(void) if (col == 0) { pad_start = 0; - } else if (col >= pad_start + (wcols -2)) { + } else if (col >= pad_start + (wcols - 2)) { pad_start = col - (wcols / 2); if (pad_start < 0) { pad_start = 0; @@ -503,7 +502,7 @@ _inp_rl_startup_hook(void) rl_variable_bind("disable-completion", "on"); // check for and load ~/.config/profanity/inputrc - gchar *inputrc = files_get_inputrc_file(); + gchar* inputrc = files_get_inputrc_file(); if (inputrc) { rl_read_init_file(inputrc); g_free(inputrc); @@ -513,7 +512,7 @@ _inp_rl_startup_hook(void) } static void -_inp_rl_linehandler(char *line) +_inp_rl_linehandler(char* line) { if (line && *line) { if (!get_password) { @@ -526,7 +525,7 @@ _inp_rl_linehandler(char *line) static gboolean shift_tab = FALSE; static int -_inp_rl_getc(FILE *stream) +_inp_rl_getc(FILE* stream) { int ch = rl_getc(stream); @@ -545,7 +544,7 @@ _inp_rl_getc(FILE *stream) shift_tab = FALSE; if (_inp_edited(ch)) { - ProfWin *window = wins_get_current(); + ProfWin* window = wins_get_current(); cmd_ac_reset(window); } return ch; @@ -554,7 +553,7 @@ _inp_rl_getc(FILE *stream) static int _inp_rl_win_clear_handler(int count, int key) { - ProfWin *win = wins_get_current(); + ProfWin* win = wins_get_current(); win_clear(win); return 0; } @@ -562,7 +561,7 @@ _inp_rl_win_clear_handler(int count, int key) static int _inp_rl_win_close_handler(int count, int key) { - ProfWin *win = wins_get_current(); + ProfWin* win = wins_get_current(); gchar* args = 0; cmd_close(win, 0, &args); return 0; @@ -575,17 +574,17 @@ _inp_rl_tab_handler(int count, int key) return 0; } - ProfWin *current = wins_get_current(); + ProfWin* current = wins_get_current(); if ((strncmp(rl_line_buffer, "/", 1) != 0) && (current->type == WIN_MUC)) { - char *result = muc_autocomplete(current, rl_line_buffer, FALSE); + char* result = muc_autocomplete(current, rl_line_buffer, FALSE); if (result) { rl_replace_line(result, 1); rl_point = rl_end; free(result); } } else if (strncmp(rl_line_buffer, "/", 1) == 0) { - ProfWin *window = wins_get_current(); - char *result = cmd_ac_complete(window, rl_line_buffer, FALSE); + ProfWin* window = wins_get_current(); + char* result = cmd_ac_complete(window, rl_line_buffer, FALSE); if (result) { rl_replace_line(result, 1); rl_point = rl_end; @@ -603,17 +602,17 @@ _inp_rl_shift_tab_handler(int count, int key) return 0; } - ProfWin *current = wins_get_current(); + ProfWin* current = wins_get_current(); if ((strncmp(rl_line_buffer, "/", 1) != 0) && (current->type == WIN_MUC)) { - char *result = muc_autocomplete(current, rl_line_buffer, TRUE); + char* result = muc_autocomplete(current, rl_line_buffer, TRUE); if (result) { rl_replace_line(result, 1); rl_point = rl_end; free(result); } } else if (strncmp(rl_line_buffer, "/", 1) == 0) { - ProfWin *window = wins_get_current(); - char *result = cmd_ac_complete(window, rl_line_buffer, TRUE); + ProfWin* window = wins_get_current(); + char* result = cmd_ac_complete(window, rl_line_buffer, TRUE); if (result) { rl_replace_line(result, 1); rl_point = rl_end; @@ -627,7 +626,7 @@ _inp_rl_shift_tab_handler(int count, int key) static void _go_to_win(int i) { - ProfWin *window = wins_get_by_num(i); + ProfWin* window = wins_get_by_num(i); if (window) { ui_focus_win(window); } @@ -776,7 +775,7 @@ _inp_rl_win_20_handler(int count, int key) static int _inp_rl_win_prev_handler(int count, int key) { - ProfWin *window = wins_get_previous(); + ProfWin* window = wins_get_previous(); if (window) { ui_focus_win(window); } @@ -786,7 +785,7 @@ _inp_rl_win_prev_handler(int count, int key) static int _inp_rl_win_next_handler(int count, int key) { - ProfWin *window = wins_get_next(); + ProfWin* window = wins_get_next(); if (window) { ui_focus_win(window); } @@ -796,7 +795,7 @@ _inp_rl_win_next_handler(int count, int key) static int _inp_rl_win_next_unread_handler(int count, int key) { - ProfWin *window = wins_get_next_unread(); + ProfWin* window = wins_get_next_unread(); if (window) { ui_focus_win(window); } @@ -806,7 +805,7 @@ _inp_rl_win_next_unread_handler(int count, int key) static int _inp_rl_win_pageup_handler(int count, int key) { - ProfWin *current = wins_get_current(); + ProfWin* current = wins_get_current(); win_page_up(current); return 0; } @@ -814,7 +813,7 @@ _inp_rl_win_pageup_handler(int count, int key) static int _inp_rl_win_pagedown_handler(int count, int key) { - ProfWin *current = wins_get_current(); + ProfWin* current = wins_get_current(); win_page_down(current); return 0; } @@ -822,7 +821,7 @@ _inp_rl_win_pagedown_handler(int count, int key) static int _inp_rl_subwin_pageup_handler(int count, int key) { - ProfWin *current = wins_get_current(); + ProfWin* current = wins_get_current(); win_sub_page_up(current); return 0; } @@ -830,7 +829,7 @@ _inp_rl_subwin_pageup_handler(int count, int key) static int _inp_rl_subwin_pagedown_handler(int count, int key) { - ProfWin *current = wins_get_current(); + ProfWin* current = wins_get_current(); win_sub_page_down(current); return 0; } diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c index 66f33a4b..b89a990f 100644 --- a/src/ui/mucwin.c +++ b/src/ui/mucwin.c @@ -50,13 +50,13 @@ #include "omemo/omemo.h" #endif -static void _mucwin_set_last_message(ProfMucWin *mucwin, const char *const id, const char *const message); +static void _mucwin_set_last_message(ProfMucWin* mucwin, const char* const id, const char* const message); ProfMucWin* -mucwin_new(const char *const barejid) +mucwin_new(const char* const barejid) { - ProfWin *window = wins_new_muc(barejid); - ProfMucWin *mucwin = (ProfMucWin *)window; + ProfWin* window = wins_new_muc(barejid); + ProfMucWin* mucwin = (ProfMucWin*)window; mucwin->last_msg_timestamp = NULL; @@ -71,11 +71,11 @@ mucwin_new(const char *const barejid) } void -mucwin_role_change(ProfMucWin *mucwin, const char *const role, const char *const actor, const char *const reason) +mucwin_role_change(ProfMucWin* mucwin, const char* const role, const char* const actor, const char* const reason) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; win_print(window, THEME_ROOMINFO, "!", "Your role has been changed to: %s", role); if (actor) { win_append(window, THEME_ROOMINFO, ", by: %s", actor); @@ -87,12 +87,12 @@ mucwin_role_change(ProfMucWin *mucwin, const char *const role, const char *const } void -mucwin_affiliation_change(ProfMucWin *mucwin, const char *const affiliation, const char *const actor, - const char *const reason) +mucwin_affiliation_change(ProfMucWin* mucwin, const char* const affiliation, const char* const actor, + const char* const reason) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; win_print(window, THEME_ROOMINFO, "!", "Your affiliation has been changed to: %s", affiliation); if (actor) { win_append(window, THEME_ROOMINFO, ", by: %s", actor); @@ -104,12 +104,12 @@ mucwin_affiliation_change(ProfMucWin *mucwin, const char *const affiliation, con } void -mucwin_role_and_affiliation_change(ProfMucWin *mucwin, const char *const role, const char *const affiliation, - const char *const actor, const char *const reason) +mucwin_role_and_affiliation_change(ProfMucWin* mucwin, const char* const role, const char* const affiliation, + const char* const actor, const char* const reason) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; win_print(window, THEME_ROOMINFO, "!", "Your role and affiliation have been changed, role: %s, affiliation: %s", role, affiliation); if (actor) { win_append(window, THEME_ROOMINFO, ", by: %s", actor); @@ -120,14 +120,13 @@ mucwin_role_and_affiliation_change(ProfMucWin *mucwin, const char *const role, c win_appendln(window, THEME_ROOMINFO, ""); } - void -mucwin_occupant_role_change(ProfMucWin *mucwin, const char *const nick, const char *const role, - const char *const actor, const char *const reason) +mucwin_occupant_role_change(ProfMucWin* mucwin, const char* const nick, const char* const role, + const char* const actor, const char* const reason) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; win_print(window, THEME_ROOMINFO, "!", "%s's role has been changed to: %s", nick, role); if (actor) { win_append(window, THEME_ROOMINFO, ", by: %s", actor); @@ -139,12 +138,12 @@ mucwin_occupant_role_change(ProfMucWin *mucwin, const char *const nick, const ch } void -mucwin_occupant_affiliation_change(ProfMucWin *mucwin, const char *const nick, const char *const affiliation, - const char *const actor, const char *const reason) +mucwin_occupant_affiliation_change(ProfMucWin* mucwin, const char* const nick, const char* const affiliation, + const char* const actor, const char* const reason) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; win_print(window, THEME_ROOMINFO, "!", "%s's affiliation has been changed to: %s", nick, affiliation); if (actor) { win_append(window, THEME_ROOMINFO, ", by: %s", actor); @@ -156,12 +155,12 @@ mucwin_occupant_affiliation_change(ProfMucWin *mucwin, const char *const nick, c } void -mucwin_occupant_role_and_affiliation_change(ProfMucWin *mucwin, const char *const nick, const char *const role, - const char *const affiliation, const char *const actor, const char *const reason) +mucwin_occupant_role_and_affiliation_change(ProfMucWin* mucwin, const char* const nick, const char* const role, + const char* const affiliation, const char* const actor, const char* const reason) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; win_print(window, THEME_ROOMINFO, "!", "%s's role and affiliation have been changed, role: %s, affiliation: %s", nick, role, affiliation); if (actor) { win_append(window, THEME_ROOMINFO, ", by: %s", actor); @@ -173,29 +172,28 @@ mucwin_occupant_role_and_affiliation_change(ProfMucWin *mucwin, const char *cons } void -mucwin_room_info_error(ProfMucWin *mucwin, const char *const error) +mucwin_room_info_error(ProfMucWin* mucwin, const char* const error) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; win_println(window, THEME_DEFAULT, "!", "Room info request failed: %s", error); win_println(window, THEME_DEFAULT, "-", ""); } void -mucwin_room_disco_info(ProfMucWin *mucwin, GSList *identities, GSList *features) +mucwin_room_disco_info(ProfMucWin* mucwin, GSList* identities, GSList* features) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; - if ((identities && (g_slist_length(identities) > 0)) || - (features && (g_slist_length(features) > 0))) { + ProfWin* window = (ProfWin*)mucwin; + if ((identities && (g_slist_length(identities) > 0)) || (features && (g_slist_length(features) > 0))) { if (identities) { win_println(window, THEME_DEFAULT, "!", "Identities:"); } while (identities) { - DiscoIdentity *identity = identities->data; // anme trpe, cat - GString *identity_str = g_string_new(" "); + DiscoIdentity* identity = identities->data; // anme trpe, cat + GString* identity_str = g_string_new(" "); if (identity->name) { identity_str = g_string_append(identity_str, identity->name); identity_str = g_string_append(identity_str, " "); @@ -224,11 +222,11 @@ mucwin_room_disco_info(ProfMucWin *mucwin, GSList *identities, GSList *features) } void -mucwin_roster(ProfMucWin *mucwin, GList *roster, const char *const presence) +mucwin_roster(ProfMucWin* mucwin, GList* roster, const char* const presence) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; if ((roster == NULL) || (g_list_length(roster) == 0)) { if (presence == NULL) { win_println(window, THEME_ROOMINFO, "!", "Room is empty."); @@ -244,8 +242,8 @@ mucwin_roster(ProfMucWin *mucwin, GList *roster, const char *const presence) } while (roster) { - Occupant *occupant = roster->data; - const char *presence_str = string_from_resource_presence(occupant->presence); + Occupant* occupant = roster->data; + const char* presence_str = string_from_resource_presence(occupant->presence); theme_item_t presence_colour = theme_main_presence_attrs(presence_str); win_append(window, presence_colour, "%s", occupant->nick); @@ -261,22 +259,22 @@ mucwin_roster(ProfMucWin *mucwin, GList *roster, const char *const presence) } void -mucwin_occupant_offline(ProfMucWin *mucwin, const char *const nick) +mucwin_occupant_offline(ProfMucWin* mucwin, const char* const nick) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; win_println(window, THEME_OFFLINE, "!", "<- %s has left the room.", nick); } void -mucwin_occupant_kicked(ProfMucWin *mucwin, const char *const nick, const char *const actor, - const char *const reason) +mucwin_occupant_kicked(ProfMucWin* mucwin, const char* const nick, const char* const actor, + const char* const reason) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; - GString *message = g_string_new(nick); + ProfWin* window = (ProfWin*)mucwin; + GString* message = g_string_new(nick); g_string_append(message, " has been kicked from the room"); if (actor) { g_string_append(message, " by "); @@ -292,13 +290,13 @@ mucwin_occupant_kicked(ProfMucWin *mucwin, const char *const nick, const char *c } void -mucwin_occupant_banned(ProfMucWin *mucwin, const char *const nick, const char *const actor, - const char *const reason) +mucwin_occupant_banned(ProfMucWin* mucwin, const char* const nick, const char* const actor, + const char* const reason) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; - GString *message = g_string_new(nick); + ProfWin* window = (ProfWin*)mucwin; + GString* message = g_string_new(nick); g_string_append(message, " has been banned from the room"); if (actor) { g_string_append(message, " by "); @@ -314,12 +312,12 @@ mucwin_occupant_banned(ProfMucWin *mucwin, const char *const nick, const char *c } void -mucwin_occupant_online(ProfMucWin *mucwin, const char *const nick, const char *const role, - const char *const affiliation, const char *const show, const char *const status) +mucwin_occupant_online(ProfMucWin* mucwin, const char* const nick, const char* const role, + const char* const affiliation, const char* const show, const char* const status) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; win_print(window, THEME_ONLINE, "!", "-> %s has joined the room", nick); if (prefs_get_boolean(PREF_MUC_PRIVILEGES)) { if (role) { @@ -333,42 +331,42 @@ mucwin_occupant_online(ProfMucWin *mucwin, const char *const nick, const char *c } void -mucwin_occupant_presence(ProfMucWin *mucwin, const char *const nick, - const char *const show, const char *const status) +mucwin_occupant_presence(ProfMucWin* mucwin, const char* const nick, + const char* const show, const char* const status) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; win_show_status_string(window, nick, show, status, NULL, "++", "online"); } void -mucwin_occupant_nick_change(ProfMucWin *mucwin, const char *const old_nick, const char *const nick) +mucwin_occupant_nick_change(ProfMucWin* mucwin, const char* const old_nick, const char* const nick) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; win_println(window, THEME_THEM, "!", "** %s is now known as %s", old_nick, nick); } void -mucwin_nick_change(ProfMucWin *mucwin, const char *const nick) +mucwin_nick_change(ProfMucWin* mucwin, const char* const nick) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; win_println(window, THEME_ME, "!", "** You are now known as %s", nick); } void -mucwin_history(ProfMucWin *mucwin, const ProfMessage *const message) +mucwin_history(ProfMucWin* mucwin, const ProfMessage* const message) { assert(mucwin != NULL); - char *nick = message->from_jid->resourcepart; - char *mynick = muc_nick(mucwin->roomjid); - GSList *mentions = get_mentions(prefs_get_boolean(PREF_NOTIFY_MENTION_WHOLE_WORD), prefs_get_boolean(PREF_NOTIFY_MENTION_CASE_SENSITIVE), message->plain, mynick); - GList *triggers = prefs_message_get_triggers(message->plain); + char* nick = message->from_jid->resourcepart; + char* mynick = muc_nick(mucwin->roomjid); + GSList* mentions = get_mentions(prefs_get_boolean(PREF_NOTIFY_MENTION_WHOLE_WORD), prefs_get_boolean(PREF_NOTIFY_MENTION_CASE_SENSITIVE), message->plain, mynick); + GList* triggers = prefs_message_get_triggers(message->plain); mucwin_incoming_msg(mucwin, message, mentions, triggers, FALSE); @@ -379,15 +377,15 @@ mucwin_history(ProfMucWin *mucwin, const ProfMessage *const message) } static void -_mucwin_print_mention(ProfWin *window, const char *const message, const char *const from, const char *const mynick, GSList *mentions, const char *const ch, int flags) +_mucwin_print_mention(ProfWin* window, const char* const message, const char* const from, const char* const mynick, GSList* mentions, const char* const ch, int flags) { int last_pos = 0; int pos; - GSList *curr = mentions; + GSList* curr = mentions; while (curr) { pos = GPOINTER_TO_INT(curr->data); - char *before_str = g_strndup(message + last_pos, pos - last_pos); + char* before_str = g_strndup(message + last_pos, pos - last_pos); if (strncmp(before_str, "/me ", 4) == 0) { win_print_them(window, THEME_ROOMMENTION, ch, flags, ""); win_append_highlight(window, THEME_ROOMMENTION, "*%s ", from); @@ -397,7 +395,7 @@ _mucwin_print_mention(ProfWin *window, const char *const message, const char *co win_append_highlight(window, THEME_ROOMMENTION, "%s", before_str); } g_free(before_str); - char *mynick_str = g_strndup(message + pos, strlen(mynick)); + char* mynick_str = g_strndup(message + pos, strlen(mynick)); win_append_highlight(window, THEME_ROOMMENTION_TERM, "%s", mynick_str); g_free(mynick_str); @@ -418,31 +416,33 @@ _cmp_trigger_weight(gconstpointer a, gconstpointer b) int alen = strlen((char*)a); int blen = strlen((char*)b); - if (alen > blen) return -1; - if (alen < blen) return 1; + if (alen > blen) + return -1; + if (alen < blen) + return 1; return 0; } static void -_mucwin_print_triggers(ProfWin *window, const char *const message, GList *triggers) +_mucwin_print_triggers(ProfWin* window, const char* const message, GList* triggers) { - GList *weighted_triggers = NULL; - GList *curr = triggers; + GList* weighted_triggers = NULL; + GList* curr = triggers; while (curr) { weighted_triggers = g_list_insert_sorted(weighted_triggers, curr->data, (GCompareFunc)_cmp_trigger_weight); curr = g_list_next(curr); } - char *message_lower = g_utf8_strdown(message, -1); + char* message_lower = g_utf8_strdown(message, -1); // find earliest trigger in message int first_trigger_pos = -1; int first_trigger_len = -1; curr = weighted_triggers; while (curr) { - char *trigger_lower = g_utf8_strdown(curr->data, -1); - char *trigger_ptr = g_strstr_len(message_lower, -1, trigger_lower); + char* trigger_lower = g_utf8_strdown(curr->data, -1); + char* trigger_ptr = g_strstr_len(message_lower, -1, trigger_lower); // not found, try next if (trigger_ptr == NULL) { @@ -496,15 +496,15 @@ _mucwin_print_triggers(ProfWin *window, const char *const message, GList *trigge } void -mucwin_outgoing_msg(ProfMucWin *mucwin, const char *const message, const char *const id, prof_enc_t enc_mode, const char *const replace_id) +mucwin_outgoing_msg(ProfMucWin* mucwin, const char* const message, const char* const id, prof_enc_t enc_mode, const char* const replace_id) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; - char *mynick = muc_nick(mucwin->roomjid); + ProfWin* window = (ProfWin*)mucwin; + char* mynick = muc_nick(mucwin->roomjid); // displayed message char - char *ch; + char* ch; if (mucwin->message_char) { ch = strdup(mucwin->message_char); } else if (enc_mode == PROF_MSG_ENC_OTR) { @@ -529,7 +529,7 @@ mucwin_outgoing_msg(ProfMucWin *mucwin, const char *const message, const char *c } void -mucwin_incoming_msg(ProfMucWin *mucwin, const ProfMessage *const message, GSList *mentions, GList *triggers, gboolean filter_reflection) +mucwin_incoming_msg(ProfMucWin* mucwin, const ProfMessage* const message, GSList* mentions, GList* triggers, gboolean filter_reflection) { assert(mucwin != NULL); int flags = 0; @@ -543,10 +543,10 @@ mucwin_incoming_msg(ProfMucWin *mucwin, const ProfMessage *const message, GSList flags |= UNTRUSTED; } - ProfWin *window = (ProfWin*)mucwin; - char *mynick = muc_nick(mucwin->roomjid); + ProfWin* window = (ProfWin*)mucwin; + char* mynick = muc_nick(mucwin->roomjid); - char *ch; + char* ch; if (mucwin->message_char) { ch = strdup(mucwin->message_char); } else if (message->enc == PROF_MSG_ENC_OTR) { @@ -575,11 +575,11 @@ mucwin_incoming_msg(ProfMucWin *mucwin, const ProfMessage *const message, GSList } void -mucwin_requires_config(ProfMucWin *mucwin) +mucwin_requires_config(ProfMucWin* mucwin) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; int num = wins_get_num(window); win_println(window, THEME_DEFAULT, "-", ""); @@ -593,18 +593,18 @@ mucwin_requires_config(ProfMucWin *mucwin) if (wins_is_current(window)) { status_bar_active(num, WIN_MUC, mucwin->roomjid); - // not currently on groupchat window + // not currently on groupchat window } else { status_bar_new(num, WIN_MUC, mucwin->roomjid); } } void -mucwin_subject(ProfMucWin *mucwin, const char *const nick, const char *const subject) +mucwin_subject(ProfMucWin* mucwin, const char* const nick, const char* const subject) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; if (subject) { if (nick) { win_print(window, THEME_ROOMINFO, "!", "*%s has set the room subject: ", nick); @@ -623,20 +623,20 @@ mucwin_subject(ProfMucWin *mucwin, const char *const nick, const char *const sub } void -mucwin_kick_error(ProfMucWin *mucwin, const char *const nick, const char *const error) +mucwin_kick_error(ProfMucWin* mucwin, const char* const nick, const char* const error) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; win_println(window, THEME_ERROR, "!", "Error kicking %s: %s", nick, error); } void -mucwin_broadcast(ProfMucWin *mucwin, const char *const message) +mucwin_broadcast(ProfMucWin* mucwin, const char* const message) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; int num = wins_get_num(window); win_print(window, THEME_ROOMINFO, "!", "Room message: "); @@ -646,33 +646,33 @@ mucwin_broadcast(ProfMucWin *mucwin, const char *const message) if (wins_is_current(window)) { status_bar_active(num, WIN_MUC, mucwin->roomjid); - // not currently on groupchat window + // not currently on groupchat window } else { status_bar_new(num, WIN_MUC, mucwin->roomjid); } } void -mucwin_affiliation_list_error(ProfMucWin *mucwin, const char *const affiliation, - const char *const error) +mucwin_affiliation_list_error(ProfMucWin* mucwin, const char* const affiliation, + const char* const error) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; win_println(window, THEME_ERROR, "!", "Error retrieving %s list: %s", affiliation, error); } void -mucwin_handle_affiliation_list(ProfMucWin *mucwin, const char *const affiliation, GSList *jids) +mucwin_handle_affiliation_list(ProfMucWin* mucwin, const char* const affiliation, GSList* jids) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; if (jids) { win_println(window, THEME_DEFAULT, "!", "Affiliation: %s", affiliation); - GSList *curr_jid = jids; + GSList* curr_jid = jids; while (curr_jid) { - const char *jid = curr_jid->data; + const char* jid = curr_jid->data; win_println(window, THEME_DEFAULT, "!", " %s", jid); curr_jid = g_slist_next(curr_jid); } @@ -684,52 +684,52 @@ mucwin_handle_affiliation_list(ProfMucWin *mucwin, const char *const affiliation } void -mucwin_show_affiliation_list(ProfMucWin *mucwin, muc_affiliation_t affiliation) +mucwin_show_affiliation_list(ProfMucWin* mucwin, muc_affiliation_t affiliation) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*) mucwin; - GSList *occupants = muc_occupants_by_affiliation(mucwin->roomjid, affiliation); + ProfWin* window = (ProfWin*)mucwin; + GSList* occupants = muc_occupants_by_affiliation(mucwin->roomjid, affiliation); if (!occupants) { switch (affiliation) { - case MUC_AFFILIATION_OWNER: - win_println(window, THEME_DEFAULT, "!", "No owners found."); - break; - case MUC_AFFILIATION_ADMIN: - win_println(window, THEME_DEFAULT, "!", "No admins found."); - break; - case MUC_AFFILIATION_MEMBER: - win_println(window, THEME_DEFAULT, "!", "No members found."); - break; - case MUC_AFFILIATION_OUTCAST: - win_println(window, THEME_DEFAULT, "!", "No outcasts found."); - break; - default: - break; + case MUC_AFFILIATION_OWNER: + win_println(window, THEME_DEFAULT, "!", "No owners found."); + break; + case MUC_AFFILIATION_ADMIN: + win_println(window, THEME_DEFAULT, "!", "No admins found."); + break; + case MUC_AFFILIATION_MEMBER: + win_println(window, THEME_DEFAULT, "!", "No members found."); + break; + case MUC_AFFILIATION_OUTCAST: + win_println(window, THEME_DEFAULT, "!", "No outcasts found."); + break; + default: + break; } win_println(window, THEME_DEFAULT, "-", ""); } else { switch (affiliation) { - case MUC_AFFILIATION_OWNER: - win_println(window, THEME_DEFAULT, "!", "Owners:"); - break; - case MUC_AFFILIATION_ADMIN: - win_println(window, THEME_DEFAULT, "!", "Admins:"); - break; - case MUC_AFFILIATION_MEMBER: - win_println(window, THEME_DEFAULT, "!", "Members:"); - break; - case MUC_AFFILIATION_OUTCAST: - win_println(window, THEME_DEFAULT, "!", "Outcasts:"); - break; - default: - break; + case MUC_AFFILIATION_OWNER: + win_println(window, THEME_DEFAULT, "!", "Owners:"); + break; + case MUC_AFFILIATION_ADMIN: + win_println(window, THEME_DEFAULT, "!", "Admins:"); + break; + case MUC_AFFILIATION_MEMBER: + win_println(window, THEME_DEFAULT, "!", "Members:"); + break; + case MUC_AFFILIATION_OUTCAST: + win_println(window, THEME_DEFAULT, "!", "Outcasts:"); + break; + default: + break; } - GSList *curr_occupant = occupants; - while(curr_occupant) { - Occupant *occupant = curr_occupant->data; + GSList* curr_occupant = occupants; + while (curr_occupant) { + Occupant* occupant = curr_occupant->data; if (occupant->affiliation == affiliation) { if (occupant->jid) { win_println(window, THEME_DEFAULT, "!", " %s (%s)", occupant->nick, occupant->jid); @@ -746,26 +746,26 @@ mucwin_show_affiliation_list(ProfMucWin *mucwin, muc_affiliation_t affiliation) } void -mucwin_role_list_error(ProfMucWin *mucwin, const char *const role, const char *const error) +mucwin_role_list_error(ProfMucWin* mucwin, const char* const role, const char* const error) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; win_println(window, THEME_ERROR, "!", "Error retrieving %s list: %s", role, error); } void -mucwin_handle_role_list(ProfMucWin *mucwin, const char *const role, GSList *nicks) +mucwin_handle_role_list(ProfMucWin* mucwin, const char* const role, GSList* nicks) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; if (nicks) { win_println(window, THEME_DEFAULT, "!", "Role: %s", role); - GSList *curr_nick = nicks; + GSList* curr_nick = nicks; while (curr_nick) { - const char *nick = curr_nick->data; - Occupant *occupant = muc_roster_item(mucwin->roomjid, nick); + const char* nick = curr_nick->data; + Occupant* occupant = muc_roster_item(mucwin->roomjid, nick); if (occupant) { if (occupant->jid) { win_println(window, THEME_DEFAULT, "!", " %s (%s)", nick, occupant->jid); @@ -785,46 +785,46 @@ mucwin_handle_role_list(ProfMucWin *mucwin, const char *const role, GSList *nick } void -mucwin_show_role_list(ProfMucWin *mucwin, muc_role_t role) +mucwin_show_role_list(ProfMucWin* mucwin, muc_role_t role) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; - GSList *occupants = muc_occupants_by_role(mucwin->roomjid, role); + ProfWin* window = (ProfWin*)mucwin; + GSList* occupants = muc_occupants_by_role(mucwin->roomjid, role); if (!occupants) { switch (role) { - case MUC_ROLE_MODERATOR: - win_println(window, THEME_DEFAULT, "!", "No moderators found."); - break; - case MUC_ROLE_PARTICIPANT: - win_println(window, THEME_DEFAULT, "!", "No participants found."); - break; - case MUC_ROLE_VISITOR: - win_println(window, THEME_DEFAULT, "!", "No visitors found."); - break; - default: - break; + case MUC_ROLE_MODERATOR: + win_println(window, THEME_DEFAULT, "!", "No moderators found."); + break; + case MUC_ROLE_PARTICIPANT: + win_println(window, THEME_DEFAULT, "!", "No participants found."); + break; + case MUC_ROLE_VISITOR: + win_println(window, THEME_DEFAULT, "!", "No visitors found."); + break; + default: + break; } win_println(window, THEME_DEFAULT, "-", ""); } else { switch (role) { - case MUC_ROLE_MODERATOR: - win_println(window, THEME_DEFAULT, "!", "Moderators:"); - break; - case MUC_ROLE_PARTICIPANT: - win_println(window, THEME_DEFAULT, "!", "Participants:"); - break; - case MUC_ROLE_VISITOR: - win_println(window, THEME_DEFAULT, "!", "Visitors:"); - break; - default: - break; + case MUC_ROLE_MODERATOR: + win_println(window, THEME_DEFAULT, "!", "Moderators:"); + break; + case MUC_ROLE_PARTICIPANT: + win_println(window, THEME_DEFAULT, "!", "Participants:"); + break; + case MUC_ROLE_VISITOR: + win_println(window, THEME_DEFAULT, "!", "Visitors:"); + break; + default: + break; } - GSList *curr_occupant = occupants; - while(curr_occupant) { - Occupant *occupant = curr_occupant->data; + GSList* curr_occupant = occupants; + while (curr_occupant) { + Occupant* occupant = curr_occupant->data; if (occupant->role == role) { if (occupant->jid) { win_println(window, THEME_DEFAULT, "!", " %s (%s)", occupant->nick, occupant->jid); @@ -841,34 +841,34 @@ mucwin_show_role_list(ProfMucWin *mucwin, muc_role_t role) } void -mucwin_affiliation_set_error(ProfMucWin *mucwin, const char *const jid, const char *const affiliation, - const char *const error) +mucwin_affiliation_set_error(ProfMucWin* mucwin, const char* const jid, const char* const affiliation, + const char* const error) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; win_println(window, THEME_ERROR, "!", "Error setting %s affiliation for %s: %s", affiliation, jid, error); } void -mucwin_role_set_error(ProfMucWin *mucwin, const char *const nick, const char *const role, - const char *const error) +mucwin_role_set_error(ProfMucWin* mucwin, const char* const nick, const char* const role, + const char* const error) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; win_println(window, THEME_ERROR, "!", "Error setting %s role for %s: %s", role, nick, error); } void -mucwin_info(ProfMucWin *mucwin) +mucwin_info(ProfMucWin* mucwin) { assert(mucwin != NULL); - char *role = muc_role_str(mucwin->roomjid); - char *affiliation = muc_affiliation_str(mucwin->roomjid); + char* role = muc_role_str(mucwin->roomjid); + char* affiliation = muc_affiliation_str(mucwin->roomjid); - ProfWin *window = (ProfWin*) mucwin; + ProfWin* window = (ProfWin*)mucwin; win_println(window, THEME_DEFAULT, "!", "Room: %s", mucwin->roomjid); win_println(window, THEME_DEFAULT, "!", "Affiliation: %s", affiliation); win_println(window, THEME_DEFAULT, "!", "Role: %s", role); @@ -876,22 +876,22 @@ mucwin_info(ProfMucWin *mucwin) } void -mucwin_update_occupants(ProfMucWin *mucwin) +mucwin_update_occupants(ProfMucWin* mucwin) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; if (win_has_active_subwin(window)) { occupantswin_occupants(mucwin->roomjid); } } void -mucwin_show_occupants(ProfMucWin *mucwin) +mucwin_show_occupants(ProfMucWin* mucwin) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; if (!win_has_active_subwin(window)) { wins_show_subwin(window); occupantswin_occupants(mucwin->roomjid); @@ -899,36 +899,36 @@ mucwin_show_occupants(ProfMucWin *mucwin) } void -mucwin_hide_occupants(ProfMucWin *mucwin) +mucwin_hide_occupants(ProfMucWin* mucwin) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; if (win_has_active_subwin(window)) { wins_hide_subwin(window); } } char* -mucwin_get_string(ProfMucWin *mucwin) +mucwin_get_string(ProfMucWin* mucwin) { assert(mucwin != NULL); - GString *res = g_string_new("Room "); + GString* res = g_string_new("Room "); g_string_append(res, mucwin->roomjid); if (mucwin->unread > 0) { g_string_append_printf(res, ", %d unread", mucwin->unread); } - char *resstr = res->str; + char* resstr = res->str; g_string_free(res, FALSE); return resstr; } void -mucwin_set_enctext(ProfMucWin *mucwin, const char *const enctext) +mucwin_set_enctext(ProfMucWin* mucwin, const char* const enctext) { if (mucwin->enctext) { free(mucwin->enctext); @@ -937,7 +937,7 @@ mucwin_set_enctext(ProfMucWin *mucwin, const char *const enctext) } void -mucwin_unset_enctext(ProfMucWin *mucwin) +mucwin_unset_enctext(ProfMucWin* mucwin) { if (mucwin->enctext) { free(mucwin->enctext); @@ -946,7 +946,7 @@ mucwin_unset_enctext(ProfMucWin *mucwin) } void -mucwin_set_message_char(ProfMucWin *mucwin, const char *const ch) +mucwin_set_message_char(ProfMucWin* mucwin, const char* const ch) { if (mucwin->message_char) { free(mucwin->message_char); @@ -955,7 +955,7 @@ mucwin_set_message_char(ProfMucWin *mucwin, const char *const ch) } void -mucwin_unset_message_char(ProfMucWin *mucwin) +mucwin_unset_message_char(ProfMucWin* mucwin) { if (mucwin->message_char) { free(mucwin->message_char); @@ -964,7 +964,7 @@ mucwin_unset_message_char(ProfMucWin *mucwin) } static void -_mucwin_set_last_message(ProfMucWin *mucwin, const char *const id, const char *const message) +_mucwin_set_last_message(ProfMucWin* mucwin, const char* const id, const char* const message) { free(mucwin->last_message); mucwin->last_message = strdup(message); diff --git a/src/ui/notifier.c b/src/ui/notifier.c index a0814b47..352351f9 100644 --- a/src/ui/notifier.c +++ b/src/ui/notifier.c @@ -55,7 +55,7 @@ #include "xmpp/xmpp.h" #include "xmpp/muc.h" -static GTimer *remind_timer; +static GTimer* remind_timer; void notifier_initialise(void) @@ -75,7 +75,7 @@ notifier_uninit(void) } void -notify_typing(const char *const name) +notify_typing(const char* const name) { char message[strlen(name) + 1 + 11]; sprintf(message, "%s: typing...", name); @@ -84,9 +84,9 @@ notify_typing(const char *const name) } void -notify_invite(const char *const from, const char *const room, const char *const reason) +notify_invite(const char* const from, const char* const room, const char* const reason) { - GString *message = g_string_new("Room invite\nfrom: "); + GString* message = g_string_new("Room invite\nfrom: "); g_string_append(message, from); g_string_append(message, "\nto: "); g_string_append(message, room); @@ -100,14 +100,14 @@ notify_invite(const char *const from, const char *const room, const char *const } void -notify_message(const char *const name, int num, const char *const text) +notify_message(const char* const name, int num, const char* const text) { int ui_index = num; if (ui_index == 10) { ui_index = 0; } - GString *message = g_string_new(""); + GString* message = g_string_new(""); g_string_append_printf(message, "%s (win %d)", name, ui_index); if (text && prefs_get_boolean(PREF_NOTIFY_CHAT_TEXT)) { g_string_append_printf(message, "\n%s", text); @@ -118,14 +118,14 @@ notify_message(const char *const name, int num, const char *const text) } void -notify_room_message(const char *const nick, const char *const room, int num, const char *const text) +notify_room_message(const char* const nick, const char* const room, int num, const char* const text) { int ui_index = num; if (ui_index == 10) { ui_index = 0; } - GString *message = g_string_new(""); + GString* message = g_string_new(""); g_string_append_printf(message, "%s in %s (win %d)", nick, room, ui_index); if (text && prefs_get_boolean(PREF_NOTIFY_ROOM_TEXT)) { g_string_append_printf(message, "\n%s", text); @@ -137,9 +137,9 @@ notify_room_message(const char *const nick, const char *const room, int num, con } void -notify_subscription(const char *const from) +notify_subscription(const char* const from) { - GString *message = g_string_new("Subscription request: \n"); + GString* message = g_string_new("Subscription request: \n"); g_string_append(message, from); notify(message->str, 10000, "Incoming message"); g_string_free(message, TRUE); @@ -156,7 +156,7 @@ notify_remind(void) gint open = muc_invites_count(); gint subs = presence_sub_request_count(); - GString *text = g_string_new(""); + GString* text = g_string_new(""); if (donotify && unread > 0) { if (unread == 1) { @@ -164,7 +164,6 @@ notify_remind(void) } else { g_string_append_printf(text, "%d unread messages", unread); } - } if (open > 0) { if (unread > 0) { @@ -198,7 +197,7 @@ notify_remind(void) } void -notify(const char *const message, int timeout, const char *const category) +notify(const char* const message, int timeout, const char* const category) { #ifdef HAVE_LIBNOTIFY log_debug("Attempting notification: %s", message); @@ -211,13 +210,13 @@ notify(const char *const message, int timeout, const char *const category) notify_init("Profanity"); } if (notify_is_initted()) { - NotifyNotification *notification; + NotifyNotification* notification; notification = notify_notification_new("Profanity", message, NULL); notify_notification_set_timeout(notification, timeout); notify_notification_set_category(notification, category); notify_notification_set_urgency(notification, NOTIFY_URGENCY_NORMAL); - GError *error = NULL; + GError* error = NULL; gboolean notify_success = notify_notification_show(notification, &error); if (!notify_success) { @@ -247,17 +246,17 @@ notify(const char *const message, int timeout, const char *const category) // For a Ballon Tip nid.uFlags = NIF_INFO; - strcpy(nid.szInfoTitle, "Profanity"); // Title + strcpy(nid.szInfoTitle, "Profanity"); // Title strncpy(nid.szInfo, message, sizeof(nid.szInfo) - 1); // Copy Tip - nid.uTimeout = timeout; // 3 Seconds + nid.uTimeout = timeout; // 3 Seconds nid.dwInfoFlags = NIIF_INFO; Shell_NotifyIcon(NIM_MODIFY, &nid); #endif #ifdef HAVE_OSXNOTIFY - GString *notify_command = g_string_new("terminal-notifier -title \"Profanity\" -message '"); + GString* notify_command = g_string_new("terminal-notifier -title \"Profanity\" -message '"); - char *escaped_single = str_replace(message, "'", "'\\''"); + char* escaped_single = str_replace(message, "'", "'\\''"); if (escaped_single[0] == '<') { g_string_append(notify_command, "\\<"); @@ -278,8 +277,8 @@ notify(const char *const message, int timeout, const char *const category) g_string_append(notify_command, "'"); free(escaped_single); - char *term_name = getenv("TERM_PROGRAM"); - char *app_id = NULL; + char* term_name = getenv("TERM_PROGRAM"); + char* app_id = NULL; if (g_strcmp0(term_name, "Apple_Terminal") == 0) { app_id = "com.apple.Terminal"; } else if (g_strcmp0(term_name, "iTerm.app") == 0) { diff --git a/src/ui/occupantswin.c b/src/ui/occupantswin.c index aff680ea..1834e47c 100644 --- a/src/ui/occupantswin.c +++ b/src/ui/occupantswin.c @@ -42,9 +42,9 @@ #include "ui/window_list.h" static void -_occuptantswin_occupant(ProfLayoutSplit *layout, Occupant *occupant, gboolean showjid) +_occuptantswin_occupant(ProfLayoutSplit* layout, Occupant* occupant, gboolean showjid) { - int colour = 0; //init to workaround compiler warning + int colour = 0; //init to workaround compiler warning theme_item_t presence_colour = THEME_ROSTER_ONLINE; //init to workaround compiler warning if (prefs_get_boolean(PREF_OCCUPANTS_COLOR_NICK)) { @@ -52,13 +52,13 @@ _occuptantswin_occupant(ProfLayoutSplit *layout, Occupant *occupant, gboolean sh wattron(layout->subwin, colour); } else { - const char *presence_str = string_from_resource_presence(occupant->presence); + const char* presence_str = string_from_resource_presence(occupant->presence); presence_colour = theme_main_presence_attrs(presence_str); wattron(layout->subwin, theme_attrs(presence_colour)); } - GString *spaces = g_string_new(" "); + GString* spaces = g_string_new(" "); int indent = prefs_get_occupants_indent(); int current_indent = 0; @@ -70,7 +70,7 @@ _occuptantswin_occupant(ProfLayoutSplit *layout, Occupant *occupant, gboolean sh } } - GString *msg = g_string_new(spaces->str); + GString* msg = g_string_new(spaces->str); char ch = prefs_get_occupants_char(); if (ch) { @@ -85,7 +85,7 @@ _occuptantswin_occupant(ProfLayoutSplit *layout, Occupant *occupant, gboolean sh g_string_free(msg, TRUE); if (showjid && occupant->jid) { - GString *msg = g_string_new(spaces->str); + GString* msg = g_string_new(spaces->str); g_string_append(msg, " "); g_string_append(msg, occupant->jid); @@ -104,18 +104,18 @@ _occuptantswin_occupant(ProfLayoutSplit *layout, Occupant *occupant, gboolean sh } void -occupantswin_occupants(const char *const roomjid) +occupantswin_occupants(const char* const roomjid) { - ProfMucWin *mucwin = wins_get_muc(roomjid); + ProfMucWin* mucwin = wins_get_muc(roomjid); if (mucwin) { - GList *occupants = muc_roster(roomjid); + GList* occupants = muc_roster(roomjid); if (occupants) { - ProfLayoutSplit *layout = (ProfLayoutSplit*)mucwin->window.layout; + ProfLayoutSplit* layout = (ProfLayoutSplit*)mucwin->window.layout; assert(layout->memcheck == LAYOUT_SPLIT_MEMCHECK); werase(layout->subwin); - GString *prefix = g_string_new(" "); + GString* prefix = g_string_new(" "); char ch = prefs_get_occupants_header_char(); if (ch) { @@ -124,7 +124,7 @@ occupantswin_occupants(const char *const roomjid) if (prefs_get_boolean(PREF_MUC_PRIVILEGES)) { - GString *role = g_string_new(prefix->str); + GString* role = g_string_new(prefix->str); g_string_append(role, "Moderators"); wattron(layout->subwin, theme_attrs(THEME_OCCUPANTS_HEADER)); @@ -132,9 +132,9 @@ occupantswin_occupants(const char *const roomjid) win_sub_print(layout->subwin, role->str, TRUE, FALSE, 0); wattroff(layout->subwin, theme_attrs(THEME_OCCUPANTS_HEADER)); g_string_free(role, TRUE); - GList *roster_curr = occupants; + GList* roster_curr = occupants; while (roster_curr) { - Occupant *occupant = roster_curr->data; + Occupant* occupant = roster_curr->data; if (occupant->role == MUC_ROLE_MODERATOR) { _occuptantswin_occupant(layout, occupant, mucwin->showjid); } @@ -151,7 +151,7 @@ occupantswin_occupants(const char *const roomjid) g_string_free(role, TRUE); roster_curr = occupants; while (roster_curr) { - Occupant *occupant = roster_curr->data; + Occupant* occupant = roster_curr->data; if (occupant->role == MUC_ROLE_PARTICIPANT) { _occuptantswin_occupant(layout, occupant, mucwin->showjid); } @@ -168,14 +168,14 @@ occupantswin_occupants(const char *const roomjid) g_string_free(role, TRUE); roster_curr = occupants; while (roster_curr) { - Occupant *occupant = roster_curr->data; + Occupant* occupant = roster_curr->data; if (occupant->role == MUC_ROLE_VISITOR) { _occuptantswin_occupant(layout, occupant, mucwin->showjid); } roster_curr = g_list_next(roster_curr); } } else { - GString *role = g_string_new(prefix->str); + GString* role = g_string_new(prefix->str); g_string_append(role, "Occupants\n"); wattron(layout->subwin, theme_attrs(THEME_OCCUPANTS_HEADER)); @@ -184,9 +184,9 @@ occupantswin_occupants(const char *const roomjid) wattroff(layout->subwin, theme_attrs(THEME_OCCUPANTS_HEADER)); g_string_free(role, TRUE); - GList *roster_curr = occupants; + GList* roster_curr = occupants; while (roster_curr) { - Occupant *occupant = roster_curr->data; + Occupant* occupant = roster_curr->data; _occuptantswin_occupant(layout, occupant, mucwin->showjid); roster_curr = g_list_next(roster_curr); } @@ -202,12 +202,12 @@ occupantswin_occupants(const char *const roomjid) void occupantswin_occupants_all(void) { - GList *rooms = muc_rooms(); - GList *curr = rooms; + GList* rooms = muc_rooms(); + GList* curr = rooms; while (curr) { char* roomjid = curr->data; - ProfMucWin *mw = wins_get_muc(roomjid); + ProfMucWin* mw = wins_get_muc(roomjid); if (mw != NULL) { mucwin_update_occupants(mw); } diff --git a/src/ui/privwin.c b/src/ui/privwin.c index c18588fb..e4e6e29a 100644 --- a/src/ui/privwin.c +++ b/src/ui/privwin.c @@ -44,14 +44,14 @@ #include "ui/window_list.h" void -privwin_incoming_msg(ProfPrivateWin *privatewin, ProfMessage *message) +privwin_incoming_msg(ProfPrivateWin* privatewin, ProfMessage* message) { assert(privatewin != NULL); - ProfWin *window = (ProfWin*) privatewin; + ProfWin* window = (ProfWin*)privatewin; int num = wins_get_num(window); - Jid *jidp = jid_create(privatewin->fulljid); + Jid* jidp = jid_create(privatewin->fulljid); if (jidp == NULL) { return; } @@ -65,7 +65,7 @@ privwin_incoming_msg(ProfPrivateWin *privatewin, ProfMessage *message) title_bar_set_typing(FALSE); status_bar_active(num, WIN_PRIVATE, privatewin->fulljid); - // not currently viewing chat window with sender + // not currently viewing chat window with sender } else { status_bar_new(num, WIN_PRIVATE, privatewin->fulljid); cons_show_incoming_private_message(jidp->resourcepart, jidp->barejid, num, privatewin->unread); @@ -93,15 +93,15 @@ privwin_incoming_msg(ProfPrivateWin *privatewin, ProfMessage *message) } void -privwin_outgoing_msg(ProfPrivateWin *privwin, const char *const message) +privwin_outgoing_msg(ProfPrivateWin* privwin, const char* const message) { assert(privwin != NULL); - win_print_outgoing((ProfWin*)privwin, "-", NULL, NULL , message); + win_print_outgoing((ProfWin*)privwin, "-", NULL, NULL, message); } void -privwin_message_occupant_offline(ProfPrivateWin *privwin) +privwin_message_occupant_offline(ProfPrivateWin* privwin) { assert(privwin != NULL); @@ -109,7 +109,7 @@ privwin_message_occupant_offline(ProfPrivateWin *privwin) } void -privwin_message_left_room(ProfPrivateWin *privwin) +privwin_message_left_room(ProfPrivateWin* privwin) { assert(privwin != NULL); @@ -117,24 +117,24 @@ privwin_message_left_room(ProfPrivateWin *privwin) } void -privwin_occupant_offline(ProfPrivateWin *privwin) +privwin_occupant_offline(ProfPrivateWin* privwin) { assert(privwin != NULL); privwin->occupant_offline = TRUE; - Jid *jidp = jid_create(privwin->fulljid); + Jid* jidp = jid_create(privwin->fulljid); win_println((ProfWin*)privwin, THEME_OFFLINE, "-", "<- %s has left the room.", jidp->resourcepart); jid_destroy(jidp); } void -privwin_occupant_kicked(ProfPrivateWin *privwin, const char *const actor, const char *const reason) +privwin_occupant_kicked(ProfPrivateWin* privwin, const char* const actor, const char* const reason) { assert(privwin != NULL); privwin->occupant_offline = TRUE; - Jid *jidp = jid_create(privwin->fulljid); - GString *message = g_string_new(jidp->resourcepart); + Jid* jidp = jid_create(privwin->fulljid); + GString* message = g_string_new(jidp->resourcepart); jid_destroy(jidp); g_string_append(message, " has been kicked from the room"); if (actor) { @@ -151,13 +151,13 @@ privwin_occupant_kicked(ProfPrivateWin *privwin, const char *const actor, const } void -privwin_occupant_banned(ProfPrivateWin *privwin, const char *const actor, const char *const reason) +privwin_occupant_banned(ProfPrivateWin* privwin, const char* const actor, const char* const reason) { assert(privwin != NULL); privwin->occupant_offline = TRUE; - Jid *jidp = jid_create(privwin->fulljid); - GString *message = g_string_new(jidp->resourcepart); + Jid* jidp = jid_create(privwin->fulljid); + GString* message = g_string_new(jidp->resourcepart); jid_destroy(jidp); g_string_append(message, " has been banned from the room"); if (actor) { @@ -174,57 +174,57 @@ privwin_occupant_banned(ProfPrivateWin *privwin, const char *const actor, const } void -privwin_occupant_online(ProfPrivateWin *privwin) +privwin_occupant_online(ProfPrivateWin* privwin) { assert(privwin != NULL); privwin->occupant_offline = FALSE; - Jid *jidp = jid_create(privwin->fulljid); + Jid* jidp = jid_create(privwin->fulljid); win_println((ProfWin*)privwin, THEME_ONLINE, "-", "-- %s has joined the room.", jidp->resourcepart); jid_destroy(jidp); } void -privwin_room_destroyed(ProfPrivateWin *privwin) +privwin_room_destroyed(ProfPrivateWin* privwin) { assert(privwin != NULL); privwin->room_left = TRUE; - Jid *jidp = jid_create(privwin->fulljid); + Jid* jidp = jid_create(privwin->fulljid); win_println((ProfWin*)privwin, THEME_OFFLINE, "!", "-- %s has been destroyed.", jidp->barejid); jid_destroy(jidp); } void -privwin_room_joined(ProfPrivateWin *privwin) +privwin_room_joined(ProfPrivateWin* privwin) { assert(privwin != NULL); privwin->room_left = FALSE; - Jid *jidp = jid_create(privwin->fulljid); + Jid* jidp = jid_create(privwin->fulljid); win_println((ProfWin*)privwin, THEME_OFFLINE, "!", "-- You have joined %s.", jidp->barejid); jid_destroy(jidp); } void -privwin_room_left(ProfPrivateWin *privwin) +privwin_room_left(ProfPrivateWin* privwin) { assert(privwin != NULL); privwin->room_left = TRUE; - Jid *jidp = jid_create(privwin->fulljid); + Jid* jidp = jid_create(privwin->fulljid); win_println((ProfWin*)privwin, THEME_OFFLINE, "!", "-- You have left %s.", jidp->barejid); jid_destroy(jidp); } void -privwin_room_kicked(ProfPrivateWin *privwin, const char *const actor, const char *const reason) +privwin_room_kicked(ProfPrivateWin* privwin, const char* const actor, const char* const reason) { assert(privwin != NULL); privwin->room_left = TRUE; - GString *message = g_string_new("Kicked from "); - Jid *jidp = jid_create(privwin->fulljid); + GString* message = g_string_new("Kicked from "); + Jid* jidp = jid_create(privwin->fulljid); g_string_append(message, jidp->barejid); jid_destroy(jidp); if (actor) { @@ -241,13 +241,13 @@ privwin_room_kicked(ProfPrivateWin *privwin, const char *const actor, const char } void -privwin_room_banned(ProfPrivateWin *privwin, const char *const actor, const char *const reason) +privwin_room_banned(ProfPrivateWin* privwin, const char* const actor, const char* const reason) { assert(privwin != NULL); privwin->room_left = TRUE; - GString *message = g_string_new("Banned from "); - Jid *jidp = jid_create(privwin->fulljid); + GString* message = g_string_new("Banned from "); + Jid* jidp = jid_create(privwin->fulljid); g_string_append(message, jidp->barejid); jid_destroy(jidp); if (actor) { @@ -264,18 +264,18 @@ privwin_room_banned(ProfPrivateWin *privwin, const char *const actor, const char } char* -privwin_get_string(ProfPrivateWin *privwin) +privwin_get_string(ProfPrivateWin* privwin) { assert(privwin != NULL); - GString *res = g_string_new("Private "); + GString* res = g_string_new("Private "); g_string_append(res, privwin->fulljid); if (privwin->unread > 0) { g_string_append_printf(res, ", %d unread", privwin->unread); } - char *resstr = res->str; + char* resstr = res->str; g_string_free(res, FALSE); return resstr; diff --git a/src/ui/rosterwin.c b/src/ui/rosterwin.c index eb025c4e..3375414c 100644 --- a/src/ui/rosterwin.c +++ b/src/ui/rosterwin.c @@ -51,39 +51,39 @@ typedef enum { ROSTER_CONTACT_UNREAD } roster_contact_theme_t; -static void _rosterwin_contacts_all(ProfLayoutSplit *layout); -static void _rosterwin_contacts_by_presence(ProfLayoutSplit *layout, const char *const presence, char *title); -static void _rosterwin_contacts_by_group(ProfLayoutSplit *layout, char *group); -static void _rosteriwin_unsubscribed(ProfLayoutSplit *layout); -static void _rosterwin_contacts_header(ProfLayoutSplit *layout, const char *title, GSList *contacts); -static void _rosterwin_unsubscribed_header(ProfLayoutSplit *layout, GList *wins); - -static void _rosterwin_contact(ProfLayoutSplit *layout, PContact contact); -static void _rosterwin_unsubscribed_item(ProfLayoutSplit *layout, ProfChatWin *chatwin); -static void _rosterwin_presence(ProfLayoutSplit *layout, const char *presence, const char *status, - int current_indent); -static void _rosterwin_resources(ProfLayoutSplit *layout, PContact contact, int current_indent, - roster_contact_theme_t theme_type, int unread); - -static void _rosterwin_rooms(ProfLayoutSplit *layout, char *title, GList *rooms); -static void _rosterwin_rooms_by_service(ProfLayoutSplit *layout); -static void _rosterwin_rooms_header(ProfLayoutSplit *layout, GList *rooms, char *title); -static void _rosterwin_room(ProfLayoutSplit *layout, ProfMucWin *mucwin); -static void _rosterwin_print_rooms(ProfLayoutSplit *layout); - -static void _rosterwin_private_chats(ProfLayoutSplit *layout, GList *orphaned_privchats); -static void _rosterwin_private_header(ProfLayoutSplit *layout, GList *privs); - -static GSList* _filter_contacts(GSList *contacts); -static GSList* _filter_contacts_with_presence(GSList *contacts, const char *const presence); -static theme_item_t _get_roster_theme(roster_contact_theme_t theme_type, const char *presence); -static int _compare_rooms_name(ProfMucWin *a, ProfMucWin *b); -static int _compare_rooms_unread(ProfMucWin *a, ProfMucWin *b); +static void _rosterwin_contacts_all(ProfLayoutSplit* layout); +static void _rosterwin_contacts_by_presence(ProfLayoutSplit* layout, const char* const presence, char* title); +static void _rosterwin_contacts_by_group(ProfLayoutSplit* layout, char* group); +static void _rosteriwin_unsubscribed(ProfLayoutSplit* layout); +static void _rosterwin_contacts_header(ProfLayoutSplit* layout, const char* title, GSList* contacts); +static void _rosterwin_unsubscribed_header(ProfLayoutSplit* layout, GList* wins); + +static void _rosterwin_contact(ProfLayoutSplit* layout, PContact contact); +static void _rosterwin_unsubscribed_item(ProfLayoutSplit* layout, ProfChatWin* chatwin); +static void _rosterwin_presence(ProfLayoutSplit* layout, const char* presence, const char* status, + int current_indent); +static void _rosterwin_resources(ProfLayoutSplit* layout, PContact contact, int current_indent, + roster_contact_theme_t theme_type, int unread); + +static void _rosterwin_rooms(ProfLayoutSplit* layout, char* title, GList* rooms); +static void _rosterwin_rooms_by_service(ProfLayoutSplit* layout); +static void _rosterwin_rooms_header(ProfLayoutSplit* layout, GList* rooms, char* title); +static void _rosterwin_room(ProfLayoutSplit* layout, ProfMucWin* mucwin); +static void _rosterwin_print_rooms(ProfLayoutSplit* layout); + +static void _rosterwin_private_chats(ProfLayoutSplit* layout, GList* orphaned_privchats); +static void _rosterwin_private_header(ProfLayoutSplit* layout, GList* privs); + +static GSList* _filter_contacts(GSList* contacts); +static GSList* _filter_contacts_with_presence(GSList* contacts, const char* const presence); +static theme_item_t _get_roster_theme(roster_contact_theme_t theme_type, const char* presence); +static int _compare_rooms_name(ProfMucWin* a, ProfMucWin* b); +static int _compare_rooms_unread(ProfMucWin* a, ProfMucWin* b); void rosterwin_roster(void) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); if (!console) { return; } @@ -93,20 +93,20 @@ rosterwin_roster(void) return; } - ProfLayoutSplit *layout = (ProfLayoutSplit*)console->layout; + ProfLayoutSplit* layout = (ProfLayoutSplit*)console->layout; assert(layout->memcheck == LAYOUT_SPLIT_MEMCHECK); werase(layout->subwin); - char *roomspos = prefs_get_string(PREF_ROSTER_ROOMS_POS); + char* roomspos = prefs_get_string(PREF_ROSTER_ROOMS_POS); if (prefs_get_boolean(PREF_ROSTER_ROOMS) && (g_strcmp0(roomspos, "first") == 0)) { _rosterwin_print_rooms(layout); - GList *orphaned_privchats = NULL; - GList *privchats = wins_get_private_chats(NULL); - GList *curr = privchats; + GList* orphaned_privchats = NULL; + GList* privchats = wins_get_private_chats(NULL); + GList* curr = privchats; while (curr) { - ProfPrivateWin *privwin = curr->data; - Jid *jidp = jid_create(privwin->fulljid); + ProfPrivateWin* privwin = curr->data; + Jid* jidp = jid_create(privwin->fulljid); if (!muc_active(jidp->barejid)) { orphaned_privchats = g_list_append(orphaned_privchats, privwin); } @@ -114,17 +114,16 @@ rosterwin_roster(void) curr = g_list_next(curr); } - char *privpref = prefs_get_string(PREF_ROSTER_PRIVATE); + char* privpref = prefs_get_string(PREF_ROSTER_PRIVATE); if (g_strcmp0(privpref, "group") == 0 || orphaned_privchats) { _rosterwin_private_chats(layout, orphaned_privchats); } g_free(privpref); g_list_free(orphaned_privchats); - } if (prefs_get_boolean(PREF_ROSTER_CONTACTS)) { - char *by = prefs_get_string(PREF_ROSTER_BY); + char* by = prefs_get_string(PREF_ROSTER_BY); if (g_strcmp0(by, "presence") == 0) { _rosterwin_contacts_by_presence(layout, "chat", "Available for chat"); _rosterwin_contacts_by_presence(layout, "online", "Online"); @@ -133,8 +132,8 @@ rosterwin_roster(void) _rosterwin_contacts_by_presence(layout, "dnd", "Do not disturb"); _rosterwin_contacts_by_presence(layout, "offline", "Offline"); } else if (g_strcmp0(by, "group") == 0) { - GList *groups = roster_get_groups(); - GList *curr_group = groups; + GList* groups = roster_get_groups(); + GList* curr_group = groups; while (curr_group) { _rosterwin_contacts_by_group(layout, curr_group->data); curr_group = g_list_next(curr_group); @@ -154,12 +153,12 @@ rosterwin_roster(void) if (prefs_get_boolean(PREF_ROSTER_ROOMS) && (g_strcmp0(roomspos, "last") == 0)) { _rosterwin_print_rooms(layout); - GList *orphaned_privchats = NULL; - GList *privchats = wins_get_private_chats(NULL); - GList *curr = privchats; + GList* orphaned_privchats = NULL; + GList* privchats = wins_get_private_chats(NULL); + GList* curr = privchats; while (curr) { - ProfPrivateWin *privwin = curr->data; - Jid *jidp = jid_create(privwin->fulljid); + ProfPrivateWin* privwin = curr->data; + Jid* jidp = jid_create(privwin->fulljid); if (!muc_active(jidp->barejid)) { orphaned_privchats = g_list_append(orphaned_privchats, privwin); } @@ -167,7 +166,7 @@ rosterwin_roster(void) curr = g_list_next(curr); } - char *privpref = prefs_get_string(PREF_ROSTER_PRIVATE); + char* privpref = prefs_get_string(PREF_ROSTER_PRIVATE); if (g_strcmp0(privpref, "group") == 0 || orphaned_privchats) { _rosterwin_private_chats(layout, orphaned_privchats); } @@ -180,11 +179,11 @@ rosterwin_roster(void) } static void -_rosterwin_contacts_all(ProfLayoutSplit *layout) +_rosterwin_contacts_all(ProfLayoutSplit* layout) { - GSList *contacts = NULL; + GSList* contacts = NULL; - char *order = prefs_get_string(PREF_ROSTER_ORDER); + char* order = prefs_get_string(PREF_ROSTER_ORDER); if (g_strcmp0(order, "presence") == 0) { contacts = roster_get_contacts(ROSTER_ORD_PRESENCE); } else { @@ -192,13 +191,13 @@ _rosterwin_contacts_all(ProfLayoutSplit *layout) } g_free(order); - GSList *filtered_contacts = _filter_contacts(contacts); + GSList* filtered_contacts = _filter_contacts(contacts); g_slist_free(contacts); _rosterwin_contacts_header(layout, "Roster", filtered_contacts); if (filtered_contacts) { - GSList *curr_contact = filtered_contacts; + GSList* curr_contact = filtered_contacts; while (curr_contact) { PContact contact = curr_contact->data; _rosterwin_contact(layout, contact); @@ -209,16 +208,16 @@ _rosterwin_contacts_all(ProfLayoutSplit *layout) } static void -_rosteriwin_unsubscribed(ProfLayoutSplit *layout) +_rosteriwin_unsubscribed(ProfLayoutSplit* layout) { - GList *wins = wins_get_chat_unsubscribed(); + GList* wins = wins_get_chat_unsubscribed(); if (wins) { _rosterwin_unsubscribed_header(layout, wins); } - GList *curr = wins; + GList* curr = wins; while (curr) { - ProfChatWin *chatwin = curr->data; + ProfChatWin* chatwin = curr->data; _rosterwin_unsubscribed_item(layout, chatwin); curr = g_list_next(curr); } @@ -227,10 +226,10 @@ _rosteriwin_unsubscribed(ProfLayoutSplit *layout) } static void -_rosterwin_contacts_by_presence(ProfLayoutSplit *layout, const char *const presence, char *title) +_rosterwin_contacts_by_presence(ProfLayoutSplit* layout, const char* const presence, char* title) { - GSList *contacts = roster_get_contacts_by_presence(presence); - GSList *filtered_contacts = _filter_contacts_with_presence(contacts, presence); + GSList* contacts = roster_get_contacts_by_presence(presence); + GSList* filtered_contacts = _filter_contacts_with_presence(contacts, presence); g_slist_free(contacts); // if this group has contacts, or if we want to show empty groups @@ -239,7 +238,7 @@ _rosterwin_contacts_by_presence(ProfLayoutSplit *layout, const char *const prese } if (filtered_contacts) { - GSList *curr_contact = filtered_contacts; + GSList* curr_contact = filtered_contacts; while (curr_contact) { PContact contact = curr_contact->data; _rosterwin_contact(layout, contact); @@ -250,11 +249,11 @@ _rosterwin_contacts_by_presence(ProfLayoutSplit *layout, const char *const prese } static void -_rosterwin_contacts_by_group(ProfLayoutSplit *layout, char *group) +_rosterwin_contacts_by_group(ProfLayoutSplit* layout, char* group) { - GSList *contacts = NULL; + GSList* contacts = NULL; - char *order = prefs_get_string(PREF_ROSTER_ORDER); + char* order = prefs_get_string(PREF_ROSTER_ORDER); if (g_strcmp0(order, "presence") == 0) { contacts = roster_get_group(group, ROSTER_ORD_PRESENCE); } else { @@ -262,7 +261,7 @@ _rosterwin_contacts_by_group(ProfLayoutSplit *layout, char *group) } g_free(order); - GSList *filtered_contacts = _filter_contacts(contacts); + GSList* filtered_contacts = _filter_contacts(contacts); g_slist_free(contacts); if (filtered_contacts || prefs_get_boolean(PREF_ROSTER_EMPTY)) { @@ -272,7 +271,7 @@ _rosterwin_contacts_by_group(ProfLayoutSplit *layout, char *group) _rosterwin_contacts_header(layout, "no group", filtered_contacts); } - GSList *curr_contact = filtered_contacts; + GSList* curr_contact = filtered_contacts; while (curr_contact) { PContact contact = curr_contact->data; _rosterwin_contact(layout, contact); @@ -283,10 +282,10 @@ _rosterwin_contacts_by_group(ProfLayoutSplit *layout, char *group) } static void -_rosterwin_unsubscribed_item(ProfLayoutSplit *layout, ProfChatWin *chatwin) +_rosterwin_unsubscribed_item(ProfLayoutSplit* layout, ProfChatWin* chatwin) { - const char *const name = chatwin->barejid; - const char *const presence = "offline"; + const char* const name = chatwin->barejid; + const char* const presence = "offline"; int unread = 0; roster_contact_theme_t theme_type = ROSTER_CONTACT; @@ -300,7 +299,7 @@ _rosterwin_unsubscribed_item(ProfLayoutSplit *layout, ProfChatWin *chatwin) theme_item_t presence_colour = _get_roster_theme(theme_type, presence); wattron(layout->subwin, theme_attrs(presence_colour)); - GString *msg = g_string_new(" "); + GString* msg = g_string_new(" "); int indent = prefs_get_roster_contact_indent(); int current_indent = 0; if (indent > 0) { @@ -315,7 +314,7 @@ _rosterwin_unsubscribed_item(ProfLayoutSplit *layout, ProfChatWin *chatwin) g_string_append_printf(msg, "%c", ch); } - char *unreadpos = prefs_get_string(PREF_ROSTER_UNREAD); + char* unreadpos = prefs_get_string(PREF_ROSTER_UNREAD); if ((g_strcmp0(unreadpos, "before") == 0) && unread > 0) { g_string_append_printf(msg, "(%d) ", unread); unread = 0; @@ -334,16 +333,16 @@ _rosterwin_unsubscribed_item(ProfLayoutSplit *layout, ProfChatWin *chatwin) } static void -_rosterwin_contact(ProfLayoutSplit *layout, PContact contact) +_rosterwin_contact(ProfLayoutSplit* layout, PContact contact) { - const char *name = p_contact_name_or_jid(contact); - const char *presence = p_contact_presence(contact); - const char *status = p_contact_status(contact); - const char *barejid = p_contact_barejid(contact); + const char* name = p_contact_name_or_jid(contact); + const char* presence = p_contact_presence(contact); + const char* status = p_contact_status(contact); + const char* barejid = p_contact_barejid(contact); int unread = 0; roster_contact_theme_t theme_type = ROSTER_CONTACT; - ProfChatWin *chatwin = wins_get_chat(barejid); + ProfChatWin* chatwin = wins_get_chat(barejid); if (chatwin) { if (chatwin->unread > 0) { theme_type = ROSTER_CONTACT_UNREAD; @@ -362,7 +361,7 @@ _rosterwin_contact(ProfLayoutSplit *layout, PContact contact) wattron(layout->subwin, theme_attrs(presence_colour)); } - GString *msg = g_string_new(" "); + GString* msg = g_string_new(" "); int indent = prefs_get_roster_contact_indent(); int current_indent = 0; if (indent > 0) { @@ -377,7 +376,7 @@ _rosterwin_contact(ProfLayoutSplit *layout, PContact contact) g_string_append_printf(msg, "%c", ch); } - char *unreadpos = prefs_get_string(PREF_ROSTER_UNREAD); + char* unreadpos = prefs_get_string(PREF_ROSTER_UNREAD); if ((g_strcmp0(unreadpos, "before") == 0) && unread > 0) { g_string_append_printf(msg, "(%d) ", unread); unread = 0; @@ -408,7 +407,7 @@ _rosterwin_contact(ProfLayoutSplit *layout, PContact contact) _rosterwin_resources(layout, contact, current_indent, theme_type, unread); } else if (prefs_get_boolean(PREF_ROSTER_PRESENCE) || prefs_get_boolean(PREF_ROSTER_STATUS)) { if (unread > 0) { - GString *unreadmsg = g_string_new(""); + GString* unreadmsg = g_string_new(""); g_string_append_printf(unreadmsg, " (%d)", unread); wattron(layout->subwin, theme_attrs(presence_colour)); @@ -422,8 +421,8 @@ _rosterwin_contact(ProfLayoutSplit *layout, PContact contact) } static void -_rosterwin_presence(ProfLayoutSplit *layout, const char *presence, const char *status, - int current_indent) +_rosterwin_presence(ProfLayoutSplit* layout, const char* presence, const char* status, + int current_indent) { // don't show presence for offline contacts gboolean is_offline = g_strcmp0(presence, "offline") == 0; @@ -431,7 +430,7 @@ _rosterwin_presence(ProfLayoutSplit *layout, const char *presence, const char *s return; } - char *by = prefs_get_string(PREF_ROSTER_BY); + char* by = prefs_get_string(PREF_ROSTER_BY); gboolean by_presence = g_strcmp0(by, "presence") == 0; g_free(by); @@ -449,13 +448,13 @@ _rosterwin_presence(ProfLayoutSplit *layout, const char *presence, const char *s wattron(layout->subwin, theme_attrs(colour)); if (presence_indent == -1) { - GString *msg = g_string_new(""); + GString* msg = g_string_new(""); g_string_append_printf(msg, ": \"%s\"", status); win_sub_print(layout->subwin, msg->str, FALSE, wrap, current_indent); g_string_free(msg, TRUE); wattroff(layout->subwin, theme_attrs(colour)); } else { - GString *msg = g_string_new(" "); + GString* msg = g_string_new(" "); while (current_indent > 0) { g_string_append(msg, " "); current_indent--; @@ -468,11 +467,11 @@ _rosterwin_presence(ProfLayoutSplit *layout, const char *presence, const char *s } } - // show both presence and status when not grouped by presence + // show both presence and status when not grouped by presence } else if (prefs_get_boolean(PREF_ROSTER_PRESENCE) || (status && prefs_get_boolean(PREF_ROSTER_STATUS))) { wattron(layout->subwin, theme_attrs(colour)); if (presence_indent == -1) { - GString *msg = g_string_new(""); + GString* msg = g_string_new(""); if (prefs_get_boolean(PREF_ROSTER_PRESENCE)) { g_string_append_printf(msg, ": %s", presence); if (status && prefs_get_boolean(PREF_ROSTER_STATUS)) { @@ -485,7 +484,7 @@ _rosterwin_presence(ProfLayoutSplit *layout, const char *presence, const char *s g_string_free(msg, TRUE); wattroff(layout->subwin, theme_attrs(colour)); } else { - GString *msg = g_string_new(" "); + GString* msg = g_string_new(" "); while (current_indent > 0) { g_string_append(msg, " "); current_indent--; @@ -507,22 +506,22 @@ _rosterwin_presence(ProfLayoutSplit *layout, const char *presence, const char *s } static void -_rosterwin_resources(ProfLayoutSplit *layout, PContact contact, int current_indent, roster_contact_theme_t theme_type, - int unread) +_rosterwin_resources(ProfLayoutSplit* layout, PContact contact, int current_indent, roster_contact_theme_t theme_type, + int unread) { gboolean join = prefs_get_boolean(PREF_ROSTER_RESOURCE_JOIN); - GList *resources = p_contact_get_available_resources(contact); + GList* resources = p_contact_get_available_resources(contact); if (resources) { // resource on same line as contact if (join && (g_list_length(resources) == 1)) { - Resource *resource = resources->data; - const char *resource_presence = string_from_resource_presence(resource->presence); + Resource* resource = resources->data; + const char* resource_presence = string_from_resource_presence(resource->presence); theme_item_t resource_presence_colour = _get_roster_theme(theme_type, resource_presence); wattron(layout->subwin, theme_attrs(resource_presence_colour)); - GString *msg = g_string_new(""); + GString* msg = g_string_new(""); char ch = prefs_get_roster_resource_char(); if (ch) { g_string_append_printf(msg, "%c", ch); @@ -534,7 +533,7 @@ _rosterwin_resources(ProfLayoutSplit *layout, PContact contact, int current_inde g_string_append_printf(msg, " %d", resource->priority); } - char *unreadpos = prefs_get_string(PREF_ROSTER_UNREAD); + char* unreadpos = prefs_get_string(PREF_ROSTER_UNREAD); if ((g_strcmp0(unreadpos, "after") == 0) && unread > 0) { g_string_append_printf(msg, " (%d)", unread); } @@ -549,16 +548,16 @@ _rosterwin_resources(ProfLayoutSplit *layout, PContact contact, int current_inde _rosterwin_presence(layout, resource_presence, resource->status, current_indent); } - // resource(s) on new lines + // resource(s) on new lines } else { gboolean wrap = prefs_get_boolean(PREF_ROSTER_WRAP); - char *unreadpos = prefs_get_string(PREF_ROSTER_UNREAD); + char* unreadpos = prefs_get_string(PREF_ROSTER_UNREAD); if ((g_strcmp0(unreadpos, "after") == 0) && unread > 0) { - GString *unreadmsg = g_string_new(""); + GString* unreadmsg = g_string_new(""); g_string_append_printf(unreadmsg, " (%d)", unread); - const char *presence = p_contact_presence(contact); + const char* presence = p_contact_presence(contact); theme_item_t presence_colour = _get_roster_theme(theme_type, presence); wattron(layout->subwin, theme_attrs(presence_colour)); @@ -573,14 +572,14 @@ _rosterwin_resources(ProfLayoutSplit *layout, PContact contact, int current_inde current_indent += resource_indent; } - GList *curr_resource = resources; + GList* curr_resource = resources; while (curr_resource) { - Resource *resource = curr_resource->data; - const char *resource_presence = string_from_resource_presence(resource->presence); + Resource* resource = curr_resource->data; + const char* resource_presence = string_from_resource_presence(resource->presence); theme_item_t resource_presence_colour = _get_roster_theme(ROSTER_CONTACT, resource_presence); wattron(layout->subwin, theme_attrs(resource_presence_colour)); - GString *msg = g_string_new(" "); + GString* msg = g_string_new(" "); int this_indent = current_indent; while (this_indent > 0) { g_string_append(msg, " "); @@ -607,14 +606,14 @@ _rosterwin_resources(ProfLayoutSplit *layout, PContact contact, int current_inde } } } else if (prefs_get_boolean(PREF_ROSTER_PRESENCE) || prefs_get_boolean(PREF_ROSTER_STATUS)) { - const char *presence = p_contact_presence(contact); - const char *status = p_contact_status(contact); + const char* presence = p_contact_presence(contact); + const char* status = p_contact_status(contact); theme_item_t presence_colour = _get_roster_theme(theme_type, presence); gboolean wrap = prefs_get_boolean(PREF_ROSTER_WRAP); - char *unreadpos = prefs_get_string(PREF_ROSTER_UNREAD); + char* unreadpos = prefs_get_string(PREF_ROSTER_UNREAD); if ((g_strcmp0(unreadpos, "after") == 0) && unread > 0) { - GString *unreadmsg = g_string_new(""); + GString* unreadmsg = g_string_new(""); g_string_append_printf(unreadmsg, " (%d)", unread); wattron(layout->subwin, theme_attrs(presence_colour)); @@ -627,11 +626,11 @@ _rosterwin_resources(ProfLayoutSplit *layout, PContact contact, int current_inde } else { gboolean wrap = prefs_get_boolean(PREF_ROSTER_WRAP); - char *unreadpos = prefs_get_string(PREF_ROSTER_UNREAD); + char* unreadpos = prefs_get_string(PREF_ROSTER_UNREAD); if ((g_strcmp0(unreadpos, "after") == 0) && unread > 0) { - GString *unreadmsg = g_string_new(""); + GString* unreadmsg = g_string_new(""); g_string_append_printf(unreadmsg, " (%d)", unread); - const char *presence = p_contact_presence(contact); + const char* presence = p_contact_presence(contact); theme_item_t presence_colour = _get_roster_theme(theme_type, presence); wattron(layout->subwin, theme_attrs(presence_colour)); @@ -643,18 +642,17 @@ _rosterwin_resources(ProfLayoutSplit *layout, PContact contact, int current_inde } g_list_free(resources); - } static void -_rosterwin_rooms(ProfLayoutSplit *layout, char *title, GList *rooms) +_rosterwin_rooms(ProfLayoutSplit* layout, char* title, GList* rooms) { - GList *rooms_sorted = NULL; - GList *curr_room = rooms; + GList* rooms_sorted = NULL; + GList* curr_room = rooms; while (curr_room) { - ProfMucWin *mucwin = wins_get_muc(curr_room->data); + ProfMucWin* mucwin = wins_get_muc(curr_room->data); if (mucwin) { - char *order = prefs_get_string(PREF_ROSTER_ROOMS_ORDER); + char* order = prefs_get_string(PREF_ROSTER_ROOMS_ORDER); if (g_strcmp0(order, "unread") == 0) { rooms_sorted = g_list_insert_sorted(rooms_sorted, mucwin, (GCompareFunc)_compare_rooms_unread); } else { @@ -669,7 +667,7 @@ _rosterwin_rooms(ProfLayoutSplit *layout, char *title, GList *rooms) if (rooms_sorted || prefs_get_boolean(PREF_ROSTER_EMPTY)) { _rosterwin_rooms_header(layout, rooms_sorted, title); - GList *curr_room = rooms_sorted; + GList* curr_room = rooms_sorted; while (curr_room) { _rosterwin_room(layout, curr_room->data); curr_room = g_list_next(curr_room); @@ -680,14 +678,14 @@ _rosterwin_rooms(ProfLayoutSplit *layout, char *title, GList *rooms) } static void -_rosterwin_rooms_by_service(ProfLayoutSplit *layout) +_rosterwin_rooms_by_service(ProfLayoutSplit* layout) { - GList *rooms = muc_rooms(); - GList *curr = rooms; - GList *services = NULL; + GList* rooms = muc_rooms(); + GList* curr = rooms; + GList* services = NULL; while (curr) { - char *roomjid = curr->data; - Jid *jidp = jid_create(roomjid); + char* roomjid = curr->data; + Jid* jidp = jid_create(roomjid); if (!g_list_find_custom(services, jidp->domainpart, (GCompareFunc)g_strcmp0)) { services = g_list_insert_sorted(services, strdup(jidp->domainpart), (GCompareFunc)g_strcmp0); @@ -697,15 +695,15 @@ _rosterwin_rooms_by_service(ProfLayoutSplit *layout) curr = g_list_next(curr); } - GList *curr_service = services; + GList* curr_service = services; while (curr_service) { - char *service = curr_service->data; - GList *filtered_rooms = NULL; + char* service = curr_service->data; + GList* filtered_rooms = NULL; curr = rooms; while (curr) { - char *roomjid = curr->data; - Jid *jidp = jid_create(roomjid); + char* roomjid = curr->data; + Jid* jidp = jid_create(roomjid); if (g_strcmp0(curr_service->data, jidp->domainpart) == 0) { filtered_rooms = g_list_append(filtered_rooms, strdup(jidp->barejid)); @@ -726,9 +724,9 @@ _rosterwin_rooms_by_service(ProfLayoutSplit *layout) } static void -_rosterwin_room(ProfLayoutSplit *layout, ProfMucWin *mucwin) +_rosterwin_room(ProfLayoutSplit* layout, ProfMucWin* mucwin) { - GString *msg = g_string_new(" "); + GString* msg = g_string_new(" "); if (mucwin->unread_mentions) { wattron(layout->subwin, theme_attrs(THEME_ROSTER_ROOM_MENTION)); @@ -754,17 +752,17 @@ _rosterwin_room(ProfLayoutSplit *layout, ProfMucWin *mucwin) g_string_append_printf(msg, "%c", ch); } - char *unreadpos = prefs_get_string(PREF_ROSTER_ROOMS_UNREAD); + char* unreadpos = prefs_get_string(PREF_ROSTER_ROOMS_UNREAD); if ((g_strcmp0(unreadpos, "before") == 0) && mucwin->unread > 0) { g_string_append_printf(msg, "(%d) ", mucwin->unread); } - char *use_as_name = prefs_get_string(PREF_ROSTER_ROOMS_USE_AS_NAME); - char *roombypref = prefs_get_string(PREF_ROSTER_ROOMS_BY); + char* use_as_name = prefs_get_string(PREF_ROSTER_ROOMS_USE_AS_NAME); + char* roombypref = prefs_get_string(PREF_ROSTER_ROOMS_BY); if (g_strcmp0(roombypref, "service") == 0) { if (mucwin->room_name == NULL || (g_strcmp0(use_as_name, "jid") == 0)) { - Jid *jidp = jid_create(mucwin->roomjid); + Jid* jidp = jid_create(mucwin->roomjid); g_string_append(msg, jidp->localpart); jid_destroy(jidp); } else { @@ -780,10 +778,9 @@ _rosterwin_room(ProfLayoutSplit *layout, ProfMucWin *mucwin) g_string_append(msg, mucwin->room_name); } } else { - Jid *jidp = jid_create(mucwin->roomjid); + Jid* jidp = jid_create(mucwin->roomjid); - if (mucwin->room_name == NULL || - (g_strcmp0(use_as_name, "jid") == 0)) { + if (mucwin->room_name == NULL || (g_strcmp0(use_as_name, "jid") == 0)) { g_string_append(msg, jidp->localpart); } else { g_string_append(msg, mucwin->room_name); @@ -816,15 +813,15 @@ _rosterwin_room(ProfLayoutSplit *layout, ProfMucWin *mucwin) wattroff(layout->subwin, theme_attrs(THEME_ROSTER_ROOM)); } - char *privpref = prefs_get_string(PREF_ROSTER_PRIVATE); + char* privpref = prefs_get_string(PREF_ROSTER_PRIVATE); if (g_strcmp0(privpref, "room") == 0) { - GList *privs = wins_get_private_chats(mucwin->roomjid); - GList *curr = privs; + GList* privs = wins_get_private_chats(mucwin->roomjid); + GList* curr = privs; while (curr) { - ProfPrivateWin *privwin = curr->data; + ProfPrivateWin* privwin = curr->data; win_sub_newline_lazy(layout->subwin); - GString *privmsg = g_string_new(" "); + GString* privmsg = g_string_new(" "); indent = prefs_get_roster_contact_indent(); current_indent = 0; if (indent > 0) { @@ -855,7 +852,7 @@ _rosterwin_room(ProfLayoutSplit *layout, ProfMucWin *mucwin) g_string_append_printf(privmsg, "%c", ch); } - char *nick = privwin->fulljid + strlen(mucwin->roomjid) + 1; + char* nick = privwin->fulljid + strlen(mucwin->roomjid) + 1; g_string_append(privmsg, nick); if ((g_strcmp0(unreadpos, "after") == 0) && privwin->unread > 0) { @@ -863,9 +860,9 @@ _rosterwin_room(ProfLayoutSplit *layout, ProfMucWin *mucwin) } g_free(unreadpos); - const char *presence = "offline"; + const char* presence = "offline"; - Occupant *occupant = muc_roster_item(mucwin->roomjid, nick); + Occupant* occupant = muc_roster_item(mucwin->roomjid, nick); if (occupant) { presence = string_from_resource_presence(occupant->presence); } @@ -892,13 +889,13 @@ _rosterwin_room(ProfLayoutSplit *layout, ProfMucWin *mucwin) } static void -_rosterwin_print_rooms(ProfLayoutSplit *layout) +_rosterwin_print_rooms(ProfLayoutSplit* layout) { - char *roomsbypref = prefs_get_string(PREF_ROSTER_ROOMS_BY); + char* roomsbypref = prefs_get_string(PREF_ROSTER_ROOMS_BY); if (g_strcmp0(roomsbypref, "service") == 0) { _rosterwin_rooms_by_service(layout); } else { - GList *rooms = muc_rooms(); + GList* rooms = muc_rooms(); _rosterwin_rooms(layout, "Rooms", rooms); g_list_free(rooms); } @@ -906,15 +903,15 @@ _rosterwin_print_rooms(ProfLayoutSplit *layout) } static void -_rosterwin_private_chats(ProfLayoutSplit *layout, GList *orphaned_privchats) +_rosterwin_private_chats(ProfLayoutSplit* layout, GList* orphaned_privchats) { - GList *privs = NULL; + GList* privs = NULL; - char *privpref = prefs_get_string(PREF_ROSTER_PRIVATE); + char* privpref = prefs_get_string(PREF_ROSTER_PRIVATE); if (g_strcmp0(privpref, "group") == 0) { privs = wins_get_private_chats(NULL); } else { - GList *curr = orphaned_privchats; + GList* curr = orphaned_privchats; while (curr) { privs = g_list_append(privs, curr->data); curr = g_list_next(curr); @@ -924,12 +921,12 @@ _rosterwin_private_chats(ProfLayoutSplit *layout, GList *orphaned_privchats) if (privs || prefs_get_boolean(PREF_ROSTER_EMPTY)) { _rosterwin_private_header(layout, privs); - GList *curr = privs; + GList* curr = privs; while (curr) { - ProfPrivateWin *privwin = curr->data; + ProfPrivateWin* privwin = curr->data; win_sub_newline_lazy(layout->subwin); - GString *privmsg = g_string_new(" "); + GString* privmsg = g_string_new(" "); int indent = prefs_get_roster_contact_indent(); int current_indent = 0; if (indent > 0) { @@ -940,7 +937,7 @@ _rosterwin_private_chats(ProfLayoutSplit *layout, GList *orphaned_privchats) } } - char *unreadpos = prefs_get_string(PREF_ROSTER_ROOMS_UNREAD); + char* unreadpos = prefs_get_string(PREF_ROSTER_ROOMS_UNREAD); if ((g_strcmp0(unreadpos, "before") == 0) && privwin->unread > 0) { g_string_append_printf(privmsg, "(%d) ", privwin->unread); } @@ -957,11 +954,11 @@ _rosterwin_private_chats(ProfLayoutSplit *layout, GList *orphaned_privchats) } g_free(unreadpos); - Jid *jidp = jid_create(privwin->fulljid); - Occupant *occupant = muc_roster_item(jidp->barejid, jidp->resourcepart); + Jid* jidp = jid_create(privwin->fulljid); + Occupant* occupant = muc_roster_item(jidp->barejid, jidp->resourcepart); jid_destroy(jidp); - const char *presence = "offline"; + const char* presence = "offline"; if (occupant) { presence = string_from_resource_presence(occupant->presence); } @@ -988,24 +985,28 @@ _rosterwin_private_chats(ProfLayoutSplit *layout, GList *orphaned_privchats) } static theme_item_t -_get_roster_theme(roster_contact_theme_t theme_type, const char *presence) +_get_roster_theme(roster_contact_theme_t theme_type, const char* presence) { switch (theme_type) { - case ROSTER_CONTACT: return theme_roster_presence_attrs(presence); - case ROSTER_CONTACT_ACTIVE: return theme_roster_active_presence_attrs(presence); - case ROSTER_CONTACT_UNREAD: return theme_roster_unread_presence_attrs(presence); - default: return theme_roster_presence_attrs(presence); + case ROSTER_CONTACT: + return theme_roster_presence_attrs(presence); + case ROSTER_CONTACT_ACTIVE: + return theme_roster_active_presence_attrs(presence); + case ROSTER_CONTACT_UNREAD: + return theme_roster_unread_presence_attrs(presence); + default: + return theme_roster_presence_attrs(presence); } } static int -_compare_rooms_name(ProfMucWin *a, ProfMucWin *b) +_compare_rooms_name(ProfMucWin* a, ProfMucWin* b) { return g_strcmp0(a->roomjid, b->roomjid); } static int -_compare_rooms_unread(ProfMucWin *a, ProfMucWin *b) +_compare_rooms_unread(ProfMucWin* a, ProfMucWin* b) { if (a->unread > b->unread) { return -1; @@ -1017,11 +1018,11 @@ _compare_rooms_unread(ProfMucWin *a, ProfMucWin *b) } static void -_rosterwin_unsubscribed_header(ProfLayoutSplit *layout, GList *wins) +_rosterwin_unsubscribed_header(ProfLayoutSplit* layout, GList* wins) { win_sub_newline_lazy(layout->subwin); - GString *header = g_string_new(" "); + GString* header = g_string_new(" "); char ch = prefs_get_roster_header_char(); if (ch) { g_string_append_printf(header, "%c", ch); @@ -1029,7 +1030,7 @@ _rosterwin_unsubscribed_header(ProfLayoutSplit *layout, GList *wins) g_string_append(header, "Unsubscribed"); - char *countpref = prefs_get_string(PREF_ROSTER_COUNT); + char* countpref = prefs_get_string(PREF_ROSTER_COUNT); if (g_strcmp0(countpref, "items") == 0) { int itemcount = g_list_length(wins); if (itemcount == 0 && prefs_get_boolean(PREF_ROSTER_COUNT_ZERO)) { @@ -1039,9 +1040,9 @@ _rosterwin_unsubscribed_header(ProfLayoutSplit *layout, GList *wins) } } else if (g_strcmp0(countpref, "unread") == 0) { int unreadcount = 0; - GList *curr = wins; + GList* curr = wins; while (curr) { - ProfChatWin *chatwin = curr->data; + ProfChatWin* chatwin = curr->data; unreadcount += chatwin->unread; curr = g_list_next(curr); } @@ -1063,11 +1064,11 @@ _rosterwin_unsubscribed_header(ProfLayoutSplit *layout, GList *wins) } static void -_rosterwin_contacts_header(ProfLayoutSplit *layout, const char *const title, GSList *contacts) +_rosterwin_contacts_header(ProfLayoutSplit* layout, const char* const title, GSList* contacts) { win_sub_newline_lazy(layout->subwin); - GString *header = g_string_new(" "); + GString* header = g_string_new(" "); char ch = prefs_get_roster_header_char(); if (ch) { g_string_append_printf(header, "%c", ch); @@ -1075,7 +1076,7 @@ _rosterwin_contacts_header(ProfLayoutSplit *layout, const char *const title, GSL g_string_append(header, title); - char *countpref = prefs_get_string(PREF_ROSTER_COUNT); + char* countpref = prefs_get_string(PREF_ROSTER_COUNT); if (g_strcmp0(countpref, "items") == 0) { int itemcount = g_slist_length(contacts); if (itemcount == 0 && prefs_get_boolean(PREF_ROSTER_COUNT_ZERO)) { @@ -1085,11 +1086,11 @@ _rosterwin_contacts_header(ProfLayoutSplit *layout, const char *const title, GSL } } else if (g_strcmp0(countpref, "unread") == 0) { int unreadcount = 0; - GSList *curr = contacts; + GSList* curr = contacts; while (curr) { PContact contact = curr->data; - const char *barejid = p_contact_barejid(contact); - ProfChatWin *chatwin = wins_get_chat(barejid); + const char* barejid = p_contact_barejid(contact); + ProfChatWin* chatwin = wins_get_chat(barejid); if (chatwin) { unreadcount += chatwin->unread; } @@ -1113,17 +1114,17 @@ _rosterwin_contacts_header(ProfLayoutSplit *layout, const char *const title, GSL } static void -_rosterwin_rooms_header(ProfLayoutSplit *layout, GList *rooms, char *title) +_rosterwin_rooms_header(ProfLayoutSplit* layout, GList* rooms, char* title) { win_sub_newline_lazy(layout->subwin); - GString *header = g_string_new(" "); + GString* header = g_string_new(" "); char ch = prefs_get_roster_header_char(); if (ch) { g_string_append_printf(header, "%c", ch); } g_string_append(header, title); - char *countpref = prefs_get_string(PREF_ROSTER_COUNT); + char* countpref = prefs_get_string(PREF_ROSTER_COUNT); if (g_strcmp0(countpref, "items") == 0) { int count = g_list_length(rooms); if (count == 0 && prefs_get_boolean(PREF_ROSTER_COUNT_ZERO)) { @@ -1133,18 +1134,18 @@ _rosterwin_rooms_header(ProfLayoutSplit *layout, GList *rooms, char *title) } } else if (g_strcmp0(countpref, "unread") == 0) { int unread = 0; - GList *curr = rooms; + GList* curr = rooms; while (curr) { - ProfMucWin *mucwin = curr->data; + ProfMucWin* mucwin = curr->data; unread += mucwin->unread; // include private chats - char *prefpriv = prefs_get_string(PREF_ROSTER_PRIVATE); + char* prefpriv = prefs_get_string(PREF_ROSTER_PRIVATE); if (g_strcmp0(prefpriv, "room") == 0) { - GList *privwins = wins_get_private_chats(mucwin->roomjid); - GList *curr_priv = privwins; + GList* privwins = wins_get_private_chats(mucwin->roomjid); + GList* curr_priv = privwins; while (curr_priv) { - ProfPrivateWin *privwin = curr_priv->data; + ProfPrivateWin* privwin = curr_priv->data; unread += privwin->unread; curr_priv = g_list_next(curr_priv); } @@ -1173,18 +1174,18 @@ _rosterwin_rooms_header(ProfLayoutSplit *layout, GList *rooms, char *title) } static void -_rosterwin_private_header(ProfLayoutSplit *layout, GList *privs) +_rosterwin_private_header(ProfLayoutSplit* layout, GList* privs) { win_sub_newline_lazy(layout->subwin); - GString *title_str = g_string_new(" "); + GString* title_str = g_string_new(" "); char ch = prefs_get_roster_header_char(); if (ch) { g_string_append_printf(title_str, "%c", ch); } g_string_append(title_str, "Private chats"); - char *countpref = prefs_get_string(PREF_ROSTER_COUNT); + char* countpref = prefs_get_string(PREF_ROSTER_COUNT); if (g_strcmp0(countpref, "items") == 0) { int itemcount = g_list_length(privs); if (itemcount == 0 && prefs_get_boolean(PREF_ROSTER_COUNT_ZERO)) { @@ -1194,9 +1195,9 @@ _rosterwin_private_header(ProfLayoutSplit *layout, GList *privs) } } else if (g_strcmp0(countpref, "unread") == 0) { int unreadcount = 0; - GList *curr = privs; + GList* curr = privs; while (curr) { - ProfPrivateWin *privwin = curr->data; + ProfPrivateWin* privwin = curr->data; unreadcount += privwin->unread; curr = g_list_next(curr); } @@ -1218,32 +1219,32 @@ _rosterwin_private_header(ProfLayoutSplit *layout, GList *privs) } static GSList* -_filter_contacts(GSList *contacts) +_filter_contacts(GSList* contacts) { - GSList *filtered_contacts = NULL; + GSList* filtered_contacts = NULL; // if show offline, include all contacts if (prefs_get_boolean(PREF_ROSTER_OFFLINE)) { - GSList *curr = contacts; + GSList* curr = contacts; while (curr) { filtered_contacts = g_slist_append(filtered_contacts, curr->data); curr = g_slist_next(curr); } - // if dont show offline + // if dont show offline } else { - GSList *curr = contacts; + GSList* curr = contacts; while (curr) { PContact contact = curr->data; - const char *presence = p_contact_presence(contact); + const char* presence = p_contact_presence(contact); // include if offline and unread messages if (g_strcmp0(presence, "offline") == 0) { - ProfChatWin *chatwin = wins_get_chat(p_contact_barejid(contact)); + ProfChatWin* chatwin = wins_get_chat(p_contact_barejid(contact)); if (chatwin && chatwin->unread > 0) { filtered_contacts = g_slist_append(filtered_contacts, contact); } - // include if not offline + // include if not offline } else { filtered_contacts = g_slist_append(filtered_contacts, contact); } @@ -1255,27 +1256,27 @@ _filter_contacts(GSList *contacts) } static GSList* -_filter_contacts_with_presence(GSList *contacts, const char *const presence) +_filter_contacts_with_presence(GSList* contacts, const char* const presence) { - GSList *filtered_contacts = NULL; + GSList* filtered_contacts = NULL; // handling offline contacts if (g_strcmp0(presence, "offline") == 0) { // if show offline, include all contacts if (prefs_get_boolean(PREF_ROSTER_OFFLINE)) { - GSList *curr = contacts; + GSList* curr = contacts; while (curr) { filtered_contacts = g_slist_append(filtered_contacts, curr->data); curr = g_slist_next(curr); } - // otherwise show if unread messages + // otherwise show if unread messages } else { - GSList *curr = contacts; + GSList* curr = contacts; while (curr) { PContact contact = curr->data; - ProfChatWin *chatwin = wins_get_chat(p_contact_barejid(contact)); + ProfChatWin* chatwin = wins_get_chat(p_contact_barejid(contact)); if (chatwin && chatwin->unread > 0) { filtered_contacts = g_slist_append(filtered_contacts, contact); } @@ -1283,9 +1284,9 @@ _filter_contacts_with_presence(GSList *contacts, const char *const presence) } } - // any other presence, include all + // any other presence, include all } else { - GSList *curr = contacts; + GSList* curr = contacts; while (curr) { filtered_contacts = g_slist_append(filtered_contacts, curr->data); curr = g_slist_next(curr); diff --git a/src/ui/screen.c b/src/ui/screen.c index 2e6faf4b..8a676082 100644 --- a/src/ui/screen.c +++ b/src/ui/screen.c @@ -44,7 +44,8 @@ #include "config/preferences.h" int -_screen_line_row(int win_pos, int mainwin_pos) { +_screen_line_row(int win_pos, int mainwin_pos) +{ int wrows = getmaxy(stdscr); if (win_pos == 1) { @@ -54,7 +55,7 @@ _screen_line_row(int win_pos, int mainwin_pos) { if (win_pos == 2) { int row = 1; if (mainwin_pos == 1) { - row = wrows-3; + row = wrows - 3; } return row; @@ -63,19 +64,19 @@ _screen_line_row(int win_pos, int mainwin_pos) { if (win_pos == 3) { int row = 2; if (mainwin_pos == 1 || mainwin_pos == 2) { - row = wrows-2; + row = wrows - 2; } return row; } - return wrows-1; + return wrows - 1; } int screen_titlebar_row(void) { - ProfWinPlacement *placement = prefs_get_win_placement(); + ProfWinPlacement* placement = prefs_get_win_placement(); int row = _screen_line_row(placement->titlebar_pos, placement->mainwin_pos); prefs_free_win_placement(placement); @@ -85,7 +86,7 @@ screen_titlebar_row(void) int screen_statusbar_row(void) { - ProfWinPlacement *placement = prefs_get_win_placement(); + ProfWinPlacement* placement = prefs_get_win_placement(); int row = _screen_line_row(placement->statusbar_pos, placement->mainwin_pos); prefs_free_win_placement(placement); @@ -95,7 +96,7 @@ screen_statusbar_row(void) int screen_inputwin_row(void) { - ProfWinPlacement *placement = prefs_get_win_placement(); + ProfWinPlacement* placement = prefs_get_win_placement(); int row = _screen_line_row(placement->inputwin_pos, placement->mainwin_pos); prefs_free_win_placement(placement); @@ -105,8 +106,8 @@ screen_inputwin_row(void) int screen_mainwin_row_start(void) { - ProfWinPlacement *placement = prefs_get_win_placement(); - int row = placement->mainwin_pos-1; + ProfWinPlacement* placement = prefs_get_win_placement(); + int row = placement->mainwin_pos - 1; prefs_free_win_placement(placement); return row; @@ -115,7 +116,7 @@ screen_mainwin_row_start(void) int screen_mainwin_row_end(void) { - ProfWinPlacement *placement = prefs_get_win_placement(); + ProfWinPlacement* placement = prefs_get_win_placement(); int wrows = getmaxy(stdscr); int row = wrows - (5 - placement->mainwin_pos); prefs_free_win_placement(placement); diff --git a/src/ui/statusbar.c b/src/ui/statusbar.c index d2c67483..146cc1ea 100644 --- a/src/ui/statusbar.c +++ b/src/ui/statusbar.c @@ -55,33 +55,35 @@ #include "xmpp/roster_list.h" #include "xmpp/contact.h" -typedef struct _status_bar_tab_t { +typedef struct _status_bar_tab_t +{ win_type_t window_type; - char *identifier; + char* identifier; gboolean highlight; - char *display_name; + char* display_name; } StatusBarTab; -typedef struct _status_bar_t { - gchar *time; - char *prompt; - char *fulljid; - GHashTable *tabs; +typedef struct _status_bar_t +{ + gchar* time; + char* prompt; + char* fulljid; + GHashTable* tabs; int current_tab; } StatusBar; -static GTimeZone *tz; -static StatusBar *statusbar; -static WINDOW *statusbar_win; +static GTimeZone* tz; +static StatusBar* statusbar; +static WINDOW* statusbar_win; static int _status_bar_draw_time(int pos); static void _status_bar_draw_maintext(int pos); static int _status_bar_draw_bracket(gboolean current, int pos, char* ch); static int _status_bar_draw_extended_tabs(int pos); -static int _status_bar_draw_tab(StatusBarTab *tab, int pos, int num); -static void _destroy_tab(StatusBarTab *tab); +static int _status_bar_draw_tab(StatusBarTab* tab, int pos, int num); +static void _destroy_tab(StatusBarTab* tab); static int _tabs_width(void); -static char* _display_name(StatusBarTab *tab); +static char* _display_name(StatusBarTab* tab); static gboolean _extended_new(void); void @@ -94,7 +96,7 @@ status_bar_init(void) statusbar->prompt = NULL; statusbar->fulljid = NULL; statusbar->tabs = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)_destroy_tab); - StatusBarTab *console = calloc(1, sizeof(StatusBarTab)); + StatusBarTab* console = calloc(1, sizeof(StatusBarTab)); console->window_type = WIN_CONSOLE; console->identifier = strdup("console"); console->display_name = NULL; @@ -175,14 +177,14 @@ status_bar_inactive(const int win) } void -_create_tab(const int win, win_type_t wintype, char *identifier, gboolean highlight) +_create_tab(const int win, win_type_t wintype, char* identifier, gboolean highlight) { int true_win = win; if (true_win == 0) { true_win = 10; } - StatusBarTab *tab = malloc(sizeof(StatusBarTab)); + StatusBarTab* tab = malloc(sizeof(StatusBarTab)); tab->identifier = strdup(identifier); tab->highlight = highlight; tab->window_type = wintype; @@ -196,13 +198,11 @@ _create_tab(const int win, win_type_t wintype, char *identifier, gboolean highli if (contact && p_contact_name(contact)) { tab->display_name = strdup(p_contact_name(contact)); } else { - char *pref = prefs_get_string(PREF_STATUSBAR_CHAT); + char* pref = prefs_get_string(PREF_STATUSBAR_CHAT); if (g_strcmp0("user", pref) == 0) { - Jid *jidp = jid_create(tab->identifier); + Jid* jidp = jid_create(tab->identifier); if (jidp) { - tab->display_name = jidp->localpart != NULL ? - strdup(jidp->localpart) : - strdup(jidp->barejid); + tab->display_name = jidp->localpart != NULL ? strdup(jidp->localpart) : strdup(jidp->barejid); jid_destroy(jidp); } else { tab->display_name = strdup(tab->identifier); @@ -220,7 +220,7 @@ _create_tab(const int win, win_type_t wintype, char *identifier, gboolean highli } void -status_bar_active(const int win, win_type_t wintype, char *identifier) +status_bar_active(const int win, win_type_t wintype, char* identifier) { _create_tab(win, wintype, identifier, FALSE); } @@ -232,7 +232,7 @@ status_bar_new(const int win, win_type_t wintype, char* identifier) } void -status_bar_set_prompt(const char *const prompt) +status_bar_set_prompt(const char* const prompt) { if (statusbar->prompt) { free(statusbar->prompt); @@ -255,7 +255,7 @@ status_bar_clear_prompt(void) } void -status_bar_set_fulljid(const char *const fulljid) +status_bar_set_fulljid(const char* const fulljid) { if (statusbar->fulljid) { free(statusbar->fulljid); @@ -296,7 +296,7 @@ status_bar_draw(void) gint max_tabs = prefs_get_statusbartabs(); int i = 1; for (i = 1; i <= max_tabs; i++) { - StatusBarTab *tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i)); + StatusBarTab* tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i)); if (tab) { pos = _status_bar_draw_tab(tab, pos, i); } @@ -319,7 +319,7 @@ _extended_new(void) int i = 0; for (i = max_tabs + 1; i <= tabs_count; i++) { - StatusBarTab *tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i)); + StatusBarTab* tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i)); if (tab && tab->highlight) { return TRUE; } @@ -364,7 +364,7 @@ _status_bar_draw_extended_tabs(int pos) } static int -_status_bar_draw_tab(StatusBarTab *tab, int pos, int num) +_status_bar_draw_tab(StatusBarTab* tab, int pos, int num) { int display_num = num == 10 ? 0 : num; gboolean is_current = num == statusbar->current_tab; @@ -397,7 +397,7 @@ _status_bar_draw_tab(StatusBarTab *tab, int pos, int num) pos++; } if (show_name) { - char *display_name = _display_name(tab); + char* display_name = _display_name(tab); mvwprintw(statusbar_win, 0, pos, display_name); pos += utf8_display_len(display_name); free(display_name); @@ -428,7 +428,7 @@ _status_bar_draw_bracket(gboolean current, int pos, char* ch) static int _status_bar_draw_time(int pos) { - char *time_pref = prefs_get_string(PREF_TIME_STATUSBAR); + char* time_pref = prefs_get_string(PREF_TIME_STATUSBAR); if (g_strcmp0(time_pref, "off") == 0) { g_free(time_pref); return pos; @@ -439,8 +439,8 @@ _status_bar_draw_time(int pos) statusbar->time = NULL; } - GDateTime *datetime = g_date_time_new_now(tz); - statusbar->time = g_date_time_format(datetime, time_pref); + GDateTime* datetime = g_date_time_new_now(tz); + statusbar->time = g_date_time_format(datetime, time_pref); assert(statusbar->time != NULL); g_date_time_unref(datetime); @@ -477,17 +477,17 @@ _status_bar_draw_maintext(int pos) gboolean stop = FALSE; if (statusbar->fulljid) { - char *pref = prefs_get_string(PREF_STATUSBAR_SELF); + char* pref = prefs_get_string(PREF_STATUSBAR_SELF); if (g_strcmp0(pref, "off") == 0) { stop = true; } else if (g_strcmp0(pref, "user") == 0) { - Jid *jidp = jid_create(statusbar->fulljid); + Jid* jidp = jid_create(statusbar->fulljid); mvwprintw(statusbar_win, 0, pos, jidp->localpart); jid_destroy(jidp); stop = true; } else if (g_strcmp0(pref, "barejid") == 0) { - Jid *jidp = jid_create(statusbar->fulljid); + Jid* jidp = jid_create(statusbar->fulljid); mvwprintw(statusbar_win, 0, pos, jidp->barejid); jid_destroy(jidp); stop = true; @@ -502,7 +502,7 @@ _status_bar_draw_maintext(int pos) } static void -_destroy_tab(StatusBarTab *tab) +_destroy_tab(StatusBarTab* tab) { if (tab) { if (tab->identifier) { @@ -527,14 +527,14 @@ _tabs_width(void) int width = g_hash_table_size(statusbar->tabs) > max_tabs ? 4 : 1; int i = 0; for (i = 1; i <= max_tabs; i++) { - StatusBarTab *tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i)); + StatusBarTab* tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i)); if (tab) { gboolean is_current = i == statusbar->current_tab; // dont calculate this in because not shown if (!show_read && !is_current && !tab->highlight) continue; - char *display_name = _display_name(tab); + char* display_name = _display_name(tab); width += utf8_display_len(display_name); width += 4; free(display_name); @@ -547,14 +547,14 @@ _tabs_width(void) int width = g_hash_table_size(statusbar->tabs) > max_tabs ? 4 : 1; int i = 0; for (i = 1; i <= max_tabs; i++) { - StatusBarTab *tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i)); + StatusBarTab* tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i)); if (tab) { gboolean is_current = i == statusbar->current_tab; // dont calculate this in because not shown if (!show_read && !is_current && !tab->highlight) continue; - char *display_name = _display_name(tab); + char* display_name = _display_name(tab); width += utf8_display_len(display_name); width += 2; free(display_name); @@ -570,9 +570,9 @@ _tabs_width(void) } static char* -_display_name(StatusBarTab *tab) +_display_name(StatusBarTab* tab) { - char *fullname = NULL; + char* fullname = NULL; if (tab->window_type == WIN_CONSOLE) { fullname = strdup("console"); @@ -585,10 +585,10 @@ _display_name(StatusBarTab *tab) fullname = strdup(tab->display_name); } } else if (tab->window_type == WIN_MUC) { - char *pref = prefs_get_string(PREF_STATUSBAR_ROOM); + char* pref = prefs_get_string(PREF_STATUSBAR_ROOM); if (g_strcmp0("room", pref) == 0) { - Jid *jidp = jid_create(tab->identifier); - char *room = strdup(jidp->localpart); + Jid* jidp = jid_create(tab->identifier); + char* room = strdup(jidp->localpart); jid_destroy(jidp); fullname = room; } else { @@ -596,11 +596,11 @@ _display_name(StatusBarTab *tab) } g_free(pref); } else if (tab->window_type == WIN_CONFIG) { - char *pref = prefs_get_string(PREF_STATUSBAR_ROOM); - GString *display_str = g_string_new(""); + char* pref = prefs_get_string(PREF_STATUSBAR_ROOM); + GString* display_str = g_string_new(""); if (g_strcmp0("room", pref) == 0) { - Jid *jidp = jid_create(tab->identifier); + Jid* jidp = jid_create(tab->identifier); g_string_append(display_str, jidp->localpart); jid_destroy(jidp); } else { @@ -609,19 +609,19 @@ _display_name(StatusBarTab *tab) g_free(pref); g_string_append(display_str, " conf"); - char *result = strdup(display_str->str); + char* result = strdup(display_str->str); g_string_free(display_str, TRUE); fullname = result; } else if (tab->window_type == WIN_PRIVATE) { - char *pref = prefs_get_string(PREF_STATUSBAR_ROOM); + char* pref = prefs_get_string(PREF_STATUSBAR_ROOM); if (g_strcmp0("room", pref) == 0) { - GString *display_str = g_string_new(""); - Jid *jidp = jid_create(tab->identifier); + GString* display_str = g_string_new(""); + Jid* jidp = jid_create(tab->identifier); g_string_append(display_str, jidp->localpart); g_string_append(display_str, "/"); g_string_append(display_str, jidp->resourcepart); jid_destroy(jidp); - char *result = strdup(display_str->str); + char* result = strdup(display_str->str); g_string_free(display_str, TRUE); fullname = result; } else { @@ -642,9 +642,9 @@ _display_name(StatusBarTab *tab) return fullname; } - gchar *trimmed = g_utf8_substring(fullname, 0, tablen); + gchar* trimmed = g_utf8_substring(fullname, 0, tablen); free(fullname); - char *trimmedname = strdup(trimmed); + char* trimmedname = strdup(trimmed); g_free(trimmed); return trimmedname; diff --git a/src/ui/statusbar.h b/src/ui/statusbar.h index 6c5513f9..4946e8c3 100644 --- a/src/ui/statusbar.h +++ b/src/ui/statusbar.h @@ -40,9 +40,9 @@ void status_bar_init(void); void status_bar_draw(void); void status_bar_close(void); void status_bar_resize(void); -void status_bar_set_prompt(const char *const prompt); +void status_bar_set_prompt(const char* const prompt); void status_bar_clear_prompt(void); -void status_bar_set_fulljid(const char *const fulljid); +void status_bar_set_fulljid(const char* const fulljid); void status_bar_clear_fulljid(void); void status_bar_current(int i); diff --git a/src/ui/titlebar.c b/src/ui/titlebar.c index 0a688e10..e587bab0 100644 --- a/src/ui/titlebar.c +++ b/src/ui/titlebar.c @@ -52,21 +52,21 @@ #include "xmpp/roster_list.h" #include "xmpp/chat_session.h" -static WINDOW *win; +static WINDOW* win; static contact_presence_t current_presence; static gboolean tls_secured; static gboolean is_connected; static gboolean typing; -static GTimer *typing_elapsed; +static GTimer* typing_elapsed; static void _title_bar_draw(void); -static void _show_self_presence(void); -static int _calc_self_presence(void); -static void _show_contact_presence(ProfChatWin *chatwin, int pos, int maxpos); -static void _show_privacy(ProfChatWin *chatwin); -static void _show_muc_privacy(ProfMucWin *mucwin); -static void _show_scrolled(ProfWin *current); +static void _show_self_presence(void); +static int _calc_self_presence(void); +static void _show_contact_presence(ProfChatWin* chatwin, int pos, int maxpos); +static void _show_privacy(ProfChatWin* chatwin); +static void _show_muc_privacy(ProfMucWin* mucwin); +static void _show_scrolled(ProfWin* current); void create_title_bar(void) @@ -87,7 +87,7 @@ create_title_bar(void) void title_bar_update_virtual(void) { - ProfWin *window = wins_get_current(); + ProfWin* window = wins_get_current(); if (window->type != WIN_CONSOLE) { if (typing_elapsed) { gdouble seconds = g_timer_elapsed(typing_elapsed, NULL); @@ -186,7 +186,7 @@ _title_bar_draw(void) { int pos; int maxrightpos; - ProfWin *current = wins_get_current(); + ProfWin* current = wins_get_current(); werase(win); wmove(win, 0, 0); @@ -195,7 +195,7 @@ _title_bar_draw(void) waddch(win, ' '); } - char *title = win_get_title(current); + char* title = win_get_title(current); mvwprintw(win, 0, 0, " %s", title); pos = strlen(title) + 1; @@ -207,7 +207,7 @@ _title_bar_draw(void) maxrightpos = _calc_self_presence(); if (current && current->type == WIN_CHAT) { - ProfChatWin *chatwin = (ProfChatWin*) current; + ProfChatWin* chatwin = (ProfChatWin*)current; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); _show_contact_presence(chatwin, pos, maxrightpos); _show_privacy(chatwin); @@ -217,7 +217,7 @@ _title_bar_draw(void) wprintw(win, " (typing...)"); } } else if (current && current->type == WIN_MUC) { - ProfMucWin *mucwin = (ProfMucWin*) current; + ProfMucWin* mucwin = (ProfMucWin*)current; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); _show_muc_privacy(mucwin); _show_scrolled(current); @@ -230,7 +230,7 @@ _title_bar_draw(void) } static void -_show_scrolled(ProfWin *current) +_show_scrolled(ProfWin* current) { if (current && current->layout->paged == 1) { int bracket_attrs = theme_attrs(THEME_TITLE_BRACKET); @@ -255,26 +255,25 @@ _calc_self_presence(void) { int tls_start = 0; - switch (current_presence) - { - case CONTACT_ONLINE: - tls_start = 15; - break; - case CONTACT_AWAY: - tls_start = 13; - break; - case CONTACT_DND: - tls_start = 12; - break; - case CONTACT_CHAT: - tls_start = 13; - break; - case CONTACT_XA: - tls_start = 11; - break; - case CONTACT_OFFLINE: - tls_start = 16; - break; + switch (current_presence) { + case CONTACT_ONLINE: + tls_start = 15; + break; + case CONTACT_AWAY: + tls_start = 13; + break; + case CONTACT_DND: + tls_start = 12; + break; + case CONTACT_CHAT: + tls_start = 13; + break; + case CONTACT_XA: + tls_start = 11; + break; + case CONTACT_OFFLINE: + tls_start = 16; + break; } return tls_start - 1; @@ -291,68 +290,67 @@ _show_self_presence(void) int tls_start = 0; - switch (current_presence) - { - case CONTACT_ONLINE: - presence_attrs = theme_attrs(THEME_TITLE_ONLINE); - wattron(win, bracket_attrs); - mvwaddch(win, 0, cols - 9, '['); - wattroff(win, bracket_attrs); - wattron(win, presence_attrs); - mvwprintw(win, 0, cols - 8, "online"); - wattroff(win, presence_attrs); - tls_start = 15; - break; - case CONTACT_AWAY: - presence_attrs = theme_attrs(THEME_TITLE_AWAY); - wattron(win, bracket_attrs); - mvwaddch(win, 0, cols - 7, '['); - wattroff(win, bracket_attrs); - wattron(win, presence_attrs); - mvwprintw(win, 0, cols - 6, "away"); - wattroff(win, presence_attrs); - tls_start = 13; - break; - case CONTACT_DND: - presence_attrs = theme_attrs(THEME_TITLE_DND); - wattron(win, bracket_attrs); - mvwaddch(win, 0, cols - 6, '['); - wattroff(win, bracket_attrs); - wattron(win, presence_attrs); - mvwprintw(win, 0, cols - 5, "dnd"); - wattroff(win, presence_attrs); - tls_start = 12; - break; - case CONTACT_CHAT: - presence_attrs = theme_attrs(THEME_TITLE_CHAT); - wattron(win, bracket_attrs); - mvwaddch(win, 0, cols - 7, '['); - wattroff(win, bracket_attrs); - wattron(win, presence_attrs); - mvwprintw(win, 0, cols - 6, "chat"); - wattroff(win, presence_attrs); - tls_start = 13; - break; - case CONTACT_XA: - presence_attrs = theme_attrs(THEME_TITLE_XA); - wattron(win, bracket_attrs); - mvwaddch(win, 0, cols - 5, '['); - wattroff(win, bracket_attrs); - wattron(win, presence_attrs); - mvwprintw(win, 0, cols - 4, "xa"); - wattroff(win, presence_attrs); - tls_start = 11; - break; - case CONTACT_OFFLINE: - presence_attrs = theme_attrs(THEME_TITLE_OFFLINE); - wattron(win, bracket_attrs); - mvwaddch(win, 0, cols - 10, '['); - wattroff(win, bracket_attrs); - wattron(win, presence_attrs); - mvwprintw(win, 0, cols - 9, "offline"); - wattroff(win, presence_attrs); - tls_start = 16; - break; + switch (current_presence) { + case CONTACT_ONLINE: + presence_attrs = theme_attrs(THEME_TITLE_ONLINE); + wattron(win, bracket_attrs); + mvwaddch(win, 0, cols - 9, '['); + wattroff(win, bracket_attrs); + wattron(win, presence_attrs); + mvwprintw(win, 0, cols - 8, "online"); + wattroff(win, presence_attrs); + tls_start = 15; + break; + case CONTACT_AWAY: + presence_attrs = theme_attrs(THEME_TITLE_AWAY); + wattron(win, bracket_attrs); + mvwaddch(win, 0, cols - 7, '['); + wattroff(win, bracket_attrs); + wattron(win, presence_attrs); + mvwprintw(win, 0, cols - 6, "away"); + wattroff(win, presence_attrs); + tls_start = 13; + break; + case CONTACT_DND: + presence_attrs = theme_attrs(THEME_TITLE_DND); + wattron(win, bracket_attrs); + mvwaddch(win, 0, cols - 6, '['); + wattroff(win, bracket_attrs); + wattron(win, presence_attrs); + mvwprintw(win, 0, cols - 5, "dnd"); + wattroff(win, presence_attrs); + tls_start = 12; + break; + case CONTACT_CHAT: + presence_attrs = theme_attrs(THEME_TITLE_CHAT); + wattron(win, bracket_attrs); + mvwaddch(win, 0, cols - 7, '['); + wattroff(win, bracket_attrs); + wattron(win, presence_attrs); + mvwprintw(win, 0, cols - 6, "chat"); + wattroff(win, presence_attrs); + tls_start = 13; + break; + case CONTACT_XA: + presence_attrs = theme_attrs(THEME_TITLE_XA); + wattron(win, bracket_attrs); + mvwaddch(win, 0, cols - 5, '['); + wattroff(win, bracket_attrs); + wattron(win, presence_attrs); + mvwprintw(win, 0, cols - 4, "xa"); + wattroff(win, presence_attrs); + tls_start = 11; + break; + case CONTACT_OFFLINE: + presence_attrs = theme_attrs(THEME_TITLE_OFFLINE); + wattron(win, bracket_attrs); + mvwaddch(win, 0, cols - 10, '['); + wattroff(win, bracket_attrs); + wattron(win, presence_attrs); + mvwprintw(win, 0, cols - 9, "offline"); + wattroff(win, presence_attrs); + tls_start = 16; + break; } wattron(win, bracket_attrs); @@ -381,7 +379,7 @@ _show_self_presence(void) } static void -_show_muc_privacy(ProfMucWin *mucwin) +_show_muc_privacy(ProfMucWin* mucwin) { int bracket_attrs = theme_attrs(THEME_TITLE_BRACKET); int encrypted_attrs = theme_attrs(THEME_TITLE_ENCRYPTED); @@ -417,7 +415,7 @@ _show_muc_privacy(ProfMucWin *mucwin) } static void -_show_privacy(ProfChatWin *chatwin) +_show_privacy(ProfChatWin* chatwin) { int bracket_attrs = theme_attrs(THEME_TITLE_BRACKET); int encrypted_attrs = theme_attrs(THEME_TITLE_ENCRYPTED); @@ -492,7 +490,7 @@ _show_privacy(ProfChatWin *chatwin) } if (chatwin->pgp_send || chatwin->pgp_recv) { - GString *pgpmsg = g_string_new("PGP "); + GString* pgpmsg = g_string_new("PGP "); if (chatwin->pgp_send && !chatwin->pgp_recv) { g_string_append(pgpmsg, "send"); } else if (!chatwin->pgp_send && chatwin->pgp_recv) { @@ -545,12 +543,12 @@ _show_privacy(ProfChatWin *chatwin) } static void -_show_contact_presence(ProfChatWin *chatwin, int pos, int maxpos) +_show_contact_presence(ProfChatWin* chatwin, int pos, int maxpos) { int bracket_attrs = theme_attrs(THEME_TITLE_BRACKET); - char *resource = NULL; + char* resource = NULL; - ChatSession *session = chat_session_get(chatwin->barejid); + ChatSession* session = chat_session_get(chatwin->barejid); if (chatwin->resource_override) { resource = chatwin->resource_override; } else if (session && session->resource) { @@ -567,14 +565,14 @@ _show_contact_presence(ProfChatWin *chatwin, int pos, int maxpos) if (prefs_get_boolean(PREF_PRESENCE)) { theme_item_t presence_colour = THEME_TITLE_OFFLINE; - const char *presence = "offline"; + const char* presence = "offline"; jabber_conn_status_t conn_status = connection_get_status(); if (conn_status == JABBER_CONNECTED) { PContact contact = roster_get_contact(chatwin->barejid); if (contact) { if (resource) { - Resource *resourcep = p_contact_get_resource(contact, resource); + Resource* resourcep = p_contact_get_resource(contact, resource); if (resourcep) { presence = string_from_resource_presence(resourcep->presence); } diff --git a/src/ui/tray.c b/src/ui/tray.c index 6d79b379..c1b07245 100644 --- a/src/ui/tray.c +++ b/src/ui/tray.c @@ -48,9 +48,9 @@ #include "ui/window_list.h" static gboolean gtk_ready = FALSE; -static GtkStatusIcon *prof_tray = NULL; -static GString *icon_filename = NULL; -static GString *icon_msg_filename = NULL; +static GtkStatusIcon* prof_tray = NULL; +static GString* icon_filename = NULL; +static GString* icon_msg_filename = NULL; static gint unread_messages; static gboolean shutting_down; static guint timer; @@ -66,7 +66,7 @@ static guint timer; static void _get_icons(void) { - GString *icons_dir = NULL; + GString* icons_dir = NULL; #ifdef ICONS_PATH @@ -79,18 +79,18 @@ _get_icons(void) #endif /* ICONS_PATH */ - gchar *icons_dir_s = files_get_config_path(DIR_ICONS); + gchar* icons_dir_s = files_get_config_path(DIR_ICONS); icons_dir = g_string_new(icons_dir_s); g_free(icons_dir_s); - GError *err = NULL; + GError* err = NULL; if (!g_file_test(icons_dir->str, G_FILE_TEST_IS_DIR)) { return; } - GDir *dir = g_dir_open(icons_dir->str, 0, &err); + GDir* dir = g_dir_open(icons_dir->str, 0, &err); if (dir) { - GString *name = g_string_new(g_dir_read_name(dir)); + GString* name = g_string_new(g_dir_read_name(dir)); while (name->len) { if (g_strcmp0("proIcon.png", name->str) == 0) { if (icon_filename) { diff --git a/src/ui/ui.h b/src/ui/ui.h index b91ea8b4..6efc837b 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -50,12 +50,12 @@ #include "otr/otr.h" #endif -#define NO_ME 1 -#define NO_DATE 2 -#define NO_EOL 4 -#define NO_COLOUR_FROM 8 -#define NO_COLOUR_DATE 16 -#define UNTRUSTED 32 +#define NO_ME 1 +#define NO_DATE 2 +#define NO_EOL 4 +#define NO_COLOUR_FROM 8 +#define NO_COLOUR_DATE 16 +#define UNTRUSTED 32 // core UI void ui_init(void); @@ -64,12 +64,12 @@ void ui_update(void); void ui_close(void); void ui_redraw(void); void ui_resize(void); -void ui_focus_win(ProfWin *window); +void ui_focus_win(ProfWin* window); void ui_sigwinch_handler(int sig); -void ui_handle_otr_error(const char *const barejid, const char *const message); +void ui_handle_otr_error(const char* const barejid, const char* const message); unsigned long ui_get_idle_time(void); void ui_reset_idle_time(void); -void ui_print_system_msg_from_recipient(const char *const barejid, const char *message); +void ui_print_system_msg_from_recipient(const char* const barejid, const char* message); void ui_close_connected_win(int index); int ui_close_all_wins(void); int ui_close_read_wins(void); @@ -77,167 +77,167 @@ void ui_close_win(int index); int ui_win_unread(int index); char* ui_ask_password(void); char* ui_get_line(void); -char* ui_ask_pgp_passphrase(const char *hint, int prev_fail); -void ui_contact_online(char *barejid, Resource *resource, GDateTime *last_activity); -void ui_contact_typing(const char *const barejid, const char *const resource); +char* ui_ask_pgp_passphrase(const char* hint, int prev_fail); +void ui_contact_online(char* barejid, Resource* resource, GDateTime* last_activity); +void ui_contact_typing(const char* const barejid, const char* const resource); void ui_disconnected(void); -void ui_room_join(const char *const roomjid, gboolean focus); -void ui_switch_to_room(const char *const roomjid); -void ui_room_destroy(const char *const roomjid); -void ui_room_destroyed(const char *const roomjid, const char *const reason, const char *const new_jid, - const char *const password); -void ui_room_kicked(const char *const roomjid, const char *const actor, const char *const reason); -void ui_room_banned(const char *const roomjid, const char *const actor, const char *const reason); -void ui_leave_room(const char *const roomjid); +void ui_room_join(const char* const roomjid, gboolean focus); +void ui_switch_to_room(const char* const roomjid); +void ui_room_destroy(const char* const roomjid); +void ui_room_destroyed(const char* const roomjid, const char* const reason, const char* const new_jid, + const char* const password); +void ui_room_kicked(const char* const roomjid, const char* const actor, const char* const reason); +void ui_room_banned(const char* const roomjid, const char* const actor, const char* const reason); +void ui_leave_room(const char* const roomjid); void ui_show_roster(void); void ui_hide_roster(void); -void ui_roster_add(const char *const barejid, const char *const name); -void ui_roster_remove(const char *const barejid); -void ui_contact_already_in_group(const char *const contact, const char *const group); -void ui_contact_not_in_group(const char *const contact, const char *const group); -void ui_group_added(const char *const contact, const char *const group); -void ui_group_removed(const char *const contact, const char *const group); -void ui_contact_offline(char *barejid, char *resource, char *status); -void ui_handle_recipient_error(const char *const recipient, const char *const err_msg); -void ui_handle_error(const char *const err_msg); +void ui_roster_add(const char* const barejid, const char* const name); +void ui_roster_remove(const char* const barejid); +void ui_contact_already_in_group(const char* const contact, const char* const group); +void ui_contact_not_in_group(const char* const contact, const char* const group); +void ui_group_added(const char* const contact, const char* const group); +void ui_group_removed(const char* const contact, const char* const group); +void ui_contact_offline(char* barejid, char* resource, char* status); +void ui_handle_recipient_error(const char* const recipient, const char* const err_msg); +void ui_handle_error(const char* const err_msg); void ui_clear_win_title(void); void ui_goodbye_title(void); -void ui_handle_room_configuration_form_error(const char *const roomjid, const char *const message); -void ui_handle_room_config_submit_result(const char *const roomjid); -void ui_handle_room_config_submit_result_error(const char *const roomjid, const char *const message); -void ui_show_lines(ProfWin *window, gchar** lines); +void ui_handle_room_configuration_form_error(const char* const roomjid, const char* const message); +void ui_handle_room_config_submit_result(const char* const roomjid); +void ui_handle_room_config_submit_result_error(const char* const roomjid, const char* const message); +void ui_show_lines(ProfWin* window, gchar** lines); void ui_redraw_all_room_rosters(void); void ui_show_all_room_rosters(void); void ui_hide_all_room_rosters(void); -void ui_handle_software_version_error(const char *const roomjid, const char *const message); -void ui_show_software_version(const char *const jid, const char *const presence, const char *const name, - const char *const version, const char *const os); +void ui_handle_software_version_error(const char* const roomjid, const char* const message); +void ui_show_software_version(const char* const jid, const char* const presence, const char* const name, + const char* const version, const char* const os); void ui_prune_wins(void); -void ui_auto_away(char *message, gint time, resource_presence_t res_presence); -void ui_handle_login_account_success(ProfAccount *account, gboolean secured); -void ui_update_presence(const resource_presence_t resource_presence, const char *const message, const char *const show); -void ui_invalid_command_usage(const char *const cmd, void (*setting_func)(void)); +void ui_auto_away(char* message, gint time, resource_presence_t res_presence); +void ui_handle_login_account_success(ProfAccount* account, gboolean secured); +void ui_update_presence(const resource_presence_t resource_presence, const char* const message, const char* const show); +void ui_invalid_command_usage(const char* const cmd, void (*setting_func)(void)); gboolean ui_win_has_unsaved_form(int num); // Chat window -ProfChatWin* chatwin_new(const char *const barejid); -void chatwin_incoming_msg(ProfChatWin *chatwin, ProfMessage *message, gboolean win_created); -void chatwin_receipt_received(ProfChatWin *chatwin, const char *const id); -void chatwin_recipient_gone(ProfChatWin *chatwin); -void chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id, prof_enc_t enc_mode, gboolean request_receipt, const char *const replace_id); -void chatwin_outgoing_carbon(ProfChatWin *chatwin, ProfMessage *message); -void chatwin_contact_online(ProfChatWin *chatwin, Resource *resource, GDateTime *last_activity); -void chatwin_contact_offline(ProfChatWin *chatwin, char *resource, char *status); -char* chatwin_get_string(ProfChatWin *chatwin); +ProfChatWin* chatwin_new(const char* const barejid); +void chatwin_incoming_msg(ProfChatWin* chatwin, ProfMessage* message, gboolean win_created); +void chatwin_receipt_received(ProfChatWin* chatwin, const char* const id); +void chatwin_recipient_gone(ProfChatWin* chatwin); +void chatwin_outgoing_msg(ProfChatWin* chatwin, const char* const message, char* id, prof_enc_t enc_mode, gboolean request_receipt, const char* const replace_id); +void chatwin_outgoing_carbon(ProfChatWin* chatwin, ProfMessage* message); +void chatwin_contact_online(ProfChatWin* chatwin, Resource* resource, GDateTime* last_activity); +void chatwin_contact_offline(ProfChatWin* chatwin, char* resource, char* status); +char* chatwin_get_string(ProfChatWin* chatwin); #ifdef HAVE_LIBOTR -void chatwin_otr_secured(ProfChatWin *chatwin, gboolean trusted); -void chatwin_otr_unsecured(ProfChatWin *chatwin); -void chatwin_otr_trust(ProfChatWin *chatwin); -void chatwin_otr_untrust(ProfChatWin *chatwin); -void chatwin_otr_smp_event(ProfChatWin *chatwin, prof_otr_smp_event_t event, void *data); +void chatwin_otr_secured(ProfChatWin* chatwin, gboolean trusted); +void chatwin_otr_unsecured(ProfChatWin* chatwin); +void chatwin_otr_trust(ProfChatWin* chatwin); +void chatwin_otr_untrust(ProfChatWin* chatwin); +void chatwin_otr_smp_event(ProfChatWin* chatwin, prof_otr_smp_event_t event, void* data); #endif -void chatwin_set_enctext(ProfChatWin *chatwin, const char *const enctext); -void chatwin_unset_enctext(ProfChatWin *chatwin); -void chatwin_set_incoming_char(ProfChatWin *chatwin, const char *const ch); -void chatwin_unset_incoming_char(ProfChatWin *chatwin); -void chatwin_set_outgoing_char(ProfChatWin *chatwin, const char *const ch); -void chatwin_unset_outgoing_char(ProfChatWin *chatwin); +void chatwin_set_enctext(ProfChatWin* chatwin, const char* const enctext); +void chatwin_unset_enctext(ProfChatWin* chatwin); +void chatwin_set_incoming_char(ProfChatWin* chatwin, const char* const ch); +void chatwin_unset_incoming_char(ProfChatWin* chatwin); +void chatwin_set_outgoing_char(ProfChatWin* chatwin, const char* const ch); +void chatwin_unset_outgoing_char(ProfChatWin* chatwin); // MUC window -ProfMucWin* mucwin_new(const char *const barejid); -void mucwin_role_change(ProfMucWin *mucwin, const char *const role, const char *const actor, const char *const reason); -void mucwin_affiliation_change(ProfMucWin *mucwin, const char *const affiliation, const char *const actor, - const char *const reason); -void mucwin_role_and_affiliation_change(ProfMucWin *mucwin, const char *const role, - const char *const affiliation, const char *const actor, const char *const reason); -void mucwin_occupant_role_change(ProfMucWin *mucwin, const char *const nick, const char *const role, - const char *const actor, const char *const reason); -void mucwin_occupant_affiliation_change(ProfMucWin *mucwin, const char *const nick, - const char *const affiliation, const char *const actor, const char *const reason); -void mucwin_occupant_role_and_affiliation_change(ProfMucWin *mucwin, const char *const nick, - const char *const role, const char *const affiliation, const char *const actor, const char *const reason); -void mucwin_roster(ProfMucWin *mucwin, GList *occupants, const char *const presence); -void mucwin_history(ProfMucWin *mucwin, const ProfMessage *const message); -void mucwin_outgoing_msg(ProfMucWin *mucwin, const char *const message, const char *const id, prof_enc_t enc_mode, const char *const replace_id); -void mucwin_incoming_msg(ProfMucWin *mucwin, const ProfMessage *const message, GSList *mentions, GList *triggers, gboolean filter_reflection); -void mucwin_subject(ProfMucWin *mucwin, const char *const nick, const char *const subject); -void mucwin_requires_config(ProfMucWin *mucwin); -void mucwin_info(ProfMucWin *mucwin); -void mucwin_show_role_list(ProfMucWin *mucwin, muc_role_t role); -void mucwin_show_affiliation_list(ProfMucWin *mucwin, muc_affiliation_t affiliation); -void mucwin_room_info_error(ProfMucWin *mucwin, const char *const error); -void mucwin_room_disco_info(ProfMucWin *mucwin, GSList *identities, GSList *features); -void mucwin_occupant_kicked(ProfMucWin *mucwin, const char *const nick, const char *const actor, - const char *const reason); -void mucwin_occupant_banned(ProfMucWin *mucwin, const char *const nick, const char *const actor, - const char *const reason); -void mucwin_broadcast(ProfMucWin *mucwin, const char *const message); -void mucwin_occupant_offline(ProfMucWin *mucwin, const char *const nick); -void mucwin_occupant_online(ProfMucWin *mucwin, const char *const nick, const char *const roles, - const char *const affiliation, const char *const show, const char *const status); -void mucwin_occupant_nick_change(ProfMucWin *mucwin, const char *const old_nick, const char *const nick); -void mucwin_nick_change(ProfMucWin *mucwin, const char *const nick); -void mucwin_occupant_presence(ProfMucWin *mucwin, const char *const nick, const char *const show, - const char *const status); -void mucwin_update_occupants(ProfMucWin *mucwin); -void mucwin_show_occupants(ProfMucWin *mucwin); -void mucwin_hide_occupants(ProfMucWin *mucwin); -void mucwin_affiliation_list_error(ProfMucWin *mucwin, const char *const affiliation, const char *const error); -void mucwin_handle_affiliation_list(ProfMucWin *mucwin, const char *const affiliation, GSList *jids); -void mucwin_affiliation_set_error(ProfMucWin *mucwin, const char *const jid, const char *const affiliation, - const char *const error); -void mucwin_role_set_error(ProfMucWin *mucwin, const char *const nick, const char *const role, const char *const error); -void mucwin_role_list_error(ProfMucWin *mucwin, const char *const role, const char *const error); -void mucwin_handle_role_list(ProfMucWin *mucwin, const char *const role, GSList *nicks); -void mucwin_kick_error(ProfMucWin *mucwin, const char *const nick, const char *const error); -char* mucwin_get_string(ProfMucWin *mucwin); -void mucwin_set_enctext(ProfMucWin *mucwin, const char *const enctext); -void mucwin_unset_enctext(ProfMucWin *mucwin); -void mucwin_set_message_char(ProfMucWin *mucwin, const char *const ch); -void mucwin_unset_message_char(ProfMucWin *mucwin); +ProfMucWin* mucwin_new(const char* const barejid); +void mucwin_role_change(ProfMucWin* mucwin, const char* const role, const char* const actor, const char* const reason); +void mucwin_affiliation_change(ProfMucWin* mucwin, const char* const affiliation, const char* const actor, + const char* const reason); +void mucwin_role_and_affiliation_change(ProfMucWin* mucwin, const char* const role, + const char* const affiliation, const char* const actor, const char* const reason); +void mucwin_occupant_role_change(ProfMucWin* mucwin, const char* const nick, const char* const role, + const char* const actor, const char* const reason); +void mucwin_occupant_affiliation_change(ProfMucWin* mucwin, const char* const nick, + const char* const affiliation, const char* const actor, const char* const reason); +void mucwin_occupant_role_and_affiliation_change(ProfMucWin* mucwin, const char* const nick, + const char* const role, const char* const affiliation, const char* const actor, const char* const reason); +void mucwin_roster(ProfMucWin* mucwin, GList* occupants, const char* const presence); +void mucwin_history(ProfMucWin* mucwin, const ProfMessage* const message); +void mucwin_outgoing_msg(ProfMucWin* mucwin, const char* const message, const char* const id, prof_enc_t enc_mode, const char* const replace_id); +void mucwin_incoming_msg(ProfMucWin* mucwin, const ProfMessage* const message, GSList* mentions, GList* triggers, gboolean filter_reflection); +void mucwin_subject(ProfMucWin* mucwin, const char* const nick, const char* const subject); +void mucwin_requires_config(ProfMucWin* mucwin); +void mucwin_info(ProfMucWin* mucwin); +void mucwin_show_role_list(ProfMucWin* mucwin, muc_role_t role); +void mucwin_show_affiliation_list(ProfMucWin* mucwin, muc_affiliation_t affiliation); +void mucwin_room_info_error(ProfMucWin* mucwin, const char* const error); +void mucwin_room_disco_info(ProfMucWin* mucwin, GSList* identities, GSList* features); +void mucwin_occupant_kicked(ProfMucWin* mucwin, const char* const nick, const char* const actor, + const char* const reason); +void mucwin_occupant_banned(ProfMucWin* mucwin, const char* const nick, const char* const actor, + const char* const reason); +void mucwin_broadcast(ProfMucWin* mucwin, const char* const message); +void mucwin_occupant_offline(ProfMucWin* mucwin, const char* const nick); +void mucwin_occupant_online(ProfMucWin* mucwin, const char* const nick, const char* const roles, + const char* const affiliation, const char* const show, const char* const status); +void mucwin_occupant_nick_change(ProfMucWin* mucwin, const char* const old_nick, const char* const nick); +void mucwin_nick_change(ProfMucWin* mucwin, const char* const nick); +void mucwin_occupant_presence(ProfMucWin* mucwin, const char* const nick, const char* const show, + const char* const status); +void mucwin_update_occupants(ProfMucWin* mucwin); +void mucwin_show_occupants(ProfMucWin* mucwin); +void mucwin_hide_occupants(ProfMucWin* mucwin); +void mucwin_affiliation_list_error(ProfMucWin* mucwin, const char* const affiliation, const char* const error); +void mucwin_handle_affiliation_list(ProfMucWin* mucwin, const char* const affiliation, GSList* jids); +void mucwin_affiliation_set_error(ProfMucWin* mucwin, const char* const jid, const char* const affiliation, + const char* const error); +void mucwin_role_set_error(ProfMucWin* mucwin, const char* const nick, const char* const role, const char* const error); +void mucwin_role_list_error(ProfMucWin* mucwin, const char* const role, const char* const error); +void mucwin_handle_role_list(ProfMucWin* mucwin, const char* const role, GSList* nicks); +void mucwin_kick_error(ProfMucWin* mucwin, const char* const nick, const char* const error); +char* mucwin_get_string(ProfMucWin* mucwin); +void mucwin_set_enctext(ProfMucWin* mucwin, const char* const enctext); +void mucwin_unset_enctext(ProfMucWin* mucwin); +void mucwin_set_message_char(ProfMucWin* mucwin, const char* const ch); +void mucwin_unset_message_char(ProfMucWin* mucwin); // MUC private chat window -void privwin_incoming_msg(ProfPrivateWin *privatewin, ProfMessage *message); -void privwin_outgoing_msg(ProfPrivateWin *privwin, const char *const message); -void privwin_message_occupant_offline(ProfPrivateWin *privwin); +void privwin_incoming_msg(ProfPrivateWin* privatewin, ProfMessage* message); +void privwin_outgoing_msg(ProfPrivateWin* privwin, const char* const message); +void privwin_message_occupant_offline(ProfPrivateWin* privwin); -void privwin_message_left_room(ProfPrivateWin *privwin); +void privwin_message_left_room(ProfPrivateWin* privwin); -char* privwin_get_string(ProfPrivateWin *privwin); -void privwin_occupant_offline(ProfPrivateWin *privwin); -void privwin_occupant_kicked(ProfPrivateWin *privwin, const char *const actor, const char *const reason); -void privwin_occupant_banned(ProfPrivateWin *privwin, const char *const actor, const char *const reason); -void privwin_occupant_online(ProfPrivateWin *privwin); +char* privwin_get_string(ProfPrivateWin* privwin); +void privwin_occupant_offline(ProfPrivateWin* privwin); +void privwin_occupant_kicked(ProfPrivateWin* privwin, const char* const actor, const char* const reason); +void privwin_occupant_banned(ProfPrivateWin* privwin, const char* const actor, const char* const reason); +void privwin_occupant_online(ProfPrivateWin* privwin); -void privwin_room_destroyed(ProfPrivateWin *privwin); -void privwin_room_left(ProfPrivateWin *privwin); -void privwin_room_kicked(ProfPrivateWin *privwin, const char *const actor, const char *const reason); -void privwin_room_banned(ProfPrivateWin *privwin, const char *const actor, const char *const reason); -void privwin_room_joined(ProfPrivateWin *privwin); +void privwin_room_destroyed(ProfPrivateWin* privwin); +void privwin_room_left(ProfPrivateWin* privwin); +void privwin_room_kicked(ProfPrivateWin* privwin, const char* const actor, const char* const reason); +void privwin_room_banned(ProfPrivateWin* privwin, const char* const actor, const char* const reason); +void privwin_room_joined(ProfPrivateWin* privwin); // config window -void confwin_handle_configuration(ProfConfWin *confwin, DataForm *form); -void confwin_show_form(ProfConfWin *confwin); -void confwin_show_form_field(ProfConfWin *confwin, DataForm *form, char *tag); -void confwin_form_help(ProfConfWin *confwin); -void confwin_field_help(ProfConfWin *confwin, char *tag); -char* confwin_get_string(ProfConfWin *confwin); +void confwin_handle_configuration(ProfConfWin* confwin, DataForm* form); +void confwin_show_form(ProfConfWin* confwin); +void confwin_show_form_field(ProfConfWin* confwin, DataForm* form, char* tag); +void confwin_form_help(ProfConfWin* confwin); +void confwin_field_help(ProfConfWin* confwin, char* tag); +char* confwin_get_string(ProfConfWin* confwin); // xml console -void xmlwin_show(ProfXMLWin *xmlwin, const char *const msg); -char* xmlwin_get_string(ProfXMLWin *xmlwin); +void xmlwin_show(ProfXMLWin* xmlwin, const char* const msg); +char* xmlwin_get_string(ProfXMLWin* xmlwin); // Input window char* inp_readline(void); void inp_nonblocking(gboolean reset); // Console window -void cons_show(const char *const msg, ...); -void cons_show_padded(int pad, const char *const msg, ...); +void cons_show(const char* const msg, ...); +void cons_show_padded(int pad, const char* const msg, ...); void cons_about(void); void cons_help(void); -void cons_show_help(const char *const cmd, CommandHelp *help); -void cons_bad_cmd_usage(const char *const cmd); +void cons_show_help(const char* const cmd, CommandHelp* help); +void cons_bad_cmd_usage(const char* const cmd); void cons_navigation_help(void); void cons_prefs(void); void cons_show_ui_prefs(void); @@ -249,36 +249,36 @@ void cons_show_connection_prefs(void); void cons_show_otr_prefs(void); void cons_show_pgp_prefs(void); void cons_show_omemo_prefs(void); -void cons_show_account(ProfAccount *account); -void cons_debug(const char *const msg, ...); -void cons_show_error(const char *const cmd, ...); -void cons_show_contacts(GSList *list); -void cons_show_roster(GSList *list); -void cons_show_roster_group(const char *const group, GSList *list); +void cons_show_account(ProfAccount* account); +void cons_debug(const char* const msg, ...); +void cons_show_error(const char* const cmd, ...); +void cons_show_contacts(GSList* list); +void cons_show_roster(GSList* list); +void cons_show_roster_group(const char* const group, GSList* list); void cons_show_wins(gboolean unread); -char* cons_get_string(ProfConsoleWin *conswin); -void cons_show_status(const char *const barejid); +char* cons_get_string(ProfConsoleWin* conswin); +void cons_show_status(const char* const barejid); void cons_show_info(PContact pcontact); -void cons_show_caps(const char *const fulljid, resource_presence_t presence); -void cons_show_themes(GSList *themes); -void cons_show_scripts(GSList *scripts); -void cons_show_script(const char *const script, GSList *commands); -void cons_show_aliases(GList *aliases); -void cons_show_login_success(ProfAccount *account, gboolean secured); -void cons_show_account_list(gchar **accounts); -void cons_show_room_list(GSList *room, const char *const conference_node); -void cons_show_bookmarks(const GList *list); -void cons_show_bookmarks_ignore(gchar **list, gsize len); -void cons_show_disco_items(GSList *items, const char *const jid); -void cons_show_disco_info(const char *from, GSList *identities, GSList *features); -void cons_show_room_invite(const char *const invitor, const char *const room, const char *const reason); +void cons_show_caps(const char* const fulljid, resource_presence_t presence); +void cons_show_themes(GSList* themes); +void cons_show_scripts(GSList* scripts); +void cons_show_script(const char* const script, GSList* commands); +void cons_show_aliases(GList* aliases); +void cons_show_login_success(ProfAccount* account, gboolean secured); +void cons_show_account_list(gchar** accounts); +void cons_show_room_list(GSList* room, const char* const conference_node); +void cons_show_bookmarks(const GList* list); +void cons_show_bookmarks_ignore(gchar** list, gsize len); +void cons_show_disco_items(GSList* items, const char* const jid); +void cons_show_disco_info(const char* from, GSList* identities, GSList* features); +void cons_show_room_invite(const char* const invitor, const char* const room, const char* const reason); void cons_check_version(gboolean not_available_msg); -void cons_show_typing(const char *const barejid); -void cons_show_incoming_room_message(const char *const nick, const char *const room, const int win_index, - gboolean mention, GList *triggers, int unread); -void cons_show_incoming_message(const char *const short_from, const int win_index, int unread); -void cons_show_incoming_private_message(const char *const nick, const char *const room, const int win_index, int unread); -void cons_show_room_invites(GList *invites); +void cons_show_typing(const char* const barejid); +void cons_show_incoming_room_message(const char* const nick, const char* const room, const int win_index, + gboolean mention, GList* triggers, int unread); +void cons_show_incoming_message(const char* const short_from, const int win_index, int unread); +void cons_show_incoming_private_message(const char* const nick, const char* const room, const int win_index, int unread); +void cons_show_room_invites(GList* invites); void cons_show_received_subs(void); void cons_show_sent_subs(void); void cons_alert(void); @@ -322,80 +322,80 @@ void cons_os_setting(void); void cons_correction_setting(void); void cons_executable_setting(void); void cons_slashguard_setting(void); -void cons_show_contact_online(PContact contact, Resource *resource, GDateTime *last_activity); -void cons_show_contact_offline(PContact contact, char *resource, char *status); +void cons_show_contact_online(PContact contact, Resource* resource, GDateTime* last_activity); +void cons_show_contact_offline(PContact contact, char* resource, char* status); void cons_theme_properties(void); void cons_theme_colours(void); -void cons_show_tlscert(TLSCertificate *cert); -void cons_show_tlscert_summary(TLSCertificate *cert); +void cons_show_tlscert(TLSCertificate* cert); +void cons_show_tlscert_summary(TLSCertificate* cert); // title bar void title_bar_set_presence(contact_presence_t presence); // status bar void status_bar_inactive(const int win); -void status_bar_active(const int win, win_type_t wintype, char *identifier); -void status_bar_new(const int win, win_type_t wintype, char *identifier); +void status_bar_active(const int win, win_type_t wintype, char* identifier); +void status_bar_new(const int win, win_type_t wintype, char* identifier); void status_bar_set_all_inactive(void); // roster window void rosterwin_roster(void); // occupants window -void occupantswin_occupants(const char *const room); +void occupantswin_occupants(const char* const room); void occupantswin_occupants_all(void); // window interface ProfWin* win_create_console(void); ProfWin* win_create_xmlconsole(void); -ProfWin* win_create_chat(const char *const barejid); -ProfWin* win_create_muc(const char *const roomjid); -ProfWin* win_create_config(const char *const title, DataForm *form, ProfConfWinCallback submit, ProfConfWinCallback cancel, const void *userdata); -ProfWin* win_create_private(const char *const fulljid); -ProfWin* win_create_plugin(const char *const plugin_name, const char *const tag); -void win_update_virtual(ProfWin *window); -void win_free(ProfWin *window); -gboolean win_notify_remind(ProfWin *window); -int win_unread(ProfWin *window); -void win_resize(ProfWin *window); -void win_hide_subwin(ProfWin *window); -void win_show_subwin(ProfWin *window); -void win_refresh_without_subwin(ProfWin *window); -void win_refresh_with_subwin(ProfWin *window); +ProfWin* win_create_chat(const char* const barejid); +ProfWin* win_create_muc(const char* const roomjid); +ProfWin* win_create_config(const char* const title, DataForm* form, ProfConfWinCallback submit, ProfConfWinCallback cancel, const void* userdata); +ProfWin* win_create_private(const char* const fulljid); +ProfWin* win_create_plugin(const char* const plugin_name, const char* const tag); +void win_update_virtual(ProfWin* window); +void win_free(ProfWin* window); +gboolean win_notify_remind(ProfWin* window); +int win_unread(ProfWin* window); +void win_resize(ProfWin* window); +void win_hide_subwin(ProfWin* window); +void win_show_subwin(ProfWin* window); +void win_refresh_without_subwin(ProfWin* window); +void win_refresh_with_subwin(ProfWin* window); -void win_print(ProfWin *window, theme_item_t theme_item, const char *show_char, const char *const message, ...); -void win_println(ProfWin *window, theme_item_t theme_item, const char *show_char, const char *const message, ...); -void win_println_indent(ProfWin *window, int pad, const char *const message, ...); +void win_print(ProfWin* window, theme_item_t theme_item, const char* show_char, const char* const message, ...); +void win_println(ProfWin* window, theme_item_t theme_item, const char* show_char, const char* const message, ...); +void win_println_indent(ProfWin* window, int pad, const char* const message, ...); -void win_append(ProfWin *window, theme_item_t theme_item, const char *const message, ...); -void win_appendln(ProfWin *window, theme_item_t theme_item, const char *const message, ...); +void win_append(ProfWin* window, theme_item_t theme_item, const char* const message, ...); +void win_appendln(ProfWin* window, theme_item_t theme_item, const char* const message, ...); -void win_append_highlight(ProfWin *window, theme_item_t theme_item, const char *const message, ...); -void win_appendln_highlight(ProfWin *window, theme_item_t theme_item, const char *const message, ...); +void win_append_highlight(ProfWin* window, theme_item_t theme_item, const char* const message, ...); +void win_appendln_highlight(ProfWin* window, theme_item_t theme_item, const char* const message, ...); -char* win_get_title(ProfWin *window); -void win_show_occupant(ProfWin *window, Occupant *occupant); -void win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupant); -void win_show_contact(ProfWin *window, PContact contact); -void win_show_info(ProfWin *window, PContact contact); -void win_clear(ProfWin *window); -char* win_get_tab_identifier(ProfWin *window); -char* win_to_string(ProfWin *window); -void win_command_list_error(ProfWin *window, const char *const error); -void win_command_exec_error(ProfWin *window, const char *const command, const char *const error, ...); -void win_handle_command_list(ProfWin *window, GSList *cmds); -void win_handle_command_exec_status(ProfWin *window, const char *const type, const char *const value); -void win_handle_command_exec_result_note(ProfWin *window, const char *const type, const char *const value); +char* win_get_title(ProfWin* window); +void win_show_occupant(ProfWin* window, Occupant* occupant); +void win_show_occupant_info(ProfWin* window, const char* const room, Occupant* occupant); +void win_show_contact(ProfWin* window, PContact contact); +void win_show_info(ProfWin* window, PContact contact); +void win_clear(ProfWin* window); +char* win_get_tab_identifier(ProfWin* window); +char* win_to_string(ProfWin* window); +void win_command_list_error(ProfWin* window, const char* const error); +void win_command_exec_error(ProfWin* window, const char* const command, const char* const error, ...); +void win_handle_command_list(ProfWin* window, GSList* cmds); +void win_handle_command_exec_status(ProfWin* window, const char* const type, const char* const value); +void win_handle_command_exec_result_note(ProfWin* window, const char* const type, const char* const value); // desktop notifications void notifier_initialise(void); void notifier_uninit(void); -void notify_typing(const char *const name); -void notify_message(const char *const name, int win, const char *const text); -void notify_room_message(const char *const nick, const char *const room, int win, const char *const text); +void notify_typing(const char* const name); +void notify_message(const char* const name, int win, const char* const text); +void notify_room_message(const char* const nick, const char* const room, int win, const char* const text); void notify_remind(void); -void notify_invite(const char *const from, const char *const room, const char *const reason); -void notify(const char *const message, int timeout, const char *const category); -void notify_subscription(const char *const from); +void notify_invite(const char* const from, const char* const room, const char* const reason); +void notify(const char* const message, int timeout, const char* const category); +void notify_subscription(const char* const from); #endif diff --git a/src/ui/win_types.h b/src/ui/win_types.h index cb6834c6..d4196111 100644 --- a/src/ui/win_types.h +++ b/src/ui/win_types.h @@ -51,13 +51,13 @@ #include "ui/buffer.h" #include "xmpp/chat_state.h" -#define LAYOUT_SPLIT_MEMCHECK 12345671 -#define PROFCHATWIN_MEMCHECK 22374522 -#define PROFMUCWIN_MEMCHECK 52345276 -#define PROFPRIVATEWIN_MEMCHECK 77437483 -#define PROFCONFWIN_MEMCHECK 64334685 -#define PROFXMLWIN_MEMCHECK 87333463 -#define PROFPLUGINWIN_MEMCHECK 43434777 +#define LAYOUT_SPLIT_MEMCHECK 12345671 +#define PROFCHATWIN_MEMCHECK 22374522 +#define PROFMUCWIN_MEMCHECK 52345276 +#define PROFPRIVATEWIN_MEMCHECK 77437483 +#define PROFCONFWIN_MEMCHECK 64334685 +#define PROFXMLWIN_MEMCHECK 87333463 +#define PROFPLUGINWIN_MEMCHECK 43434777 typedef enum { FIELD_HIDDEN, @@ -73,30 +73,33 @@ typedef enum { FIELD_UNKNOWN } form_field_type_t; -typedef struct form_option_t { - char *label; - char *value; +typedef struct form_option_t +{ + char* label; + char* value; } FormOption; -typedef struct form_field_t { - char *label; - char *type; +typedef struct form_field_t +{ + char* label; + char* type; form_field_type_t type_t; - char *var; - char *description; + char* var; + char* description; gboolean required; - GSList *values; - GSList *options; + GSList* values; + GSList* options; Autocomplete value_ac; } FormField; -typedef struct data_form_t { - char *type; - char *title; - char *instructions; - GSList *fields; - GHashTable *var_to_tag; - GHashTable *tag_to_var; +typedef struct data_form_t +{ + char* type; + char* title; + char* instructions; + GSList* fields; + GHashTable* var_to_tag; + GHashTable* tag_to_var; Autocomplete tag_ac; gboolean modified; } DataForm; @@ -106,21 +109,24 @@ typedef enum { LAYOUT_SPLIT } layout_type_t; -typedef struct prof_layout_t { +typedef struct prof_layout_t +{ layout_type_t type; - WINDOW *win; + WINDOW* win; ProfBuff buffer; int y_pos; int paged; } ProfLayout; -typedef struct prof_layout_simple_t { +typedef struct prof_layout_simple_t +{ ProfLayout base; } ProfLayoutSimple; -typedef struct prof_layout_split_t { +typedef struct prof_layout_split_t +{ ProfLayout base; - WINDOW *subwin; + WINDOW* subwin; int sub_y_pos; unsigned long memcheck; } ProfLayoutSplit; @@ -135,87 +141,95 @@ typedef enum { WIN_PLUGIN } win_type_t; -typedef struct prof_win_t { +typedef struct prof_win_t +{ win_type_t type; - ProfLayout *layout; + ProfLayout* layout; Autocomplete urls_ac; } ProfWin; -typedef struct prof_console_win_t { +typedef struct prof_console_win_t +{ ProfWin window; } ProfConsoleWin; -typedef struct prof_chat_win_t { +typedef struct prof_chat_win_t +{ ProfWin window; - char *barejid; + char* barejid; int unread; - ChatState *state; + ChatState* state; gboolean is_otr; gboolean otr_is_trusted; gboolean pgp_send; gboolean pgp_recv; gboolean is_omemo; - gboolean is_ox; // XEP-0373: OpenPGP for XMPP - char *resource_override; + gboolean is_ox; // XEP-0373: OpenPGP for XMPP + char* resource_override; gboolean history_shown; unsigned long memcheck; - char *enctext; - char *incoming_char; - char *outgoing_char; + char* enctext; + char* incoming_char; + char* outgoing_char; // For LMC - char *last_message; - char *last_msg_id; + char* last_message; + char* last_msg_id; } ProfChatWin; -typedef struct prof_muc_win_t { +typedef struct prof_muc_win_t +{ ProfWin window; - char *roomjid; - char *room_name; + char* roomjid; + char* room_name; int unread; gboolean unread_mentions; gboolean unread_triggers; gboolean showjid; gboolean is_omemo; unsigned long memcheck; - char *enctext; - char *message_char; - GDateTime *last_msg_timestamp; + char* enctext; + char* message_char; + GDateTime* last_msg_timestamp; // For LMC - char *last_message; - char *last_msg_id; + char* last_message; + char* last_msg_id; } ProfMucWin; typedef struct prof_conf_win_t ProfConfWin; -typedef void (*ProfConfWinCallback)(ProfConfWin *); +typedef void (*ProfConfWinCallback)(ProfConfWin*); -struct prof_conf_win_t { +struct prof_conf_win_t +{ ProfWin window; - char *roomjid; - DataForm *form; + char* roomjid; + DataForm* form; unsigned long memcheck; ProfConfWinCallback submit; ProfConfWinCallback cancel; - const void *userdata; + const void* userdata; }; -typedef struct prof_private_win_t { +typedef struct prof_private_win_t +{ ProfWin window; - char *fulljid; + char* fulljid; int unread; unsigned long memcheck; gboolean occupant_offline; gboolean room_left; } ProfPrivateWin; -typedef struct prof_xml_win_t { +typedef struct prof_xml_win_t +{ ProfWin window; unsigned long memcheck; } ProfXMLWin; -typedef struct prof_plugin_win_t { +typedef struct prof_plugin_win_t +{ ProfWin window; - char *tag; - char *plugin_name; + char* tag; + char* plugin_name; unsigned long memcheck; } ProfPluginWin; diff --git a/src/ui/window.c b/src/ui/window.c index 9840716d..33651866 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -60,22 +60,22 @@ #include "xmpp/roster_list.h" #define CONS_WIN_TITLE "Profanity. Type /help for help information." -#define XML_WIN_TITLE "XML Console" +#define XML_WIN_TITLE "XML Console" -#define CEILING(X) (X-(int)(X) > 0 ? (int)(X+1) : (int)(X)) +#define CEILING(X) (X - (int)(X) > 0 ? (int)(X + 1) : (int)(X)) static void -_win_printf(ProfWin *window, const char *show_char, int pad_indent, GDateTime *timestamp, int flags, theme_item_t theme_item, const char *const display_from, const char *const from_jid, const char *const message_id, const char *const message, ...); -static void _win_print_internal(ProfWin *window, const char *show_char, int pad_indent, GDateTime *time, - int flags, theme_item_t theme_item, const char *const from, const char *const message, DeliveryReceipt *receipt); -static void _win_print_wrapped(WINDOW *win, const char *const message, size_t indent, int pad_indent); +_win_printf(ProfWin* window, const char* show_char, int pad_indent, GDateTime* timestamp, int flags, theme_item_t theme_item, const char* const display_from, const char* const from_jid, const char* const message_id, const char* const message, ...); +static void _win_print_internal(ProfWin* window, const char* show_char, int pad_indent, GDateTime* time, + int flags, theme_item_t theme_item, const char* const from, const char* const message, DeliveryReceipt* receipt); +static void _win_print_wrapped(WINDOW* win, const char* const message, size_t indent, int pad_indent); int win_roster_cols(void) { int roster_win_percent = prefs_get_roster_size(); int cols = getmaxx(stdscr); - return CEILING( (((double)cols) / 100) * roster_win_percent); + return CEILING((((double)cols) / 100) * roster_win_percent); } int @@ -83,7 +83,7 @@ win_occpuants_cols(void) { int occupants_win_percent = prefs_get_occupants_size(); int cols = getmaxx(stdscr); - return CEILING( (((double)cols) / 100) * occupants_win_percent); + return CEILING((((double)cols) / 100) * occupants_win_percent); } static ProfLayout* @@ -91,7 +91,7 @@ _win_create_simple_layout(void) { int cols = getmaxx(stdscr); - ProfLayoutSimple *layout = malloc(sizeof(ProfLayoutSimple)); + ProfLayoutSimple* layout = malloc(sizeof(ProfLayoutSimple)); layout->base.type = LAYOUT_SIMPLE; layout->base.win = newpad(PAD_SIZE, cols); wbkgd(layout->base.win, theme_attrs(THEME_TEXT)); @@ -108,7 +108,7 @@ _win_create_split_layout(void) { int cols = getmaxx(stdscr); - ProfLayoutSplit *layout = malloc(sizeof(ProfLayoutSplit)); + ProfLayoutSplit* layout = malloc(sizeof(ProfLayoutSplit)); layout->base.type = LAYOUT_SPLIT; layout->base.win = newpad(PAD_SIZE, cols); wbkgd(layout->base.win, theme_attrs(THEME_TEXT)); @@ -126,7 +126,7 @@ _win_create_split_layout(void) ProfWin* win_create_console(void) { - ProfConsoleWin *new_win = malloc(sizeof(ProfConsoleWin)); + ProfConsoleWin* new_win = malloc(sizeof(ProfConsoleWin)); new_win->window.type = WIN_CONSOLE; new_win->window.layout = _win_create_split_layout(); @@ -134,9 +134,9 @@ win_create_console(void) } ProfWin* -win_create_chat(const char *const barejid) +win_create_chat(const char* const barejid) { - ProfChatWin *new_win = malloc(sizeof(ProfChatWin)); + ProfChatWin* new_win = malloc(sizeof(ProfChatWin)); new_win->window.type = WIN_CHAT; new_win->window.layout = _win_create_simple_layout(); @@ -163,20 +163,21 @@ win_create_chat(const char *const barejid) } ProfWin* -win_create_muc(const char *const roomjid) +win_create_muc(const char* const roomjid) { - ProfMucWin *new_win = malloc(sizeof(ProfMucWin)); + ProfMucWin* new_win = malloc(sizeof(ProfMucWin)); int cols = getmaxx(stdscr); new_win->window.type = WIN_MUC; - ProfLayoutSplit *layout = malloc(sizeof(ProfLayoutSplit)); + ProfLayoutSplit* layout = malloc(sizeof(ProfLayoutSplit)); layout->base.type = LAYOUT_SPLIT; if (prefs_get_boolean(PREF_OCCUPANTS)) { int subwin_cols = win_occpuants_cols(); layout->base.win = newpad(PAD_SIZE, cols - subwin_cols); wbkgd(layout->base.win, theme_attrs(THEME_TEXT)); - layout->subwin = newpad(PAD_SIZE, subwin_cols);; + layout->subwin = newpad(PAD_SIZE, subwin_cols); + ; wbkgd(layout->subwin, theme_attrs(THEME_TEXT)); } else { layout->base.win = newpad(PAD_SIZE, (cols)); @@ -213,9 +214,9 @@ win_create_muc(const char *const roomjid) } ProfWin* -win_create_config(const char *const roomjid, DataForm *form, ProfConfWinCallback submit, ProfConfWinCallback cancel, const void *userdata) +win_create_config(const char* const roomjid, DataForm* form, ProfConfWinCallback submit, ProfConfWinCallback cancel, const void* userdata) { - ProfConfWin *new_win = malloc(sizeof(ProfConfWin)); + ProfConfWin* new_win = malloc(sizeof(ProfConfWin)); new_win->window.type = WIN_CONFIG; new_win->window.layout = _win_create_simple_layout(); new_win->roomjid = strdup(roomjid); @@ -230,9 +231,9 @@ win_create_config(const char *const roomjid, DataForm *form, ProfConfWinCallback } ProfWin* -win_create_private(const char *const fulljid) +win_create_private(const char* const fulljid) { - ProfPrivateWin *new_win = malloc(sizeof(ProfPrivateWin)); + ProfPrivateWin* new_win = malloc(sizeof(ProfPrivateWin)); new_win->window.type = WIN_PRIVATE; new_win->window.layout = _win_create_simple_layout(); new_win->fulljid = strdup(fulljid); @@ -248,7 +249,7 @@ win_create_private(const char *const fulljid) ProfWin* win_create_xmlconsole(void) { - ProfXMLWin *new_win = malloc(sizeof(ProfXMLWin)); + ProfXMLWin* new_win = malloc(sizeof(ProfXMLWin)); new_win->window.type = WIN_XML; new_win->window.layout = _win_create_simple_layout(); @@ -258,9 +259,9 @@ win_create_xmlconsole(void) } ProfWin* -win_create_plugin(const char *const plugin_name, const char *const tag) +win_create_plugin(const char* const plugin_name, const char* const tag) { - ProfPluginWin *new_win = malloc(sizeof(ProfPluginWin)); + ProfPluginWin* new_win = malloc(sizeof(ProfPluginWin)); new_win->window.type = WIN_PLUGIN; new_win->window.layout = _win_create_simple_layout(); @@ -273,7 +274,7 @@ win_create_plugin(const char *const plugin_name, const char *const tag) } char* -win_get_title(ProfWin *window) +win_get_title(ProfWin* window) { if (window == NULL) { return strdup(CONS_WIN_TITLE); @@ -282,13 +283,13 @@ win_get_title(ProfWin *window) return strdup(CONS_WIN_TITLE); } if (window->type == WIN_CHAT) { - ProfChatWin *chatwin = (ProfChatWin*) window; + ProfChatWin* chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); jabber_conn_status_t conn_status = connection_get_status(); if (conn_status == JABBER_CONNECTED) { PContact contact = roster_get_contact(chatwin->barejid); if (contact) { - const char *name = p_contact_name_or_jid(contact); + const char* name = p_contact_name_or_jid(contact); return strdup(name); } else { return strdup(chatwin->barejid); @@ -298,12 +299,12 @@ win_get_title(ProfWin *window) } } if (window->type == WIN_MUC) { - ProfMucWin *mucwin = (ProfMucWin*) window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); gboolean show_titlebar_jid = prefs_get_boolean(PREF_TITLEBAR_MUC_TITLE_JID); gboolean show_titlebar_name = prefs_get_boolean(PREF_TITLEBAR_MUC_TITLE_NAME); - GString *title = g_string_new(""); + GString* title = g_string_new(""); if (show_titlebar_name) { g_string_append(title, mucwin->room_name); @@ -313,24 +314,24 @@ win_get_title(ProfWin *window) g_string_append(title, mucwin->roomjid); } - char *title_str = title->str; + char* title_str = title->str; g_string_free(title, FALSE); return title_str; } if (window->type == WIN_CONFIG) { - ProfConfWin *confwin = (ProfConfWin*) window; + ProfConfWin* confwin = (ProfConfWin*)window; assert(confwin->memcheck == PROFCONFWIN_MEMCHECK); - GString *title = g_string_new(confwin->roomjid); + GString* title = g_string_new(confwin->roomjid); g_string_append(title, " config"); if (confwin->form->modified) { g_string_append(title, " *"); } - char *title_str = title->str; + char* title_str = title->str; g_string_free(title, FALSE); return title_str; } if (window->type == WIN_PRIVATE) { - ProfPrivateWin *privatewin = (ProfPrivateWin*) window; + ProfPrivateWin* privatewin = (ProfPrivateWin*)window; assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK); return strdup(privatewin->fulljid); } @@ -338,7 +339,7 @@ win_get_title(ProfWin *window) return strdup(XML_WIN_TITLE); } if (window->type == WIN_PLUGIN) { - ProfPluginWin *pluginwin = (ProfPluginWin*) window; + ProfPluginWin* pluginwin = (ProfPluginWin*)window; assert(pluginwin->memcheck == PROFPLUGINWIN_MEMCHECK); return strdup(pluginwin->tag); } @@ -347,104 +348,104 @@ win_get_title(ProfWin *window) } char* -win_get_tab_identifier(ProfWin *window) +win_get_tab_identifier(ProfWin* window) { assert(window != NULL); switch (window->type) { - case WIN_CONSOLE: - { - return strdup("console"); - } - case WIN_CHAT: - { - ProfChatWin *chatwin = (ProfChatWin*)window; - return strdup(chatwin->barejid); - } - case WIN_MUC: - { - ProfMucWin *mucwin = (ProfMucWin*)window; - return strdup(mucwin->roomjid); - } - case WIN_CONFIG: - { - ProfConfWin *confwin = (ProfConfWin*)window; - return strdup(confwin->roomjid); - } - case WIN_PRIVATE: - { - ProfPrivateWin *privwin = (ProfPrivateWin*)window; - return strdup(privwin->fulljid); - } - case WIN_PLUGIN: - { - ProfPluginWin *pluginwin = (ProfPluginWin*)window; - return strdup(pluginwin->tag); - } - case WIN_XML: - { - return strdup("xmlconsole"); - } - default: - return strdup("UNKNOWN"); + case WIN_CONSOLE: + { + return strdup("console"); + } + case WIN_CHAT: + { + ProfChatWin* chatwin = (ProfChatWin*)window; + return strdup(chatwin->barejid); + } + case WIN_MUC: + { + ProfMucWin* mucwin = (ProfMucWin*)window; + return strdup(mucwin->roomjid); + } + case WIN_CONFIG: + { + ProfConfWin* confwin = (ProfConfWin*)window; + return strdup(confwin->roomjid); + } + case WIN_PRIVATE: + { + ProfPrivateWin* privwin = (ProfPrivateWin*)window; + return strdup(privwin->fulljid); + } + case WIN_PLUGIN: + { + ProfPluginWin* pluginwin = (ProfPluginWin*)window; + return strdup(pluginwin->tag); + } + case WIN_XML: + { + return strdup("xmlconsole"); + } + default: + return strdup("UNKNOWN"); } } char* -win_to_string(ProfWin *window) +win_to_string(ProfWin* window) { assert(window != NULL); switch (window->type) { - case WIN_CONSOLE: - { - ProfConsoleWin *conswin = (ProfConsoleWin*)window; - return cons_get_string(conswin); - } - case WIN_CHAT: - { - ProfChatWin *chatwin = (ProfChatWin*)window; - return chatwin_get_string(chatwin); - } - case WIN_MUC: - { - ProfMucWin *mucwin = (ProfMucWin*)window; - return mucwin_get_string(mucwin); - } - case WIN_CONFIG: - { - ProfConfWin *confwin = (ProfConfWin*)window; - return confwin_get_string(confwin); - } - case WIN_PRIVATE: - { - ProfPrivateWin *privwin = (ProfPrivateWin*)window; - return privwin_get_string(privwin); - } - case WIN_XML: - { - ProfXMLWin *xmlwin = (ProfXMLWin*)window; - return xmlwin_get_string(xmlwin); - } - case WIN_PLUGIN: - { - ProfPluginWin *pluginwin = (ProfPluginWin*)window; - GString *gstring = g_string_new(""); - g_string_append_printf(gstring, "Plugin: %s", pluginwin->tag); - char *res = gstring->str; - g_string_free(gstring, FALSE); - return res; - } - default: - return NULL; + case WIN_CONSOLE: + { + ProfConsoleWin* conswin = (ProfConsoleWin*)window; + return cons_get_string(conswin); + } + case WIN_CHAT: + { + ProfChatWin* chatwin = (ProfChatWin*)window; + return chatwin_get_string(chatwin); + } + case WIN_MUC: + { + ProfMucWin* mucwin = (ProfMucWin*)window; + return mucwin_get_string(mucwin); + } + case WIN_CONFIG: + { + ProfConfWin* confwin = (ProfConfWin*)window; + return confwin_get_string(confwin); + } + case WIN_PRIVATE: + { + ProfPrivateWin* privwin = (ProfPrivateWin*)window; + return privwin_get_string(privwin); + } + case WIN_XML: + { + ProfXMLWin* xmlwin = (ProfXMLWin*)window; + return xmlwin_get_string(xmlwin); + } + case WIN_PLUGIN: + { + ProfPluginWin* pluginwin = (ProfPluginWin*)window; + GString* gstring = g_string_new(""); + g_string_append_printf(gstring, "Plugin: %s", pluginwin->tag); + char* res = gstring->str; + g_string_free(gstring, FALSE); + return res; + } + default: + return NULL; } } void -win_hide_subwin(ProfWin *window) +win_hide_subwin(ProfWin* window) { if (window->layout->type == LAYOUT_SPLIT) { - ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout; + ProfLayoutSplit* layout = (ProfLayoutSplit*)window->layout; if (layout->subwin) { delwin(layout->subwin); } @@ -461,7 +462,7 @@ win_hide_subwin(ProfWin *window) } void -win_show_subwin(ProfWin *window) +win_show_subwin(ProfWin* window) { int cols = getmaxx(stdscr); int subwin_cols = 0; @@ -476,7 +477,7 @@ win_show_subwin(ProfWin *window) subwin_cols = win_roster_cols(); } - ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout; + ProfLayoutSplit* layout = (ProfLayoutSplit*)window->layout; layout->subwin = newpad(PAD_SIZE, subwin_cols); wbkgd(layout->subwin, theme_attrs(THEME_TEXT)); wresize(layout->base.win, PAD_SIZE, cols - subwin_cols); @@ -487,7 +488,7 @@ void win_free(ProfWin* window) { if (window->layout->type == LAYOUT_SPLIT) { - ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout; + ProfLayoutSplit* layout = (ProfLayoutSplit*)window->layout; if (layout->subwin) { delwin(layout->subwin); } @@ -502,7 +503,7 @@ win_free(ProfWin* window) switch (window->type) { case WIN_CHAT: { - ProfChatWin *chatwin = (ProfChatWin*)window; + ProfChatWin* chatwin = (ProfChatWin*)window; free(chatwin->barejid); free(chatwin->resource_override); free(chatwin->enctext); @@ -515,7 +516,7 @@ win_free(ProfWin* window) } case WIN_MUC: { - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; free(mucwin->roomjid); free(mucwin->room_name); free(mucwin->enctext); @@ -526,20 +527,20 @@ win_free(ProfWin* window) } case WIN_CONFIG: { - ProfConfWin *conf = (ProfConfWin*)window; + ProfConfWin* conf = (ProfConfWin*)window; free(conf->roomjid); form_destroy(conf->form); break; } case WIN_PRIVATE: { - ProfPrivateWin *privatewin = (ProfPrivateWin*)window; + ProfPrivateWin* privatewin = (ProfPrivateWin*)window; free(privatewin->fulljid); break; } case WIN_PLUGIN: { - ProfPluginWin *pluginwin = (ProfPluginWin*)window; + ProfPluginWin* pluginwin = (ProfPluginWin*)window; free(pluginwin->tag); free(pluginwin->plugin_name); break; @@ -552,12 +553,12 @@ win_free(ProfWin* window) } void -win_page_up(ProfWin *window) +win_page_up(ProfWin* window) { int rows = getmaxy(stdscr); int y = getcury(window->layout->win); int page_space = rows - 4; - int *page_start = &(window->layout->y_pos); + int* page_start = &(window->layout->y_pos); *page_start -= page_space; @@ -575,12 +576,12 @@ win_page_up(ProfWin *window) } void -win_page_down(ProfWin *window) +win_page_down(ProfWin* window) { int rows = getmaxy(stdscr); int y = getcury(window->layout->win); int page_space = rows - 4; - int *page_start = &(window->layout->y_pos); + int* page_start = &(window->layout->y_pos); *page_start += page_space; @@ -602,19 +603,19 @@ win_page_down(ProfWin *window) } void -win_sub_page_down(ProfWin *window) +win_sub_page_down(ProfWin* window) { if (window->layout->type == LAYOUT_SPLIT) { int rows = getmaxy(stdscr); int page_space = rows - 4; - ProfLayoutSplit *split_layout = (ProfLayoutSplit*)window->layout; + ProfLayoutSplit* split_layout = (ProfLayoutSplit*)window->layout; int sub_y = getcury(split_layout->subwin); - int *sub_y_pos = &(split_layout->sub_y_pos); + int* sub_y_pos = &(split_layout->sub_y_pos); *sub_y_pos += page_space; // only got half a screen, show full screen - if ((sub_y- (*sub_y_pos)) < page_space) + if ((sub_y - (*sub_y_pos)) < page_space) *sub_y_pos = sub_y - page_space; // went past end, show full screen @@ -626,13 +627,13 @@ win_sub_page_down(ProfWin *window) } void -win_sub_page_up(ProfWin *window) +win_sub_page_up(ProfWin* window) { if (window->layout->type == LAYOUT_SPLIT) { int rows = getmaxy(stdscr); int page_space = rows - 4; - ProfLayoutSplit *split_layout = (ProfLayoutSplit*)window->layout; - int *sub_y_pos = &(split_layout->sub_y_pos); + ProfLayoutSplit* split_layout = (ProfLayoutSplit*)window->layout; + int* sub_y_pos = &(split_layout->sub_y_pos); *sub_y_pos -= page_space; @@ -645,7 +646,7 @@ win_sub_page_up(ProfWin *window) } void -win_clear(ProfWin *window) +win_clear(ProfWin* window) { if (!prefs_get_boolean(PREF_CLEAR_PERSIST_HISTORY)) { werase(window->layout->win); @@ -655,19 +656,19 @@ win_clear(ProfWin *window) } int y = getcury(window->layout->win); - int *page_start = &(window->layout->y_pos); + int* page_start = &(window->layout->y_pos); *page_start = y; window->layout->paged = 1; win_update_virtual(window); } void -win_resize(ProfWin *window) +win_resize(ProfWin* window) { int cols = getmaxx(stdscr); if (window->layout->type == LAYOUT_SPLIT) { - ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout; + ProfLayoutSplit* layout = (ProfLayoutSplit*)window->layout; if (layout->subwin) { int subwin_cols = 0; if (window->type == WIN_CONSOLE) { @@ -682,7 +683,7 @@ win_resize(ProfWin *window) if (window->type == WIN_CONSOLE) { rosterwin_roster(); } else if (window->type == WIN_MUC) { - ProfMucWin *mucwin = (ProfMucWin *)window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); occupantswin_occupants(mucwin->roomjid); } @@ -699,14 +700,14 @@ win_resize(ProfWin *window) } void -win_update_virtual(ProfWin *window) +win_update_virtual(ProfWin* window) { int cols = getmaxx(stdscr); int row_start = screen_mainwin_row_start(); int row_end = screen_mainwin_row_end(); if (window->layout->type == LAYOUT_SPLIT) { - ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout; + ProfLayoutSplit* layout = (ProfLayoutSplit*)window->layout; if (layout->subwin) { int subwin_cols = 0; if (window->type == WIN_MUC) { @@ -714,36 +715,36 @@ win_update_virtual(ProfWin *window) } else { subwin_cols = win_roster_cols(); } - pnoutrefresh(layout->base.win, layout->base.y_pos, 0, row_start, 0, row_end, (cols-subwin_cols)-1); - pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, row_start, (cols-subwin_cols), row_end, cols-1); + pnoutrefresh(layout->base.win, layout->base.y_pos, 0, row_start, 0, row_end, (cols - subwin_cols) - 1); + pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, row_start, (cols - subwin_cols), row_end, cols - 1); } else { - pnoutrefresh(layout->base.win, layout->base.y_pos, 0, row_start, 0, row_end, cols-1); + pnoutrefresh(layout->base.win, layout->base.y_pos, 0, row_start, 0, row_end, cols - 1); } } else { - pnoutrefresh(window->layout->win, window->layout->y_pos, 0, row_start, 0, row_end, cols-1); + pnoutrefresh(window->layout->win, window->layout->y_pos, 0, row_start, 0, row_end, cols - 1); } } void -win_refresh_without_subwin(ProfWin *window) +win_refresh_without_subwin(ProfWin* window) { int cols = getmaxx(stdscr); if ((window->type == WIN_MUC) || (window->type == WIN_CONSOLE)) { int row_start = screen_mainwin_row_start(); int row_end = screen_mainwin_row_end(); - pnoutrefresh(window->layout->win, window->layout->y_pos, 0, row_start, 0, row_end, cols-1); + pnoutrefresh(window->layout->win, window->layout->y_pos, 0, row_start, 0, row_end, cols - 1); } } void -win_refresh_with_subwin(ProfWin *window) +win_refresh_with_subwin(ProfWin* window) { int subwin_cols = 0; int cols = getmaxx(stdscr); int row_start = screen_mainwin_row_start(); int row_end = screen_mainwin_row_end(); - ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout; + ProfLayoutSplit* layout = (ProfLayoutSplit*)window->layout; if (window->type == WIN_MUC) { subwin_cols = win_occpuants_cols(); @@ -754,12 +755,12 @@ win_refresh_with_subwin(ProfWin *window) return; } - pnoutrefresh(layout->base.win, layout->base.y_pos, 0, row_start, 0, row_end, (cols-subwin_cols)-1); - pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, row_start, (cols-subwin_cols), row_end, cols-1); + pnoutrefresh(layout->base.win, layout->base.y_pos, 0, row_start, 0, row_end, (cols - subwin_cols) - 1); + pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, row_start, (cols - subwin_cols), row_end, cols - 1); } void -win_move_to_end(ProfWin *window) +win_move_to_end(ProfWin* window) { window->layout->paged = 0; @@ -774,9 +775,9 @@ win_move_to_end(ProfWin *window) } void -win_show_occupant(ProfWin *window, Occupant *occupant) +win_show_occupant(ProfWin* window, Occupant* occupant) { - const char *presence_str = string_from_resource_presence(occupant->presence); + const char* presence_str = string_from_resource_presence(occupant->presence); theme_item_t presence_colour = theme_main_presence_attrs(presence_str); @@ -791,13 +792,13 @@ win_show_occupant(ProfWin *window, Occupant *occupant) } void -win_show_contact(ProfWin *window, PContact contact) +win_show_contact(ProfWin* window, PContact contact) { - const char *barejid = p_contact_barejid(contact); - const char *name = p_contact_name(contact); - const char *presence = p_contact_presence(contact); - const char *status = p_contact_status(contact); - GDateTime *last_activity = p_contact_last_activity(contact); + const char* barejid = p_contact_barejid(contact); + const char* name = p_contact_name(contact); + const char* presence = p_contact_presence(contact); + const char* status = p_contact_status(contact); + GDateTime* last_activity = p_contact_last_activity(contact); theme_item_t presence_colour = theme_main_presence_attrs(presence); @@ -810,7 +811,7 @@ win_show_contact(ProfWin *window, PContact contact) win_append(window, presence_colour, " is %s", presence); if (last_activity) { - GDateTime *now = g_date_time_new_now_local(); + GDateTime* now = g_date_time_new_now_local(); GTimeSpan span = g_date_time_difference(now, last_activity); g_date_time_unref(now); @@ -835,11 +836,11 @@ win_show_contact(ProfWin *window, PContact contact) } void -win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupant) +win_show_occupant_info(ProfWin* window, const char* const room, Occupant* occupant) { - const char *presence_str = string_from_resource_presence(occupant->presence); - const char *occupant_affiliation = muc_occupant_affiliation_str(occupant); - const char *occupant_role = muc_occupant_role_str(occupant); + const char* presence_str = string_from_resource_presence(occupant->presence); + const char* occupant_affiliation = muc_occupant_affiliation_str(occupant); + const char* occupant_role = muc_occupant_role_str(occupant); theme_item_t presence_colour = theme_main_presence_attrs(presence_str); @@ -859,14 +860,14 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa win_println(window, THEME_DEFAULT, "!", " Affiliation: %s", occupant_affiliation); win_println(window, THEME_DEFAULT, "!", " Role: %s", occupant_role); - Jid *jidp = jid_create_from_bare_and_resource(room, occupant->nick); - EntityCapabilities *caps = caps_lookup(jidp->fulljid); + Jid* jidp = jid_create_from_bare_and_resource(room, occupant->nick); + EntityCapabilities* caps = caps_lookup(jidp->fulljid); jid_destroy(jidp); if (caps) { // show identity if (caps->identity) { - DiscoIdentity *identity = caps->identity; + DiscoIdentity* identity = caps->identity; win_print(window, THEME_DEFAULT, "!", " Identity: "); if (identity->name) { win_append(window, THEME_DEFAULT, "%s", identity->name); @@ -887,7 +888,7 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa } if (caps->software_version) { - SoftwareVersion *software_version = caps->software_version; + SoftwareVersion* software_version = caps->software_version; if (software_version->software) { win_print(window, THEME_DEFAULT, "!", " Software: %s", software_version->software); } @@ -915,13 +916,13 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa } void -win_show_info(ProfWin *window, PContact contact) +win_show_info(ProfWin* window, PContact contact) { - const char *barejid = p_contact_barejid(contact); - const char *name = p_contact_name(contact); - const char *presence = p_contact_presence(contact); - const char *sub = p_contact_subscription(contact); - GDateTime *last_activity = p_contact_last_activity(contact); + const char* barejid = p_contact_barejid(contact); + const char* name = p_contact_name(contact); + const char* presence = p_contact_presence(contact); + const char* sub = p_contact_subscription(contact); + GDateTime* last_activity = p_contact_last_activity(contact); theme_item_t presence_colour = theme_main_presence_attrs(presence); @@ -937,7 +938,7 @@ win_show_info(ProfWin *window, PContact contact) } if (last_activity) { - GDateTime *now = g_date_time_new_now_local(); + GDateTime* now = g_date_time_new_now_local(); GTimeSpan span = g_date_time_difference(now, last_activity); int hours = span / G_TIME_SPAN_HOUR; @@ -947,35 +948,34 @@ win_show_info(ProfWin *window, PContact contact) int seconds = span / G_TIME_SPAN_SECOND; if (hours > 0) { - win_println(window, THEME_DEFAULT, "-", "Last activity: %dh%dm%ds", hours, minutes, seconds); - } - else { - win_println(window, THEME_DEFAULT, "-", "Last activity: %dm%ds", minutes, seconds); + win_println(window, THEME_DEFAULT, "-", "Last activity: %dh%dm%ds", hours, minutes, seconds); + } else { + win_println(window, THEME_DEFAULT, "-", "Last activity: %dm%ds", minutes, seconds); } g_date_time_unref(now); } - GList *resources = p_contact_get_available_resources(contact); - GList *ordered_resources = NULL; + GList* resources = p_contact_get_available_resources(contact); + GList* ordered_resources = NULL; if (resources) { win_println(window, THEME_DEFAULT, "-", "Resources:"); // sort in order of availability - GList *curr = resources; + GList* curr = resources; while (curr) { - Resource *resource = curr->data; + Resource* resource = curr->data; ordered_resources = g_list_insert_sorted(ordered_resources, - resource, (GCompareFunc)resource_compare_availability); + resource, (GCompareFunc)resource_compare_availability); curr = g_list_next(curr); } } g_list_free(resources); - GList *curr = ordered_resources; + GList* curr = ordered_resources; while (curr) { - Resource *resource = curr->data; - const char *resource_presence = string_from_resource_presence(resource->presence); + Resource* resource = curr->data; + const char* resource_presence = string_from_resource_presence(resource->presence); theme_item_t presence_colour = theme_main_presence_attrs(resource_presence); win_print(window, presence_colour, "-", " %s (%d), %s", resource->name, resource->priority, resource_presence); if (resource->status) { @@ -983,14 +983,14 @@ win_show_info(ProfWin *window, PContact contact) } win_newline(window); - Jid *jidp = jid_create_from_bare_and_resource(barejid, resource->name); - EntityCapabilities *caps = caps_lookup(jidp->fulljid); + Jid* jidp = jid_create_from_bare_and_resource(barejid, resource->name); + EntityCapabilities* caps = caps_lookup(jidp->fulljid); jid_destroy(jidp); if (caps) { // show identity if (caps->identity) { - DiscoIdentity *identity = caps->identity; + DiscoIdentity* identity = caps->identity; win_print(window, THEME_DEFAULT, "-", " Identity: "); if (identity->name) { win_append(window, THEME_DEFAULT, "%s", identity->name); @@ -1011,7 +1011,7 @@ win_show_info(ProfWin *window, PContact contact) } if (caps->software_version) { - SoftwareVersion *software_version = caps->software_version; + SoftwareVersion* software_version = caps->software_version; if (software_version->software) { win_print(window, THEME_DEFAULT, "-", " Software: %s", software_version->software); } @@ -1041,10 +1041,10 @@ win_show_info(ProfWin *window, PContact contact) } void -win_show_status_string(ProfWin *window, const char *const from, - const char *const show, const char *const status, - GDateTime *last_activity, const char *const pre, - const char *const default_show) +win_show_status_string(ProfWin* window, const char* const from, + const char* const show, const char* const status, + GDateTime* last_activity, const char* const pre, + const char* const default_show) { theme_item_t presence_colour; @@ -1064,8 +1064,8 @@ win_show_status_string(ProfWin *window, const char *const from, win_append(window, presence_colour, " is %s", default_show); if (last_activity) { - gchar *date_fmt = NULL; - char *time_pref = prefs_get_string(PREF_TIME_LASTACTIVITY); + gchar* date_fmt = NULL; + char* time_pref = prefs_get_string(PREF_TIME_LASTACTIVITY); date_fmt = g_date_time_format(last_activity, time_pref); g_free(time_pref); assert(date_fmt != NULL); @@ -1082,9 +1082,9 @@ win_show_status_string(ProfWin *window, const char *const from, } static void -_win_correct(ProfWin *window, const char *const message, const char *const id, const char *const replace_id, const char *const from_jid) +_win_correct(ProfWin* window, const char* const message, const char* const id, const char* const replace_id, const char* const from_jid) { - ProfBuffEntry *entry = buffer_get_entry_by_id(window->layout->buffer, replace_id); + ProfBuffEntry* entry = buffer_get_entry_by_id(window->layout->buffer, replace_id); if (!entry) { log_debug("Replace ID %s could not be found in buffer. Message: %s", replace_id, message); return; @@ -1124,7 +1124,7 @@ _win_correct(ProfWin *window, const char *const message, const char *const id, c } void -win_print_incoming(ProfWin *window, const char *const display_name_from, ProfMessage *message) +win_print_incoming(ProfWin* window, const char* const display_name_from, ProfMessage* message) { int flags = NO_ME; @@ -1132,53 +1132,52 @@ win_print_incoming(ProfWin *window, const char *const display_name_from, ProfMes flags |= UNTRUSTED; } - switch (window->type) + switch (window->type) { + case WIN_CHAT: { - case WIN_CHAT: - { - char *enc_char; - ProfChatWin *chatwin = (ProfChatWin*)window; - - if (chatwin->incoming_char) { - enc_char = strdup(chatwin->incoming_char); - } else if (message->enc == PROF_MSG_ENC_OTR) { - enc_char = prefs_get_otr_char(); - } else if (message->enc == PROF_MSG_ENC_PGP) { - enc_char = prefs_get_pgp_char(); - } else if (message->enc == PROF_MSG_ENC_OX) { // XEP-0373: OpenPGP for XMPP - enc_char = prefs_get_ox_char(); - } else if (message->enc == PROF_MSG_ENC_OMEMO) { - enc_char = prefs_get_omemo_char(); - } else { - enc_char = strdup("-"); - } - - if (prefs_get_boolean(PREF_CORRECTION_ALLOW) && message->replace_id) { - _win_correct(window, message->plain, message->id, message->replace_id, message->from_jid->barejid); - } else { - _win_printf(window, enc_char, 0, message->timestamp, flags, THEME_TEXT_THEM, display_name_from, message->from_jid->barejid, message->id, "%s", message->plain); - } + char* enc_char; + ProfChatWin* chatwin = (ProfChatWin*)window; + + if (chatwin->incoming_char) { + enc_char = strdup(chatwin->incoming_char); + } else if (message->enc == PROF_MSG_ENC_OTR) { + enc_char = prefs_get_otr_char(); + } else if (message->enc == PROF_MSG_ENC_PGP) { + enc_char = prefs_get_pgp_char(); + } else if (message->enc == PROF_MSG_ENC_OX) { // XEP-0373: OpenPGP for XMPP + enc_char = prefs_get_ox_char(); + } else if (message->enc == PROF_MSG_ENC_OMEMO) { + enc_char = prefs_get_omemo_char(); + } else { + enc_char = strdup("-"); + } - free(enc_char); - break; + if (prefs_get_boolean(PREF_CORRECTION_ALLOW) && message->replace_id) { + _win_correct(window, message->plain, message->id, message->replace_id, message->from_jid->barejid); + } else { + _win_printf(window, enc_char, 0, message->timestamp, flags, THEME_TEXT_THEM, display_name_from, message->from_jid->barejid, message->id, "%s", message->plain); } - case WIN_PRIVATE: - _win_printf(window, "-", 0, message->timestamp, flags, THEME_TEXT_THEM, display_name_from, message->from_jid->barejid, message->id, "%s", message->plain); - break; - default: - assert(FALSE); - break; + + free(enc_char); + break; + } + case WIN_PRIVATE: + _win_printf(window, "-", 0, message->timestamp, flags, THEME_TEXT_THEM, display_name_from, message->from_jid->barejid, message->id, "%s", message->plain); + break; + default: + assert(FALSE); + break; } } void -win_print_them(ProfWin *window, theme_item_t theme_item, const char *const show_char, int flags, const char *const them) +win_print_them(ProfWin* window, theme_item_t theme_item, const char* const show_char, int flags, const char* const them) { _win_printf(window, show_char, 0, NULL, flags | NO_ME | NO_EOL, theme_item, them, NULL, NULL, ""); } void -win_println_incoming_muc_msg(ProfWin *window, char *show_char, int flags, const ProfMessage *const message) +win_println_incoming_muc_msg(ProfWin* window, char* show_char, int flags, const ProfMessage* const message) { if (prefs_get_boolean(PREF_CORRECTION_ALLOW) && message->replace_id) { _win_correct(window, message->plain, message->id, message->replace_id, message->from_jid->fulljid); @@ -1190,9 +1189,9 @@ win_println_incoming_muc_msg(ProfWin *window, char *show_char, int flags, const } void -win_print_outgoing_muc_msg(ProfWin *window, char *show_char, const char *const me, const char *const id, const char *const replace_id, const char *const message) +win_print_outgoing_muc_msg(ProfWin* window, char* show_char, const char* const me, const char* const id, const char* const replace_id, const char* const message) { - GDateTime *timestamp = g_date_time_new_now_local(); + GDateTime* timestamp = g_date_time_new_now_local(); if (prefs_get_boolean(PREF_CORRECTION_ALLOW) && replace_id) { _win_correct(window, message, id, replace_id, me); @@ -1205,11 +1204,11 @@ win_print_outgoing_muc_msg(ProfWin *window, char *show_char, const char *const m } void -win_print_outgoing(ProfWin *window, const char *show_char, const char *const id, const char *const replace_id, const char *const message) +win_print_outgoing(ProfWin* window, const char* show_char, const char* const id, const char* const replace_id, const char* const message) { - GDateTime *timestamp = g_date_time_new_now_local(); + GDateTime* timestamp = g_date_time_new_now_local(); - const char *myjid = connection_get_fulljid(); + const char* myjid = connection_get_fulljid(); if (replace_id) { _win_correct(window, message, id, replace_id, myjid); } else { @@ -1222,14 +1221,14 @@ win_print_outgoing(ProfWin *window, const char *show_char, const char *const id, } void -win_print_history(ProfWin *window, const ProfMessage *const message) +win_print_history(ProfWin* window, const ProfMessage* const message) { g_date_time_ref(message->timestamp); - char *display_name; + char* display_name; int flags = 0; - const char *jid = connection_get_fulljid(); - Jid *jidp = jid_create(jid); + const char* jid = connection_get_fulljid(); + Jid* jidp = jid_create(jid); if (g_strcmp0(jidp->barejid, message->from_jid->barejid) == 0) { display_name = strdup("me"); @@ -1249,13 +1248,13 @@ win_print_history(ProfWin *window, const ProfMessage *const message) } void -win_print(ProfWin *window, theme_item_t theme_item, const char *show_char, const char *const message, ...) +win_print(ProfWin* window, theme_item_t theme_item, const char* show_char, const char* const message, ...) { - GDateTime *timestamp = g_date_time_new_now_local(); + GDateTime* timestamp = g_date_time_new_now_local(); va_list arg; va_start(arg, message); - GString *fmt_msg = g_string_new(NULL); + GString* fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); buffer_append(window->layout->buffer, show_char, 0, timestamp, NO_EOL, theme_item, "", NULL, fmt_msg->str, NULL, NULL); @@ -1269,13 +1268,13 @@ win_print(ProfWin *window, theme_item_t theme_item, const char *show_char, const } void -win_println(ProfWin *window, theme_item_t theme_item, const char *show_char, const char *const message, ...) +win_println(ProfWin* window, theme_item_t theme_item, const char* show_char, const char* const message, ...) { - GDateTime *timestamp = g_date_time_new_now_local(); + GDateTime* timestamp = g_date_time_new_now_local(); va_list arg; va_start(arg, message); - GString *fmt_msg = g_string_new(NULL); + GString* fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); buffer_append(window->layout->buffer, show_char, 0, timestamp, 0, theme_item, "", NULL, fmt_msg->str, NULL, NULL); @@ -1289,13 +1288,13 @@ win_println(ProfWin *window, theme_item_t theme_item, const char *show_char, con } void -win_println_indent(ProfWin *window, int pad, const char *const message, ...) +win_println_indent(ProfWin* window, int pad, const char* const message, ...) { - GDateTime *timestamp = g_date_time_new_now_local(); + GDateTime* timestamp = g_date_time_new_now_local(); va_list arg; va_start(arg, message); - GString *fmt_msg = g_string_new(NULL); + GString* fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); buffer_append(window->layout->buffer, "-", pad, timestamp, 0, THEME_DEFAULT, "", NULL, fmt_msg->str, NULL, NULL); @@ -1309,13 +1308,13 @@ win_println_indent(ProfWin *window, int pad, const char *const message, ...) } void -win_append(ProfWin *window, theme_item_t theme_item, const char *const message, ...) +win_append(ProfWin* window, theme_item_t theme_item, const char* const message, ...) { - GDateTime *timestamp = g_date_time_new_now_local(); + GDateTime* timestamp = g_date_time_new_now_local(); va_list arg; va_start(arg, message); - GString *fmt_msg = g_string_new(NULL); + GString* fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); buffer_append(window->layout->buffer, "-", 0, timestamp, NO_DATE | NO_EOL, theme_item, "", NULL, fmt_msg->str, NULL, NULL); @@ -1329,13 +1328,13 @@ win_append(ProfWin *window, theme_item_t theme_item, const char *const message, } void -win_appendln(ProfWin *window, theme_item_t theme_item, const char *const message, ...) +win_appendln(ProfWin* window, theme_item_t theme_item, const char* const message, ...) { - GDateTime *timestamp = g_date_time_new_now_local(); + GDateTime* timestamp = g_date_time_new_now_local(); va_list arg; va_start(arg, message); - GString *fmt_msg = g_string_new(NULL); + GString* fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); buffer_append(window->layout->buffer, "-", 0, timestamp, NO_DATE, theme_item, "", NULL, fmt_msg->str, NULL, NULL); @@ -1349,13 +1348,13 @@ win_appendln(ProfWin *window, theme_item_t theme_item, const char *const message } void -win_append_highlight(ProfWin *window, theme_item_t theme_item, const char *const message, ...) +win_append_highlight(ProfWin* window, theme_item_t theme_item, const char* const message, ...) { - GDateTime *timestamp = g_date_time_new_now_local(); + GDateTime* timestamp = g_date_time_new_now_local(); va_list arg; va_start(arg, message); - GString *fmt_msg = g_string_new(NULL); + GString* fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); buffer_append(window->layout->buffer, "-", 0, timestamp, NO_DATE | NO_ME | NO_EOL, theme_item, "", NULL, fmt_msg->str, NULL, NULL); @@ -1369,13 +1368,13 @@ win_append_highlight(ProfWin *window, theme_item_t theme_item, const char *const } void -win_appendln_highlight(ProfWin *window, theme_item_t theme_item, const char *const message, ...) +win_appendln_highlight(ProfWin* window, theme_item_t theme_item, const char* const message, ...) { - GDateTime *timestamp = g_date_time_new_now_local(); + GDateTime* timestamp = g_date_time_new_now_local(); va_list arg; va_start(arg, message); - GString *fmt_msg = g_string_new(NULL); + GString* fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); buffer_append(window->layout->buffer, "-", 0, timestamp, NO_DATE | NO_ME, theme_item, "", NULL, fmt_msg->str, NULL, NULL); @@ -1389,20 +1388,20 @@ win_appendln_highlight(ProfWin *window, theme_item_t theme_item, const char *con } void -win_print_http_upload(ProfWin *window, const char *const message, char *url) +win_print_http_upload(ProfWin* window, const char* const message, char* url) { win_print_outgoing_with_receipt(window, "!", NULL, message, url, NULL); } void -win_print_outgoing_with_receipt(ProfWin *window, const char *show_char, const char *const from, const char *const message, char *id, const char *const replace_id) +win_print_outgoing_with_receipt(ProfWin* window, const char* show_char, const char* const from, const char* const message, char* id, const char* const replace_id) { - GDateTime *time = g_date_time_new_now_local(); + GDateTime* time = g_date_time_new_now_local(); - DeliveryReceipt *receipt = malloc(sizeof(struct delivery_receipt_t)); + DeliveryReceipt* receipt = malloc(sizeof(struct delivery_receipt_t)); receipt->received = FALSE; - const char *myjid = connection_get_fulljid(); + const char* myjid = connection_get_fulljid(); if (replace_id) { _win_correct(window, message, id, replace_id, myjid); } else { @@ -1416,7 +1415,7 @@ win_print_outgoing_with_receipt(ProfWin *window, const char *show_char, const ch } void -win_mark_received(ProfWin *window, const char *const id) +win_mark_received(ProfWin* window, const char* const id) { gboolean received = buffer_mark_received(window->layout->buffer, id); if (received) { @@ -1425,9 +1424,9 @@ win_mark_received(ProfWin *window, const char *const id) } void -win_update_entry_message(ProfWin *window, const char *const id, const char *const message) +win_update_entry_message(ProfWin* window, const char* const id, const char* const message) { - ProfBuffEntry *entry = buffer_get_entry_by_id(window->layout->buffer, id); + ProfBuffEntry* entry = buffer_get_entry_by_id(window->layout->buffer, id); if (entry) { free(entry->message); entry->message = strdup(message); @@ -1436,20 +1435,20 @@ win_update_entry_message(ProfWin *window, const char *const id, const char *cons } void -win_remove_entry_message(ProfWin *window, const char *const id) +win_remove_entry_message(ProfWin* window, const char* const id) { buffer_remove_entry_by_id(window->layout->buffer, id); win_redraw(window); } void -win_newline(ProfWin *window) +win_newline(ProfWin* window) { win_appendln(window, THEME_DEFAULT, ""); } static void -_win_printf(ProfWin *window, const char *show_char, int pad_indent, GDateTime *timestamp, int flags, theme_item_t theme_item, const char *const display_from, const char *const from_jid, const char *const message_id, const char *const message, ...) +_win_printf(ProfWin* window, const char* show_char, int pad_indent, GDateTime* timestamp, int flags, theme_item_t theme_item, const char* const display_from, const char* const from_jid, const char* const message_id, const char* const message, ...) { if (timestamp == NULL) { timestamp = g_date_time_new_now_local(); @@ -1459,7 +1458,7 @@ _win_printf(ProfWin *window, const char *show_char, int pad_indent, GDateTime *t va_list arg; va_start(arg, message); - GString *fmt_msg = g_string_new(NULL); + GString* fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); buffer_append(window->layout->buffer, show_char, pad_indent, timestamp, flags, theme_item, display_from, from_jid, fmt_msg->str, NULL, message_id); @@ -1474,8 +1473,8 @@ _win_printf(ProfWin *window, const char *show_char, int pad_indent, GDateTime *t } static void -_win_print_internal(ProfWin *window, const char *show_char, int pad_indent, GDateTime *time, - int flags, theme_item_t theme_item, const char *const from, const char *const message, DeliveryReceipt *receipt) +_win_print_internal(ProfWin* window, const char* show_char, int pad_indent, GDateTime* time, + int flags, theme_item_t theme_item, const char* const from, const char* const message, DeliveryReceipt* receipt) { // flags : 1st bit = 0/1 - me/not me. define: NO_ME // 2nd bit = 0/1 - date/no date. define: NO_DATE @@ -1488,29 +1487,29 @@ _win_print_internal(ProfWin *window, const char *show_char, int pad_indent, GDat int colour = theme_attrs(THEME_ME); size_t indent = 0; - char *time_pref = NULL; + char* time_pref = NULL; switch (window->type) { - case WIN_CHAT: - time_pref = prefs_get_string(PREF_TIME_CHAT); - break; - case WIN_MUC: - time_pref = prefs_get_string(PREF_TIME_MUC); - break; - case WIN_CONFIG: - time_pref = prefs_get_string(PREF_TIME_CONFIG); - break; - case WIN_PRIVATE: - time_pref = prefs_get_string(PREF_TIME_PRIVATE); - break; - case WIN_XML: - time_pref = prefs_get_string(PREF_TIME_XMLCONSOLE); - break; - default: - time_pref = prefs_get_string(PREF_TIME_CONSOLE); - break; - } - - gchar *date_fmt = NULL; + case WIN_CHAT: + time_pref = prefs_get_string(PREF_TIME_CHAT); + break; + case WIN_MUC: + time_pref = prefs_get_string(PREF_TIME_MUC); + break; + case WIN_CONFIG: + time_pref = prefs_get_string(PREF_TIME_CONFIG); + break; + case WIN_PRIVATE: + time_pref = prefs_get_string(PREF_TIME_PRIVATE); + break; + case WIN_XML: + time_pref = prefs_get_string(PREF_TIME_XMLCONSOLE); + break; + default: + time_pref = prefs_get_string(PREF_TIME_CONSOLE); + break; + } + + gchar* date_fmt = NULL; if (g_strcmp0(time_pref, "off") == 0 || time == NULL) { date_fmt = g_strdup(""); } else { @@ -1519,7 +1518,7 @@ _win_print_internal(ProfWin *window, const char *show_char, int pad_indent, GDat g_free(time_pref); assert(date_fmt != NULL); - if(strlen(date_fmt) != 0){ + if (strlen(date_fmt) != 0) { indent = 3 + strlen(date_fmt); } @@ -1541,7 +1540,7 @@ _win_print_internal(ProfWin *window, const char *show_char, int pad_indent, GDat colour = theme_attrs(THEME_THEM); } - char *color_pref = prefs_get_string(PREF_COLOR_NICK); + char* color_pref = prefs_get_string(PREF_COLOR_NICK); if (color_pref != NULL && (strcmp(color_pref, "false") != 0)) { if (flags & NO_ME || (!(flags & NO_ME) && prefs_get_boolean(PREF_COLOR_NICK_OWN))) { colour = theme_hash_attrs(from); @@ -1583,9 +1582,9 @@ _win_print_internal(ProfWin *window, const char *show_char, int pad_indent, GDat } if (prefs_get_boolean(PREF_WRAP)) { - _win_print_wrapped(window->layout->win, message+offset, indent, pad_indent); + _win_print_wrapped(window->layout->win, message + offset, indent, pad_indent); } else { - wprintw(window->layout->win, "%s", message+offset); + wprintw(window->layout->win, "%s", message + offset); } if ((flags & NO_EOL) == 0) { @@ -1609,7 +1608,7 @@ _win_print_internal(ProfWin *window, const char *show_char, int pad_indent, GDat } static void -_win_indent(WINDOW *win, int size) +_win_indent(WINDOW* win, int size) { int i = 0; for (i = 0; i < size; i++) { @@ -1618,13 +1617,13 @@ _win_indent(WINDOW *win, int size) } static void -_win_print_wrapped(WINDOW *win, const char *const message, size_t indent, int pad_indent) +_win_print_wrapped(WINDOW* win, const char* const message, size_t indent, int pad_indent) { int starty = getcury(win); int wordi = 0; - char *word = malloc(strlen(message) + 1); + char* word = malloc(strlen(message) + 1); - gchar *curr_ch = g_utf8_offset_to_pointer(message, 0); + gchar* curr_ch = g_utf8_offset_to_pointer(message, 0); while (*curr_ch != '\0') { @@ -1633,13 +1632,13 @@ _win_print_wrapped(WINDOW *win, const char *const message, size_t indent, int pa waddch(win, ' '); curr_ch = g_utf8_next_char(curr_ch); - // handle newline + // handle newline } else if (*curr_ch == '\n') { waddch(win, '\n'); _win_indent(win, indent + pad_indent); curr_ch = g_utf8_next_char(curr_ch); - // handle word + // handle word } else { wordi = 0; int wordlen = 0; @@ -1668,8 +1667,8 @@ _win_print_wrapped(WINDOW *win, const char *const message, size_t indent, int pa // word larger than line if (wordlen > linelen) { - gchar *word_ch = g_utf8_offset_to_pointer(word, 0); - while(*word_ch != '\0') { + gchar* word_ch = g_utf8_offset_to_pointer(word, 0); + while (*word_ch != '\0') { curx = getcurx(win); cury = getcury(win); gboolean firstline = cury == starty; @@ -1681,14 +1680,14 @@ _win_print_wrapped(WINDOW *win, const char *const message, size_t indent, int pa _win_indent(win, indent + pad_indent); } - gchar copy[wordi+1]; + gchar copy[wordi + 1]; g_utf8_strncpy(copy, word_ch, 1); waddstr(win, copy); word_ch = g_utf8_next_char(word_ch); } - // newline and print word + // newline and print word } else { waddch(win, '\n'); curx = getcurx(win); @@ -1704,7 +1703,7 @@ _win_print_wrapped(WINDOW *win, const char *const message, size_t indent, int pa waddstr(win, word); } - // no wrap required + // no wrap required } else { curx = getcurx(win); cury = getcury(win); @@ -1734,7 +1733,7 @@ _win_print_wrapped(WINDOW *win, const char *const message, size_t indent, int pa } void -win_print_trackbar(ProfWin *window) +win_print_trackbar(ProfWin* window) { int cols = getmaxx(window->layout->win); @@ -1742,7 +1741,7 @@ win_print_trackbar(ProfWin *window) wattron(window->layout->win, theme_attrs(THEME_TRACKBAR)); int i; - for (i=1; i<cols; i++) { + for (i = 1; i < cols; i++) { wprintw(window->layout->win, "-"); } @@ -1752,14 +1751,14 @@ win_print_trackbar(ProfWin *window) } void -win_redraw(ProfWin *window) +win_redraw(ProfWin* window) { int i, size; werase(window->layout->win); size = buffer_size(window->layout->buffer); for (i = 0; i < size; i++) { - ProfBuffEntry *e = buffer_get_entry(window->layout->buffer, i); + ProfBuffEntry* e = buffer_get_entry(window->layout->buffer, i); if (e->display_from == NULL && e->message && e->message[0] == '-') { // just an indicator to print the trackbar/separator not the actual message @@ -1772,10 +1771,10 @@ win_redraw(ProfWin *window) } gboolean -win_has_active_subwin(ProfWin *window) +win_has_active_subwin(ProfWin* window) { if (window->layout->type == LAYOUT_SPLIT) { - ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout; + ProfLayoutSplit* layout = (ProfLayoutSplit*)window->layout; return (layout->subwin != NULL); } else { return FALSE; @@ -1783,12 +1782,12 @@ win_has_active_subwin(ProfWin *window) } gboolean -win_notify_remind(ProfWin *window) +win_notify_remind(ProfWin* window) { switch (window->type) { case WIN_CHAT: { - ProfChatWin *chatwin = (ProfChatWin*) window; + ProfChatWin* chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); if (prefs_get_boolean(PREF_NOTIFY_CHAT) && chatwin->unread > 0) { @@ -1799,14 +1798,14 @@ win_notify_remind(ProfWin *window) } case WIN_MUC: { - ProfMucWin *mucwin = (ProfMucWin*) window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); return prefs_do_room_notify_mention(mucwin->roomjid, mucwin->unread, mucwin->unread_mentions, mucwin->unread_triggers); } case WIN_PRIVATE: { - ProfPrivateWin *privatewin = (ProfPrivateWin*) window; + ProfPrivateWin* privatewin = (ProfPrivateWin*)window; assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK); if (prefs_get_boolean(PREF_NOTIFY_CHAT) && privatewin->unread > 0) { @@ -1821,18 +1820,18 @@ win_notify_remind(ProfWin *window) } int -win_unread(ProfWin *window) +win_unread(ProfWin* window) { if (window->type == WIN_CHAT) { - ProfChatWin *chatwin = (ProfChatWin*) window; + ProfChatWin* chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); return chatwin->unread; } else if (window->type == WIN_MUC) { - ProfMucWin *mucwin = (ProfMucWin*) window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); return mucwin->unread; } else if (window->type == WIN_PRIVATE) { - ProfPrivateWin *privatewin = (ProfPrivateWin*) window; + ProfPrivateWin* privatewin = (ProfPrivateWin*)window; assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK); return privatewin->unread; } else { @@ -1841,7 +1840,7 @@ win_unread(ProfWin *window) } void -win_sub_print(WINDOW *win, char *msg, gboolean newline, gboolean wrap, int indent) +win_sub_print(WINDOW* win, char* msg, gboolean newline, gboolean wrap, int indent) { int maxx = getmaxx(win); int curx = getcurx(win); @@ -1854,22 +1853,22 @@ win_sub_print(WINDOW *win, char *msg, gboolean newline, gboolean wrap, int inden } if (newline) { - wmove(win, cury+1, 0); + wmove(win, cury + 1, 0); } } void -win_sub_newline_lazy(WINDOW *win) +win_sub_newline_lazy(WINDOW* win) { int curx = getcurx(win); if (curx > 0) { int cury = getcury(win); - wmove(win, cury+1, 0); + wmove(win, cury + 1, 0); } } void -win_command_list_error(ProfWin *window, const char *const error) +win_command_list_error(ProfWin* window, const char* const error) { assert(window != NULL); @@ -1877,12 +1876,12 @@ win_command_list_error(ProfWin *window, const char *const error) } void -win_command_exec_error(ProfWin *window, const char *const command, const char *const error, ...) +win_command_exec_error(ProfWin* window, const char* const command, const char* const error, ...) { assert(window != NULL); va_list arg; va_start(arg, error); - GString *msg = g_string_new(NULL); + GString* msg = g_string_new(NULL); g_string_vprintf(msg, error, arg); win_println(window, THEME_ERROR, "!", "Error executing command %s: %s", command, msg->str); @@ -1892,15 +1891,15 @@ win_command_exec_error(ProfWin *window, const char *const command, const char *c } void -win_handle_command_list(ProfWin *window, GSList *cmds) +win_handle_command_list(ProfWin* window, GSList* cmds) { assert(window != NULL); if (cmds) { win_println(window, THEME_DEFAULT, "!", "Ad hoc commands:"); - GSList *curr_cmd = cmds; + GSList* curr_cmd = cmds; while (curr_cmd) { - const char *cmd = curr_cmd->data; + const char* cmd = curr_cmd->data; win_println(window, THEME_DEFAULT, "!", " %s", cmd); curr_cmd = g_slist_next(curr_cmd); } @@ -1912,21 +1911,21 @@ win_handle_command_list(ProfWin *window, GSList *cmds) } void -win_handle_command_exec_status(ProfWin *window, const char *const command, const char *const value) +win_handle_command_exec_status(ProfWin* window, const char* const command, const char* const value) { assert(window != NULL); win_println(window, THEME_DEFAULT, "!", "%s %s", command, value); } void -win_handle_command_exec_result_note(ProfWin *window, const char *const type, const char *const value) +win_handle_command_exec_result_note(ProfWin* window, const char* const type, const char* const value) { assert(window != NULL); win_println(window, THEME_DEFAULT, "!", value); } void -win_insert_last_read_position_marker(ProfWin *window, char* id) +win_insert_last_read_position_marker(ProfWin* window, char* id) { int i, size; size = buffer_size(window->layout->buffer); @@ -1934,7 +1933,7 @@ win_insert_last_read_position_marker(ProfWin *window, char* id) // TODO: this is somewhat costly. We should improve this later. // check if we already have a separator present for (i = 0; i < size; i++) { - ProfBuffEntry *e = buffer_get_entry(window->layout->buffer, i); + ProfBuffEntry* e = buffer_get_entry(window->layout->buffer, i); // if yes, don't print a new one if (e->id && (g_strcmp0(e->id, id) == 0)) { @@ -1942,7 +1941,7 @@ win_insert_last_read_position_marker(ProfWin *window, char* id) } } - GDateTime *time = g_date_time_new_now_local(); + GDateTime* time = g_date_time_new_now_local(); // the trackbar/separator will actually be print in win_redraw(). // this only puts it in the buffer and win_redraw() will interpret it. @@ -1952,4 +1951,3 @@ win_insert_last_read_position_marker(ProfWin *window, char* id) g_date_time_unref(time); } - diff --git a/src/ui/window.h b/src/ui/window.h index 4dc8e7d2..17316b05 100644 --- a/src/ui/window.h +++ b/src/ui/window.h @@ -56,39 +56,39 @@ #define PAD_SIZE 1000 -void win_move_to_end(ProfWin *window); -void win_show_status_string(ProfWin *window, const char *const from, - const char *const show, const char *const status, - GDateTime *last_activity, const char *const pre, - const char *const default_show); +void win_move_to_end(ProfWin* window); +void win_show_status_string(ProfWin* window, const char* const from, + const char* const show, const char* const status, + GDateTime* last_activity, const char* const pre, + const char* const default_show); -void win_print_them(ProfWin *window, theme_item_t theme_item, const char *const show_char, int flags, const char *const them); -void win_print_incoming(ProfWin *window, const char *const from, ProfMessage *message); -void win_print_outgoing(ProfWin *window, const char *show_char, const char *const id, const char *const replace_id, const char *const message); -void win_print_outgoing_with_receipt(ProfWin *window, const char *show_char, const char *const from, const char *const message, char *id, const char *const replace_id); -void win_println_incoming_muc_msg(ProfWin *window, char *show_char, int flags, const ProfMessage *const message); -void win_print_outgoing_muc_msg(ProfWin *window, char *show_char, const char *const me, const char *const id, const char *const replace_id, const char *const message); -void win_print_history(ProfWin *window, const ProfMessage *const message); +void win_print_them(ProfWin* window, theme_item_t theme_item, const char* const show_char, int flags, const char* const them); +void win_print_incoming(ProfWin* window, const char* const from, ProfMessage* message); +void win_print_outgoing(ProfWin* window, const char* show_char, const char* const id, const char* const replace_id, const char* const message); +void win_print_outgoing_with_receipt(ProfWin* window, const char* show_char, const char* const from, const char* const message, char* id, const char* const replace_id); +void win_println_incoming_muc_msg(ProfWin* window, char* show_char, int flags, const ProfMessage* const message); +void win_print_outgoing_muc_msg(ProfWin* window, char* show_char, const char* const me, const char* const id, const char* const replace_id, const char* const message); +void win_print_history(ProfWin* window, const ProfMessage* const message); -void win_print_http_upload(ProfWin *window, const char *const message, char *url); +void win_print_http_upload(ProfWin* window, const char* const message, char* url); -void win_newline(ProfWin *window); -void win_redraw(ProfWin *window); +void win_newline(ProfWin* window); +void win_redraw(ProfWin* window); int win_roster_cols(void); int win_occpuants_cols(void); -void win_sub_print(WINDOW *win, char *msg, gboolean newline, gboolean wrap, int indent); -void win_sub_newline_lazy(WINDOW *win); -void win_mark_received(ProfWin *window, const char *const id); -void win_update_entry_message(ProfWin *window, const char *const id, const char *const message); +void win_sub_print(WINDOW* win, char* msg, gboolean newline, gboolean wrap, int indent); +void win_sub_newline_lazy(WINDOW* win); +void win_mark_received(ProfWin* window, const char* const id); +void win_update_entry_message(ProfWin* window, const char* const id, const char* const message); -gboolean win_has_active_subwin(ProfWin *window); +gboolean win_has_active_subwin(ProfWin* window); -void win_page_up(ProfWin *window); -void win_page_down(ProfWin *window); -void win_sub_page_down(ProfWin *window); -void win_sub_page_up(ProfWin *window); +void win_page_up(ProfWin* window); +void win_page_down(ProfWin* window); +void win_sub_page_down(ProfWin* window); +void win_sub_page_up(ProfWin* window); -void win_insert_last_read_position_marker(ProfWin *window, char* id); -void win_remove_entry_message(ProfWin *window, const char *const id); +void win_insert_last_read_position_marker(ProfWin* window, char* id); +void win_remove_entry_message(ProfWin* window, const char* const id); #endif diff --git a/src/ui/window_list.c b/src/ui/window_list.c index 3972fadb..bb59e64d 100644 --- a/src/ui/window_list.c +++ b/src/ui/window_list.c @@ -52,20 +52,20 @@ #include "xmpp/roster_list.h" #include "tools/http_upload.h" -static GHashTable *windows; +static GHashTable* windows; static int current; static Autocomplete wins_ac; static Autocomplete wins_close_ac; static int _wins_cmp_num(gconstpointer a, gconstpointer b); -static int _wins_get_next_available_num(GList *used); +static int _wins_get_next_available_num(GList* used); void wins_init(void) { windows = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)win_free); - ProfWin *console = win_create_console(); + ProfWin* console = win_create_console(); g_hash_table_insert(windows, GINT_TO_POINTER(1), console); current = 1; @@ -85,22 +85,22 @@ wins_get_console(void) } gboolean -wins_chat_exists(const char *const barejid) +wins_chat_exists(const char* const barejid) { - ProfChatWin *chatwin = wins_get_chat(barejid); + ProfChatWin* chatwin = wins_get_chat(barejid); return (chatwin != NULL); } ProfChatWin* -wins_get_chat(const char *const barejid) +wins_get_chat(const char* const barejid) { - GList *values = g_hash_table_get_values(windows); - GList *curr = values; + GList* values = g_hash_table_get_values(windows); + GList* curr = values; while (curr) { - ProfWin *window = curr->data; + ProfWin* window = curr->data; if (window->type == WIN_CHAT) { - ProfChatWin *chatwin = (ProfChatWin*)window; + ProfChatWin* chatwin = (ProfChatWin*)window; if (g_strcmp0(chatwin->barejid, barejid) == 0) { g_list_free(values); return chatwin; @@ -114,7 +114,7 @@ wins_get_chat(const char *const barejid) } static gint -_cmp_unsubscribed_wins(ProfChatWin *a, ProfChatWin *b) +_cmp_unsubscribed_wins(ProfChatWin* a, ProfChatWin* b) { return g_strcmp0(a->barejid, b->barejid); } @@ -122,14 +122,14 @@ _cmp_unsubscribed_wins(ProfChatWin *a, ProfChatWin *b) GList* wins_get_chat_unsubscribed(void) { - GList *result = NULL; - GList *values = g_hash_table_get_values(windows); - GList *curr = values; + GList* result = NULL; + GList* values = g_hash_table_get_values(windows); + GList* curr = values; while (curr) { - ProfWin *window = curr->data; + ProfWin* window = curr->data; if (window->type == WIN_CHAT) { - ProfChatWin *chatwin = (ProfChatWin*)window; + ProfChatWin* chatwin = (ProfChatWin*)window; PContact contact = roster_get_contact(chatwin->barejid); if (contact == NULL) { result = g_list_insert_sorted(result, chatwin, (GCompareFunc)_cmp_unsubscribed_wins); @@ -143,15 +143,15 @@ wins_get_chat_unsubscribed(void) } ProfConfWin* -wins_get_conf(const char *const roomjid) +wins_get_conf(const char* const roomjid) { - GList *values = g_hash_table_get_values(windows); - GList *curr = values; + GList* values = g_hash_table_get_values(windows); + GList* curr = values; while (curr) { - ProfWin *window = curr->data; + ProfWin* window = curr->data; if (window->type == WIN_CONFIG) { - ProfConfWin *confwin = (ProfConfWin*)window; + ProfConfWin* confwin = (ProfConfWin*)window; if (g_strcmp0(confwin->roomjid, roomjid) == 0) { g_list_free(values); return confwin; @@ -165,15 +165,15 @@ wins_get_conf(const char *const roomjid) } ProfMucWin* -wins_get_muc(const char *const roomjid) +wins_get_muc(const char* const roomjid) { - GList *values = g_hash_table_get_values(windows); - GList *curr = values; + GList* values = g_hash_table_get_values(windows); + GList* curr = values; while (curr) { - ProfWin *window = curr->data; + ProfWin* window = curr->data; if (window->type == WIN_MUC) { - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; if (g_strcmp0(mucwin->roomjid, roomjid) == 0) { g_list_free(values); return mucwin; @@ -187,15 +187,15 @@ wins_get_muc(const char *const roomjid) } ProfPrivateWin* -wins_get_private(const char *const fulljid) +wins_get_private(const char* const fulljid) { - GList *values = g_hash_table_get_values(windows); - GList *curr = values; + GList* values = g_hash_table_get_values(windows); + GList* curr = values; while (curr) { - ProfWin *window = curr->data; + ProfWin* window = curr->data; if (window->type == WIN_PRIVATE) { - ProfPrivateWin *privatewin = (ProfPrivateWin*)window; + ProfPrivateWin* privatewin = (ProfPrivateWin*)window; if (g_strcmp0(privatewin->fulljid, fulljid) == 0) { g_list_free(values); return privatewin; @@ -209,15 +209,15 @@ wins_get_private(const char *const fulljid) } ProfPluginWin* -wins_get_plugin(const char *const tag) +wins_get_plugin(const char* const tag) { - GList *values = g_hash_table_get_values(windows); - GList *curr = values; + GList* values = g_hash_table_get_values(windows); + GList* curr = values; while (curr) { - ProfWin *window = curr->data; + ProfWin* window = curr->data; if (window->type == WIN_PLUGIN) { - ProfPluginWin *pluginwin = (ProfPluginWin*)window; + ProfPluginWin* pluginwin = (ProfPluginWin*)window; if (g_strcmp0(pluginwin->tag, tag) == 0) { g_list_free(values); return pluginwin; @@ -231,9 +231,9 @@ wins_get_plugin(const char *const tag) } void -wins_close_plugin(char *tag) +wins_close_plugin(char* tag) { - ProfWin *toclose = wins_get_by_string(tag); + ProfWin* toclose = wins_get_by_string(tag); if (toclose == NULL) { return; } @@ -245,18 +245,18 @@ wins_close_plugin(char *tag) } GList* -wins_get_private_chats(const char *const roomjid) +wins_get_private_chats(const char* const roomjid) { - GList *result = NULL; - GString *prefix = g_string_new(roomjid); + GList* result = NULL; + GString* prefix = g_string_new(roomjid); g_string_append(prefix, "/"); - GList *values = g_hash_table_get_values(windows); - GList *curr = values; + GList* values = g_hash_table_get_values(windows); + GList* curr = values; while (curr) { - ProfWin *window = curr->data; + ProfWin* window = curr->data; if (window->type == WIN_PRIVATE) { - ProfPrivateWin *privatewin = (ProfPrivateWin*)window; + ProfPrivateWin* privatewin = (ProfPrivateWin*)window; if (roomjid == NULL || g_str_has_prefix(privatewin->fulljid, prefix->str)) { result = g_list_append(result, privatewin); } @@ -270,15 +270,15 @@ wins_get_private_chats(const char *const roomjid) } void -wins_private_nick_change(const char *const roomjid, const char *const oldnick, const char *const newnick) +wins_private_nick_change(const char* const roomjid, const char* const oldnick, const char* const newnick) { - Jid *oldjid = jid_create_from_bare_and_resource(roomjid, oldnick); + Jid* oldjid = jid_create_from_bare_and_resource(roomjid, oldnick); - ProfPrivateWin *privwin = wins_get_private(oldjid->fulljid); + ProfPrivateWin* privwin = wins_get_private(oldjid->fulljid); if (privwin) { free(privwin->fulljid); - Jid *newjid = jid_create_from_bare_and_resource(roomjid, newnick); + Jid* newjid = jid_create_from_bare_and_resource(roomjid, newnick); privwin->fulljid = strdup(newjid->fulljid); win_println((ProfWin*)privwin, THEME_THEM, "!", "** %s is now known as %s.", oldjid->resourcepart, newjid->resourcepart); @@ -294,9 +294,9 @@ wins_private_nick_change(const char *const roomjid, const char *const oldnick, c } void -wins_change_nick(const char *const barejid, const char *const oldnick, const char *const newnick) +wins_change_nick(const char* const barejid, const char* const oldnick, const char* const newnick) { - ProfChatWin *chatwin = wins_get_chat(barejid); + ProfChatWin* chatwin = wins_get_chat(barejid); if (chatwin) { if (oldnick) { autocomplete_remove(wins_ac, oldnick); @@ -308,9 +308,9 @@ wins_change_nick(const char *const barejid, const char *const oldnick, const cha } void -wins_remove_nick(const char *const barejid, const char *const oldnick) +wins_remove_nick(const char* const barejid, const char* const oldnick) { - ProfChatWin *chatwin = wins_get_chat(barejid); + ProfChatWin* chatwin = wins_get_chat(barejid); if (chatwin) { if (oldnick) { autocomplete_remove(wins_ac, oldnick); @@ -338,23 +338,23 @@ wins_get_nums(void) void wins_set_current_by_num(int i) { - ProfWin *window = g_hash_table_lookup(windows, GINT_TO_POINTER(i)); + ProfWin* window = g_hash_table_lookup(windows, GINT_TO_POINTER(i)); if (window) { current = i; if (window->type == WIN_CHAT) { - ProfChatWin *chatwin = (ProfChatWin*) window; + ProfChatWin* chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); chatwin->unread = 0; plugins_on_chat_win_focus(chatwin->barejid); } else if (window->type == WIN_MUC) { - ProfMucWin *mucwin = (ProfMucWin*) window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); mucwin->unread = 0; mucwin->unread_mentions = FALSE; mucwin->unread_triggers = FALSE; plugins_on_room_win_focus(mucwin->roomjid); } else if (window->type == WIN_PRIVATE) { - ProfPrivateWin *privatewin = (ProfPrivateWin*) window; + ProfPrivateWin* privatewin = (ProfPrivateWin*)window; privatewin->unread = 0; } } @@ -367,45 +367,45 @@ wins_get_by_num(int i) } ProfWin* -wins_get_by_string(const char *str) +wins_get_by_string(const char* str) { if (g_strcmp0(str, "console") == 0) { - ProfWin *conswin = wins_get_console(); + ProfWin* conswin = wins_get_console(); return conswin; } if (g_strcmp0(str, "xmlconsole") == 0) { - ProfXMLWin *xmlwin = wins_get_xmlconsole(); - return (ProfWin*)xmlwin; + ProfXMLWin* xmlwin = wins_get_xmlconsole(); + return (ProfWin*)xmlwin; } - ProfChatWin *chatwin = wins_get_chat(str); + ProfChatWin* chatwin = wins_get_chat(str); if (chatwin) { return (ProfWin*)chatwin; } jabber_conn_status_t conn_status = connection_get_status(); if (conn_status == JABBER_CONNECTED) { - char *barejid = roster_barejid_from_name(str); + char* barejid = roster_barejid_from_name(str); if (barejid) { - ProfChatWin *chatwin = wins_get_chat(barejid); + ProfChatWin* chatwin = wins_get_chat(barejid); if (chatwin) { return (ProfWin*)chatwin; } } } - ProfMucWin *mucwin = wins_get_muc(str); + ProfMucWin* mucwin = wins_get_muc(str); if (mucwin) { return (ProfWin*)mucwin; } - ProfPrivateWin *privwin = wins_get_private(str); + ProfPrivateWin* privwin = wins_get_private(str); if (privwin) { return (ProfWin*)privwin; } - ProfPluginWin *pluginwin = wins_get_plugin(str); + ProfPluginWin* pluginwin = wins_get_plugin(str); if (pluginwin) { return (ProfWin*)pluginwin; } @@ -417,9 +417,9 @@ ProfWin* wins_get_next(void) { // get and sort win nums - GList *keys = g_hash_table_get_keys(windows); + GList* keys = g_hash_table_get_keys(windows); keys = g_list_sort(keys, _wins_cmp_num); - GList *curr = keys; + GList* curr = keys; // find our place in the list while (curr) { @@ -435,7 +435,7 @@ wins_get_next(void) int next = GPOINTER_TO_INT(curr->data); g_list_free(keys); return wins_get_by_num(next); - // otherwise return the first window (console) + // otherwise return the first window (console) } else { g_list_free(keys); return wins_get_console(); @@ -446,9 +446,9 @@ ProfWin* wins_get_previous(void) { // get and sort win nums - GList *keys = g_hash_table_get_keys(windows); + GList* keys = g_hash_table_get_keys(windows); keys = g_list_sort(keys, _wins_cmp_num); - GList *curr = keys; + GList* curr = keys; // find our place in the list while (curr) { @@ -464,7 +464,7 @@ wins_get_previous(void) int previous = GPOINTER_TO_INT(curr->data); g_list_free(keys); return wins_get_by_num(previous); - // otherwise return the last window + // otherwise return the last window } else { int new_num = GPOINTER_TO_INT(g_list_last(keys)->data); g_list_free(keys); @@ -473,14 +473,14 @@ wins_get_previous(void) } int -wins_get_num(ProfWin *window) +wins_get_num(ProfWin* window) { - GList *keys = g_hash_table_get_keys(windows); - GList *curr = keys; + GList* keys = g_hash_table_get_keys(windows); + GList* curr = keys; while (curr) { gconstpointer num_p = curr->data; - ProfWin *curr_win = g_hash_table_lookup(windows, num_p); + ProfWin* curr_win = g_hash_table_lookup(windows, num_p); if (curr_win == window) { g_list_free(keys); return GPOINTER_TO_INT(num_p); @@ -507,11 +507,11 @@ wins_close_by_num(int i) // go to console if closing current window if (i == current) { current = 1; - ProfWin *window = wins_get_current(); + ProfWin* window = wins_get_current(); win_update_virtual(window); } - ProfWin *window = wins_get_by_num(i); + ProfWin* window = wins_get_by_num(i); if (window) { // cancel upload proccesses of this window http_upload_cancel_processes(window); @@ -519,7 +519,7 @@ wins_close_by_num(int i) switch (window->type) { case WIN_CHAT: { - ProfChatWin *chatwin = (ProfChatWin*)window; + ProfChatWin* chatwin = (ProfChatWin*)window; autocomplete_remove(wins_ac, chatwin->barejid); autocomplete_remove(wins_close_ac, chatwin->barejid); @@ -539,7 +539,7 @@ wins_close_by_num(int i) } case WIN_MUC: { - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; autocomplete_remove(wins_ac, mucwin->roomjid); autocomplete_remove(wins_close_ac, mucwin->roomjid); @@ -551,7 +551,7 @@ wins_close_by_num(int i) } case WIN_PRIVATE: { - ProfPrivateWin *privwin = (ProfPrivateWin*)window; + ProfPrivateWin* privwin = (ProfPrivateWin*)window; autocomplete_remove(wins_ac, privwin->fulljid); autocomplete_remove(wins_close_ac, privwin->fulljid); autocomplete_free(window->urls_ac); @@ -565,7 +565,7 @@ wins_close_by_num(int i) } case WIN_PLUGIN: { - ProfPluginWin *pluginwin = (ProfPluginWin*)window; + ProfPluginWin* pluginwin = (ProfPluginWin*)window; plugins_close_win(pluginwin->plugin_name, pluginwin->tag); autocomplete_remove(wins_ac, pluginwin->tag); autocomplete_remove(wins_close_ac, pluginwin->tag); @@ -583,9 +583,9 @@ wins_close_by_num(int i) } gboolean -wins_is_current(ProfWin *window) +wins_is_current(ProfWin* window) { - ProfWin *current_window = wins_get_current(); + ProfWin* current_window = wins_get_current(); if (current_window == window) { return TRUE; @@ -597,10 +597,10 @@ wins_is_current(ProfWin *window) ProfWin* wins_new_xmlconsole(void) { - GList *keys = g_hash_table_get_keys(windows); + GList* keys = g_hash_table_get_keys(windows); int result = _wins_get_next_available_num(keys); g_list_free(keys); - ProfWin *newwin = win_create_xmlconsole(); + ProfWin* newwin = win_create_xmlconsole(); g_hash_table_insert(windows, GINT_TO_POINTER(result), newwin); autocomplete_add(wins_ac, "xmlconsole"); autocomplete_add(wins_close_ac, "xmlconsole"); @@ -608,12 +608,12 @@ wins_new_xmlconsole(void) } ProfWin* -wins_new_chat(const char *const barejid) +wins_new_chat(const char* const barejid) { - GList *keys = g_hash_table_get_keys(windows); + GList* keys = g_hash_table_get_keys(windows); int result = _wins_get_next_available_num(keys); g_list_free(keys); - ProfWin *newwin = win_create_chat(barejid); + ProfWin* newwin = win_create_chat(barejid); g_hash_table_insert(windows, GINT_TO_POINTER(result), newwin); autocomplete_add(wins_ac, barejid); @@ -632,12 +632,12 @@ wins_new_chat(const char *const barejid) } ProfWin* -wins_new_muc(const char *const roomjid) +wins_new_muc(const char* const roomjid) { - GList *keys = g_hash_table_get_keys(windows); + GList* keys = g_hash_table_get_keys(windows); int result = _wins_get_next_available_num(keys); g_list_free(keys); - ProfWin *newwin = win_create_muc(roomjid); + ProfWin* newwin = win_create_muc(roomjid); g_hash_table_insert(windows, GINT_TO_POINTER(result), newwin); autocomplete_add(wins_ac, roomjid); autocomplete_add(wins_close_ac, roomjid); @@ -647,24 +647,24 @@ wins_new_muc(const char *const roomjid) } ProfWin* -wins_new_config(const char *const roomjid, DataForm *form, ProfConfWinCallback submit, ProfConfWinCallback cancel, const void *userdata) +wins_new_config(const char* const roomjid, DataForm* form, ProfConfWinCallback submit, ProfConfWinCallback cancel, const void* userdata) { - GList *keys = g_hash_table_get_keys(windows); + GList* keys = g_hash_table_get_keys(windows); int result = _wins_get_next_available_num(keys); g_list_free(keys); - ProfWin *newwin = win_create_config(roomjid, form, submit, cancel, userdata); + ProfWin* newwin = win_create_config(roomjid, form, submit, cancel, userdata); g_hash_table_insert(windows, GINT_TO_POINTER(result), newwin); return newwin; } ProfWin* -wins_new_private(const char *const fulljid) +wins_new_private(const char* const fulljid) { - GList *keys = g_hash_table_get_keys(windows); + GList* keys = g_hash_table_get_keys(windows); int result = _wins_get_next_available_num(keys); g_list_free(keys); - ProfWin *newwin = win_create_private(fulljid); + ProfWin* newwin = win_create_private(fulljid); g_hash_table_insert(windows, GINT_TO_POINTER(result), newwin); autocomplete_add(wins_ac, fulljid); autocomplete_add(wins_close_ac, fulljid); @@ -673,13 +673,13 @@ wins_new_private(const char *const fulljid) return newwin; } -ProfWin * -wins_new_plugin(const char *const plugin_name, const char * const tag) +ProfWin* +wins_new_plugin(const char* const plugin_name, const char* const tag) { - GList *keys = g_hash_table_get_keys(windows); + GList* keys = g_hash_table_get_keys(windows); int result = _wins_get_next_available_num(keys); g_list_free(keys); - ProfWin *newwin = win_create_plugin(plugin_name, tag); + ProfWin* newwin = win_create_plugin(plugin_name, tag); g_hash_table_insert(windows, GINT_TO_POINTER(result), newwin); autocomplete_add(wins_ac, tag); autocomplete_add(wins_close_ac, tag); @@ -689,11 +689,11 @@ wins_new_plugin(const char *const plugin_name, const char * const tag) gboolean wins_do_notify_remind(void) { - GList *values = g_hash_table_get_values(windows); - GList *curr = values; + GList* values = g_hash_table_get_values(windows); + GList* curr = values; while (curr) { - ProfWin *window = curr->data; + ProfWin* window = curr->data; if (win_notify_remind(window)) { g_list_free(values); return TRUE; @@ -708,11 +708,11 @@ int wins_get_total_unread(void) { int result = 0; - GList *values = g_hash_table_get_values(windows); - GList *curr = values; + GList* values = g_hash_table_get_values(windows); + GList* curr = values; while (curr) { - ProfWin *window = curr->data; + ProfWin* window = curr->data; result += win_unread(window); curr = g_list_next(curr); } @@ -723,30 +723,30 @@ wins_get_total_unread(void) void wins_resize_all(void) { - GList *values = g_hash_table_get_values(windows); - GList *curr = values; + GList* values = g_hash_table_get_values(windows); + GList* curr = values; while (curr) { - ProfWin *window = curr->data; + ProfWin* window = curr->data; win_resize(window); curr = g_list_next(curr); } g_list_free(values); - ProfWin *current_win = wins_get_current(); + ProfWin* current_win = wins_get_current(); win_update_virtual(current_win); } void -wins_hide_subwin(ProfWin *window) +wins_hide_subwin(ProfWin* window) { win_hide_subwin(window); - ProfWin *current_win = wins_get_current(); + ProfWin* current_win = wins_get_current(); win_refresh_without_subwin(current_win); } void -wins_show_subwin(ProfWin *window) +wins_show_subwin(ProfWin* window) { win_show_subwin(window); @@ -755,20 +755,20 @@ wins_show_subwin(ProfWin *window) return; } - ProfWin *current_win = wins_get_current(); + ProfWin* current_win = wins_get_current(); win_refresh_with_subwin(current_win); } ProfXMLWin* wins_get_xmlconsole(void) { - GList *values = g_hash_table_get_values(windows); - GList *curr = values; + GList* values = g_hash_table_get_values(windows); + GList* curr = values; while (curr) { - ProfWin *window = curr->data; + ProfWin* window = curr->data; if (window->type == WIN_XML) { - ProfXMLWin *xmlwin = (ProfXMLWin*)window; + ProfXMLWin* xmlwin = (ProfXMLWin*)window; assert(xmlwin->memcheck == PROFXMLWIN_MEMCHECK); g_list_free(values); return xmlwin; @@ -783,14 +783,14 @@ wins_get_xmlconsole(void) GSList* wins_get_chat_recipients(void) { - GSList *result = NULL; - GList *values = g_hash_table_get_values(windows); - GList *curr = values; + GSList* result = NULL; + GList* values = g_hash_table_get_values(windows); + GList* curr = values; while (curr) { - ProfWin *window = curr->data; + ProfWin* window = curr->data; if (window->type == WIN_CHAT) { - ProfChatWin *chatwin = (ProfChatWin*)window; + ProfChatWin* chatwin = (ProfChatWin*)window; result = g_slist_append(result, chatwin->barejid); } curr = g_list_next(curr); @@ -802,17 +802,13 @@ wins_get_chat_recipients(void) GSList* wins_get_prune_wins(void) { - GSList *result = NULL; - GList *values = g_hash_table_get_values(windows); - GList *curr = values; + GSList* result = NULL; + GList* values = g_hash_table_get_values(windows); + GList* curr = values; while (curr) { - ProfWin *window = curr->data; - if (win_unread(window) == 0 && - window->type != WIN_MUC && - window->type != WIN_CONFIG && - window->type != WIN_XML && - window->type != WIN_CONSOLE) { + ProfWin* window = curr->data; + if (win_unread(window) == 0 && window->type != WIN_MUC && window->type != WIN_CONFIG && window->type != WIN_XML && window->type != WIN_CONSOLE) { result = g_slist_append(result, window); } curr = g_list_next(curr); @@ -824,11 +820,11 @@ wins_get_prune_wins(void) void wins_lost_connection(void) { - GList *values = g_hash_table_get_values(windows); - GList *curr = values; + GList* values = g_hash_table_get_values(windows); + GList* curr = values; while (curr) { - ProfWin *window = curr->data; + ProfWin* window = curr->data; if (window->type != WIN_CONSOLE) { win_println(window, THEME_ERROR, "-", "Lost connection."); @@ -845,11 +841,11 @@ wins_lost_connection(void) void wins_reestablished_connection(void) { - GList *values = g_hash_table_get_values(windows); - GList *curr = values; + GList* values = g_hash_table_get_values(windows); + GList* curr = values; while (curr) { - ProfWin *window = curr->data; + ProfWin* window = curr->data; if (window->type != WIN_CONSOLE) { win_println(window, THEME_TEXT, "-", "Connection re-established."); @@ -866,18 +862,18 @@ wins_reestablished_connection(void) void wins_swap(int source_win, int target_win) { - ProfWin *source = g_hash_table_lookup(windows, GINT_TO_POINTER(source_win)); - ProfWin *console = wins_get_console(); + ProfWin* source = g_hash_table_lookup(windows, GINT_TO_POINTER(source_win)); + ProfWin* console = wins_get_console(); if (source) { - ProfWin *target = g_hash_table_lookup(windows, GINT_TO_POINTER(target_win)); + ProfWin* target = g_hash_table_lookup(windows, GINT_TO_POINTER(target_win)); // target window empty if (target == NULL) { g_hash_table_steal(windows, GINT_TO_POINTER(source_win)); g_hash_table_insert(windows, GINT_TO_POINTER(target_win), source); status_bar_inactive(source_win); - char *identifier = win_get_tab_identifier(source); + char* identifier = win_get_tab_identifier(source); if (win_unread(source) > 0) { status_bar_new(target_win, source->type, identifier); } else { @@ -889,14 +885,14 @@ wins_swap(int source_win, int target_win) ui_focus_win(console); } - // target window occupied + // target window occupied } else { g_hash_table_steal(windows, GINT_TO_POINTER(source_win)); g_hash_table_steal(windows, GINT_TO_POINTER(target_win)); g_hash_table_insert(windows, GINT_TO_POINTER(source_win), target); g_hash_table_insert(windows, GINT_TO_POINTER(target_win), source); - char *source_identifier = win_get_tab_identifier(source); - char *target_identifier = win_get_tab_identifier(target); + char* source_identifier = win_get_tab_identifier(source); + char* target_identifier = win_get_tab_identifier(target); if (win_unread(source) > 0) { status_bar_new(target_win, source->type, source_identifier); } else { @@ -940,14 +936,14 @@ _wins_cmp_num(gconstpointer a, gconstpointer b) } static int -_wins_get_next_available_num(GList *used) +_wins_get_next_available_num(GList* used) { // only console used if (g_list_length(used) == 1) { return 2; } else { - GList *sorted = NULL; - GList *curr = used; + GList* sorted = NULL; + GList* curr = used; while (curr) { sorted = g_list_insert_sorted(sorted, curr->data, _wins_cmp_num); curr = g_list_next(curr); @@ -961,8 +957,7 @@ _wins_get_next_available_num(GList *used) while (curr) { int curr_num = GPOINTER_TO_INT(curr->data); - if (((last_num != 9) && ((last_num + 1) != curr_num)) || - ((last_num == 9) && (curr_num != 0))) { + if (((last_num != 9) && ((last_num + 1) != curr_num)) || ((last_num == 9) && (curr_num != 0))) { result = last_num + 1; if (result == 10) { result = 0; @@ -993,11 +988,11 @@ wins_tidy(void) { gboolean tidy_required = FALSE; // check for gaps - GList *keys = g_hash_table_get_keys(windows); + GList* keys = g_hash_table_get_keys(windows); keys = g_list_sort(keys, _wins_cmp_num); // get last used - GList *last = g_list_last(keys); + GList* last = g_list_last(keys); int last_num = GPOINTER_TO_INT(last->data); // find first free num TODO - Will sort again @@ -1010,14 +1005,14 @@ wins_tidy(void) if (tidy_required) { status_bar_set_all_inactive(); - GHashTable *new_windows = g_hash_table_new_full(g_direct_hash, - g_direct_equal, NULL, (GDestroyNotify)win_free); + GHashTable* new_windows = g_hash_table_new_full(g_direct_hash, + g_direct_equal, NULL, (GDestroyNotify)win_free); int num = 1; - GList *curr = keys; + GList* curr = keys; while (curr) { - ProfWin *window = g_hash_table_lookup(windows, curr->data); - char *identifier = win_get_tab_identifier(window); + ProfWin* window = g_hash_table_lookup(windows, curr->data); + char* identifier = win_get_tab_identifier(window); g_hash_table_steal(windows, curr->data); if (num == 10) { g_hash_table_insert(new_windows, GINT_TO_POINTER(0), window); @@ -1042,7 +1037,7 @@ wins_tidy(void) g_hash_table_destroy(windows); windows = new_windows; current = 1; - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); ui_focus_win(console); g_list_free(keys); return TRUE; @@ -1059,19 +1054,19 @@ wins_create_summary(gboolean unread) return NULL; } - GSList *result = NULL; + GSList* result = NULL; - GList *keys = g_hash_table_get_keys(windows); + GList* keys = g_hash_table_get_keys(windows); keys = g_list_sort(keys, _wins_cmp_num); - GList *curr = keys; + GList* curr = keys; while (curr) { - ProfWin *window = g_hash_table_lookup(windows, curr->data); + ProfWin* window = g_hash_table_lookup(windows, curr->data); if (!unread || (unread && win_unread(window) > 0)) { - GString *line = g_string_new(""); + GString* line = g_string_new(""); int ui_index = GPOINTER_TO_INT(curr->data); - char *winstring = win_to_string(window); + char* winstring = win_to_string(window); if (!winstring) { g_string_free(line, TRUE); continue; @@ -1093,13 +1088,13 @@ wins_create_summary(gboolean unread) } char* -win_autocomplete(const char *const search_str, gboolean previous, void *context) +win_autocomplete(const char* const search_str, gboolean previous, void* context) { return autocomplete_complete(wins_ac, search_str, TRUE, previous); } char* -win_close_autocomplete(const char *const search_str, gboolean previous, void *context) +win_close_autocomplete(const char* const search_str, gboolean previous, void* context) { return autocomplete_complete(wins_close_ac, search_str, TRUE, previous); } @@ -1128,16 +1123,16 @@ ProfWin* wins_get_next_unread(void) { // get and sort win nums - GList *values = g_hash_table_get_values(windows); + GList* values = g_hash_table_get_values(windows); values = g_list_sort(values, _wins_cmp_num); - GList *curr = values; + GList* curr = values; while (curr) { if (current == GPOINTER_TO_INT(curr->data)) { break; } - ProfWin *window = curr->data; + ProfWin* window = curr->data; if (win_unread(window) > 0) { g_list_free(values); return window; @@ -1151,34 +1146,33 @@ wins_get_next_unread(void) } void -wins_add_urls_ac(const ProfWin *const win, const ProfMessage *const message) +wins_add_urls_ac(const ProfWin* const win, const ProfMessage* const message) { - GRegex *regex; - GMatchInfo *match_info; + GRegex* regex; + GMatchInfo* match_info; regex = g_regex_new("(https?|aesgcm)://\\S+", 0, 0, NULL); - g_regex_match (regex, message->plain, 0, &match_info); + g_regex_match(regex, message->plain, 0, &match_info); - while (g_match_info_matches (match_info)) - { - gchar *word = g_match_info_fetch (match_info, 0); + while (g_match_info_matches(match_info)) { + gchar* word = g_match_info_fetch(match_info, 0); autocomplete_add_reverse(win->urls_ac, word); // for people who run profanity a long time, we don't want to waste a lot of memory autocomplete_remove_older_than_max_reverse(win->urls_ac, 20); - g_free (word); - g_match_info_next (match_info, NULL); + g_free(word); + g_match_info_next(match_info, NULL); } - g_match_info_free (match_info); - g_regex_unref (regex); + g_match_info_free(match_info); + g_regex_unref(regex); } char* -wins_get_url(const char *const search_str, gboolean previous, void *context) +wins_get_url(const char* const search_str, gboolean previous, void* context) { - ProfWin *win = (ProfWin*)context; + ProfWin* win = (ProfWin*)context; return autocomplete_complete(win->urls_ac, search_str, FALSE, previous); } diff --git a/src/ui/window_list.h b/src/ui/window_list.h index 6547354d..e02358f9 100644 --- a/src/ui/window_list.h +++ b/src/ui/window_list.h @@ -41,43 +41,43 @@ void wins_init(void); ProfWin* wins_new_xmlconsole(void); -ProfWin* wins_new_chat(const char *const barejid); -ProfWin* wins_new_muc(const char *const roomjid); -ProfWin* wins_new_config(const char *const roomjid, DataForm *form, ProfConfWinCallback submit, ProfConfWinCallback cancel, const void *userdata); -ProfWin* wins_new_private(const char *const fulljid); -ProfWin* wins_new_plugin(const char *const plugin_name, const char *const tag); +ProfWin* wins_new_chat(const char* const barejid); +ProfWin* wins_new_muc(const char* const roomjid); +ProfWin* wins_new_config(const char* const roomjid, DataForm* form, ProfConfWinCallback submit, ProfConfWinCallback cancel, const void* userdata); +ProfWin* wins_new_private(const char* const fulljid); +ProfWin* wins_new_plugin(const char* const plugin_name, const char* const tag); -gboolean wins_chat_exists(const char *const barejid); -GList* wins_get_private_chats(const char *const roomjid); -void wins_private_nick_change(const char *const roomjid, const char *const oldnick, const char *const newnick); -void wins_change_nick(const char *const barejid, const char *const oldnick, const char *const newnick); -void wins_remove_nick(const char *const barejid, const char *const oldnick); +gboolean wins_chat_exists(const char* const barejid); +GList* wins_get_private_chats(const char* const roomjid); +void wins_private_nick_change(const char* const roomjid, const char* const oldnick, const char* const newnick); +void wins_change_nick(const char* const barejid, const char* const oldnick, const char* const newnick); +void wins_remove_nick(const char* const barejid, const char* const oldnick); ProfWin* wins_get_console(void); -ProfChatWin* wins_get_chat(const char *const barejid); +ProfChatWin* wins_get_chat(const char* const barejid); GList* wins_get_chat_unsubscribed(void); -ProfMucWin* wins_get_muc(const char *const roomjid); -ProfConfWin* wins_get_conf(const char *const roomjid); -ProfPrivateWin* wins_get_private(const char *const fulljid); -ProfPluginWin* wins_get_plugin(const char *const tag); +ProfMucWin* wins_get_muc(const char* const roomjid); +ProfConfWin* wins_get_conf(const char* const roomjid); +ProfPrivateWin* wins_get_private(const char* const fulljid); +ProfPluginWin* wins_get_plugin(const char* const tag); ProfXMLWin* wins_get_xmlconsole(void); -void wins_close_plugin(char *tag); +void wins_close_plugin(char* tag); ProfWin* wins_get_current(void); void wins_set_current_by_num(int i); ProfWin* wins_get_by_num(int i); -ProfWin* wins_get_by_string(const char *str); +ProfWin* wins_get_by_string(const char* str); ProfWin* wins_get_next(void); ProfWin* wins_get_previous(void); ProfWin* wins_get_next_unread(void); -int wins_get_num(ProfWin *window); +int wins_get_num(ProfWin* window); int wins_get_current_num(void); void wins_close_by_num(int i); -gboolean wins_is_current(ProfWin *window); +gboolean wins_is_current(ProfWin* window); gboolean wins_do_notify_remind(void); int wins_get_total_unread(void); void wins_resize_all(void); @@ -90,15 +90,15 @@ GSList* wins_create_summary(gboolean unread); void wins_destroy(void); GList* wins_get_nums(void); void wins_swap(int source_win, int target_win); -void wins_hide_subwin(ProfWin *window); -void wins_show_subwin(ProfWin *window); +void wins_hide_subwin(ProfWin* window); +void wins_show_subwin(ProfWin* window); -char* win_autocomplete(const char *const search_str, gboolean previous, void *context); +char* win_autocomplete(const char* const search_str, gboolean previous, void* context); void win_reset_search_attempts(void); -char* win_close_autocomplete(const char *const search_str, gboolean previous, void *context); +char* win_close_autocomplete(const char* const search_str, gboolean previous, void* context); void win_close_reset_search_attempts(void); -void wins_add_urls_ac(const ProfWin *const win, const ProfMessage *const message); -char* wins_get_url(const char *const search_str, gboolean previous, void *context); +void wins_add_urls_ac(const ProfWin* const win, const ProfMessage* const message); +char* wins_get_url(const char* const search_str, gboolean previous, void* context); #endif diff --git a/src/ui/xmlwin.c b/src/ui/xmlwin.c index b6a085ef..cee8f21a 100644 --- a/src/ui/xmlwin.c +++ b/src/ui/xmlwin.c @@ -40,11 +40,11 @@ #include "ui/window_list.h" void -xmlwin_show(ProfXMLWin *xmlwin, const char *const msg) +xmlwin_show(ProfXMLWin* xmlwin, const char* const msg) { assert(xmlwin != NULL); - ProfWin *window = (ProfWin*)xmlwin; + ProfWin* window = (ProfWin*)xmlwin; if (g_str_has_prefix(msg, "SENT:")) { win_println(window, THEME_DEFAULT, "-", "SENT:"); win_println(window, THEME_ONLINE, "-", "%s", &msg[6]); @@ -57,7 +57,7 @@ xmlwin_show(ProfXMLWin *xmlwin, const char *const msg) } char* -xmlwin_get_string(ProfXMLWin *xmlwin) +xmlwin_get_string(ProfXMLWin* xmlwin) { assert(xmlwin != NULL); diff --git a/src/xmpp/avatar.c b/src/xmpp/avatar.c index c5b44411..97bd9e67 100644 --- a/src/xmpp/avatar.c +++ b/src/xmpp/avatar.c @@ -50,20 +50,21 @@ #include "config/files.h" #include "config/preferences.h" -typedef struct avatar_metadata { - char *type; - char *id; +typedef struct avatar_metadata +{ + char* type; + char* id; } avatar_metadata; -static GHashTable *looking_for = NULL; // contains nicks/barejids from who we want to get the avatar -static GHashTable *shall_open = NULL; // contains a list of nicks that shall not just downloaded but also opened +static GHashTable* looking_for = NULL; // contains nicks/barejids from who we want to get the avatar +static GHashTable* shall_open = NULL; // contains a list of nicks that shall not just downloaded but also opened -static void _avatar_request_item_by_id(const char *jid, avatar_metadata *data); -static int _avatar_metadata_handler(xmpp_stanza_t *const stanza, void *const userdata); -static int _avatar_request_item_result_handler(xmpp_stanza_t *const stanza, void *const userdata); +static void _avatar_request_item_by_id(const char* jid, avatar_metadata* data); +static int _avatar_metadata_handler(xmpp_stanza_t* const stanza, void* const userdata); +static int _avatar_request_item_result_handler(xmpp_stanza_t* const stanza, void* const userdata); static void -_free_avatar_data(avatar_metadata *data) +_free_avatar_data(avatar_metadata* data) { if (data) { free(data->type); @@ -110,21 +111,21 @@ avatar_get_by_nick(const char* nick, gboolean open) } static int -_avatar_metadata_handler(xmpp_stanza_t *const stanza, void *const userdata) +_avatar_metadata_handler(xmpp_stanza_t* const stanza, void* const userdata) { - const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); + const char* from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); if (!g_hash_table_contains(looking_for, from)) { return 1; } - xmpp_stanza_t *root = NULL; - xmpp_stanza_t *event = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB_EVENT); + xmpp_stanza_t* root = NULL; + xmpp_stanza_t* event = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB_EVENT); if (event) { root = event; } - xmpp_stanza_t *pubsub = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB); + xmpp_stanza_t* pubsub = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB); if (pubsub) { root = pubsub; } @@ -133,25 +134,25 @@ _avatar_metadata_handler(xmpp_stanza_t *const stanza, void *const userdata) return 1; } - xmpp_stanza_t *items = xmpp_stanza_get_child_by_name(root, "items"); + xmpp_stanza_t* items = xmpp_stanza_get_child_by_name(root, "items"); if (!items) { return 1; } - xmpp_stanza_t *item = xmpp_stanza_get_child_by_name(items, "item"); + xmpp_stanza_t* item = xmpp_stanza_get_child_by_name(items, "item"); if (item) { - xmpp_stanza_t *metadata = xmpp_stanza_get_child_by_name(item, "metadata"); + xmpp_stanza_t* metadata = xmpp_stanza_get_child_by_name(item, "metadata"); if (!metadata) return 1; - xmpp_stanza_t *info = xmpp_stanza_get_child_by_name(metadata, "info"); + xmpp_stanza_t* info = xmpp_stanza_get_child_by_name(metadata, "info"); - const char *id = xmpp_stanza_get_id(info); - const char *type = xmpp_stanza_get_attribute(info, "type"); + const char* id = xmpp_stanza_get_id(info); + const char* type = xmpp_stanza_get_attribute(info, "type"); log_debug("Avatar ID for %s is: %s", from, id); - avatar_metadata *data = malloc(sizeof(avatar_metadata)); + avatar_metadata* data = malloc(sizeof(avatar_metadata)); data->type = strdup(type); data->id = strdup(id); @@ -163,15 +164,15 @@ _avatar_metadata_handler(xmpp_stanza_t *const stanza, void *const userdata) } static void -_avatar_request_item_by_id(const char *jid, avatar_metadata *data) +_avatar_request_item_by_id(const char* jid, avatar_metadata* data) { caps_remove_feature(XMPP_FEATURE_USER_AVATAR_METADATA_NOTIFY); - xmpp_ctx_t * const ctx = connection_get_ctx(); + xmpp_ctx_t* const ctx = connection_get_ctx(); - char *uid = connection_create_stanza_id(); + char* uid = connection_create_stanza_id(); - xmpp_stanza_t *iq = stanza_create_avatar_retrieve_data_request(ctx, uid, data->id, jid); + xmpp_stanza_t* iq = stanza_create_avatar_retrieve_data_request(ctx, uid, data->id, jid); iq_id_handler_add(uid, _avatar_request_item_result_handler, (ProfIqFreeCallback)_free_avatar_data, data); free(uid); @@ -181,9 +182,9 @@ _avatar_request_item_by_id(const char *jid, avatar_metadata *data) } static int -_avatar_request_item_result_handler(xmpp_stanza_t *const stanza, void *const userdata) +_avatar_request_item_result_handler(xmpp_stanza_t* const stanza, void* const userdata) { - const char *from_attr = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); + const char* from_attr = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); if (!from_attr) { return 1; @@ -194,33 +195,33 @@ _avatar_request_item_result_handler(xmpp_stanza_t *const stanza, void *const use } g_hash_table_remove(looking_for, from_attr); - xmpp_stanza_t *pubsub = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB); + xmpp_stanza_t* pubsub = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB); if (!pubsub) { return 1; } - xmpp_stanza_t *items = xmpp_stanza_get_child_by_name(pubsub, "items"); + xmpp_stanza_t* items = xmpp_stanza_get_child_by_name(pubsub, "items"); if (!items) { return 1; } - xmpp_stanza_t *item = xmpp_stanza_get_child_by_name(items, "item"); + xmpp_stanza_t* item = xmpp_stanza_get_child_by_name(items, "item"); if (!item) { return 1; } - xmpp_stanza_t *st_data = stanza_get_child_by_name_and_ns(item, "data", STANZA_NS_USER_AVATAR_DATA); + xmpp_stanza_t* st_data = stanza_get_child_by_name_and_ns(item, "data", STANZA_NS_USER_AVATAR_DATA); if (!st_data) { return 1; } - char *buf = xmpp_stanza_get_text(st_data); + char* buf = xmpp_stanza_get_text(st_data); gsize size; - gchar *de = (gchar*)g_base64_decode(buf, &size); + gchar* de = (gchar*)g_base64_decode(buf, &size); free(buf); - char *path = files_get_data_path(""); - GString *filename = g_string_new(path); + char* path = files_get_data_path(""); + GString* filename = g_string_new(path); free(path); g_string_append(filename, "avatars/"); @@ -228,7 +229,7 @@ _avatar_request_item_result_handler(xmpp_stanza_t *const stanza, void *const use errno = 0; int res = g_mkdir_with_parents(filename->str, S_IRWXU); if (res == -1) { - char *errmsg = strerror(errno); + char* errmsg = strerror(errno); if (errmsg) { log_error("Avatar: error creating directory: %s, %s", filename->str, errmsg); } else { @@ -236,10 +237,10 @@ _avatar_request_item_result_handler(xmpp_stanza_t *const stanza, void *const use } } - gchar *from = str_replace(from_attr, "@", "_at_"); + gchar* from = str_replace(from_attr, "@", "_at_"); g_string_append(filename, from); - avatar_metadata *data = (avatar_metadata*)userdata; + avatar_metadata* data = (avatar_metadata*)userdata; // check a few image types ourselves // if none matches we won't add an extension but linux will @@ -255,8 +256,8 @@ _avatar_request_item_result_handler(xmpp_stanza_t *const stanza, void *const use free(from); - GError *err = NULL; - if (g_file_set_contents (filename->str, de, size, &err) == FALSE) { + GError* err = NULL; + if (g_file_set_contents(filename->str, de, size, &err) == FALSE) { log_error("Unable to save picture: %s", err->message); cons_show("Unable to save picture %s", err->message); g_error_free(err); @@ -266,9 +267,9 @@ _avatar_request_item_result_handler(xmpp_stanza_t *const stanza, void *const use // if we shall open it if (g_hash_table_contains(shall_open, from_attr)) { - gchar *argv[] = {prefs_get_string(PREF_AVATAR_CMD), filename->str, NULL}; + gchar* argv[] = { prefs_get_string(PREF_AVATAR_CMD), filename->str, NULL }; if (!call_external(argv, NULL, NULL)) { - cons_show_error("Unable to display avatar: check the logs for more information."); + cons_show_error("Unable to display avatar: check the logs for more information."); } g_hash_table_remove(shall_open, from_attr); } diff --git a/src/xmpp/blocking.c b/src/xmpp/blocking.c index 302471a6..036e2582 100644 --- a/src/xmpp/blocking.c +++ b/src/xmpp/blocking.c @@ -54,11 +54,11 @@ #include "xmpp/stanza.h" #include "xmpp/iq.h" -static int _blocklist_result_handler(xmpp_stanza_t *const stanza, void *const userdata); -static int _block_add_result_handler(xmpp_stanza_t *const stanza, void *const userdata); -static int _block_remove_result_handler(xmpp_stanza_t *const stanza, void *const userdata); +static int _blocklist_result_handler(xmpp_stanza_t* const stanza, void* const userdata); +static int _block_add_result_handler(xmpp_stanza_t* const stanza, void* const userdata); +static int _block_remove_result_handler(xmpp_stanza_t* const stanza, void* const userdata); -static GList *blocked; +static GList* blocked; static Autocomplete blocked_ac; void @@ -74,11 +74,11 @@ blocking_request(void) } blocked_ac = autocomplete_new(); - char *id = connection_create_stanza_id(); + char* id = connection_create_stanza_id(); iq_id_handler_add(id, _blocklist_result_handler, NULL, NULL); - xmpp_ctx_t *ctx = connection_get_ctx(); - xmpp_stanza_t *iq = stanza_create_blocked_list_request(ctx); + xmpp_ctx_t* ctx = connection_get_ctx(); + xmpp_stanza_t* iq = stanza_create_blocked_list_request(ctx); xmpp_stanza_set_id(iq, id); free(id); @@ -93,7 +93,7 @@ blocked_list(void) } char* -blocked_ac_find(const char *const search_str, gboolean previous, void *context) +blocked_ac_find(const char* const search_str, gboolean previous, void* context) { return autocomplete_complete(blocked_ac, search_str, TRUE, previous); } @@ -107,23 +107,23 @@ blocked_ac_reset(void) } gboolean -blocked_add(char *jid) +blocked_add(char* jid) { - GList *found = g_list_find_custom(blocked, jid, (GCompareFunc)g_strcmp0); + GList* found = g_list_find_custom(blocked, jid, (GCompareFunc)g_strcmp0); if (found) { return FALSE; } - xmpp_ctx_t *ctx = connection_get_ctx(); + xmpp_ctx_t* ctx = connection_get_ctx(); - char *id = connection_create_stanza_id(); - xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); + char* id = connection_create_stanza_id(); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); - xmpp_stanza_t *block = xmpp_stanza_new(ctx); + xmpp_stanza_t* block = xmpp_stanza_new(ctx); xmpp_stanza_set_name(block, STANZA_NAME_BLOCK); xmpp_stanza_set_ns(block, STANZA_NS_BLOCKING); - xmpp_stanza_t *item = xmpp_stanza_new(ctx); + xmpp_stanza_t* item = xmpp_stanza_new(ctx); xmpp_stanza_set_name(item, STANZA_NAME_ITEM); xmpp_stanza_set_attribute(item, STANZA_ATTR_JID, jid); @@ -143,23 +143,23 @@ blocked_add(char *jid) } gboolean -blocked_remove(char *jid) +blocked_remove(char* jid) { - GList *found = g_list_find_custom(blocked, jid, (GCompareFunc)g_strcmp0); + GList* found = g_list_find_custom(blocked, jid, (GCompareFunc)g_strcmp0); if (!found) { return FALSE; } - xmpp_ctx_t *ctx = connection_get_ctx(); + xmpp_ctx_t* ctx = connection_get_ctx(); - char *id = connection_create_stanza_id(); - xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); + char* id = connection_create_stanza_id(); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); - xmpp_stanza_t *block = xmpp_stanza_new(ctx); + xmpp_stanza_t* block = xmpp_stanza_new(ctx); xmpp_stanza_set_name(block, STANZA_NAME_UNBLOCK); xmpp_stanza_set_ns(block, STANZA_NS_BLOCKING); - xmpp_stanza_t *item = xmpp_stanza_new(ctx); + xmpp_stanza_t* item = xmpp_stanza_new(ctx); xmpp_stanza_set_name(item, STANZA_NAME_ITEM); xmpp_stanza_set_attribute(item, STANZA_ATTR_JID, jid); @@ -179,28 +179,27 @@ blocked_remove(char *jid) } int -blocked_set_handler(xmpp_stanza_t *stanza) +blocked_set_handler(xmpp_stanza_t* stanza) { - xmpp_stanza_t *block = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BLOCK); + xmpp_stanza_t* block = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BLOCK); if (block) { - xmpp_stanza_t *child = xmpp_stanza_get_children(block); + xmpp_stanza_t* child = xmpp_stanza_get_children(block); while (child) { if (g_strcmp0(xmpp_stanza_get_name(child), STANZA_NAME_ITEM) == 0) { - const char *jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID); + const char* jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID); if (jid) { blocked = g_list_append(blocked, strdup(jid)); autocomplete_add(blocked_ac, jid); } - } child = xmpp_stanza_get_next(child); } } - xmpp_stanza_t *unblock = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_UNBLOCK); + xmpp_stanza_t* unblock = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_UNBLOCK); if (unblock) { - xmpp_stanza_t *child = xmpp_stanza_get_children(unblock); + xmpp_stanza_t* child = xmpp_stanza_get_children(unblock); if (!child) { g_list_free_full(blocked, free); blocked = NULL; @@ -208,16 +207,15 @@ blocked_set_handler(xmpp_stanza_t *stanza) } else { while (child) { if (g_strcmp0(xmpp_stanza_get_name(child), STANZA_NAME_ITEM) == 0) { - const char *jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID); + const char* jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID); if (jid) { - GList *found = g_list_find_custom(blocked, jid, (GCompareFunc)g_strcmp0); + GList* found = g_list_find_custom(blocked, jid, (GCompareFunc)g_strcmp0); if (found) { blocked = g_list_remove_link(blocked, found); g_list_free_full(found, free); autocomplete_remove(blocked_ac, jid); } } - } child = xmpp_stanza_get_next(child); @@ -229,11 +227,11 @@ blocked_set_handler(xmpp_stanza_t *stanza) } static int -_block_add_result_handler(xmpp_stanza_t *const stanza, void *const userdata) +_block_add_result_handler(xmpp_stanza_t* const stanza, void* const userdata) { - char *jid = (char*)userdata; + char* jid = (char*)userdata; - const char *type = xmpp_stanza_get_type(stanza); + const char* type = xmpp_stanza_get_type(stanza); if (!type) { log_info("Block response received for %s with no type attribute.", jid); return 0; @@ -250,11 +248,11 @@ _block_add_result_handler(xmpp_stanza_t *const stanza, void *const userdata) } static int -_block_remove_result_handler(xmpp_stanza_t *const stanza, void *const userdata) +_block_remove_result_handler(xmpp_stanza_t* const stanza, void* const userdata) { - char *jid = (char*)userdata; + char* jid = (char*)userdata; - const char *type = xmpp_stanza_get_type(stanza); + const char* type = xmpp_stanza_get_type(stanza); if (!type) { log_info("Unblock response received for %s with no type attribute.", jid); return 0; @@ -271,17 +269,17 @@ _block_remove_result_handler(xmpp_stanza_t *const stanza, void *const userdata) } static int -_blocklist_result_handler(xmpp_stanza_t *const stanza, void *const userdata) +_blocklist_result_handler(xmpp_stanza_t* const stanza, void* const userdata) { log_debug("Blocked list result handler fired."); - const char *type = xmpp_stanza_get_type(stanza); + const char* type = xmpp_stanza_get_type(stanza); if (g_strcmp0(type, "result") != 0) { log_info("Received blocklist without result type"); return 0; } - xmpp_stanza_t *blocklist = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BLOCKLIST); + xmpp_stanza_t* blocklist = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BLOCKLIST); if (!blocklist) { log_info("Received blocklist without blocklist element"); return 0; @@ -292,17 +290,17 @@ _blocklist_result_handler(xmpp_stanza_t *const stanza, void *const userdata) blocked = NULL; } - xmpp_stanza_t *items = xmpp_stanza_get_children(blocklist); + xmpp_stanza_t* items = xmpp_stanza_get_children(blocklist); if (!items) { log_debug("No blocked users."); return 0; } - xmpp_stanza_t *curr = items; + xmpp_stanza_t* curr = items; while (curr) { - const char *name = xmpp_stanza_get_name(curr); + const char* name = xmpp_stanza_get_name(curr); if (g_strcmp0(name, "item") == 0) { - const char *jid = xmpp_stanza_get_attribute(curr, STANZA_ATTR_JID); + const char* jid = xmpp_stanza_get_attribute(curr, STANZA_ATTR_JID); if (jid) { blocked = g_list_append(blocked, strdup(jid)); autocomplete_add(blocked_ac, jid); diff --git a/src/xmpp/blocking.h b/src/xmpp/blocking.h index ee4eecae..ff09f21b 100644 --- a/src/xmpp/blocking.h +++ b/src/xmpp/blocking.h @@ -37,6 +37,6 @@ #define XMPP_BLOCKING_H void blocking_request(void); -int blocked_set_handler(xmpp_stanza_t *stanza); +int blocked_set_handler(xmpp_stanza_t* stanza); #endif diff --git a/src/xmpp/bookmark.c b/src/xmpp/bookmark.c index a28b6107..a866354e 100644 --- a/src/xmpp/bookmark.c +++ b/src/xmpp/bookmark.c @@ -64,12 +64,12 @@ #define BOOKMARK_TIMEOUT 5000 static Autocomplete bookmark_ac; -static GHashTable *bookmarks; +static GHashTable* bookmarks; // id handlers -static int _bookmark_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata); +static int _bookmark_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata); -static void _bookmark_destroy(Bookmark *bookmark); +static void _bookmark_destroy(Bookmark* bookmark); static void _send_bookmarks(void); void @@ -83,11 +83,11 @@ bookmark_request(void) autocomplete_free(bookmark_ac); bookmark_ac = autocomplete_new(); - char *id = "bookmark_init_request"; + char* id = "bookmark_init_request"; iq_id_handler_add(id, _bookmark_result_id_handler, free, NULL); - xmpp_ctx_t *ctx = connection_get_ctx(); - xmpp_stanza_t *iq = stanza_create_bookmarks_storage_request(ctx); + xmpp_ctx_t* ctx = connection_get_ctx(); + xmpp_stanza_t* iq = stanza_create_bookmarks_storage_request(ctx); xmpp_stanza_set_id(iq, id); iq_send_stanza(iq); @@ -95,11 +95,11 @@ bookmark_request(void) } gboolean -bookmark_add(const char *jid, const char *nick, const char *password, const char *autojoin_str, const char *name) +bookmark_add(const char* jid, const char* nick, const char* password, const char* autojoin_str, const char* name) { assert(jid != NULL); - Jid *jidp = jid_create(jid); + Jid* jidp = jid_create(jid); if (jidp->domainpart) { muc_confserver_add(jidp->domainpart); } @@ -109,7 +109,7 @@ bookmark_add(const char *jid, const char *nick, const char *password, const char return FALSE; } - Bookmark *bookmark = malloc(sizeof(Bookmark)); + Bookmark* bookmark = malloc(sizeof(Bookmark)); bookmark->barejid = strdup(jid); if (nick) { bookmark->nick = strdup(nick); @@ -142,11 +142,11 @@ bookmark_add(const char *jid, const char *nick, const char *password, const char } gboolean -bookmark_update(const char *jid, const char *nick, const char *password, const char *autojoin_str, const char *name) +bookmark_update(const char* jid, const char* nick, const char* password, const char* autojoin_str, const char* name) { assert(jid != NULL); - Bookmark *bookmark = g_hash_table_lookup(bookmarks, jid); + Bookmark* bookmark = g_hash_table_lookup(bookmarks, jid); if (!bookmark) { return FALSE; } @@ -176,19 +176,19 @@ bookmark_update(const char *jid, const char *nick, const char *password, const c } gboolean -bookmark_join(const char *jid) +bookmark_join(const char* jid) { assert(jid != NULL); - Bookmark *bookmark = g_hash_table_lookup(bookmarks, jid); + Bookmark* bookmark = g_hash_table_lookup(bookmarks, jid); if (!bookmark) { return FALSE; } - char *account_name = session_get_account_name(); - ProfAccount *account = accounts_get_account(account_name); + char* account_name = session_get_account_name(); + ProfAccount* account = accounts_get_account(account_name); if (!muc_active(bookmark->barejid)) { - char *nick = bookmark->nick; + char* nick = bookmark->nick; if (!nick) { nick = account->muc_nick; } @@ -207,11 +207,11 @@ bookmark_join(const char *jid) } gboolean -bookmark_remove(const char *jid) +bookmark_remove(const char* jid) { assert(jid != NULL); - Bookmark *bookmark = g_hash_table_lookup(bookmarks, jid); + Bookmark* bookmark = g_hash_table_lookup(bookmarks, jid); if (!bookmark) { return FALSE; } @@ -231,7 +231,7 @@ bookmark_get_list(void) } char* -bookmark_find(const char *const search_str, gboolean previous, void *context) +bookmark_find(const char* const search_str, gboolean previous, void* context) { return autocomplete_complete(bookmark_ac, search_str, TRUE, previous); } @@ -245,24 +245,24 @@ bookmark_autocomplete_reset(void) } gboolean -bookmark_exists(const char *const room) +bookmark_exists(const char* const room) { return g_hash_table_contains(bookmarks, room); } static int -_bookmark_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata) +_bookmark_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata) { - const char *name = xmpp_stanza_get_name(stanza); + const char* name = xmpp_stanza_get_name(stanza); if (!name || strcmp(name, STANZA_NAME_IQ) != 0) { return 0; } - xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); + xmpp_stanza_t* query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); if (!query) { return 0; } - xmpp_stanza_t *storage = xmpp_stanza_get_child_by_name(query, STANZA_NAME_STORAGE); + xmpp_stanza_t* storage = xmpp_stanza_get_child_by_name(query, STANZA_NAME_STORAGE); if (!storage) { return 0; } @@ -271,14 +271,14 @@ _bookmark_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata) bookmark_ac = autocomplete_new(); } - xmpp_stanza_t *child = xmpp_stanza_get_children(storage); + xmpp_stanza_t* child = xmpp_stanza_get_children(storage); while (child) { name = xmpp_stanza_get_name(child); if (!name || strcmp(name, STANZA_NAME_CONFERENCE) != 0) { child = xmpp_stanza_get_next(child); continue; } - const char *barejid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID); + const char* barejid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID); if (!barejid) { child = xmpp_stanza_get_next(child); continue; @@ -286,21 +286,21 @@ _bookmark_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata) log_debug("Handle bookmark for %s", barejid); - const char *room_name = xmpp_stanza_get_attribute(child, "name"); + const char* room_name = xmpp_stanza_get_attribute(child, "name"); - char *nick = NULL; - xmpp_stanza_t *nick_st = xmpp_stanza_get_child_by_name(child, "nick"); + char* nick = NULL; + xmpp_stanza_t* nick_st = xmpp_stanza_get_child_by_name(child, "nick"); if (nick_st) { nick = stanza_text_strdup(nick_st); } - char *password = NULL; - xmpp_stanza_t *password_st = xmpp_stanza_get_child_by_name(child, "password"); + char* password = NULL; + xmpp_stanza_t* password_st = xmpp_stanza_get_child_by_name(child, "password"); if (password_st) { password = stanza_text_strdup(password_st); } - const char *autojoin = xmpp_stanza_get_attribute(child, "autojoin"); + const char* autojoin = xmpp_stanza_get_attribute(child, "autojoin"); gboolean autojoin_val = FALSE; if (autojoin && (strcmp(autojoin, "1") == 0 || strcmp(autojoin, "true") == 0)) { autojoin_val = TRUE; @@ -308,9 +308,9 @@ _bookmark_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata) // we save minimize, which is not standard, so that we don't remove it if it was set by gajim int minimize = 0; - xmpp_stanza_t *minimize_st = stanza_get_child_by_name_and_ns(child, STANZA_NAME_MINIMIZE, STANZA_NS_EXT_GAJIM_BOOKMARKS); + xmpp_stanza_t* minimize_st = stanza_get_child_by_name_and_ns(child, STANZA_NAME_MINIMIZE, STANZA_NS_EXT_GAJIM_BOOKMARKS); if (minimize_st) { - char *min_str = xmpp_stanza_get_text(minimize_st); + char* min_str = xmpp_stanza_get_text(minimize_st); if (strcmp(min_str, "true") == 0) { minimize = 1; } else if (strcmp(min_str, "false") == 0) { @@ -320,7 +320,7 @@ _bookmark_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata) } autocomplete_add(bookmark_ac, barejid); - Bookmark *bookmark = malloc(sizeof(Bookmark)); + Bookmark* bookmark = malloc(sizeof(Bookmark)); bookmark->barejid = strdup(barejid); bookmark->nick = nick; bookmark->password = password; @@ -333,7 +333,7 @@ _bookmark_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata) sv_ev_bookmark_autojoin(bookmark); } - Jid *jidp = jid_create(barejid); + Jid* jidp = jid_create(barejid); if (jidp->domainpart) { muc_confserver_add(jidp->domainpart); } @@ -346,7 +346,7 @@ _bookmark_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata) } static void -_bookmark_destroy(Bookmark *bookmark) +_bookmark_destroy(Bookmark* bookmark) { if (bookmark) { free(bookmark->barejid); @@ -360,25 +360,25 @@ _bookmark_destroy(Bookmark *bookmark) static void _send_bookmarks(void) { - xmpp_ctx_t *ctx = connection_get_ctx(); + xmpp_ctx_t* ctx = connection_get_ctx(); - char *id = connection_create_stanza_id(); - xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); + char* id = connection_create_stanza_id(); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); free(id); - xmpp_stanza_t *query = xmpp_stanza_new(ctx); + xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_ns(query, "jabber:iq:private"); - xmpp_stanza_t *storage = xmpp_stanza_new(ctx); + xmpp_stanza_t* storage = xmpp_stanza_new(ctx); xmpp_stanza_set_name(storage, STANZA_NAME_STORAGE); xmpp_stanza_set_ns(storage, "storage:bookmarks"); - GList *bookmark_list = g_hash_table_get_values(bookmarks); - GList *curr = bookmark_list; + GList* bookmark_list = g_hash_table_get_values(bookmarks); + GList* curr = bookmark_list; while (curr) { - Bookmark *bookmark = curr->data; - xmpp_stanza_t *conference = xmpp_stanza_new(ctx); + Bookmark* bookmark = curr->data; + xmpp_stanza_t* conference = xmpp_stanza_new(ctx); xmpp_stanza_set_name(conference, STANZA_NAME_CONFERENCE); xmpp_stanza_set_attribute(conference, STANZA_ATTR_JID, bookmark->barejid); @@ -387,7 +387,7 @@ _send_bookmarks(void) xmpp_stanza_set_attribute(conference, STANZA_ATTR_NAME, bookmark->name); } else { // use localpart of JID by if no name is specified - Jid *jidp = jid_create(bookmark->barejid); + Jid* jidp = jid_create(bookmark->barejid); if (jidp->localpart) { xmpp_stanza_set_attribute(conference, STANZA_ATTR_NAME, jidp->localpart); } @@ -401,9 +401,9 @@ _send_bookmarks(void) } if (bookmark->nick) { - xmpp_stanza_t *nick_st = xmpp_stanza_new(ctx); + xmpp_stanza_t* nick_st = xmpp_stanza_new(ctx); xmpp_stanza_set_name(nick_st, STANZA_NAME_NICK); - xmpp_stanza_t *nick_text = xmpp_stanza_new(ctx); + xmpp_stanza_t* nick_text = xmpp_stanza_new(ctx); xmpp_stanza_set_text(nick_text, bookmark->nick); xmpp_stanza_add_child(nick_st, nick_text); xmpp_stanza_add_child(conference, nick_st); @@ -413,9 +413,9 @@ _send_bookmarks(void) } if (bookmark->password) { - xmpp_stanza_t *password_st = xmpp_stanza_new(ctx); + xmpp_stanza_t* password_st = xmpp_stanza_new(ctx); xmpp_stanza_set_name(password_st, STANZA_NAME_PASSWORD); - xmpp_stanza_t *password_text = xmpp_stanza_new(ctx); + xmpp_stanza_t* password_text = xmpp_stanza_new(ctx); xmpp_stanza_set_text(password_text, bookmark->password); xmpp_stanza_add_child(password_st, password_text); xmpp_stanza_add_child(conference, password_st); @@ -424,13 +424,12 @@ _send_bookmarks(void) xmpp_stanza_release(password_st); } - if (bookmark->ext_gajim_minimize == 1 || - bookmark->ext_gajim_minimize == 2) { - xmpp_stanza_t *minimize_st = xmpp_stanza_new(ctx); + if (bookmark->ext_gajim_minimize == 1 || bookmark->ext_gajim_minimize == 2) { + xmpp_stanza_t* minimize_st = xmpp_stanza_new(ctx); xmpp_stanza_set_name(minimize_st, STANZA_NAME_MINIMIZE); xmpp_stanza_set_ns(minimize_st, STANZA_NS_EXT_GAJIM_BOOKMARKS); - xmpp_stanza_t *minimize_text = xmpp_stanza_new(ctx); + xmpp_stanza_t* minimize_text = xmpp_stanza_new(ctx); if (bookmark->ext_gajim_minimize == 1) { xmpp_stanza_set_text(minimize_text, "true"); } else { diff --git a/src/xmpp/capabilities.c b/src/xmpp/capabilities.c index a0fcecb0..f3788a41 100644 --- a/src/xmpp/capabilities.c +++ b/src/xmpp/capabilities.c @@ -64,19 +64,19 @@ #include "xmpp/form.h" #include "xmpp/capabilities.h" -static char *cache_loc; -static GKeyFile *cache; +static char* cache_loc; +static GKeyFile* cache; -static GHashTable *jid_to_ver; -static GHashTable *jid_to_caps; +static GHashTable* jid_to_ver; +static GHashTable* jid_to_caps; -static GHashTable *prof_features; -static char *my_sha1; +static GHashTable* prof_features; +static char* my_sha1; static void _save_cache(void); -static EntityCapabilities* _caps_by_ver(const char *const ver); -static EntityCapabilities* _caps_by_jid(const char *const jid); -static EntityCapabilities* _caps_copy(EntityCapabilities *caps); +static EntityCapabilities* _caps_by_ver(const char* const ver); +static EntityCapabilities* _caps_by_jid(const char* const jid); +static EntityCapabilities* _caps_copy(EntityCapabilities* caps); void caps_init(void) @@ -121,7 +121,7 @@ caps_init(void) } void -caps_add_feature(char *feature) +caps_add_feature(char* feature) { if (g_hash_table_contains(prof_features, feature)) { return; @@ -139,7 +139,7 @@ caps_add_feature(char *feature) } void -caps_remove_feature(char *feature) +caps_remove_feature(char* feature) { if (!g_hash_table_contains(prof_features, feature)) { return; @@ -159,17 +159,17 @@ caps_remove_feature(char *feature) GList* caps_get_features(void) { - GList *result = NULL; + GList* result = NULL; - GList *features_as_list = g_hash_table_get_keys(prof_features); - GList *curr = features_as_list; + GList* features_as_list = g_hash_table_get_keys(prof_features); + GList* curr = features_as_list; while (curr) { result = g_list_append(result, strdup(curr->data)); curr = g_list_next(curr); } g_list_free(features_as_list); - GList *plugin_features = plugins_get_disco_features(); + GList* plugin_features = plugins_get_disco_features(); curr = plugin_features; while (curr) { result = g_list_append(result, strdup(curr->data)); @@ -182,15 +182,15 @@ caps_get_features(void) } EntityCapabilities* -caps_create(const char *const category, const char *const type, const char *const name, - const char *const software, const char *const software_version, - const char *const os, const char *const os_version, - GSList *features) +caps_create(const char* const category, const char* const type, const char* const name, + const char* const software, const char* const software_version, + const char* const os, const char* const os_version, + GSList* features) { - EntityCapabilities *result = (EntityCapabilities *)malloc(sizeof(EntityCapabilities)); + EntityCapabilities* result = (EntityCapabilities*)malloc(sizeof(EntityCapabilities)); if (category || type || name) { - DiscoIdentity *identity = (DiscoIdentity*)malloc(sizeof(DiscoIdentity)); + DiscoIdentity* identity = (DiscoIdentity*)malloc(sizeof(DiscoIdentity)); identity->category = category ? strdup(category) : NULL; identity->type = type ? strdup(type) : NULL; identity->name = name ? strdup(name) : NULL; @@ -200,7 +200,7 @@ caps_create(const char *const category, const char *const type, const char *cons } if (software || software_version || os || os_version) { - SoftwareVersion *software_versionp = (SoftwareVersion*)malloc(sizeof(SoftwareVersion)); + SoftwareVersion* software_versionp = (SoftwareVersion*)malloc(sizeof(SoftwareVersion)); software_versionp->software = software ? strdup(software) : NULL; software_versionp->software_version = software_version ? strdup(software_version) : NULL; software_versionp->os = os ? strdup(os) : NULL; @@ -211,7 +211,7 @@ caps_create(const char *const category, const char *const type, const char *cons } result->features = NULL; - GSList *curr = features; + GSList* curr = features; while (curr) { result->features = g_slist_append(result->features, strdup(curr->data)); curr = g_slist_next(curr); @@ -221,7 +221,7 @@ caps_create(const char *const category, const char *const type, const char *cons } void -caps_add_by_ver(const char *const ver, EntityCapabilities *caps) +caps_add_by_ver(const char* const ver, EntityCapabilities* caps) { if (ver == NULL || caps == NULL) { return; @@ -233,7 +233,7 @@ caps_add_by_ver(const char *const ver, EntityCapabilities *caps) } if (caps->identity) { - DiscoIdentity *identity = caps->identity; + DiscoIdentity* identity = caps->identity; if (identity->name) { g_key_file_set_string(cache, ver, "name", identity->name); } @@ -246,7 +246,7 @@ caps_add_by_ver(const char *const ver, EntityCapabilities *caps) } if (caps->software_version) { - SoftwareVersion *software_version = caps->software_version; + SoftwareVersion* software_version = caps->software_version; if (software_version->software) { g_key_file_set_string(cache, ver, "software", software_version->software); } @@ -262,7 +262,7 @@ caps_add_by_ver(const char *const ver, EntityCapabilities *caps) } if (caps->features) { - GSList *curr_feature = caps->features; + GSList* curr_feature = caps->features; int num = g_slist_length(caps->features); const gchar* features_list[num]; int curr = 0; @@ -277,35 +277,35 @@ caps_add_by_ver(const char *const ver, EntityCapabilities *caps) } void -caps_add_by_jid(const char *const jid, EntityCapabilities *caps) +caps_add_by_jid(const char* const jid, EntityCapabilities* caps) { g_hash_table_insert(jid_to_caps, strdup(jid), caps); } void -caps_map_jid_to_ver(const char *const jid, const char *const ver) +caps_map_jid_to_ver(const char* const jid, const char* const ver) { g_hash_table_insert(jid_to_ver, strdup(jid), strdup(ver)); } gboolean -caps_cache_contains(const char *const ver) +caps_cache_contains(const char* const ver) { return (g_key_file_has_group(cache, ver)); } EntityCapabilities* -caps_lookup(const char *const jid) +caps_lookup(const char* const jid) { - char *ver = g_hash_table_lookup(jid_to_ver, jid); + char* ver = g_hash_table_lookup(jid_to_ver, jid); if (ver) { - EntityCapabilities *caps = _caps_by_ver(ver); + EntityCapabilities* caps = _caps_by_ver(ver); if (caps) { log_debug("Capabilities lookup %s, found by verification string %s.", jid, ver); return caps; } } else { - EntityCapabilities *caps = _caps_by_jid(jid); + EntityCapabilities* caps = _caps_by_jid(jid); if (caps) { log_debug("Capabilities lookup %s, found by JID.", jid); return _caps_copy(caps); @@ -317,15 +317,15 @@ caps_lookup(const char *const jid) } gboolean -caps_jid_has_feature(const char *const jid, const char *const feature) +caps_jid_has_feature(const char* const jid, const char* const feature) { - EntityCapabilities *caps = caps_lookup(jid); + EntityCapabilities* caps = caps_lookup(jid); if (caps == NULL) { return FALSE; } - GSList *found = g_slist_find_custom(caps->features, feature, (GCompareFunc)g_strcmp0); + GSList* found = g_slist_find_custom(caps->features, feature, (GCompareFunc)g_strcmp0); gboolean result = found != NULL; caps_destroy(caps); @@ -334,10 +334,10 @@ caps_jid_has_feature(const char *const jid, const char *const feature) } char* -caps_get_my_sha1(xmpp_ctx_t *const ctx) +caps_get_my_sha1(xmpp_ctx_t* const ctx) { if (my_sha1 == NULL) { - xmpp_stanza_t *query = stanza_create_caps_query_element(ctx); + xmpp_stanza_t* query = stanza_create_caps_query_element(ctx); my_sha1 = stanza_create_caps_sha1_from_query(query); xmpp_stanza_release(query); } @@ -368,24 +368,24 @@ caps_close(void) } static EntityCapabilities* -_caps_by_ver(const char *const ver) +_caps_by_ver(const char* const ver) { if (!g_key_file_has_group(cache, ver)) { return NULL; } - char *category = g_key_file_get_string(cache, ver, "category", NULL); - char *type = g_key_file_get_string(cache, ver, "type", NULL); - char *name = g_key_file_get_string(cache, ver, "name", NULL); + char* category = g_key_file_get_string(cache, ver, "category", NULL); + char* type = g_key_file_get_string(cache, ver, "type", NULL); + char* name = g_key_file_get_string(cache, ver, "name", NULL); - char *software = g_key_file_get_string(cache, ver, "software", NULL); - char *software_version = g_key_file_get_string(cache, ver, "software_version", NULL); - char *os = g_key_file_get_string(cache, ver, "os", NULL); - char *os_version = g_key_file_get_string(cache, ver, "os_version", NULL); + char* software = g_key_file_get_string(cache, ver, "software", NULL); + char* software_version = g_key_file_get_string(cache, ver, "software_version", NULL); + char* os = g_key_file_get_string(cache, ver, "os", NULL); + char* os_version = g_key_file_get_string(cache, ver, "os_version", NULL); gsize features_len = 0; - gchar **features_list = g_key_file_get_string_list(cache, ver, "features", &features_len, NULL); - GSList *features = NULL; + gchar** features_list = g_key_file_get_string_list(cache, ver, "features", &features_len, NULL); + GSList* features = NULL; if (features_list && features_len > 0) { int i; for (i = 0; i < features_len; i++) { @@ -393,7 +393,7 @@ _caps_by_ver(const char *const ver) } } - EntityCapabilities *result = caps_create( + EntityCapabilities* result = caps_create( category, type, name, software, software_version, os, os_version, features); @@ -414,32 +414,32 @@ _caps_by_ver(const char *const ver) } static EntityCapabilities* -_caps_by_jid(const char *const jid) +_caps_by_jid(const char* const jid) { return g_hash_table_lookup(jid_to_caps, jid); } static EntityCapabilities* -_caps_copy(EntityCapabilities *caps) +_caps_copy(EntityCapabilities* caps) { if (!caps) { return NULL; } - const char *const categoty = caps->identity ? caps->identity->category : NULL; - const char *const type = caps->identity ? caps->identity->type : NULL; - const char *const name = caps->identity ? caps->identity->name : NULL; + const char* const categoty = caps->identity ? caps->identity->category : NULL; + const char* const type = caps->identity ? caps->identity->type : NULL; + const char* const name = caps->identity ? caps->identity->name : NULL; - const char *const software = caps->software_version ? caps->software_version->software : NULL; - const char *const software_version = caps->software_version ? caps->software_version->software_version : NULL; - const char *const os = caps->software_version ? caps->software_version->os : NULL; - const char *const os_version = caps->software_version ? caps->software_version->os_version : NULL; + const char* const software = caps->software_version ? caps->software_version->software : NULL; + const char* const software_version = caps->software_version ? caps->software_version->software_version : NULL; + const char* const os = caps->software_version ? caps->software_version->os : NULL; + const char* const os_version = caps->software_version ? caps->software_version->os_version : NULL; return caps_create(categoty, type, name, software, software_version, os, os_version, caps->features); } static void -_disco_identity_destroy(DiscoIdentity *disco_identity) +_disco_identity_destroy(DiscoIdentity* disco_identity) { if (disco_identity) { free(disco_identity->category); @@ -450,7 +450,7 @@ _disco_identity_destroy(DiscoIdentity *disco_identity) } static void -_software_version_destroy(SoftwareVersion *software_version) +_software_version_destroy(SoftwareVersion* software_version) { if (software_version) { free(software_version->software); @@ -462,7 +462,7 @@ _software_version_destroy(SoftwareVersion *software_version) } void -caps_destroy(EntityCapabilities *caps) +caps_destroy(EntityCapabilities* caps) { if (caps) { _disco_identity_destroy(caps->identity); @@ -478,7 +478,7 @@ static void _save_cache(void) { gsize g_data_size; - gchar *g_cache_data = g_key_file_to_data(cache, &g_data_size, NULL); + gchar* g_cache_data = g_key_file_to_data(cache, &g_data_size, NULL); g_file_set_contents(cache_loc, g_cache_data, g_data_size, NULL); g_chmod(cache_loc, S_IRUSR | S_IWUSR); g_free(g_cache_data); diff --git a/src/xmpp/capabilities.h b/src/xmpp/capabilities.h index 4cf3dd6c..0760f7d7 100644 --- a/src/xmpp/capabilities.h +++ b/src/xmpp/capabilities.h @@ -50,15 +50,15 @@ void caps_init(void); -EntityCapabilities* caps_create(const char *const category, const char *const type, const char *const name, - const char *const software, const char *const software_version, - const char *const os, const char *const os_version, - GSList *features); -void caps_add_by_ver(const char *const ver, EntityCapabilities *caps); -void caps_add_by_jid(const char *const jid, EntityCapabilities *caps); -void caps_map_jid_to_ver(const char *const jid, const char *const ver); -gboolean caps_cache_contains(const char *const ver); +EntityCapabilities* caps_create(const char* const category, const char* const type, const char* const name, + const char* const software, const char* const software_version, + const char* const os, const char* const os_version, + GSList* features); +void caps_add_by_ver(const char* const ver, EntityCapabilities* caps); +void caps_add_by_jid(const char* const jid, EntityCapabilities* caps); +void caps_map_jid_to_ver(const char* const jid, const char* const ver); +gboolean caps_cache_contains(const char* const ver); GList* caps_get_features(void); -char* caps_get_my_sha1(xmpp_ctx_t *const ctx); +char* caps_get_my_sha1(xmpp_ctx_t* const ctx); #endif diff --git a/src/xmpp/chat_session.c b/src/xmpp/chat_session.c index 3a018be8..56d92862 100644 --- a/src/xmpp/chat_session.c +++ b/src/xmpp/chat_session.c @@ -45,16 +45,16 @@ #include "xmpp/stanza.h" #include "xmpp/chat_session.h" -static GHashTable *sessions; +static GHashTable* sessions; static void -_chat_session_new(const char *const barejid, const char *const resource, gboolean resource_override, - gboolean send_states) +_chat_session_new(const char* const barejid, const char* const resource, gboolean resource_override, + gboolean send_states) { assert(barejid != NULL); assert(resource != NULL); - ChatSession *new_session = malloc(sizeof(struct chat_session_t)); + ChatSession* new_session = malloc(sizeof(struct chat_session_t)); new_session->barejid = strdup(barejid); new_session->resource = strdup(resource); new_session->resource_override = resource_override; @@ -64,7 +64,7 @@ _chat_session_new(const char *const barejid, const char *const resource, gboolea } static void -_chat_session_free(ChatSession *session) +_chat_session_free(ChatSession* session) { if (session) { free(session->barejid); @@ -91,24 +91,24 @@ chat_sessions_clear(void) } void -chat_session_resource_override(const char *const barejid, const char *const resource) +chat_session_resource_override(const char* const barejid, const char* const resource) { _chat_session_new(barejid, resource, TRUE, TRUE); } ChatSession* -chat_session_get(const char *const barejid) +chat_session_get(const char* const barejid) { return g_hash_table_lookup(sessions, barejid); } char* -chat_session_get_jid(const char *const barejid) +chat_session_get_jid(const char* const barejid) { - ChatSession *session = chat_session_get(barejid); - char *jid = NULL; + ChatSession* session = chat_session_get(barejid); + char* jid = NULL; if (session) { - Jid *jidp = jid_create_from_bare_and_resource(session->barejid, session->resource); + Jid* jidp = jid_create_from_bare_and_resource(session->barejid, session->resource); jid = strdup(jidp->fulljid); jid_destroy(jidp); } else { @@ -119,10 +119,10 @@ chat_session_get_jid(const char *const barejid) } char* -chat_session_get_state(const char *const barejid) +chat_session_get_state(const char* const barejid) { - ChatSession *session = chat_session_get(barejid); - char *state = NULL; + ChatSession* session = chat_session_get(barejid); + char* state = NULL; if (session) { if (prefs_get_boolean(PREF_STATES) && session->send_states) { state = STANZA_NAME_ACTIVE; @@ -137,12 +137,12 @@ chat_session_get_state(const char *const barejid) } void -chat_session_recipient_gone(const char *const barejid, const char *const resource) +chat_session_recipient_gone(const char* const barejid, const char* const resource) { assert(barejid != NULL); assert(resource != NULL); - ChatSession *session = g_hash_table_lookup(sessions, barejid); + ChatSession* session = g_hash_table_lookup(sessions, barejid); if (session && g_strcmp0(session->resource, resource) == 0) { if (!session->resource_override) { chat_session_remove(barejid); @@ -151,48 +151,48 @@ chat_session_recipient_gone(const char *const barejid, const char *const resourc } void -chat_session_recipient_typing(const char *const barejid, const char *const resource) +chat_session_recipient_typing(const char* const barejid, const char* const resource) { chat_session_recipient_active(barejid, resource, TRUE); } void -chat_session_recipient_paused(const char *const barejid, const char *const resource) +chat_session_recipient_paused(const char* const barejid, const char* const resource) { chat_session_recipient_active(barejid, resource, TRUE); } void -chat_session_recipient_inactive(const char *const barejid, const char *const resource) +chat_session_recipient_inactive(const char* const barejid, const char* const resource) { chat_session_recipient_active(barejid, resource, TRUE); } void -chat_session_recipient_active(const char *const barejid, const char *const resource, - gboolean send_states) +chat_session_recipient_active(const char* const barejid, const char* const resource, + gboolean send_states) { assert(barejid != NULL); assert(resource != NULL); - ChatSession *session = g_hash_table_lookup(sessions, barejid); + ChatSession* session = g_hash_table_lookup(sessions, barejid); if (session) { // session exists with resource, update chat_states if (g_strcmp0(session->resource, resource) == 0) { session->send_states = send_states; - // session exists with different resource and no override, replace + // session exists with different resource and no override, replace } else if (!session->resource_override) { _chat_session_new(barejid, resource, FALSE, send_states); } - // no session, create one + // no session, create one } else { _chat_session_new(barejid, resource, FALSE, send_states); } } void -chat_session_remove(const char *const barejid) +chat_session_remove(const char* const barejid) { g_hash_table_remove(sessions, barejid); } diff --git a/src/xmpp/chat_session.h b/src/xmpp/chat_session.h index 550858e7..e0144874 100644 --- a/src/xmpp/chat_session.h +++ b/src/xmpp/chat_session.h @@ -38,9 +38,10 @@ #include <glib.h> -typedef struct chat_session_t { - char *barejid; - char *resource; +typedef struct chat_session_t +{ + char* barejid; + char* resource; gboolean resource_override; gboolean send_states; @@ -49,17 +50,17 @@ typedef struct chat_session_t { void chat_sessions_init(void); void chat_sessions_clear(void); -void chat_session_resource_override(const char *const barejid, const char *const resource); -ChatSession* chat_session_get(const char *const barejid); +void chat_session_resource_override(const char* const barejid, const char* const resource); +ChatSession* chat_session_get(const char* const barejid); -void chat_session_recipient_active(const char *const barejid, const char *const resource, gboolean send_states); -void chat_session_recipient_typing(const char *const barejid, const char *const resource); -void chat_session_recipient_paused(const char *const barejid, const char *const resource); -void chat_session_recipient_gone(const char *const barejid, const char *const resource); -void chat_session_recipient_inactive(const char *const barejid, const char *const resource); -char* chat_session_get_jid(const char *const barejid); -char* chat_session_get_state(const char *const barejid); +void chat_session_recipient_active(const char* const barejid, const char* const resource, gboolean send_states); +void chat_session_recipient_typing(const char* const barejid, const char* const resource); +void chat_session_recipient_paused(const char* const barejid, const char* const resource); +void chat_session_recipient_gone(const char* const barejid, const char* const resource); +void chat_session_recipient_inactive(const char* const barejid, const char* const resource); +char* chat_session_get_jid(const char* const barejid); +char* chat_session_get_state(const char* const barejid); -void chat_session_remove(const char *const barejid); +void chat_session_remove(const char* const barejid); #endif diff --git a/src/xmpp/chat_state.c b/src/xmpp/chat_state.c index 77945a50..ad236a43 100644 --- a/src/xmpp/chat_state.c +++ b/src/xmpp/chat_state.c @@ -45,15 +45,15 @@ #include "xmpp/chat_state.h" #include "xmpp/chat_session.h" -#define PAUSED_TIMEOUT 10.0 +#define PAUSED_TIMEOUT 10.0 #define INACTIVE_TIMEOUT 30.0 -static void _send_if_supported(const char *const barejid, void (*send_func)(const char *const)); +static void _send_if_supported(const char* const barejid, void (*send_func)(const char* const)); ChatState* chat_state_new(void) { - ChatState *new_state = malloc(sizeof(struct prof_chat_state_t)); + ChatState* new_state = malloc(sizeof(struct prof_chat_state_t)); new_state->type = CHAT_STATE_GONE; new_state->timer = g_timer_new(); @@ -61,16 +61,16 @@ chat_state_new(void) } void -chat_state_free(ChatState *state) +chat_state_free(ChatState* state) { - if (state && state->timer!= NULL) { + if (state && state->timer != NULL) { g_timer_destroy(state->timer); } free(state); } void -chat_state_handle_idle(const char *const barejid, ChatState *state) +chat_state_handle_idle(const char* const barejid, ChatState* state) { gdouble elapsed = g_timer_elapsed(state->timer, NULL); @@ -92,13 +92,12 @@ chat_state_handle_idle(const char *const barejid, ChatState *state) _send_if_supported(barejid, message_send_inactive); } return; - } // INACTIVE -> GONE if (state->type == CHAT_STATE_INACTIVE) { if (prefs_get_gone() != 0 && (elapsed > (prefs_get_gone() * 60.0))) { - ChatSession *session = chat_session_get(barejid); + ChatSession* session = chat_session_get(barejid); if (session) { // never move to GONE when resource override if (!session->resource_override) { @@ -122,7 +121,7 @@ chat_state_handle_idle(const char *const barejid, ChatState *state) } void -chat_state_handle_typing(const char *const barejid, ChatState *state) +chat_state_handle_typing(const char* const barejid, ChatState* state) { // ACTIVE|INACTIVE|PAUSED|GONE -> COMPOSING if (state->type != CHAT_STATE_COMPOSING) { @@ -135,14 +134,14 @@ chat_state_handle_typing(const char *const barejid, ChatState *state) } void -chat_state_active(ChatState *state) +chat_state_active(ChatState* state) { state->type = CHAT_STATE_ACTIVE; g_timer_start(state->timer); } void -chat_state_gone(const char *const barejid, ChatState *state) +chat_state_gone(const char* const barejid, ChatState* state) { if (state->type != CHAT_STATE_GONE) { if (prefs_get_boolean(PREF_STATES)) { @@ -158,12 +157,12 @@ chat_state_idle(void) { jabber_conn_status_t status = connection_get_status(); if (status == JABBER_CONNECTED) { - GSList *recipients = wins_get_chat_recipients(); - GSList *curr = recipients; + GSList* recipients = wins_get_chat_recipients(); + GSList* curr = recipients; while (curr) { - char *barejid = curr->data; - ProfChatWin *chatwin = wins_get_chat(barejid); + char* barejid = curr->data; + ProfChatWin* chatwin = wins_get_chat(barejid); chat_state_handle_idle(chatwin->barejid, chatwin->state); curr = g_slist_next(curr); } @@ -178,21 +177,21 @@ void chat_state_activity(void) { jabber_conn_status_t status = connection_get_status(); - ProfWin *current = wins_get_current(); + ProfWin* current = wins_get_current(); if ((status == JABBER_CONNECTED) && (current->type == WIN_CHAT)) { - ProfChatWin *chatwin = (ProfChatWin*)current; + ProfChatWin* chatwin = (ProfChatWin*)current; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); chat_state_handle_typing(chatwin->barejid, chatwin->state); } } static void -_send_if_supported(const char *const barejid, void (*send_func)(const char *const)) +_send_if_supported(const char* const barejid, void (*send_func)(const char* const)) { gboolean send = TRUE; - GString *jid = g_string_new(barejid); - ChatSession *session = chat_session_get(barejid); + GString* jid = g_string_new(barejid); + ChatSession* session = chat_session_get(barejid); if (session) { if (session->send_states) { g_string_append(jid, "/"); diff --git a/src/xmpp/chat_state.h b/src/xmpp/chat_state.h index e484b284..3b2e5829 100644 --- a/src/xmpp/chat_state.h +++ b/src/xmpp/chat_state.h @@ -46,20 +46,21 @@ typedef enum { CHAT_STATE_GONE } chat_state_type_t; -typedef struct prof_chat_state_t { +typedef struct prof_chat_state_t +{ chat_state_type_t type; - GTimer *timer; + GTimer* timer; } ChatState; ChatState* chat_state_new(void); -void chat_state_free(ChatState *state); +void chat_state_free(ChatState* state); void chat_state_idle(void); void chat_state_activity(void); -void chat_state_handle_idle(const char *const barejid, ChatState *state); -void chat_state_handle_typing(const char *const barejid, ChatState *state); -void chat_state_active(ChatState *state); -void chat_state_gone(const char *const barejid, ChatState *state); +void chat_state_handle_idle(const char* const barejid, ChatState* state); +void chat_state_handle_typing(const char* const barejid, ChatState* state); +void chat_state_active(ChatState* state); +void chat_state_gone(const char* const barejid, ChatState* state); #endif diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c index 8c875e63..ace28255 100644 --- a/src/xmpp/connection.c +++ b/src/xmpp/connection.c @@ -61,39 +61,40 @@ #include "xmpp/iq.h" #include "ui/ui.h" -typedef struct prof_conn_t { - xmpp_log_t *xmpp_log; - xmpp_ctx_t *xmpp_ctx; - xmpp_conn_t *xmpp_conn; +typedef struct prof_conn_t +{ + xmpp_log_t* xmpp_log; + xmpp_ctx_t* xmpp_ctx; + xmpp_conn_t* xmpp_conn; gboolean xmpp_in_event_loop; jabber_conn_status_t conn_status; xmpp_conn_event_t conn_last_event; - char *presence_message; + char* presence_message; int priority; - char *domain; - GHashTable *available_resources; - GHashTable *features_by_jid; - GHashTable *requested_features; + char* domain; + GHashTable* available_resources; + GHashTable* features_by_jid; + GHashTable* requested_features; } ProfConnection; static ProfConnection conn; -static gchar *profanity_instance_id = NULL; -static gchar *prof_identifier = NULL; +static gchar* profanity_instance_id = NULL; +static gchar* prof_identifier = NULL; static xmpp_log_t* _xmpp_get_file_logger(void); -static void _xmpp_file_logger(void *const userdata, const xmpp_log_level_t level, const char *const area, const char *const msg); +static void _xmpp_file_logger(void* const userdata, const xmpp_log_level_t level, const char* const area, const char* const msg); -static void _connection_handler(xmpp_conn_t *const xmpp_conn, const xmpp_conn_event_t status, const int error, - xmpp_stream_error_t *const stream_error, void *const userdata); +static void _connection_handler(xmpp_conn_t* const xmpp_conn, const xmpp_conn_event_t status, const int error, + xmpp_stream_error_t* const stream_error, void* const userdata); #ifdef HAVE_LIBMESODE -TLSCertificate* _xmppcert_to_profcert(xmpp_tlscert_t *xmpptlscert); -static int _connection_certfail_cb(xmpp_tlscert_t *xmpptlscert, const char *const errormsg); +TLSCertificate* _xmppcert_to_profcert(xmpp_tlscert_t* xmpptlscert); +static int _connection_certfail_cb(xmpp_tlscert_t* xmpptlscert, const char* const errormsg); #endif static void _random_bytes_init(void); static void _random_bytes_close(void); -static void _compute_identifier(const char *barejid); +static void _compute_identifier(const char* barejid); void connection_init(void) @@ -110,7 +111,7 @@ connection_init(void) conn.available_resources = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)resource_destroy); conn.requested_features = g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL); - _random_bytes_init(); + _random_bytes_init(); } void @@ -130,19 +131,19 @@ connection_shutdown(void) free(conn.xmpp_log); conn.xmpp_log = NULL; - _random_bytes_close(); + _random_bytes_close(); } jabber_conn_status_t -connection_connect(const char *const jid, const char *const passwd, const char *const altdomain, int port, - const char *const tls_policy, const char *const auth_policy) +connection_connect(const char* const jid, const char* const passwd, const char* const altdomain, int port, + const char* const tls_policy, const char* const auth_policy) { long flags; assert(jid != NULL); assert(passwd != NULL); - Jid *jidp = jid_create(jid); + Jid* jidp = jid_create(jid); if (jidp == NULL) { log_error("Malformed JID not able to connect: %s", jid); conn.conn_status = JABBER_DISCONNECTED; @@ -206,7 +207,10 @@ connection_connect(const char *const jid, const char *const passwd, const char * /* Print debug logs that can help when users share the logs */ if (flags != 0) { log_debug("Connecting with flags (0x%lx):", flags); -#define LOG_FLAG_IF_SET(name) if (flags & name) { log_debug(" " #name); } +#define LOG_FLAG_IF_SET(name) \ + if (flags & name) { \ + log_debug(" " #name); \ + } LOG_FLAG_IF_SET(XMPP_CONN_FLAG_MANDATORY_TLS); LOG_FLAG_IF_SET(XMPP_CONN_FLAG_TRUST_TLS); LOG_FLAG_IF_SET(XMPP_CONN_FLAG_DISABLE_TLS); @@ -218,7 +222,7 @@ connection_connect(const char *const jid, const char *const passwd, const char * } #ifdef HAVE_LIBMESODE - char *cert_path = prefs_get_tls_certpath(); + char* cert_path = prefs_get_tls_certpath(); if (cert_path) { xmpp_conn_tlscert_path(conn.xmpp_conn, cert_path); free(cert_path); @@ -311,8 +315,8 @@ connection_clear_data(void) TLSCertificate* connection_get_tls_peer_cert(void) { - xmpp_tlscert_t *xmpptlscert = xmpp_conn_tls_peer_cert(conn.xmpp_conn); - TLSCertificate *cert = _xmppcert_to_profcert(xmpptlscert); + xmpp_tlscert_t* xmpptlscert = xmpp_conn_tls_peer_cert(conn.xmpp_conn); + TLSCertificate* cert = _xmppcert_to_profcert(xmpptlscert); xmpp_conn_free_tlscert(conn.xmpp_ctx, xmpptlscert); return cert; @@ -330,7 +334,7 @@ connection_is_secured(void) } gboolean -connection_send_stanza(const char *const stanza) +connection_send_stanza(const char* const stanza) { if (conn.conn_status != JABBER_CONNECTED) { return FALSE; @@ -341,15 +345,15 @@ connection_send_stanza(const char *const stanza) } gboolean -connection_supports(const char *const feature) +connection_supports(const char* const feature) { gboolean ret = FALSE; - GList *jids = g_hash_table_get_keys(conn.features_by_jid); + GList* jids = g_hash_table_get_keys(conn.features_by_jid); - GList *curr = jids; + GList* curr = jids; while (curr) { - char *jid = curr->data; - GHashTable *features = g_hash_table_lookup(conn.features_by_jid, jid); + char* jid = curr->data; + GHashTable* features = g_hash_table_lookup(conn.features_by_jid, jid); if (features && g_hash_table_lookup(features, feature)) { ret = TRUE; break; @@ -364,18 +368,18 @@ connection_supports(const char *const feature) } char* -connection_jid_for_feature(const char *const feature) +connection_jid_for_feature(const char* const feature) { if (conn.features_by_jid == NULL) { return NULL; } - GList *jids = g_hash_table_get_keys(conn.features_by_jid); + GList* jids = g_hash_table_get_keys(conn.features_by_jid); - GList *curr = jids; + GList* curr = jids; while (curr) { - char *jid = curr->data; - GHashTable *features = g_hash_table_lookup(conn.features_by_jid, jid); + char* jid = curr->data; + GHashTable* features = g_hash_table_lookup(conn.features_by_jid, jid); if (features && g_hash_table_lookup(features, feature)) { g_list_free(jids); return jid; @@ -398,14 +402,14 @@ connection_request_features(void) } void -connection_set_disco_items(GSList *items) +connection_set_disco_items(GSList* items) { - GSList *curr = items; + GSList* curr = items; while (curr) { - DiscoItem *item = curr->data; + DiscoItem* item = curr->data; g_hash_table_insert(conn.requested_features, strdup(item->jid), NULL); g_hash_table_insert(conn.features_by_jid, strdup(item->jid), - g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL)); + g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL)); iq_disco_info_request_onconnect(item->jid); @@ -434,7 +438,7 @@ connection_get_ctx(void) const char* connection_get_fulljid(void) { - const char *jid = xmpp_conn_get_bound_jid(conn.xmpp_conn); + const char* jid = xmpp_conn_get_bound_jid(conn.xmpp_conn); if (jid) { return jid; } else { @@ -443,11 +447,12 @@ connection_get_fulljid(void) } char* -connection_get_barejid(void) { - const char *jid = connection_get_fulljid(); - char *result; +connection_get_barejid(void) +{ + const char* jid = connection_get_fulljid(); + char* result; - Jid *jidp = jid_create(jid); + Jid* jidp = jid_create(jid); result = strdup(jidp->barejid); jid_destroy(jidp); @@ -455,7 +460,7 @@ connection_get_barejid(void) { } void -connection_features_received(const char *const jid) +connection_features_received(const char* const jid) { if (g_hash_table_remove(conn.requested_features, jid) && g_hash_table_size(conn.requested_features) == 0) { sv_ev_connection_features_received(); @@ -463,7 +468,7 @@ connection_features_received(const char *const jid) } GHashTable* -connection_get_features(const char *const jid) +connection_get_features(const char* const jid) { return g_hash_table_lookup(conn.features_by_jid, jid); } @@ -475,13 +480,13 @@ connection_get_available_resources(void) } void -connection_add_available_resource(Resource *resource) +connection_add_available_resource(Resource* resource) { g_hash_table_replace(conn.available_resources, strdup(resource->name), resource); } void -connection_remove_available_resource(const char *const resource) +connection_remove_available_resource(const char* const resource) { g_hash_table_remove(conn.available_resources, resource); } @@ -493,7 +498,7 @@ connection_create_uuid(void) } void -connection_free_uuid(char *uuid) +connection_free_uuid(char* uuid) { if (uuid) { xmpp_free(conn.xmpp_ctx, uuid); @@ -503,21 +508,21 @@ connection_free_uuid(char *uuid) char* connection_create_stanza_id(void) { - char *uuid = connection_create_uuid(); + char* uuid = connection_create_uuid(); assert(uuid != NULL); - gchar *hmac = g_compute_hmac_for_string(G_CHECKSUM_SHA256, - (guchar*)prof_identifier, strlen(prof_identifier), - uuid, strlen(uuid)); + gchar* hmac = g_compute_hmac_for_string(G_CHECKSUM_SHA256, + (guchar*)prof_identifier, strlen(prof_identifier), + uuid, strlen(uuid)); - GString *signature = g_string_new(""); + GString* signature = g_string_new(""); g_string_printf(signature, "%s%s", uuid, hmac); free(uuid); g_free(hmac); - char *b64 = g_base64_encode((unsigned char*)signature->str, signature->len); + char* b64 = g_base64_encode((unsigned char*)signature->str, signature->len); g_string_free(signature, TRUE); assert(b64 != NULL); @@ -538,7 +543,7 @@ connection_get_presence_msg(void) } void -connection_set_presence_msg(const char *const message) +connection_set_presence_msg(const char* const message) { FREE_SET_NULL(conn.presence_message); if (message) { @@ -553,8 +558,8 @@ connection_set_priority(const int priority) } static void -_connection_handler(xmpp_conn_t *const xmpp_conn, const xmpp_conn_event_t status, const int error, - xmpp_stream_error_t *const stream_error, void *const userdata) +_connection_handler(xmpp_conn_t* const xmpp_conn, const xmpp_conn_event_t status, const int error, + xmpp_stream_error_t* const stream_error, void* const userdata) { conn.conn_last_event = status; @@ -565,7 +570,7 @@ _connection_handler(xmpp_conn_t *const xmpp_conn, const xmpp_conn_event_t status log_debug("Connection handler: XMPP_CONN_CONNECT"); conn.conn_status = JABBER_CONNECTED; - Jid *my_jid = jid_create(xmpp_conn_get_jid(conn.xmpp_conn)); + Jid* my_jid = jid_create(xmpp_conn_get_jid(conn.xmpp_conn)); conn.domain = strdup(my_jid->domainpart); jid_destroy(my_jid); @@ -585,7 +590,7 @@ _connection_handler(xmpp_conn_t *const xmpp_conn, const xmpp_conn_event_t status log_debug("Connection handler: Lost connection for unknown reason"); session_lost_connection(); - // login attempt failed + // login attempt failed } else if (conn.conn_status != JABBER_DISCONNECTING) { log_debug("Connection handler: Login failed"); session_login_failed(); @@ -610,9 +615,9 @@ _connection_handler(xmpp_conn_t *const xmpp_conn, const xmpp_conn_event_t status #ifdef HAVE_LIBMESODE static int -_connection_certfail_cb(xmpp_tlscert_t *xmpptlscert, const char *const errormsg) +_connection_certfail_cb(xmpp_tlscert_t* xmpptlscert, const char* const errormsg) { - TLSCertificate *cert = _xmppcert_to_profcert(xmpptlscert); + TLSCertificate* cert = _xmppcert_to_profcert(xmpptlscert); int res = sv_ev_certfail(errormsg, cert); tlscerts_free(cert); @@ -621,7 +626,7 @@ _connection_certfail_cb(xmpp_tlscert_t *xmpptlscert, const char *const errormsg) } TLSCertificate* -_xmppcert_to_profcert(xmpp_tlscert_t *xmpptlscert) +_xmppcert_to_profcert(xmpp_tlscert_t* xmpptlscert) { return tlscerts_new( xmpp_conn_tlscert_fingerprint(xmpptlscert), @@ -643,13 +648,21 @@ _xmpp_get_file_logger(void) xmpp_log_level_t xmpp_level = XMPP_LEVEL_ERROR; switch (prof_level) { - case PROF_LEVEL_DEBUG: xmpp_level = XMPP_LEVEL_DEBUG; break; - case PROF_LEVEL_INFO: xmpp_level = XMPP_LEVEL_INFO; break; - case PROF_LEVEL_WARN: xmpp_level = XMPP_LEVEL_WARN; break; - default: xmpp_level = XMPP_LEVEL_ERROR; break; + case PROF_LEVEL_DEBUG: + xmpp_level = XMPP_LEVEL_DEBUG; + break; + case PROF_LEVEL_INFO: + xmpp_level = XMPP_LEVEL_INFO; + break; + case PROF_LEVEL_WARN: + xmpp_level = XMPP_LEVEL_WARN; + break; + default: + xmpp_level = XMPP_LEVEL_ERROR; + break; } - xmpp_log_t *file_log = malloc(sizeof(xmpp_log_t)); + xmpp_log_t* file_log = malloc(sizeof(xmpp_log_t)); file_log->handler = _xmpp_file_logger; file_log->userdata = &xmpp_level; @@ -657,15 +670,23 @@ _xmpp_get_file_logger(void) } static void -_xmpp_file_logger(void *const userdata, const xmpp_log_level_t xmpp_level, const char *const area, const char *const msg) +_xmpp_file_logger(void* const userdata, const xmpp_log_level_t xmpp_level, const char* const area, const char* const msg) { log_level_t prof_level = PROF_LEVEL_ERROR; switch (xmpp_level) { - case XMPP_LEVEL_DEBUG: prof_level = PROF_LEVEL_DEBUG; break; - case XMPP_LEVEL_INFO: prof_level = PROF_LEVEL_INFO; break; - case XMPP_LEVEL_WARN: prof_level = PROF_LEVEL_WARN; break; - default: prof_level = PROF_LEVEL_ERROR; break; + case XMPP_LEVEL_DEBUG: + prof_level = PROF_LEVEL_DEBUG; + break; + case XMPP_LEVEL_INFO: + prof_level = PROF_LEVEL_INFO; + break; + case XMPP_LEVEL_WARN: + prof_level = PROF_LEVEL_WARN; + break; + default: + prof_level = PROF_LEVEL_ERROR; + break; } log_msg(prof_level, area, msg); @@ -675,10 +696,11 @@ _xmpp_file_logger(void *const userdata, const xmpp_log_level_t xmpp_level, const } } -static void _random_bytes_init(void) +static void +_random_bytes_init(void) { - char *rndbytes_loc; - GKeyFile *rndbytes; + char* rndbytes_loc; + GKeyFile* rndbytes; rndbytes_loc = files_get_data_path(FILE_PROFANITY_IDENTIFIER); @@ -696,10 +718,10 @@ static void _random_bytes_init(void) g_key_file_set_string(rndbytes, "identifier", "random_bytes", profanity_instance_id); gsize g_data_size; - gchar *g_accounts_data = g_key_file_to_data(rndbytes, &g_data_size, NULL); + gchar* g_accounts_data = g_key_file_to_data(rndbytes, &g_data_size, NULL); - gchar *base = g_path_get_dirname(rndbytes_loc); - gchar *true_loc = get_file_or_linked(rndbytes_loc, base); + gchar* base = g_path_get_dirname(rndbytes_loc); + gchar* true_loc = get_file_or_linked(rndbytes_loc, base); g_file_set_contents(true_loc, g_accounts_data, g_data_size, NULL); g_free(base); @@ -711,18 +733,20 @@ static void _random_bytes_init(void) g_key_file_free(rndbytes); } -static void _random_bytes_close(void) +static void +_random_bytes_close(void) { g_free(profanity_instance_id); } -static void _compute_identifier(const char *barejid) +static void +_compute_identifier(const char* barejid) { - gchar *hmac = g_compute_hmac_for_string(G_CHECKSUM_SHA256, - (guchar*)profanity_instance_id, strlen(profanity_instance_id), - barejid, strlen(barejid)); + gchar* hmac = g_compute_hmac_for_string(G_CHECKSUM_SHA256, + (guchar*)profanity_instance_id, strlen(profanity_instance_id), + barejid, strlen(barejid)); - char *b64 = g_base64_encode((guchar*)hmac, XMPP_SHA1_DIGEST_SIZE); + char* b64 = g_base64_encode((guchar*)hmac, XMPP_SHA1_DIGEST_SIZE); assert(b64 != NULL); g_free(hmac); @@ -732,6 +756,8 @@ static void _compute_identifier(const char *barejid) prof_identifier = b64; } -const char* connection_get_profanity_identifier(void) { +const char* +connection_get_profanity_identifier(void) +{ return prof_identifier; } diff --git a/src/xmpp/connection.h b/src/xmpp/connection.h index 016a9d92..d638d037 100644 --- a/src/xmpp/connection.h +++ b/src/xmpp/connection.h @@ -42,26 +42,26 @@ void connection_init(void); void connection_shutdown(void); void connection_check_events(void); -jabber_conn_status_t connection_connect(const char *const fulljid, const char *const passwd, const char *const altdomain, int port, - const char *const tls_policy, const char *const auth_policy); +jabber_conn_status_t connection_connect(const char* const fulljid, const char* const passwd, const char* const altdomain, int port, + const char* const tls_policy, const char* const auth_policy); void connection_disconnect(void); void connection_set_disconnected(void); void connection_set_priority(const int priority); void connection_set_priority(int priority); -void connection_set_disco_items(GSList *items); +void connection_set_disco_items(GSList* items); xmpp_conn_t* connection_get_conn(void); xmpp_ctx_t* connection_get_ctx(void); -char *connection_get_domain(void); +char* connection_get_domain(void); void connection_request_features(void); -void connection_features_received(const char *const jid); -GHashTable* connection_get_features(const char *const jid); +void connection_features_received(const char* const jid); +GHashTable* connection_get_features(const char* const jid); void connection_clear_data(void); -void connection_add_available_resource(Resource *resource); -void connection_remove_available_resource(const char *const resource); +void connection_add_available_resource(Resource* resource); +void connection_remove_available_resource(const char* const resource); char* connection_create_stanza_id(void); diff --git a/src/xmpp/contact.c b/src/xmpp/contact.c index 31568237..cb1b7f05 100644 --- a/src/xmpp/contact.c +++ b/src/xmpp/contact.c @@ -44,24 +44,25 @@ #include "xmpp/resource.h" #include "xmpp/contact.h" -struct p_contact_t { - char *barejid; - gchar *barejid_collate_key; - char *name; - gchar *name_collate_key; - GSList *groups; - char *subscription; - char *offline_message; +struct p_contact_t +{ + char* barejid; + gchar* barejid_collate_key; + char* name; + gchar* name_collate_key; + GSList* groups; + char* subscription; + char* offline_message; gboolean pending_out; - GDateTime *last_activity; - GHashTable *available_resources; + GDateTime* last_activity; + GHashTable* available_resources; Autocomplete resource_ac; }; PContact -p_contact_new(const char *const barejid, const char *const name, - GSList *groups, const char *const subscription, - const char *const offline_message, gboolean pending_out) +p_contact_new(const char* const barejid, const char* const name, + GSList* groups, const char* const subscription, + const char* const offline_message, gboolean pending_out) { PContact contact = malloc(sizeof(struct p_contact_t)); contact->barejid = strdup(barejid); @@ -91,7 +92,7 @@ p_contact_new(const char *const barejid, const char *const name, contact->last_activity = NULL; contact->available_resources = g_hash_table_new_full(g_str_hash, g_str_equal, free, - (GDestroyNotify)resource_destroy); + (GDestroyNotify)resource_destroy); contact->resource_ac = autocomplete_new(); @@ -99,7 +100,7 @@ p_contact_new(const char *const barejid, const char *const name, } void -p_contact_set_name(const PContact contact, const char *const name) +p_contact_set_name(const PContact contact, const char* const name) { FREE_SET_NULL(contact->name); FREE_SET_NULL(contact->name_collate_key); @@ -110,7 +111,7 @@ p_contact_set_name(const PContact contact, const char *const name) } void -p_contact_set_groups(const PContact contact, GSList *groups) +p_contact_set_groups(const PContact contact, GSList* groups) { if (contact->groups) { g_slist_free_full(contact->groups, g_free); @@ -121,9 +122,9 @@ p_contact_set_groups(const PContact contact, GSList *groups) } gboolean -p_contact_in_group(const PContact contact, const char *const group) +p_contact_in_group(const PContact contact, const char* const group) { - GSList *groups = contact->groups; + GSList* groups = contact->groups; while (groups) { if (strcmp(groups->data, group) == 0) { return TRUE; @@ -141,7 +142,7 @@ p_contact_groups(const PContact contact) } gboolean -p_contact_remove_resource(PContact contact, const char *const resource) +p_contact_remove_resource(PContact contact, const char* const resource) { gboolean result = g_hash_table_remove(contact->available_resources, resource); autocomplete_remove(contact->resource_ac, resource); @@ -209,12 +210,12 @@ p_contact_name_or_jid(const PContact contact) } char* -p_contact_create_display_string(const PContact contact, const char *const resource) +p_contact_create_display_string(const PContact contact, const char* const resource) { - GString *result_str = g_string_new(""); + GString* result_str = g_string_new(""); // use nickname if exists - const char *display_name = p_contact_name_or_jid(contact); + const char* display_name = p_contact_name_or_jid(contact); g_string_append(result_str, display_name); // add resource if not default provided by profanity @@ -224,14 +225,14 @@ p_contact_create_display_string(const PContact contact, const char *const resour g_string_append(result_str, ")"); } - char *result = result_str->str; + char* result = result_str->str; g_string_free(result_str, FALSE); return result; } static Resource* -_highest_presence(Resource *first, Resource *second) +_highest_presence(Resource* first, Resource* second) { if (first->presence == RESOURCE_CHAT) { return first; @@ -264,10 +265,10 @@ _get_most_available_resource(PContact contact) // away // xa // dnd - GList *resources = g_hash_table_get_values(contact->available_resources); - GList *curr = resources; - Resource *current = curr->data; - Resource *highest = current; + GList* resources = g_hash_table_get_values(contact->available_resources); + GList* curr = resources; + Resource* current = curr->data; + Resource* highest = current; curr = g_list_next(curr); while (curr) { current = curr->data; @@ -276,7 +277,7 @@ _get_most_available_resource(PContact contact) if (current->priority == highest->priority) { highest = _highest_presence(highest, current); - // priority higher than current highest, set new presence + // priority higher than current highest, set new presence } else if (current->priority > highest->priority) { highest = current; } @@ -298,7 +299,7 @@ p_contact_presence(const PContact contact) return "offline"; } - Resource *resource = _get_most_available_resource(contact); + Resource* resource = _get_most_available_resource(contact); return string_from_resource_presence(resource->presence); } @@ -313,7 +314,7 @@ p_contact_status(const PContact contact) return contact->offline_message; } - Resource *resource = _get_most_available_resource(contact); + Resource* resource = _get_most_available_resource(contact); return resource->status; } @@ -339,7 +340,7 @@ p_contact_subscribed(const PContact contact) } Resource* -p_contact_get_resource(const PContact contact, const char *const resource) +p_contact_get_resource(const PContact contact, const char* const resource) { return g_hash_table_lookup(contact->available_resources, resource); } @@ -360,12 +361,12 @@ GList* p_contact_get_available_resources(const PContact contact) { assert(contact != NULL); - GList *resources = g_hash_table_get_values(contact->available_resources); - GList *ordered = NULL; + GList* resources = g_hash_table_get_values(contact->available_resources); + GList* ordered = NULL; - GList *curr_resource = resources; + GList* curr_resource = resources; while (curr_resource) { - Resource *resource = curr_resource->data; + Resource* resource = curr_resource->data; ordered = g_list_insert_sorted(ordered, resource, (GCompareFunc)resource_compare_availability); curr_resource = g_list_next(curr_resource); } @@ -384,9 +385,8 @@ p_contact_is_available(const PContact contact) } // if most available resource is CHAT or ONLINE, available - Resource *most_available = _get_most_available_resource(contact); - if ((most_available->presence == RESOURCE_ONLINE) || - (most_available->presence == RESOURCE_CHAT)) { + Resource* most_available = _get_most_available_resource(contact); + if ((most_available->presence == RESOURCE_ONLINE) || (most_available->presence == RESOURCE_CHAT)) { return TRUE; } else { return FALSE; @@ -400,14 +400,14 @@ p_contact_has_available_resource(const PContact contact) } void -p_contact_set_presence(const PContact contact, Resource *resource) +p_contact_set_presence(const PContact contact, Resource* resource) { g_hash_table_replace(contact->available_resources, strdup(resource->name), resource); autocomplete_add(contact->resource_ac, resource->name); } void -p_contact_set_subscription(const PContact contact, const char *const subscription) +p_contact_set_subscription(const PContact contact, const char* const subscription) { FREE_SET_NULL(contact->subscription); if (subscription) { @@ -422,7 +422,7 @@ p_contact_set_pending_out(const PContact contact, gboolean pending_out) } void -p_contact_set_last_activity(const PContact contact, GDateTime *last_activity) +p_contact_set_last_activity(const PContact contact, GDateTime* last_activity) { if (contact->last_activity) { g_date_time_unref(contact->last_activity); diff --git a/src/xmpp/contact.h b/src/xmpp/contact.h index 28b6e60c..26e73c1d 100644 --- a/src/xmpp/contact.h +++ b/src/xmpp/contact.h @@ -39,12 +39,12 @@ #include "tools/autocomplete.h" #include "xmpp/resource.h" -typedef struct p_contact_t *PContact; +typedef struct p_contact_t* PContact; -PContact p_contact_new(const char *const barejid, const char *const name, GSList *groups, - const char *const subscription, const char *const offline_message, gboolean pending_out); -void p_contact_add_resource(PContact contact, Resource *resource); -gboolean p_contact_remove_resource(PContact contact, const char *const resource); +PContact p_contact_new(const char* const barejid, const char* const name, GSList* groups, + const char* const subscription, const char* const offline_message, gboolean pending_out); +void p_contact_add_resource(PContact contact, Resource* resource); +gboolean p_contact_remove_resource(PContact contact, const char* const resource); void p_contact_free(PContact contact); const char* p_contact_barejid(PContact contact); const char* p_contact_barejid_collate_key(PContact contact); @@ -57,20 +57,20 @@ const char* p_contact_subscription(const PContact contact); GList* p_contact_get_available_resources(const PContact contact); GDateTime* p_contact_last_activity(const PContact contact); gboolean p_contact_pending_out(const PContact contact); -void p_contact_set_presence(const PContact contact, Resource *resource); -void p_contact_set_status(const PContact contact, const char *const status); -void p_contact_set_name(const PContact contact, const char *const name); -void p_contact_set_subscription(const PContact contact, const char *const subscription); +void p_contact_set_presence(const PContact contact, Resource* resource); +void p_contact_set_status(const PContact contact, const char* const status); +void p_contact_set_name(const PContact contact, const char* const name); +void p_contact_set_subscription(const PContact contact, const char* const subscription); void p_contact_set_pending_out(const PContact contact, gboolean pending_out); -void p_contact_set_last_activity(const PContact contact, GDateTime *last_activity); +void p_contact_set_last_activity(const PContact contact, GDateTime* last_activity); gboolean p_contact_is_available(const PContact contact); gboolean p_contact_has_available_resource(const PContact contact); -Resource* p_contact_get_resource(const PContact contact, const char *const resource); -void p_contact_set_groups(const PContact contact, GSList *groups); +Resource* p_contact_get_resource(const PContact contact, const char* const resource); +void p_contact_set_groups(const PContact contact, GSList* groups); GSList* p_contact_groups(const PContact contact); -gboolean p_contact_in_group(const PContact contact, const char *const group); +gboolean p_contact_in_group(const PContact contact, const char* const group); gboolean p_contact_subscribed(const PContact contact); -char* p_contact_create_display_string(const PContact contact, const char *const resource); +char* p_contact_create_display_string(const PContact contact, const char* const resource); Autocomplete p_contact_resource_ac(const PContact contact); void p_contact_resource_ac_reset(const PContact contact); diff --git a/src/xmpp/form.c b/src/xmpp/form.c index 0e778ad3..a1fa31d4 100644 --- a/src/xmpp/form.c +++ b/src/xmpp/form.c @@ -54,25 +54,22 @@ #include "xmpp/connection.h" static gboolean -_is_valid_form_element(xmpp_stanza_t *stanza) +_is_valid_form_element(xmpp_stanza_t* stanza) { - const char *name = xmpp_stanza_get_name(stanza); + const char* name = xmpp_stanza_get_name(stanza); if (g_strcmp0(name, STANZA_NAME_X) != 0) { log_error("Error parsing form, root element not <x/>."); return FALSE; } - const char *ns = xmpp_stanza_get_ns(stanza); + const char* ns = xmpp_stanza_get_ns(stanza); if (g_strcmp0(ns, STANZA_NS_DATA) != 0) { log_error("Error parsing form, namespace not %s.", STANZA_NS_DATA); return FALSE; } - const char *type = xmpp_stanza_get_type(stanza); - if ((g_strcmp0(type, "form") != 0) && - (g_strcmp0(type, "submit") != 0) && - (g_strcmp0(type, "cancel") != 0) && - (g_strcmp0(type, "result") != 0)) { + const char* type = xmpp_stanza_get_type(stanza); + if ((g_strcmp0(type, "form") != 0) && (g_strcmp0(type, "submit") != 0) && (g_strcmp0(type, "cancel") != 0) && (g_strcmp0(type, "result") != 0)) { log_error("Error parsing form, unknown type."); return FALSE; } @@ -83,7 +80,7 @@ _is_valid_form_element(xmpp_stanza_t *stanza) static DataForm* _form_new(void) { - DataForm *form = calloc(1, sizeof(DataForm)); + DataForm* form = calloc(1, sizeof(DataForm)); return form; } @@ -91,20 +88,20 @@ _form_new(void) static FormField* _field_new(void) { - FormField *field = calloc(1, sizeof(FormField)); + FormField* field = calloc(1, sizeof(FormField)); return field; } static char* -_get_property(xmpp_stanza_t *const stanza, const char *const property) +_get_property(xmpp_stanza_t* const stanza, const char* const property) { - char *result = NULL; - xmpp_ctx_t *ctx = connection_get_ctx(); + char* result = NULL; + xmpp_ctx_t* ctx = connection_get_ctx(); - xmpp_stanza_t *child = xmpp_stanza_get_child_by_name(stanza, property); + xmpp_stanza_t* child = xmpp_stanza_get_child_by_name(stanza, property); if (child) { - char *child_text = xmpp_stanza_get_text(child); + char* child_text = xmpp_stanza_get_text(child); if (child_text) { result = strdup(child_text); xmpp_free(ctx, child_text); @@ -115,9 +112,9 @@ _get_property(xmpp_stanza_t *const stanza, const char *const property) } static char* -_get_attr(xmpp_stanza_t *const stanza, const char *const attr) +_get_attr(xmpp_stanza_t* const stanza, const char* const attr) { - const char *result = xmpp_stanza_get_attribute(stanza, attr); + const char* result = xmpp_stanza_get_attribute(stanza, attr); if (result) { return strdup(result); } else { @@ -126,9 +123,9 @@ _get_attr(xmpp_stanza_t *const stanza, const char *const attr) } static gboolean -_is_required(xmpp_stanza_t *const stanza) +_is_required(xmpp_stanza_t* const stanza) { - xmpp_stanza_t *child = xmpp_stanza_get_child_by_name(stanza, "required"); + xmpp_stanza_t* child = xmpp_stanza_get_child_by_name(stanza, "required"); if (child) { return TRUE; } else { @@ -137,7 +134,7 @@ _is_required(xmpp_stanza_t *const stanza) } static form_field_type_t -_get_field_type(const char *const type) +_get_field_type(const char* const type) { if (g_strcmp0(type, "hidden") == 0) { return FIELD_HIDDEN; @@ -173,15 +170,15 @@ _get_field_type(const char *const type) } DataForm* -form_create(xmpp_stanza_t *const form_stanza) +form_create(xmpp_stanza_t* const form_stanza) { - xmpp_ctx_t *ctx = connection_get_ctx(); + xmpp_ctx_t* ctx = connection_get_ctx(); if (!_is_valid_form_element(form_stanza)) { return NULL; } - DataForm *form = _form_new(); + DataForm* form = _form_new(); form->type = _get_attr(form_stanza, "type"); form->title = _get_property(form_stanza, "title"); form->instructions = _get_property(form_stanza, "instructions"); @@ -193,13 +190,13 @@ form_create(xmpp_stanza_t *const form_stanza) int tag_num = 1; // get fields - xmpp_stanza_t *form_child = xmpp_stanza_get_children(form_stanza); + xmpp_stanza_t* form_child = xmpp_stanza_get_children(form_stanza); while (form_child) { - const char *child_name = xmpp_stanza_get_name(form_child); + const char* child_name = xmpp_stanza_get_name(form_child); if (g_strcmp0(child_name, "field") == 0) { - xmpp_stanza_t *field_stanza = form_child; + xmpp_stanza_t* field_stanza = form_child; - FormField *field = _field_new(); + FormField* field = _field_new(); field->label = _get_attr(field_stanza, "label"); field->type = _get_attr(field_stanza, "type"); field->type_t = _get_field_type(field->type); @@ -208,7 +205,7 @@ form_create(xmpp_stanza_t *const form_stanza) field->var = _get_attr(field_stanza, "var"); if (field->type_t != FIELD_HIDDEN && field->var) { - GString *tag = g_string_new(""); + GString* tag = g_string_new(""); g_string_printf(tag, "field%d", tag_num++); g_hash_table_insert(form->var_to_tag, strdup(field->var), strdup(tag->str)); g_hash_table_insert(form->tag_to_var, strdup(tag->str), strdup(field->var)); @@ -220,19 +217,19 @@ form_create(xmpp_stanza_t *const form_stanza) field->required = _is_required(field_stanza); // handle repeated field children - xmpp_stanza_t *field_child = xmpp_stanza_get_children(field_stanza); + xmpp_stanza_t* field_child = xmpp_stanza_get_children(field_stanza); int value_index = 1; while (field_child) { child_name = xmpp_stanza_get_name(field_child); // handle values if (g_strcmp0(child_name, "value") == 0) { - char *value = xmpp_stanza_get_text(field_child); + char* value = xmpp_stanza_get_text(field_child); if (value) { field->values = g_slist_append(field->values, strdup(value)); if (field->type_t == FIELD_TEXT_MULTI) { - GString *ac_val = g_string_new(""); + GString* ac_val = g_string_new(""); g_string_printf(ac_val, "val%d", value_index++); autocomplete_add(field->value_ac, ac_val->str); g_string_free(ac_val, TRUE); @@ -244,9 +241,9 @@ form_create(xmpp_stanza_t *const form_stanza) xmpp_free(ctx, value); } - // handle options + // handle options } else if (g_strcmp0(child_name, "option") == 0) { - FormOption *option = malloc(sizeof(FormOption)); + FormOption* option = malloc(sizeof(FormOption)); option->label = _get_attr(field_child, "label"); option->value = _get_property(field_child, "value"); @@ -270,74 +267,74 @@ form_create(xmpp_stanza_t *const form_stanza) } xmpp_stanza_t* -form_create_submission(DataForm *form) +form_create_submission(DataForm* form) { - xmpp_ctx_t *ctx = connection_get_ctx(); + xmpp_ctx_t* ctx = connection_get_ctx(); - xmpp_stanza_t *x = xmpp_stanza_new(ctx); + xmpp_stanza_t* x = xmpp_stanza_new(ctx); xmpp_stanza_set_name(x, STANZA_NAME_X); xmpp_stanza_set_ns(x, STANZA_NS_DATA); xmpp_stanza_set_type(x, "submit"); - GSList *curr_field = form->fields; + GSList* curr_field = form->fields; while (curr_field) { - FormField *field = curr_field->data; + FormField* field = curr_field->data; if (field->type_t != FIELD_FIXED) { - xmpp_stanza_t *field_stanza = xmpp_stanza_new(ctx); + xmpp_stanza_t* field_stanza = xmpp_stanza_new(ctx); xmpp_stanza_set_name(field_stanza, "field"); xmpp_stanza_set_attribute(field_stanza, "var", field->var); - xmpp_stanza_t *value_stanza = NULL; - GSList *curr_value = NULL; + xmpp_stanza_t* value_stanza = NULL; + GSList* curr_value = NULL; switch (field->type_t) { - case FIELD_HIDDEN: - case FIELD_TEXT_SINGLE: - case FIELD_TEXT_PRIVATE: - case FIELD_BOOLEAN: - case FIELD_LIST_SINGLE: - case FIELD_JID_SINGLE: + case FIELD_HIDDEN: + case FIELD_TEXT_SINGLE: + case FIELD_TEXT_PRIVATE: + case FIELD_BOOLEAN: + case FIELD_LIST_SINGLE: + case FIELD_JID_SINGLE: + value_stanza = xmpp_stanza_new(ctx); + xmpp_stanza_set_name(value_stanza, "value"); + if (field->values) { + if (field->values->data) { + xmpp_stanza_t* text_stanza = xmpp_stanza_new(ctx); + xmpp_stanza_set_text(text_stanza, field->values->data); + xmpp_stanza_add_child(value_stanza, text_stanza); + xmpp_stanza_release(text_stanza); + } + } + xmpp_stanza_add_child(field_stanza, value_stanza); + xmpp_stanza_release(value_stanza); + + break; + + case FIELD_TEXT_MULTI: + case FIELD_LIST_MULTI: + case FIELD_JID_MULTI: + curr_value = field->values; + while (curr_value) { + char* value = curr_value->data; + value_stanza = xmpp_stanza_new(ctx); xmpp_stanza_set_name(value_stanza, "value"); - if (field->values) { - if (field->values->data) { - xmpp_stanza_t *text_stanza = xmpp_stanza_new(ctx); - xmpp_stanza_set_text(text_stanza, field->values->data); - xmpp_stanza_add_child(value_stanza, text_stanza); - xmpp_stanza_release(text_stanza); - } + if (value) { + xmpp_stanza_t* text_stanza = xmpp_stanza_new(ctx); + xmpp_stanza_set_text(text_stanza, value); + xmpp_stanza_add_child(value_stanza, text_stanza); + xmpp_stanza_release(text_stanza); } + xmpp_stanza_add_child(field_stanza, value_stanza); xmpp_stanza_release(value_stanza); - break; - - case FIELD_TEXT_MULTI: - case FIELD_LIST_MULTI: - case FIELD_JID_MULTI: - curr_value = field->values; - while (curr_value) { - char *value = curr_value->data; - - value_stanza = xmpp_stanza_new(ctx); - xmpp_stanza_set_name(value_stanza, "value"); - if (value) { - xmpp_stanza_t *text_stanza = xmpp_stanza_new(ctx); - xmpp_stanza_set_text(text_stanza, value); - xmpp_stanza_add_child(value_stanza, text_stanza); - xmpp_stanza_release(text_stanza); - } - - xmpp_stanza_add_child(field_stanza, value_stanza); - xmpp_stanza_release(value_stanza); - - curr_value = g_slist_next(curr_value); - } - break; - case FIELD_FIXED: - default: - break; + curr_value = g_slist_next(curr_value); + } + break; + case FIELD_FIXED: + default: + break; } xmpp_stanza_add_child(x, field_stanza); @@ -351,7 +348,7 @@ form_create_submission(DataForm *form) } static void -_free_option(FormOption *option) +_free_option(FormOption* option) { if (option) { free(option->label); @@ -361,7 +358,7 @@ _free_option(FormOption *option) } static void -_free_field(FormField *field) +_free_field(FormField* field) { if (field) { free(field->label); @@ -376,7 +373,7 @@ _free_field(FormField *field) } void -form_destroy(DataForm *form) +form_destroy(DataForm* form) { if (form) { free(form->type); @@ -391,18 +388,18 @@ form_destroy(DataForm *form) } static int -_field_compare_by_var(FormField *a, FormField *b) +_field_compare_by_var(FormField* a, FormField* b) { return g_strcmp0(a->var, b->var); } GSList* -form_get_non_form_type_fields_sorted(DataForm *form) +form_get_non_form_type_fields_sorted(DataForm* form) { - GSList *sorted = NULL; - GSList *curr = form->fields; + GSList* sorted = NULL; + GSList* curr = form->fields; while (curr) { - FormField *field = curr->data; + FormField* field = curr->data; if (g_strcmp0(field->var, "FORM_TYPE") != 0) { sorted = g_slist_insert_sorted(sorted, field, (GCompareFunc)_field_compare_by_var); } @@ -413,12 +410,12 @@ form_get_non_form_type_fields_sorted(DataForm *form) } GSList* -form_get_field_values_sorted(FormField *field) +form_get_field_values_sorted(FormField* field) { - GSList *sorted = NULL; - GSList *curr = field->values; + GSList* sorted = NULL; + GSList* curr = field->values; while (curr) { - char *value = curr->data; + char* value = curr->data; if (value) { sorted = g_slist_insert_sorted(sorted, value, (GCompareFunc)g_strcmp0); } @@ -429,11 +426,11 @@ form_get_field_values_sorted(FormField *field) } char* -form_get_form_type_field(DataForm *form) +form_get_form_type_field(DataForm* form) { - GSList *curr = form->fields; + GSList* curr = form->fields; while (curr) { - FormField *field = curr->data; + FormField* field = curr->data; if (g_strcmp0(field->var, "FORM_TYPE") == 0) { return field->values->data; } @@ -444,10 +441,10 @@ form_get_form_type_field(DataForm *form) } gboolean -form_tag_exists(DataForm *form, const char *const tag) +form_tag_exists(DataForm* form, const char* const tag) { - GList *tags = g_hash_table_get_keys(form->tag_to_var); - GList *curr = tags; + GList* tags = g_hash_table_get_keys(form->tag_to_var); + GList* curr = tags; while (curr) { if (g_strcmp0(curr->data, tag) == 0) { return TRUE; @@ -460,13 +457,13 @@ form_tag_exists(DataForm *form, const char *const tag) } form_field_type_t -form_get_field_type(DataForm *form, const char *const tag) +form_get_field_type(DataForm* form, const char* const tag) { - char *var = g_hash_table_lookup(form->tag_to_var, tag); + char* var = g_hash_table_lookup(form->tag_to_var, tag); if (var) { - GSList *curr = form->fields; + GSList* curr = form->fields; while (curr) { - FormField *field = curr->data; + FormField* field = curr->data; if (g_strcmp0(field->var, var) == 0) { return field->type_t; } @@ -477,13 +474,13 @@ form_get_field_type(DataForm *form, const char *const tag) } void -form_set_value(DataForm *form, const char *const tag, char *value) +form_set_value(DataForm* form, const char* const tag, char* value) { - char *var = g_hash_table_lookup(form->tag_to_var, tag); + char* var = g_hash_table_lookup(form->tag_to_var, tag); if (var) { - GSList *curr = form->fields; + GSList* curr = form->fields; while (curr) { - FormField *field = curr->data; + FormField* field = curr->data; if (g_strcmp0(field->var, var) == 0) { if (g_slist_length(field->values) == 0) { field->values = g_slist_append(field->values, strdup(value)); @@ -502,18 +499,18 @@ form_set_value(DataForm *form, const char *const tag, char *value) } void -form_add_value(DataForm *form, const char *const tag, char *value) +form_add_value(DataForm* form, const char* const tag, char* value) { - char *var = g_hash_table_lookup(form->tag_to_var, tag); + char* var = g_hash_table_lookup(form->tag_to_var, tag); if (var) { - GSList *curr = form->fields; + GSList* curr = form->fields; while (curr) { - FormField *field = curr->data; + FormField* field = curr->data; if (g_strcmp0(field->var, var) == 0) { field->values = g_slist_append(field->values, strdup(value)); if (field->type_t == FIELD_TEXT_MULTI) { int total = g_slist_length(field->values); - GString *value_index = g_string_new(""); + GString* value_index = g_string_new(""); g_string_printf(value_index, "val%d", total); autocomplete_add(field->value_ac, value_index->str); g_string_free(value_index, TRUE); @@ -527,15 +524,15 @@ form_add_value(DataForm *form, const char *const tag, char *value) } gboolean -form_add_unique_value(DataForm *form, const char *const tag, char *value) +form_add_unique_value(DataForm* form, const char* const tag, char* value) { - char *var = g_hash_table_lookup(form->tag_to_var, tag); + char* var = g_hash_table_lookup(form->tag_to_var, tag); if (var) { - GSList *curr = form->fields; + GSList* curr = form->fields; while (curr) { - FormField *field = curr->data; + FormField* field = curr->data; if (g_strcmp0(field->var, var) == 0) { - GSList *curr_value = field->values; + GSList* curr_value = field->values; while (curr_value) { if (g_strcmp0(curr_value->data, value) == 0) { return FALSE; @@ -558,15 +555,15 @@ form_add_unique_value(DataForm *form, const char *const tag, char *value) } gboolean -form_remove_value(DataForm *form, const char *const tag, char *value) +form_remove_value(DataForm* form, const char* const tag, char* value) { - char *var = g_hash_table_lookup(form->tag_to_var, tag); + char* var = g_hash_table_lookup(form->tag_to_var, tag); if (var) { - GSList *curr = form->fields; + GSList* curr = form->fields; while (curr) { - FormField *field = curr->data; + FormField* field = curr->data; if (g_strcmp0(field->var, var) == 0) { - GSList *found = g_slist_find_custom(field->values, value, (GCompareFunc)g_strcmp0); + GSList* found = g_slist_find_custom(field->values, value, (GCompareFunc)g_strcmp0); if (found) { free(found->data); found->data = NULL; @@ -588,22 +585,22 @@ form_remove_value(DataForm *form, const char *const tag, char *value) } gboolean -form_remove_text_multi_value(DataForm *form, const char *const tag, int index) +form_remove_text_multi_value(DataForm* form, const char* const tag, int index) { index--; - char *var = g_hash_table_lookup(form->tag_to_var, tag); + char* var = g_hash_table_lookup(form->tag_to_var, tag); if (var) { - GSList *curr = form->fields; + GSList* curr = form->fields; while (curr) { - FormField *field = curr->data; + FormField* field = curr->data; if (g_strcmp0(field->var, var) == 0) { - GSList *item = g_slist_nth(field->values, index); + GSList* item = g_slist_nth(field->values, index); if (item) { free(item->data); item->data = NULL; field->values = g_slist_delete_link(field->values, item); - GString *value_index = g_string_new(""); - g_string_printf(value_index, "val%d", index+1); + GString* value_index = g_string_new(""); + g_string_printf(value_index, "val%d", index + 1); autocomplete_remove(field->value_ac, value_index->str); g_string_free(value_index, TRUE); form->modified = TRUE; @@ -620,13 +617,13 @@ form_remove_text_multi_value(DataForm *form, const char *const tag, int index) } int -form_get_value_count(DataForm *form, const char *const tag) +form_get_value_count(DataForm* form, const char* const tag) { - char *var = g_hash_table_lookup(form->tag_to_var, tag); + char* var = g_hash_table_lookup(form->tag_to_var, tag); if (var) { - GSList *curr = form->fields; + GSList* curr = form->fields; while (curr) { - FormField *field = curr->data; + FormField* field = curr->data; if (g_strcmp0(field->var, var) == 0) { if ((g_slist_length(field->values) == 1) && (field->values->data == NULL)) { return 0; @@ -642,17 +639,17 @@ form_get_value_count(DataForm *form, const char *const tag) } gboolean -form_field_contains_option(DataForm *form, const char *const tag, char *value) +form_field_contains_option(DataForm* form, const char* const tag, char* value) { - char *var = g_hash_table_lookup(form->tag_to_var, tag); + char* var = g_hash_table_lookup(form->tag_to_var, tag); if (var) { - GSList *curr = form->fields; + GSList* curr = form->fields; while (curr) { - FormField *field = curr->data; + FormField* field = curr->data; if (g_strcmp0(field->var, var) == 0) { - GSList *curr_option = field->options; + GSList* curr_option = field->options; while (curr_option) { - FormOption *option = curr_option->data; + FormOption* option = curr_option->data; if (g_strcmp0(option->value, value) == 0) { return TRUE; } @@ -667,13 +664,13 @@ form_field_contains_option(DataForm *form, const char *const tag, char *value) } FormField* -form_get_field_by_tag(DataForm *form, const char *const tag) +form_get_field_by_tag(DataForm* form, const char* const tag) { - char *var = g_hash_table_lookup(form->tag_to_var, tag); + char* var = g_hash_table_lookup(form->tag_to_var, tag); if (var) { - GSList *curr = form->fields; + GSList* curr = form->fields; while (curr) { - FormField *field = curr->data; + FormField* field = curr->data; if (g_strcmp0(field->var, var) == 0) { return field; } @@ -684,13 +681,13 @@ form_get_field_by_tag(DataForm *form, const char *const tag) } Autocomplete -form_get_value_ac(DataForm *form, const char *const tag) +form_get_value_ac(DataForm* form, const char* const tag) { - char *var = g_hash_table_lookup(form->tag_to_var, tag); + char* var = g_hash_table_lookup(form->tag_to_var, tag); if (var) { - GSList *curr = form->fields; + GSList* curr = form->fields; while (curr) { - FormField *field = curr->data; + FormField* field = curr->data; if (g_strcmp0(field->var, var) == 0) { return field->value_ac; } @@ -701,12 +698,12 @@ form_get_value_ac(DataForm *form, const char *const tag) } void -form_reset_autocompleters(DataForm *form) +form_reset_autocompleters(DataForm* form) { autocomplete_reset(form->tag_ac); - GSList *curr_field = form->fields; + GSList* curr_field = form->fields; while (curr_field) { - FormField *field = curr_field->data; + FormField* field = curr_field->data; autocomplete_reset(field->value_ac); curr_field = g_slist_next(curr_field); } diff --git a/src/xmpp/form.h b/src/xmpp/form.h index 4b61b4c2..b305addf 100644 --- a/src/xmpp/form.h +++ b/src/xmpp/form.h @@ -46,10 +46,10 @@ #include "xmpp/xmpp.h" -DataForm* form_create(xmpp_stanza_t *const stanza); -xmpp_stanza_t* form_create_submission(DataForm *form); -char* form_get_form_type_field(DataForm *form); -GSList* form_get_non_form_type_fields_sorted(DataForm *form); -GSList* form_get_field_values_sorted(FormField *field); +DataForm* form_create(xmpp_stanza_t* const stanza); +xmpp_stanza_t* form_create_submission(DataForm* form); +char* form_get_form_type_field(DataForm* form); +GSList* form_get_non_form_type_fields_sorted(DataForm* form); +GSList* form_get_field_values_sorted(FormField* field); #endif diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index 75bd73a1..d583eda0 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -77,91 +77,96 @@ #include "omemo/omemo.h" #endif -typedef struct p_room_info_data_t { - char *room; +typedef struct p_room_info_data_t +{ + char* room; gboolean display; } ProfRoomInfoData; -typedef struct p_iq_handle_t { +typedef struct p_iq_handle_t +{ ProfIqCallback func; ProfIqFreeCallback free_func; - void *userdata; + void* userdata; } ProfIqHandler; -typedef struct privilege_set_t { - char *item; - char *privilege; +typedef struct privilege_set_t +{ + char* item; + char* privilege; } ProfPrivilegeSet; -typedef struct affiliation_list_t { - char *affiliation; +typedef struct affiliation_list_t +{ + char* affiliation; bool show_ui_message; } ProfAffiliationList; -typedef struct command_config_data_t { - char *sessionid; - char *command; +typedef struct command_config_data_t +{ + char* sessionid; + char* command; } CommandConfigData; -static int _iq_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata); - -static void _error_handler(xmpp_stanza_t *const stanza); -static void _disco_info_get_handler(xmpp_stanza_t *const stanza); -static void _disco_items_get_handler(xmpp_stanza_t *const stanza); -static void _disco_items_result_handler(xmpp_stanza_t *const stanza); -static void _last_activity_get_handler(xmpp_stanza_t *const stanza); -static void _version_get_handler(xmpp_stanza_t *const stanza); -static void _ping_get_handler(xmpp_stanza_t *const stanza); - -static int _version_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata); -static int _disco_info_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata); -static int _disco_info_response_id_handler_onconnect(xmpp_stanza_t *const stanza, void *const userdata); -static int _http_upload_response_id_handler(xmpp_stanza_t *const stanza, void *const upload_ctx); -static int _last_activity_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata); -static int _room_info_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata); -static int _destroy_room_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata); -static int _room_config_id_handler(xmpp_stanza_t *const stanza, void *const userdata); -static int _room_config_submit_id_handler(xmpp_stanza_t *const stanza, void *const userdata); -static int _room_affiliation_list_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata); -static int _room_affiliation_set_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata); -static int _room_role_set_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata); -static int _room_role_list_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata); -static int _room_kick_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata); -static int _enable_carbons_id_handler(xmpp_stanza_t *const stanza, void *const userdata); -static int _disable_carbons_id_handler(xmpp_stanza_t *const stanza, void *const userdata); -static int _manual_pong_id_handler(xmpp_stanza_t *const stanza, void *const userdata); -static int _caps_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata); -static int _caps_response_for_jid_id_handler(xmpp_stanza_t *const stanza, void *const userdata); -static int _caps_response_legacy_id_handler(xmpp_stanza_t *const stanza, void *const userdata); -static int _auto_pong_id_handler(xmpp_stanza_t *const stanza, void *const userdata); -static int _room_list_id_handler(xmpp_stanza_t *const stanza, void *const userdata); -static int _command_list_result_handler(xmpp_stanza_t *const stanza, void *const userdata); -static int _command_exec_response_handler(xmpp_stanza_t *const stanza, void *const userdata); - -static void _iq_free_room_data(ProfRoomInfoData *roominfo); -static void _iq_free_affiliation_set(ProfPrivilegeSet *affiliation_set); -static void _iq_free_affiliation_list(ProfAffiliationList *affiliation_list); -static void _iq_id_handler_free(ProfIqHandler *handler); +static int _iq_handler(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void* const userdata); + +static void _error_handler(xmpp_stanza_t* const stanza); +static void _disco_info_get_handler(xmpp_stanza_t* const stanza); +static void _disco_items_get_handler(xmpp_stanza_t* const stanza); +static void _disco_items_result_handler(xmpp_stanza_t* const stanza); +static void _last_activity_get_handler(xmpp_stanza_t* const stanza); +static void _version_get_handler(xmpp_stanza_t* const stanza); +static void _ping_get_handler(xmpp_stanza_t* const stanza); + +static int _version_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata); +static int _disco_info_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata); +static int _disco_info_response_id_handler_onconnect(xmpp_stanza_t* const stanza, void* const userdata); +static int _http_upload_response_id_handler(xmpp_stanza_t* const stanza, void* const upload_ctx); +static int _last_activity_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata); +static int _room_info_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata); +static int _destroy_room_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata); +static int _room_config_id_handler(xmpp_stanza_t* const stanza, void* const userdata); +static int _room_config_submit_id_handler(xmpp_stanza_t* const stanza, void* const userdata); +static int _room_affiliation_list_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata); +static int _room_affiliation_set_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata); +static int _room_role_set_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata); +static int _room_role_list_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata); +static int _room_kick_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata); +static int _enable_carbons_id_handler(xmpp_stanza_t* const stanza, void* const userdata); +static int _disable_carbons_id_handler(xmpp_stanza_t* const stanza, void* const userdata); +static int _manual_pong_id_handler(xmpp_stanza_t* const stanza, void* const userdata); +static int _caps_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata); +static int _caps_response_for_jid_id_handler(xmpp_stanza_t* const stanza, void* const userdata); +static int _caps_response_legacy_id_handler(xmpp_stanza_t* const stanza, void* const userdata); +static int _auto_pong_id_handler(xmpp_stanza_t* const stanza, void* const userdata); +static int _room_list_id_handler(xmpp_stanza_t* const stanza, void* const userdata); +static int _command_list_result_handler(xmpp_stanza_t* const stanza, void* const userdata); +static int _command_exec_response_handler(xmpp_stanza_t* const stanza, void* const userdata); + +static void _iq_free_room_data(ProfRoomInfoData* roominfo); +static void _iq_free_affiliation_set(ProfPrivilegeSet* affiliation_set); +static void _iq_free_affiliation_list(ProfAffiliationList* affiliation_list); +static void _iq_id_handler_free(ProfIqHandler* handler); // scheduled -static int _autoping_timed_send(xmpp_conn_t *const conn, void *const userdata); +static int _autoping_timed_send(xmpp_conn_t* const conn, void* const userdata); -static void _identity_destroy(DiscoIdentity *identity); -static void _item_destroy(DiscoItem *item); +static void _identity_destroy(DiscoIdentity* identity); +static void _item_destroy(DiscoItem* item); static gboolean autoping_wait = FALSE; -static GTimer *autoping_time = NULL; -static GHashTable *id_handlers; -static GHashTable *rooms_cache = NULL; +static GTimer* autoping_time = NULL; +static GHashTable* id_handlers; +static GHashTable* rooms_cache = NULL; static int -_iq_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata) +_iq_handler(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void* const userdata) { log_debug("iq stanza handler fired"); iq_autoping_timer_cancel(); // reset the autoping timer - char *text; + char* text; size_t text_size; xmpp_stanza_to_text(stanza, &text, &text_size); gboolean cont = plugins_on_iq_stanza_receive(text); @@ -170,18 +175,18 @@ _iq_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const us return 1; } - const char *type = xmpp_stanza_get_type(stanza); + const char* type = xmpp_stanza_get_type(stanza); if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { _error_handler(stanza); } - xmpp_stanza_t *discoinfo = xmpp_stanza_get_child_by_ns(stanza, XMPP_NS_DISCO_INFO); + xmpp_stanza_t* discoinfo = xmpp_stanza_get_child_by_ns(stanza, XMPP_NS_DISCO_INFO); if (discoinfo && (g_strcmp0(type, STANZA_TYPE_GET) == 0)) { _disco_info_get_handler(stanza); } - xmpp_stanza_t *discoitems = xmpp_stanza_get_child_by_ns(stanza, XMPP_NS_DISCO_ITEMS); + xmpp_stanza_t* discoitems = xmpp_stanza_get_child_by_ns(stanza, XMPP_NS_DISCO_ITEMS); if (discoitems && (g_strcmp0(type, STANZA_TYPE_GET) == 0)) { _disco_items_get_handler(stanza); } @@ -189,22 +194,22 @@ _iq_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const us _disco_items_result_handler(stanza); } - xmpp_stanza_t *lastactivity = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_LASTACTIVITY); + xmpp_stanza_t* lastactivity = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_LASTACTIVITY); if (lastactivity && (g_strcmp0(type, STANZA_TYPE_GET) == 0)) { _last_activity_get_handler(stanza); } - xmpp_stanza_t *version = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_VERSION); + xmpp_stanza_t* version = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_VERSION); if (version && (g_strcmp0(type, STANZA_TYPE_GET) == 0)) { _version_get_handler(stanza); } - xmpp_stanza_t *ping = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PING); + xmpp_stanza_t* ping = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PING); if (ping && (g_strcmp0(type, STANZA_TYPE_GET) == 0)) { _ping_get_handler(stanza); } - xmpp_stanza_t *roster = xmpp_stanza_get_child_by_ns(stanza, XMPP_NS_ROSTER); + xmpp_stanza_t* roster = xmpp_stanza_get_child_by_ns(stanza, XMPP_NS_ROSTER); if (roster && (g_strcmp0(type, STANZA_TYPE_SET) == 0)) { roster_set_handler(stanza); } @@ -212,14 +217,14 @@ _iq_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const us roster_result_handler(stanza); } - xmpp_stanza_t *blocking = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_BLOCKING); + xmpp_stanza_t* blocking = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_BLOCKING); if (blocking && (g_strcmp0(type, STANZA_TYPE_SET) == 0)) { blocked_set_handler(stanza); } - const char *id = xmpp_stanza_get_id(stanza); + const char* id = xmpp_stanza_get_id(stanza); if (id) { - ProfIqHandler *handler = g_hash_table_lookup(id_handlers, id); + ProfIqHandler* handler = g_hash_table_lookup(id_handlers, id); if (handler) { int keep = handler->func(stanza, handler->userdata); if (!keep) { @@ -234,8 +239,8 @@ _iq_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const us void iq_handlers_init(void) { - xmpp_conn_t * const conn = connection_get_conn(); - xmpp_ctx_t * const ctx = connection_get_ctx(); + xmpp_conn_t* const conn = connection_get_conn(); + xmpp_ctx_t* const ctx = connection_get_ctx(); xmpp_handler_add(conn, _iq_handler, NULL, STANZA_NAME_IQ, NULL, ctx); if (prefs_get_autoping() != 0) { @@ -260,7 +265,7 @@ iq_handlers_clear() } static void -_iq_id_handler_free(ProfIqHandler *handler) +_iq_id_handler_free(ProfIqHandler* handler) { if (handler == NULL) { return; @@ -272,9 +277,9 @@ _iq_id_handler_free(ProfIqHandler *handler) } void -iq_id_handler_add(const char *const id, ProfIqCallback func, ProfIqFreeCallback free_func, void *userdata) +iq_id_handler_add(const char* const id, ProfIqCallback func, ProfIqFreeCallback free_func, void* userdata) { - ProfIqHandler *handler = malloc(sizeof(ProfIqHandler)); + ProfIqHandler* handler = malloc(sizeof(ProfIqHandler)); handler->func = func; handler->free_func = free_func; handler->userdata = userdata; @@ -325,7 +330,7 @@ iq_set_autoping(const int seconds) return; } - xmpp_conn_t * const conn = connection_get_conn(); + xmpp_conn_t* const conn = connection_get_conn(); xmpp_timed_handler_delete(conn, _autoping_timed_send); if (seconds == 0) { @@ -333,7 +338,7 @@ iq_set_autoping(const int seconds) } int millis = seconds * 1000; - xmpp_ctx_t * const ctx = connection_get_ctx(); + xmpp_ctx_t* const ctx = connection_get_ctx(); xmpp_timed_handler_add(conn, _autoping_timed_send, millis, ctx); } @@ -348,7 +353,7 @@ iq_rooms_cache_clear(void) } void -iq_room_list_request(gchar *conferencejid, gchar *filter) +iq_room_list_request(gchar* conferencejid, gchar* filter) { if (g_hash_table_contains(rooms_cache, conferencejid)) { log_debug("Rooms request cached for: %s", conferencejid); @@ -358,9 +363,9 @@ iq_room_list_request(gchar *conferencejid, gchar *filter) log_debug("Rooms request not cached for: %s", conferencejid); - xmpp_ctx_t * const ctx = connection_get_ctx(); - char *id = connection_create_stanza_id(); - xmpp_stanza_t *iq = stanza_create_disco_items_iq(ctx, id, conferencejid, NULL); + xmpp_ctx_t* const ctx = connection_get_ctx(); + char* id = connection_create_stanza_id(); + xmpp_stanza_t* iq = stanza_create_disco_items_iq(ctx, id, conferencejid, NULL); iq_id_handler_add(id, _room_list_id_handler, NULL, filter); @@ -371,9 +376,9 @@ iq_room_list_request(gchar *conferencejid, gchar *filter) void iq_enable_carbons(void) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - xmpp_stanza_t *iq = stanza_enable_carbons(ctx); - const char *id = xmpp_stanza_get_id(iq); + xmpp_ctx_t* const ctx = connection_get_ctx(); + xmpp_stanza_t* iq = stanza_enable_carbons(ctx); + const char* id = xmpp_stanza_get_id(iq); iq_id_handler_add(id, _enable_carbons_id_handler, NULL, NULL); @@ -384,9 +389,9 @@ iq_enable_carbons(void) void iq_disable_carbons(void) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - xmpp_stanza_t *iq = stanza_disable_carbons(ctx); - const char *id = xmpp_stanza_get_id(iq); + xmpp_ctx_t* const ctx = connection_get_ctx(); + xmpp_stanza_t* iq = stanza_disable_carbons(ctx); + const char* id = xmpp_stanza_get_id(iq); iq_id_handler_add(id, _disable_carbons_id_handler, NULL, NULL); @@ -395,17 +400,17 @@ iq_disable_carbons(void) } void -iq_http_upload_request(HTTPUpload *upload) +iq_http_upload_request(HTTPUpload* upload) { - char *jid = connection_jid_for_feature(STANZA_NS_HTTP_UPLOAD); + char* jid = connection_jid_for_feature(STANZA_NS_HTTP_UPLOAD); if (jid == NULL) { cons_show_error("XEP-0363 HTTP File Upload is not supported by the server"); return; } - xmpp_ctx_t * const ctx = connection_get_ctx(); - char *id = connection_create_stanza_id(); - xmpp_stanza_t *iq = stanza_create_http_upload_request(ctx, id, jid, upload); + xmpp_ctx_t* const ctx = connection_get_ctx(); + char* id = connection_create_stanza_id(); + xmpp_stanza_t* iq = stanza_create_http_upload_request(ctx, id, jid, upload); iq_id_handler_add(id, _http_upload_response_id_handler, NULL, upload); free(id); @@ -416,11 +421,11 @@ iq_http_upload_request(HTTPUpload *upload) } void -iq_disco_info_request(gchar *jid) +iq_disco_info_request(gchar* jid) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - char *id = connection_create_stanza_id(); - xmpp_stanza_t *iq = stanza_create_disco_info_iq(ctx, id, jid, NULL); + xmpp_ctx_t* const ctx = connection_get_ctx(); + char* id = connection_create_stanza_id(); + xmpp_stanza_t* iq = stanza_create_disco_info_iq(ctx, id, jid, NULL); iq_id_handler_add(id, _disco_info_response_id_handler, NULL, NULL); @@ -431,11 +436,11 @@ iq_disco_info_request(gchar *jid) } void -iq_disco_info_request_onconnect(gchar *jid) +iq_disco_info_request_onconnect(gchar* jid) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - char *id = connection_create_stanza_id(); - xmpp_stanza_t *iq = stanza_create_disco_info_iq(ctx, id, jid, NULL); + xmpp_ctx_t* const ctx = connection_get_ctx(); + char* id = connection_create_stanza_id(); + xmpp_stanza_t* iq = stanza_create_disco_info_iq(ctx, id, jid, NULL); iq_id_handler_add(id, _disco_info_response_id_handler_onconnect, NULL, NULL); @@ -446,11 +451,11 @@ iq_disco_info_request_onconnect(gchar *jid) } void -iq_last_activity_request(gchar *jid) +iq_last_activity_request(gchar* jid) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - char *id = connection_create_stanza_id(); - xmpp_stanza_t *iq = stanza_create_last_activity_iq(ctx, id, jid); + xmpp_ctx_t* const ctx = connection_get_ctx(); + char* id = connection_create_stanza_id(); + xmpp_stanza_t* iq = stanza_create_last_activity_iq(ctx, id, jid); iq_id_handler_add(id, _last_activity_response_id_handler, NULL, NULL); @@ -461,13 +466,13 @@ iq_last_activity_request(gchar *jid) } void -iq_room_info_request(const char *const room, gboolean display_result) +iq_room_info_request(const char* const room, gboolean display_result) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - char *id = connection_create_stanza_id(); - xmpp_stanza_t *iq = stanza_create_disco_info_iq(ctx, id, room, NULL); + xmpp_ctx_t* const ctx = connection_get_ctx(); + char* id = connection_create_stanza_id(); + xmpp_stanza_t* iq = stanza_create_disco_info_iq(ctx, id, room, NULL); - ProfRoomInfoData *cb_data = malloc(sizeof(ProfRoomInfoData)); + ProfRoomInfoData* cb_data = malloc(sizeof(ProfRoomInfoData)); cb_data->room = strdup(room); cb_data->display = display_result; @@ -480,10 +485,10 @@ iq_room_info_request(const char *const room, gboolean display_result) } void -iq_send_caps_request_for_jid(const char *const to, const char *const id, - const char *const node, const char *const ver) +iq_send_caps_request_for_jid(const char* const to, const char* const id, + const char* const node, const char* const ver) { - xmpp_ctx_t * const ctx = connection_get_ctx(); + xmpp_ctx_t* const ctx = connection_get_ctx(); if (!node) { log_error("Could not create caps request, no node"); @@ -494,9 +499,9 @@ iq_send_caps_request_for_jid(const char *const to, const char *const id, return; } - GString *node_str = g_string_new(""); + GString* node_str = g_string_new(""); g_string_printf(node_str, "%s#%s", node, ver); - xmpp_stanza_t *iq = stanza_create_disco_info_iq(ctx, id, to, node_str->str); + xmpp_stanza_t* iq = stanza_create_disco_info_iq(ctx, id, to, node_str->str); g_string_free(node_str, TRUE); iq_id_handler_add(id, _caps_response_for_jid_id_handler, free, strdup(to)); @@ -506,10 +511,10 @@ iq_send_caps_request_for_jid(const char *const to, const char *const id, } void -iq_send_caps_request(const char *const to, const char *const id, - const char *const node, const char *const ver) +iq_send_caps_request(const char* const to, const char* const id, + const char* const node, const char* const ver) { - xmpp_ctx_t * const ctx = connection_get_ctx(); + xmpp_ctx_t* const ctx = connection_get_ctx(); if (!node) { log_error("Could not create caps request, no node"); @@ -520,9 +525,9 @@ iq_send_caps_request(const char *const to, const char *const id, return; } - GString *node_str = g_string_new(""); + GString* node_str = g_string_new(""); g_string_printf(node_str, "%s#%s", node, ver); - xmpp_stanza_t *iq = stanza_create_disco_info_iq(ctx, id, to, node_str->str); + xmpp_stanza_t* iq = stanza_create_disco_info_iq(ctx, id, to, node_str->str); g_string_free(node_str, TRUE); iq_id_handler_add(id, _caps_response_id_handler, NULL, NULL); @@ -532,10 +537,10 @@ iq_send_caps_request(const char *const to, const char *const id, } void -iq_send_caps_request_legacy(const char *const to, const char *const id, - const char *const node, const char *const ver) +iq_send_caps_request_legacy(const char* const to, const char* const id, + const char* const node, const char* const ver) { - xmpp_ctx_t * const ctx = connection_get_ctx(); + xmpp_ctx_t* const ctx = connection_get_ctx(); if (!node) { log_error("Could not create caps request, no node"); @@ -546,9 +551,9 @@ iq_send_caps_request_legacy(const char *const to, const char *const id, return; } - GString *node_str = g_string_new(""); + GString* node_str = g_string_new(""); g_string_printf(node_str, "%s#%s", node, ver); - xmpp_stanza_t *iq = stanza_create_disco_info_iq(ctx, id, to, node_str->str); + xmpp_stanza_t* iq = stanza_create_disco_info_iq(ctx, id, to, node_str->str); iq_id_handler_add(id, _caps_response_legacy_id_handler, g_free, node_str->str); g_string_free(node_str, FALSE); @@ -558,30 +563,30 @@ iq_send_caps_request_legacy(const char *const to, const char *const id, } void -iq_disco_items_request(gchar *jid) +iq_disco_items_request(gchar* jid) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - xmpp_stanza_t *iq = stanza_create_disco_items_iq(ctx, "discoitemsreq", jid, NULL); + xmpp_ctx_t* const ctx = connection_get_ctx(); + xmpp_stanza_t* iq = stanza_create_disco_items_iq(ctx, "discoitemsreq", jid, NULL); iq_send_stanza(iq); xmpp_stanza_release(iq); } void -iq_disco_items_request_onconnect(gchar *jid) +iq_disco_items_request_onconnect(gchar* jid) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - xmpp_stanza_t *iq = stanza_create_disco_items_iq(ctx, "discoitemsreq_onconnect", jid, NULL); + xmpp_ctx_t* const ctx = connection_get_ctx(); + xmpp_stanza_t* iq = stanza_create_disco_items_iq(ctx, "discoitemsreq_onconnect", jid, NULL); iq_send_stanza(iq); xmpp_stanza_release(iq); } void -iq_send_software_version(const char *const fulljid) +iq_send_software_version(const char* const fulljid) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - xmpp_stanza_t *iq = stanza_create_software_version_iq(ctx, fulljid); + xmpp_ctx_t* const ctx = connection_get_ctx(); + xmpp_stanza_t* iq = stanza_create_software_version_iq(ctx, fulljid); - const char *id = xmpp_stanza_get_id(iq); + const char* id = xmpp_stanza_get_id(iq); iq_id_handler_add(id, _version_result_id_handler, free, strdup(fulljid)); iq_send_stanza(iq); @@ -589,21 +594,21 @@ iq_send_software_version(const char *const fulljid) } void -iq_confirm_instant_room(const char *const room_jid) +iq_confirm_instant_room(const char* const room_jid) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - xmpp_stanza_t *iq = stanza_create_instant_room_request_iq(ctx, room_jid); + xmpp_ctx_t* const ctx = connection_get_ctx(); + xmpp_stanza_t* iq = stanza_create_instant_room_request_iq(ctx, room_jid); iq_send_stanza(iq); xmpp_stanza_release(iq); } void -iq_destroy_room(const char *const room_jid) +iq_destroy_room(const char* const room_jid) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - xmpp_stanza_t *iq = stanza_create_instant_room_destroy_iq(ctx, room_jid); + xmpp_ctx_t* const ctx = connection_get_ctx(); + xmpp_stanza_t* iq = stanza_create_instant_room_destroy_iq(ctx, room_jid); - const char *id = xmpp_stanza_get_id(iq); + const char* id = xmpp_stanza_get_id(iq); iq_id_handler_add(id, _destroy_room_result_id_handler, NULL, NULL); iq_send_stanza(iq); @@ -611,12 +616,12 @@ iq_destroy_room(const char *const room_jid) } void -iq_request_room_config_form(const char *const room_jid) +iq_request_room_config_form(const char* const room_jid) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - xmpp_stanza_t *iq = stanza_create_room_config_request_iq(ctx, room_jid); + xmpp_ctx_t* const ctx = connection_get_ctx(); + xmpp_stanza_t* iq = stanza_create_room_config_request_iq(ctx, room_jid); - const char *id = xmpp_stanza_get_id(iq); + const char* id = xmpp_stanza_get_id(iq); iq_id_handler_add(id, _room_config_id_handler, NULL, NULL); iq_send_stanza(iq); @@ -624,12 +629,12 @@ iq_request_room_config_form(const char *const room_jid) } void -iq_submit_room_config(ProfConfWin *confwin) +iq_submit_room_config(ProfConfWin* confwin) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - xmpp_stanza_t *iq = stanza_create_room_config_submit_iq(ctx, confwin->roomjid, confwin->form); + xmpp_ctx_t* const ctx = connection_get_ctx(); + xmpp_stanza_t* iq = stanza_create_room_config_submit_iq(ctx, confwin->roomjid, confwin->form); - const char *id = xmpp_stanza_get_id(iq); + const char* id = xmpp_stanza_get_id(iq); iq_id_handler_add(id, _room_config_submit_id_handler, NULL, NULL); iq_send_stanza(iq); @@ -637,23 +642,23 @@ iq_submit_room_config(ProfConfWin *confwin) } void -iq_room_config_cancel(ProfConfWin *confwin) +iq_room_config_cancel(ProfConfWin* confwin) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - xmpp_stanza_t *iq = stanza_create_room_config_cancel_iq(ctx, confwin->roomjid); + xmpp_ctx_t* const ctx = connection_get_ctx(); + xmpp_stanza_t* iq = stanza_create_room_config_cancel_iq(ctx, confwin->roomjid); iq_send_stanza(iq); xmpp_stanza_release(iq); } void -iq_room_affiliation_list(const char *const room, char *affiliation, bool show_ui_message) +iq_room_affiliation_list(const char* const room, char* affiliation, bool show_ui_message) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - xmpp_stanza_t *iq = stanza_create_room_affiliation_list_iq(ctx, room, affiliation); + xmpp_ctx_t* const ctx = connection_get_ctx(); + xmpp_stanza_t* iq = stanza_create_room_affiliation_list_iq(ctx, room, affiliation); - const char *id = xmpp_stanza_get_id(iq); + const char* id = xmpp_stanza_get_id(iq); - ProfAffiliationList *affiliation_list = malloc(sizeof(ProfAffiliationList)); + ProfAffiliationList* affiliation_list = malloc(sizeof(ProfAffiliationList)); affiliation_list->affiliation = strdup(affiliation); affiliation_list->show_ui_message = show_ui_message; @@ -664,12 +669,12 @@ iq_room_affiliation_list(const char *const room, char *affiliation, bool show_ui } void -iq_room_kick_occupant(const char *const room, const char *const nick, const char *const reason) +iq_room_kick_occupant(const char* const room, const char* const nick, const char* const reason) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - xmpp_stanza_t *iq = stanza_create_room_kick_iq(ctx, room, nick, reason); + xmpp_ctx_t* const ctx = connection_get_ctx(); + xmpp_stanza_t* iq = stanza_create_room_kick_iq(ctx, room, nick, reason); - const char *id = xmpp_stanza_get_id(iq); + const char* id = xmpp_stanza_get_id(iq); iq_id_handler_add(id, _room_kick_result_id_handler, free, strdup(nick)); iq_send_stanza(iq); @@ -677,15 +682,15 @@ iq_room_kick_occupant(const char *const room, const char *const nick, const char } void -iq_room_affiliation_set(const char *const room, const char *const jid, char *affiliation, - const char *const reason) +iq_room_affiliation_set(const char* const room, const char* const jid, char* affiliation, + const char* const reason) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - xmpp_stanza_t *iq = stanza_create_room_affiliation_set_iq(ctx, room, jid, affiliation, reason); + xmpp_ctx_t* const ctx = connection_get_ctx(); + xmpp_stanza_t* iq = stanza_create_room_affiliation_set_iq(ctx, room, jid, affiliation, reason); - const char *id = xmpp_stanza_get_id(iq); + const char* id = xmpp_stanza_get_id(iq); - ProfPrivilegeSet *affiliation_set = malloc(sizeof(struct privilege_set_t)); + ProfPrivilegeSet* affiliation_set = malloc(sizeof(struct privilege_set_t)); affiliation_set->item = strdup(jid); affiliation_set->privilege = strdup(affiliation); @@ -696,15 +701,15 @@ iq_room_affiliation_set(const char *const room, const char *const jid, char *aff } void -iq_room_role_set(const char *const room, const char *const nick, char *role, - const char *const reason) +iq_room_role_set(const char* const room, const char* const nick, char* role, + const char* const reason) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - xmpp_stanza_t *iq = stanza_create_room_role_set_iq(ctx, room, nick, role, reason); + xmpp_ctx_t* const ctx = connection_get_ctx(); + xmpp_stanza_t* iq = stanza_create_room_role_set_iq(ctx, room, nick, role, reason); - const char *id = xmpp_stanza_get_id(iq); + const char* id = xmpp_stanza_get_id(iq); - struct privilege_set_t *role_set = malloc(sizeof(ProfPrivilegeSet)); + struct privilege_set_t* role_set = malloc(sizeof(ProfPrivilegeSet)); role_set->item = strdup(nick); role_set->privilege = strdup(role); @@ -715,12 +720,12 @@ iq_room_role_set(const char *const room, const char *const nick, char *role, } void -iq_room_role_list(const char *const room, char *role) +iq_room_role_list(const char* const room, char* role) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - xmpp_stanza_t *iq = stanza_create_room_role_list_iq(ctx, room, role); + xmpp_ctx_t* const ctx = connection_get_ctx(); + xmpp_stanza_t* iq = stanza_create_room_role_list_iq(ctx, room, role); - const char *id = xmpp_stanza_get_id(iq); + const char* id = xmpp_stanza_get_id(iq); iq_id_handler_add(id, _room_role_list_result_id_handler, free, strdup(role)); iq_send_stanza(iq); @@ -728,13 +733,13 @@ iq_room_role_list(const char *const room, char *role) } void -iq_send_ping(const char *const target) +iq_send_ping(const char* const target) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - xmpp_stanza_t *iq = stanza_create_ping_iq(ctx, target); - const char *id = xmpp_stanza_get_id(iq); + xmpp_ctx_t* const ctx = connection_get_ctx(); + xmpp_stanza_t* iq = stanza_create_ping_iq(ctx, target); + const char* id = xmpp_stanza_get_id(iq); - GDateTime *now = g_date_time_new_now_local(); + GDateTime* now = g_date_time_new_now_local(); iq_id_handler_add(id, _manual_pong_id_handler, (ProfIqFreeCallback)g_date_time_unref, now); iq_send_stanza(iq); @@ -742,11 +747,11 @@ iq_send_ping(const char *const target) } void -iq_command_list(const char *const target) +iq_command_list(const char* const target) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - const char *id = connection_create_stanza_id(); - xmpp_stanza_t *iq = stanza_create_disco_items_iq(ctx, id, target, STANZA_NS_COMMAND); + xmpp_ctx_t* const ctx = connection_get_ctx(); + const char* id = connection_create_stanza_id(); + xmpp_stanza_t* iq = stanza_create_disco_items_iq(ctx, id, target, STANZA_NS_COMMAND); iq_id_handler_add(id, _command_list_result_handler, NULL, NULL); @@ -755,11 +760,11 @@ iq_command_list(const char *const target) } void -iq_command_exec(const char *const target, const char *const command) +iq_command_exec(const char* const target, const char* const command) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - xmpp_stanza_t *iq = stanza_create_command_exec_iq(ctx, target, command); - const char *id = xmpp_stanza_get_id(iq); + xmpp_ctx_t* const ctx = connection_get_ctx(); + xmpp_stanza_t* iq = stanza_create_command_exec_iq(ctx, target, command); + const char* id = xmpp_stanza_get_id(iq); iq_id_handler_add(id, _command_exec_response_handler, free, strdup(command)); @@ -768,14 +773,14 @@ iq_command_exec(const char *const target, const char *const command) } void -iq_submit_command_config(ProfConfWin *confwin) +iq_submit_command_config(ProfConfWin* confwin) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - CommandConfigData *data = (CommandConfigData *)confwin->userdata; - xmpp_stanza_t *iq = stanza_create_command_config_submit_iq(ctx, confwin->roomjid, data->command, data->sessionid, confwin->form); + xmpp_ctx_t* const ctx = connection_get_ctx(); + CommandConfigData* data = (CommandConfigData*)confwin->userdata; + xmpp_stanza_t* iq = stanza_create_command_config_submit_iq(ctx, confwin->roomjid, data->command, data->sessionid, confwin->form); - const char *id = xmpp_stanza_get_id(iq); - iq_id_handler_add(id, _command_exec_response_handler, free, strdup(data->command)); + const char* id = xmpp_stanza_get_id(iq); + iq_id_handler_add(id, _command_exec_response_handler, free, strdup(data->command)); iq_send_stanza(iq); xmpp_stanza_release(iq); @@ -785,11 +790,11 @@ iq_submit_command_config(ProfConfWin *confwin) } void -iq_cancel_command_config(ProfConfWin *confwin) +iq_cancel_command_config(ProfConfWin* confwin) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - CommandConfigData *data = (CommandConfigData *)confwin->userdata; - xmpp_stanza_t *iq = stanza_create_room_config_cancel_iq(ctx, confwin->roomjid); + xmpp_ctx_t* const ctx = connection_get_ctx(); + CommandConfigData* data = (CommandConfigData*)confwin->userdata; + xmpp_stanza_t* iq = stanza_create_room_config_cancel_iq(ctx, confwin->roomjid); iq_send_stanza(iq); xmpp_stanza_release(iq); free(data->sessionid); @@ -798,10 +803,10 @@ iq_cancel_command_config(ProfConfWin *confwin) } static void -_error_handler(xmpp_stanza_t *const stanza) +_error_handler(xmpp_stanza_t* const stanza) { - const char *id = xmpp_stanza_get_id(stanza); - char *error_msg = stanza_get_error_message(stanza); + const char* id = xmpp_stanza_get_id(stanza); + char* error_msg = stanza_get_error_message(stanza); if (id) { log_debug("IQ error handler fired, id: %s, error: %s", id, error_msg); @@ -815,12 +820,12 @@ _error_handler(xmpp_stanza_t *const stanza) } static int -_caps_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata) +_caps_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata) { - const char *id = xmpp_stanza_get_id(stanza); - xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); + const char* id = xmpp_stanza_get_id(stanza); + xmpp_stanza_t* query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); - const char *type = xmpp_stanza_get_type(stanza); + const char* type = xmpp_stanza_get_type(stanza); // ignore non result if ((g_strcmp0(type, "get") == 0) || (g_strcmp0(type, "set") == 0)) { return 1; @@ -832,7 +837,7 @@ _caps_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata) log_debug("Capabilities response handler fired"); } - const char *from = xmpp_stanza_get_from(stanza); + const char* from = xmpp_stanza_get_from(stanza); if (!from) { log_info("_caps_response_id_handler(): No from attribute"); return 0; @@ -840,7 +845,7 @@ _caps_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata) // handle error responses if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { - char *error_message = stanza_get_error_message(stanza); + char* error_message = stanza_get_error_message(stanza); log_warning("Error received for capabilities response from %s: ", from, error_message); free(error_message); return 0; @@ -851,16 +856,16 @@ _caps_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata) return 0; } - const char *node = xmpp_stanza_get_attribute(query, STANZA_ATTR_NODE); + const char* node = xmpp_stanza_get_attribute(query, STANZA_ATTR_NODE); if (node == NULL) { log_info("_caps_response_id_handler(): No node attribute found"); return 0; } // validate sha1 - gchar **split = g_strsplit(node, "#", -1); - char *given_sha1 = split[1]; - char *generated_sha1 = stanza_create_caps_sha1_from_query(query); + gchar** split = g_strsplit(node, "#", -1); + char* given_sha1 = split[1]; + char* generated_sha1 = stanza_create_caps_sha1_from_query(query); if (g_strcmp0(given_sha1, generated_sha1) != 0) { log_warning("Generated sha-1 does not match given:"); @@ -873,7 +878,7 @@ _caps_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata) log_debug("Capabilties already cached: %s", given_sha1); } else { log_debug("Capabilities not cached: %s, storing", given_sha1); - EntityCapabilities *capabilities = stanza_create_caps_from_query_element(query); + EntityCapabilities* capabilities = stanza_create_caps_from_query_element(query); caps_add_by_ver(given_sha1, capabilities); caps_destroy(capabilities); } @@ -888,13 +893,13 @@ _caps_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata) } static int -_caps_response_for_jid_id_handler(xmpp_stanza_t *const stanza, void *const userdata) +_caps_response_for_jid_id_handler(xmpp_stanza_t* const stanza, void* const userdata) { - char *jid = (char *)userdata; - const char *id = xmpp_stanza_get_id(stanza); - xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); + char* jid = (char*)userdata; + const char* id = xmpp_stanza_get_id(stanza); + xmpp_stanza_t* query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); - const char *type = xmpp_stanza_get_type(stanza); + const char* type = xmpp_stanza_get_type(stanza); // ignore non result if ((g_strcmp0(type, "get") == 0) || (g_strcmp0(type, "set") == 0)) { return 1; @@ -906,7 +911,7 @@ _caps_response_for_jid_id_handler(xmpp_stanza_t *const stanza, void *const userd log_debug("Capabilities response handler fired"); } - const char *from = xmpp_stanza_get_from(stanza); + const char* from = xmpp_stanza_get_from(stanza); if (!from) { if (jid) { log_info("_caps_response_for_jid_id_handler(): No from attribute for %s", jid); @@ -918,7 +923,7 @@ _caps_response_for_jid_id_handler(xmpp_stanza_t *const stanza, void *const userd // handle error responses if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { - char *error_message = stanza_get_error_message(stanza); + char* error_message = stanza_get_error_message(stanza); log_warning("Error received for capabilities response from %s: ", from, error_message); free(error_message); return 0; @@ -933,7 +938,7 @@ _caps_response_for_jid_id_handler(xmpp_stanza_t *const stanza, void *const userd return 0; } - const char *node = xmpp_stanza_get_attribute(query, STANZA_ATTR_NODE); + const char* node = xmpp_stanza_get_attribute(query, STANZA_ATTR_NODE); if (node == NULL) { if (jid) { log_info("_caps_response_for_jid_id_handler(): No node attribute found for %s", jid); @@ -944,20 +949,20 @@ _caps_response_for_jid_id_handler(xmpp_stanza_t *const stanza, void *const userd } log_debug("Associating capabilities with: %s", jid); - EntityCapabilities *capabilities = stanza_create_caps_from_query_element(query); + EntityCapabilities* capabilities = stanza_create_caps_from_query_element(query); caps_add_by_jid(jid, capabilities); return 0; } static int -_caps_response_legacy_id_handler(xmpp_stanza_t *const stanza, void *const userdata) +_caps_response_legacy_id_handler(xmpp_stanza_t* const stanza, void* const userdata) { - const char *id = xmpp_stanza_get_id(stanza); - xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); - char *expected_node = (char *)userdata; + const char* id = xmpp_stanza_get_id(stanza); + xmpp_stanza_t* query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); + char* expected_node = (char*)userdata; - const char *type = xmpp_stanza_get_type(stanza); + const char* type = xmpp_stanza_get_type(stanza); // ignore non result if ((g_strcmp0(type, "get") == 0) || (g_strcmp0(type, "set") == 0)) { return 1; @@ -969,7 +974,7 @@ _caps_response_legacy_id_handler(xmpp_stanza_t *const stanza, void *const userda log_debug("Capabilities response handler fired"); } - const char *from = xmpp_stanza_get_from(stanza); + const char* from = xmpp_stanza_get_from(stanza); if (!from) { log_info("_caps_response_legacy_id_handler(): No from attribute"); return 0; @@ -977,7 +982,7 @@ _caps_response_legacy_id_handler(xmpp_stanza_t *const stanza, void *const userda // handle error responses if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { - char *error_message = stanza_get_error_message(stanza); + char* error_message = stanza_get_error_message(stanza); log_warning("Error received for capabilities response from %s: ", from, error_message); free(error_message); return 0; @@ -988,7 +993,7 @@ _caps_response_legacy_id_handler(xmpp_stanza_t *const stanza, void *const userda return 0; } - const char *node = xmpp_stanza_get_attribute(query, STANZA_ATTR_NODE); + const char* node = xmpp_stanza_get_attribute(query, STANZA_ATTR_NODE); if (node == NULL) { log_info("_caps_response_legacy_id_handler(): No node attribute found"); return 0; @@ -1001,14 +1006,14 @@ _caps_response_legacy_id_handler(xmpp_stanza_t *const stanza, void *const userda log_debug("Capabilties already cached: %s", node); } else { log_debug("Capabilities not cached: %s, storing", node); - EntityCapabilities *capabilities = stanza_create_caps_from_query_element(query); + EntityCapabilities* capabilities = stanza_create_caps_from_query_element(query); caps_add_by_ver(node, capabilities); caps_destroy(capabilities); } caps_map_jid_to_ver(from, node); - // node match fail + // node match fail } else { log_info("Legacy Capabilities nodes do not match, expeceted %s, given %s.", expected_node, node); } @@ -1017,11 +1022,11 @@ _caps_response_legacy_id_handler(xmpp_stanza_t *const stanza, void *const userda } static int -_room_list_id_handler(xmpp_stanza_t *const stanza, void *const userdata) +_room_list_id_handler(xmpp_stanza_t* const stanza, void* const userdata) { - gchar *filter = (gchar*)userdata; - const char *id = xmpp_stanza_get_id(stanza); - const char *from = xmpp_stanza_get_from(stanza); + gchar* filter = (gchar*)userdata; + const char* id = xmpp_stanza_get_id(stanza); + const char* from = xmpp_stanza_get_from(stanza); if (prefs_get_boolean(PREF_ROOM_LIST_CACHE) && !g_hash_table_contains(rooms_cache, from)) { g_hash_table_insert(rooms_cache, strdup(from), xmpp_stanza_copy(stanza)); @@ -1029,7 +1034,7 @@ _room_list_id_handler(xmpp_stanza_t *const stanza, void *const userdata) log_debug("Response to query: %s", id); - xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); + xmpp_stanza_t* query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); if (query == NULL) { return 0; } @@ -1040,16 +1045,16 @@ _room_list_id_handler(xmpp_stanza_t *const stanza, void *const userdata) } else { cons_show("Rooms list response received: %s", from); } - xmpp_stanza_t *child = xmpp_stanza_get_children(query); + xmpp_stanza_t* child = xmpp_stanza_get_children(query); if (child == NULL) { cons_show(" No rooms found."); return 0; } - GPatternSpec *glob = NULL; + GPatternSpec* glob = NULL; if (filter != NULL) { - gchar *filter_lower = g_utf8_strdown(filter, -1); - GString *glob_str = g_string_new("*"); + gchar* filter_lower = g_utf8_strdown(filter, -1); + GString* glob_str = g_string_new("*"); g_string_append(glob_str, filter_lower); g_string_append(glob_str, "*"); glob = g_pattern_spec_new(glob_str->str); @@ -1058,30 +1063,28 @@ _room_list_id_handler(xmpp_stanza_t *const stanza, void *const userdata) gboolean matched = FALSE; while (child) { - const char *stanza_name = xmpp_stanza_get_name(child); + const char* stanza_name = xmpp_stanza_get_name(child); if (stanza_name && (g_strcmp0(stanza_name, STANZA_NAME_ITEM) == 0)) { - const char *item_jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID); - gchar *item_jid_lower = NULL; + const char* item_jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID); + gchar* item_jid_lower = NULL; if (item_jid) { - Jid *jidp = jid_create(item_jid); + Jid* jidp = jid_create(item_jid); if (jidp && jidp->localpart) { item_jid_lower = g_utf8_strdown(jidp->localpart, -1); } jid_destroy(jidp); } - const char *item_name = xmpp_stanza_get_attribute(child, STANZA_ATTR_NAME); - gchar *item_name_lower = NULL; + const char* item_name = xmpp_stanza_get_attribute(child, STANZA_ATTR_NAME); + gchar* item_name_lower = NULL; if (item_name) { item_name_lower = g_utf8_strdown(item_name, -1); } - if ((item_jid_lower) && ((glob == NULL) || - ((g_pattern_match(glob, strlen(item_jid_lower), item_jid_lower, NULL)) || - (item_name_lower && g_pattern_match(glob, strlen(item_name_lower), item_name_lower, NULL))))) { + if ((item_jid_lower) && ((glob == NULL) || ((g_pattern_match(glob, strlen(item_jid_lower), item_jid_lower, NULL)) || (item_name_lower && g_pattern_match(glob, strlen(item_name_lower), item_name_lower, NULL))))) { if (glob) { matched = TRUE; } - GString *item = g_string_new(item_jid); + GString* item = g_string_new(item_jid); if (item_name) { g_string_append(item, " ("); g_string_append(item, item_name); @@ -1108,11 +1111,11 @@ _room_list_id_handler(xmpp_stanza_t *const stanza, void *const userdata) } static int -_command_list_result_handler(xmpp_stanza_t *const stanza, void *const userdata) +_command_list_result_handler(xmpp_stanza_t* const stanza, void* const userdata) { - const char *id = xmpp_stanza_get_id(stanza); - const char *type = xmpp_stanza_get_type(stanza); - char *from = strdup(xmpp_stanza_get_from(stanza)); + const char* id = xmpp_stanza_get_id(stanza); + const char* type = xmpp_stanza_get_type(stanza); + char* from = strdup(xmpp_stanza_get_from(stanza)); if (id) { log_debug("IQ command list result handler fired, id: %s.", id); @@ -1122,9 +1125,9 @@ _command_list_result_handler(xmpp_stanza_t *const stanza, void *const userdata) // handle error responses if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { - char *error_message = stanza_get_error_message(stanza); + char* error_message = stanza_get_error_message(stanza); log_debug("Error retrieving command list for %s: %s", from, error_message); - ProfWin *win = wins_get_by_string(from); + ProfWin* win = wins_get_by_string(from); if (win) { win_command_list_error(win, error_message); } @@ -1133,15 +1136,15 @@ _command_list_result_handler(xmpp_stanza_t *const stanza, void *const userdata) return 0; } - GSList *cmds = NULL; + GSList* cmds = NULL; - xmpp_stanza_t *query = xmpp_stanza_get_child_by_ns(stanza, XMPP_NS_DISCO_ITEMS); + xmpp_stanza_t* query = xmpp_stanza_get_child_by_ns(stanza, XMPP_NS_DISCO_ITEMS); if (query) { - xmpp_stanza_t *child = xmpp_stanza_get_children(query); + xmpp_stanza_t* child = xmpp_stanza_get_children(query); while (child) { - const char *name = xmpp_stanza_get_name(child); + const char* name = xmpp_stanza_get_name(child); if (g_strcmp0(name, "item") == 0) { - const char *node = xmpp_stanza_get_attribute(child, STANZA_ATTR_NODE); + const char* node = xmpp_stanza_get_attribute(child, STANZA_ATTR_NODE); if (node) { cmds = g_slist_insert_sorted(cmds, (gpointer)node, (GCompareFunc)g_strcmp0); } @@ -1150,9 +1153,9 @@ _command_list_result_handler(xmpp_stanza_t *const stanza, void *const userdata) } } - ProfWin *win = wins_get_by_string(from); + ProfWin* win = wins_get_by_string(from); if (win == NULL) { - win = wins_get_console(); + win = wins_get_console(); } win_handle_command_list(win, cmds); @@ -1163,12 +1166,12 @@ _command_list_result_handler(xmpp_stanza_t *const stanza, void *const userdata) } static int -_command_exec_response_handler(xmpp_stanza_t *const stanza, void *const userdata) +_command_exec_response_handler(xmpp_stanza_t* const stanza, void* const userdata) { - const char *id = xmpp_stanza_get_id(stanza); - const char *type = xmpp_stanza_get_type(stanza); - const char *from = xmpp_stanza_get_from(stanza); - char *command = userdata; + const char* id = xmpp_stanza_get_id(stanza); + const char* type = xmpp_stanza_get_type(stanza); + const char* from = xmpp_stanza_get_from(stanza); + char* command = userdata; if (id) { log_debug("IQ command exec response handler fired, id: %s.", id); @@ -1176,7 +1179,7 @@ _command_exec_response_handler(xmpp_stanza_t *const stanza, void *const userdata log_debug("IQ command exec response handler fired."); } - ProfWin *win = wins_get_by_string(from); + ProfWin* win = wins_get_by_string(from); if (win == NULL) { /* No more window associated with this command. * Fallback to console. */ @@ -1185,45 +1188,44 @@ _command_exec_response_handler(xmpp_stanza_t *const stanza, void *const userdata // handle error responses if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { - char *error_message = stanza_get_error_message(stanza); + char* error_message = stanza_get_error_message(stanza); log_debug("Error executing command %s for %s: %s", command, from, error_message); win_command_exec_error(win, command, error_message); free(error_message); return 0; } - xmpp_stanza_t *cmd = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_COMMAND); + xmpp_stanza_t* cmd = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_COMMAND); if (!cmd) { log_error("No command element for command response"); win_command_exec_error(win, command, "Malformed command response"); return 0; } - - const char *status = xmpp_stanza_get_attribute(cmd, STANZA_ATTR_STATUS); + const char* status = xmpp_stanza_get_attribute(cmd, STANZA_ATTR_STATUS); if (g_strcmp0(status, "completed") == 0) { win_handle_command_exec_status(win, command, "completed"); - xmpp_stanza_t *note = xmpp_stanza_get_child_by_name(cmd, "note"); + xmpp_stanza_t* note = xmpp_stanza_get_child_by_name(cmd, "note"); if (note) { - const char *type = xmpp_stanza_get_attribute(note, "type"); - const char *value = xmpp_stanza_get_text(note); + const char* type = xmpp_stanza_get_attribute(note, "type"); + const char* value = xmpp_stanza_get_text(note); win_handle_command_exec_result_note(win, type, value); } - xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(cmd, STANZA_NS_DATA); + xmpp_stanza_t* x = xmpp_stanza_get_child_by_ns(cmd, STANZA_NS_DATA); if (x) { - xmpp_stanza_t *roster = xmpp_stanza_get_child_by_ns(x, XMPP_NS_ROSTER); + xmpp_stanza_t* roster = xmpp_stanza_get_child_by_ns(x, XMPP_NS_ROSTER); if (roster) { /* Special handling of xep-0133 roster in response */ - GSList *list = NULL; - xmpp_stanza_t *child = xmpp_stanza_get_children(roster); + GSList* list = NULL; + xmpp_stanza_t* child = xmpp_stanza_get_children(roster); while (child) { - const char *barejid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID); - gchar *barejid_lower = g_utf8_strdown(barejid, -1); - const char *name = xmpp_stanza_get_attribute(child, STANZA_ATTR_NAME); - const char *sub = xmpp_stanza_get_attribute(child, STANZA_ATTR_SUBSCRIPTION); - const char *ask = xmpp_stanza_get_attribute(child, STANZA_ATTR_ASK); + const char* barejid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID); + gchar* barejid_lower = g_utf8_strdown(barejid, -1); + const char* name = xmpp_stanza_get_attribute(child, STANZA_ATTR_NAME); + const char* sub = xmpp_stanza_get_attribute(child, STANZA_ATTR_SUBSCRIPTION); + const char* ask = xmpp_stanza_get_attribute(child, STANZA_ATTR_ASK); - GSList *groups = NULL; + GSList* groups = NULL; groups = roster_get_groups_from_item(child); gboolean pending_out = FALSE; @@ -1239,8 +1241,8 @@ _command_exec_response_handler(xmpp_stanza_t *const stanza, void *const userdata cons_show_roster(list); g_slist_free(list); } else { - DataForm *form = form_create(x); - ProfConfWin *confwin = (ProfConfWin*)wins_new_config(from, form, NULL, NULL, NULL); + DataForm* form = form_create(x); + ProfConfWin* confwin = (ProfConfWin*)wins_new_config(from, form, NULL, NULL, NULL); confwin_handle_configuration(confwin, form); } } @@ -1248,35 +1250,35 @@ _command_exec_response_handler(xmpp_stanza_t *const stanza, void *const userdata win_handle_command_exec_status(win, command, "executing"); /* Looking for a jabber:x:data type form */ - xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(cmd, STANZA_NS_DATA); + xmpp_stanza_t* x = xmpp_stanza_get_child_by_ns(cmd, STANZA_NS_DATA); if (x == NULL) { return 0; } - const char *form_type = xmpp_stanza_get_type(x); + const char* form_type = xmpp_stanza_get_type(x); if (g_strcmp0(form_type, "form") != 0) { log_error("Unsupported payload in command response"); win_command_exec_error(win, command, "Unsupported command response"); return 0; } - const char *sessionid = xmpp_stanza_get_attribute(cmd, "sessionid"); + const char* sessionid = xmpp_stanza_get_attribute(cmd, "sessionid"); - DataForm *form = form_create(x); - CommandConfigData *data = malloc(sizeof(CommandConfigData)); + DataForm* form = form_create(x); + CommandConfigData* data = malloc(sizeof(CommandConfigData)); if (sessionid == NULL) { data->sessionid = NULL; } else { data->sessionid = strdup(sessionid); } data->command = strdup(command); - ProfConfWin *confwin = (ProfConfWin*)wins_new_config(from, form, iq_submit_command_config, iq_cancel_command_config, data); + ProfConfWin* confwin = (ProfConfWin*)wins_new_config(from, form, iq_submit_command_config, iq_cancel_command_config, data); confwin_handle_configuration(confwin, form); } else if (g_strcmp0(status, "canceled") == 0) { win_handle_command_exec_status(win, command, "canceled"); - xmpp_stanza_t *note = xmpp_stanza_get_child_by_name(cmd, "note"); + xmpp_stanza_t* note = xmpp_stanza_get_child_by_name(cmd, "note"); if (note) { - const char *type = xmpp_stanza_get_attribute(note, "type"); - const char *value = xmpp_stanza_get_text(note); + const char* type = xmpp_stanza_get_attribute(note, "type"); + const char* value = xmpp_stanza_get_text(note); win_handle_command_exec_result_note(win, type, value); } } else { @@ -1288,11 +1290,11 @@ _command_exec_response_handler(xmpp_stanza_t *const stanza, void *const userdata } static int -_enable_carbons_id_handler(xmpp_stanza_t *const stanza, void *const userdata) +_enable_carbons_id_handler(xmpp_stanza_t* const stanza, void* const userdata) { - const char *type = xmpp_stanza_get_type(stanza); + const char* type = xmpp_stanza_get_type(stanza); if (g_strcmp0(type, "error") == 0) { - char *error_message = stanza_get_error_message(stanza); + char* error_message = stanza_get_error_message(stanza); cons_show_error("Server error enabling message carbons: %s", error_message); log_debug("Error enabling carbons: %s", error_message); free(error_message); @@ -1304,11 +1306,11 @@ _enable_carbons_id_handler(xmpp_stanza_t *const stanza, void *const userdata) } static int -_disable_carbons_id_handler(xmpp_stanza_t *const stanza, void *const userdata) +_disable_carbons_id_handler(xmpp_stanza_t* const stanza, void* const userdata) { - const char *type = xmpp_stanza_get_type(stanza); + const char* type = xmpp_stanza_get_type(stanza); if (g_strcmp0(type, "error") == 0) { - char *error_message = stanza_get_error_message(stanza); + char* error_message = stanza_get_error_message(stanza); cons_show_error("Server error disabling message carbons: %s", error_message); log_debug("Error disabling carbons: %s", error_message); free(error_message); @@ -1320,15 +1322,15 @@ _disable_carbons_id_handler(xmpp_stanza_t *const stanza, void *const userdata) } static int -_manual_pong_id_handler(xmpp_stanza_t *const stanza, void *const userdata) +_manual_pong_id_handler(xmpp_stanza_t* const stanza, void* const userdata) { - const char *from = xmpp_stanza_get_from(stanza); - const char *type = xmpp_stanza_get_type(stanza); - GDateTime *sent = (GDateTime *)userdata; + const char* from = xmpp_stanza_get_from(stanza); + const char* type = xmpp_stanza_get_type(stanza); + GDateTime* sent = (GDateTime*)userdata; // handle error responses if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { - char *error_message = stanza_get_error_message(stanza); + char* error_message = stanza_get_error_message(stanza); if (!error_message) { cons_show_error("Error returned from pinging %s.", from); } else { @@ -1339,7 +1341,7 @@ _manual_pong_id_handler(xmpp_stanza_t *const stanza, void *const userdata) return 0; } - GDateTime *now = g_date_time_new_now_local(); + GDateTime* now = g_date_time_new_now_local(); GTimeSpan elapsed = g_date_time_difference(now, sent); int elapsed_millis = elapsed / 1000; @@ -1356,7 +1358,7 @@ _manual_pong_id_handler(xmpp_stanza_t *const stanza, void *const userdata) } static int -_autoping_timed_send(xmpp_conn_t *const conn, void *const userdata) +_autoping_timed_send(xmpp_conn_t* const conn, void* const userdata) { if (connection_get_status() != JABBER_CONNECTED) { return 1; @@ -1366,7 +1368,7 @@ _autoping_timed_send(xmpp_conn_t *const conn, void *const userdata) log_warning("Server doesn't advertise %s feature, disabling autoping.", XMPP_FEATURE_PING); prefs_set_autoping(0); cons_show_error("Server ping not supported, autoping disabled."); - xmpp_conn_t *conn = connection_get_conn(); + xmpp_conn_t* conn = connection_get_conn(); xmpp_timed_handler_delete(conn, _autoping_timed_send); return 1; } @@ -1376,9 +1378,9 @@ _autoping_timed_send(xmpp_conn_t *const conn, void *const userdata) return 1; } - xmpp_ctx_t *ctx = (xmpp_ctx_t *)userdata; - xmpp_stanza_t *iq = stanza_create_ping_iq(ctx, NULL); - const char *id = xmpp_stanza_get_id(iq); + xmpp_ctx_t* ctx = (xmpp_ctx_t*)userdata; + xmpp_stanza_t* iq = stanza_create_ping_iq(ctx, NULL); + const char* id = xmpp_stanza_get_id(iq); log_debug("Autoping: Sending ping request: %s", id); // add pong handler @@ -1396,11 +1398,11 @@ _autoping_timed_send(xmpp_conn_t *const conn, void *const userdata) } static int -_auto_pong_id_handler(xmpp_stanza_t *const stanza, void *const userdata) +_auto_pong_id_handler(xmpp_stanza_t* const stanza, void* const userdata) { iq_autoping_timer_cancel(); - const char *id = xmpp_stanza_get_id(stanza); + const char* id = xmpp_stanza_get_id(stanza); if (id == NULL) { log_debug("Autoping: Pong handler fired."); return 0; @@ -1408,7 +1410,7 @@ _auto_pong_id_handler(xmpp_stanza_t *const stanza, void *const userdata) log_debug("Autoping: Pong handler fired: %s.", id); - const char *type = xmpp_stanza_get_type(stanza); + const char* type = xmpp_stanza_get_type(stanza); if (type == NULL) { return 0; } @@ -1417,16 +1419,16 @@ _auto_pong_id_handler(xmpp_stanza_t *const stanza, void *const userdata) } // show warning if error - char *error_msg = stanza_get_error_message(stanza); + char* error_msg = stanza_get_error_message(stanza); log_warning("Server ping (id=%s) responded with error: %s", id, error_msg); free(error_msg); // turn off autoping if error type is 'cancel' - xmpp_stanza_t *error = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ERROR); + xmpp_stanza_t* error = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ERROR); if (error == NULL) { return 0; } - const char *errtype = xmpp_stanza_get_type(error); + const char* errtype = xmpp_stanza_get_type(error); if (errtype == NULL) { return 0; } @@ -1434,7 +1436,7 @@ _auto_pong_id_handler(xmpp_stanza_t *const stanza, void *const userdata) log_warning("Server ping (id=%s) error type 'cancel', disabling autoping.", id); prefs_set_autoping(0); cons_show_error("Server ping not supported, autoping disabled."); - xmpp_conn_t *conn = connection_get_conn(); + xmpp_conn_t* conn = connection_get_conn(); xmpp_timed_handler_delete(conn, _autoping_timed_send); } @@ -1442,9 +1444,9 @@ _auto_pong_id_handler(xmpp_stanza_t *const stanza, void *const userdata) } static int -_version_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata) +_version_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata) { - const char *id = xmpp_stanza_get_id(stanza); + const char* id = xmpp_stanza_get_id(stanza); if (id) { log_debug("IQ version result handler fired, id: %s.", id); @@ -1452,12 +1454,12 @@ _version_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata) log_debug("IQ version result handler fired."); } - const char *type = xmpp_stanza_get_type(stanza); - const char *from = xmpp_stanza_get_from(stanza); + const char* type = xmpp_stanza_get_type(stanza); + const char* from = xmpp_stanza_get_from(stanza); if (g_strcmp0(type, STANZA_TYPE_RESULT) != 0) { if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { - char *error_message = stanza_get_error_message(stanza); + char* error_message = stanza_get_error_message(stanza); ui_handle_software_version_error(from, error_message); free(error_message); } else { @@ -1468,26 +1470,26 @@ _version_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata) return 0; } - const char *jid = xmpp_stanza_get_from(stanza); + const char* jid = xmpp_stanza_get_from(stanza); - xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); + xmpp_stanza_t* query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); if (query == NULL) { log_error("Software version result received with no query element."); return 0; } - const char *ns = xmpp_stanza_get_ns(query); + const char* ns = xmpp_stanza_get_ns(query); if (g_strcmp0(ns, STANZA_NS_VERSION) != 0) { log_error("Software version result received without namespace."); return 0; } - char *name_str = NULL; - char *version_str = NULL; - char *os_str = NULL; - xmpp_stanza_t *name = xmpp_stanza_get_child_by_name(query, "name"); - xmpp_stanza_t *version = xmpp_stanza_get_child_by_name(query, "version"); - xmpp_stanza_t *os = xmpp_stanza_get_child_by_name(query, "os"); + char* name_str = NULL; + char* version_str = NULL; + char* os_str = NULL; + xmpp_stanza_t* name = xmpp_stanza_get_child_by_name(query, "name"); + xmpp_stanza_t* version = xmpp_stanza_get_child_by_name(query, "version"); + xmpp_stanza_t* os = xmpp_stanza_get_child_by_name(query, "os"); if (name) { name_str = xmpp_stanza_get_text(name); @@ -1503,27 +1505,30 @@ _version_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata) log_warning("From attribute specified different JID, using original JID."); } - xmpp_conn_t *conn = connection_get_conn(); - xmpp_ctx_t *ctx = xmpp_conn_get_context(conn); + xmpp_conn_t* conn = connection_get_conn(); + xmpp_ctx_t* ctx = xmpp_conn_get_context(conn); - Jid *jidp = jid_create((char*)userdata); + Jid* jidp = jid_create((char*)userdata); - const char *presence = NULL; + const char* presence = NULL; // if it has a fulljid it is a regular user (not server or component) if (jidp->fulljid) { if (muc_active(jidp->barejid)) { - Occupant *occupant = muc_roster_item(jidp->barejid, jidp->resourcepart); + Occupant* occupant = muc_roster_item(jidp->barejid, jidp->resourcepart); presence = string_from_resource_presence(occupant->presence); } else { PContact contact = roster_get_contact(jidp->barejid); if (contact) { - Resource *resource = p_contact_get_resource(contact, jidp->resourcepart); + Resource* resource = p_contact_get_resource(contact, jidp->resourcepart); if (!resource) { ui_handle_software_version_error(jidp->fulljid, "Unknown resource"); - if (name_str) xmpp_free(ctx, name_str); - if (version_str) xmpp_free(ctx, version_str); - if (os_str) xmpp_free(ctx, os_str); + if (name_str) + xmpp_free(ctx, name_str); + if (version_str) + xmpp_free(ctx, version_str); + if (os_str) + xmpp_free(ctx, os_str); return 0; } presence = string_from_resource_presence(resource->presence); @@ -1543,20 +1548,23 @@ _version_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata) jid_destroy(jidp); - if (name_str) xmpp_free(ctx, name_str); - if (version_str) xmpp_free(ctx, version_str); - if (os_str) xmpp_free(ctx, os_str); + if (name_str) + xmpp_free(ctx, name_str); + if (version_str) + xmpp_free(ctx, version_str); + if (os_str) + xmpp_free(ctx, os_str); return 0; } static void -_ping_get_handler(xmpp_stanza_t *const stanza) +_ping_get_handler(xmpp_stanza_t* const stanza) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - const char *id = xmpp_stanza_get_id(stanza); - const char *to = xmpp_stanza_get_to(stanza); - const char *from = xmpp_stanza_get_from(stanza); + xmpp_ctx_t* const ctx = connection_get_ctx(); + const char* id = xmpp_stanza_get_id(stanza); + const char* to = xmpp_stanza_get_to(stanza); + const char* from = xmpp_stanza_get_from(stanza); if (id) { log_debug("IQ ping get handler fired, id: %s.", id); @@ -1568,7 +1576,7 @@ _ping_get_handler(xmpp_stanza_t *const stanza) return; } - xmpp_stanza_t *pong = xmpp_iq_new(ctx, STANZA_TYPE_RESULT, id); + xmpp_stanza_t* pong = xmpp_iq_new(ctx, STANZA_TYPE_RESULT, id); xmpp_stanza_set_to(pong, from); xmpp_stanza_set_from(pong, to); @@ -1577,11 +1585,11 @@ _ping_get_handler(xmpp_stanza_t *const stanza) } static void -_version_get_handler(xmpp_stanza_t *const stanza) +_version_get_handler(xmpp_stanza_t* const stanza) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - const char *id = xmpp_stanza_get_id(stanza); - const char *from = xmpp_stanza_get_from(stanza); + xmpp_ctx_t* const ctx = connection_get_ctx(); + const char* id = xmpp_stanza_get_id(stanza); + const char* from = xmpp_stanza_get_from(stanza); if (id) { log_debug("IQ version get handler fired, id: %s.", id); @@ -1594,23 +1602,23 @@ _version_get_handler(xmpp_stanza_t *const stanza) cons_show("Received IQ version request (XEP-0092) from %s", from); } - xmpp_stanza_t *response = xmpp_iq_new(ctx, STANZA_TYPE_RESULT, id); + xmpp_stanza_t* response = xmpp_iq_new(ctx, STANZA_TYPE_RESULT, id); xmpp_stanza_set_to(response, from); - xmpp_stanza_t *query = xmpp_stanza_new(ctx); + xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_ns(query, STANZA_NS_VERSION); - xmpp_stanza_t *name = xmpp_stanza_new(ctx); + xmpp_stanza_t* name = xmpp_stanza_new(ctx); xmpp_stanza_set_name(name, "name"); - xmpp_stanza_t *name_txt = xmpp_stanza_new(ctx); + xmpp_stanza_t* name_txt = xmpp_stanza_new(ctx); xmpp_stanza_set_text(name_txt, "Profanity"); xmpp_stanza_add_child(name, name_txt); - xmpp_stanza_t *version = xmpp_stanza_new(ctx); + xmpp_stanza_t* version = xmpp_stanza_new(ctx); xmpp_stanza_set_name(version, "version"); - xmpp_stanza_t *version_txt = xmpp_stanza_new(ctx); - GString *version_str = g_string_new(PACKAGE_VERSION); + xmpp_stanza_t* version_txt = xmpp_stanza_new(ctx); + GString* version_str = g_string_new(PACKAGE_VERSION); if (strcmp(PACKAGE_STATUS, "development") == 0) { #ifdef HAVE_GIT_VERSION g_string_append(version_str, "dev."); @@ -1624,8 +1632,8 @@ _version_get_handler(xmpp_stanza_t *const stanza) xmpp_stanza_set_text(version_txt, version_str->str); xmpp_stanza_add_child(version, version_txt); - xmpp_stanza_t *os; - xmpp_stanza_t *os_txt; + xmpp_stanza_t* os; + xmpp_stanza_t* os_txt; bool include_os = prefs_get_boolean(PREF_REVEAL_OS); if (include_os) { @@ -1654,7 +1662,9 @@ _version_get_handler(xmpp_stanza_t *const stanza) xmpp_stanza_add_child(query, name); xmpp_stanza_add_child(query, version); - if (include_os) {xmpp_stanza_add_child(query, os);} + if (include_os) { + xmpp_stanza_add_child(query, os); + } xmpp_stanza_add_child(response, query); iq_send_stanza(response); @@ -1662,21 +1672,25 @@ _version_get_handler(xmpp_stanza_t *const stanza) g_string_free(version_str, TRUE); xmpp_stanza_release(name_txt); xmpp_stanza_release(version_txt); - if (include_os) {xmpp_stanza_release(os_txt);} + if (include_os) { + xmpp_stanza_release(os_txt); + } xmpp_stanza_release(name); xmpp_stanza_release(version); - if (include_os) {xmpp_stanza_release(os);} + if (include_os) { + xmpp_stanza_release(os); + } xmpp_stanza_release(query); xmpp_stanza_release(response); } } static void -_disco_items_get_handler(xmpp_stanza_t *const stanza) +_disco_items_get_handler(xmpp_stanza_t* const stanza) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - const char *id = xmpp_stanza_get_id(stanza); - const char *from = xmpp_stanza_get_from(stanza); + xmpp_ctx_t* const ctx = connection_get_ctx(); + const char* id = xmpp_stanza_get_id(stanza); + const char* from = xmpp_stanza_get_from(stanza); if (id) { log_debug("IQ disco items get handler fired, id: %s.", id); @@ -1685,10 +1699,10 @@ _disco_items_get_handler(xmpp_stanza_t *const stanza) } if (from) { - xmpp_stanza_t *response = xmpp_iq_new(ctx, STANZA_TYPE_RESULT, xmpp_stanza_get_id(stanza)); + xmpp_stanza_t* response = xmpp_iq_new(ctx, STANZA_TYPE_RESULT, xmpp_stanza_get_id(stanza)); xmpp_stanza_set_to(response, from); - xmpp_stanza_t *query = xmpp_stanza_new(ctx); + xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_ns(query, XMPP_NS_DISCO_ITEMS); xmpp_stanza_add_child(response, query); @@ -1700,10 +1714,10 @@ _disco_items_get_handler(xmpp_stanza_t *const stanza) } static void -_last_activity_get_handler(xmpp_stanza_t *const stanza) +_last_activity_get_handler(xmpp_stanza_t* const stanza) { - xmpp_ctx_t *ctx = connection_get_ctx(); - const char *from = xmpp_stanza_get_from(stanza); + xmpp_ctx_t* ctx = connection_get_ctx(); + const char* from = xmpp_stanza_get_from(stanza); if (!from) { return; @@ -1714,10 +1728,10 @@ _last_activity_get_handler(xmpp_stanza_t *const stanza) char str[50]; sprintf(str, "%d", idls_secs); - xmpp_stanza_t *response = xmpp_iq_new(ctx, STANZA_TYPE_RESULT, xmpp_stanza_get_id(stanza)); + xmpp_stanza_t* response = xmpp_iq_new(ctx, STANZA_TYPE_RESULT, xmpp_stanza_get_id(stanza)); xmpp_stanza_set_to(response, from); - xmpp_stanza_t *query = xmpp_stanza_new(ctx); + xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_attribute(query, STANZA_ATTR_XMLNS, STANZA_NS_LASTACTIVITY); xmpp_stanza_set_attribute(query, "seconds", str); @@ -1729,14 +1743,14 @@ _last_activity_get_handler(xmpp_stanza_t *const stanza) xmpp_stanza_release(response); } else { - xmpp_stanza_t *response = xmpp_iq_new(ctx, STANZA_TYPE_ERROR, xmpp_stanza_get_id(stanza)); + xmpp_stanza_t* response = xmpp_iq_new(ctx, STANZA_TYPE_ERROR, xmpp_stanza_get_id(stanza)); xmpp_stanza_set_to(response, from); - xmpp_stanza_t *error = xmpp_stanza_new(ctx); + xmpp_stanza_t* error = xmpp_stanza_new(ctx); xmpp_stanza_set_name(error, STANZA_NAME_ERROR); xmpp_stanza_set_type(error, "cancel"); - xmpp_stanza_t *service_unavailable = xmpp_stanza_new(ctx); + xmpp_stanza_t* service_unavailable = xmpp_stanza_new(ctx); xmpp_stanza_set_name(service_unavailable, "service-unavailable"); xmpp_stanza_set_ns(service_unavailable, "urn:ietf:params:xml:ns:xmpp-stanzas"); @@ -1753,15 +1767,15 @@ _last_activity_get_handler(xmpp_stanza_t *const stanza) } static void -_disco_info_get_handler(xmpp_stanza_t *const stanza) +_disco_info_get_handler(xmpp_stanza_t* const stanza) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - const char *from = xmpp_stanza_get_from(stanza); + xmpp_ctx_t* const ctx = connection_get_ctx(); + const char* from = xmpp_stanza_get_from(stanza); - xmpp_stanza_t *incoming_query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); - const char *node_str = xmpp_stanza_get_attribute(incoming_query, STANZA_ATTR_NODE); + xmpp_stanza_t* incoming_query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); + const char* node_str = xmpp_stanza_get_attribute(incoming_query, STANZA_ATTR_NODE); - const char *id = xmpp_stanza_get_id(stanza); + const char* id = xmpp_stanza_get_id(stanza); if (id) { log_debug("IQ disco info get handler fired, id: %s.", id); @@ -1774,10 +1788,10 @@ _disco_info_get_handler(xmpp_stanza_t *const stanza) cons_show("Received IQ disco info request (XEP-0232) from %s", from); } - xmpp_stanza_t *response = xmpp_iq_new(ctx, STANZA_TYPE_RESULT, xmpp_stanza_get_id(stanza)); + xmpp_stanza_t* response = xmpp_iq_new(ctx, STANZA_TYPE_RESULT, xmpp_stanza_get_id(stanza)); xmpp_stanza_set_to(response, from); - xmpp_stanza_t *query = stanza_create_caps_query_element(ctx); + xmpp_stanza_t* query = stanza_create_caps_query_element(ctx); if (node_str) { xmpp_stanza_set_attribute(query, STANZA_ATTR_NODE, node_str); } @@ -1790,9 +1804,9 @@ _disco_info_get_handler(xmpp_stanza_t *const stanza) } static int -_destroy_room_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata) +_destroy_room_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata) { - const char *id = xmpp_stanza_get_id(stanza); + const char* id = xmpp_stanza_get_id(stanza); if (id) { log_debug("IQ destroy room result handler fired, id: %s.", id); @@ -1800,7 +1814,7 @@ _destroy_room_result_id_handler(xmpp_stanza_t *const stanza, void *const userdat log_debug("IQ destroy room result handler fired."); } - const char *from = xmpp_stanza_get_from(stanza); + const char* from = xmpp_stanza_get_from(stanza); if (from == NULL) { log_error("No from attribute for IQ destroy room result"); } else { @@ -1811,11 +1825,11 @@ _destroy_room_result_id_handler(xmpp_stanza_t *const stanza, void *const userdat } static int -_room_config_id_handler(xmpp_stanza_t *const stanza, void *const userdata) +_room_config_id_handler(xmpp_stanza_t* const stanza, void* const userdata) { - const char *id = xmpp_stanza_get_id(stanza); - const char *type = xmpp_stanza_get_type(stanza); - const char *from = xmpp_stanza_get_from(stanza); + const char* id = xmpp_stanza_get_id(stanza); + const char* type = xmpp_stanza_get_type(stanza); + const char* from = xmpp_stanza_get_from(stanza); if (id) { log_debug("IQ room config handler fired, id: %s.", id); @@ -1825,7 +1839,7 @@ _room_config_id_handler(xmpp_stanza_t *const stanza, void *const userdata) // handle error responses if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { - char *error_message = stanza_get_error_message(stanza); + char* error_message = stanza_get_error_message(stanza); ui_handle_room_configuration_form_error(from, error_message); free(error_message); return 0; @@ -1837,41 +1851,41 @@ _room_config_id_handler(xmpp_stanza_t *const stanza, void *const userdata) return 0; } - xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); + xmpp_stanza_t* query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); if (query == NULL) { log_warning("No query element found parsing room config response"); ui_handle_room_configuration_form_error(from, "No query element found parsing room config response"); return 0; } - xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(query, STANZA_NS_DATA); + xmpp_stanza_t* x = xmpp_stanza_get_child_by_ns(query, STANZA_NS_DATA); if (x == NULL) { log_warning("No x element found with %s namespace parsing room config response", STANZA_NS_DATA); ui_handle_room_configuration_form_error(from, "No form configuration options available"); return 0; } - const char *form_type = xmpp_stanza_get_type(x); + const char* form_type = xmpp_stanza_get_type(x); if (g_strcmp0(form_type, "form") != 0) { log_warning("x element not of type 'form' parsing room config response"); ui_handle_room_configuration_form_error(from, "Form not of type 'form' parsing room config response."); return 0; } - DataForm *form = form_create(x); - ProfConfWin *confwin = (ProfConfWin*)wins_new_config(from, form, iq_submit_room_config, iq_room_config_cancel, NULL); + DataForm* form = form_create(x); + ProfConfWin* confwin = (ProfConfWin*)wins_new_config(from, form, iq_submit_room_config, iq_room_config_cancel, NULL); confwin_handle_configuration(confwin, form); return 0; } static int -_room_affiliation_set_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata) +_room_affiliation_set_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata) { - const char *id = xmpp_stanza_get_id(stanza); - const char *type = xmpp_stanza_get_type(stanza); - const char *from = xmpp_stanza_get_from(stanza); - ProfPrivilegeSet *affiliation_set = (ProfPrivilegeSet*)userdata; + const char* id = xmpp_stanza_get_id(stanza); + const char* type = xmpp_stanza_get_type(stanza); + const char* from = xmpp_stanza_get_from(stanza); + ProfPrivilegeSet* affiliation_set = (ProfPrivilegeSet*)userdata; if (id) { log_debug("IQ affiliation set handler fired, id: %s.", id); @@ -1881,9 +1895,9 @@ _room_affiliation_set_result_id_handler(xmpp_stanza_t *const stanza, void *const // handle error responses if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { - char *error_message = stanza_get_error_message(stanza); + char* error_message = stanza_get_error_message(stanza); log_debug("Error setting affiliation %s list for room %s, user %s: %s", affiliation_set->privilege, from, affiliation_set->item, error_message); - ProfMucWin *mucwin = wins_get_muc(from); + ProfMucWin* mucwin = wins_get_muc(from); if (mucwin) { mucwin_affiliation_set_error(mucwin, affiliation_set->item, affiliation_set->privilege, error_message); } @@ -1894,12 +1908,12 @@ _room_affiliation_set_result_id_handler(xmpp_stanza_t *const stanza, void *const } static int -_room_role_set_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata) +_room_role_set_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata) { - const char *id = xmpp_stanza_get_id(stanza); - const char *type = xmpp_stanza_get_type(stanza); - const char *from = xmpp_stanza_get_from(stanza); - ProfPrivilegeSet *role_set = (ProfPrivilegeSet*)userdata; + const char* id = xmpp_stanza_get_id(stanza); + const char* type = xmpp_stanza_get_type(stanza); + const char* from = xmpp_stanza_get_from(stanza); + ProfPrivilegeSet* role_set = (ProfPrivilegeSet*)userdata; if (id) { log_debug("IQ role set handler fired, id: %s.", id); @@ -1909,9 +1923,9 @@ _room_role_set_result_id_handler(xmpp_stanza_t *const stanza, void *const userda // handle error responses if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { - char *error_message = stanza_get_error_message(stanza); + char* error_message = stanza_get_error_message(stanza); log_debug("Error setting role %s list for room %s, user %s: %s", role_set->privilege, from, role_set->item, error_message); - ProfMucWin *mucwin = wins_get_muc(from); + ProfMucWin* mucwin = wins_get_muc(from); if (mucwin) { mucwin_role_set_error(mucwin, role_set->item, role_set->privilege, error_message); } @@ -1922,12 +1936,12 @@ _room_role_set_result_id_handler(xmpp_stanza_t *const stanza, void *const userda } static int -_room_affiliation_list_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata) +_room_affiliation_list_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata) { - const char *id = xmpp_stanza_get_id(stanza); - const char *type = xmpp_stanza_get_type(stanza); - const char *from = xmpp_stanza_get_from(stanza); - ProfAffiliationList *affiliation_list = (ProfAffiliationList *)userdata; + const char* id = xmpp_stanza_get_id(stanza); + const char* type = xmpp_stanza_get_type(stanza); + const char* from = xmpp_stanza_get_from(stanza); + ProfAffiliationList* affiliation_list = (ProfAffiliationList*)userdata; if (id) { log_debug("IQ affiliation list result handler fired, id: %s.", id); @@ -1937,28 +1951,28 @@ _room_affiliation_list_result_id_handler(xmpp_stanza_t *const stanza, void *cons // handle error responses if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { - char *error_message = stanza_get_error_message(stanza); + char* error_message = stanza_get_error_message(stanza); log_debug("Error retrieving %s list for room %s: %s", affiliation_list->affiliation, from, error_message); - ProfMucWin *mucwin = wins_get_muc(from); + ProfMucWin* mucwin = wins_get_muc(from); if (mucwin && affiliation_list->show_ui_message) { mucwin_affiliation_list_error(mucwin, affiliation_list->affiliation, error_message); } free(error_message); return 0; } - GSList *jids = NULL; + GSList* jids = NULL; - xmpp_stanza_t *query = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_ADMIN); + xmpp_stanza_t* query = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_ADMIN); if (query) { - xmpp_stanza_t *child = xmpp_stanza_get_children(query); + xmpp_stanza_t* child = xmpp_stanza_get_children(query); while (child) { - const char *name = xmpp_stanza_get_name(child); + const char* name = xmpp_stanza_get_name(child); if (g_strcmp0(name, "item") == 0) { - const char *jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID); + const char* jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID); if (jid) { if (g_strcmp0(affiliation_list->affiliation, "member") == 0 - || g_strcmp0(affiliation_list->affiliation, "owner") == 0 - || g_strcmp0(affiliation_list->affiliation, "admin") == 0) { + || g_strcmp0(affiliation_list->affiliation, "owner") == 0 + || g_strcmp0(affiliation_list->affiliation, "admin") == 0) { muc_members_add(from, jid); } jids = g_slist_insert_sorted(jids, (gpointer)jid, (GCompareFunc)g_strcmp0); @@ -1969,7 +1983,7 @@ _room_affiliation_list_result_id_handler(xmpp_stanza_t *const stanza, void *cons } muc_jid_autocomplete_add_all(from, jids); - ProfMucWin *mucwin = wins_get_muc(from); + ProfMucWin* mucwin = wins_get_muc(from); if (mucwin && affiliation_list->show_ui_message) { mucwin_handle_affiliation_list(mucwin, affiliation_list->affiliation, jids); } @@ -1979,12 +1993,12 @@ _room_affiliation_list_result_id_handler(xmpp_stanza_t *const stanza, void *cons } static int -_room_role_list_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata) +_room_role_list_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata) { - const char *id = xmpp_stanza_get_id(stanza); - const char *type = xmpp_stanza_get_type(stanza); - const char *from = xmpp_stanza_get_from(stanza); - char *role = (char *)userdata; + const char* id = xmpp_stanza_get_id(stanza); + const char* type = xmpp_stanza_get_type(stanza); + const char* from = xmpp_stanza_get_from(stanza); + char* role = (char*)userdata; if (id) { log_debug("IQ role list result handler fired, id: %s.", id); @@ -1994,24 +2008,24 @@ _room_role_list_result_id_handler(xmpp_stanza_t *const stanza, void *const userd // handle error responses if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { - char *error_message = stanza_get_error_message(stanza); + char* error_message = stanza_get_error_message(stanza); log_debug("Error retrieving %s list for room %s: %s", role, from, error_message); - ProfMucWin *mucwin = wins_get_muc(from); + ProfMucWin* mucwin = wins_get_muc(from); if (mucwin) { mucwin_role_list_error(mucwin, role, error_message); } free(error_message); return 0; } - GSList *nicks = NULL; + GSList* nicks = NULL; - xmpp_stanza_t *query = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_ADMIN); + xmpp_stanza_t* query = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_ADMIN); if (query) { - xmpp_stanza_t *child = xmpp_stanza_get_children(query); + xmpp_stanza_t* child = xmpp_stanza_get_children(query); while (child) { - const char *name = xmpp_stanza_get_name(child); + const char* name = xmpp_stanza_get_name(child); if (g_strcmp0(name, "item") == 0) { - const char *nick = xmpp_stanza_get_attribute(child, STANZA_ATTR_NICK); + const char* nick = xmpp_stanza_get_attribute(child, STANZA_ATTR_NICK); if (nick) { nicks = g_slist_insert_sorted(nicks, (gpointer)nick, (GCompareFunc)g_strcmp0); } @@ -2020,7 +2034,7 @@ _room_role_list_result_id_handler(xmpp_stanza_t *const stanza, void *const userd } } - ProfMucWin *mucwin = wins_get_muc(from); + ProfMucWin* mucwin = wins_get_muc(from); if (mucwin) { mucwin_handle_role_list(mucwin, role, nicks); } @@ -2030,11 +2044,11 @@ _room_role_list_result_id_handler(xmpp_stanza_t *const stanza, void *const userd } static int -_room_config_submit_id_handler(xmpp_stanza_t *const stanza, void *const userdata) +_room_config_submit_id_handler(xmpp_stanza_t* const stanza, void* const userdata) { - const char *id = xmpp_stanza_get_id(stanza); - const char *type = xmpp_stanza_get_type(stanza); - const char *from = xmpp_stanza_get_from(stanza); + const char* id = xmpp_stanza_get_id(stanza); + const char* type = xmpp_stanza_get_type(stanza); + const char* from = xmpp_stanza_get_from(stanza); if (id) { log_debug("IQ room config submit handler fired, id: %s.", id); @@ -2044,7 +2058,7 @@ _room_config_submit_id_handler(xmpp_stanza_t *const stanza, void *const userdata // handle error responses if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { - char *error_message = stanza_get_error_message(stanza); + char* error_message = stanza_get_error_message(stanza); ui_handle_room_config_submit_result_error(from, error_message); free(error_message); return 0; @@ -2056,12 +2070,12 @@ _room_config_submit_id_handler(xmpp_stanza_t *const stanza, void *const userdata } static int -_room_kick_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata) +_room_kick_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata) { - const char *id = xmpp_stanza_get_id(stanza); - const char *type = xmpp_stanza_get_type(stanza); - const char *from = xmpp_stanza_get_from(stanza); - char *nick = (char *)userdata; + const char* id = xmpp_stanza_get_id(stanza); + const char* type = xmpp_stanza_get_type(stanza); + const char* from = xmpp_stanza_get_from(stanza); + char* nick = (char*)userdata; if (id) { log_debug("IQ kick result handler fired, id: %s.", id); @@ -2070,9 +2084,9 @@ _room_kick_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata) } // handle error responses - ProfMucWin *mucwin = wins_get_muc(from); + ProfMucWin* mucwin = wins_get_muc(from); if (mucwin && (g_strcmp0(type, STANZA_TYPE_ERROR) == 0)) { - char *error_message = stanza_get_error_message(stanza); + char* error_message = stanza_get_error_message(stanza); mucwin_kick_error(mucwin, nick, error_message); free(error_message); } @@ -2081,7 +2095,7 @@ _room_kick_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata) } static void -_identity_destroy(DiscoIdentity *identity) +_identity_destroy(DiscoIdentity* identity) { if (identity) { free(identity->name); @@ -2092,7 +2106,7 @@ _identity_destroy(DiscoIdentity *identity) } static void -_item_destroy(DiscoItem *item) +_item_destroy(DiscoItem* item) { if (item) { free(item->jid); @@ -2102,47 +2116,47 @@ _item_destroy(DiscoItem *item) } static int -_room_info_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata) +_room_info_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata) { - const char *type = xmpp_stanza_get_type(stanza); - ProfRoomInfoData *cb_data = (ProfRoomInfoData *)userdata; + const char* type = xmpp_stanza_get_type(stanza); + ProfRoomInfoData* cb_data = (ProfRoomInfoData*)userdata; log_debug("Received disco#info response for room: %s", cb_data->room); // handle error responses if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { - ProfMucWin *mucwin = wins_get_muc(cb_data->room); + ProfMucWin* mucwin = wins_get_muc(cb_data->room); if (mucwin && cb_data->display) { - char *error_message = stanza_get_error_message(stanza); + char* error_message = stanza_get_error_message(stanza); mucwin_room_info_error(mucwin, error_message); free(error_message); } return 0; } - xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); + xmpp_stanza_t* query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); if (query) { - xmpp_stanza_t *child = xmpp_stanza_get_children(query); - GSList *identities = NULL; - GSList *features = NULL; + xmpp_stanza_t* child = xmpp_stanza_get_children(query); + GSList* identities = NULL; + GSList* features = NULL; while (child) { - const char *stanza_name = xmpp_stanza_get_name(child); + const char* stanza_name = xmpp_stanza_get_name(child); if (g_strcmp0(stanza_name, STANZA_NAME_FEATURE) == 0) { - const char *var = xmpp_stanza_get_attribute(child, STANZA_ATTR_VAR); + const char* var = xmpp_stanza_get_attribute(child, STANZA_ATTR_VAR); if (var) { features = g_slist_append(features, strdup(var)); } } else if (g_strcmp0(stanza_name, STANZA_NAME_IDENTITY) == 0) { - const char *name = xmpp_stanza_get_attribute(child, STANZA_ATTR_NAME); - const char *type = xmpp_stanza_get_type(child); - const char *category = xmpp_stanza_get_attribute(child, STANZA_ATTR_CATEGORY); + const char* name = xmpp_stanza_get_attribute(child, STANZA_ATTR_NAME); + const char* type = xmpp_stanza_get_type(child); + const char* category = xmpp_stanza_get_attribute(child, STANZA_ATTR_CATEGORY); if (name || category || type) { - DiscoIdentity *identity = malloc(sizeof(struct disco_identity_t)); + DiscoIdentity* identity = malloc(sizeof(struct disco_identity_t)); if (name) { identity->name = strdup(name); - ProfMucWin *mucwin = wins_get_muc(cb_data->room); + ProfMucWin* mucwin = wins_get_muc(cb_data->room); if (mucwin) { mucwin->room_name = strdup(name); } @@ -2168,7 +2182,7 @@ _room_info_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata } muc_set_features(cb_data->room, features); - ProfMucWin *mucwin = wins_get_muc(cb_data->room); + ProfMucWin* mucwin = wins_get_muc(cb_data->room); if (mucwin) { #ifdef HAVE_OMEMO if (muc_anonymity_type(mucwin->roomjid) == MUC_ANONYMITY_TYPE_NONANONYMOUS && omemo_automatic_start(cb_data->room)) { @@ -2189,20 +2203,20 @@ _room_info_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata } static int -_last_activity_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata) +_last_activity_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata) { - const char *from = xmpp_stanza_get_from(stanza); + const char* from = xmpp_stanza_get_from(stanza); if (!from) { cons_show_error("Invalid last activity response received."); log_info("Received last activity response with no from attribute."); return 0; } - const char *type = xmpp_stanza_get_type(stanza); + const char* type = xmpp_stanza_get_type(stanza); // handle error responses if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { - char *error_message = stanza_get_error_message(stanza); + char* error_message = stanza_get_error_message(stanza); if (from) { cons_show_error("Last activity request failed for %s: %s", from, error_message); } else { @@ -2212,7 +2226,7 @@ _last_activity_response_id_handler(xmpp_stanza_t *const stanza, void *const user return 0; } - xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); + xmpp_stanza_t* query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); if (!query) { cons_show_error("Invalid last activity response received."); @@ -2220,7 +2234,7 @@ _last_activity_response_id_handler(xmpp_stanza_t *const stanza, void *const user return 0; } - const char *seconds_str = xmpp_stanza_get_attribute(query, "seconds"); + const char* seconds_str = xmpp_stanza_get_attribute(query, "seconds"); if (!seconds_str) { cons_show_error("Invalid last activity response received."); log_info("Received last activity response with no seconds attribute."); @@ -2234,7 +2248,7 @@ _last_activity_response_id_handler(xmpp_stanza_t *const stanza, void *const user return 0; } - char *msg = xmpp_stanza_get_text(query); + char* msg = xmpp_stanza_get_text(query); sv_ev_lastactivity_response(from, seconds, msg); @@ -2243,10 +2257,10 @@ _last_activity_response_id_handler(xmpp_stanza_t *const stanza, void *const user } static int -_disco_info_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata) +_disco_info_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata) { - const char *from = xmpp_stanza_get_from(stanza); - const char *type = xmpp_stanza_get_type(stanza); + const char* from = xmpp_stanza_get_from(stanza); + const char* type = xmpp_stanza_get_type(stanza); if (from) { log_debug("Received disco#info response from: %s", from); @@ -2256,7 +2270,7 @@ _disco_info_response_id_handler(xmpp_stanza_t *const stanza, void *const userdat // handle error responses if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { - char *error_message = stanza_get_error_message(stanza); + char* error_message = stanza_get_error_message(stanza); if (from) { cons_show_error("Service discovery failed for %s: %s", from, error_message); } else { @@ -2266,26 +2280,26 @@ _disco_info_response_id_handler(xmpp_stanza_t *const stanza, void *const userdat return 0; } - xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); + xmpp_stanza_t* query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); if (query) { - xmpp_stanza_t *child = xmpp_stanza_get_children(query); - GSList *identities = NULL; - GSList *features = NULL; + xmpp_stanza_t* child = xmpp_stanza_get_children(query); + GSList* identities = NULL; + GSList* features = NULL; while (child) { - const char *stanza_name = xmpp_stanza_get_name(child); + const char* stanza_name = xmpp_stanza_get_name(child); if (g_strcmp0(stanza_name, STANZA_NAME_FEATURE) == 0) { - const char *var = xmpp_stanza_get_attribute(child, STANZA_ATTR_VAR); + const char* var = xmpp_stanza_get_attribute(child, STANZA_ATTR_VAR); if (var) { features = g_slist_append(features, strdup(var)); } } else if (g_strcmp0(stanza_name, STANZA_NAME_IDENTITY) == 0) { - const char *name = xmpp_stanza_get_attribute(child, STANZA_ATTR_NAME); - const char *type = xmpp_stanza_get_type(child); - const char *category = xmpp_stanza_get_attribute(child, STANZA_ATTR_CATEGORY); + const char* name = xmpp_stanza_get_attribute(child, STANZA_ATTR_NAME); + const char* type = xmpp_stanza_get_type(child); + const char* category = xmpp_stanza_get_attribute(child, STANZA_ATTR_CATEGORY); if (name || category || type) { - DiscoIdentity *identity = malloc(sizeof(struct disco_identity_t)); + DiscoIdentity* identity = malloc(sizeof(struct disco_identity_t)); if (name) { identity->name = strdup(name); @@ -2320,10 +2334,10 @@ _disco_info_response_id_handler(xmpp_stanza_t *const stanza, void *const userdat } static int -_disco_info_response_id_handler_onconnect(xmpp_stanza_t *const stanza, void *const userdata) +_disco_info_response_id_handler_onconnect(xmpp_stanza_t* const stanza, void* const userdata) { - const char *from = xmpp_stanza_get_from(stanza); - const char *type = xmpp_stanza_get_type(stanza); + const char* from = xmpp_stanza_get_from(stanza); + const char* type = xmpp_stanza_get_type(stanza); if (from) { log_debug("Received disco#info response from: %s", from); @@ -2333,7 +2347,7 @@ _disco_info_response_id_handler_onconnect(xmpp_stanza_t *const stanza, void *con // handle error responses if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { - char *error_message = stanza_get_error_message(stanza); + char* error_message = stanza_get_error_message(stanza); if (from) { log_error("Service discovery failed for %s: %s", from, error_message); } else { @@ -2343,20 +2357,20 @@ _disco_info_response_id_handler_onconnect(xmpp_stanza_t *const stanza, void *con return 0; } - xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); + xmpp_stanza_t* query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); if (query) { - GHashTable *features = connection_get_features(from); + GHashTable* features = connection_get_features(from); if (features == NULL) { log_error("No matching disco item found for %s", from); return 1; } - xmpp_stanza_t *child = xmpp_stanza_get_children(query); + xmpp_stanza_t* child = xmpp_stanza_get_children(query); while (child) { - const char *stanza_name = xmpp_stanza_get_name(child); + const char* stanza_name = xmpp_stanza_get_name(child); if (g_strcmp0(stanza_name, STANZA_NAME_FEATURE) == 0) { - const char *var = xmpp_stanza_get_attribute(child, STANZA_ATTR_VAR); + const char* var = xmpp_stanza_get_attribute(child, STANZA_ATTR_VAR); if (var) { g_hash_table_add(features, strdup(var)); } @@ -2371,11 +2385,11 @@ _disco_info_response_id_handler_onconnect(xmpp_stanza_t *const stanza, void *con } static int -_http_upload_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata) +_http_upload_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata) { - HTTPUpload *upload = (HTTPUpload *)userdata; - const char *from = xmpp_stanza_get_from(stanza); - const char *type = xmpp_stanza_get_type(stanza); + HTTPUpload* upload = (HTTPUpload*)userdata; + const char* from = xmpp_stanza_get_from(stanza); + const char* type = xmpp_stanza_get_type(stanza); if (from) { log_info("Received http_upload response from: %s", from); @@ -2385,7 +2399,7 @@ _http_upload_response_id_handler(xmpp_stanza_t *const stanza, void *const userda // handle error responses if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { - char *error_message = stanza_get_error_message(stanza); + char* error_message = stanza_get_error_message(stanza); if (from) { cons_show_error("Uploading '%s' failed for %s: %s", upload->filename, from, error_message); } else { @@ -2395,23 +2409,25 @@ _http_upload_response_id_handler(xmpp_stanza_t *const stanza, void *const userda return 0; } - xmpp_stanza_t *slot = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_SLOT); + xmpp_stanza_t* slot = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_SLOT); if (slot && g_strcmp0(xmpp_stanza_get_ns(slot), STANZA_NS_HTTP_UPLOAD) == 0) { - xmpp_stanza_t *put = xmpp_stanza_get_child_by_name(slot, STANZA_NAME_PUT); - xmpp_stanza_t *get = xmpp_stanza_get_child_by_name(slot, STANZA_NAME_GET); + xmpp_stanza_t* put = xmpp_stanza_get_child_by_name(slot, STANZA_NAME_PUT); + xmpp_stanza_t* get = xmpp_stanza_get_child_by_name(slot, STANZA_NAME_GET); if (put && get) { - char *put_url = xmpp_stanza_get_text(put); - char *get_url = xmpp_stanza_get_text(get); + char* put_url = xmpp_stanza_get_text(put); + char* get_url = xmpp_stanza_get_text(get); upload->put_url = strdup(put_url); upload->get_url = strdup(get_url); - xmpp_conn_t *conn = connection_get_conn(); - xmpp_ctx_t *ctx = xmpp_conn_get_context(conn); - if (put_url) xmpp_free(ctx, put_url); - if (get_url) xmpp_free(ctx, get_url); + xmpp_conn_t* conn = connection_get_conn(); + xmpp_ctx_t* ctx = xmpp_conn_get_context(conn); + if (put_url) + xmpp_free(ctx, put_url); + if (get_url) + xmpp_free(ctx, get_url); pthread_create(&(upload->worker), NULL, &http_file_put, upload); http_upload_add_upload(upload); @@ -2425,38 +2441,37 @@ _http_upload_response_id_handler(xmpp_stanza_t *const stanza, void *const userda } static void -_disco_items_result_handler(xmpp_stanza_t *const stanza) +_disco_items_result_handler(xmpp_stanza_t* const stanza) { log_debug("Received disco#items response"); - const char *id = xmpp_stanza_get_id(stanza); - const char *from = xmpp_stanza_get_from(stanza); - GSList *items = NULL; + const char* id = xmpp_stanza_get_id(stanza); + const char* from = xmpp_stanza_get_from(stanza); + GSList* items = NULL; - if ((g_strcmp0(id, "discoitemsreq") != 0) && - (g_strcmp0(id, "discoitemsreq_onconnect") != 0)) { + if ((g_strcmp0(id, "discoitemsreq") != 0) && (g_strcmp0(id, "discoitemsreq_onconnect") != 0)) { return; } log_debug("Response to query: %s", id); - xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); + xmpp_stanza_t* query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); if (query == NULL) { return; } - xmpp_stanza_t *child = xmpp_stanza_get_children(query); + xmpp_stanza_t* child = xmpp_stanza_get_children(query); if (child == NULL) { return; } while (child) { - const char *stanza_name = xmpp_stanza_get_name(child); + const char* stanza_name = xmpp_stanza_get_name(child); if (stanza_name && (g_strcmp0(stanza_name, STANZA_NAME_ITEM) == 0)) { - const char *item_jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID); + const char* item_jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID); if (item_jid) { - DiscoItem *item = malloc(sizeof(struct disco_item_t)); + DiscoItem* item = malloc(sizeof(struct disco_item_t)); item->jid = strdup(item_jid); - const char *item_name = xmpp_stanza_get_attribute(child, STANZA_ATTR_NAME); + const char* item_name = xmpp_stanza_get_attribute(child, STANZA_ATTR_NAME); if (item_name) { item->name = strdup(item_name); } else { @@ -2479,14 +2494,14 @@ _disco_items_result_handler(xmpp_stanza_t *const stanza) } void -iq_send_stanza(xmpp_stanza_t *const stanza) +iq_send_stanza(xmpp_stanza_t* const stanza) { - char *text; + char* text; size_t text_size; xmpp_stanza_to_text(stanza, &text, &text_size); - xmpp_conn_t *conn = connection_get_conn(); - char *plugin_text = plugins_on_iq_stanza_send(text); + xmpp_conn_t* conn = connection_get_conn(); + char* plugin_text = plugins_on_iq_stanza_send(text); if (plugin_text) { xmpp_send_raw_string(conn, "%s", plugin_text); free(plugin_text); @@ -2497,7 +2512,7 @@ iq_send_stanza(xmpp_stanza_t *const stanza) } static void -_iq_free_room_data(ProfRoomInfoData *roominfo) +_iq_free_room_data(ProfRoomInfoData* roominfo) { if (roominfo) { free(roominfo->room); @@ -2506,7 +2521,7 @@ _iq_free_room_data(ProfRoomInfoData *roominfo) } static void -_iq_free_affiliation_set(ProfPrivilegeSet *affiliation_set) +_iq_free_affiliation_set(ProfPrivilegeSet* affiliation_set) { if (affiliation_set) { free(affiliation_set->item); @@ -2516,7 +2531,7 @@ _iq_free_affiliation_set(ProfPrivilegeSet *affiliation_set) } static void -_iq_free_affiliation_list(ProfAffiliationList *affiliation_list) +_iq_free_affiliation_list(ProfAffiliationList* affiliation_list) { if (affiliation_list) { free(affiliation_list->affiliation); @@ -2525,26 +2540,26 @@ _iq_free_affiliation_list(ProfAffiliationList *affiliation_list) } void -iq_mam_request(ProfChatWin *win) +iq_mam_request(ProfChatWin* win) { - if (connection_supports(XMPP_FEATURE_MAM2) == FALSE) { + if (connection_supports(XMPP_FEATURE_MAM2) == FALSE) { log_warning("Server doesn't advertise %s feature.", XMPP_FEATURE_PING); cons_show_error("Server doesn't support MAM."); return; - } + } - xmpp_ctx_t * const ctx = connection_get_ctx(); - char *id = connection_create_stanza_id(); + xmpp_ctx_t* const ctx = connection_get_ctx(); + char* id = connection_create_stanza_id(); - GDateTime *now = g_date_time_new_now_local(); - GDateTime *timestamp = g_date_time_add_days(now, -1); + GDateTime* now = g_date_time_new_now_local(); + GDateTime* timestamp = g_date_time_add_days(now, -1); g_date_time_unref(now); - gchar *datestr = g_date_time_format(timestamp,"%FT%T%:::z"); - xmpp_stanza_t *iq = stanza_create_mam_iq(ctx, win->barejid, datestr); + gchar* datestr = g_date_time_format(timestamp, "%FT%T%:::z"); + xmpp_stanza_t* iq = stanza_create_mam_iq(ctx, win->barejid, datestr); g_free(datestr); g_date_time_unref(timestamp); -// iq_id_handler_add(id, _http_upload_response_id_handler, NULL, upload); + // iq_id_handler_add(id, _http_upload_response_id_handler, NULL, upload); free(id); iq_send_stanza(iq); diff --git a/src/xmpp/iq.h b/src/xmpp/iq.h index eba79034..887e832e 100644 --- a/src/xmpp/iq.h +++ b/src/xmpp/iq.h @@ -36,18 +36,18 @@ #ifndef XMPP_IQ_H #define XMPP_IQ_H -typedef int(*ProfIqCallback)(xmpp_stanza_t *const stanza, void *const userdata); -typedef void(*ProfIqFreeCallback)(void *userdata); +typedef int (*ProfIqCallback)(xmpp_stanza_t* const stanza, void* const userdata); +typedef void (*ProfIqFreeCallback)(void* userdata); void iq_handlers_init(void); -void iq_send_stanza(xmpp_stanza_t *const stanza); -void iq_id_handler_add(const char *const id, ProfIqCallback func, ProfIqFreeCallback free_func, void *userdata); -void iq_disco_info_request_onconnect(gchar *jid); -void iq_disco_items_request_onconnect(gchar *jid); -void iq_send_caps_request(const char *const to, const char *const id, const char *const node, const char *const ver); -void iq_send_caps_request_for_jid(const char *const to, const char *const id, const char *const node, - const char *const ver); -void iq_send_caps_request_legacy(const char *const to, const char *const id, const char *const node, - const char *const ver); +void iq_send_stanza(xmpp_stanza_t* const stanza); +void iq_id_handler_add(const char* const id, ProfIqCallback func, ProfIqFreeCallback free_func, void* userdata); +void iq_disco_info_request_onconnect(gchar* jid); +void iq_disco_items_request_onconnect(gchar* jid); +void iq_send_caps_request(const char* const to, const char* const id, const char* const node, const char* const ver); +void iq_send_caps_request_for_jid(const char* const to, const char* const id, const char* const node, + const char* const ver); +void iq_send_caps_request_legacy(const char* const to, const char* const id, const char* const node, + const char* const ver); #endif diff --git a/src/xmpp/jid.c b/src/xmpp/jid.c index a427a318..32743cb4 100644 --- a/src/xmpp/jid.c +++ b/src/xmpp/jid.c @@ -42,12 +42,12 @@ #include "xmpp/jid.h" Jid* -jid_create(const gchar *const str) +jid_create(const gchar* const str) { - Jid *result = NULL; + Jid* result = NULL; /* if str is NULL g_strdup returns NULL */ - gchar *trimmed = g_strdup(str); + gchar* trimmed = g_strdup(str); if (trimmed == NULL) { return NULL; } @@ -75,9 +75,9 @@ jid_create(const gchar *const str) result->barejid = NULL; result->fulljid = NULL; - gchar *atp = g_utf8_strchr(trimmed, -1, '@'); - gchar *slashp = g_utf8_strchr(trimmed, -1, '/'); - gchar *domain_start = trimmed; + gchar* atp = g_utf8_strchr(trimmed, -1, '@'); + gchar* slashp = g_utf8_strchr(trimmed, -1, '/'); + gchar* domain_start = trimmed; if (atp) { result->localpart = g_utf8_substring(trimmed, 0, g_utf8_pointer_to_offset(trimmed, atp)); @@ -87,7 +87,7 @@ jid_create(const gchar *const str) if (slashp) { result->resourcepart = g_strdup(slashp + 1); result->domainpart = g_utf8_substring(domain_start, 0, g_utf8_pointer_to_offset(domain_start, slashp)); - char *barejidraw = g_utf8_substring(trimmed, 0, g_utf8_pointer_to_offset(trimmed, slashp)); + char* barejidraw = g_utf8_substring(trimmed, 0, g_utf8_pointer_to_offset(trimmed, slashp)); result->barejid = g_utf8_strdown(barejidraw, -1); result->fulljid = g_strdup(trimmed); g_free(barejidraw); @@ -107,10 +107,10 @@ jid_create(const gchar *const str) } Jid* -jid_create_from_bare_and_resource(const char *const barejid, const char *const resource) +jid_create_from_bare_and_resource(const char* const barejid, const char* const resource) { - Jid *result; - char *jid = create_fulljid(barejid, resource); + Jid* result; + char* jid = create_fulljid(barejid, resource); result = jid_create(jid); free(jid); @@ -118,7 +118,7 @@ jid_create_from_bare_and_resource(const char *const barejid, const char *const r } void -jid_destroy(Jid *jid) +jid_destroy(Jid* jid) { if (jid == NULL) { return; @@ -134,7 +134,7 @@ jid_destroy(Jid *jid) } gboolean -jid_is_valid_room_form(Jid *jid) +jid_is_valid_room_form(Jid* jid) { return (jid->fulljid != NULL); } @@ -145,15 +145,15 @@ jid_is_valid_room_form(Jid *jid) * Will return a newly created string that must be freed by the caller */ char* -create_fulljid(const char *const barejid, const char *const resource) +create_fulljid(const char* const barejid, const char* const resource) { - gchar *barejidlower = g_utf8_strdown(barejid, -1); - GString *full_jid = g_string_new(barejidlower); + gchar* barejidlower = g_utf8_strdown(barejid, -1); + GString* full_jid = g_string_new(barejidlower); g_free(barejidlower); g_string_append(full_jid, "/"); g_string_append(full_jid, resource); - char *result = strdup(full_jid->str); + char* result = strdup(full_jid->str); g_string_free(full_jid, TRUE); @@ -166,10 +166,10 @@ create_fulljid(const char *const barejid, const char *const resource) * returns "person" */ char* -get_nick_from_full_jid(const char *const full_room_jid) +get_nick_from_full_jid(const char* const full_room_jid) { - char **tokens = g_strsplit(full_room_jid, "/", 0); - char *nick_part = NULL; + char** tokens = g_strsplit(full_room_jid, "/", 0); + char* nick_part = NULL; if (tokens) { if (tokens[0] && tokens[1]) { @@ -182,12 +182,11 @@ get_nick_from_full_jid(const char *const full_room_jid) return nick_part; } - /* * get the fulljid, fall back to the barejid */ char* -jid_fulljid_or_barejid(Jid *jid) +jid_fulljid_or_barejid(Jid* jid) { if (jid->fulljid) { return jid->fulljid; @@ -199,9 +198,9 @@ jid_fulljid_or_barejid(Jid *jid) char* jid_random_resource(void) { - char *rand = get_random_string(4); + char* rand = get_random_string(4); - gchar *result = g_strdup_printf("profanity.%s", rand); + gchar* result = g_strdup_printf("profanity.%s", rand); free(rand); return result; diff --git a/src/xmpp/jid.h b/src/xmpp/jid.h index dd9361a2..dae6cb2d 100644 --- a/src/xmpp/jid.h +++ b/src/xmpp/jid.h @@ -38,26 +38,27 @@ #include <glib.h> -struct jid_t { - char *str; - char *localpart; - char *domainpart; - char *resourcepart; - char *barejid; - char *fulljid; +struct jid_t +{ + char* str; + char* localpart; + char* domainpart; + char* resourcepart; + char* barejid; + char* fulljid; }; typedef struct jid_t Jid; -Jid* jid_create(const gchar *const str); -Jid* jid_create_from_bare_and_resource(const char *const barejid, const char *const resource); -void jid_destroy(Jid *jid); +Jid* jid_create(const gchar* const str); +Jid* jid_create_from_bare_and_resource(const char* const barejid, const char* const resource); +void jid_destroy(Jid* jid); -gboolean jid_is_valid_room_form(Jid *jid); -char* create_fulljid(const char *const barejid, const char *const resource); -char* get_nick_from_full_jid(const char *const full_room_jid); +gboolean jid_is_valid_room_form(Jid* jid); +char* create_fulljid(const char* const barejid, const char* const resource); +char* get_nick_from_full_jid(const char* const full_room_jid); -char* jid_fulljid_or_barejid(Jid *jid); +char* jid_fulljid_or_barejid(Jid* jid); char* jid_random_resource(void); #endif diff --git a/src/xmpp/message.c b/src/xmpp/message.c index a50b5518..f9940204 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -70,37 +70,38 @@ #include "omemo/omemo.h" #endif -typedef struct p_message_handle_t { +typedef struct p_message_handle_t +{ ProfMessageCallback func; ProfMessageFreeCallback free_func; - void *userdata; + void* userdata; } ProfMessageHandler; -static int _message_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata); -static void _handle_error(xmpp_stanza_t *const stanza); -static void _handle_groupchat(xmpp_stanza_t *const stanza); -static void _handle_muc_user(xmpp_stanza_t *const stanza); -static void _handle_muc_private_message(xmpp_stanza_t *const stanza); -static void _handle_conference(xmpp_stanza_t *const stanza); -static void _handle_captcha(xmpp_stanza_t *const stanza); -static void _handle_receipt_received(xmpp_stanza_t *const stanza); -static void _handle_chat(xmpp_stanza_t *const stanza, gboolean is_mam, gboolean is_carbon); -static void _handle_ox_chat(xmpp_stanza_t *const stanza, ProfMessage *message, gboolean is_mam); -static xmpp_stanza_t* _handle_carbons(xmpp_stanza_t *const stanza); -static void _send_message_stanza(xmpp_stanza_t *const stanza); -static gboolean _handle_mam(xmpp_stanza_t *const stanza); -static void _handle_pubsub(xmpp_stanza_t *const stanza, xmpp_stanza_t *const event); +static int _message_handler(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void* const userdata); +static void _handle_error(xmpp_stanza_t* const stanza); +static void _handle_groupchat(xmpp_stanza_t* const stanza); +static void _handle_muc_user(xmpp_stanza_t* const stanza); +static void _handle_muc_private_message(xmpp_stanza_t* const stanza); +static void _handle_conference(xmpp_stanza_t* const stanza); +static void _handle_captcha(xmpp_stanza_t* const stanza); +static void _handle_receipt_received(xmpp_stanza_t* const stanza); +static void _handle_chat(xmpp_stanza_t* const stanza, gboolean is_mam, gboolean is_carbon); +static void _handle_ox_chat(xmpp_stanza_t* const stanza, ProfMessage* message, gboolean is_mam); +static xmpp_stanza_t* _handle_carbons(xmpp_stanza_t* const stanza); +static void _send_message_stanza(xmpp_stanza_t* const stanza); +static gboolean _handle_mam(xmpp_stanza_t* const stanza); +static void _handle_pubsub(xmpp_stanza_t* const stanza, xmpp_stanza_t* const event); #ifdef HAVE_LIBGPGME static xmpp_stanza_t* _openpgp_signcrypt(xmpp_ctx_t* ctx, const char* const to, const char* const text); #endif // HAVE_LIBGPGME -static GHashTable *pubsub_event_handlers; +static GHashTable* pubsub_event_handlers; static gboolean -_handled_by_plugin(xmpp_stanza_t *const stanza) +_handled_by_plugin(xmpp_stanza_t* const stanza) { - char *text; + char* text; size_t text_size; xmpp_stanza_to_text(stanza, &text, &text_size); @@ -111,11 +112,11 @@ _handled_by_plugin(xmpp_stanza_t *const stanza) } static void -_handle_headline(xmpp_stanza_t *const stanza) +_handle_headline(xmpp_stanza_t* const stanza) { - xmpp_ctx_t *ctx = connection_get_ctx(); + xmpp_ctx_t* ctx = connection_get_ctx(); char* text = NULL; - xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BODY); + xmpp_stanza_t* body = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BODY); if (body) { text = xmpp_stanza_get_text(body); if (text) { @@ -126,7 +127,7 @@ _handle_headline(xmpp_stanza_t *const stanza) } static void -_handle_chat_states(xmpp_stanza_t *const stanza, Jid *const jid) +_handle_chat_states(xmpp_stanza_t* const stanza, Jid* const jid) { gboolean gone = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_GONE) != NULL; gboolean typing = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_COMPOSING) != NULL; @@ -148,7 +149,7 @@ _handle_chat_states(xmpp_stanza_t *const stanza, Jid *const jid) } static int -_message_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata) +_message_handler(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void* const userdata) { log_debug("Message stanza handler fired"); @@ -157,7 +158,7 @@ _message_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *con } // type according to RFC 6121 - const char *type = xmpp_stanza_get_type(stanza); + const char* type = xmpp_stanza_get_type(stanza); if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { _handle_error(stanza); @@ -166,7 +167,7 @@ _message_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *con _handle_groupchat(stanza); } else if (g_strcmp0(type, STANZA_TYPE_HEADLINE) == 0) { _handle_headline(stanza); - } else if (type == NULL || g_strcmp0(type, STANZA_TYPE_CHAT) != 0 || g_strcmp0(type, STANZA_TYPE_NORMAL) != 0 ) { + } else if (type == NULL || g_strcmp0(type, STANZA_TYPE_CHAT) != 0 || g_strcmp0(type, STANZA_TYPE_NORMAL) != 0) { // type: chat, normal (==NULL) // XEP-0313: Message Archive Management @@ -175,48 +176,48 @@ _message_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *con } // XEP-0045: Multi-User Chat - invites - presence - xmpp_stanza_t *mucuser = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); + xmpp_stanza_t* mucuser = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); if (mucuser) { _handle_muc_user(stanza); } // XEP-0249: Direct MUC Invitations - xmpp_stanza_t *conference = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CONFERENCE); + xmpp_stanza_t* conference = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CONFERENCE); if (conference) { _handle_conference(stanza); return 1; } // XEP-0158: CAPTCHA Forms - xmpp_stanza_t *captcha = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CAPTCHA); + xmpp_stanza_t* captcha = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CAPTCHA); if (captcha) { _handle_captcha(stanza); return 1; } // XEP-0184: Message Delivery Receipts - xmpp_stanza_t *receipts = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_RECEIPTS); + xmpp_stanza_t* receipts = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_RECEIPTS); if (receipts) { _handle_receipt_received(stanza); } // XEP-0060: Publish-Subscribe - xmpp_stanza_t *event = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB_EVENT); + xmpp_stanza_t* event = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB_EVENT); if (event) { _handle_pubsub(stanza, event); return 1; } - xmpp_stanza_t *msg_stanza = stanza; + xmpp_stanza_t* msg_stanza = stanza; gboolean is_carbon = FALSE; // XEP-0280: Message Carbons - xmpp_stanza_t *carbons = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CARBONS); + xmpp_stanza_t* carbons = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CARBONS); if (carbons) { // carbon must come from ourselves - char *mybarejid = connection_get_barejid(); - const char *const stanza_from = xmpp_stanza_get_from(stanza); + char* mybarejid = connection_get_barejid(); + const char* const stanza_from = xmpp_stanza_get_from(stanza); if (g_strcmp0(mybarejid, stanza_from) != 0) { log_warning("Invalid carbon received, from: %s", stanza_from); @@ -235,7 +236,7 @@ _message_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *con } } else { // none of the allowed types - char *text; + char* text; size_t text_size; xmpp_stanza_to_text(stanza, &text, &text_size); @@ -250,15 +251,15 @@ _message_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *con void message_handlers_init(void) { - xmpp_conn_t * const conn = connection_get_conn(); - xmpp_ctx_t * const ctx = connection_get_ctx(); + xmpp_conn_t* const conn = connection_get_conn(); + xmpp_ctx_t* const ctx = connection_get_ctx(); xmpp_handler_add(conn, _message_handler, NULL, STANZA_NAME_MESSAGE, NULL, ctx); if (pubsub_event_handlers) { - GList *keys = g_hash_table_get_keys(pubsub_event_handlers); - GList *curr = keys; + GList* keys = g_hash_table_get_keys(pubsub_event_handlers); + GList* curr = keys; while (curr) { - ProfMessageHandler *handler = g_hash_table_lookup(pubsub_event_handlers, curr->data); + ProfMessageHandler* handler = g_hash_table_lookup(pubsub_event_handlers, curr->data); if (handler->free_func && handler->userdata) { handler->free_func(handler->userdata); } @@ -271,10 +272,10 @@ message_handlers_init(void) pubsub_event_handlers = g_hash_table_new_full(g_str_hash, g_str_equal, free, free); } -ProfMessage * +ProfMessage* message_init(void) { - ProfMessage *message = malloc(sizeof(ProfMessage)); + ProfMessage* message = malloc(sizeof(ProfMessage)); message->from_jid = NULL; message->to_jid = NULL; @@ -293,9 +294,9 @@ message_init(void) } void -message_free(ProfMessage *message) +message_free(ProfMessage* message) { - xmpp_ctx_t *ctx = connection_get_ctx(); + xmpp_ctx_t* ctx = connection_get_ctx(); if (message->from_jid) { jid_destroy(message->from_jid); } @@ -344,9 +345,9 @@ message_handlers_clear(void) } void -message_pubsub_event_handler_add(const char *const node, ProfMessageCallback func, ProfMessageFreeCallback free_func, void *userdata) +message_pubsub_event_handler_add(const char* const node, ProfMessageCallback func, ProfMessageFreeCallback free_func, void* userdata) { - ProfMessageHandler *handler = malloc(sizeof(ProfMessageHandler)); + ProfMessageHandler* handler = malloc(sizeof(ProfMessageHandler)); handler->func = func; handler->free_func = free_func; handler->userdata = userdata; @@ -355,15 +356,15 @@ message_pubsub_event_handler_add(const char *const node, ProfMessageCallback fun } char* -message_send_chat(const char *const barejid, const char *const msg, const char *const oob_url, gboolean request_receipt, const char *const replace_id) +message_send_chat(const char* const barejid, const char* const msg, const char* const oob_url, gboolean request_receipt, const char* const replace_id) { - xmpp_ctx_t * const ctx = connection_get_ctx(); + xmpp_ctx_t* const ctx = connection_get_ctx(); - char *state = chat_session_get_state(barejid); - char *jid = chat_session_get_jid(barejid); - char *id = connection_create_stanza_id(); + char* state = chat_session_get_state(barejid); + char* jid = chat_session_get_jid(barejid); + char* id = connection_create_stanza_id(); - xmpp_stanza_t *message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, jid, id); + xmpp_stanza_t* message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, jid, id); xmpp_message_set_body(message, msg); free(jid); @@ -390,28 +391,28 @@ message_send_chat(const char *const barejid, const char *const msg, const char * } char* -message_send_chat_pgp(const char *const barejid, const char *const msg, gboolean request_receipt, const char *const replace_id) +message_send_chat_pgp(const char* const barejid, const char* const msg, gboolean request_receipt, const char* const replace_id) { - xmpp_ctx_t * const ctx = connection_get_ctx(); + xmpp_ctx_t* const ctx = connection_get_ctx(); - char *state = chat_session_get_state(barejid); - char *jid = chat_session_get_jid(barejid); - char *id = connection_create_stanza_id(); + char* state = chat_session_get_state(barejid); + char* jid = chat_session_get_jid(barejid); + char* id = connection_create_stanza_id(); - xmpp_stanza_t *message = NULL; + xmpp_stanza_t* message = NULL; #ifdef HAVE_LIBGPGME - char *account_name = session_get_account_name(); - ProfAccount *account = accounts_get_account(account_name); + char* account_name = session_get_account_name(); + ProfAccount* account = accounts_get_account(account_name); if (account->pgp_keyid) { - Jid *jidp = jid_create(jid); - char *encrypted = p_gpg_encrypt(jidp->barejid, msg, account->pgp_keyid); + Jid* jidp = jid_create(jid); + char* encrypted = p_gpg_encrypt(jidp->barejid, msg, account->pgp_keyid); if (encrypted) { message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, jid, id); xmpp_message_set_body(message, "This message is encrypted (XEP-0027)."); - xmpp_stanza_t *x = xmpp_stanza_new(ctx); + xmpp_stanza_t* x = xmpp_stanza_new(ctx); xmpp_stanza_set_name(x, STANZA_NAME_X); xmpp_stanza_set_ns(x, STANZA_NS_ENCRYPTED); - xmpp_stanza_t *enc_st = xmpp_stanza_new(ctx); + xmpp_stanza_t* enc_st = xmpp_stanza_new(ctx); xmpp_stanza_set_text(enc_st, encrypted); xmpp_stanza_add_child(x, enc_st); xmpp_stanza_release(enc_st); @@ -455,44 +456,44 @@ message_send_chat_pgp(const char *const barejid, const char *const msg, gboolean // XEP-0373: OpenPGP for XMPP char* -message_send_chat_ox(const char *const barejid, const char *const msg, gboolean request_receipt, const char *const replace_id) +message_send_chat_ox(const char* const barejid, const char* const msg, gboolean request_receipt, const char* const replace_id) { #ifdef HAVE_LIBGPGME - xmpp_ctx_t * const ctx = connection_get_ctx(); + xmpp_ctx_t* const ctx = connection_get_ctx(); - char *state = chat_session_get_state(barejid); - char *jid = chat_session_get_jid(barejid); - char *id = connection_create_stanza_id(); + char* state = chat_session_get_state(barejid); + char* jid = chat_session_get_jid(barejid); + char* id = connection_create_stanza_id(); - xmpp_stanza_t *message = NULL; - Jid *jidp = jid_create(jid); + xmpp_stanza_t* message = NULL; + Jid* jidp = jid_create(jid); - char *account_name = session_get_account_name(); - ProfAccount *account = accounts_get_account(account_name); + char* account_name = session_get_account_name(); + ProfAccount* account = accounts_get_account(account_name); message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, jid, id); xmpp_message_set_body(message, "This message is encrypted (XEP-0373: OpenPGP for XMPP)."); - xmpp_stanza_t *openpgp = xmpp_stanza_new(ctx); + xmpp_stanza_t* openpgp = xmpp_stanza_new(ctx); xmpp_stanza_set_name(openpgp, STANZA_NAME_OPENPGP); xmpp_stanza_set_ns(openpgp, STANZA_NS_OPENPGP_0); - xmpp_stanza_t * signcrypt = _openpgp_signcrypt(ctx, barejid, msg); + xmpp_stanza_t* signcrypt = _openpgp_signcrypt(ctx, barejid, msg); char* c; size_t s; - xmpp_stanza_to_text(signcrypt, &c,&s); + xmpp_stanza_to_text(signcrypt, &c, &s); char* signcrypt_e = p_ox_gpg_signcrypt(account->jid, barejid, c); - if( signcrypt_e == NULL ) { - log_error("Message not signcrypted."); - return NULL; + if (signcrypt_e == NULL) { + log_error("Message not signcrypted."); + return NULL; } // BASE64_OPENPGP_MESSAGE xmpp_stanza_t* base64_openpgp_message = xmpp_stanza_new(ctx); - xmpp_stanza_set_text(base64_openpgp_message,signcrypt_e); + xmpp_stanza_set_text(base64_openpgp_message, signcrypt_e); xmpp_stanza_add_child(openpgp, base64_openpgp_message); xmpp_stanza_add_child(message, openpgp); - xmpp_stanza_to_text(message, &c,&s); + xmpp_stanza_to_text(message, &c, &s); account_free(account); jid_destroy(jidp); @@ -519,15 +520,15 @@ message_send_chat_ox(const char *const barejid, const char *const msg, gboolean } char* -message_send_chat_otr(const char *const barejid, const char *const msg, gboolean request_receipt, const char *const replace_id) +message_send_chat_otr(const char* const barejid, const char* const msg, gboolean request_receipt, const char* const replace_id) { - xmpp_ctx_t * const ctx = connection_get_ctx(); + xmpp_ctx_t* const ctx = connection_get_ctx(); - char *state = chat_session_get_state(barejid); - char *jid = chat_session_get_jid(barejid); - char *id = connection_create_stanza_id(); + char* state = chat_session_get_state(barejid); + char* jid = chat_session_get_jid(barejid); + char* id = connection_create_stanza_id(); - xmpp_stanza_t *message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, barejid, id); + xmpp_stanza_t* message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, barejid, id); xmpp_message_set_body(message, msg); free(jid); @@ -556,15 +557,15 @@ message_send_chat_otr(const char *const barejid, const char *const msg, gboolean #ifdef HAVE_OMEMO char* -message_send_chat_omemo(const char *const jid, uint32_t sid, GList *keys, - const unsigned char *const iv, size_t iv_len, - const unsigned char *const ciphertext, size_t ciphertext_len, - gboolean request_receipt, gboolean muc, const char *const replace_id) +message_send_chat_omemo(const char* const jid, uint32_t sid, GList* keys, + const unsigned char* const iv, size_t iv_len, + const unsigned char* const ciphertext, size_t ciphertext_len, + gboolean request_receipt, gboolean muc, const char* const replace_id) { - char *state = chat_session_get_state(jid); - xmpp_ctx_t * const ctx = connection_get_ctx(); - char *id; - xmpp_stanza_t *message; + char* state = chat_session_get_state(jid); + xmpp_ctx_t* const ctx = connection_get_ctx(); + char* id; + xmpp_stanza_t* message; if (muc) { id = connection_create_stanza_id(); message = xmpp_message_new(ctx, STANZA_TYPE_GROUPCHAT, jid, id); @@ -574,31 +575,31 @@ message_send_chat_omemo(const char *const jid, uint32_t sid, GList *keys, message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, jid, id); } - xmpp_stanza_t *encrypted = xmpp_stanza_new(ctx); + xmpp_stanza_t* encrypted = xmpp_stanza_new(ctx); xmpp_stanza_set_name(encrypted, "encrypted"); xmpp_stanza_set_ns(encrypted, STANZA_NS_OMEMO); - xmpp_stanza_t *header = xmpp_stanza_new(ctx); + xmpp_stanza_t* header = xmpp_stanza_new(ctx); xmpp_stanza_set_name(header, "header"); - char *sid_text = g_strdup_printf("%d", sid); + char* sid_text = g_strdup_printf("%d", sid); xmpp_stanza_set_attribute(header, "sid", sid_text); g_free(sid_text); - GList *key_iter; + GList* key_iter; for (key_iter = keys; key_iter != NULL; key_iter = key_iter->next) { - omemo_key_t *key = (omemo_key_t *)key_iter->data; + omemo_key_t* key = (omemo_key_t*)key_iter->data; - xmpp_stanza_t *key_stanza = xmpp_stanza_new(ctx); + xmpp_stanza_t* key_stanza = xmpp_stanza_new(ctx); xmpp_stanza_set_name(key_stanza, "key"); - char *rid = g_strdup_printf("%d", key->device_id); + char* rid = g_strdup_printf("%d", key->device_id); xmpp_stanza_set_attribute(key_stanza, "rid", rid); g_free(rid); if (key->prekey) { xmpp_stanza_set_attribute(key_stanza, "prekey", "true"); } - gchar *key_raw = g_base64_encode(key->data, key->length); - xmpp_stanza_t *key_text = xmpp_stanza_new(ctx); + gchar* key_raw = g_base64_encode(key->data, key->length); + xmpp_stanza_t* key_text = xmpp_stanza_new(ctx); xmpp_stanza_set_text(key_text, key_raw); g_free(key_raw); @@ -608,11 +609,11 @@ message_send_chat_omemo(const char *const jid, uint32_t sid, GList *keys, xmpp_stanza_release(key_stanza); } - xmpp_stanza_t *iv_stanza = xmpp_stanza_new(ctx); + xmpp_stanza_t* iv_stanza = xmpp_stanza_new(ctx); xmpp_stanza_set_name(iv_stanza, "iv"); - gchar *iv_raw = g_base64_encode(iv, iv_len); - xmpp_stanza_t *iv_text = xmpp_stanza_new(ctx); + gchar* iv_raw = g_base64_encode(iv, iv_len); + xmpp_stanza_t* iv_text = xmpp_stanza_new(ctx); xmpp_stanza_set_text(iv_text, iv_raw); g_free(iv_raw); @@ -624,11 +625,11 @@ message_send_chat_omemo(const char *const jid, uint32_t sid, GList *keys, xmpp_stanza_add_child(encrypted, header); xmpp_stanza_release(header); - xmpp_stanza_t *payload = xmpp_stanza_new(ctx); + xmpp_stanza_t* payload = xmpp_stanza_new(ctx); xmpp_stanza_set_name(payload, "payload"); - gchar *ciphertext_raw = g_base64_encode(ciphertext, ciphertext_len); - xmpp_stanza_t *payload_text = xmpp_stanza_new(ctx); + gchar* ciphertext_raw = g_base64_encode(ciphertext, ciphertext_len); + xmpp_stanza_t* payload_text = xmpp_stanza_new(ctx); xmpp_stanza_set_text(payload_text, ciphertext_raw); g_free(ciphertext_raw); @@ -640,9 +641,9 @@ message_send_chat_omemo(const char *const jid, uint32_t sid, GList *keys, xmpp_stanza_add_child(message, encrypted); xmpp_stanza_release(encrypted); - xmpp_stanza_t *body = xmpp_stanza_new(ctx); + xmpp_stanza_t* body = xmpp_stanza_new(ctx); xmpp_stanza_set_name(body, "body"); - xmpp_stanza_t *body_text = xmpp_stanza_new(ctx); + xmpp_stanza_t* body_text = xmpp_stanza_new(ctx); xmpp_stanza_set_text(body_text, "You received a message encrypted with OMEMO but your client doesn't support OMEMO."); xmpp_stanza_add_child(body, body_text); xmpp_stanza_release(body_text); @@ -671,12 +672,12 @@ message_send_chat_omemo(const char *const jid, uint32_t sid, GList *keys, #endif char* -message_send_private(const char *const fulljid, const char *const msg, const char *const oob_url) +message_send_private(const char* const fulljid, const char* const msg, const char* const oob_url) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - char *id = connection_create_stanza_id(); + xmpp_ctx_t* const ctx = connection_get_ctx(); + char* id = connection_create_stanza_id(); - xmpp_stanza_t *message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, fulljid, id); + xmpp_stanza_t* message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, fulljid, id); xmpp_message_set_body(message, msg); if (oob_url) { @@ -690,12 +691,12 @@ message_send_private(const char *const fulljid, const char *const msg, const cha } char* -message_send_groupchat(const char *const roomjid, const char *const msg, const char *const oob_url, const char *const replace_id) +message_send_groupchat(const char* const roomjid, const char* const msg, const char* const oob_url, const char* const replace_id) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - char *id = connection_create_stanza_id(); + xmpp_ctx_t* const ctx = connection_get_ctx(); + char* id = connection_create_stanza_id(); - xmpp_stanza_t *message = xmpp_message_new(ctx, STANZA_TYPE_GROUPCHAT, roomjid, id); + xmpp_stanza_t* message = xmpp_message_new(ctx, STANZA_TYPE_GROUPCHAT, roomjid, id); stanza_attach_origin_id(ctx, message, id); xmpp_message_set_body(message, msg); @@ -714,26 +715,26 @@ message_send_groupchat(const char *const roomjid, const char *const msg, const c } void -message_send_groupchat_subject(const char *const roomjid, const char *const subject) +message_send_groupchat_subject(const char* const roomjid, const char* const subject) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - xmpp_stanza_t *message = stanza_create_room_subject_message(ctx, roomjid, subject); + xmpp_ctx_t* const ctx = connection_get_ctx(); + xmpp_stanza_t* message = stanza_create_room_subject_message(ctx, roomjid, subject); _send_message_stanza(message); xmpp_stanza_release(message); } void -message_send_invite(const char *const roomjid, const char *const contact, - const char *const reason) +message_send_invite(const char* const roomjid, const char* const contact, + const char* const reason) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - xmpp_stanza_t *stanza; + xmpp_ctx_t* const ctx = connection_get_ctx(); + xmpp_stanza_t* stanza; muc_member_type_t member_type = muc_member_type(roomjid); if (member_type == MUC_MEMBER_TYPE_PUBLIC) { log_debug("Sending direct invite to %s, for %s", contact, roomjid); - char *password = muc_password(roomjid); + char* password = muc_password(roomjid); stanza = stanza_create_invite(ctx, roomjid, contact, reason, password); } else { log_debug("Sending mediated invite to %s, for %s", contact, roomjid); @@ -745,59 +746,58 @@ message_send_invite(const char *const roomjid, const char *const contact, } void -message_send_composing(const char *const jid) +message_send_composing(const char* const jid) { - xmpp_ctx_t * const ctx = connection_get_ctx(); + xmpp_ctx_t* const ctx = connection_get_ctx(); - xmpp_stanza_t *stanza = stanza_create_chat_state(ctx, jid, STANZA_NAME_COMPOSING); + xmpp_stanza_t* stanza = stanza_create_chat_state(ctx, jid, STANZA_NAME_COMPOSING); _send_message_stanza(stanza); xmpp_stanza_release(stanza); - } void -message_send_paused(const char *const jid) +message_send_paused(const char* const jid) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - xmpp_stanza_t *stanza = stanza_create_chat_state(ctx, jid, STANZA_NAME_PAUSED); + xmpp_ctx_t* const ctx = connection_get_ctx(); + xmpp_stanza_t* stanza = stanza_create_chat_state(ctx, jid, STANZA_NAME_PAUSED); _send_message_stanza(stanza); xmpp_stanza_release(stanza); } void -message_send_inactive(const char *const jid) +message_send_inactive(const char* const jid) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - xmpp_stanza_t *stanza = stanza_create_chat_state(ctx, jid, STANZA_NAME_INACTIVE); + xmpp_ctx_t* const ctx = connection_get_ctx(); + xmpp_stanza_t* stanza = stanza_create_chat_state(ctx, jid, STANZA_NAME_INACTIVE); _send_message_stanza(stanza); xmpp_stanza_release(stanza); } void -message_send_gone(const char *const jid) +message_send_gone(const char* const jid) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - xmpp_stanza_t *stanza = stanza_create_chat_state(ctx, jid, STANZA_NAME_GONE); + xmpp_ctx_t* const ctx = connection_get_ctx(); + xmpp_stanza_t* stanza = stanza_create_chat_state(ctx, jid, STANZA_NAME_GONE); _send_message_stanza(stanza); xmpp_stanza_release(stanza); } static void -_handle_error(xmpp_stanza_t *const stanza) +_handle_error(xmpp_stanza_t* const stanza) { - const char *id = xmpp_stanza_get_id(stanza); - const char *jid = xmpp_stanza_get_from(stanza); - xmpp_stanza_t *error_stanza = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ERROR); - const char *type = NULL; + const char* id = xmpp_stanza_get_id(stanza); + const char* jid = xmpp_stanza_get_from(stanza); + xmpp_stanza_t* error_stanza = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ERROR); + const char* type = NULL; if (error_stanza) { type = xmpp_stanza_get_type(error_stanza); } // stanza_get_error never returns NULL - char *err_msg = stanza_get_error_message(stanza); + char* err_msg = stanza_get_error_message(stanza); - GString *log_msg = g_string_new("message stanza error received"); + GString* log_msg = g_string_new("message stanza error received"); if (id) { g_string_append(log_msg, " id="); g_string_append(log_msg, id); @@ -821,7 +821,7 @@ _handle_error(xmpp_stanza_t *const stanza) ui_handle_error(err_msg); } else if (type && (strcmp(type, "cancel") == 0)) { log_info("Recipient %s not found: %s", jid, err_msg); - Jid *jidp = jid_create(jid); + Jid* jidp = jid_create(jid); chat_session_remove(jidp->barejid); jid_destroy(jidp); } else { @@ -832,11 +832,11 @@ _handle_error(xmpp_stanza_t *const stanza) } static void -_handle_muc_user(xmpp_stanza_t *const stanza) +_handle_muc_user(xmpp_stanza_t* const stanza) { - xmpp_ctx_t *ctx = connection_get_ctx(); - xmpp_stanza_t *xns_muc_user = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); - const char *room = xmpp_stanza_get_from(stanza); + xmpp_ctx_t* ctx = connection_get_ctx(); + xmpp_stanza_t* xns_muc_user = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); + const char* room = xmpp_stanza_get_from(stanza); if (!room) { log_warning("Message received with no from attribute, ignoring"); @@ -844,31 +844,31 @@ _handle_muc_user(xmpp_stanza_t *const stanza) } // XEP-0045 - xmpp_stanza_t *invite = xmpp_stanza_get_child_by_name(xns_muc_user, STANZA_NAME_INVITE); + xmpp_stanza_t* invite = xmpp_stanza_get_child_by_name(xns_muc_user, STANZA_NAME_INVITE); if (!invite) { return; } - const char *invitor_jid = xmpp_stanza_get_from(invite); + const char* invitor_jid = xmpp_stanza_get_from(invite); if (!invitor_jid) { log_warning("Chat room invite received with no from attribute"); return; } - Jid *jidp = jid_create(invitor_jid); + Jid* jidp = jid_create(invitor_jid); if (!jidp) { return; } - char *invitor = jidp->barejid; + char* invitor = jidp->barejid; - char *reason = NULL; - xmpp_stanza_t *reason_st = xmpp_stanza_get_child_by_name(invite, STANZA_NAME_REASON); + char* reason = NULL; + xmpp_stanza_t* reason_st = xmpp_stanza_get_child_by_name(invite, STANZA_NAME_REASON); if (reason_st) { reason = xmpp_stanza_get_text(reason_st); } - char *password = NULL; - xmpp_stanza_t *password_st = xmpp_stanza_get_child_by_name(xns_muc_user, STANZA_NAME_PASSWORD); + char* password = NULL; + xmpp_stanza_t* password_st = xmpp_stanza_get_child_by_name(xns_muc_user, STANZA_NAME_PASSWORD); if (password_st) { password = xmpp_stanza_get_text(password_st); } @@ -884,40 +884,40 @@ _handle_muc_user(xmpp_stanza_t *const stanza) } static void -_handle_conference(xmpp_stanza_t *const stanza) +_handle_conference(xmpp_stanza_t* const stanza) { - xmpp_stanza_t *xns_conference = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CONFERENCE); + xmpp_stanza_t* xns_conference = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CONFERENCE); - const char *from = xmpp_stanza_get_from(stanza); + const char* from = xmpp_stanza_get_from(stanza); if (!from) { log_warning("Message received with no from attribute, ignoring"); return; } - Jid *jidp = jid_create(from); + Jid* jidp = jid_create(from); if (!jidp) { return; } // XEP-0249 - const char *room = xmpp_stanza_get_attribute(xns_conference, STANZA_ATTR_JID); + const char* room = xmpp_stanza_get_attribute(xns_conference, STANZA_ATTR_JID); if (!room) { jid_destroy(jidp); return; } - const char *reason = xmpp_stanza_get_attribute(xns_conference, STANZA_ATTR_REASON); - const char *password = xmpp_stanza_get_attribute(xns_conference, STANZA_ATTR_PASSWORD); + const char* reason = xmpp_stanza_get_attribute(xns_conference, STANZA_ATTR_REASON); + const char* password = xmpp_stanza_get_attribute(xns_conference, STANZA_ATTR_PASSWORD); sv_ev_room_invite(INVITE_DIRECT, jidp->barejid, room, reason, password); jid_destroy(jidp); } static void -_handle_captcha(xmpp_stanza_t *const stanza) +_handle_captcha(xmpp_stanza_t* const stanza) { - xmpp_ctx_t *ctx = connection_get_ctx(); - const char *from = xmpp_stanza_get_from(stanza); + xmpp_ctx_t* ctx = connection_get_ctx(); + const char* from = xmpp_stanza_get_from(stanza); if (!from) { log_warning("Message received with no from attribute, ignoring"); @@ -925,7 +925,7 @@ _handle_captcha(xmpp_stanza_t *const stanza) } // XEP-0158 - char *message = xmpp_message_get_body(stanza); + char* message = xmpp_message_get_body(stanza); if (!message) { return; } @@ -935,25 +935,25 @@ _handle_captcha(xmpp_stanza_t *const stanza) } static void -_handle_groupchat(xmpp_stanza_t *const stanza) +_handle_groupchat(xmpp_stanza_t* const stanza) { - xmpp_ctx_t *ctx = connection_get_ctx(); + xmpp_ctx_t* ctx = connection_get_ctx(); - const char *id = xmpp_stanza_get_id(stanza); - char *originid = NULL; + const char* id = xmpp_stanza_get_id(stanza); + char* originid = NULL; - xmpp_stanza_t *origin = stanza_get_child_by_name_and_ns(stanza, STANZA_NAME_ORIGIN_ID, STANZA_NS_STABLE_ID); + xmpp_stanza_t* origin = stanza_get_child_by_name_and_ns(stanza, STANZA_NAME_ORIGIN_ID, STANZA_NS_STABLE_ID); if (origin) { originid = (char*)xmpp_stanza_get_attribute(origin, STANZA_ATTR_ID); } - const char *room_jid = xmpp_stanza_get_from(stanza); - Jid *from_jid = jid_create(room_jid); + const char* room_jid = xmpp_stanza_get_from(stanza); + Jid* from_jid = jid_create(room_jid); // handle room subject - xmpp_stanza_t *subject = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_SUBJECT); + xmpp_stanza_t* subject = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_SUBJECT); if (subject) { - char *subject_text; + char* subject_text; subject_text = xmpp_stanza_get_text(subject); sv_ev_room_subject(from_jid->barejid, from_jid->resourcepart, subject_text); xmpp_free(ctx, subject_text); @@ -964,7 +964,7 @@ _handle_groupchat(xmpp_stanza_t *const stanza) // handle room broadcasts if (!from_jid->resourcepart) { - char *broadcast; + char* broadcast; broadcast = xmpp_message_get_body(stanza); if (!broadcast) { jid_destroy(from_jid); @@ -991,7 +991,7 @@ _handle_groupchat(xmpp_stanza_t *const stanza) return; } - ProfMessage *message = message_init(); + ProfMessage* message = message_init(); message->from_jid = from_jid; message->type = PROF_MSG_TYPE_MUC; @@ -1003,9 +1003,9 @@ _handle_groupchat(xmpp_stanza_t *const stanza) message->originid = strdup(originid); } - xmpp_stanza_t *replace_id_stanza = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_LAST_MESSAGE_CORRECTION); + xmpp_stanza_t* replace_id_stanza = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_LAST_MESSAGE_CORRECTION); if (replace_id_stanza) { - const char *replace_id = xmpp_stanza_get_id(replace_id_stanza); + const char* replace_id = xmpp_stanza_get_id(replace_id_stanza); if (replace_id) { message->replace_id = strdup(replace_id); } @@ -1063,15 +1063,15 @@ out: } static void -_message_send_receipt(const char *const fulljid, const char *const message_id) +_message_send_receipt(const char* const fulljid, const char* const message_id) { - xmpp_ctx_t * const ctx = connection_get_ctx(); + xmpp_ctx_t* const ctx = connection_get_ctx(); - char *id = connection_create_stanza_id(); - xmpp_stanza_t *message = xmpp_message_new(ctx, NULL, fulljid, id); + char* id = connection_create_stanza_id(); + xmpp_stanza_t* message = xmpp_message_new(ctx, NULL, fulljid, id); free(id); - xmpp_stanza_t *receipt = xmpp_stanza_new(ctx); + xmpp_stanza_t* receipt = xmpp_stanza_new(ctx); xmpp_stanza_set_name(receipt, "received"); xmpp_stanza_set_ns(receipt, STANZA_NS_RECEIPTS); xmpp_stanza_set_id(receipt, message_id); @@ -1084,69 +1084,69 @@ _message_send_receipt(const char *const fulljid, const char *const message_id) } static void -_handle_receipt_received(xmpp_stanza_t *const stanza) +_handle_receipt_received(xmpp_stanza_t* const stanza) { - xmpp_stanza_t *receipt = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_RECEIPTS); - const char *name = xmpp_stanza_get_name(receipt); + xmpp_stanza_t* receipt = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_RECEIPTS); + const char* name = xmpp_stanza_get_name(receipt); if (g_strcmp0(name, "received") != 0) { return; } - const char *id = xmpp_stanza_get_id(receipt); + const char* id = xmpp_stanza_get_id(receipt); if (!id) { return; } - const char *fulljid = xmpp_stanza_get_from(stanza); + const char* fulljid = xmpp_stanza_get_from(stanza); if (!fulljid) { return; } - Jid *jidp = jid_create(fulljid); + Jid* jidp = jid_create(fulljid); sv_ev_message_receipt(jidp->barejid, id); jid_destroy(jidp); } static void -_receipt_request_handler(xmpp_stanza_t *const stanza) +_receipt_request_handler(xmpp_stanza_t* const stanza) { if (!prefs_get_boolean(PREF_RECEIPTS_SEND)) { return; } - const char *id = xmpp_stanza_get_id(stanza); + const char* id = xmpp_stanza_get_id(stanza); if (!id) { return; } - xmpp_stanza_t *receipts = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_RECEIPTS); + xmpp_stanza_t* receipts = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_RECEIPTS); if (!receipts) { return; } - const char *receipts_name = xmpp_stanza_get_name(receipts); + const char* receipts_name = xmpp_stanza_get_name(receipts); if (g_strcmp0(receipts_name, "request") != 0) { return; } - const gchar *from = xmpp_stanza_get_from(stanza); - Jid *jid = jid_create(from); + const gchar* from = xmpp_stanza_get_from(stanza); + Jid* jid = jid_create(from); _message_send_receipt(jid->fulljid, id); jid_destroy(jid); } static void -_handle_muc_private_message(xmpp_stanza_t *const stanza) +_handle_muc_private_message(xmpp_stanza_t* const stanza) { // standard chat message, use jid without resource - ProfMessage *message = message_init(); + ProfMessage* message = message_init(); message->type = PROF_MSG_TYPE_MUCPM; - const gchar *from = xmpp_stanza_get_from(stanza); + const gchar* from = xmpp_stanza_get_from(stanza); message->from_jid = jid_create(from); // message stanza id - const char *id = xmpp_stanza_get_id(stanza); + const char* id = xmpp_stanza_get_id(stanza); if (id) { message->id = strdup(id); } @@ -1182,9 +1182,9 @@ out: } static xmpp_stanza_t* -_handle_carbons(xmpp_stanza_t *const stanza) +_handle_carbons(xmpp_stanza_t* const stanza) { - const char *name = xmpp_stanza_get_name(stanza); + const char* name = xmpp_stanza_get_name(stanza); if (!name) { log_error("Unable to retrieve stanza name for Carbon"); return NULL; @@ -1201,13 +1201,13 @@ _handle_carbons(xmpp_stanza_t *const stanza) return NULL; } - xmpp_stanza_t *forwarded = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_FORWARD); + xmpp_stanza_t* forwarded = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_FORWARD); if (!forwarded) { log_warning("Carbon received with no forwarded element"); return NULL; } - xmpp_stanza_t *message_stanza = xmpp_stanza_get_child_by_name(forwarded, STANZA_NAME_MESSAGE); + xmpp_stanza_t* message_stanza = xmpp_stanza_get_child_by_name(forwarded, STANZA_NAME_MESSAGE); if (!message_stanza) { log_warning("Carbon received with no message element"); return NULL; @@ -1217,25 +1217,25 @@ _handle_carbons(xmpp_stanza_t *const stanza) } static void -_handle_chat(xmpp_stanza_t *const stanza, gboolean is_mam, gboolean is_carbon) +_handle_chat(xmpp_stanza_t* const stanza, gboolean is_mam, gboolean is_carbon) { // some clients send the mucuser namespace with private messages // if the namespace exists, and the stanza contains a body element, assume its a private message // otherwise exit the handler - xmpp_stanza_t *mucuser = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); - xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BODY); + xmpp_stanza_t* mucuser = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); + xmpp_stanza_t* body = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BODY); if (mucuser && body == NULL) { return; } - const gchar *from = xmpp_stanza_get_from(stanza); + const gchar* from = xmpp_stanza_get_from(stanza); if (!from) { return; } - Jid *jid = jid_create(from); + Jid* jid = jid_create(from); - Jid *to_jid = NULL; - const gchar *to = xmpp_stanza_get_to(stanza); + Jid* to_jid = NULL; + const gchar* to = xmpp_stanza_get_to(stanza); if (to) { to_jid = jid_create(to); } @@ -1249,7 +1249,7 @@ _handle_chat(xmpp_stanza_t *const stanza, gboolean is_mam, gboolean is_carbon) } // standard chat message, use jid without resource - ProfMessage *message = message_init(); + ProfMessage* message = message_init(); message->is_mam = is_mam; message->from_jid = jid; if (to_jid) { @@ -1258,7 +1258,7 @@ _handle_chat(xmpp_stanza_t *const stanza, gboolean is_mam, gboolean is_carbon) if (is_carbon) { // happens when receive a carbon of a self sent message // really? maybe some servers do this, but it's not required. - Jid *from_jid = jid_create(from); + Jid* from_jid = jid_create(from); message->to_jid = from_jid; } } @@ -1269,21 +1269,21 @@ _handle_chat(xmpp_stanza_t *const stanza, gboolean is_mam, gboolean is_carbon) message->type = PROF_MSG_TYPE_CHAT; } - const gchar *to_text = xmpp_stanza_get_to(stanza); + const gchar* to_text = xmpp_stanza_get_to(stanza); if (to_text) { message->to_jid = jid_create(to_text); } // message stanza id - const char *id = xmpp_stanza_get_id(stanza); + const char* id = xmpp_stanza_get_id(stanza); if (id) { message->id = strdup(id); } // replace id for XEP-0308: Last Message Correction - xmpp_stanza_t *replace_id_stanza = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_LAST_MESSAGE_CORRECTION); + xmpp_stanza_t* replace_id_stanza = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_LAST_MESSAGE_CORRECTION); if (replace_id_stanza) { - const char *replace_id = xmpp_stanza_get_id(replace_id_stanza); + const char* replace_id = xmpp_stanza_get_id(replace_id_stanza); if (replace_id) { message->replace_id = strdup(replace_id); } @@ -1307,19 +1307,19 @@ _handle_chat(xmpp_stanza_t *const stanza, gboolean is_mam, gboolean is_carbon) } #endif - xmpp_stanza_t *encrypted = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_ENCRYPTED); + xmpp_stanza_t* encrypted = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_ENCRYPTED); if (encrypted) { message->encrypted = xmpp_stanza_get_text(encrypted); } - xmpp_stanza_t *ox = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_OPENPGP_0); + xmpp_stanza_t* ox = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_OPENPGP_0); if (ox) { - _handle_ox_chat(stanza,message, FALSE); + _handle_ox_chat(stanza, message, FALSE); } if (message->plain || message->body || message->encrypted) { if (is_carbon) { - char *mybarejid = connection_get_barejid(); + char* mybarejid = connection_get_barejid(); // if we are the recipient, treat as standard incoming message if (g_strcmp0(mybarejid, message->to_jid->barejid) == 0) { @@ -1345,18 +1345,17 @@ _handle_chat(xmpp_stanza_t *const stanza, gboolean is_mam, gboolean is_carbon) message_free(message); } - /*! * @brief Handle incoming XMMP-OX chat message. */ static void -_handle_ox_chat(xmpp_stanza_t *const stanza, ProfMessage *message, gboolean is_mam) +_handle_ox_chat(xmpp_stanza_t* const stanza, ProfMessage* message, gboolean is_mam) { - message->enc=PROF_MSG_ENC_OX; + message->enc = PROF_MSG_ENC_OX; #ifdef HAVE_LIBGPGME - xmpp_stanza_t *ox = stanza_get_child_by_name_and_ns(stanza, "openpgp", STANZA_NS_OPENPGP_0); - message->plain = p_ox_gpg_decrypt(xmpp_stanza_get_text(ox)); + xmpp_stanza_t* ox = stanza_get_child_by_name_and_ns(stanza, "openpgp", STANZA_NS_OPENPGP_0); + message->plain = p_ox_gpg_decrypt(xmpp_stanza_get_text(ox)); // Implementation for libstrophe 0.10. /* @@ -1370,40 +1369,41 @@ _handle_ox_chat(xmpp_stanza_t *const stanza, ProfMessage *message, gboolean is_m message->encrypted = xmpp_stanza_get_text(ox); */ - if(message->plain == NULL ) { + if (message->plain == NULL) { message->plain = xmpp_stanza_get_text(stanza); } - message->encrypted = xmpp_stanza_get_text(ox); + message->encrypted = xmpp_stanza_get_text(ox); #endif // HAVE_LIBGPGME } static gboolean -_handle_mam(xmpp_stanza_t *const stanza) +_handle_mam(xmpp_stanza_t* const stanza) { - xmpp_stanza_t *result = stanza_get_child_by_name_and_ns(stanza, "result", STANZA_NS_MAM2); + xmpp_stanza_t* result = stanza_get_child_by_name_and_ns(stanza, "result", STANZA_NS_MAM2); if (!result) { return FALSE; } - xmpp_stanza_t *forwarded = xmpp_stanza_get_child_by_ns(result, STANZA_NS_FORWARD); + xmpp_stanza_t* forwarded = xmpp_stanza_get_child_by_ns(result, STANZA_NS_FORWARD); if (!forwarded) { log_warning("MAM received with no forwarded element"); return FALSE; } - xmpp_stanza_t *message_stanza = xmpp_stanza_get_child_by_ns(forwarded, "jabber:client"); + xmpp_stanza_t* message_stanza = xmpp_stanza_get_child_by_ns(forwarded, "jabber:client"); _handle_chat(message_stanza, TRUE, FALSE); return TRUE; } static void -_handle_pubsub(xmpp_stanza_t *const stanza, xmpp_stanza_t *const event) { - xmpp_stanza_t *child = xmpp_stanza_get_children(event); +_handle_pubsub(xmpp_stanza_t* const stanza, xmpp_stanza_t* const event) +{ + xmpp_stanza_t* child = xmpp_stanza_get_children(event); if (child) { - const char *node = xmpp_stanza_get_attribute(child, STANZA_ATTR_NODE); + const char* node = xmpp_stanza_get_attribute(child, STANZA_ATTR_NODE); if (node) { - ProfMessageHandler *handler = g_hash_table_lookup(pubsub_event_handlers, node); + ProfMessageHandler* handler = g_hash_table_lookup(pubsub_event_handlers, node); if (handler) { int keep = handler->func(stanza, handler->userdata); if (!keep) { @@ -1415,14 +1415,14 @@ _handle_pubsub(xmpp_stanza_t *const stanza, xmpp_stanza_t *const event) { } static void -_send_message_stanza(xmpp_stanza_t *const stanza) +_send_message_stanza(xmpp_stanza_t* const stanza) { - char *text; + char* text; size_t text_size; xmpp_stanza_to_text(stanza, &text, &text_size); - xmpp_conn_t *conn = connection_get_conn(); - char *plugin_text = plugins_on_message_stanza_send(text); + xmpp_conn_t* conn = connection_get_conn(); + char* plugin_text = plugins_on_message_stanza_send(text); if (plugin_text) { xmpp_send_raw_string(conn, "%s", plugin_text); free(plugin_text); @@ -1436,13 +1436,14 @@ _send_message_stanza(xmpp_stanza_t *const stanza) * checkOID = false: check regular id */ bool -message_is_sent_by_us(const ProfMessage *const message, bool checkOID) { +message_is_sent_by_us(const ProfMessage* const message, bool checkOID) +{ bool ret = FALSE; // we check the </origin-id> for this we calculate a hash into it so we can detect // whether this client sent it. See connection_create_stanza_id() if (message) { - char *tmp_id = NULL; + char* tmp_id = NULL; if (checkOID && message->originid != NULL) { tmp_id = message->originid; @@ -1452,16 +1453,16 @@ message_is_sent_by_us(const ProfMessage *const message, bool checkOID) { if (tmp_id != NULL) { gsize tmp_len; - char *tmp = (char*)g_base64_decode(tmp_id, &tmp_len); + char* tmp = (char*)g_base64_decode(tmp_id, &tmp_len); // our client sents at least 36 (uuid) + identifier if (tmp_len > 36) { - char *uuid = g_strndup(tmp, 36); - const char *prof_identifier = connection_get_profanity_identifier(); + char* uuid = g_strndup(tmp, 36); + const char* prof_identifier = connection_get_profanity_identifier(); - gchar *hmac = g_compute_hmac_for_string(G_CHECKSUM_SHA256, - (guchar*)prof_identifier, strlen(prof_identifier), - uuid, strlen(uuid)); + gchar* hmac = g_compute_hmac_for_string(G_CHECKSUM_SHA256, + (guchar*)prof_identifier, strlen(prof_identifier), + uuid, strlen(uuid)); if (g_strcmp0(&tmp[36], hmac) == 0) { ret = TRUE; @@ -1474,7 +1475,7 @@ message_is_sent_by_us(const ProfMessage *const message, bool checkOID) { } } - return ret; + return ret; } #ifdef HAVE_LIBGPGME @@ -1488,44 +1489,44 @@ _openpgp_signcrypt(xmpp_ctx_t* ctx, const char* const to, const char* const text int randnr = rand() % 5; char rpad_data[randnr]; - for(int i = 0; i < randnr-1; i++) { + for (int i = 0; i < randnr - 1; i++) { rpad_data[i] = 'c'; } - rpad_data[randnr-1] = '\0'; + rpad_data[randnr - 1] = '\0'; // signcrypt - xmpp_stanza_t *signcrypt = xmpp_stanza_new(ctx); + xmpp_stanza_t* signcrypt = xmpp_stanza_new(ctx); xmpp_stanza_set_name(signcrypt, "signcrypt"); xmpp_stanza_set_ns(signcrypt, "urn:xmpp:openpgp:0"); // to - xmpp_stanza_t *s_to = xmpp_stanza_new(ctx); + xmpp_stanza_t* s_to = xmpp_stanza_new(ctx); xmpp_stanza_set_name(s_to, "to"); xmpp_stanza_set_attribute(s_to, "jid", to); // time - xmpp_stanza_t *time = xmpp_stanza_new(ctx); + xmpp_stanza_t* time = xmpp_stanza_new(ctx); xmpp_stanza_set_name(time, "time"); xmpp_stanza_set_attribute(time, "stamp", buf); xmpp_stanza_set_name(time, "time"); // rpad - xmpp_stanza_t *rpad = xmpp_stanza_new(ctx); + xmpp_stanza_t* rpad = xmpp_stanza_new(ctx); xmpp_stanza_set_name(rpad, "rpad"); - xmpp_stanza_t *rpad_text = xmpp_stanza_new(ctx); + xmpp_stanza_t* rpad_text = xmpp_stanza_new(ctx); xmpp_stanza_set_text(rpad_text, rpad_data); // payload - xmpp_stanza_t *payload= xmpp_stanza_new(ctx); + xmpp_stanza_t* payload = xmpp_stanza_new(ctx); xmpp_stanza_set_name(payload, "payload"); // body - xmpp_stanza_t *body = xmpp_stanza_new(ctx); + xmpp_stanza_t* body = xmpp_stanza_new(ctx); xmpp_stanza_set_name(body, "body"); xmpp_stanza_set_ns(body, "jabber:client"); // text - xmpp_stanza_t *body_text = xmpp_stanza_new(ctx); + xmpp_stanza_t* body_text = xmpp_stanza_new(ctx); xmpp_stanza_set_text(body_text, text); - xmpp_stanza_add_child(signcrypt,s_to); - xmpp_stanza_add_child(signcrypt,time); - xmpp_stanza_add_child(signcrypt,rpad); - xmpp_stanza_add_child(rpad,rpad_text); - xmpp_stanza_add_child(signcrypt,payload); + xmpp_stanza_add_child(signcrypt, s_to); + xmpp_stanza_add_child(signcrypt, time); + xmpp_stanza_add_child(signcrypt, rpad); + xmpp_stanza_add_child(rpad, rpad_text); + xmpp_stanza_add_child(signcrypt, payload); xmpp_stanza_add_child(payload, body); xmpp_stanza_add_child(body, body_text); @@ -1539,4 +1540,3 @@ _openpgp_signcrypt(xmpp_ctx_t* ctx, const char* const to, const char* const text return signcrypt; } #endif // HAVE_LIBGPGME - diff --git a/src/xmpp/message.h b/src/xmpp/message.h index aa82b2cf..fec5662a 100644 --- a/src/xmpp/message.h +++ b/src/xmpp/message.h @@ -38,13 +38,13 @@ #include "xmpp/xmpp.h" -typedef int(*ProfMessageCallback)(xmpp_stanza_t *const stanza, void *const userdata); -typedef void(*ProfMessageFreeCallback)(void *userdata); +typedef int (*ProfMessageCallback)(xmpp_stanza_t* const stanza, void* const userdata); +typedef void (*ProfMessageFreeCallback)(void* userdata); -ProfMessage *message_init(void); -void message_free(ProfMessage *message); +ProfMessage* message_init(void); +void message_free(ProfMessage* message); void message_handlers_init(void); void message_handlers_clear(void); -void message_pubsub_event_handler_add(const char *const node, ProfMessageCallback func, ProfMessageFreeCallback free_func, void *userdata); +void message_pubsub_event_handler_add(const char* const node, ProfMessageCallback func, ProfMessageFreeCallback free_func, void* userdata); #endif diff --git a/src/xmpp/muc.c b/src/xmpp/muc.c index 85f90ae6..0e42bef5 100644 --- a/src/xmpp/muc.c +++ b/src/xmpp/muc.c @@ -51,42 +51,43 @@ #include "omemo/omemo.h" #endif -typedef struct _muc_room_t { - char *room; // e.g. test@conference.server - char *nick; // e.g. Some User +typedef struct _muc_room_t +{ + char* room; // e.g. test@conference.server + char* nick; // e.g. Some User muc_role_t role; muc_affiliation_t affiliation; - char *password; - char *subject; - char *autocomplete_prefix; + char* password; + char* subject; + char* autocomplete_prefix; gboolean pending_config; - GList *pending_broadcasts; + GList* pending_broadcasts; gboolean autojoin; gboolean pending_nick_change; - GHashTable *roster; - GHashTable *members; + GHashTable* roster; + GHashTable* members; Autocomplete nick_ac; Autocomplete jid_ac; - GHashTable *nick_changes; + GHashTable* nick_changes; gboolean roster_received; muc_member_type_t member_type; muc_anonymity_type_t anonymity_type; } ChatRoom; -GHashTable *rooms = NULL; -GHashTable *invite_passwords = NULL; +GHashTable* rooms = NULL; +GHashTable* invite_passwords = NULL; Autocomplete invite_ac = NULL; Autocomplete confservers_ac = NULL; -static void _free_room(ChatRoom *room); -static gint _compare_occupants(Occupant *a, Occupant *b); -static muc_role_t _role_from_string(const char *const role); -static muc_affiliation_t _affiliation_from_string(const char *const affiliation); +static void _free_room(ChatRoom* room); +static gint _compare_occupants(Occupant* a, Occupant* b); +static muc_role_t _role_from_string(const char* const role); +static muc_affiliation_t _affiliation_from_string(const char* const affiliation); static char* _role_to_string(muc_role_t role); static char* _affiliation_to_string(muc_affiliation_t affiliation); -static Occupant* _muc_occupant_new(const char *const nick, const char *const jid, muc_role_t role, - muc_affiliation_t affiliation, resource_presence_t presence, const char *const status); -static void _occupant_free(Occupant *occupant); +static Occupant* _muc_occupant_new(const char* const nick, const char* const jid, muc_role_t role, + muc_affiliation_t affiliation, resource_presence_t presence, const char* const status); +static void _occupant_free(Occupant* occupant); void muc_init(void) @@ -111,13 +112,13 @@ muc_close(void) } void -muc_confserver_add(const char *const server) +muc_confserver_add(const char* const server) { autocomplete_add(confservers_ac, server); } void -muc_invites_add(const char *const room, const char *const password) +muc_invites_add(const char* const room, const char* const password) { autocomplete_add(invite_ac, room); if (password) { @@ -126,7 +127,7 @@ muc_invites_add(const char *const room, const char *const password) } void -muc_invites_remove(const char *const room) +muc_invites_remove(const char* const room) { autocomplete_remove(invite_ac, room); g_hash_table_remove(invite_passwords, room); @@ -145,16 +146,16 @@ muc_invites(void) } char* -muc_invite_password(const char *const room) +muc_invite_password(const char* const room) { return g_hash_table_lookup(invite_passwords, room); } gboolean -muc_invites_contain(const char *const room) +muc_invites_contain(const char* const room) { - GList *invites = autocomplete_create_list(invite_ac); - GList *curr = invites; + GList* invites = autocomplete_create_list(invite_ac); + GList* curr = invites; while (curr) { if (strcmp(curr->data, room) == 0) { g_list_free_full(invites, g_free); @@ -181,13 +182,13 @@ muc_confserver_reset_ac(void) } char* -muc_invites_find(const char *const search_str, gboolean previous, void *context) +muc_invites_find(const char* const search_str, gboolean previous, void* context) { return autocomplete_complete(invite_ac, search_str, TRUE, previous); } char* -muc_confserver_find(const char *const search_str, gboolean previous, void *context) +muc_confserver_find(const char* const search_str, gboolean previous, void* context) { return autocomplete_complete(confservers_ac, search_str, TRUE, previous); } @@ -208,9 +209,9 @@ muc_confserver_clear(void) } void -muc_join(const char *const room, const char *const nick, const char *const password, gboolean autojoin) +muc_join(const char* const room, const char* const nick, const char* const password, gboolean autojoin) { - ChatRoom *new_room = malloc(sizeof(ChatRoom)); + ChatRoom* new_room = malloc(sizeof(ChatRoom)); new_room->room = strdup(room); new_room->nick = strdup(nick); new_room->role = MUC_ROLE_NONE; @@ -239,36 +240,35 @@ muc_join(const char *const room, const char *const nick, const char *const passw } void -muc_leave(const char *const room) +muc_leave(const char* const room) { g_hash_table_remove(rooms, room); } gboolean -muc_requires_config(const char *const room) +muc_requires_config(const char* const room) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); if (chat_room) { return chat_room->pending_config; } else { return FALSE; } - } void -muc_set_requires_config(const char *const room, gboolean val) +muc_set_requires_config(const char* const room, gboolean val) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); if (chat_room) { chat_room->pending_config = val; } } void -muc_set_features(const char *const room, GSList *features) +muc_set_features(const char* const room, GSList* features) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); if (chat_room && features) { if (g_slist_find_custom(features, "muc_membersonly", (GCompareFunc)g_strcmp0)) { chat_room->member_type = MUC_MEMBER_TYPE_MEMBERS_ONLY; @@ -289,16 +289,16 @@ muc_set_features(const char *const room, GSList *features) * Returns TRUE if the user is currently in the room */ gboolean -muc_active(const char *const room) +muc_active(const char* const room) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); return (chat_room != NULL); } gboolean -muc_autojoin(const char *const room) +muc_autojoin(const char* const room) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); if (chat_room) { return chat_room->autojoin; } else { @@ -307,9 +307,9 @@ muc_autojoin(const char *const room) } void -muc_set_subject(const char *const room, const char *const subject) +muc_set_subject(const char* const room, const char* const subject) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); if (chat_room) { free(chat_room->subject); if (subject) { @@ -321,9 +321,9 @@ muc_set_subject(const char *const room, const char *const subject) } char* -muc_subject(const char *const room) +muc_subject(const char* const room) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); if (chat_room) { return chat_room->subject; } else { @@ -332,18 +332,18 @@ muc_subject(const char *const room) } void -muc_pending_broadcasts_add(const char *const room, const char *const message) +muc_pending_broadcasts_add(const char* const room, const char* const message) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); if (chat_room) { chat_room->pending_broadcasts = g_list_append(chat_room->pending_broadcasts, strdup(message)); } } GList* -muc_pending_broadcasts(const char *const room) +muc_pending_broadcasts(const char* const room) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); if (chat_room) { return chat_room->pending_broadcasts; } else { @@ -352,9 +352,9 @@ muc_pending_broadcasts(const char *const room) } char* -muc_old_nick(const char *const room, const char *const new_nick) +muc_old_nick(const char* const room, const char* const new_nick) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); if (chat_room && chat_room->pending_nick_change) { return g_hash_table_lookup(chat_room->nick_changes, new_nick); } else { @@ -367,9 +367,9 @@ muc_old_nick(const char *const room, const char *const new_nick) * and is awaiting the response */ void -muc_nick_change_start(const char *const room, const char *const new_nick) +muc_nick_change_start(const char* const room, const char* const new_nick) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); if (chat_room) { chat_room->pending_nick_change = TRUE; g_hash_table_insert(chat_room->nick_changes, strdup(new_nick), strdup(chat_room->nick)); @@ -381,9 +381,9 @@ muc_nick_change_start(const char *const room, const char *const new_nick) * nick change */ gboolean -muc_nick_change_pending(const char *const room) +muc_nick_change_pending(const char* const room) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); if (chat_room) { return chat_room->pending_nick_change; } else { @@ -396,9 +396,9 @@ muc_nick_change_pending(const char *const room) * the service has responded */ void -muc_nick_change_complete(const char *const room, const char *const nick) +muc_nick_change_complete(const char* const room, const char* const nick) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); if (chat_room) { g_hash_table_remove(chat_room->roster, chat_room->nick); autocomplete_remove(chat_room->nick_ac, chat_room->nick); @@ -425,9 +425,9 @@ muc_rooms(void) * The nickname is owned by the chat room and should not be modified or freed */ char* -muc_nick(const char *const room) +muc_nick(const char* const room) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); if (chat_room) { return chat_room->nick; } else { @@ -440,9 +440,9 @@ muc_nick(const char *const room) * The password is owned by the chat room and should not be modified or freed */ char* -muc_password(const char *const room) +muc_password(const char* const room) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); if (chat_room) { return chat_room->password; } else { @@ -454,11 +454,11 @@ muc_password(const char *const room) * Returns TRUE if the specified nick exists in the room's roster */ gboolean -muc_roster_contains_nick(const char *const room, const char *const nick) +muc_roster_contains_nick(const char* const room, const char* const nick) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); if (chat_room) { - Occupant *occupant = g_hash_table_lookup(chat_room->roster, nick); + Occupant* occupant = g_hash_table_lookup(chat_room->roster, nick); return (occupant != NULL); } else { return FALSE; @@ -469,32 +469,31 @@ muc_roster_contains_nick(const char *const room, const char *const nick) * Add a new chat room member to the room's roster */ gboolean -muc_roster_add(const char *const room, const char *const nick, const char *const jid, const char *const role, - const char *const affiliation, const char *const show, const char *const status) +muc_roster_add(const char* const room, const char* const nick, const char* const jid, const char* const role, + const char* const affiliation, const char* const show, const char* const status) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); gboolean updated = FALSE; resource_presence_t new_presence = resource_presence_from_string(show); if (chat_room) { - Occupant *old = g_hash_table_lookup(chat_room->roster, nick); + Occupant* old = g_hash_table_lookup(chat_room->roster, nick); if (!old) { updated = TRUE; autocomplete_add(chat_room->nick_ac, nick); - } else if (old->presence != new_presence || - (g_strcmp0(old->status, status) != 0)) { + } else if (old->presence != new_presence || (g_strcmp0(old->status, status) != 0)) { updated = TRUE; } resource_presence_t presence = resource_presence_from_string(show); muc_role_t role_t = _role_from_string(role); muc_affiliation_t affiliation_t = _affiliation_from_string(affiliation); - Occupant *occupant = _muc_occupant_new(nick, jid, role_t, affiliation_t, presence, status); + Occupant* occupant = _muc_occupant_new(nick, jid, role_t, affiliation_t, presence, status); g_hash_table_replace(chat_room->roster, strdup(nick), occupant); if (jid) { - Jid *jidp = jid_create(jid); + Jid* jidp = jid_create(jid); if (jidp->barejid) { autocomplete_add(chat_room->jid_ac, jidp->barejid); } @@ -509,9 +508,9 @@ muc_roster_add(const char *const room, const char *const nick, const char *const * Remove a room member from the room's roster */ void -muc_roster_remove(const char *const room, const char *const nick) +muc_roster_remove(const char* const room, const char* const nick) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); if (chat_room) { g_hash_table_remove(chat_room->roster, nick); autocomplete_remove(chat_room->nick_ac, nick); @@ -519,11 +518,11 @@ muc_roster_remove(const char *const room, const char *const nick) } Occupant* -muc_roster_item(const char *const room, const char *const nick) +muc_roster_item(const char* const room, const char* const nick) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); if (chat_room) { - Occupant *occupant = g_hash_table_lookup(chat_room->roster, nick); + Occupant* occupant = g_hash_table_lookup(chat_room->roster, nick); return occupant; } else { return NULL; @@ -534,14 +533,14 @@ muc_roster_item(const char *const room, const char *const nick) * Return a list of PContacts representing the room members in the room's roster */ GList* -muc_roster(const char *const room) +muc_roster(const char* const room) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); if (chat_room) { - GList *result = NULL; - GList *occupants = g_hash_table_get_values(chat_room->roster); + GList* result = NULL; + GList* occupants = g_hash_table_get_values(chat_room->roster); - GList *curr = occupants; + GList* curr = occupants; while (curr) { result = g_list_insert_sorted(result, curr->data, (GCompareFunc)_compare_occupants); curr = g_list_next(curr); @@ -559,9 +558,9 @@ muc_roster(const char *const room) * Return a Autocomplete representing the room member's in the roster */ Autocomplete -muc_roster_ac(const char *const room) +muc_roster_ac(const char* const room) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); if (chat_room) { return chat_room->nick_ac; } else { @@ -570,9 +569,9 @@ muc_roster_ac(const char *const room) } Autocomplete -muc_roster_jid_ac(const char *const room) +muc_roster_jid_ac(const char* const room) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); if (chat_room) { return chat_room->jid_ac; } else { @@ -584,9 +583,9 @@ muc_roster_jid_ac(const char *const room) * Set to TRUE when the rooms roster has been fully received */ void -muc_roster_set_complete(const char *const room) +muc_roster_set_complete(const char* const room) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); if (chat_room) { chat_room->roster_received = TRUE; } @@ -596,9 +595,9 @@ muc_roster_set_complete(const char *const room) * Returns TRUE id the rooms roster has been fully received */ gboolean -muc_roster_complete(const char *const room) +muc_roster_complete(const char* const room) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); if (chat_room) { return chat_room->roster_received; } else { @@ -607,36 +606,36 @@ muc_roster_complete(const char *const room) } gboolean -muc_occupant_available(Occupant *occupant) +muc_occupant_available(Occupant* occupant) { return (occupant->presence == RESOURCE_ONLINE || occupant->presence == RESOURCE_CHAT); } const char* -muc_occupant_affiliation_str(Occupant *occupant) +muc_occupant_affiliation_str(Occupant* occupant) { return _affiliation_to_string(occupant->affiliation); } const char* -muc_occupant_role_str(Occupant *occupant) +muc_occupant_role_str(Occupant* occupant) { return _role_to_string(occupant->role); } GSList* -muc_occupants_by_role(const char *const room, muc_role_t role) +muc_occupants_by_role(const char* const room, muc_role_t role) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); if (chat_room) { - GSList *result = NULL; + GSList* result = NULL; GHashTableIter iter; gpointer key; gpointer value; g_hash_table_iter_init(&iter, chat_room->roster); while (g_hash_table_iter_next(&iter, &key, &value)) { - Occupant *occupant = (Occupant *)value; + Occupant* occupant = (Occupant*)value; if (occupant->role == role) { result = g_slist_insert_sorted(result, value, (GCompareFunc)_compare_occupants); } @@ -648,18 +647,18 @@ muc_occupants_by_role(const char *const room, muc_role_t role) } GSList* -muc_occupants_by_affiliation(const char *const room, muc_affiliation_t affiliation) +muc_occupants_by_affiliation(const char* const room, muc_affiliation_t affiliation) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); if (chat_room) { - GSList *result = NULL; + GSList* result = NULL; GHashTableIter iter; gpointer key; gpointer value; g_hash_table_iter_init(&iter, chat_room->roster); while (g_hash_table_iter_next(&iter, &key, &value)) { - Occupant *occupant = (Occupant *)value; + Occupant* occupant = (Occupant*)value; if (occupant->affiliation == affiliation) { result = g_slist_insert_sorted(result, value, (GCompareFunc)_compare_occupants); } @@ -675,9 +674,9 @@ muc_occupants_by_affiliation(const char *const room, muc_affiliation_t affiliati * is in progress */ void -muc_occupant_nick_change_start(const char *const room, const char *const new_nick, const char *const old_nick) +muc_occupant_nick_change_start(const char* const room, const char* const new_nick, const char* const old_nick) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); if (chat_room) { g_hash_table_insert(chat_room->nick_changes, strdup(new_nick), strdup(old_nick)); muc_roster_remove(room, old_nick); @@ -691,13 +690,13 @@ muc_occupant_nick_change_start(const char *const room, const char *const new_nic * the caller */ char* -muc_roster_nick_change_complete(const char *const room, const char *const nick) +muc_roster_nick_change_complete(const char* const room, const char* const nick) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); if (chat_room) { - char *old_nick = g_hash_table_lookup(chat_room->nick_changes, nick); + char* old_nick = g_hash_table_lookup(chat_room->nick_changes, nick); if (old_nick) { - char *old_nick_cpy = strdup(old_nick); + char* old_nick_cpy = strdup(old_nick); g_hash_table_remove(chat_room->nick_changes, nick); return old_nick_cpy; @@ -708,40 +707,40 @@ muc_roster_nick_change_complete(const char *const room, const char *const nick) } char* -muc_autocomplete(ProfWin *window, const char *const input, gboolean previous) +muc_autocomplete(ProfWin* window, const char* const input, gboolean previous) { if (window->type != WIN_MUC) { return NULL; } - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); - ChatRoom *chat_room = g_hash_table_lookup(rooms, mucwin->roomjid); + ChatRoom* chat_room = g_hash_table_lookup(rooms, mucwin->roomjid); if (chat_room == NULL || chat_room->nick_ac == NULL) { return NULL; } - const char * search_str = NULL; + const char* search_str = NULL; - gchar *last_space = g_strrstr(input, " "); + gchar* last_space = g_strrstr(input, " "); if (!last_space) { search_str = input; if (!chat_room->autocomplete_prefix) { chat_room->autocomplete_prefix = strdup(""); } } else { - search_str = last_space+1; + search_str = last_space + 1; if (!chat_room->autocomplete_prefix) { chat_room->autocomplete_prefix = g_strndup(input, search_str - input); } } - char *result = autocomplete_complete(chat_room->nick_ac, search_str, FALSE, previous); + char* result = autocomplete_complete(chat_room->nick_ac, search_str, FALSE, previous); if (result == NULL) { return NULL; } - GString *replace_with = g_string_new(chat_room->autocomplete_prefix); + GString* replace_with = g_string_new(chat_room->autocomplete_prefix); g_string_append(replace_with, result); if (strlen(chat_room->autocomplete_prefix) == 0) { @@ -754,9 +753,9 @@ muc_autocomplete(ProfWin *window, const char *const input, gboolean previous) } void -muc_jid_autocomplete_reset(const char *const room) +muc_jid_autocomplete_reset(const char* const room) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); if (chat_room) { if (chat_room->jid_ac) { autocomplete_reset(chat_room->jid_ac); @@ -765,15 +764,15 @@ muc_jid_autocomplete_reset(const char *const room) } void -muc_jid_autocomplete_add_all(const char *const room, GSList *jids) +muc_jid_autocomplete_add_all(const char* const room, GSList* jids) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); if (chat_room) { if (chat_room->jid_ac) { - GSList *curr_jid = jids; + GSList* curr_jid = jids; while (curr_jid) { - const char *jid = curr_jid->data; - Jid *jidp = jid_create(jid); + const char* jid = curr_jid->data; + Jid* jidp = jid_create(jid); if (jidp) { if (jidp->barejid) { autocomplete_add(chat_room->jid_ac, jidp->barejid); @@ -787,9 +786,9 @@ muc_jid_autocomplete_add_all(const char *const room, GSList *jids) } void -muc_autocomplete_reset(const char *const room) +muc_autocomplete_reset(const char* const room) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); if (chat_room) { if (chat_room->nick_ac) { autocomplete_reset(chat_room->nick_ac); @@ -803,9 +802,9 @@ muc_autocomplete_reset(const char *const room) } char* -muc_role_str(const char *const room) +muc_role_str(const char* const room) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); if (chat_room) { return _role_to_string(chat_room->role); } else { @@ -814,18 +813,18 @@ muc_role_str(const char *const room) } void -muc_set_role(const char *const room, const char *const role) +muc_set_role(const char* const room, const char* const role) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); if (chat_room) { chat_room->role = _role_from_string(role); } } char* -muc_affiliation_str(const char *const room) +muc_affiliation_str(const char* const room) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); if (chat_room) { return _affiliation_to_string(chat_room->affiliation); } else { @@ -834,18 +833,18 @@ muc_affiliation_str(const char *const room) } void -muc_set_affiliation(const char *const room, const char *const affiliation) +muc_set_affiliation(const char* const room, const char* const affiliation) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); if (chat_room) { chat_room->affiliation = _affiliation_from_string(affiliation); } } muc_member_type_t -muc_member_type(const char *const room) +muc_member_type(const char* const room) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); if (chat_room) { return chat_room->member_type; } else { @@ -854,9 +853,9 @@ muc_member_type(const char *const room) } muc_anonymity_type_t -muc_anonymity_type(const char *const room) +muc_anonymity_type(const char* const room) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); if (chat_room) { return chat_room->anonymity_type; } else { @@ -868,9 +867,9 @@ muc_anonymity_type(const char *const room) * Return the list of jid affiliated as member in the room */ GList* -muc_members(const char *const room) +muc_members(const char* const room) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); if (chat_room) { return g_hash_table_get_keys(chat_room->members); } else { @@ -879,14 +878,14 @@ muc_members(const char *const room) } void -muc_members_add(const char *const room, const char *const jid) +muc_members_add(const char* const room, const char* const jid) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); if (chat_room) { if (g_hash_table_insert(chat_room->members, strdup(jid), NULL)) { #ifdef HAVE_OMEMO - if(chat_room->anonymity_type == MUC_ANONYMITY_TYPE_NONANONYMOUS ) { - char *our_barejid = connection_get_barejid(); + if (chat_room->anonymity_type == MUC_ANONYMITY_TYPE_NONANONYMOUS) { + char* our_barejid = connection_get_barejid(); if (strcmp(jid, our_barejid) != 0) { omemo_start_session(jid); } @@ -898,16 +897,16 @@ muc_members_add(const char *const room, const char *const jid) } void -muc_members_remove(const char *const room, const char *const jid) +muc_members_remove(const char* const room, const char* const jid) { - ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + ChatRoom* chat_room = g_hash_table_lookup(rooms, room); if (chat_room) { g_hash_table_remove(chat_room->members, jid); } } void -muc_members_update(const char *const room, const char *const jid, const char *const affiliation) +muc_members_update(const char* const room, const char* const jid, const char* const affiliation) { if (strcmp(affiliation, "outcast") == 0 || strcmp(affiliation, "none") == 0) { muc_members_remove(room, jid); @@ -917,7 +916,7 @@ muc_members_update(const char *const room, const char *const jid, const char *co } static void -_free_room(ChatRoom *room) +_free_room(ChatRoom* room) { if (room) { free(room->room); @@ -944,10 +943,10 @@ _free_room(ChatRoom *room) } static gint -_compare_occupants(Occupant *a, Occupant *b) +_compare_occupants(Occupant* a, Occupant* b) { - const char * utf8_str_a = a->nick_collate_key; - const char * utf8_str_b = b->nick_collate_key; + const char* utf8_str_a = a->nick_collate_key; + const char* utf8_str_b = b->nick_collate_key; gint result = g_strcmp0(utf8_str_a, utf8_str_b); @@ -955,7 +954,7 @@ _compare_occupants(Occupant *a, Occupant *b) } static muc_role_t -_role_from_string(const char *const role) +_role_from_string(const char* const role) { if (role) { if (g_strcmp0(role, "visitor") == 0) { @@ -975,7 +974,7 @@ _role_from_string(const char *const role) static char* _role_to_string(muc_role_t role) { - char *result = NULL; + char* result = NULL; switch (role) { case MUC_ROLE_NONE: @@ -999,7 +998,7 @@ _role_to_string(muc_role_t role) } static muc_affiliation_t -_affiliation_from_string(const char *const affiliation) +_affiliation_from_string(const char* const affiliation) { if (affiliation) { if (g_strcmp0(affiliation, "outcast") == 0) { @@ -1021,7 +1020,7 @@ _affiliation_from_string(const char *const affiliation) static char* _affiliation_to_string(muc_affiliation_t affiliation) { - char *result = NULL; + char* result = NULL; switch (affiliation) { case MUC_AFFILIATION_NONE: @@ -1048,10 +1047,10 @@ _affiliation_to_string(muc_affiliation_t affiliation) } static Occupant* -_muc_occupant_new(const char *const nick, const char *const jid, muc_role_t role, muc_affiliation_t affiliation, - resource_presence_t presence, const char *const status) +_muc_occupant_new(const char* const nick, const char* const jid, muc_role_t role, muc_affiliation_t affiliation, + resource_presence_t presence, const char* const status) { - Occupant *occupant = malloc(sizeof(Occupant)); + Occupant* occupant = malloc(sizeof(Occupant)); if (nick) { occupant->nick = strdup(nick); @@ -1082,7 +1081,7 @@ _muc_occupant_new(const char *const nick, const char *const jid, muc_role_t role } static void -_occupant_free(Occupant *occupant) +_occupant_free(Occupant* occupant) { if (occupant) { free(occupant->nick); diff --git a/src/xmpp/muc.h b/src/xmpp/muc.h index 1c5506ab..27fa0d4f 100644 --- a/src/xmpp/muc.h +++ b/src/xmpp/muc.h @@ -70,98 +70,99 @@ typedef enum { MUC_ANONYMITY_TYPE_SEMIANONYMOUS } muc_anonymity_type_t; -typedef struct _muc_occupant_t { - char *nick; - gchar *nick_collate_key; - char *jid; +typedef struct _muc_occupant_t +{ + char* nick; + gchar* nick_collate_key; + char* jid; muc_role_t role; muc_affiliation_t affiliation; resource_presence_t presence; - char *status; + char* status; } Occupant; void muc_init(void); void muc_close(void); -void muc_join(const char *const room, const char *const nick, const char *const password, gboolean autojoin); -void muc_leave(const char *const room); +void muc_join(const char* const room, const char* const nick, const char* const password, gboolean autojoin); +void muc_leave(const char* const room); -gboolean muc_active(const char *const room); -gboolean muc_autojoin(const char *const room); +gboolean muc_active(const char* const room); +gboolean muc_autojoin(const char* const room); GList* muc_rooms(void); -void muc_set_features(const char *const room, GSList *features); +void muc_set_features(const char* const room, GSList* features); -char* muc_nick(const char *const room); -char* muc_password(const char *const room); +char* muc_nick(const char* const room); +char* muc_password(const char* const room); -void muc_nick_change_start(const char *const room, const char *const new_nick); -void muc_nick_change_complete(const char *const room, const char *const nick); -gboolean muc_nick_change_pending(const char *const room); -char* muc_old_nick(const char *const room, const char *const new_nick); +void muc_nick_change_start(const char* const room, const char* const new_nick); +void muc_nick_change_complete(const char* const room, const char* const nick); +gboolean muc_nick_change_pending(const char* const room); +char* muc_old_nick(const char* const room, const char* const new_nick); -gboolean muc_roster_contains_nick(const char *const room, const char *const nick); -gboolean muc_roster_complete(const char *const room); -gboolean muc_roster_add(const char *const room, const char *const nick, const char *const jid, const char *const role, - const char *const affiliation, const char *const show, const char *const status); -void muc_roster_remove(const char *const room, const char *const nick); -void muc_roster_set_complete(const char *const room); -GList* muc_roster(const char *const room); -Autocomplete muc_roster_ac(const char *const room); -Autocomplete muc_roster_jid_ac(const char *const room); -void muc_jid_autocomplete_reset(const char *const room); -void muc_jid_autocomplete_add_all(const char *const room, GSList *jids); +gboolean muc_roster_contains_nick(const char* const room, const char* const nick); +gboolean muc_roster_complete(const char* const room); +gboolean muc_roster_add(const char* const room, const char* const nick, const char* const jid, const char* const role, + const char* const affiliation, const char* const show, const char* const status); +void muc_roster_remove(const char* const room, const char* const nick); +void muc_roster_set_complete(const char* const room); +GList* muc_roster(const char* const room); +Autocomplete muc_roster_ac(const char* const room); +Autocomplete muc_roster_jid_ac(const char* const room); +void muc_jid_autocomplete_reset(const char* const room); +void muc_jid_autocomplete_add_all(const char* const room, GSList* jids); -Occupant* muc_roster_item(const char *const room, const char *const nick); +Occupant* muc_roster_item(const char* const room, const char* const nick); -gboolean muc_occupant_available(Occupant *occupant); -const char* muc_occupant_affiliation_str(Occupant *occupant); -const char* muc_occupant_role_str(Occupant *occupant); -GSList* muc_occupants_by_role(const char *const room, muc_role_t role); -GSList* muc_occupants_by_affiliation(const char *const room, muc_affiliation_t affiliation); +gboolean muc_occupant_available(Occupant* occupant); +const char* muc_occupant_affiliation_str(Occupant* occupant); +const char* muc_occupant_role_str(Occupant* occupant); +GSList* muc_occupants_by_role(const char* const room, muc_role_t role); +GSList* muc_occupants_by_affiliation(const char* const room, muc_affiliation_t affiliation); -void muc_occupant_nick_change_start(const char *const room, const char *const new_nick, const char *const old_nick); -char* muc_roster_nick_change_complete(const char *const room, const char *const nick); +void muc_occupant_nick_change_start(const char* const room, const char* const new_nick, const char* const old_nick); +char* muc_roster_nick_change_complete(const char* const room, const char* const nick); -void muc_confserver_add(const char *const server); +void muc_confserver_add(const char* const server); void muc_confserver_reset_ac(void); -char* muc_confserver_find(const char *const search_str, gboolean previous, void *context); +char* muc_confserver_find(const char* const search_str, gboolean previous, void* context); void muc_confserver_clear(void); -void muc_invites_add(const char *const room, const char *const password); -void muc_invites_remove(const char *const room); +void muc_invites_add(const char* const room, const char* const password); +void muc_invites_remove(const char* const room); gint muc_invites_count(void); GList* muc_invites(void); -gboolean muc_invites_contain(const char *const room); +gboolean muc_invites_contain(const char* const room); void muc_invites_reset_ac(void); -char* muc_invites_find(const char *const search_str, gboolean previous, void *context); +char* muc_invites_find(const char* const search_str, gboolean previous, void* context); void muc_invites_clear(void); -char* muc_invite_password(const char *const room); +char* muc_invite_password(const char* const room); -void muc_set_subject(const char *const room, const char *const subject); -char* muc_subject(const char *const room); +void muc_set_subject(const char* const room, const char* const subject); +char* muc_subject(const char* const room); -void muc_pending_broadcasts_add(const char *const room, const char *const message); -GList* muc_pending_broadcasts(const char *const room); +void muc_pending_broadcasts_add(const char* const room, const char* const message); +GList* muc_pending_broadcasts(const char* const room); -char* muc_autocomplete(ProfWin *window, const char *const input, gboolean previous); -void muc_autocomplete_reset(const char *const room); +char* muc_autocomplete(ProfWin* window, const char* const input, gboolean previous); +void muc_autocomplete_reset(const char* const room); -gboolean muc_requires_config(const char *const room); -void muc_set_requires_config(const char *const room, gboolean val); +gboolean muc_requires_config(const char* const room); +void muc_set_requires_config(const char* const room, gboolean val); -void muc_set_role(const char *const room, const char *const role); -void muc_set_affiliation(const char *const room, const char *const affiliation); -char* muc_role_str(const char *const room); -char* muc_affiliation_str(const char *const room); +void muc_set_role(const char* const room, const char* const role); +void muc_set_affiliation(const char* const room, const char* const affiliation); +char* muc_role_str(const char* const room); +char* muc_affiliation_str(const char* const room); -muc_member_type_t muc_member_type(const char *const room); -muc_anonymity_type_t muc_anonymity_type(const char *const room); +muc_member_type_t muc_member_type(const char* const room); +muc_anonymity_type_t muc_anonymity_type(const char* const room); -GList* muc_members(const char *const room); -void muc_members_add(const char *const room, const char *const jid); -void muc_members_remove(const char *const room, const char *const jid); -void muc_members_update(const char *const room, const char *const jid, const char *const affiliation); +GList* muc_members(const char* const room); +void muc_members_add(const char* const room, const char* const jid); +void muc_members_remove(const char* const room, const char* const jid); +void muc_members_update(const char* const room, const char* const jid, const char* const affiliation); #endif diff --git a/src/xmpp/omemo.c b/src/xmpp/omemo.c index 2021816a..e527d4c7 100644 --- a/src/xmpp/omemo.c +++ b/src/xmpp/omemo.c @@ -44,10 +44,10 @@ #include "omemo/omemo.h" -static int _omemo_receive_devicelist(xmpp_stanza_t *const stanza, void *const userdata); -static int _omemo_bundle_publish_result(xmpp_stanza_t *const stanza, void *const userdata); -static int _omemo_bundle_publish_configure(xmpp_stanza_t *const stanza, void *const userdata); -static int _omemo_bundle_publish_configure_result(xmpp_stanza_t *const stanza, void *const userdata); +static int _omemo_receive_devicelist(xmpp_stanza_t* const stanza, void* const userdata); +static int _omemo_bundle_publish_result(xmpp_stanza_t* const stanza, void* const userdata); +static int _omemo_bundle_publish_configure(xmpp_stanza_t* const stanza, void* const userdata); +static int _omemo_bundle_publish_configure_result(xmpp_stanza_t* const stanza, void* const userdata); void omemo_devicelist_subscribe(void) @@ -58,10 +58,10 @@ omemo_devicelist_subscribe(void) } void -omemo_devicelist_publish(GList *device_list) +omemo_devicelist_publish(GList* device_list) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - xmpp_stanza_t *iq = stanza_create_omemo_devicelist_publish(ctx, device_list); + xmpp_ctx_t* const ctx = connection_get_ctx(); + xmpp_stanza_t* iq = stanza_create_omemo_devicelist_publish(ctx, device_list); if (connection_supports(XMPP_FEATURE_PUBSUB_PUBLISH_OPTIONS)) { stanza_attach_publish_options(ctx, iq, "pubsub#access_model", "open"); @@ -72,12 +72,12 @@ omemo_devicelist_publish(GList *device_list) } void -omemo_devicelist_request(const char * const jid) +omemo_devicelist_request(const char* const jid) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - char *id = connection_create_stanza_id(); + xmpp_ctx_t* const ctx = connection_get_ctx(); + char* id = connection_create_stanza_id(); - xmpp_stanza_t *iq = stanza_create_omemo_devicelist_request(ctx, id, jid); + xmpp_stanza_t* iq = stanza_create_omemo_devicelist_request(ctx, id, jid); iq_id_handler_add(id, _omemo_receive_devicelist, NULL, NULL); iq_send_stanza(iq); @@ -89,12 +89,12 @@ omemo_devicelist_request(const char * const jid) void omemo_bundle_publish(gboolean first) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - unsigned char *identity_key = NULL; + xmpp_ctx_t* const ctx = connection_get_ctx(); + unsigned char* identity_key = NULL; size_t identity_key_length; - unsigned char *signed_prekey = NULL; + unsigned char* signed_prekey = NULL; size_t signed_prekey_length; - unsigned char *signed_prekey_signature = NULL; + unsigned char* signed_prekey_signature = NULL; size_t signed_prekey_signature_length; GList *prekeys = NULL, *ids = NULL, *lengths = NULL; @@ -103,11 +103,11 @@ omemo_bundle_publish(gboolean first) omemo_signed_prekey_signature(&signed_prekey_signature, &signed_prekey_signature_length); omemo_prekeys(&prekeys, &ids, &lengths); - char *id = connection_create_stanza_id(); - xmpp_stanza_t *iq = stanza_create_omemo_bundle_publish(ctx, id, - omemo_device_id(), identity_key, identity_key_length, signed_prekey, - signed_prekey_length, signed_prekey_signature, - signed_prekey_signature_length, prekeys, ids, lengths); + char* id = connection_create_stanza_id(); + xmpp_stanza_t* iq = stanza_create_omemo_bundle_publish(ctx, id, + omemo_device_id(), identity_key, identity_key_length, signed_prekey, + signed_prekey_length, signed_prekey_signature, + signed_prekey_signature_length, prekeys, ids, lengths); g_list_free_full(prekeys, free); g_list_free(lengths); @@ -129,12 +129,12 @@ omemo_bundle_publish(gboolean first) } void -omemo_bundle_request(const char * const jid, uint32_t device_id, ProfIqCallback func, ProfIqFreeCallback free_func, void *userdata) +omemo_bundle_request(const char* const jid, uint32_t device_id, ProfIqCallback func, ProfIqFreeCallback free_func, void* userdata) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - char *id = connection_create_stanza_id(); + xmpp_ctx_t* const ctx = connection_get_ctx(); + char* id = connection_create_stanza_id(); - xmpp_stanza_t *iq = stanza_create_omemo_bundle_request(ctx, id, jid, device_id); + xmpp_stanza_t* iq = stanza_create_omemo_bundle_request(ctx, id, jid, device_id); iq_id_handler_add(id, func, free_func, userdata); iq_send_stanza(iq); @@ -144,17 +144,17 @@ omemo_bundle_request(const char * const jid, uint32_t device_id, ProfIqCallback } int -omemo_start_device_session_handle_bundle(xmpp_stanza_t *const stanza, void *const userdata) +omemo_start_device_session_handle_bundle(xmpp_stanza_t* const stanza, void* const userdata) { - GList *prekeys_list = NULL; - unsigned char *signed_prekey_raw = NULL; - unsigned char *signed_prekey_signature_raw = NULL; - char *from = NULL; + GList* prekeys_list = NULL; + unsigned char* signed_prekey_raw = NULL; + unsigned char* signed_prekey_signature_raw = NULL; + char* from = NULL; - const char *from_attr = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); + const char* from_attr = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); if (!from_attr) { - Jid *jid = jid_create(connection_get_fulljid()); + Jid* jid = jid_create(connection_get_fulljid()); from = strdup(jid->barejid); jid_destroy(jid); } else { @@ -165,62 +165,62 @@ omemo_start_device_session_handle_bundle(xmpp_stanza_t *const stanza, void *cons goto out; } - xmpp_stanza_t *pubsub = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB); + xmpp_stanza_t* pubsub = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB); if (!pubsub) { goto out; } - xmpp_stanza_t *items = xmpp_stanza_get_child_by_name(pubsub, "items"); + xmpp_stanza_t* items = xmpp_stanza_get_child_by_name(pubsub, "items"); if (!items) { goto out; } - const char *node = xmpp_stanza_get_attribute(items, "node"); - char *device_id_str = strstr(node, ":"); + const char* node = xmpp_stanza_get_attribute(items, "node"); + char* device_id_str = strstr(node, ":"); if (!device_id_str) { goto out; } uint32_t device_id = strtoul(++device_id_str, NULL, 10); - xmpp_stanza_t *item = xmpp_stanza_get_child_by_name(items, "item"); + xmpp_stanza_t* item = xmpp_stanza_get_child_by_name(items, "item"); if (!item) { goto out; } - xmpp_stanza_t *bundle = xmpp_stanza_get_child_by_ns(item, STANZA_NS_OMEMO); + xmpp_stanza_t* bundle = xmpp_stanza_get_child_by_ns(item, STANZA_NS_OMEMO); if (!bundle) { goto out; } - xmpp_stanza_t *prekeys = xmpp_stanza_get_child_by_name(bundle, "prekeys"); + xmpp_stanza_t* prekeys = xmpp_stanza_get_child_by_name(bundle, "prekeys"); if (!prekeys) { goto out; } - xmpp_stanza_t *prekey; + xmpp_stanza_t* prekey; for (prekey = xmpp_stanza_get_children(prekeys); prekey != NULL; prekey = xmpp_stanza_get_next(prekey)) { if (g_strcmp0(xmpp_stanza_get_name(prekey), "preKeyPublic") != 0) { continue; } - omemo_key_t *key = malloc(sizeof(omemo_key_t)); + omemo_key_t* key = malloc(sizeof(omemo_key_t)); key->data = NULL; - const char *prekey_id_text = xmpp_stanza_get_attribute(prekey, "preKeyId"); + const char* prekey_id_text = xmpp_stanza_get_attribute(prekey, "preKeyId"); if (!prekey_id_text) { omemo_key_free(key); continue; } key->id = strtoul(prekey_id_text, NULL, 10); - xmpp_stanza_t *prekey_text = xmpp_stanza_get_children(prekey); + xmpp_stanza_t* prekey_text = xmpp_stanza_get_children(prekey); if (!prekey_text) { omemo_key_free(key); continue; } - char *prekey_b64 = xmpp_stanza_get_text(prekey_text); + char* prekey_b64 = xmpp_stanza_get_text(prekey_text); key->data = g_base64_decode(prekey_b64, &key->length); free(prekey_b64); if (!key->data) { @@ -233,64 +233,64 @@ omemo_start_device_session_handle_bundle(xmpp_stanza_t *const stanza, void *cons prekeys_list = g_list_append(prekeys_list, key); } - xmpp_stanza_t *signed_prekey = xmpp_stanza_get_child_by_name(bundle, "signedPreKeyPublic"); + xmpp_stanza_t* signed_prekey = xmpp_stanza_get_child_by_name(bundle, "signedPreKeyPublic"); if (!signed_prekey) { goto out; } - const char *signed_prekey_id_text = xmpp_stanza_get_attribute(signed_prekey, "signedPreKeyId"); + const char* signed_prekey_id_text = xmpp_stanza_get_attribute(signed_prekey, "signedPreKeyId"); if (!signed_prekey_id_text) { goto out; } uint32_t signed_prekey_id = strtoul(signed_prekey_id_text, NULL, 10); - xmpp_stanza_t *signed_prekey_text = xmpp_stanza_get_children(signed_prekey); + xmpp_stanza_t* signed_prekey_text = xmpp_stanza_get_children(signed_prekey); if (!signed_prekey_text) { goto out; } size_t signed_prekey_len; - char *signed_prekey_b64 = xmpp_stanza_get_text(signed_prekey_text); + char* signed_prekey_b64 = xmpp_stanza_get_text(signed_prekey_text); signed_prekey_raw = g_base64_decode(signed_prekey_b64, &signed_prekey_len); free(signed_prekey_b64); if (!signed_prekey_raw) { goto out; } - xmpp_stanza_t *signed_prekey_signature = xmpp_stanza_get_child_by_name(bundle, "signedPreKeySignature"); + xmpp_stanza_t* signed_prekey_signature = xmpp_stanza_get_child_by_name(bundle, "signedPreKeySignature"); if (!signed_prekey_signature) { goto out; } - xmpp_stanza_t *signed_prekey_signature_text = xmpp_stanza_get_children(signed_prekey_signature); + xmpp_stanza_t* signed_prekey_signature_text = xmpp_stanza_get_children(signed_prekey_signature); if (!signed_prekey_signature_text) { goto out; } size_t signed_prekey_signature_len; - char *signed_prekey_signature_b64 = xmpp_stanza_get_text(signed_prekey_signature_text); + char* signed_prekey_signature_b64 = xmpp_stanza_get_text(signed_prekey_signature_text); signed_prekey_signature_raw = g_base64_decode(signed_prekey_signature_b64, &signed_prekey_signature_len); free(signed_prekey_signature_b64); if (!signed_prekey_signature_raw) { goto out; } - xmpp_stanza_t *identity_key = xmpp_stanza_get_child_by_name(bundle, "identityKey"); + xmpp_stanza_t* identity_key = xmpp_stanza_get_child_by_name(bundle, "identityKey"); if (!identity_key) { goto out; } - xmpp_stanza_t *identity_key_text = xmpp_stanza_get_children(identity_key); + xmpp_stanza_t* identity_key_text = xmpp_stanza_get_children(identity_key); if (!identity_key_text) { goto out; } size_t identity_key_len; - char *identity_key_b64 = xmpp_stanza_get_text(identity_key_text); - unsigned char *identity_key_raw = g_base64_decode(identity_key_b64, &identity_key_len); + char* identity_key_b64 = xmpp_stanza_get_text(identity_key_text); + unsigned char* identity_key_raw = g_base64_decode(identity_key_b64, &identity_key_len); free(identity_key_b64); if (!identity_key_raw) { goto out; } omemo_start_device_session(from, device_id, prekeys_list, signed_prekey_id, - signed_prekey_raw, signed_prekey_len, signed_prekey_signature_raw, - signed_prekey_signature_len, identity_key_raw, identity_key_len); + signed_prekey_raw, signed_prekey_len, signed_prekey_signature_raw, + signed_prekey_signature_len, identity_key_raw, identity_key_len); g_free(identity_key_raw); @@ -308,34 +308,34 @@ out: return 1; } -char * -omemo_receive_message(xmpp_stanza_t *const stanza, gboolean *trusted) +char* +omemo_receive_message(xmpp_stanza_t* const stanza, gboolean* trusted) { - char *plaintext = NULL; - const char *type = xmpp_stanza_get_type(stanza); - GList *keys = NULL; - unsigned char *iv_raw = NULL; - unsigned char *payload_raw = NULL; - char *iv_text = NULL; - char *payload_text = NULL; - - xmpp_stanza_t *encrypted = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_OMEMO); + char* plaintext = NULL; + const char* type = xmpp_stanza_get_type(stanza); + GList* keys = NULL; + unsigned char* iv_raw = NULL; + unsigned char* payload_raw = NULL; + char* iv_text = NULL; + char* payload_text = NULL; + + xmpp_stanza_t* encrypted = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_OMEMO); if (!encrypted) { return NULL; } - xmpp_stanza_t *header = xmpp_stanza_get_child_by_name(encrypted, "header"); + xmpp_stanza_t* header = xmpp_stanza_get_child_by_name(encrypted, "header"); if (!header) { return NULL; } - const char *sid_text = xmpp_stanza_get_attribute(header, "sid"); + const char* sid_text = xmpp_stanza_get_attribute(header, "sid"); if (!sid_text) { return NULL; } uint32_t sid = strtoul(sid_text, NULL, 10); - xmpp_stanza_t *iv = xmpp_stanza_get_child_by_name(header, "iv"); + xmpp_stanza_t* iv = xmpp_stanza_get_child_by_name(header, "iv"); if (!iv) { return NULL; } @@ -349,7 +349,7 @@ omemo_receive_message(xmpp_stanza_t *const stanza, gboolean *trusted) goto out; } - xmpp_stanza_t *payload = xmpp_stanza_get_child_by_name(encrypted, "payload"); + xmpp_stanza_t* payload = xmpp_stanza_get_child_by_name(encrypted, "payload"); if (!payload) { goto out; } @@ -363,19 +363,19 @@ omemo_receive_message(xmpp_stanza_t *const stanza, gboolean *trusted) goto out; } - xmpp_stanza_t *key_stanza; + xmpp_stanza_t* key_stanza; for (key_stanza = xmpp_stanza_get_children(header); key_stanza != NULL; key_stanza = xmpp_stanza_get_next(key_stanza)) { if (g_strcmp0(xmpp_stanza_get_name(key_stanza), "key") != 0) { continue; } - omemo_key_t *key = malloc(sizeof(omemo_key_t)); - char *key_text = xmpp_stanza_get_text(key_stanza); + omemo_key_t* key = malloc(sizeof(omemo_key_t)); + char* key_text = xmpp_stanza_get_text(key_stanza); if (!key_text) { goto skip; } - const char *rid_text = xmpp_stanza_get_attribute(key_stanza, "rid"); + const char* rid_text = xmpp_stanza_get_attribute(key_stanza, "rid"); key->device_id = strtoul(rid_text, NULL, 10); if (!key->device_id) { goto skip; @@ -386,21 +386,20 @@ omemo_receive_message(xmpp_stanza_t *const stanza, gboolean *trusted) if (!key->data) { goto skip; } - key->prekey = - g_strcmp0(xmpp_stanza_get_attribute(key_stanza, "prekey"), "true") == 0 - || g_strcmp0(xmpp_stanza_get_attribute(key_stanza, "prekey"), "1") == 0; + key->prekey = g_strcmp0(xmpp_stanza_get_attribute(key_stanza, "prekey"), "true") == 0 + || g_strcmp0(xmpp_stanza_get_attribute(key_stanza, "prekey"), "1") == 0; keys = g_list_append(keys, key); continue; -skip: + skip: free(key); } - const char *from = xmpp_stanza_get_from(stanza); + const char* from = xmpp_stanza_get_from(stanza); plaintext = omemo_on_message_recv(from, sid, iv_raw, iv_len, - keys, payload_raw, payload_len, - g_strcmp0(type, STANZA_TYPE_GROUPCHAT) == 0, trusted); + keys, payload_raw, payload_len, + g_strcmp0(type, STANZA_TYPE_GROUPCHAT) == 0, trusted); out: if (keys) { @@ -416,18 +415,18 @@ out: } static int -_omemo_receive_devicelist(xmpp_stanza_t *const stanza, void *const userdata) +_omemo_receive_devicelist(xmpp_stanza_t* const stanza, void* const userdata) { - GList *device_list = NULL; - const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); + GList* device_list = NULL; + const char* from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); - xmpp_stanza_t *root = NULL; - xmpp_stanza_t *event = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB_EVENT); + xmpp_stanza_t* root = NULL; + xmpp_stanza_t* event = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB_EVENT); if (event) { root = event; } - xmpp_stanza_t *pubsub = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB); + xmpp_stanza_t* pubsub = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB); if (pubsub) { root = pubsub; } @@ -436,21 +435,20 @@ _omemo_receive_devicelist(xmpp_stanza_t *const stanza, void *const userdata) return 1; } - xmpp_stanza_t *items = xmpp_stanza_get_child_by_name(root, "items"); + xmpp_stanza_t* items = xmpp_stanza_get_child_by_name(root, "items"); if (!items) { return 1; } - // Looking for "current" item - if there is no current, take the first item. xmpp_stanza_t* first = NULL; xmpp_stanza_t* current = NULL; - - xmpp_stanza_t *item = xmpp_stanza_get_children(items); - while ( item ) { + + xmpp_stanza_t* item = xmpp_stanza_get_children(items); + while (item) { if (g_strcmp0(xmpp_stanza_get_name(item), "item") == 0) { first = item; - if (g_strcmp0(xmpp_stanza_get_id(item), "current") == 0 ) { + if (g_strcmp0(xmpp_stanza_get_id(item), "current") == 0) { current = item; break; } @@ -458,27 +456,27 @@ _omemo_receive_devicelist(xmpp_stanza_t *const stanza, void *const userdata) item = xmpp_stanza_get_next(item); } - if(current) { + if (current) { item = current; - } else if( first ) { + } else if (first) { log_warning("OMEMO: User %s has a non 'current' device item list: %s.", from, xmpp_stanza_get_id(first)); item = first; } else { return 1; } - xmpp_stanza_t *list = xmpp_stanza_get_child_by_ns(item, STANZA_NS_OMEMO); + xmpp_stanza_t* list = xmpp_stanza_get_child_by_ns(item, STANZA_NS_OMEMO); if (!list) { return 1; } - xmpp_stanza_t *device; + xmpp_stanza_t* device; for (device = xmpp_stanza_get_children(list); device != NULL; device = xmpp_stanza_get_next(device)) { if (g_strcmp0(xmpp_stanza_get_name(device), "device") != 0) { continue; } - const char *id = xmpp_stanza_get_id(device); + const char* id = xmpp_stanza_get_id(device); if (id != NULL) { device_list = g_list_append(device_list, GINT_TO_POINTER(strtoul(id, NULL, 10))); } else { @@ -492,9 +490,9 @@ _omemo_receive_devicelist(xmpp_stanza_t *const stanza, void *const userdata) } static int -_omemo_bundle_publish_result(xmpp_stanza_t *const stanza, void *const userdata) +_omemo_bundle_publish_result(xmpp_stanza_t* const stanza, void* const userdata) { - const char *type = xmpp_stanza_get_type(stanza); + const char* type = xmpp_stanza_get_type(stanza); if (g_strcmp0(type, STANZA_TYPE_ERROR) != 0) { return 0; @@ -506,11 +504,11 @@ _omemo_bundle_publish_result(xmpp_stanza_t *const stanza, void *const userdata) } log_info("OMEMO: cannot publish bundle with open access model, trying to configure node"); - xmpp_ctx_t * const ctx = connection_get_ctx(); - Jid *jid = jid_create(connection_get_fulljid()); - char *id = connection_create_stanza_id(); - char *node = g_strdup_printf("%s:%d", STANZA_NS_OMEMO_BUNDLES, omemo_device_id()); - xmpp_stanza_t *iq = stanza_create_pubsub_configure_request(ctx, id, jid->barejid, node); + xmpp_ctx_t* const ctx = connection_get_ctx(); + Jid* jid = jid_create(connection_get_fulljid()); + char* id = connection_create_stanza_id(); + char* node = g_strdup_printf("%s:%d", STANZA_NS_OMEMO_BUNDLES, omemo_device_id()); + xmpp_stanza_t* iq = stanza_create_pubsub_configure_request(ctx, id, jid->barejid, node); g_free(node); iq_id_handler_add(id, _omemo_bundle_publish_configure, NULL, userdata); @@ -524,26 +522,26 @@ _omemo_bundle_publish_result(xmpp_stanza_t *const stanza, void *const userdata) } static int -_omemo_bundle_publish_configure(xmpp_stanza_t *const stanza, void *const userdata) +_omemo_bundle_publish_configure(xmpp_stanza_t* const stanza, void* const userdata) { /* TODO handle error */ - xmpp_stanza_t *pubsub = xmpp_stanza_get_child_by_name(stanza, "pubsub"); - xmpp_stanza_t *configure = xmpp_stanza_get_child_by_name(pubsub, STANZA_NAME_CONFIGURE); - xmpp_stanza_t *x = xmpp_stanza_get_child_by_name(configure, "x"); + xmpp_stanza_t* pubsub = xmpp_stanza_get_child_by_name(stanza, "pubsub"); + xmpp_stanza_t* configure = xmpp_stanza_get_child_by_name(pubsub, STANZA_NAME_CONFIGURE); + xmpp_stanza_t* x = xmpp_stanza_get_child_by_name(configure, "x"); DataForm* form = form_create(x); - char *tag = g_hash_table_lookup(form->var_to_tag, "pubsub#access_model"); + char* tag = g_hash_table_lookup(form->var_to_tag, "pubsub#access_model"); if (!tag) { log_info("OMEMO: cannot configure bundle to an open access model"); return 0; } form_set_value(form, tag, "open"); - xmpp_ctx_t * const ctx = connection_get_ctx(); - Jid *jid = jid_create(connection_get_fulljid()); - char *id = connection_create_stanza_id(); - char *node = g_strdup_printf("%s:%d", STANZA_NS_OMEMO_BUNDLES, omemo_device_id()); - xmpp_stanza_t *iq = stanza_create_pubsub_configure_submit(ctx, id, jid->barejid, node, form); + xmpp_ctx_t* const ctx = connection_get_ctx(); + Jid* jid = jid_create(connection_get_fulljid()); + char* id = connection_create_stanza_id(); + char* node = g_strdup_printf("%s:%d", STANZA_NS_OMEMO_BUNDLES, omemo_device_id()); + xmpp_stanza_t* iq = stanza_create_pubsub_configure_submit(ctx, id, jid->barejid, node, form); g_free(node); iq_id_handler_add(id, _omemo_bundle_publish_configure_result, NULL, userdata); @@ -557,9 +555,9 @@ _omemo_bundle_publish_configure(xmpp_stanza_t *const stanza, void *const userdat } static int -_omemo_bundle_publish_configure_result(xmpp_stanza_t *const stanza, void *const userdata) +_omemo_bundle_publish_configure_result(xmpp_stanza_t* const stanza, void* const userdata) { - const char *type = xmpp_stanza_get_type(stanza); + const char* type = xmpp_stanza_get_type(stanza); if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { log_error("OMEMO: cannot configure bundle to an open access model"); diff --git a/src/xmpp/omemo.h b/src/xmpp/omemo.h index bc025519..31021ab4 100644 --- a/src/xmpp/omemo.h +++ b/src/xmpp/omemo.h @@ -38,9 +38,9 @@ #include "xmpp/iq.h" void omemo_devicelist_subscribe(void); -void omemo_devicelist_publish(GList *device_list); -void omemo_devicelist_request(const char * const jid); +void omemo_devicelist_publish(GList* device_list); +void omemo_devicelist_request(const char* const jid); void omemo_bundle_publish(gboolean first); -void omemo_bundle_request(const char * const jid, uint32_t device_id, ProfIqCallback func, ProfIqFreeCallback free_func, void *userdata); -int omemo_start_device_session_handle_bundle(xmpp_stanza_t *const stanza, void *const userdata); -char * omemo_receive_message(xmpp_stanza_t *const stanza, gboolean *trusted); +void omemo_bundle_request(const char* const jid, uint32_t device_id, ProfIqCallback func, ProfIqFreeCallback free_func, void* userdata); +int omemo_start_device_session_handle_bundle(xmpp_stanza_t* const stanza, void* const userdata); +char* omemo_receive_message(xmpp_stanza_t* const stanza, gboolean* trusted); diff --git a/src/xmpp/ox.c b/src/xmpp/ox.c index 1ece9fde..1727bc34 100644 --- a/src/xmpp/ox.c +++ b/src/xmpp/ox.c @@ -77,8 +77,9 @@ static char* _gettimestamp(); * */ -gboolean -ox_announce_public_key(const char* const filename) { +gboolean +ox_announce_public_key(const char* const filename) +{ assert(filename); cons_show("Annonuce OpenPGP Key for OX %s ...", filename); @@ -89,13 +90,13 @@ ox_announce_public_key(const char* const filename) { char* fp = NULL; p_ox_gpg_readkey(filename, &key, &fp); - if( !(key && fp) ) { + if (!(key && fp)) { cons_show("Error during OpenPGP OX announce. See log file for more information"); return FALSE; } else { log_info("Annonuce OpenPGP Key for Fingerprint: %s", fp); - xmpp_ctx_t * const ctx = connection_get_ctx(); - char *id = xmpp_uuid_gen(ctx); + xmpp_ctx_t* const ctx = connection_get_ctx(); + char* id = xmpp_uuid_gen(ctx); xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); xmpp_stanza_set_from(iq, xmpp_conn_get_jid(connection_get_conn())); @@ -108,22 +109,21 @@ ox_announce_public_key(const char* const filename) { g_string_append(node_name, fp); xmpp_stanza_t* publish = xmpp_stanza_new(ctx); - xmpp_stanza_set_name(publish, STANZA_NAME_PUBLISH); - xmpp_stanza_set_attribute(publish, STANZA_ATTR_NODE, node_name->str) ; + xmpp_stanza_set_name(publish, STANZA_NAME_PUBLISH); + xmpp_stanza_set_attribute(publish, STANZA_ATTR_NODE, node_name->str); xmpp_stanza_t* item = xmpp_stanza_new(ctx); - xmpp_stanza_set_name(item, STANZA_NAME_ITEM); - xmpp_stanza_set_attribute(item, STANZA_ATTR_ID, _gettimestamp()) ; - + xmpp_stanza_set_name(item, STANZA_NAME_ITEM); + xmpp_stanza_set_attribute(item, STANZA_ATTR_ID, _gettimestamp()); + xmpp_stanza_t* pubkey = xmpp_stanza_new(ctx); - xmpp_stanza_set_name(pubkey, STANZA_NAME_PUPKEY); + xmpp_stanza_set_name(pubkey, STANZA_NAME_PUPKEY); xmpp_stanza_set_ns(pubkey, STANZA_NS_OPENPGP_0); - + xmpp_stanza_t* data = xmpp_stanza_new(ctx); - xmpp_stanza_set_name(data, STANZA_NAME_DATA); - xmpp_stanza_t* keydata = xmpp_stanza_new(ctx); - xmpp_stanza_set_text(keydata,key); - + xmpp_stanza_set_name(data, STANZA_NAME_DATA); + xmpp_stanza_t* keydata = xmpp_stanza_new(ctx); + xmpp_stanza_set_text(keydata, key); xmpp_stanza_add_child(data, keydata); xmpp_stanza_add_child(pubkey, data); @@ -131,10 +131,9 @@ ox_announce_public_key(const char* const filename) { xmpp_stanza_add_child(publish, item); xmpp_stanza_add_child(pubsub, publish); xmpp_stanza_add_child(iq, pubsub); - xmpp_send (connection_get_conn(), iq); + xmpp_send(connection_get_conn(), iq); _ox_metadata_node__public_key(fp); - } return TRUE; } @@ -166,14 +165,15 @@ ox_announce_public_key(const char* const filename) { * */ -void -_ox_metadata_node__public_key(const char* const fingerprint) { +void +_ox_metadata_node__public_key(const char* const fingerprint) +{ log_info("Annonuce OpenPGP metadata: %s", fingerprint); assert(fingerprint); assert(strlen(fingerprint) == 40); // iq - xmpp_ctx_t * const ctx = connection_get_ctx(); - char *id = xmpp_uuid_gen(ctx); + xmpp_ctx_t* const ctx = connection_get_ctx(); + char* id = xmpp_uuid_gen(ctx); xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); xmpp_stanza_set_from(iq, xmpp_conn_get_jid(connection_get_conn())); // pubsub @@ -182,31 +182,33 @@ _ox_metadata_node__public_key(const char* const fingerprint) { xmpp_stanza_set_ns(pubsub, XMPP_FEATURE_PUBSUB); // publish xmpp_stanza_t* publish = xmpp_stanza_new(ctx); - xmpp_stanza_set_name(publish, STANZA_NAME_PUBLISH); - xmpp_stanza_set_attribute(publish, STANZA_ATTR_NODE, STANZA_NS_OPENPGP_0_PUBLIC_KEYS) ; + xmpp_stanza_set_name(publish, STANZA_NAME_PUBLISH); + xmpp_stanza_set_attribute(publish, STANZA_ATTR_NODE, STANZA_NS_OPENPGP_0_PUBLIC_KEYS); // item xmpp_stanza_t* item = xmpp_stanza_new(ctx); xmpp_stanza_set_name(item, STANZA_NAME_ITEM); - // public-keys-list + // public-keys-list xmpp_stanza_t* publickeyslist = xmpp_stanza_new(ctx); - xmpp_stanza_set_name(publickeyslist, STANZA_NAME_PUBLIC_KEYS_LIST); + xmpp_stanza_set_name(publickeyslist, STANZA_NAME_PUBLIC_KEYS_LIST); xmpp_stanza_set_ns(publickeyslist, STANZA_NS_OPENPGP_0); // pubkey-metadata xmpp_stanza_t* pubkeymetadata = xmpp_stanza_new(ctx); - xmpp_stanza_set_name(pubkeymetadata, STANZA_NAME_PUBKEY_METADATA); + xmpp_stanza_set_name(pubkeymetadata, STANZA_NAME_PUBKEY_METADATA); xmpp_stanza_set_attribute(pubkeymetadata, STANZA_ATTR_V4_FINGERPRINT, fingerprint); xmpp_stanza_set_attribute(pubkeymetadata, STANZA_ATTR_DATE, _gettimestamp()); - xmpp_stanza_add_child(publickeyslist,pubkeymetadata ); - xmpp_stanza_add_child(item, publickeyslist ); - xmpp_stanza_add_child(publish,item ); + xmpp_stanza_add_child(publickeyslist, pubkeymetadata); + xmpp_stanza_add_child(item, publickeyslist); + xmpp_stanza_add_child(publish, item); xmpp_stanza_add_child(pubsub, publish); xmpp_stanza_add_child(iq, pubsub); - xmpp_send (connection_get_conn(), iq); -} + xmpp_send(connection_get_conn(), iq); +} // Date and Time (XEP-0082) -char* _gettimestamp() { +char* +_gettimestamp() +{ time_t now = time(NULL); struct tm* tm = localtime(&now); char buf[255]; diff --git a/src/xmpp/ox.h b/src/xmpp/ox.h index 8d959eb1..51435bb5 100644 --- a/src/xmpp/ox.h +++ b/src/xmpp/ox.h @@ -43,7 +43,6 @@ * https://xmpp.org/extensions/xep-0373.html */ - /*! * \brief Announcing OpenPGP public key from file to PEP. * @@ -57,5 +56,3 @@ */ gboolean ox_announce_public_key(const char* const filename); - - diff --git a/src/xmpp/presence.c b/src/xmpp/presence.c index e6f236cd..2982274d 100644 --- a/src/xmpp/presence.c +++ b/src/xmpp/presence.c @@ -67,19 +67,19 @@ static Autocomplete sub_requests_ac; -static int _presence_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata); +static int _presence_handler(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void* const userdata); -static void _presence_error_handler(xmpp_stanza_t *const stanza); -static void _unavailable_handler(xmpp_stanza_t *const stanza); -static void _subscribe_handler(xmpp_stanza_t *const stanza); -static void _subscribed_handler(xmpp_stanza_t *const stanza); -static void _unsubscribed_handler(xmpp_stanza_t *const stanza); -static void _muc_user_handler(xmpp_stanza_t *const stanza); -static void _available_handler(xmpp_stanza_t *const stanza); +static void _presence_error_handler(xmpp_stanza_t* const stanza); +static void _unavailable_handler(xmpp_stanza_t* const stanza); +static void _subscribe_handler(xmpp_stanza_t* const stanza); +static void _subscribed_handler(xmpp_stanza_t* const stanza); +static void _unsubscribed_handler(xmpp_stanza_t* const stanza); +static void _muc_user_handler(xmpp_stanza_t* const stanza); +static void _available_handler(xmpp_stanza_t* const stanza); -void _send_caps_request(char *node, char *caps_key, char *id, char *from); -static void _send_room_presence(xmpp_stanza_t *presence); -static void _send_presence_stanza(xmpp_stanza_t *const stanza); +void _send_caps_request(char* node, char* caps_key, char* id, char* from); +static void _send_room_presence(xmpp_stanza_t* presence); +static void _send_presence_stanza(xmpp_stanza_t* const stanza); void presence_sub_requests_init(void) @@ -90,46 +90,45 @@ presence_sub_requests_init(void) void presence_handlers_init(void) { - xmpp_conn_t * const conn = connection_get_conn(); - xmpp_ctx_t * const ctx = connection_get_ctx(); + xmpp_conn_t* const conn = connection_get_conn(); + xmpp_ctx_t* const ctx = connection_get_ctx(); xmpp_handler_add(conn, _presence_handler, NULL, STANZA_NAME_PRESENCE, NULL, ctx); } void -presence_subscription(const char *const jid, const jabber_subscr_t action) +presence_subscription(const char* const jid, const jabber_subscr_t action) { assert(jid != NULL); - Jid *jidp = jid_create(jid); + Jid* jidp = jid_create(jid); autocomplete_remove(sub_requests_ac, jidp->barejid); - const char *type = NULL; - switch (action) - { - case PRESENCE_SUBSCRIBE: - log_debug("Sending presence subscribe: %s", jid); - type = STANZA_TYPE_SUBSCRIBE; - break; - case PRESENCE_SUBSCRIBED: - log_debug("Sending presence subscribed: %s", jid); - type = STANZA_TYPE_SUBSCRIBED; - break; - case PRESENCE_UNSUBSCRIBED: - log_debug("Sending presence usubscribed: %s", jid); - type = STANZA_TYPE_UNSUBSCRIBED; - break; - default: - break; + const char* type = NULL; + switch (action) { + case PRESENCE_SUBSCRIBE: + log_debug("Sending presence subscribe: %s", jid); + type = STANZA_TYPE_SUBSCRIBE; + break; + case PRESENCE_SUBSCRIBED: + log_debug("Sending presence subscribed: %s", jid); + type = STANZA_TYPE_SUBSCRIBED; + break; + case PRESENCE_UNSUBSCRIBED: + log_debug("Sending presence usubscribed: %s", jid); + type = STANZA_TYPE_UNSUBSCRIBED; + break; + default: + break; } if (!type) { log_error("Attempt to send unknown subscription action: %s", jid); return; } - xmpp_ctx_t * const ctx = connection_get_ctx(); - xmpp_stanza_t *presence = xmpp_presence_new(ctx); + xmpp_ctx_t* const ctx = connection_get_ctx(); + xmpp_stanza_t* presence = xmpp_presence_new(ctx); - char *id = connection_create_stanza_id(); + char* id = connection_create_stanza_id(); xmpp_stanza_set_id(presence, id); free(id); @@ -161,18 +160,18 @@ presence_clear_sub_requests(void) } char* -presence_sub_request_find(const char *const search_str, gboolean previous, void *context) +presence_sub_request_find(const char* const search_str, gboolean previous, void* context) { return autocomplete_complete(sub_requests_ac, search_str, TRUE, previous); } gboolean -presence_sub_request_exists(const char *const bare_jid) +presence_sub_request_exists(const char* const bare_jid) { gboolean result = FALSE; - GList *requests = autocomplete_create_list(sub_requests_ac); - GList *curr = requests; + GList* requests = autocomplete_create_list(sub_requests_ac); + GList* curr = requests; while (curr) { if (strcmp(curr->data, bare_jid) == 0) { result = TRUE; @@ -192,14 +191,14 @@ presence_reset_sub_request_search(void) } void -presence_send(const resource_presence_t presence_type, const int idle, char *signed_status) +presence_send(const resource_presence_t presence_type, const int idle, char* signed_status) { if (connection_get_status() != JABBER_CONNECTED) { log_warning("Error setting presence, not connected."); return; } - char *msg = connection_get_presence_msg(); + char* msg = connection_get_presence_msg(); if (msg) { log_debug("Updating presence: %s, \"%s\"", string_from_resource_presence(presence_type), msg); } else { @@ -209,24 +208,24 @@ presence_send(const resource_presence_t presence_type, const int idle, char *sig const int pri = accounts_get_priority_for_presence_type(session_get_account_name(), presence_type); connection_set_priority(pri); - xmpp_ctx_t * const ctx = connection_get_ctx(); - xmpp_stanza_t *presence = xmpp_presence_new(ctx); + xmpp_ctx_t* const ctx = connection_get_ctx(); + xmpp_stanza_t* presence = xmpp_presence_new(ctx); - char *id = connection_create_stanza_id(); + char* id = connection_create_stanza_id(); xmpp_stanza_set_id(presence, id); free(id); - const char *show = stanza_get_presence_string_from_type(presence_type); + const char* show = stanza_get_presence_string_from_type(presence_type); stanza_attach_show(ctx, presence, show); stanza_attach_status(ctx, presence, msg); if (signed_status) { - xmpp_stanza_t *x = xmpp_stanza_new(ctx); + xmpp_stanza_t* x = xmpp_stanza_new(ctx); xmpp_stanza_set_name(x, STANZA_NAME_X); xmpp_stanza_set_ns(x, STANZA_NS_SIGNED); - xmpp_stanza_t *signed_text = xmpp_stanza_new(ctx); + xmpp_stanza_t* signed_text = xmpp_stanza_new(ctx); xmpp_stanza_set_text(signed_text, signed_status); xmpp_stanza_add_child(x, signed_text); @@ -250,27 +249,27 @@ presence_send(const resource_presence_t presence_type, const int idle, char *sig xmpp_stanza_release(presence); // set last presence for account - const char *last = show; + const char* last = show; if (last == NULL) { last = STANZA_TEXT_ONLINE; } - char *account = session_get_account_name(); + char* account = session_get_account_name(); accounts_set_last_presence(account, last); accounts_set_last_status(account, msg); } static void -_send_room_presence(xmpp_stanza_t *presence) +_send_room_presence(xmpp_stanza_t* presence) { - GList *rooms = muc_rooms(); - GList *curr = rooms; + GList* rooms = muc_rooms(); + GList* curr = rooms; while (curr) { - const char *room = curr->data; - const char *nick = muc_nick(room); + const char* room = curr->data; + const char* nick = muc_nick(room); if (nick) { - char *full_room_jid = create_fulljid(room, nick); + char* full_room_jid = create_fulljid(room, nick); xmpp_stanza_set_to(presence, full_room_jid); log_debug("Sending presence to room: %s", full_room_jid); free(full_room_jid); @@ -284,18 +283,18 @@ _send_room_presence(xmpp_stanza_t *presence) } void -presence_join_room(const char *const room, const char *const nick, const char *const passwd) +presence_join_room(const char* const room, const char* const nick, const char* const passwd) { - Jid *jid = jid_create_from_bare_and_resource(room, nick); + Jid* jid = jid_create_from_bare_and_resource(room, nick); log_debug("Sending room join presence to: %s", jid->fulljid); resource_presence_t presence_type = accounts_get_last_presence(session_get_account_name()); - const char *show = stanza_get_presence_string_from_type(presence_type); - char *status = connection_get_presence_msg(); + const char* show = stanza_get_presence_string_from_type(presence_type); + char* status = connection_get_presence_msg(); int pri = accounts_get_priority_for_presence_type(session_get_account_name(), presence_type); - xmpp_ctx_t *ctx = connection_get_ctx(); - xmpp_stanza_t *presence = stanza_create_room_join_presence(ctx, jid->fulljid, passwd); + xmpp_ctx_t* ctx = connection_get_ctx(); + xmpp_stanza_t* presence = stanza_create_room_join_presence(ctx, jid->fulljid, passwd); stanza_attach_show(ctx, presence, show); stanza_attach_status(ctx, presence, status); stanza_attach_priority(ctx, presence, pri); @@ -308,20 +307,20 @@ presence_join_room(const char *const room, const char *const nick, const char *c } void -presence_change_room_nick(const char *const room, const char *const nick) +presence_change_room_nick(const char* const room, const char* const nick) { assert(room != NULL); assert(nick != NULL); log_debug("Sending room nickname change to: %s, nick: %s", room, nick); resource_presence_t presence_type = accounts_get_last_presence(session_get_account_name()); - const char *show = stanza_get_presence_string_from_type(presence_type); - char *status = connection_get_presence_msg(); + const char* show = stanza_get_presence_string_from_type(presence_type); + char* status = connection_get_presence_msg(); int pri = accounts_get_priority_for_presence_type(session_get_account_name(), presence_type); - char *full_room_jid = create_fulljid(room, nick); + char* full_room_jid = create_fulljid(room, nick); - xmpp_ctx_t *ctx = connection_get_ctx(); - xmpp_stanza_t *presence = stanza_create_room_newnick_presence(ctx, full_room_jid); + xmpp_ctx_t* ctx = connection_get_ctx(); + xmpp_stanza_t* presence = stanza_create_room_newnick_presence(ctx, full_room_jid); stanza_attach_show(ctx, presence, show); stanza_attach_status(ctx, presence, status); stanza_attach_priority(ctx, presence, pri); @@ -334,11 +333,11 @@ presence_change_room_nick(const char *const room, const char *const nick) } void -presence_leave_chat_room(const char *const room_jid) +presence_leave_chat_room(const char* const room_jid) { assert(room_jid != NULL); - char *nick = muc_nick(room_jid); + char* nick = muc_nick(room_jid); if (!nick) { log_error("Could not get nickname for room: %s", room_jid); return; @@ -346,8 +345,8 @@ presence_leave_chat_room(const char *const room_jid) log_debug("Sending room leave presence to: %s", room_jid); - xmpp_ctx_t *ctx = connection_get_ctx(); - xmpp_stanza_t *presence = stanza_create_room_leave_presence(ctx, room_jid, nick); + xmpp_ctx_t* ctx = connection_get_ctx(); + xmpp_stanza_t* presence = stanza_create_room_leave_presence(ctx, room_jid, nick); _send_presence_stanza(presence); @@ -355,11 +354,11 @@ presence_leave_chat_room(const char *const room_jid) } static int -_presence_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata) +_presence_handler(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void* const userdata) { log_debug("Presence stanza handler fired"); - char *text = NULL; + char* text = NULL; size_t text_size; xmpp_stanza_to_text(stanza, &text, &text_size); @@ -369,7 +368,7 @@ _presence_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *co return 1; } - const char *type = xmpp_stanza_get_type(stanza); + const char* type = xmpp_stanza_get_type(stanza); if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { _presence_error_handler(stanza); @@ -391,7 +390,7 @@ _presence_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *co _unsubscribed_handler(stanza); } - xmpp_stanza_t *mucuser = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); + xmpp_stanza_t* mucuser = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); if (mucuser) { _muc_user_handler(stanza); } @@ -402,21 +401,21 @@ _presence_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *co } static void -_presence_error_handler(xmpp_stanza_t *const stanza) +_presence_error_handler(xmpp_stanza_t* const stanza) { - const char *xmlns = NULL; - xmpp_stanza_t *x = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_X); + const char* xmlns = NULL; + xmpp_stanza_t* x = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_X); if (x) { xmlns = xmpp_stanza_get_ns(x); } - const char *from = xmpp_stanza_get_from(stanza); - xmpp_stanza_t *error_stanza = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ERROR); + const char* from = xmpp_stanza_get_from(stanza); + xmpp_stanza_t* error_stanza = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ERROR); // handle MUC join errors if (g_strcmp0(xmlns, STANZA_NS_MUC) == 0) { - const char *error_cond = NULL; - xmpp_stanza_t *reason_st = xmpp_stanza_get_child_by_ns(error_stanza, STANZA_NS_STANZAS); + const char* error_cond = NULL; + xmpp_stanza_t* reason_st = xmpp_stanza_get_child_by_ns(error_stanza, STANZA_NS_STANZAS); if (reason_st) { error_cond = xmpp_stanza_get_name(reason_st); } @@ -424,7 +423,7 @@ _presence_error_handler(xmpp_stanza_t *const stanza) error_cond = "unknown"; } - Jid *fulljid = jid_create(from); + Jid* fulljid = jid_create(from); log_info("Error joining room: %s, reason: %s", fulljid->barejid, error_cond); if (muc_active(fulljid->barejid)) { muc_leave(fulljid->barejid); @@ -435,8 +434,8 @@ _presence_error_handler(xmpp_stanza_t *const stanza) return; } - GString *log_msg = g_string_new("presence stanza error received"); - const char *id = xmpp_stanza_get_id(stanza); + GString* log_msg = g_string_new("presence stanza error received"); + const char* id = xmpp_stanza_get_id(stanza); if (id) { g_string_append(log_msg, " id="); g_string_append(log_msg, id); @@ -446,7 +445,7 @@ _presence_error_handler(xmpp_stanza_t *const stanza) g_string_append(log_msg, from); } - const char *type = NULL; + const char* type = NULL; if (error_stanza) { type = xmpp_stanza_get_type(error_stanza); } @@ -456,7 +455,7 @@ _presence_error_handler(xmpp_stanza_t *const stanza) } // stanza_get_error never returns NULL - char *err_msg = stanza_get_error_message(stanza); + char* err_msg = stanza_get_error_message(stanza); g_string_append(log_msg, " error="); g_string_append(log_msg, err_msg); @@ -474,16 +473,16 @@ _presence_error_handler(xmpp_stanza_t *const stanza) } static void -_unsubscribed_handler(xmpp_stanza_t *const stanza) +_unsubscribed_handler(xmpp_stanza_t* const stanza) { - const char *from = xmpp_stanza_get_from(stanza); + const char* from = xmpp_stanza_get_from(stanza); if (!from) { log_warning("Unsubscribed presence handler received with no from attribute"); return; } log_debug("Unsubscribed presence handler fired for %s", from); - Jid *from_jid = jid_create(from); + Jid* from_jid = jid_create(from); sv_ev_subscription(from_jid->barejid, PRESENCE_UNSUBSCRIBED); autocomplete_remove(sub_requests_ac, from_jid->barejid); @@ -491,16 +490,16 @@ _unsubscribed_handler(xmpp_stanza_t *const stanza) } static void -_subscribed_handler(xmpp_stanza_t *const stanza) +_subscribed_handler(xmpp_stanza_t* const stanza) { - const char *from = xmpp_stanza_get_from(stanza); + const char* from = xmpp_stanza_get_from(stanza); if (!from) { log_warning("Subscribed presence handler received with no from attribute"); return; } log_debug("Subscribed presence handler fired for %s", from); - Jid *from_jid = jid_create(from); + Jid* from_jid = jid_create(from); sv_ev_subscription(from_jid->barejid, PRESENCE_SUBSCRIBED); autocomplete_remove(sub_requests_ac, from_jid->barejid); @@ -508,15 +507,15 @@ _subscribed_handler(xmpp_stanza_t *const stanza) } static void -_subscribe_handler(xmpp_stanza_t *const stanza) +_subscribe_handler(xmpp_stanza_t* const stanza) { - const char *from = xmpp_stanza_get_from(stanza); + const char* from = xmpp_stanza_get_from(stanza); if (!from) { log_warning("Subscribe presence handler received with no from attribute", from); } log_debug("Subscribe presence handler fired for %s", from); - Jid *from_jid = jid_create(from); + Jid* from_jid = jid_create(from); if (from_jid == NULL) { return; } @@ -528,32 +527,32 @@ _subscribe_handler(xmpp_stanza_t *const stanza) } static void -_unavailable_handler(xmpp_stanza_t *const stanza) +_unavailable_handler(xmpp_stanza_t* const stanza) { inp_nonblocking(TRUE); - xmpp_conn_t *conn = connection_get_conn(); - const char *jid = xmpp_conn_get_jid(conn); - const char *from = xmpp_stanza_get_from(stanza); + xmpp_conn_t* conn = connection_get_conn(); + const char* jid = xmpp_conn_get_jid(conn); + const char* from = xmpp_stanza_get_from(stanza); if (!from) { log_warning("Unavailable presence received with no from attribute"); } log_debug("Unavailable presence handler fired for %s", from); - Jid *my_jid = jid_create(jid); - Jid *from_jid = jid_create(from); + Jid* my_jid = jid_create(jid); + Jid* from_jid = jid_create(from); if (my_jid == NULL || from_jid == NULL) { jid_destroy(my_jid); jid_destroy(from_jid); return; } - if (strcmp(my_jid->barejid, from_jid->barejid) !=0) { - char *status_str = stanza_get_status(stanza, NULL); + if (strcmp(my_jid->barejid, from_jid->barejid) != 0) { + char* status_str = stanza_get_status(stanza, NULL); if (from_jid->resourcepart) { sv_ev_contact_offline(from_jid->barejid, from_jid->resourcepart, status_str); - // hack for servers that do not send full jid with unavailable presence + // hack for servers that do not send full jid with unavailable presence } else { sv_ev_contact_offline(from_jid->barejid, "__prof_default", status_str); } @@ -569,7 +568,7 @@ _unavailable_handler(xmpp_stanza_t *const stanza) } static void -_handle_caps(const char *const jid, XMPPCaps *caps) +_handle_caps(const char* const jid, XMPPCaps* caps) { // hash supported, xep-0115, cache against ver if (g_strcmp0(caps->hash, "sha-1") == 0) { @@ -580,23 +579,23 @@ _handle_caps(const char *const jid, XMPPCaps *caps) caps_map_jid_to_ver(jid, caps->ver); } else { log_debug("Capabilities cache miss: %s, for %s, sending service discovery request", caps->ver, jid); - char *id = connection_create_stanza_id(); + char* id = connection_create_stanza_id(); iq_send_caps_request(jid, id, caps->node, caps->ver); free(id); } } - // unsupported hash, xep-0115, associate with JID, no cache + // unsupported hash, xep-0115, associate with JID, no cache } else if (caps->hash) { log_info("Hash %s not supported: %s, sending service discovery request", caps->hash, jid); - char *id = connection_create_stanza_id(); + char* id = connection_create_stanza_id(); iq_send_caps_request_for_jid(jid, id, caps->node, caps->ver); free(id); - // no hash, legacy caps, cache against node#ver - } else if (caps->node && caps->ver) { + // no hash, legacy caps, cache against node#ver + } else if (caps->node && caps->ver) { log_info("No hash specified: %s, legacy request made for %s#%s", jid, caps->node, caps->ver); - char *id = connection_create_stanza_id(); + char* id = connection_create_stanza_id(); iq_send_caps_request_legacy(jid, id, caps->node, caps->ver); free(id); } else { @@ -605,7 +604,7 @@ _handle_caps(const char *const jid, XMPPCaps *caps) } static void -_available_handler(xmpp_stanza_t *const stanza) +_available_handler(xmpp_stanza_t* const stanza) { inp_nonblocking(TRUE); @@ -615,10 +614,7 @@ _available_handler(xmpp_stanza_t *const stanza) } // handler still fires if other types - if ((g_strcmp0(xmpp_stanza_get_type(stanza), STANZA_TYPE_UNAVAILABLE) == 0) || - (g_strcmp0(xmpp_stanza_get_type(stanza), STANZA_TYPE_SUBSCRIBE) == 0) || - (g_strcmp0(xmpp_stanza_get_type(stanza), STANZA_TYPE_SUBSCRIBED) == 0) || - (g_strcmp0(xmpp_stanza_get_type(stanza), STANZA_TYPE_UNSUBSCRIBED) == 0)) { + if ((g_strcmp0(xmpp_stanza_get_type(stanza), STANZA_TYPE_UNAVAILABLE) == 0) || (g_strcmp0(xmpp_stanza_get_type(stanza), STANZA_TYPE_SUBSCRIBE) == 0) || (g_strcmp0(xmpp_stanza_get_type(stanza), STANZA_TYPE_SUBSCRIBED) == 0) || (g_strcmp0(xmpp_stanza_get_type(stanza), STANZA_TYPE_UNSUBSCRIBED) == 0)) { return; } @@ -628,52 +624,52 @@ _available_handler(xmpp_stanza_t *const stanza) } int err = 0; - XMPPPresence *xmpp_presence = stanza_parse_presence(stanza, &err); + XMPPPresence* xmpp_presence = stanza_parse_presence(stanza, &err); if (!xmpp_presence) { - const char *from = NULL; - switch(err) { - case STANZA_PARSE_ERROR_NO_FROM: - log_warning("Available presence handler fired with no from attribute."); - break; - case STANZA_PARSE_ERROR_INVALID_FROM: - from = xmpp_stanza_get_from(stanza); - log_warning("Available presence handler fired with invalid from attribute: %s", from); - break; - default: - log_warning("Available presence handler fired, could not parse stanza."); - break; + const char* from = NULL; + switch (err) { + case STANZA_PARSE_ERROR_NO_FROM: + log_warning("Available presence handler fired with no from attribute."); + break; + case STANZA_PARSE_ERROR_INVALID_FROM: + from = xmpp_stanza_get_from(stanza); + log_warning("Available presence handler fired with invalid from attribute: %s", from); + break; + default: + log_warning("Available presence handler fired, could not parse stanza."); + break; } return; } else { - char *jid = jid_fulljid_or_barejid(xmpp_presence->jid); + char* jid = jid_fulljid_or_barejid(xmpp_presence->jid); log_debug("Presence available handler fired for: %s", jid); } - xmpp_conn_t *conn = connection_get_conn(); - const char *my_jid_str = xmpp_conn_get_jid(conn); - Jid *my_jid = jid_create(my_jid_str); + xmpp_conn_t* conn = connection_get_conn(); + const char* my_jid_str = xmpp_conn_get_jid(conn); + Jid* my_jid = jid_create(my_jid_str); - XMPPCaps *caps = stanza_parse_caps(stanza); + XMPPCaps* caps = stanza_parse_caps(stanza); if ((g_strcmp0(my_jid->fulljid, xmpp_presence->jid->fulljid) != 0) && caps) { log_debug("Presence contains capabilities."); - char *jid = jid_fulljid_or_barejid(xmpp_presence->jid); + char* jid = jid_fulljid_or_barejid(xmpp_presence->jid); _handle_caps(jid, caps); } stanza_free_caps(caps); - Resource *resource = stanza_resource_from_presence(xmpp_presence); + Resource* resource = stanza_resource_from_presence(xmpp_presence); if (g_strcmp0(xmpp_presence->jid->barejid, my_jid->barejid) == 0) { connection_add_available_resource(resource); } else { - char *pgpsig = NULL; - xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_SIGNED); + char* pgpsig = NULL; + xmpp_stanza_t* x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_SIGNED); if (x) { pgpsig = xmpp_stanza_get_text(x); } sv_ev_contact_online(xmpp_presence->jid->barejid, resource, xmpp_presence->last_activity, pgpsig); - xmpp_ctx_t *ctx = connection_get_ctx(); + xmpp_ctx_t* ctx = connection_get_ctx(); xmpp_free(ctx, pgpsig); } @@ -682,7 +678,7 @@ _available_handler(xmpp_stanza_t *const stanza) } void -_send_caps_request(char *node, char *caps_key, char *id, char *from) +_send_caps_request(char* node, char* caps_key, char* id, char* from) { if (!node) { log_debug("No node string, not sending discovery IQ."); @@ -696,8 +692,8 @@ _send_caps_request(char *node, char *caps_key, char *id, char *from) } log_debug("Capabilities not cached for '%s', sending discovery IQ.", from); - xmpp_ctx_t *ctx = connection_get_ctx(); - xmpp_stanza_t *iq = stanza_create_disco_info_iq(ctx, id, from, node); + xmpp_ctx_t* ctx = connection_get_ctx(); + xmpp_stanza_t* iq = stanza_create_disco_info_iq(ctx, id, from, node); iq_send_stanza(iq); @@ -705,51 +701,51 @@ _send_caps_request(char *node, char *caps_key, char *id, char *from) } static void -_muc_user_self_handler(xmpp_stanza_t *stanza) +_muc_user_self_handler(xmpp_stanza_t* stanza) { - const char *from = xmpp_stanza_get_from(stanza); - Jid *from_jid = jid_create(from); + const char* from = xmpp_stanza_get_from(stanza); + Jid* from_jid = jid_create(from); log_debug("Room self presence received from %s", from_jid->fulljid); - char *room = from_jid->barejid; + char* room = from_jid->barejid; - const char *type = xmpp_stanza_get_type(stanza); + const char* type = xmpp_stanza_get_type(stanza); if (g_strcmp0(type, STANZA_TYPE_UNAVAILABLE) == 0) { // handle nickname change - const char *new_nick = stanza_get_new_nick(stanza); + const char* new_nick = stanza_get_new_nick(stanza); if (new_nick) { muc_nick_change_start(room, new_nick); - // handle left room + // handle left room } else { - GSList *status_codes = stanza_get_status_codes_by_ns(stanza, STANZA_NS_MUC_USER); + GSList* status_codes = stanza_get_status_codes_by_ns(stanza, STANZA_NS_MUC_USER); // room destroyed if (stanza_room_destroyed(stanza)) { - const char *new_jid = stanza_get_muc_destroy_alternative_room(stanza); - char *password = stanza_get_muc_destroy_alternative_password(stanza); - char *reason = stanza_get_muc_destroy_reason(stanza); + const char* new_jid = stanza_get_muc_destroy_alternative_room(stanza); + char* password = stanza_get_muc_destroy_alternative_password(stanza); + char* reason = stanza_get_muc_destroy_reason(stanza); sv_ev_room_destroyed(room, new_jid, password, reason); free(password); free(reason); - // kicked from room + // kicked from room } else if (g_slist_find_custom(status_codes, "307", (GCompareFunc)g_strcmp0)) { - const char *actor = stanza_get_actor(stanza); - char *reason = stanza_get_reason(stanza); + const char* actor = stanza_get_actor(stanza); + char* reason = stanza_get_reason(stanza); sv_ev_room_kicked(room, actor, reason); free(reason); - // banned from room + // banned from room } else if (g_slist_find_custom(status_codes, "301", (GCompareFunc)g_strcmp0)) { - const char *actor = stanza_get_actor(stanza); - char *reason = stanza_get_reason(stanza); + const char* actor = stanza_get_actor(stanza); + char* reason = stanza_get_reason(stanza); sv_ev_room_banned(room, actor, reason); free(reason); - // normal exit + // normal exit } else { sv_ev_leave_room(room); } @@ -758,17 +754,17 @@ _muc_user_self_handler(xmpp_stanza_t *stanza) } } else { gboolean config_required = stanza_muc_requires_config(stanza); - const char *actor = stanza_get_actor(stanza); - char *reason = stanza_get_reason(stanza); - char *nick = from_jid->resourcepart; - char *show_str = stanza_get_show(stanza, "online"); - char *status_str = stanza_get_status(stanza, NULL); - const char *jid = NULL; - const char *role = NULL; - const char *affiliation = NULL; - xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); + const char* actor = stanza_get_actor(stanza); + char* reason = stanza_get_reason(stanza); + char* nick = from_jid->resourcepart; + char* show_str = stanza_get_show(stanza, "online"); + char* status_str = stanza_get_status(stanza, NULL); + const char* jid = NULL; + const char* role = NULL; + const char* affiliation = NULL; + xmpp_stanza_t* x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); if (x) { - xmpp_stanza_t *item = xmpp_stanza_get_child_by_name(x, STANZA_NAME_ITEM); + xmpp_stanza_t* item = xmpp_stanza_get_child_by_name(x, STANZA_NAME_ITEM); if (item) { jid = xmpp_stanza_get_attribute(item, "jid"); role = xmpp_stanza_get_attribute(item, "role"); @@ -785,44 +781,44 @@ _muc_user_self_handler(xmpp_stanza_t *stanza) } static void -_muc_user_occupant_handler(xmpp_stanza_t *stanza) +_muc_user_occupant_handler(xmpp_stanza_t* stanza) { - const char *from = xmpp_stanza_get_from(stanza); - Jid *from_jid = jid_create(from); + const char* from = xmpp_stanza_get_from(stanza); + Jid* from_jid = jid_create(from); log_debug("Room presence received from %s", from_jid->fulljid); - char *room = from_jid->barejid; - char *nick = from_jid->resourcepart; - char *status_str = stanza_get_status(stanza, NULL); + char* room = from_jid->barejid; + char* nick = from_jid->resourcepart; + char* status_str = stanza_get_status(stanza, NULL); - const char *type = xmpp_stanza_get_type(stanza); + const char* type = xmpp_stanza_get_type(stanza); if (g_strcmp0(type, STANZA_TYPE_UNAVAILABLE) == 0) { // handle nickname change - const char *new_nick = stanza_get_new_nick(stanza); + const char* new_nick = stanza_get_new_nick(stanza); if (new_nick) { muc_occupant_nick_change_start(room, new_nick, nick); - // handle left room + // handle left room } else { - GSList *status_codes = stanza_get_status_codes_by_ns(stanza, STANZA_NS_MUC_USER); + GSList* status_codes = stanza_get_status_codes_by_ns(stanza, STANZA_NS_MUC_USER); // kicked from room if (g_slist_find_custom(status_codes, "307", (GCompareFunc)g_strcmp0)) { - const char *actor = stanza_get_actor(stanza); - char *reason = stanza_get_reason(stanza); + const char* actor = stanza_get_actor(stanza); + char* reason = stanza_get_reason(stanza); sv_ev_room_occupent_kicked(room, nick, actor, reason); free(reason); - // banned from room + // banned from room } else if (g_slist_find_custom(status_codes, "301", (GCompareFunc)g_strcmp0)) { - const char *actor = stanza_get_actor(stanza); - char *reason = stanza_get_reason(stanza); + const char* actor = stanza_get_actor(stanza); + char* reason = stanza_get_reason(stanza); sv_ev_room_occupent_banned(room, nick, actor, reason); free(reason); - // normal exit + // normal exit } else { sv_ev_room_occupant_offline(room, nick, "offline", status_str); } @@ -830,24 +826,24 @@ _muc_user_occupant_handler(xmpp_stanza_t *stanza) g_slist_free_full(status_codes, free); } - // room occupant online + // room occupant online } else { // send disco info for capabilities, if not cached - XMPPCaps *caps = stanza_parse_caps(stanza); + XMPPCaps* caps = stanza_parse_caps(stanza); if (caps) { _handle_caps(from, caps); } stanza_free_caps(caps); - const char *actor = stanza_get_actor(stanza); - char *show_str = stanza_get_show(stanza, "online"); - char *reason = stanza_get_reason(stanza); - const char *jid = NULL; - const char *role = NULL; - const char *affiliation = NULL; - xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); + const char* actor = stanza_get_actor(stanza); + char* show_str = stanza_get_show(stanza, "online"); + char* reason = stanza_get_reason(stanza); + const char* jid = NULL; + const char* role = NULL; + const char* affiliation = NULL; + xmpp_stanza_t* x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); if (x) { - xmpp_stanza_t *item = xmpp_stanza_get_child_by_name(x, STANZA_NAME_ITEM); + xmpp_stanza_t* item = xmpp_stanza_get_child_by_name(x, STANZA_NAME_ITEM); if (item) { jid = xmpp_stanza_get_attribute(item, "jid"); role = xmpp_stanza_get_attribute(item, "role"); @@ -864,23 +860,23 @@ _muc_user_occupant_handler(xmpp_stanza_t *stanza) } static void -_muc_user_handler(xmpp_stanza_t *const stanza) +_muc_user_handler(xmpp_stanza_t* const stanza) { inp_nonblocking(TRUE); - const char *type = xmpp_stanza_get_type(stanza); + const char* type = xmpp_stanza_get_type(stanza); // handler still fires if error if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { return; } - const char *from = xmpp_stanza_get_from(stanza); + const char* from = xmpp_stanza_get_from(stanza); if (!from) { log_warning("MUC User stanza received with no from attribute"); return; } - Jid *from_jid = jid_create(from); + Jid* from_jid = jid_create(from); if (from_jid == NULL || from_jid->resourcepart == NULL) { log_warning("MUC User stanza received with invalid from attribute: %s", from); jid_destroy(from_jid); @@ -896,14 +892,14 @@ _muc_user_handler(xmpp_stanza_t *const stanza) } static void -_send_presence_stanza(xmpp_stanza_t *const stanza) +_send_presence_stanza(xmpp_stanza_t* const stanza) { - char *text; + char* text; size_t text_size; xmpp_stanza_to_text(stanza, &text, &text_size); - xmpp_conn_t *conn = connection_get_conn(); - char *plugin_text = plugins_on_presence_stanza_send(text); + xmpp_conn_t* conn = connection_get_conn(); + char* plugin_text = plugins_on_presence_stanza_send(text); if (plugin_text) { xmpp_send_raw_string(conn, "%s", plugin_text); free(plugin_text); diff --git a/src/xmpp/resource.c b/src/xmpp/resource.c index 774c8e23..9e8e1a8b 100644 --- a/src/xmpp/resource.c +++ b/src/xmpp/resource.c @@ -41,10 +41,10 @@ #include "xmpp/resource.h" Resource* -resource_new(const char *const name, resource_presence_t presence, const char *const status, const int priority) +resource_new(const char* const name, resource_presence_t presence, const char* const status, const int priority) { assert(name != NULL); - Resource *new_resource = malloc(sizeof(struct resource_t)); + Resource* new_resource = malloc(sizeof(struct resource_t)); new_resource->name = strdup(name); new_resource->presence = presence; if (status) { @@ -58,7 +58,7 @@ resource_new(const char *const name, resource_presence_t presence, const char *c } int -resource_compare_availability(Resource *first, Resource *second) +resource_compare_availability(Resource* first, Resource* second) { if (first->priority > second->priority) { return -1; @@ -88,7 +88,7 @@ resource_compare_availability(Resource *first, Resource *second) } void -resource_destroy(Resource *resource) +resource_destroy(Resource* resource) { if (resource) { free(resource->name); @@ -98,12 +98,10 @@ resource_destroy(Resource *resource) } gboolean -valid_resource_presence_string(const char *const str) +valid_resource_presence_string(const char* const str) { assert(str != NULL); - if ((strcmp(str, "online") == 0) || (strcmp(str, "chat") == 0) || - (strcmp(str, "away") == 0) || (strcmp(str, "xa") == 0) || - (strcmp(str, "dnd") == 0)) { + if ((strcmp(str, "online") == 0) || (strcmp(str, "chat") == 0) || (strcmp(str, "away") == 0) || (strcmp(str, "xa") == 0) || (strcmp(str, "dnd") == 0)) { return TRUE; } else { return FALSE; @@ -113,23 +111,22 @@ valid_resource_presence_string(const char *const str) const char* string_from_resource_presence(resource_presence_t presence) { - switch(presence) - { - case RESOURCE_CHAT: - return "chat"; - case RESOURCE_AWAY: - return "away"; - case RESOURCE_XA: - return "xa"; - case RESOURCE_DND: - return "dnd"; - default: - return "online"; + switch (presence) { + case RESOURCE_CHAT: + return "chat"; + case RESOURCE_AWAY: + return "away"; + case RESOURCE_XA: + return "xa"; + case RESOURCE_DND: + return "dnd"; + default: + return "online"; } } resource_presence_t -resource_presence_from_string(const char *const str) +resource_presence_from_string(const char* const str) { if (str == NULL) { return RESOURCE_ONLINE; @@ -151,17 +148,16 @@ resource_presence_from_string(const char *const str) contact_presence_t contact_presence_from_resource_presence(resource_presence_t resource_presence) { - switch(resource_presence) - { - case RESOURCE_CHAT: - return CONTACT_CHAT; - case RESOURCE_AWAY: - return CONTACT_AWAY; - case RESOURCE_XA: - return CONTACT_XA; - case RESOURCE_DND: - return CONTACT_DND; - default: - return CONTACT_ONLINE; + switch (resource_presence) { + case RESOURCE_CHAT: + return CONTACT_CHAT; + case RESOURCE_AWAY: + return CONTACT_AWAY; + case RESOURCE_XA: + return CONTACT_XA; + case RESOURCE_DND: + return CONTACT_DND; + default: + return CONTACT_ONLINE; } } diff --git a/src/xmpp/resource.h b/src/xmpp/resource.h index ce01203f..41d20511 100644 --- a/src/xmpp/resource.h +++ b/src/xmpp/resource.h @@ -38,21 +38,22 @@ #include "common.h" -typedef struct resource_t { - char *name; +typedef struct resource_t +{ + char* name; resource_presence_t presence; - char *status; + char* status; int priority; } Resource; -Resource* resource_new(const char *const name, resource_presence_t presence, const char *const status, - const int priority); -void resource_destroy(Resource *resource); -int resource_compare_availability(Resource *first, Resource *second); +Resource* resource_new(const char* const name, resource_presence_t presence, const char* const status, + const int priority); +void resource_destroy(Resource* resource); +int resource_compare_availability(Resource* first, Resource* second); -gboolean valid_resource_presence_string(const char *const str); +gboolean valid_resource_presence_string(const char* const str); const char* string_from_resource_presence(resource_presence_t presence); -resource_presence_t resource_presence_from_string(const char *const str); +resource_presence_t resource_presence_from_string(const char* const str); contact_presence_t contact_presence_from_resource_presence(resource_presence_t resource_presence); #endif diff --git a/src/xmpp/roster.c b/src/xmpp/roster.c index 64099335..2b5a1696 100644 --- a/src/xmpp/roster.c +++ b/src/xmpp/roster.c @@ -66,61 +66,62 @@ #include "xmpp/xmpp.h" // callback data for group commands -typedef struct _group_data { - char *name; - char *group; +typedef struct _group_data +{ + char* name; + char* group; } GroupData; // id handlers -static int _group_add_id_handler(xmpp_stanza_t *const stanza, void *const userdata); -static int _group_remove_id_handler(xmpp_stanza_t *const stanza, void *const userdata); -static void _free_group_data(GroupData *data); +static int _group_add_id_handler(xmpp_stanza_t* const stanza, void* const userdata); +static int _group_remove_id_handler(xmpp_stanza_t* const stanza, void* const userdata); +static void _free_group_data(GroupData* data); void roster_request(void) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - xmpp_stanza_t *iq = stanza_create_roster_iq(ctx); + xmpp_ctx_t* const ctx = connection_get_ctx(); + xmpp_stanza_t* iq = stanza_create_roster_iq(ctx); iq_send_stanza(iq); xmpp_stanza_release(iq); } void -roster_send_add_new(const char *const barejid, const char *const name) +roster_send_add_new(const char* const barejid, const char* const name) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - char *id = connection_create_stanza_id(); - xmpp_stanza_t *iq = stanza_create_roster_set(ctx, id, barejid, name, NULL); + xmpp_ctx_t* const ctx = connection_get_ctx(); + char* id = connection_create_stanza_id(); + xmpp_stanza_t* iq = stanza_create_roster_set(ctx, id, barejid, name, NULL); free(id); iq_send_stanza(iq); xmpp_stanza_release(iq); } void -roster_send_remove(const char *const barejid) +roster_send_remove(const char* const barejid) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - xmpp_stanza_t *iq = stanza_create_roster_remove_set(ctx, barejid); + xmpp_ctx_t* const ctx = connection_get_ctx(); + xmpp_stanza_t* iq = stanza_create_roster_remove_set(ctx, barejid); iq_send_stanza(iq); xmpp_stanza_release(iq); } void -roster_send_name_change(const char *const barejid, const char *const new_name, GSList *groups) +roster_send_name_change(const char* const barejid, const char* const new_name, GSList* groups) { - xmpp_ctx_t * const ctx = connection_get_ctx(); - char *id = connection_create_stanza_id(); - xmpp_stanza_t *iq = stanza_create_roster_set(ctx, id, barejid, new_name, groups); + xmpp_ctx_t* const ctx = connection_get_ctx(); + char* id = connection_create_stanza_id(); + xmpp_stanza_t* iq = stanza_create_roster_set(ctx, id, barejid, new_name, groups); free(id); iq_send_stanza(iq); xmpp_stanza_release(iq); } void -roster_send_add_to_group(const char *const group, PContact contact) +roster_send_add_to_group(const char* const group, PContact contact) { - GSList *groups = p_contact_groups(contact); - GSList *new_groups = NULL; + GSList* groups = p_contact_groups(contact); + GSList* new_groups = NULL; while (groups) { new_groups = g_slist_append(new_groups, strdup(groups->data)); groups = g_slist_next(groups); @@ -128,8 +129,8 @@ roster_send_add_to_group(const char *const group, PContact contact) new_groups = g_slist_append(new_groups, strdup(group)); // add an id handler to handle the response - char *unique_id = connection_create_stanza_id(); - GroupData *data = malloc(sizeof(GroupData)); + char* unique_id = connection_create_stanza_id(); + GroupData* data = malloc(sizeof(GroupData)); data->group = strdup(group); if (p_contact_name(contact)) { data->name = strdup(p_contact_name(contact)); @@ -137,30 +138,30 @@ roster_send_add_to_group(const char *const group, PContact contact) data->name = strdup(p_contact_barejid(contact)); } - xmpp_ctx_t * const ctx = connection_get_ctx(); + xmpp_ctx_t* const ctx = connection_get_ctx(); iq_id_handler_add(unique_id, _group_add_id_handler, (ProfIqFreeCallback)_free_group_data, data); - xmpp_stanza_t *iq = stanza_create_roster_set(ctx, unique_id, p_contact_barejid(contact), - p_contact_name(contact), new_groups); + xmpp_stanza_t* iq = stanza_create_roster_set(ctx, unique_id, p_contact_barejid(contact), + p_contact_name(contact), new_groups); iq_send_stanza(iq); xmpp_stanza_release(iq); free(unique_id); } static int -_group_add_id_handler(xmpp_stanza_t *const stanza, void *const userdata) +_group_add_id_handler(xmpp_stanza_t* const stanza, void* const userdata) { if (userdata) { - GroupData *data = userdata; + GroupData* data = userdata; ui_group_added(data->name, data->group); } return 0; } void -roster_send_remove_from_group(const char *const group, PContact contact) +roster_send_remove_from_group(const char* const group, PContact contact) { - GSList *groups = p_contact_groups(contact); - GSList *new_groups = NULL; + GSList* groups = p_contact_groups(contact); + GSList* new_groups = NULL; while (groups) { if (strcmp(groups->data, group) != 0) { new_groups = g_slist_append(new_groups, strdup(groups->data)); @@ -168,11 +169,11 @@ roster_send_remove_from_group(const char *const group, PContact contact) groups = g_slist_next(groups); } - xmpp_ctx_t * const ctx = connection_get_ctx(); + xmpp_ctx_t* const ctx = connection_get_ctx(); // add an id handler to handle the response - char *unique_id = connection_create_stanza_id(); - GroupData *data = malloc(sizeof(GroupData)); + char* unique_id = connection_create_stanza_id(); + GroupData* data = malloc(sizeof(GroupData)); data->group = strdup(group); if (p_contact_name(contact)) { data->name = strdup(p_contact_name(contact)); @@ -181,38 +182,36 @@ roster_send_remove_from_group(const char *const group, PContact contact) } iq_id_handler_add(unique_id, _group_remove_id_handler, (ProfIqFreeCallback)_free_group_data, data); - xmpp_stanza_t *iq = stanza_create_roster_set(ctx, unique_id, p_contact_barejid(contact), - p_contact_name(contact), new_groups); + xmpp_stanza_t* iq = stanza_create_roster_set(ctx, unique_id, p_contact_barejid(contact), + p_contact_name(contact), new_groups); iq_send_stanza(iq); xmpp_stanza_release(iq); free(unique_id); } static int -_group_remove_id_handler(xmpp_stanza_t *const stanza, void *const userdata) +_group_remove_id_handler(xmpp_stanza_t* const stanza, void* const userdata) { if (userdata) { - GroupData *data = userdata; + GroupData* data = userdata; ui_group_removed(data->name, data->group); } return 0; } void -roster_set_handler(xmpp_stanza_t *const stanza) +roster_set_handler(xmpp_stanza_t* const stanza) { - xmpp_stanza_t *query = - xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); - xmpp_stanza_t *item = - xmpp_stanza_get_child_by_name(query, STANZA_NAME_ITEM); + xmpp_stanza_t* query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); + xmpp_stanza_t* item = xmpp_stanza_get_child_by_name(query, STANZA_NAME_ITEM); if (item == NULL) { return; } // if from attribute exists and it is not current users barejid, ignore push - char *mybarejid = connection_get_barejid(); - const char *from = xmpp_stanza_get_from(stanza); + char* mybarejid = connection_get_barejid(); + const char* from = xmpp_stanza_get_from(stanza); if (from && (strcmp(from, mybarejid) != 0)) { log_warning("Received alleged roster push from: %s", from); free(mybarejid); @@ -220,11 +219,11 @@ roster_set_handler(xmpp_stanza_t *const stanza) } free(mybarejid); - const char *barejid = xmpp_stanza_get_attribute(item, STANZA_ATTR_JID); - gchar *barejid_lower = g_utf8_strdown(barejid, -1); - const char *name = xmpp_stanza_get_attribute(item, STANZA_ATTR_NAME); - const char *sub = xmpp_stanza_get_attribute(item, STANZA_ATTR_SUBSCRIPTION); - const char *ask = xmpp_stanza_get_attribute(item, STANZA_ATTR_ASK); + const char* barejid = xmpp_stanza_get_attribute(item, STANZA_ATTR_JID); + gchar* barejid_lower = g_utf8_strdown(barejid, -1); + const char* name = xmpp_stanza_get_attribute(item, STANZA_ATTR_NAME); + const char* sub = xmpp_stanza_get_attribute(item, STANZA_ATTR_SUBSCRIPTION); + const char* ask = xmpp_stanza_get_attribute(item, STANZA_ATTR_ASK); // do not set nickname to empty string, set to NULL instead if (name && (strlen(name) == 0)) { @@ -240,7 +239,7 @@ roster_set_handler(xmpp_stanza_t *const stanza) roster_remove(name, barejid_lower); ui_roster_remove(barejid_lower); - // otherwise update local roster + // otherwise update local roster } else { // check for pending out subscriptions @@ -249,7 +248,7 @@ roster_set_handler(xmpp_stanza_t *const stanza) pending_out = TRUE; } - GSList *groups = roster_get_groups_from_item(item); + GSList* groups = roster_get_groups_from_item(item); // update the local roster PContact contact = roster_get_contact(barejid_lower); @@ -269,34 +268,35 @@ roster_set_handler(xmpp_stanza_t *const stanza) } void -roster_result_handler(xmpp_stanza_t *const stanza) +roster_result_handler(xmpp_stanza_t* const stanza) { - const char *id = xmpp_stanza_get_id(stanza); + const char* id = xmpp_stanza_get_id(stanza); if (g_strcmp0(id, "roster") != 0) { return; } // handle initial roster response - xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); - xmpp_stanza_t *item = xmpp_stanza_get_children(query); + xmpp_stanza_t* query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); + xmpp_stanza_t* item = xmpp_stanza_get_children(query); while (item) { - const char *barejid = xmpp_stanza_get_attribute(item, STANZA_ATTR_JID); - gchar *barejid_lower = g_utf8_strdown(barejid, -1); - const char *name = xmpp_stanza_get_attribute(item, STANZA_ATTR_NAME); - const char *sub = xmpp_stanza_get_attribute(item, STANZA_ATTR_SUBSCRIPTION); + const char* barejid = xmpp_stanza_get_attribute(item, STANZA_ATTR_JID); + gchar* barejid_lower = g_utf8_strdown(barejid, -1); + const char* name = xmpp_stanza_get_attribute(item, STANZA_ATTR_NAME); + const char* sub = xmpp_stanza_get_attribute(item, STANZA_ATTR_SUBSCRIPTION); // do not set nickname to empty string, set to NULL instead - if (name && (strlen(name) == 0)) name = NULL; + if (name && (strlen(name) == 0)) + name = NULL; gboolean pending_out = FALSE; - const char *ask = xmpp_stanza_get_attribute(item, STANZA_ATTR_ASK); + const char* ask = xmpp_stanza_get_attribute(item, STANZA_ATTR_ASK); if (g_strcmp0(ask, "subscribe") == 0) { pending_out = TRUE; } - GSList *groups = roster_get_groups_from_item(item); + GSList* groups = roster_get_groups_from_item(item); gboolean added = roster_add(barejid_lower, name, groups, sub, pending_out); if (!added) { @@ -313,14 +313,14 @@ roster_result_handler(xmpp_stanza_t *const stanza) } GSList* -roster_get_groups_from_item(xmpp_stanza_t *item) +roster_get_groups_from_item(xmpp_stanza_t* item) { - GSList *groups = NULL; - xmpp_stanza_t *group_element = xmpp_stanza_get_children(item); + GSList* groups = NULL; + xmpp_stanza_t* group_element = xmpp_stanza_get_children(item); while (group_element) { if (strcmp(xmpp_stanza_get_name(group_element), STANZA_NAME_GROUP) == 0) { - char *groupname = xmpp_stanza_get_text(group_element); + char* groupname = xmpp_stanza_get_text(group_element); if (groupname) { groups = g_slist_append(groups, groupname); } @@ -332,7 +332,7 @@ roster_get_groups_from_item(xmpp_stanza_t *item) } static void -_free_group_data(GroupData *data) +_free_group_data(GroupData* data) { if (data) { free(data->group); diff --git a/src/xmpp/roster.h b/src/xmpp/roster.h index d516fa97..253e088d 100644 --- a/src/xmpp/roster.h +++ b/src/xmpp/roster.h @@ -37,8 +37,8 @@ #define XMPP_ROSTER_H void roster_request(void); -void roster_set_handler(xmpp_stanza_t *const stanza); -void roster_result_handler(xmpp_stanza_t *const stanza); -GSList* roster_get_groups_from_item(xmpp_stanza_t *const item); +void roster_set_handler(xmpp_stanza_t* const stanza); +void roster_result_handler(xmpp_stanza_t* const stanza); +GSList* roster_get_groups_from_item(xmpp_stanza_t* const item); #endif diff --git a/src/xmpp/roster_list.c b/src/xmpp/roster_list.c index 49f067d6..f0d4ba86 100644 --- a/src/xmpp/roster_list.c +++ b/src/xmpp/roster_list.c @@ -33,7 +33,6 @@ * */ - #include <string.h> #include <stdlib.h> #include <assert.h> @@ -47,9 +46,10 @@ #include "xmpp/contact.h" #include "xmpp/jid.h" -typedef struct prof_roster_t { +typedef struct prof_roster_t +{ // contacts, indexed on barejid - GHashTable *contacts; + GHashTable* contacts; // nicknames Autocomplete name_ac; @@ -61,27 +61,28 @@ typedef struct prof_roster_t { Autocomplete fulljid_ac; // nickname to barejid map - GHashTable *name_to_barejid; + GHashTable* name_to_barejid; // groups Autocomplete groups_ac; - GHashTable *group_count; + GHashTable* group_count; } ProfRoster; -typedef struct pending_presence { - char *barejid; - Resource *resource; - GDateTime *last_activity; +typedef struct pending_presence +{ + char* barejid; + Resource* resource; + GDateTime* last_activity; } ProfPendingPresence; -static ProfRoster *roster = NULL; +static ProfRoster* roster = NULL; static gboolean roster_received = FALSE; -static GSList *roster_pending_presence = NULL; +static GSList* roster_pending_presence = NULL; -static gboolean _key_equals(void *key1, void *key2); -static gboolean _datetimes_equal(GDateTime *dt1, GDateTime *dt2); -static void _replace_name(const char *const current_name, const char *const new_name, const char *const barejid); -static void _add_name_and_barejid(const char *const name, const char *const barejid); +static gboolean _key_equals(void* key1, void* key2); +static gboolean _datetimes_equal(GDateTime* dt1, GDateTime* dt2); +static void _replace_name(const char* const current_name, const char* const new_name, const char* const barejid); +static void _add_name_and_barejid(const char* const name, const char* const barejid); void roster_create(void) @@ -119,7 +120,7 @@ roster_destroy(void) } gboolean -roster_update_presence(const char *const barejid, Resource *resource, GDateTime *last_activity) +roster_update_presence(const char* const barejid, Resource* resource, GDateTime* last_activity) { assert(roster != NULL); @@ -127,7 +128,7 @@ roster_update_presence(const char *const barejid, Resource *resource, GDateTime assert(resource != NULL); if (!roster_received) { - ProfPendingPresence *presence = malloc(sizeof(ProfPendingPresence)); + ProfPendingPresence* presence = malloc(sizeof(ProfPendingPresence)); presence->barejid = strdup(barejid); presence->resource = resource; presence->last_activity = last_activity; @@ -148,7 +149,7 @@ roster_update_presence(const char *const barejid, Resource *resource, GDateTime p_contact_set_last_activity(contact, last_activity); } p_contact_set_presence(contact, resource); - Jid *jid = jid_create_from_bare_and_resource(barejid, resource->name); + Jid* jid = jid_create_from_bare_and_resource(barejid, resource->name); autocomplete_add(roster->fulljid_ac, jid->fulljid); jid_destroy(jid); @@ -156,11 +157,11 @@ roster_update_presence(const char *const barejid, Resource *resource, GDateTime } PContact -roster_get_contact(const char *const barejid) +roster_get_contact(const char* const barejid) { assert(roster != NULL); - gchar *barejidlower = g_utf8_strdown(barejid, -1); + gchar* barejidlower = g_utf8_strdown(barejid, -1); PContact contact = g_hash_table_lookup(roster->contacts, barejidlower); g_free(barejidlower); @@ -168,11 +169,11 @@ roster_get_contact(const char *const barejid) } char* -roster_get_msg_display_name(const char *const barejid, const char *const resource) +roster_get_msg_display_name(const char* const barejid, const char* const resource) { assert(roster != NULL); - GString *result = g_string_new(""); + GString* result = g_string_new(""); PContact contact = roster_get_contact(barejid); if (contact) { @@ -190,14 +191,14 @@ roster_get_msg_display_name(const char *const barejid, const char *const resourc g_string_append(result, resource); } - char *result_str = result->str; + char* result_str = result->str; g_string_free(result, FALSE); return result_str; } gboolean -roster_contact_offline(const char *const barejid, const char *const resource, const char *const status) +roster_contact_offline(const char* const barejid, const char* const resource, const char* const status) { assert(roster != NULL); @@ -211,7 +212,7 @@ roster_contact_offline(const char *const barejid, const char *const resource, co } else { gboolean result = p_contact_remove_resource(contact, resource); if (result == TRUE) { - Jid *jid = jid_create_from_bare_and_resource(barejid, resource); + Jid* jid = jid_create_from_bare_and_resource(barejid, resource); autocomplete_remove(roster->fulljid_ac, jid->fulljid); jid_destroy(jid); } @@ -232,13 +233,13 @@ roster_reset_search_attempts(void) } void -roster_change_name(PContact contact, const char *const new_name) +roster_change_name(PContact contact, const char* const new_name) { assert(roster != NULL); assert(contact != NULL); - char *current_name = NULL; - const char *barejid = p_contact_barejid(contact); + char* current_name = NULL; + const char* barejid = p_contact_barejid(contact); if (p_contact_name(contact)) { current_name = strdup(p_contact_name(contact)); @@ -250,7 +251,7 @@ roster_change_name(PContact contact, const char *const new_name) } void -roster_remove(const char *const name, const char *const barejid) +roster_remove(const char* const name, const char* const barejid) { assert(roster != NULL); @@ -261,9 +262,9 @@ roster_remove(const char *const name, const char *const barejid) // remove each fulljid PContact contact = roster_get_contact(barejid); if (contact) { - GList *resources = p_contact_get_available_resources(contact); + GList* resources = p_contact_get_available_resources(contact); while (resources) { - GString *fulljid = g_string_new(barejid); + GString* fulljid = g_string_new(barejid); g_string_append(fulljid, "/"); g_string_append(fulljid, resources->data); autocomplete_remove(roster->fulljid_ac, fulljid->str); @@ -272,10 +273,10 @@ roster_remove(const char *const name, const char *const barejid) } g_list_free(resources); - GSList *groups = p_contact_groups(contact); - GSList *curr = groups; + GSList* groups = p_contact_groups(contact); + GSList* curr = groups; while (curr) { - gchar *group = curr->data; + gchar* group = curr->data; if (g_hash_table_contains(roster->group_count, group)) { int count = GPOINTER_TO_INT(g_hash_table_lookup(roster->group_count, group)); count--; @@ -295,8 +296,8 @@ roster_remove(const char *const name, const char *const barejid) } void -roster_update(const char *const barejid, const char *const name, GSList *groups, const char *const subscription, - gboolean pending_out) +roster_update(const char* const barejid, const char* const name, GSList* groups, const char* const subscription, + gboolean pending_out) { assert(roster != NULL); @@ -308,9 +309,9 @@ roster_update(const char *const barejid, const char *const name, GSList *groups, roster_change_name(contact, name); - GSList *curr_new_group = groups; + GSList* curr_new_group = groups; while (curr_new_group) { - char *new_group = curr_new_group->data; + char* new_group = curr_new_group->data; // contact added to group if (!p_contact_in_group(contact, new_group)) { @@ -320,7 +321,7 @@ roster_update(const char *const barejid, const char *const name, GSList *groups, g_hash_table_insert(roster->group_count, strdup(new_group), GINT_TO_POINTER(1)); autocomplete_add(roster->groups_ac, curr_new_group->data); - // increment count + // increment count } else { int count = GPOINTER_TO_INT(g_hash_table_lookup(roster->group_count, new_group)); g_hash_table_insert(roster->group_count, strdup(new_group), GINT_TO_POINTER(count + 1)); @@ -329,10 +330,10 @@ roster_update(const char *const barejid, const char *const name, GSList *groups, curr_new_group = g_slist_next(curr_new_group); } - GSList *old_groups = p_contact_groups(contact); - GSList *curr_old_group = old_groups; + GSList* old_groups = p_contact_groups(contact); + GSList* curr_old_group = old_groups; while (curr_old_group) { - char *old_group = curr_old_group->data; + char* old_group = curr_old_group->data; // removed from group if (!g_slist_find_custom(groups, old_group, (GCompareFunc)g_strcmp0)) { if (g_hash_table_contains(roster->group_count, old_group)) { @@ -354,8 +355,8 @@ roster_update(const char *const barejid, const char *const name, GSList *groups, } gboolean -roster_add(const char *const barejid, const char *const name, GSList *groups, const char *const subscription, - gboolean pending_out) +roster_add(const char* const barejid, const char* const name, GSList* groups, const char* const subscription, + gboolean pending_out) { assert(roster != NULL); @@ -367,9 +368,9 @@ roster_add(const char *const barejid, const char *const name, GSList *groups, co contact = p_contact_new(barejid, name, groups, subscription, NULL, pending_out); // add groups - GSList *curr_new_group = groups; + GSList* curr_new_group = groups; while (curr_new_group) { - char *new_group = curr_new_group->data; + char* new_group = curr_new_group->data; if (g_hash_table_contains(roster->group_count, new_group)) { int count = GPOINTER_TO_INT(g_hash_table_lookup(roster->group_count, new_group)); g_hash_table_insert(roster->group_count, strdup(new_group), GINT_TO_POINTER(count + 1)); @@ -389,7 +390,7 @@ roster_add(const char *const barejid, const char *const name, GSList *groups, co } char* -roster_barejid_from_name(const char *const name) +roster_barejid_from_name(const char* const name) { assert(roster != NULL); @@ -401,11 +402,11 @@ roster_barejid_from_name(const char *const name) } GSList* -roster_get_contacts_by_presence(const char *const presence) +roster_get_contacts_by_presence(const char* const presence) { assert(roster != NULL); - GSList *result = NULL; + GSList* result = NULL; GHashTableIter iter; gpointer key; gpointer value; @@ -427,16 +428,16 @@ roster_get_contacts(roster_ord_t order) { assert(roster != NULL); - GSList *result = NULL; + GSList* result = NULL; GHashTableIter iter; gpointer key; gpointer value; GCompareFunc cmp_func; if (order == ROSTER_ORD_PRESENCE) { - cmp_func = (GCompareFunc) roster_compare_presence; + cmp_func = (GCompareFunc)roster_compare_presence; } else { - cmp_func = (GCompareFunc) roster_compare_name; + cmp_func = (GCompareFunc)roster_compare_name; } g_hash_table_iter_init(&iter, roster->contacts); @@ -453,14 +454,14 @@ roster_get_contacts_online(void) { assert(roster != NULL); - GSList *result = NULL; + GSList* result = NULL; GHashTableIter iter; gpointer key; gpointer value; g_hash_table_iter_init(&iter, roster->contacts); while (g_hash_table_iter_next(&iter, &key, &value)) { - if(strcmp(p_contact_presence(value), "offline")) + if (strcmp(p_contact_presence(value), "offline")) result = g_slist_insert_sorted(result, value, (GCompareFunc)roster_compare_name); } @@ -479,7 +480,7 @@ roster_has_pending_subscriptions(void) g_hash_table_iter_init(&iter, roster->contacts); while (g_hash_table_iter_next(&iter, &key, &value)) { - PContact contact = (PContact) value; + PContact contact = (PContact)value; if (p_contact_pending_out(contact)) { return TRUE; } @@ -489,7 +490,7 @@ roster_has_pending_subscriptions(void) } char* -roster_contact_autocomplete(const char *const search_str, gboolean previous, void *context) +roster_contact_autocomplete(const char* const search_str, gboolean previous, void* context) { assert(roster != NULL); @@ -497,7 +498,7 @@ roster_contact_autocomplete(const char *const search_str, gboolean previous, voi } char* -roster_fulljid_autocomplete(const char *const search_str, gboolean previous, void *context) +roster_fulljid_autocomplete(const char* const search_str, gboolean previous, void* context) { assert(roster != NULL); @@ -505,25 +506,25 @@ roster_fulljid_autocomplete(const char *const search_str, gboolean previous, voi } GSList* -roster_get_group(const char *const group, roster_ord_t order) +roster_get_group(const char* const group, roster_ord_t order) { assert(roster != NULL); - GSList *result = NULL; + GSList* result = NULL; GHashTableIter iter; gpointer key; gpointer value; GCompareFunc cmp_func; if (order == ROSTER_ORD_PRESENCE) { - cmp_func = (GCompareFunc) roster_compare_presence; + cmp_func = (GCompareFunc)roster_compare_presence; } else { - cmp_func = (GCompareFunc) roster_compare_name; + cmp_func = (GCompareFunc)roster_compare_name; } g_hash_table_iter_init(&iter, roster->contacts); while (g_hash_table_iter_next(&iter, &key, &value)) { - GSList *groups = p_contact_groups(value); + GSList* groups = p_contact_groups(value); if (group == NULL) { if (groups == NULL) { result = g_slist_insert_sorted(result, value, cmp_func); @@ -552,7 +553,7 @@ roster_get_groups(void) } char* -roster_group_autocomplete(const char *const search_str, gboolean previous, void *context) +roster_group_autocomplete(const char* const search_str, gboolean previous, void* context) { assert(roster != NULL); @@ -560,7 +561,7 @@ roster_group_autocomplete(const char *const search_str, gboolean previous, void } char* -roster_barejid_autocomplete(const char *const search_str, gboolean previous, void *context) +roster_barejid_autocomplete(const char* const search_str, gboolean previous, void* context) { assert(roster != NULL); @@ -568,16 +569,16 @@ roster_barejid_autocomplete(const char *const search_str, gboolean previous, voi } static gboolean -_key_equals(void *key1, void *key2) +_key_equals(void* key1, void* key2) { - gchar *str1 = (gchar *) key1; - gchar *str2 = (gchar *) key2; + gchar* str1 = (gchar*)key1; + gchar* str2 = (gchar*)key2; return (g_strcmp0(str1, str2) == 0); } static gboolean -_datetimes_equal(GDateTime *dt1, GDateTime *dt2) +_datetimes_equal(GDateTime* dt1, GDateTime* dt2) { if ((dt1 == NULL) && (dt2 == NULL)) { return TRUE; @@ -591,7 +592,7 @@ _datetimes_equal(GDateTime *dt1, GDateTime *dt2) } static void -_replace_name(const char *const current_name, const char *const new_name, const char *const barejid) +_replace_name(const char* const current_name, const char* const new_name, const char* const barejid) { assert(roster != NULL); @@ -600,7 +601,7 @@ _replace_name(const char *const current_name, const char *const new_name, const autocomplete_remove(roster->name_ac, current_name); g_hash_table_remove(roster->name_to_barejid, current_name); _add_name_and_barejid(new_name, barejid); - // no current handle + // no current handle } else if (new_name) { autocomplete_remove(roster->name_ac, barejid); g_hash_table_remove(roster->name_to_barejid, barejid); @@ -609,7 +610,7 @@ _replace_name(const char *const current_name, const char *const new_name, const } static void -_add_name_and_barejid(const char *const name, const char *const barejid) +_add_name_and_barejid(const char* const name, const char* const barejid) { assert(roster != NULL); @@ -625,8 +626,8 @@ _add_name_and_barejid(const char *const name, const char *const barejid) gint roster_compare_name(PContact a, PContact b) { - const char * utf8_str_a = NULL; - const char * utf8_str_b = NULL; + const char* utf8_str_a = NULL; + const char* utf8_str_b = NULL; if (p_contact_name_collate_key(a)) { utf8_str_a = p_contact_name_collate_key(a); @@ -645,7 +646,7 @@ roster_compare_name(PContact a, PContact b) } static gint -_get_presence_weight(const char *presence) +_get_presence_weight(const char* presence) { if (g_strcmp0(presence, "chat") == 0) { return 0; @@ -665,8 +666,8 @@ _get_presence_weight(const char *presence) gint roster_compare_presence(PContact a, PContact b) { - const char *presence_a = p_contact_presence(a); - const char *presence_b = p_contact_presence(b); + const char* presence_a = p_contact_presence(a); + const char* presence_b = p_contact_presence(b); // if presence different, order by presence if (g_strcmp0(presence_a, presence_b) != 0) { @@ -678,14 +679,14 @@ roster_compare_presence(PContact a, PContact b) return 1; } - // otherwise order by name + // otherwise order by name } else { return roster_compare_name(a, b); } } static void -_pendingPresence_free(ProfPendingPresence *presence) +_pendingPresence_free(ProfPendingPresence* presence) { if (!presence) return; @@ -698,9 +699,9 @@ roster_process_pending_presence(void) { roster_received = TRUE; - GSList *iter; + GSList* iter; for (iter = roster_pending_presence; iter != NULL; iter = iter->next) { - ProfPendingPresence *presence = iter->data; + ProfPendingPresence* presence = iter->data; roster_update_presence(presence->barejid, presence->resource, presence->last_activity); /* seems like resource isn't free on the calling side */ if (presence->last_activity) { @@ -713,7 +714,8 @@ roster_process_pending_presence(void) } gboolean -roster_exists(void) { +roster_exists(void) +{ if (roster != NULL) { return TRUE; } diff --git a/src/xmpp/roster_list.h b/src/xmpp/roster_list.h index d5d3c572..e47a29cb 100644 --- a/src/xmpp/roster_list.h +++ b/src/xmpp/roster_list.h @@ -47,30 +47,30 @@ typedef enum { } roster_ord_t; void roster_clear(void); -gboolean roster_update_presence(const char *const barejid, Resource *resource, GDateTime *last_activity); -PContact roster_get_contact(const char *const barejid); -gboolean roster_contact_offline(const char *const barejid, const char *const resource, const char *const status); +gboolean roster_update_presence(const char* const barejid, Resource* resource, GDateTime* last_activity); +PContact roster_get_contact(const char* const barejid); +gboolean roster_contact_offline(const char* const barejid, const char* const resource, const char* const status); void roster_reset_search_attempts(void); void roster_create(void); void roster_destroy(void); -void roster_change_name(PContact contact, const char *const new_name); -void roster_remove(const char *const name, const char *const barejid); -void roster_update(const char *const barejid, const char *const name, GSList *groups, const char *const subscription, - gboolean pending_out); -gboolean roster_add(const char *const barejid, const char *const name, GSList *groups, const char *const subscription, - gboolean pending_out); -char* roster_barejid_from_name(const char *const name); +void roster_change_name(PContact contact, const char* const new_name); +void roster_remove(const char* const name, const char* const barejid); +void roster_update(const char* const barejid, const char* const name, GSList* groups, const char* const subscription, + gboolean pending_out); +gboolean roster_add(const char* const barejid, const char* const name, GSList* groups, const char* const subscription, + gboolean pending_out); +char* roster_barejid_from_name(const char* const name); GSList* roster_get_contacts(roster_ord_t order); GSList* roster_get_contacts_online(void); gboolean roster_has_pending_subscriptions(void); -char* roster_contact_autocomplete(const char *const search_str, gboolean previous, void *context); -char* roster_fulljid_autocomplete(const char *const search_str, gboolean previous, void *context); -GSList* roster_get_group(const char *const group, roster_ord_t order); +char* roster_contact_autocomplete(const char* const search_str, gboolean previous, void* context); +char* roster_fulljid_autocomplete(const char* const search_str, gboolean previous, void* context); +GSList* roster_get_group(const char* const group, roster_ord_t order); GList* roster_get_groups(void); -char* roster_group_autocomplete(const char *const search_str, gboolean previous, void *context); -char* roster_barejid_autocomplete(const char *const search_str, gboolean previous, void *context); -GSList* roster_get_contacts_by_presence(const char *const presence); -char* roster_get_msg_display_name(const char *const barejid, const char *const resource); +char* roster_group_autocomplete(const char* const search_str, gboolean previous, void* context); +char* roster_barejid_autocomplete(const char* const search_str, gboolean previous, void* context); +GSList* roster_get_contacts_by_presence(const char* const presence); +char* roster_get_msg_display_name(const char* const barejid, const char* const resource); gint roster_compare_name(PContact a, PContact b); gint roster_compare_presence(PContact a, PContact b); void roster_process_pending_presence(void); diff --git a/src/xmpp/session.c b/src/xmpp/session.c index 21517305..e81d55ae 100644 --- a/src/xmpp/session.c +++ b/src/xmpp/session.c @@ -67,19 +67,21 @@ #endif // for auto reconnect -static struct { - char *name; - char *passwd; +static struct +{ + char* name; + char* passwd; } saved_account; -static struct { - char *name; - char *jid; - char *passwd; - char *altdomain; +static struct +{ + char* name; + char* jid; + char* passwd; + char* altdomain; int port; - char *tls_policy; - char *auth_policy; + char* tls_policy; + char* auth_policy; } saved_details; typedef enum { @@ -89,10 +91,10 @@ typedef enum { ACTIVITY_ST_XA, } activity_state_t; -static GTimer *reconnect_timer; +static GTimer* reconnect_timer; static activity_state_t activity_state; static resource_presence_t saved_presence; -static char *saved_status; +static char* saved_status; static void _session_reconnect(void); @@ -109,7 +111,7 @@ session_init(void) } jabber_conn_status_t -session_connect_with_account(const ProfAccount *const account) +session_connect_with_account(const ProfAccount* const account) { assert(account != NULL); @@ -122,9 +124,9 @@ session_connect_with_account(const ProfAccount *const account) saved_account.name = strdup(account->name); saved_account.passwd = strdup(account->password); - char *jid = NULL; + char* jid = NULL; if (account->resource) { - Jid *jidp = jid_create_from_bare_and_resource(account->jid, account->resource); + Jid* jidp = jid_create_from_bare_and_resource(account->jid, account->resource); jid = strdup(jidp->fulljid); jid_destroy(jidp); } else { @@ -144,8 +146,8 @@ session_connect_with_account(const ProfAccount *const account) } jabber_conn_status_t -session_connect_with_details(const char *const jid, const char *const passwd, const char *const altdomain, - const int port, const char *const tls_policy, const char *const auth_policy) +session_connect_with_details(const char* const jid, const char* const passwd, const char* const altdomain, + const int port, const char* const tls_policy, const char* const auth_policy) { assert(jid != NULL); assert(passwd != NULL); @@ -178,10 +180,10 @@ session_connect_with_details(const char *const jid, const char *const passwd, co } // use 'profanity' when no resourcepart in provided jid - Jid *jidp = jid_create(jid); + Jid* jidp = jid_create(jid); if (jidp->resourcepart == NULL) { jid_destroy(jidp); - char *resource = jid_random_resource(); + char* resource = jid_random_resource(); jidp = jid_create_from_bare_and_resource(jid, resource); free(resource); saved_details.jid = strdup(jidp->fulljid); @@ -215,8 +217,8 @@ session_disconnect(void) if (connection_get_status() == JABBER_CONNECTED) { log_info("Closing connection"); - char *account_name = session_get_account_name(); - const char *fulljid = connection_get_fulljid(); + char* account_name = session_get_account_name(); + const char* fulljid = connection_get_fulljid(); plugins_on_disconnect(account_name, fulljid); accounts_set_last_activity(session_get_account_name()); @@ -256,8 +258,7 @@ session_process_events(void) int reconnect_sec; jabber_conn_status_t conn_status = connection_get_status(); - switch (conn_status) - { + switch (conn_status) { case JABBER_CONNECTED: case JABBER_CONNECTING: case JABBER_DISCONNECTING: @@ -297,7 +298,7 @@ session_login_success(gboolean secured) log_debug("Connection handler: logged in with account name: %s", saved_account.name); sv_ev_login_account_success(saved_account.name, secured); - // logged in without account, use details to create new account + // logged in without account, use details to create new account } else { log_debug("Connection handler: logged in with jid: %s", saved_details.name); accounts_add(saved_details.name, saved_details.altdomain, saved_details.port, saved_details.tls_policy, saved_details.auth_policy); @@ -316,10 +317,10 @@ session_login_success(gboolean secured) // items discovery connection_request_features(); - char *domain = connection_get_domain(); + char* domain = connection_get_domain(); iq_disco_items_request_onconnect(domain); - if (prefs_get_boolean(PREF_CARBONS)){ + if (prefs_get_boolean(PREF_CARBONS)) { iq_enable_carbons(); } @@ -378,16 +379,16 @@ session_check_autoaway(void) return; } - char *mode = prefs_get_string(PREF_AUTOAWAY_MODE); + char* mode = prefs_get_string(PREF_AUTOAWAY_MODE); gboolean check = prefs_get_boolean(PREF_AUTOAWAY_CHECK); gint away_time = prefs_get_autoaway_time(); gint xa_time = prefs_get_autoxa_time(); int away_time_ms = away_time * 60000; int xa_time_ms = xa_time * 60000; - char *account = session_get_account_name(); + char* account = session_get_account_name(); resource_presence_t curr_presence = accounts_get_last_presence(account); - char *curr_status = accounts_get_last_status(account); + char* curr_status = accounts_get_last_status(account); unsigned long idle_ms = ui_get_idle_time(); @@ -410,7 +411,7 @@ session_check_autoaway(void) } // send away presence with last activity - char *message = prefs_get_string(PREF_AUTOAWAY_MESSAGE); + char* message = prefs_get_string(PREF_AUTOAWAY_MESSAGE); connection_set_presence_msg(message); if (prefs_get_boolean(PREF_LASTACTIVITY)) { cl_ev_presence_send(RESOURCE_AWAY, idle_ms / 1000); @@ -453,7 +454,7 @@ session_check_autoaway(void) activity_state = ACTIVITY_ST_XA; // send extended away presence with last activity - char *message = prefs_get_string(PREF_AUTOXA_MESSAGE); + char* message = prefs_get_string(PREF_AUTOXA_MESSAGE); connection_set_presence_msg(message); if (prefs_get_boolean(PREF_LASTACTIVITY)) { cl_ev_presence_send(RESOURCE_XA, idle_ms / 1000); @@ -505,13 +506,13 @@ static void _session_reconnect(void) { // reconnect with account. - ProfAccount *account = accounts_get_account(saved_account.name); + ProfAccount* account = accounts_get_account(saved_account.name); if (account == NULL) { log_error("Unable to reconnect, account no longer exists: %s", saved_account.name); return; } - char *jid = NULL; + char* jid = NULL; if (account->resource) { jid = create_fulljid(account->jid, account->resource); } else { @@ -542,4 +543,3 @@ _session_free_saved_details(void) FREE_SET_NULL(saved_details.tls_policy); FREE_SET_NULL(saved_details.auth_policy); } - diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c index 3a7e39c8..85fdd2c3 100644 --- a/src/xmpp/stanza.c +++ b/src/xmpp/stanza.c @@ -67,8 +67,8 @@ #include "xmpp/form.h" #include "xmpp/muc.h" -static void _stanza_add_unique_id(xmpp_stanza_t *stanza); -static char* _stanza_create_sha1_hash(char *str); +static void _stanza_add_unique_id(xmpp_stanza_t* stanza); +static char* _stanza_create_sha1_hash(char* str); #if 0 xmpp_stanza_t* @@ -94,16 +94,16 @@ stanza_create_bookmarks_pubsub_request(xmpp_ctx_t *ctx) #endif xmpp_stanza_t* -stanza_create_bookmarks_storage_request(xmpp_ctx_t *ctx) +stanza_create_bookmarks_storage_request(xmpp_ctx_t* ctx) { - xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, NULL); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, NULL); xmpp_stanza_set_ns(iq, "jabber:client"); - xmpp_stanza_t *query = xmpp_stanza_new(ctx); + xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_ns(query, "jabber:iq:private"); - xmpp_stanza_t *storage = xmpp_stanza_new(ctx); + xmpp_stanza_t* storage = xmpp_stanza_new(ctx); xmpp_stanza_set_name(storage, STANZA_NAME_STORAGE); xmpp_stanza_set_ns(storage, "storage:bookmarks"); @@ -116,11 +116,11 @@ stanza_create_bookmarks_storage_request(xmpp_ctx_t *ctx) } xmpp_stanza_t* -stanza_create_blocked_list_request(xmpp_ctx_t *ctx) +stanza_create_blocked_list_request(xmpp_ctx_t* ctx) { - xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, NULL); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, NULL); - xmpp_stanza_t *blocklist = xmpp_stanza_new(ctx); + xmpp_stanza_t* blocklist = xmpp_stanza_new(ctx); xmpp_stanza_set_name(blocklist, STANZA_NAME_BLOCKLIST); xmpp_stanza_set_ns(blocklist, STANZA_NS_BLOCKING); @@ -222,23 +222,23 @@ stanza_create_bookmarks_pubsub_add(xmpp_ctx_t *ctx, const char *const jid, #endif xmpp_stanza_t* -stanza_create_http_upload_request(xmpp_ctx_t *ctx, const char *const id, - const char *const jid, HTTPUpload *upload) +stanza_create_http_upload_request(xmpp_ctx_t* ctx, const char* const id, + const char* const jid, HTTPUpload* upload) { - xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id); xmpp_stanza_set_to(iq, jid); - xmpp_stanza_t *request = xmpp_stanza_new(ctx); + xmpp_stanza_t* request = xmpp_stanza_new(ctx); xmpp_stanza_set_name(request, STANZA_NAME_REQUEST); xmpp_stanza_set_ns(request, STANZA_NS_HTTP_UPLOAD); - xmpp_stanza_t *filename = xmpp_stanza_new(ctx); + xmpp_stanza_t* filename = xmpp_stanza_new(ctx); xmpp_stanza_set_name(filename, STANZA_NAME_FILENAME); - xmpp_stanza_t *filename_txt = xmpp_stanza_new(ctx); + xmpp_stanza_t* filename_txt = xmpp_stanza_new(ctx); char* filename_cpy = strdup(upload->filename); // strip spaces from filename (servers don't spaces) int i; - for (i=0; i<strlen(filename_cpy); i++) { + for (i = 0; i < strlen(filename_cpy); i++) { if (filename_cpy[i] == ' ') { filename_cpy[i] = '_'; } @@ -250,9 +250,9 @@ stanza_create_http_upload_request(xmpp_ctx_t *ctx, const char *const id, xmpp_stanza_release(filename_txt); xmpp_stanza_release(filename); - xmpp_stanza_t *size = xmpp_stanza_new(ctx); + xmpp_stanza_t* size = xmpp_stanza_new(ctx); xmpp_stanza_set_name(size, STANZA_NAME_SIZE); - xmpp_stanza_t *size_txt = xmpp_stanza_new(ctx); + xmpp_stanza_t* size_txt = xmpp_stanza_new(ctx); char* filesize = NULL; if (asprintf(&filesize, "%jd", (intmax_t)(upload->filesize)) != -1) { xmpp_stanza_set_text(size_txt, filesize); @@ -263,9 +263,9 @@ stanza_create_http_upload_request(xmpp_ctx_t *ctx, const char *const id, xmpp_stanza_release(size_txt); xmpp_stanza_release(size); - xmpp_stanza_t *content_type = xmpp_stanza_new(ctx); + xmpp_stanza_t* content_type = xmpp_stanza_new(ctx); xmpp_stanza_set_name(content_type, STANZA_NAME_CONTENT_TYPE); - xmpp_stanza_t *content_type_txt = xmpp_stanza_new(ctx); + xmpp_stanza_t* content_type_txt = xmpp_stanza_new(ctx); xmpp_stanza_set_text(content_type_txt, upload->mime_type); xmpp_stanza_add_child(content_type, content_type_txt); xmpp_stanza_add_child(request, content_type); @@ -279,13 +279,13 @@ stanza_create_http_upload_request(xmpp_ctx_t *ctx, const char *const id, } xmpp_stanza_t* -stanza_enable_carbons(xmpp_ctx_t *ctx) +stanza_enable_carbons(xmpp_ctx_t* ctx) { - char *id = connection_create_stanza_id(); - xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); + char* id = connection_create_stanza_id(); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); free(id); - xmpp_stanza_t *carbons_enable = xmpp_stanza_new(ctx); + xmpp_stanza_t* carbons_enable = xmpp_stanza_new(ctx); xmpp_stanza_set_name(carbons_enable, STANZA_NAME_ENABLE); xmpp_stanza_set_ns(carbons_enable, STANZA_NS_CARBONS); @@ -296,13 +296,13 @@ stanza_enable_carbons(xmpp_ctx_t *ctx) } xmpp_stanza_t* -stanza_disable_carbons(xmpp_ctx_t *ctx) +stanza_disable_carbons(xmpp_ctx_t* ctx) { - char *id = connection_create_stanza_id(); - xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); + char* id = connection_create_stanza_id(); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); free(id); - xmpp_stanza_t *carbons_disable = xmpp_stanza_new(ctx); + xmpp_stanza_t* carbons_disable = xmpp_stanza_new(ctx); xmpp_stanza_set_name(carbons_disable, STANZA_NAME_DISABLE); xmpp_stanza_set_ns(carbons_disable, STANZA_NS_CARBONS); @@ -313,13 +313,13 @@ stanza_disable_carbons(xmpp_ctx_t *ctx) } xmpp_stanza_t* -stanza_create_chat_state(xmpp_ctx_t *ctx, const char *const fulljid, const char *const state) +stanza_create_chat_state(xmpp_ctx_t* ctx, const char* const fulljid, const char* const state) { - char *id = connection_create_stanza_id(); - xmpp_stanza_t *msg = xmpp_message_new(ctx, STANZA_TYPE_CHAT, fulljid, id); + char* id = connection_create_stanza_id(); + xmpp_stanza_t* msg = xmpp_message_new(ctx, STANZA_TYPE_CHAT, fulljid, id); free(id); - xmpp_stanza_t *chat_state = xmpp_stanza_new(ctx); + xmpp_stanza_t* chat_state = xmpp_stanza_new(ctx); xmpp_stanza_set_name(chat_state, state); xmpp_stanza_set_ns(chat_state, STANZA_NS_CHATSTATES); xmpp_stanza_add_child(msg, chat_state); @@ -329,14 +329,14 @@ stanza_create_chat_state(xmpp_ctx_t *ctx, const char *const fulljid, const char } xmpp_stanza_t* -stanza_create_room_subject_message(xmpp_ctx_t *ctx, const char *const room, const char *const subject) +stanza_create_room_subject_message(xmpp_ctx_t* ctx, const char* const room, const char* const subject) { - xmpp_stanza_t *msg = xmpp_message_new(ctx, STANZA_TYPE_GROUPCHAT, room, NULL); + xmpp_stanza_t* msg = xmpp_message_new(ctx, STANZA_TYPE_GROUPCHAT, room, NULL); - xmpp_stanza_t *subject_st = xmpp_stanza_new(ctx); + xmpp_stanza_t* subject_st = xmpp_stanza_new(ctx); xmpp_stanza_set_name(subject_st, STANZA_NAME_SUBJECT); if (subject) { - xmpp_stanza_t *subject_text = xmpp_stanza_new(ctx); + xmpp_stanza_t* subject_text = xmpp_stanza_new(ctx); xmpp_stanza_set_text(subject_text, subject); xmpp_stanza_add_child(subject_st, subject_text); xmpp_stanza_release(subject_text); @@ -349,9 +349,9 @@ stanza_create_room_subject_message(xmpp_ctx_t *ctx, const char *const room, cons } xmpp_stanza_t* -stanza_attach_state(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza, const char *const state) +stanza_attach_state(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza, const char* const state) { - xmpp_stanza_t *chat_state = xmpp_stanza_new(ctx); + xmpp_stanza_t* chat_state = xmpp_stanza_new(ctx); xmpp_stanza_set_name(chat_state, state); xmpp_stanza_set_ns(chat_state, STANZA_NS_CHATSTATES); xmpp_stanza_add_child(stanza, chat_state); @@ -361,9 +361,9 @@ stanza_attach_state(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza, const char *const st } xmpp_stanza_t* -stanza_attach_carbons_private(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza) +stanza_attach_carbons_private(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza) { - xmpp_stanza_t *private_carbon = xmpp_stanza_new(ctx); + xmpp_stanza_t* private_carbon = xmpp_stanza_new(ctx); xmpp_stanza_set_name(private_carbon, "private"); xmpp_stanza_set_ns(private_carbon, STANZA_NS_CARBONS); xmpp_stanza_add_child(stanza, private_carbon); @@ -373,9 +373,9 @@ stanza_attach_carbons_private(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza) } xmpp_stanza_t* -stanza_attach_hints_no_copy(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza) +stanza_attach_hints_no_copy(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza) { - xmpp_stanza_t *no_copy = xmpp_stanza_new(ctx); + xmpp_stanza_t* no_copy = xmpp_stanza_new(ctx); xmpp_stanza_set_name(no_copy, "no-copy"); xmpp_stanza_set_ns(no_copy, STANZA_NS_HINTS); xmpp_stanza_add_child(stanza, no_copy); @@ -385,9 +385,9 @@ stanza_attach_hints_no_copy(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza) } xmpp_stanza_t* -stanza_attach_hints_no_store(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza) +stanza_attach_hints_no_store(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza) { - xmpp_stanza_t *no_store = xmpp_stanza_new(ctx); + xmpp_stanza_t* no_store = xmpp_stanza_new(ctx); xmpp_stanza_set_name(no_store, "no-store"); xmpp_stanza_set_ns(no_store, STANZA_NS_HINTS); xmpp_stanza_add_child(stanza, no_store); @@ -397,9 +397,9 @@ stanza_attach_hints_no_store(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza) } xmpp_stanza_t* -stanza_attach_hints_store(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza) +stanza_attach_hints_store(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza) { - xmpp_stanza_t *store = xmpp_stanza_new(ctx); + xmpp_stanza_t* store = xmpp_stanza_new(ctx); xmpp_stanza_set_name(store, "store"); xmpp_stanza_set_ns(store, STANZA_NS_HINTS); xmpp_stanza_add_child(stanza, store); @@ -409,9 +409,9 @@ stanza_attach_hints_store(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza) } xmpp_stanza_t* -stanza_attach_receipt_request(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza) +stanza_attach_receipt_request(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza) { - xmpp_stanza_t *receipet_request = xmpp_stanza_new(ctx); + xmpp_stanza_t* receipet_request = xmpp_stanza_new(ctx); xmpp_stanza_set_name(receipet_request, "request"); xmpp_stanza_set_ns(receipet_request, STANZA_NS_RECEIPTS); xmpp_stanza_add_child(stanza, receipet_request); @@ -421,16 +421,16 @@ stanza_attach_receipt_request(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza) } xmpp_stanza_t* -stanza_attach_x_oob_url(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza, const char *const url) +stanza_attach_x_oob_url(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza, const char* const url) { - xmpp_stanza_t *x_oob = xmpp_stanza_new(ctx); + xmpp_stanza_t* x_oob = xmpp_stanza_new(ctx); xmpp_stanza_set_name(x_oob, STANZA_NAME_X); xmpp_stanza_set_ns(x_oob, STANZA_NS_X_OOB); - xmpp_stanza_t *surl = xmpp_stanza_new(ctx); + xmpp_stanza_t* surl = xmpp_stanza_new(ctx); xmpp_stanza_set_name(surl, STANZA_NAME_URL); - xmpp_stanza_t *surl_txt = xmpp_stanza_new(ctx); + xmpp_stanza_t* surl_txt = xmpp_stanza_new(ctx); xmpp_stanza_set_text(surl_txt, url); xmpp_stanza_add_child(surl, surl_txt); xmpp_stanza_release(surl_txt); @@ -445,17 +445,17 @@ stanza_attach_x_oob_url(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza, const char *cons } xmpp_stanza_t* -stanza_create_roster_remove_set(xmpp_ctx_t *ctx, const char *const barejid) +stanza_create_roster_remove_set(xmpp_ctx_t* ctx, const char* const barejid) { - char *id = connection_create_stanza_id(); - xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); + char* id = connection_create_stanza_id(); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); free(id); - xmpp_stanza_t *query = xmpp_stanza_new(ctx); + xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_ns(query, XMPP_NS_ROSTER); - xmpp_stanza_t *item = xmpp_stanza_new(ctx); + xmpp_stanza_t* item = xmpp_stanza_new(ctx); xmpp_stanza_set_name(item, STANZA_NAME_ITEM); xmpp_stanza_set_attribute(item, STANZA_ATTR_JID, barejid); xmpp_stanza_set_attribute(item, STANZA_ATTR_SUBSCRIPTION, "remove"); @@ -466,20 +466,19 @@ stanza_create_roster_remove_set(xmpp_ctx_t *ctx, const char *const barejid) xmpp_stanza_release(query); return iq; - } xmpp_stanza_t* -stanza_create_roster_set(xmpp_ctx_t *ctx, const char *const id, - const char *const jid, const char *const handle, GSList *groups) +stanza_create_roster_set(xmpp_ctx_t* ctx, const char* const id, + const char* const jid, const char* const handle, GSList* groups) { - xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); - xmpp_stanza_t *query = xmpp_stanza_new(ctx); + xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_ns(query, XMPP_NS_ROSTER); - xmpp_stanza_t *item = xmpp_stanza_new(ctx); + xmpp_stanza_t* item = xmpp_stanza_new(ctx); xmpp_stanza_set_name(item, STANZA_NAME_ITEM); xmpp_stanza_set_attribute(item, STANZA_ATTR_JID, jid); @@ -490,8 +489,8 @@ stanza_create_roster_set(xmpp_ctx_t *ctx, const char *const id, } while (groups) { - xmpp_stanza_t *group = xmpp_stanza_new(ctx); - xmpp_stanza_t *groupname = xmpp_stanza_new(ctx); + xmpp_stanza_t* group = xmpp_stanza_new(ctx); + xmpp_stanza_t* groupname = xmpp_stanza_new(ctx); xmpp_stanza_set_name(group, STANZA_NAME_GROUP); xmpp_stanza_set_text(groupname, groups->data); xmpp_stanza_add_child(group, groupname); @@ -510,14 +509,14 @@ stanza_create_roster_set(xmpp_ctx_t *ctx, const char *const id, } xmpp_stanza_t* -stanza_create_invite(xmpp_ctx_t *ctx, const char *const room, - const char *const contact, const char *const reason, const char *const password) +stanza_create_invite(xmpp_ctx_t* ctx, const char* const room, + const char* const contact, const char* const reason, const char* const password) { - char *id = connection_create_stanza_id(); - xmpp_stanza_t *message = xmpp_message_new(ctx, NULL, contact, id); + char* id = connection_create_stanza_id(); + xmpp_stanza_t* message = xmpp_message_new(ctx, NULL, contact, id); free(id); - xmpp_stanza_t *x = xmpp_stanza_new(ctx); + xmpp_stanza_t* x = xmpp_stanza_new(ctx); xmpp_stanza_set_name(x, STANZA_NAME_X); xmpp_stanza_set_ns(x, STANZA_NS_CONFERENCE); @@ -536,25 +535,25 @@ stanza_create_invite(xmpp_ctx_t *ctx, const char *const room, } xmpp_stanza_t* -stanza_create_mediated_invite(xmpp_ctx_t *ctx, const char *const room, - const char *const contact, const char *const reason) +stanza_create_mediated_invite(xmpp_ctx_t* ctx, const char* const room, + const char* const contact, const char* const reason) { - char *id = connection_create_stanza_id(); - xmpp_stanza_t *message = xmpp_message_new(ctx, NULL, room, id); + char* id = connection_create_stanza_id(); + xmpp_stanza_t* message = xmpp_message_new(ctx, NULL, room, id); free(id); - xmpp_stanza_t *x = xmpp_stanza_new(ctx); + xmpp_stanza_t* x = xmpp_stanza_new(ctx); xmpp_stanza_set_name(x, STANZA_NAME_X); xmpp_stanza_set_ns(x, STANZA_NS_MUC_USER); - xmpp_stanza_t *invite = xmpp_stanza_new(ctx); + xmpp_stanza_t* invite = xmpp_stanza_new(ctx); xmpp_stanza_set_name(invite, STANZA_NAME_INVITE); xmpp_stanza_set_to(invite, contact); if (reason) { - xmpp_stanza_t *reason_st = xmpp_stanza_new(ctx); + xmpp_stanza_t* reason_st = xmpp_stanza_new(ctx); xmpp_stanza_set_name(reason_st, STANZA_NAME_REASON); - xmpp_stanza_t *reason_txt = xmpp_stanza_new(ctx); + xmpp_stanza_t* reason_txt = xmpp_stanza_new(ctx); xmpp_stanza_set_text(reason_txt, reason); xmpp_stanza_add_child(reason_st, reason_txt); xmpp_stanza_release(reason_txt); @@ -571,21 +570,21 @@ stanza_create_mediated_invite(xmpp_ctx_t *ctx, const char *const room, } xmpp_stanza_t* -stanza_create_room_join_presence(xmpp_ctx_t *const ctx, - const char *const full_room_jid, const char *const passwd) +stanza_create_room_join_presence(xmpp_ctx_t* const ctx, + const char* const full_room_jid, const char* const passwd) { - xmpp_stanza_t *presence = xmpp_presence_new(ctx); + xmpp_stanza_t* presence = xmpp_presence_new(ctx); xmpp_stanza_set_to(presence, full_room_jid); _stanza_add_unique_id(presence); - xmpp_stanza_t *x = xmpp_stanza_new(ctx); + xmpp_stanza_t* x = xmpp_stanza_new(ctx); xmpp_stanza_set_name(x, STANZA_NAME_X); xmpp_stanza_set_ns(x, STANZA_NS_MUC); if (passwd) { - xmpp_stanza_t *pass = xmpp_stanza_new(ctx); + xmpp_stanza_t* pass = xmpp_stanza_new(ctx); xmpp_stanza_set_name(pass, "password"); - xmpp_stanza_t *text = xmpp_stanza_new(ctx); + xmpp_stanza_t* text = xmpp_stanza_new(ctx); xmpp_stanza_set_text(text, passwd); xmpp_stanza_add_child(pass, text); xmpp_stanza_add_child(x, pass); @@ -600,10 +599,10 @@ stanza_create_room_join_presence(xmpp_ctx_t *const ctx, } xmpp_stanza_t* -stanza_create_room_newnick_presence(xmpp_ctx_t *ctx, - const char *const full_room_jid) +stanza_create_room_newnick_presence(xmpp_ctx_t* ctx, + const char* const full_room_jid) { - xmpp_stanza_t *presence = xmpp_presence_new(ctx); + xmpp_stanza_t* presence = xmpp_presence_new(ctx); _stanza_add_unique_id(presence); xmpp_stanza_set_to(presence, full_room_jid); @@ -611,14 +610,14 @@ stanza_create_room_newnick_presence(xmpp_ctx_t *ctx, } xmpp_stanza_t* -stanza_create_room_leave_presence(xmpp_ctx_t *ctx, const char *const room, - const char *const nick) +stanza_create_room_leave_presence(xmpp_ctx_t* ctx, const char* const room, + const char* const nick) { - GString *full_jid = g_string_new(room); + GString* full_jid = g_string_new(room); g_string_append(full_jid, "/"); g_string_append(full_jid, nick); - xmpp_stanza_t *presence = xmpp_presence_new(ctx); + xmpp_stanza_t* presence = xmpp_presence_new(ctx); xmpp_stanza_set_type(presence, STANZA_TYPE_UNAVAILABLE); xmpp_stanza_set_to(presence, full_jid->str); _stanza_add_unique_id(presence); @@ -629,18 +628,18 @@ stanza_create_room_leave_presence(xmpp_ctx_t *ctx, const char *const room, } xmpp_stanza_t* -stanza_create_instant_room_request_iq(xmpp_ctx_t *ctx, const char *const room_jid) +stanza_create_instant_room_request_iq(xmpp_ctx_t* ctx, const char* const room_jid) { - char *id = connection_create_stanza_id(); - xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); + char* id = connection_create_stanza_id(); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); free(id); xmpp_stanza_set_to(iq, room_jid); - xmpp_stanza_t *query = xmpp_stanza_new(ctx); + xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_ns(query, STANZA_NS_MUC_OWNER); - xmpp_stanza_t *x = xmpp_stanza_new(ctx); + xmpp_stanza_t* x = xmpp_stanza_new(ctx); xmpp_stanza_set_name(x, STANZA_NAME_X); xmpp_stanza_set_type(x, "submit"); xmpp_stanza_set_ns(x, STANZA_NS_DATA); @@ -655,18 +654,18 @@ stanza_create_instant_room_request_iq(xmpp_ctx_t *ctx, const char *const room_ji } xmpp_stanza_t* -stanza_create_instant_room_destroy_iq(xmpp_ctx_t *ctx, const char *const room_jid) +stanza_create_instant_room_destroy_iq(xmpp_ctx_t* ctx, const char* const room_jid) { - char *id = connection_create_stanza_id(); - xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); + char* id = connection_create_stanza_id(); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); free(id); xmpp_stanza_set_to(iq, room_jid); - xmpp_stanza_t *query = xmpp_stanza_new(ctx); + xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_ns(query, STANZA_NS_MUC_OWNER); - xmpp_stanza_t *destroy = xmpp_stanza_new(ctx); + xmpp_stanza_t* destroy = xmpp_stanza_new(ctx); xmpp_stanza_set_name(destroy, STANZA_NAME_DESTROY); xmpp_stanza_add_child(query, destroy); @@ -679,14 +678,14 @@ stanza_create_instant_room_destroy_iq(xmpp_ctx_t *ctx, const char *const room_ji } xmpp_stanza_t* -stanza_create_room_config_request_iq(xmpp_ctx_t *ctx, const char *const room_jid) +stanza_create_room_config_request_iq(xmpp_ctx_t* ctx, const char* const room_jid) { - char *id = connection_create_stanza_id(); - xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id); + char* id = connection_create_stanza_id(); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id); free(id); xmpp_stanza_set_to(iq, room_jid); - xmpp_stanza_t *query = xmpp_stanza_new(ctx); + xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_ns(query, STANZA_NS_MUC_OWNER); @@ -697,18 +696,18 @@ stanza_create_room_config_request_iq(xmpp_ctx_t *ctx, const char *const room_jid } xmpp_stanza_t* -stanza_create_room_config_cancel_iq(xmpp_ctx_t *ctx, const char *const room_jid) +stanza_create_room_config_cancel_iq(xmpp_ctx_t* ctx, const char* const room_jid) { - char *id = connection_create_stanza_id(); - xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); + char* id = connection_create_stanza_id(); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); free(id); xmpp_stanza_set_to(iq, room_jid); - xmpp_stanza_t *query = xmpp_stanza_new(ctx); + xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_ns(query, STANZA_NS_MUC_OWNER); - xmpp_stanza_t *x = xmpp_stanza_new(ctx); + xmpp_stanza_t* x = xmpp_stanza_new(ctx); xmpp_stanza_set_name(x, STANZA_NAME_X); xmpp_stanza_set_type(x, "cancel"); xmpp_stanza_set_ns(x, STANZA_NS_DATA); @@ -723,18 +722,18 @@ stanza_create_room_config_cancel_iq(xmpp_ctx_t *ctx, const char *const room_jid) } xmpp_stanza_t* -stanza_create_room_affiliation_list_iq(xmpp_ctx_t *ctx, const char *const room, const char *const affiliation) +stanza_create_room_affiliation_list_iq(xmpp_ctx_t* ctx, const char* const room, const char* const affiliation) { - char *id = connection_create_stanza_id(); - xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id); + char* id = connection_create_stanza_id(); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id); free(id); xmpp_stanza_set_to(iq, room); - xmpp_stanza_t *query = xmpp_stanza_new(ctx); + xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_ns(query, STANZA_NS_MUC_ADMIN); - xmpp_stanza_t *item = xmpp_stanza_new(ctx); + xmpp_stanza_t* item = xmpp_stanza_new(ctx); xmpp_stanza_set_name(item, STANZA_NAME_ITEM); xmpp_stanza_set_attribute(item, "affiliation", affiliation); @@ -747,18 +746,18 @@ stanza_create_room_affiliation_list_iq(xmpp_ctx_t *ctx, const char *const room, } xmpp_stanza_t* -stanza_create_room_role_list_iq(xmpp_ctx_t *ctx, const char *const room, const char *const role) +stanza_create_room_role_list_iq(xmpp_ctx_t* ctx, const char* const room, const char* const role) { - char *id = connection_create_stanza_id(); - xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id); + char* id = connection_create_stanza_id(); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id); free(id); xmpp_stanza_set_to(iq, room); - xmpp_stanza_t *query = xmpp_stanza_new(ctx); + xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_ns(query, STANZA_NS_MUC_ADMIN); - xmpp_stanza_t *item = xmpp_stanza_new(ctx); + xmpp_stanza_t* item = xmpp_stanza_new(ctx); xmpp_stanza_set_name(item, STANZA_NAME_ITEM); xmpp_stanza_set_attribute(item, "role", role); @@ -771,27 +770,27 @@ stanza_create_room_role_list_iq(xmpp_ctx_t *ctx, const char *const room, const c } xmpp_stanza_t* -stanza_create_room_affiliation_set_iq(xmpp_ctx_t *ctx, const char *const room, const char *const jid, - const char *const affiliation, const char *const reason) +stanza_create_room_affiliation_set_iq(xmpp_ctx_t* ctx, const char* const room, const char* const jid, + const char* const affiliation, const char* const reason) { - char *id = connection_create_stanza_id(); - xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); + char* id = connection_create_stanza_id(); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); free(id); xmpp_stanza_set_to(iq, room); - xmpp_stanza_t *query = xmpp_stanza_new(ctx); + xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_ns(query, STANZA_NS_MUC_ADMIN); - xmpp_stanza_t *item = xmpp_stanza_new(ctx); + xmpp_stanza_t* item = xmpp_stanza_new(ctx); xmpp_stanza_set_name(item, STANZA_NAME_ITEM); xmpp_stanza_set_attribute(item, "affiliation", affiliation); xmpp_stanza_set_attribute(item, STANZA_ATTR_JID, jid); if (reason) { - xmpp_stanza_t *reason_st = xmpp_stanza_new(ctx); + xmpp_stanza_t* reason_st = xmpp_stanza_new(ctx); xmpp_stanza_set_name(reason_st, STANZA_NAME_REASON); - xmpp_stanza_t *reason_text = xmpp_stanza_new(ctx); + xmpp_stanza_t* reason_text = xmpp_stanza_new(ctx); xmpp_stanza_set_text(reason_text, reason); xmpp_stanza_add_child(reason_st, reason_text); xmpp_stanza_release(reason_text); @@ -809,27 +808,27 @@ stanza_create_room_affiliation_set_iq(xmpp_ctx_t *ctx, const char *const room, c } xmpp_stanza_t* -stanza_create_room_role_set_iq(xmpp_ctx_t *const ctx, const char *const room, const char *const nick, - const char *const role, const char *const reason) +stanza_create_room_role_set_iq(xmpp_ctx_t* const ctx, const char* const room, const char* const nick, + const char* const role, const char* const reason) { - char *id = connection_create_stanza_id(); - xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); + char* id = connection_create_stanza_id(); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); free(id); xmpp_stanza_set_to(iq, room); - xmpp_stanza_t *query = xmpp_stanza_new(ctx); + xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_ns(query, STANZA_NS_MUC_ADMIN); - xmpp_stanza_t *item = xmpp_stanza_new(ctx); + xmpp_stanza_t* item = xmpp_stanza_new(ctx); xmpp_stanza_set_name(item, STANZA_NAME_ITEM); xmpp_stanza_set_attribute(item, "role", role); xmpp_stanza_set_attribute(item, STANZA_ATTR_NICK, nick); if (reason) { - xmpp_stanza_t *reason_st = xmpp_stanza_new(ctx); + xmpp_stanza_t* reason_st = xmpp_stanza_new(ctx); xmpp_stanza_set_name(reason_st, STANZA_NAME_REASON); - xmpp_stanza_t *reason_text = xmpp_stanza_new(ctx); + xmpp_stanza_t* reason_text = xmpp_stanza_new(ctx); xmpp_stanza_set_text(reason_text, reason); xmpp_stanza_add_child(reason_st, reason_text); xmpp_stanza_release(reason_text); @@ -847,27 +846,27 @@ stanza_create_room_role_set_iq(xmpp_ctx_t *const ctx, const char *const room, co } xmpp_stanza_t* -stanza_create_room_kick_iq(xmpp_ctx_t *const ctx, const char *const room, const char *const nick, - const char *const reason) +stanza_create_room_kick_iq(xmpp_ctx_t* const ctx, const char* const room, const char* const nick, + const char* const reason) { - char *id = connection_create_stanza_id(); - xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); + char* id = connection_create_stanza_id(); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); free(id); xmpp_stanza_set_to(iq, room); - xmpp_stanza_t *query = xmpp_stanza_new(ctx); + xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_ns(query, STANZA_NS_MUC_ADMIN); - xmpp_stanza_t *item = xmpp_stanza_new(ctx); + xmpp_stanza_t* item = xmpp_stanza_new(ctx); xmpp_stanza_set_name(item, STANZA_NAME_ITEM); xmpp_stanza_set_attribute(item, STANZA_ATTR_NICK, nick); xmpp_stanza_set_attribute(item, "role", "none"); if (reason) { - xmpp_stanza_t *reason_st = xmpp_stanza_new(ctx); + xmpp_stanza_t* reason_st = xmpp_stanza_new(ctx); xmpp_stanza_set_name(reason_st, STANZA_NAME_REASON); - xmpp_stanza_t *reason_text = xmpp_stanza_new(ctx); + xmpp_stanza_t* reason_text = xmpp_stanza_new(ctx); xmpp_stanza_set_text(reason_text, reason); xmpp_stanza_add_child(reason_st, reason_text); xmpp_stanza_release(reason_text); @@ -885,14 +884,14 @@ stanza_create_room_kick_iq(xmpp_ctx_t *const ctx, const char *const room, const } xmpp_stanza_t* -stanza_create_software_version_iq(xmpp_ctx_t *ctx, const char *const fulljid) +stanza_create_software_version_iq(xmpp_ctx_t* ctx, const char* const fulljid) { - char *id = connection_create_stanza_id(); - xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id); + char* id = connection_create_stanza_id(); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id); free(id); xmpp_stanza_set_to(iq, fulljid); - xmpp_stanza_t *query = xmpp_stanza_new(ctx); + xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_ns(query, STANZA_NS_VERSION); @@ -903,11 +902,11 @@ stanza_create_software_version_iq(xmpp_ctx_t *ctx, const char *const fulljid) } xmpp_stanza_t* -stanza_create_roster_iq(xmpp_ctx_t *ctx) +stanza_create_roster_iq(xmpp_ctx_t* ctx) { - xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, "roster"); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, "roster"); - xmpp_stanza_t *query = xmpp_stanza_new(ctx); + xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_ns(query, XMPP_NS_ROSTER); @@ -918,13 +917,13 @@ stanza_create_roster_iq(xmpp_ctx_t *ctx) } xmpp_stanza_t* -stanza_create_disco_info_iq(xmpp_ctx_t *ctx, const char *const id, const char *const to, - const char *const node) +stanza_create_disco_info_iq(xmpp_ctx_t* ctx, const char* const id, const char* const to, + const char* const node) { - xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id); xmpp_stanza_set_to(iq, to); - xmpp_stanza_t *query = xmpp_stanza_new(ctx); + xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_ns(query, XMPP_NS_DISCO_INFO); if (node) { @@ -938,13 +937,13 @@ stanza_create_disco_info_iq(xmpp_ctx_t *ctx, const char *const id, const char *c } xmpp_stanza_t* -stanza_create_disco_items_iq(xmpp_ctx_t *ctx, const char *const id, - const char *const jid, const char *const node) +stanza_create_disco_items_iq(xmpp_ctx_t* ctx, const char* const id, + const char* const jid, const char* const node) { - xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id); xmpp_stanza_set_to(iq, jid); - xmpp_stanza_t *query = xmpp_stanza_new(ctx); + xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_ns(query, XMPP_NS_DISCO_ITEMS); if (node) { @@ -958,12 +957,12 @@ stanza_create_disco_items_iq(xmpp_ctx_t *ctx, const char *const id, } xmpp_stanza_t* -stanza_create_last_activity_iq(xmpp_ctx_t *ctx, const char *const id, const char *const to) +stanza_create_last_activity_iq(xmpp_ctx_t* ctx, const char* const id, const char* const to) { - xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id); xmpp_stanza_set_to(iq, to); - xmpp_stanza_t *query = xmpp_stanza_new(ctx); + xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_ns(query, STANZA_NS_LASTACTIVITY); @@ -974,18 +973,18 @@ stanza_create_last_activity_iq(xmpp_ctx_t *ctx, const char *const id, const char } xmpp_stanza_t* -stanza_create_room_config_submit_iq(xmpp_ctx_t *ctx, const char *const room, DataForm *form) +stanza_create_room_config_submit_iq(xmpp_ctx_t* ctx, const char* const room, DataForm* form) { - char *id = connection_create_stanza_id(); - xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); + char* id = connection_create_stanza_id(); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); free(id); xmpp_stanza_set_to(iq, room); - xmpp_stanza_t *query = xmpp_stanza_new(ctx); + xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_ns(query, STANZA_NS_MUC_OWNER); - xmpp_stanza_t *x = form_create_submission(form); + xmpp_stanza_t* x = form_create_submission(form); xmpp_stanza_add_child(query, x); xmpp_stanza_release(x); @@ -996,18 +995,18 @@ stanza_create_room_config_submit_iq(xmpp_ctx_t *ctx, const char *const room, Dat } xmpp_stanza_t* -stanza_create_caps_query_element(xmpp_ctx_t *ctx) +stanza_create_caps_query_element(xmpp_ctx_t* ctx) { - xmpp_stanza_t *query = xmpp_stanza_new(ctx); + xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_ns(query, XMPP_NS_DISCO_INFO); - xmpp_stanza_t *identity = xmpp_stanza_new(ctx); + xmpp_stanza_t* identity = xmpp_stanza_new(ctx); xmpp_stanza_set_name(identity, "identity"); xmpp_stanza_set_attribute(identity, "category", "client"); xmpp_stanza_set_type(identity, "console"); - GString *name_str = g_string_new("Profanity "); + GString* name_str = g_string_new("Profanity "); g_string_append(name_str, PACKAGE_VERSION); if (strcmp(PACKAGE_STATUS, "development") == 0) { #ifdef HAVE_GIT_VERSION @@ -1024,10 +1023,10 @@ stanza_create_caps_query_element(xmpp_ctx_t *ctx) xmpp_stanza_add_child(query, identity); xmpp_stanza_release(identity); - GList *features = caps_get_features(); - GList *curr = features; + GList* features = caps_get_features(); + GList* curr = features; while (curr) { - xmpp_stanza_t *feature = xmpp_stanza_new(ctx); + xmpp_stanza_t* feature = xmpp_stanza_new(ctx); xmpp_stanza_set_name(feature, STANZA_NAME_FEATURE); xmpp_stanza_set_attribute(feature, STANZA_ATTR_VAR, curr->data); xmpp_stanza_add_child(query, feature); @@ -1041,26 +1040,22 @@ stanza_create_caps_query_element(xmpp_ctx_t *ctx) } gboolean -stanza_contains_chat_state(xmpp_stanza_t *stanza) +stanza_contains_chat_state(xmpp_stanza_t* stanza) { - return ((xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ACTIVE) != NULL) || - (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_COMPOSING) != NULL) || - (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_PAUSED) != NULL) || - (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_GONE) != NULL) || - (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_INACTIVE) != NULL)); + return ((xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ACTIVE) != NULL) || (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_COMPOSING) != NULL) || (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_PAUSED) != NULL) || (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_GONE) != NULL) || (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_INACTIVE) != NULL)); } xmpp_stanza_t* -stanza_create_ping_iq(xmpp_ctx_t *ctx, const char *const target) +stanza_create_ping_iq(xmpp_ctx_t* ctx, const char* const target) { - char *id = connection_create_stanza_id(); - xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id); + char* id = connection_create_stanza_id(); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id); free(id); if (target) { xmpp_stanza_set_to(iq, target); } - xmpp_stanza_t *ping = xmpp_stanza_new(ctx); + xmpp_stanza_t* ping = xmpp_stanza_new(ctx); xmpp_stanza_set_name(ping, STANZA_NAME_PING); xmpp_stanza_set_ns(ping, STANZA_NS_PING); @@ -1072,22 +1067,22 @@ stanza_create_ping_iq(xmpp_ctx_t *ctx, const char *const target) } char* -stanza_create_caps_sha1_from_query(xmpp_stanza_t *const query) +stanza_create_caps_sha1_from_query(xmpp_stanza_t* const query) { - GSList *identities = NULL; - GSList *features = NULL; - GSList *form_names = NULL; - GHashTable *forms = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)form_destroy); + GSList* identities = NULL; + GSList* features = NULL; + GSList* form_names = NULL; + GHashTable* forms = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)form_destroy); - xmpp_stanza_t *child = xmpp_stanza_get_children(query); + xmpp_stanza_t* child = xmpp_stanza_get_children(query); while (child) { if (g_strcmp0(xmpp_stanza_get_name(child), STANZA_NAME_IDENTITY) == 0) { - const char *category = xmpp_stanza_get_attribute(child, "category"); - const char *type = xmpp_stanza_get_type(child); - const char *lang = xmpp_stanza_get_attribute(child, "xml:lang"); - const char *name = xmpp_stanza_get_attribute(child, "name"); + const char* category = xmpp_stanza_get_attribute(child, "category"); + const char* type = xmpp_stanza_get_type(child); + const char* lang = xmpp_stanza_get_attribute(child, "xml:lang"); + const char* name = xmpp_stanza_get_attribute(child, "name"); - GString *identity_str = g_string_new(category); + GString* identity_str = g_string_new(category); g_string_append(identity_str, "/"); if (type) { g_string_append(identity_str, type); @@ -1104,12 +1099,12 @@ stanza_create_caps_sha1_from_query(xmpp_stanza_t *const query) identities = g_slist_insert_sorted(identities, g_strdup(identity_str->str), (GCompareFunc)strcmp); g_string_free(identity_str, TRUE); } else if (g_strcmp0(xmpp_stanza_get_name(child), STANZA_NAME_FEATURE) == 0) { - const char *feature_str = xmpp_stanza_get_attribute(child, "var"); + const char* feature_str = xmpp_stanza_get_attribute(child, "var"); features = g_slist_insert_sorted(features, g_strdup(feature_str), (GCompareFunc)strcmp); } else if (g_strcmp0(xmpp_stanza_get_name(child), STANZA_NAME_X) == 0) { if (g_strcmp0(xmpp_stanza_get_ns(child), STANZA_NS_DATA) == 0) { - DataForm *form = form_create(child); - char *form_type = form_get_form_type_field(form); + DataForm* form = form_create(child); + char* form_type = form_get_form_type_field(form); form_names = g_slist_insert_sorted(form_names, g_strdup(form_type), (GCompareFunc)strcmp); g_hash_table_insert(forms, g_strdup(form_type), form); } @@ -1117,9 +1112,9 @@ stanza_create_caps_sha1_from_query(xmpp_stanza_t *const query) child = xmpp_stanza_get_next(child); } - GString *s = g_string_new(""); + GString* s = g_string_new(""); - GSList *curr = identities; + GSList* curr = identities; while (curr) { g_string_append(s, curr->data); curr = g_slist_next(curr); @@ -1134,20 +1129,20 @@ stanza_create_caps_sha1_from_query(xmpp_stanza_t *const query) curr = form_names; while (curr) { - DataForm *form = g_hash_table_lookup(forms, curr->data); - char *form_type = form_get_form_type_field(form); + DataForm* form = g_hash_table_lookup(forms, curr->data); + char* form_type = form_get_form_type_field(form); g_string_append(s, form_type); g_string_append(s, "<"); - GSList *sorted_fields = form_get_non_form_type_fields_sorted(form); - GSList *curr_field = sorted_fields; + GSList* sorted_fields = form_get_non_form_type_fields_sorted(form); + GSList* curr_field = sorted_fields; while (curr_field) { - FormField *field = curr_field->data; + FormField* field = curr_field->data; g_string_append(s, field->var); g_string_append(s, "<"); - GSList *sorted_values = form_get_field_values_sorted(field); - GSList *curr_value = sorted_values; + GSList* sorted_values = form_get_field_values_sorted(field); + GSList* curr_value = sorted_values; while (curr_value) { g_string_append(s, curr_value->data); g_string_append(s, "<"); @@ -1161,7 +1156,7 @@ stanza_create_caps_sha1_from_query(xmpp_stanza_t *const query) curr = g_slist_next(curr); } - char *result = _stanza_create_sha1_hash(s->str); + char* result = _stanza_create_sha1_hash(s->str); g_string_free(s, TRUE); g_slist_free_full(identities, g_free); @@ -1173,11 +1168,11 @@ stanza_create_caps_sha1_from_query(xmpp_stanza_t *const query) } xmpp_stanza_t* -stanza_get_child_by_name_and_from(xmpp_stanza_t * const stanza, const char * const name, const char * const from) +stanza_get_child_by_name_and_from(xmpp_stanza_t* const stanza, const char* const name, const char* const from) { - xmpp_stanza_t *child; - const char *child_from; - const char *child_name; + xmpp_stanza_t* child; + const char* child_from; + const char* child_name; for (child = xmpp_stanza_get_children(stanza); child; child = xmpp_stanza_get_next(child)) { child_name = xmpp_stanza_get_name(child); @@ -1193,24 +1188,24 @@ stanza_get_child_by_name_and_from(xmpp_stanza_t * const stanza, const char * con } GDateTime* -stanza_get_delay(xmpp_stanza_t *const stanza) +stanza_get_delay(xmpp_stanza_t* const stanza) { return stanza_get_delay_from(stanza, NULL); } static GDateTime* -_stanza_get_delay_timestamp_xep0203(xmpp_stanza_t *const delay_stanza) +_stanza_get_delay_timestamp_xep0203(xmpp_stanza_t* const delay_stanza) { GTimeVal utc_stamp; - const char *xmlns = xmpp_stanza_get_attribute(delay_stanza, STANZA_ATTR_XMLNS); + const char* xmlns = xmpp_stanza_get_attribute(delay_stanza, STANZA_ATTR_XMLNS); if (xmlns && (strcmp(xmlns, "urn:xmpp:delay") == 0)) { - const char *stamp = xmpp_stanza_get_attribute(delay_stanza, STANZA_ATTR_STAMP); + const char* stamp = xmpp_stanza_get_attribute(delay_stanza, STANZA_ATTR_STAMP); if (stamp && (g_time_val_from_iso8601(stamp, &utc_stamp))) { - GDateTime *utc_datetime = g_date_time_new_from_timeval_utc(&utc_stamp); - GDateTime *local_datetime = g_date_time_to_local(utc_datetime); + GDateTime* utc_datetime = g_date_time_new_from_timeval_utc(&utc_stamp); + GDateTime* local_datetime = g_date_time_to_local(utc_datetime); g_date_time_unref(utc_datetime); return local_datetime; @@ -1221,17 +1216,17 @@ _stanza_get_delay_timestamp_xep0203(xmpp_stanza_t *const delay_stanza) } static GDateTime* -_stanza_get_delay_timestamp_xep0091(xmpp_stanza_t *const x_stanza) +_stanza_get_delay_timestamp_xep0091(xmpp_stanza_t* const x_stanza) { GTimeVal utc_stamp; - const char *xmlns = xmpp_stanza_get_attribute(x_stanza, STANZA_ATTR_XMLNS); + const char* xmlns = xmpp_stanza_get_attribute(x_stanza, STANZA_ATTR_XMLNS); if (xmlns && (strcmp(xmlns, "jabber:x:delay") == 0)) { - const char *stamp = xmpp_stanza_get_attribute(x_stanza, STANZA_ATTR_STAMP); + const char* stamp = xmpp_stanza_get_attribute(x_stanza, STANZA_ATTR_STAMP); if (stamp && (g_time_val_from_iso8601(stamp, &utc_stamp))) { - GDateTime *utc_datetime = g_date_time_new_from_timeval_utc(&utc_stamp); - GDateTime *local_datetime = g_date_time_to_local(utc_datetime); + GDateTime* utc_datetime = g_date_time_new_from_timeval_utc(&utc_stamp); + GDateTime* local_datetime = g_date_time_to_local(utc_datetime); g_date_time_unref(utc_datetime); return local_datetime; @@ -1242,9 +1237,9 @@ _stanza_get_delay_timestamp_xep0091(xmpp_stanza_t *const x_stanza) } GDateTime* -stanza_get_delay_from(xmpp_stanza_t *const stanza, gchar *from) +stanza_get_delay_from(xmpp_stanza_t* const stanza, gchar* from) { - xmpp_stanza_t *delay = NULL; + xmpp_stanza_t* delay = NULL; // first check for XEP-0203 delayed delivery if (from) { @@ -1273,10 +1268,10 @@ stanza_get_delay_from(xmpp_stanza_t *const stanza, gchar *from) } GDateTime* -stanza_get_oldest_delay(xmpp_stanza_t *const stanza) +stanza_get_oldest_delay(xmpp_stanza_t* const stanza) { - xmpp_stanza_t *child; - const char *child_name; + xmpp_stanza_t* child; + const char* child_name; GDateTime* oldest = NULL; for (child = xmpp_stanza_get_children(stanza); child; child = xmpp_stanza_get_next(child)) { @@ -1284,7 +1279,7 @@ stanza_get_oldest_delay(xmpp_stanza_t *const stanza) child_name = xmpp_stanza_get_name(child); if (child_name && strcmp(child_name, STANZA_NAME_DELAY) == 0) { - GDateTime *tmp = _stanza_get_delay_timestamp_xep0203(child); + GDateTime* tmp = _stanza_get_delay_timestamp_xep0203(child); if (oldest == NULL) { oldest = tmp; @@ -1297,7 +1292,7 @@ stanza_get_oldest_delay(xmpp_stanza_t *const stanza) } if (child_name && strcmp(child_name, STANZA_NAME_X) == 0) { - GDateTime *tmp = _stanza_get_delay_timestamp_xep0091(child); + GDateTime* tmp = _stanza_get_delay_timestamp_xep0091(child); if (oldest == NULL) { oldest = tmp; @@ -1314,9 +1309,9 @@ stanza_get_oldest_delay(xmpp_stanza_t *const stanza) } char* -stanza_get_status(xmpp_stanza_t *stanza, char *def) +stanza_get_status(xmpp_stanza_t* stanza, char* def) { - xmpp_stanza_t *status = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_STATUS); + xmpp_stanza_t* status = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_STATUS); if (status) { return stanza_text_strdup(status); @@ -1328,9 +1323,9 @@ stanza_get_status(xmpp_stanza_t *stanza, char *def) } char* -stanza_get_show(xmpp_stanza_t *stanza, char *def) +stanza_get_show(xmpp_stanza_t* stanza, char* def) { - xmpp_stanza_t *show = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_SHOW); + xmpp_stanza_t* show = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_SHOW); if (show) { return stanza_text_strdup(show); @@ -1342,7 +1337,7 @@ stanza_get_show(xmpp_stanza_t *stanza, char *def) } gboolean -stanza_is_muc_presence(xmpp_stanza_t *const stanza) +stanza_is_muc_presence(xmpp_stanza_t* const stanza) { if (stanza == NULL) { return FALSE; @@ -1351,7 +1346,7 @@ stanza_is_muc_presence(xmpp_stanza_t *const stanza) return FALSE; } - xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); + xmpp_stanza_t* x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); if (x) { return TRUE; @@ -1361,7 +1356,7 @@ stanza_is_muc_presence(xmpp_stanza_t *const stanza) } gboolean -stanza_muc_requires_config(xmpp_stanza_t *const stanza) +stanza_muc_requires_config(xmpp_stanza_t* const stanza) { // no stanza, or not presence stanza if ((stanza == NULL) || (g_strcmp0(xmpp_stanza_get_name(stanza), STANZA_NAME_PRESENCE) != 0)) { @@ -1369,26 +1364,26 @@ stanza_muc_requires_config(xmpp_stanza_t *const stanza) } // muc user namespaced x element - xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); + xmpp_stanza_t* x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); if (x == NULL) { return FALSE; } // check for item element with owner affiliation - xmpp_stanza_t *item = xmpp_stanza_get_child_by_name(x, "item"); + xmpp_stanza_t* item = xmpp_stanza_get_child_by_name(x, "item"); if (item == NULL) { return FALSE; } - const char *affiliation = xmpp_stanza_get_attribute(item, "affiliation"); + const char* affiliation = xmpp_stanza_get_attribute(item, "affiliation"); if (g_strcmp0(affiliation, "owner") != 0) { return FALSE; } // check for status code 201 - xmpp_stanza_t *x_children = xmpp_stanza_get_children(x); + xmpp_stanza_t* x_children = xmpp_stanza_get_children(x); while (x_children) { if (g_strcmp0(xmpp_stanza_get_name(x_children), STANZA_NAME_STATUS) == 0) { - const char *code = xmpp_stanza_get_attribute(x_children, STANZA_ATTR_CODE); + const char* code = xmpp_stanza_get_attribute(x_children, STANZA_ATTR_CODE); if (g_strcmp0(code, "201") == 0) { return TRUE; } @@ -1400,8 +1395,8 @@ stanza_muc_requires_config(xmpp_stanza_t *const stanza) } gboolean -stanza_is_muc_self_presence(xmpp_stanza_t *const stanza, - const char *const self_jid) +stanza_is_muc_self_presence(xmpp_stanza_t* const stanza, + const char* const self_jid) { // no stanza, or not presence stanza if ((stanza == NULL) || (g_strcmp0(xmpp_stanza_get_name(stanza), STANZA_NAME_PRESENCE) != 0)) { @@ -1409,17 +1404,17 @@ stanza_is_muc_self_presence(xmpp_stanza_t *const stanza, } // muc user namespaced x element - xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); + xmpp_stanza_t* x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); if (x == NULL) { return FALSE; } // check for status child element with 110 code - xmpp_stanza_t *x_children = xmpp_stanza_get_children(x); + xmpp_stanza_t* x_children = xmpp_stanza_get_children(x); while (x_children) { if (g_strcmp0(xmpp_stanza_get_name(x_children), STANZA_NAME_STATUS) == 0) { - const char *code = xmpp_stanza_get_attribute(x_children, STANZA_ATTR_CODE); + const char* code = xmpp_stanza_get_attribute(x_children, STANZA_ATTR_CODE); if (g_strcmp0(code, "110") == 0) { return TRUE; } @@ -1428,9 +1423,9 @@ stanza_is_muc_self_presence(xmpp_stanza_t *const stanza, } // check for item child element with jid property - xmpp_stanza_t *item = xmpp_stanza_get_child_by_name(x, STANZA_NAME_ITEM); + xmpp_stanza_t* item = xmpp_stanza_get_child_by_name(x, STANZA_NAME_ITEM); if (item) { - const char *jid = xmpp_stanza_get_attribute(item, STANZA_ATTR_JID); + const char* jid = xmpp_stanza_get_attribute(item, STANZA_ATTR_JID); if (jid) { if (g_str_has_prefix(self_jid, jid)) { return TRUE; @@ -1439,11 +1434,11 @@ stanza_is_muc_self_presence(xmpp_stanza_t *const stanza, } // check if 'from' attribute identifies this user - const char *from = xmpp_stanza_get_from(stanza); + const char* from = xmpp_stanza_get_from(stanza); if (from) { - Jid *from_jid = jid_create(from); + Jid* from_jid = jid_create(from); if (muc_active(from_jid->barejid)) { - char *nick = muc_nick(from_jid->barejid); + char* nick = muc_nick(from_jid->barejid); if (g_strcmp0(from_jid->resourcepart, nick) == 0) { jid_destroy(from_jid); return TRUE; @@ -1452,10 +1447,10 @@ stanza_is_muc_self_presence(xmpp_stanza_t *const stanza, // check if a new nickname maps to a pending nick change for this user if (muc_nick_change_pending(from_jid->barejid)) { - char *new_nick = from_jid->resourcepart; + char* new_nick = from_jid->resourcepart; if (new_nick) { - char *nick = muc_nick(from_jid->barejid); - char *old_nick = muc_old_nick(from_jid->barejid, new_nick); + char* nick = muc_nick(from_jid->barejid); + char* old_nick = muc_old_nick(from_jid->barejid, new_nick); if (g_strcmp0(old_nick, nick) == 0) { jid_destroy(from_jid); return TRUE; @@ -1471,19 +1466,19 @@ stanza_is_muc_self_presence(xmpp_stanza_t *const stanza, } GSList* -stanza_get_status_codes_by_ns(xmpp_stanza_t *const stanza, char *ns) +stanza_get_status_codes_by_ns(xmpp_stanza_t* const stanza, char* ns) { - xmpp_stanza_t *ns_child = xmpp_stanza_get_child_by_ns(stanza, ns); + xmpp_stanza_t* ns_child = xmpp_stanza_get_child_by_ns(stanza, ns); if (ns_child == NULL) { return NULL; } - GSList *codes = NULL; - xmpp_stanza_t *child = xmpp_stanza_get_children(ns_child); + GSList* codes = NULL; + xmpp_stanza_t* child = xmpp_stanza_get_children(ns_child); while (child) { - const char *name = xmpp_stanza_get_name(child); + const char* name = xmpp_stanza_get_name(child); if (g_strcmp0(name, STANZA_NAME_STATUS) == 0) { - const char *code = xmpp_stanza_get_attribute(child, STANZA_ATTR_CODE); + const char* code = xmpp_stanza_get_attribute(child, STANZA_ATTR_CODE); if (code) { codes = g_slist_append(codes, strdup(code)); } @@ -1495,19 +1490,19 @@ stanza_get_status_codes_by_ns(xmpp_stanza_t *const stanza, char *ns) } gboolean -stanza_room_destroyed(xmpp_stanza_t *stanza) +stanza_room_destroyed(xmpp_stanza_t* stanza) { - const char *stanza_name = xmpp_stanza_get_name(stanza); + const char* stanza_name = xmpp_stanza_get_name(stanza); if (g_strcmp0(stanza_name, STANZA_NAME_PRESENCE) != 0) { return FALSE; } - xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); + xmpp_stanza_t* x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); if (x == NULL) { return FALSE; } - xmpp_stanza_t *destroy = xmpp_stanza_get_child_by_name(x, STANZA_NAME_DESTROY); + xmpp_stanza_t* destroy = xmpp_stanza_get_child_by_name(x, STANZA_NAME_DESTROY); if (destroy) { return TRUE; } @@ -1516,24 +1511,24 @@ stanza_room_destroyed(xmpp_stanza_t *stanza) } const char* -stanza_get_muc_destroy_alternative_room(xmpp_stanza_t *stanza) +stanza_get_muc_destroy_alternative_room(xmpp_stanza_t* stanza) { - const char *stanza_name = xmpp_stanza_get_name(stanza); + const char* stanza_name = xmpp_stanza_get_name(stanza); if (g_strcmp0(stanza_name, STANZA_NAME_PRESENCE) != 0) { return NULL; } - xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); + xmpp_stanza_t* x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); if (x == NULL) { return NULL; } - xmpp_stanza_t *destroy = xmpp_stanza_get_child_by_name(x, STANZA_NAME_DESTROY); + xmpp_stanza_t* destroy = xmpp_stanza_get_child_by_name(x, STANZA_NAME_DESTROY); if (destroy == NULL) { return NULL; } - const char *jid = xmpp_stanza_get_attribute(destroy, STANZA_ATTR_JID); + const char* jid = xmpp_stanza_get_attribute(destroy, STANZA_ATTR_JID); if (jid) { return jid; } @@ -1542,24 +1537,24 @@ stanza_get_muc_destroy_alternative_room(xmpp_stanza_t *stanza) } char* -stanza_get_muc_destroy_alternative_password(xmpp_stanza_t *stanza) +stanza_get_muc_destroy_alternative_password(xmpp_stanza_t* stanza) { - const char *stanza_name = xmpp_stanza_get_name(stanza); + const char* stanza_name = xmpp_stanza_get_name(stanza); if (g_strcmp0(stanza_name, STANZA_NAME_PRESENCE) != 0) { return NULL; } - xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); + xmpp_stanza_t* x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); if (x == NULL) { return NULL; } - xmpp_stanza_t *destroy = xmpp_stanza_get_child_by_name(x, STANZA_NAME_DESTROY); + xmpp_stanza_t* destroy = xmpp_stanza_get_child_by_name(x, STANZA_NAME_DESTROY); if (destroy == NULL) { return NULL; } - xmpp_stanza_t *password_st = xmpp_stanza_get_child_by_name(destroy, STANZA_NAME_PASSWORD); + xmpp_stanza_t* password_st = xmpp_stanza_get_child_by_name(destroy, STANZA_NAME_PASSWORD); if (password_st == NULL) { return NULL; } @@ -1568,24 +1563,24 @@ stanza_get_muc_destroy_alternative_password(xmpp_stanza_t *stanza) } char* -stanza_get_muc_destroy_reason(xmpp_stanza_t *stanza) +stanza_get_muc_destroy_reason(xmpp_stanza_t* stanza) { - const char *stanza_name = xmpp_stanza_get_name(stanza); + const char* stanza_name = xmpp_stanza_get_name(stanza); if (g_strcmp0(stanza_name, STANZA_NAME_PRESENCE) != 0) { return NULL; } - xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); + xmpp_stanza_t* x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); if (x == NULL) { return NULL; } - xmpp_stanza_t *destroy = xmpp_stanza_get_child_by_name(x, STANZA_NAME_DESTROY); + xmpp_stanza_t* destroy = xmpp_stanza_get_child_by_name(x, STANZA_NAME_DESTROY); if (destroy == NULL) { return NULL; } - xmpp_stanza_t *reason_st = xmpp_stanza_get_child_by_name(destroy, STANZA_NAME_REASON); + xmpp_stanza_t* reason_st = xmpp_stanza_get_child_by_name(destroy, STANZA_NAME_REASON); if (reason_st == NULL) { return NULL; } @@ -1594,34 +1589,34 @@ stanza_get_muc_destroy_reason(xmpp_stanza_t *stanza) } const char* -stanza_get_actor(xmpp_stanza_t *stanza) +stanza_get_actor(xmpp_stanza_t* stanza) { - const char *stanza_name = xmpp_stanza_get_name(stanza); + const char* stanza_name = xmpp_stanza_get_name(stanza); if (g_strcmp0(stanza_name, STANZA_NAME_PRESENCE) != 0) { return NULL; } - xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); + xmpp_stanza_t* x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); if (x == NULL) { return NULL; } - xmpp_stanza_t *item = xmpp_stanza_get_child_by_name(x, STANZA_NAME_ITEM); + xmpp_stanza_t* item = xmpp_stanza_get_child_by_name(x, STANZA_NAME_ITEM); if (item == NULL) { return NULL; } - xmpp_stanza_t *actor = xmpp_stanza_get_child_by_name(item, STANZA_NAME_ACTOR); + xmpp_stanza_t* actor = xmpp_stanza_get_child_by_name(item, STANZA_NAME_ACTOR); if (actor == NULL) { return NULL; } - const char *nick = xmpp_stanza_get_attribute(actor, STANZA_ATTR_NICK); + const char* nick = xmpp_stanza_get_attribute(actor, STANZA_ATTR_NICK); if (nick) { return nick; } - const char *jid = xmpp_stanza_get_attribute(actor, STANZA_ATTR_JID); + const char* jid = xmpp_stanza_get_attribute(actor, STANZA_ATTR_JID); if (jid) { return jid; } @@ -1630,24 +1625,24 @@ stanza_get_actor(xmpp_stanza_t *stanza) } char* -stanza_get_reason(xmpp_stanza_t *stanza) +stanza_get_reason(xmpp_stanza_t* stanza) { - const char *stanza_name = xmpp_stanza_get_name(stanza); + const char* stanza_name = xmpp_stanza_get_name(stanza); if (g_strcmp0(stanza_name, STANZA_NAME_PRESENCE) != 0) { return NULL; } - xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); + xmpp_stanza_t* x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); if (x == NULL) { return NULL; } - xmpp_stanza_t *item = xmpp_stanza_get_child_by_name(x, STANZA_NAME_ITEM); + xmpp_stanza_t* item = xmpp_stanza_get_child_by_name(x, STANZA_NAME_ITEM); if (item == NULL) { return NULL; } - xmpp_stanza_t *reason_st = xmpp_stanza_get_child_by_name(item, STANZA_NAME_REASON); + xmpp_stanza_t* reason_st = xmpp_stanza_get_child_by_name(item, STANZA_NAME_REASON); if (reason_st == NULL) { return NULL; } @@ -1656,7 +1651,7 @@ stanza_get_reason(xmpp_stanza_t *stanza) } gboolean -stanza_is_room_nick_change(xmpp_stanza_t *const stanza) +stanza_is_room_nick_change(xmpp_stanza_t* const stanza) { // no stanza, or not presence stanza if ((stanza == NULL) || (g_strcmp0(xmpp_stanza_get_name(stanza), STANZA_NAME_PRESENCE) != 0)) { @@ -1664,16 +1659,16 @@ stanza_is_room_nick_change(xmpp_stanza_t *const stanza) } // muc user namespaced x element - xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); + xmpp_stanza_t* x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); if (x == NULL) { return FALSE; } // check for status child element with 303 code - xmpp_stanza_t *x_children = xmpp_stanza_get_children(x); + xmpp_stanza_t* x_children = xmpp_stanza_get_children(x); while (x_children) { if (g_strcmp0(xmpp_stanza_get_name(x_children), STANZA_NAME_STATUS) == 0) { - const char *code = xmpp_stanza_get_attribute(x_children, STANZA_ATTR_CODE); + const char* code = xmpp_stanza_get_attribute(x_children, STANZA_ATTR_CODE); if (g_strcmp0(code, "303") == 0) { return TRUE; } @@ -1685,18 +1680,18 @@ stanza_is_room_nick_change(xmpp_stanza_t *const stanza) } const char* -stanza_get_new_nick(xmpp_stanza_t *const stanza) +stanza_get_new_nick(xmpp_stanza_t* const stanza) { if (!stanza_is_room_nick_change(stanza)) { return NULL; } - xmpp_stanza_t *x = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_X); - xmpp_stanza_t *x_children = xmpp_stanza_get_children(x); + xmpp_stanza_t* x = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_X); + xmpp_stanza_t* x_children = xmpp_stanza_get_children(x); while (x_children) { if (strcmp(xmpp_stanza_get_name(x_children), STANZA_NAME_ITEM) == 0) { - const char *nick = xmpp_stanza_get_attribute(x_children, STANZA_ATTR_NICK); + const char* nick = xmpp_stanza_get_attribute(x_children, STANZA_ATTR_NICK); if (nick) { return nick; } @@ -1708,15 +1703,15 @@ stanza_get_new_nick(xmpp_stanza_t *const stanza) } int -stanza_get_idle_time(xmpp_stanza_t *const stanza) +stanza_get_idle_time(xmpp_stanza_t* const stanza) { - xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); + xmpp_stanza_t* query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); if (query == NULL) { return 0; } - const char *ns = xmpp_stanza_get_ns(query); + const char* ns = xmpp_stanza_get_ns(query); if (ns == NULL) { return 0; } @@ -1725,7 +1720,7 @@ stanza_get_idle_time(xmpp_stanza_t *const stanza) return 0; } - const char *seconds_str = xmpp_stanza_get_attribute(query, STANZA_ATTR_SECONDS); + const char* seconds_str = xmpp_stanza_get_attribute(query, STANZA_ATTR_SECONDS); if (seconds_str == NULL) { return 0; } @@ -1739,24 +1734,24 @@ stanza_get_idle_time(xmpp_stanza_t *const stanza) } XMPPCaps* -stanza_parse_caps(xmpp_stanza_t *const stanza) +stanza_parse_caps(xmpp_stanza_t* const stanza) { - xmpp_stanza_t *caps_st = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_C); + xmpp_stanza_t* caps_st = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_C); if (!caps_st) { return NULL; } - const char *ns = xmpp_stanza_get_ns(caps_st); + const char* ns = xmpp_stanza_get_ns(caps_st); if (g_strcmp0(ns, STANZA_NS_CAPS) != 0) { return NULL; } - const char *hash = xmpp_stanza_get_attribute(caps_st, STANZA_ATTR_HASH); - const char *node = xmpp_stanza_get_attribute(caps_st, STANZA_ATTR_NODE); - const char *ver = xmpp_stanza_get_attribute(caps_st, STANZA_ATTR_VER); + const char* hash = xmpp_stanza_get_attribute(caps_st, STANZA_ATTR_HASH); + const char* node = xmpp_stanza_get_attribute(caps_st, STANZA_ATTR_NODE); + const char* ver = xmpp_stanza_get_attribute(caps_st, STANZA_ATTR_VER); - XMPPCaps *caps = (XMPPCaps *)malloc(sizeof(XMPPCaps)); + XMPPCaps* caps = (XMPPCaps*)malloc(sizeof(XMPPCaps)); caps->hash = hash ? strdup(hash) : NULL; caps->node = node ? strdup(node) : NULL; caps->ver = ver ? strdup(ver) : NULL; @@ -1765,21 +1760,21 @@ stanza_parse_caps(xmpp_stanza_t *const stanza) } EntityCapabilities* -stanza_create_caps_from_query_element(xmpp_stanza_t *query) +stanza_create_caps_from_query_element(xmpp_stanza_t* query) { - char *software = NULL; - char *software_version = NULL; - char *os = NULL; - char *os_version = NULL; + char* software = NULL; + char* software_version = NULL; + char* os = NULL; + char* os_version = NULL; - xmpp_stanza_t *softwareinfo = xmpp_stanza_get_child_by_ns(query, STANZA_NS_DATA); + xmpp_stanza_t* softwareinfo = xmpp_stanza_get_child_by_ns(query, STANZA_NS_DATA); if (softwareinfo) { - DataForm *form = form_create(softwareinfo); - FormField *formField = NULL; + DataForm* form = form_create(softwareinfo); + FormField* formField = NULL; - char *form_type = form_get_form_type_field(form); + char* form_type = form_get_form_type_field(form); if (g_strcmp0(form_type, STANZA_DATAFORM_SOFTWARE) == 0) { - GSList *field = form->fields; + GSList* field = form->fields; while (field) { formField = field->data; if (formField->values) { @@ -1808,9 +1803,9 @@ stanza_create_caps_from_query_element(xmpp_stanza_t *query) form_destroy(form); } - xmpp_stanza_t *child = xmpp_stanza_get_children(query); - GSList *identity_stanzas = NULL; - GSList *features = NULL; + xmpp_stanza_t* child = xmpp_stanza_get_children(query); + GSList* identity_stanzas = NULL; + GSList* features = NULL; while (child) { if (g_strcmp0(xmpp_stanza_get_name(child), "feature") == 0) { features = g_slist_append(features, strdup(xmpp_stanza_get_attribute(child, "var"))); @@ -1823,13 +1818,13 @@ stanza_create_caps_from_query_element(xmpp_stanza_t *query) } // find identity by locale - const gchar* const *langs = g_get_language_names(); + const gchar* const* langs = g_get_language_names(); int num_langs = g_strv_length((gchar**)langs); - xmpp_stanza_t *found = NULL; - GSList *curr_identity = identity_stanzas; + xmpp_stanza_t* found = NULL; + GSList* curr_identity = identity_stanzas; while (curr_identity) { - xmpp_stanza_t *id_stanza = curr_identity->data; - const char *stanza_lang = xmpp_stanza_get_attribute(id_stanza, "xml:lang"); + xmpp_stanza_t* id_stanza = curr_identity->data; + const char* stanza_lang = xmpp_stanza_get_attribute(id_stanza, "xml:lang"); if (stanza_lang) { int i = 0; for (i = 0; i < num_langs; i++) { @@ -1849,8 +1844,8 @@ stanza_create_caps_from_query_element(xmpp_stanza_t *query) if (!found) { curr_identity = identity_stanzas; while (curr_identity) { - xmpp_stanza_t *id_stanza = curr_identity->data; - const char *stanza_lang = xmpp_stanza_get_attribute(id_stanza, "xml:lang"); + xmpp_stanza_t* id_stanza = curr_identity->data; + const char* stanza_lang = xmpp_stanza_get_attribute(id_stanza, "xml:lang"); if (!stanza_lang) { found = id_stanza; break; @@ -1869,16 +1864,16 @@ stanza_create_caps_from_query_element(xmpp_stanza_t *query) g_slist_free(identity_stanzas); - const char *category = NULL; - const char *type = NULL; - const char *name = NULL; + const char* category = NULL; + const char* type = NULL; + const char* name = NULL; if (found) { category = xmpp_stanza_get_attribute(found, "category"); type = xmpp_stanza_get_type(found); name = xmpp_stanza_get_attribute(found, "name"); } - EntityCapabilities *result = caps_create(category, type, name, software, software_version, os, os_version, features); + EntityCapabilities* result = caps_create(category, type, name, software, software_version, os, os_version, features); g_slist_free_full(features, free); free(software); free(software_version); @@ -1889,9 +1884,9 @@ stanza_create_caps_from_query_element(xmpp_stanza_t *query) } char* -stanza_get_error_message(xmpp_stanza_t *stanza) +stanza_get_error_message(xmpp_stanza_t* stanza) { - xmpp_stanza_t *error_stanza = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ERROR); + xmpp_stanza_t* error_stanza = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ERROR); // return nothing if no error stanza if (error_stanza == NULL) { @@ -1899,18 +1894,18 @@ stanza_get_error_message(xmpp_stanza_t *stanza) } // check for text child - xmpp_stanza_t *text_stanza = xmpp_stanza_get_child_by_name(error_stanza, STANZA_NAME_TEXT); + xmpp_stanza_t* text_stanza = xmpp_stanza_get_child_by_name(error_stanza, STANZA_NAME_TEXT); // check for text if (text_stanza) { - char *err_msg = stanza_text_strdup(text_stanza); + char* err_msg = stanza_text_strdup(text_stanza); if (err_msg) { return err_msg; } - // otherwise check each defined-condition RFC-6120 8.3.3 + // otherwise check each defined-condition RFC-6120 8.3.3 } else { - gchar *defined_conditions[] = { + gchar* defined_conditions[] = { STANZA_NAME_BAD_REQUEST, STANZA_NAME_CONFLICT, STANZA_NAME_FEATURE_NOT_IMPLEMENTED, @@ -1936,9 +1931,9 @@ stanza_get_error_message(xmpp_stanza_t *stanza) int i; for (i = 0; i < ARRAY_SIZE(defined_conditions); i++) { - xmpp_stanza_t *cond_stanza = xmpp_stanza_get_child_by_name(error_stanza, defined_conditions[i]); + xmpp_stanza_t* cond_stanza = xmpp_stanza_get_child_by_name(error_stanza, defined_conditions[i]); if (cond_stanza) { - char *result = strdup(xmpp_stanza_get_name(cond_stanza)); + char* result = strdup(xmpp_stanza_get_name(cond_stanza)); return result; } } @@ -1949,41 +1944,41 @@ stanza_get_error_message(xmpp_stanza_t *stanza) } void -stanza_attach_publish_options(xmpp_ctx_t *const ctx, xmpp_stanza_t *const iq, const char *const option, const char *const value) +stanza_attach_publish_options(xmpp_ctx_t* const ctx, xmpp_stanza_t* const iq, const char* const option, const char* const value) { - xmpp_stanza_t *publish_options = xmpp_stanza_new(ctx); + xmpp_stanza_t* publish_options = xmpp_stanza_new(ctx); xmpp_stanza_set_name(publish_options, STANZA_NAME_PUBLISH_OPTIONS); - xmpp_stanza_t *x = xmpp_stanza_new(ctx); + xmpp_stanza_t* x = xmpp_stanza_new(ctx); xmpp_stanza_set_name(x, STANZA_NAME_X); xmpp_stanza_set_ns(x, STANZA_NS_DATA); xmpp_stanza_set_type(x, "submit"); xmpp_stanza_add_child(publish_options, x); - xmpp_stanza_t *form_type = xmpp_stanza_new(ctx); + xmpp_stanza_t* form_type = xmpp_stanza_new(ctx); xmpp_stanza_set_name(form_type, STANZA_NAME_FIELD); xmpp_stanza_set_attribute(form_type, STANZA_ATTR_VAR, "FORM_TYPE"); xmpp_stanza_set_type(form_type, "hidden"); - xmpp_stanza_t *form_type_value = xmpp_stanza_new(ctx); + xmpp_stanza_t* form_type_value = xmpp_stanza_new(ctx); xmpp_stanza_set_name(form_type_value, STANZA_NAME_VALUE); - xmpp_stanza_t *form_type_value_text = xmpp_stanza_new(ctx); + xmpp_stanza_t* form_type_value_text = xmpp_stanza_new(ctx); xmpp_stanza_set_text(form_type_value_text, XMPP_FEATURE_PUBSUB_PUBLISH_OPTIONS); xmpp_stanza_add_child(form_type_value, form_type_value_text); xmpp_stanza_add_child(form_type, form_type_value); xmpp_stanza_add_child(x, form_type); - xmpp_stanza_t *access_model = xmpp_stanza_new(ctx); + xmpp_stanza_t* access_model = xmpp_stanza_new(ctx); xmpp_stanza_set_name(access_model, STANZA_NAME_FIELD); xmpp_stanza_set_attribute(access_model, STANZA_ATTR_VAR, option); - xmpp_stanza_t *access_model_value = xmpp_stanza_new(ctx); + xmpp_stanza_t* access_model_value = xmpp_stanza_new(ctx); xmpp_stanza_set_name(access_model_value, STANZA_NAME_VALUE); - xmpp_stanza_t *access_model_value_text = xmpp_stanza_new(ctx); + xmpp_stanza_t* access_model_value_text = xmpp_stanza_new(ctx); xmpp_stanza_set_text(access_model_value_text, value); xmpp_stanza_add_child(access_model_value, access_model_value_text); xmpp_stanza_add_child(access_model, access_model_value); xmpp_stanza_add_child(x, access_model); - xmpp_stanza_t *pubsub = xmpp_stanza_get_child_by_ns(iq, STANZA_NS_PUBSUB); + xmpp_stanza_t* pubsub = xmpp_stanza_get_child_by_ns(iq, STANZA_NS_PUBSUB); xmpp_stanza_add_child(pubsub, publish_options); xmpp_stanza_release(access_model_value_text); @@ -1997,7 +1992,7 @@ stanza_attach_publish_options(xmpp_ctx_t *const ctx, xmpp_stanza_t *const iq, co } void -stanza_attach_priority(xmpp_ctx_t *const ctx, xmpp_stanza_t *const presence, const int pri) +stanza_attach_priority(xmpp_ctx_t* const ctx, xmpp_stanza_t* const presence, const int pri) { if (pri == 0) { return; @@ -2006,10 +2001,10 @@ stanza_attach_priority(xmpp_ctx_t *const ctx, xmpp_stanza_t *const presence, con char pri_str[10]; snprintf(pri_str, sizeof(pri_str), "%d", pri); - xmpp_stanza_t *priority = xmpp_stanza_new(ctx); + xmpp_stanza_t* priority = xmpp_stanza_new(ctx); xmpp_stanza_set_name(priority, STANZA_NAME_PRIORITY); - xmpp_stanza_t *value = xmpp_stanza_new(ctx); + xmpp_stanza_t* value = xmpp_stanza_new(ctx); xmpp_stanza_set_text(value, pri_str); xmpp_stanza_add_child(priority, value); @@ -2020,16 +2015,16 @@ stanza_attach_priority(xmpp_ctx_t *const ctx, xmpp_stanza_t *const presence, con } void -stanza_attach_show(xmpp_ctx_t *const ctx, xmpp_stanza_t *const presence, - const char *const show) +stanza_attach_show(xmpp_ctx_t* const ctx, xmpp_stanza_t* const presence, + const char* const show) { if (show == NULL) { return; } - xmpp_stanza_t *show_stanza = xmpp_stanza_new(ctx); + xmpp_stanza_t* show_stanza = xmpp_stanza_new(ctx); xmpp_stanza_set_name(show_stanza, STANZA_NAME_SHOW); - xmpp_stanza_t *text = xmpp_stanza_new(ctx); + xmpp_stanza_t* text = xmpp_stanza_new(ctx); xmpp_stanza_set_text(text, show); xmpp_stanza_add_child(show_stanza, text); xmpp_stanza_add_child(presence, show_stanza); @@ -2038,16 +2033,16 @@ stanza_attach_show(xmpp_ctx_t *const ctx, xmpp_stanza_t *const presence, } void -stanza_attach_status(xmpp_ctx_t *const ctx, xmpp_stanza_t *const presence, - const char *const status) +stanza_attach_status(xmpp_ctx_t* const ctx, xmpp_stanza_t* const presence, + const char* const status) { if (status == NULL) { return; } - xmpp_stanza_t *status_stanza = xmpp_stanza_new(ctx); + xmpp_stanza_t* status_stanza = xmpp_stanza_new(ctx); xmpp_stanza_set_name(status_stanza, STANZA_NAME_STATUS); - xmpp_stanza_t *text = xmpp_stanza_new(ctx); + xmpp_stanza_t* text = xmpp_stanza_new(ctx); xmpp_stanza_set_text(text, status); xmpp_stanza_add_child(status_stanza, text); xmpp_stanza_add_child(presence, status_stanza); @@ -2056,10 +2051,10 @@ stanza_attach_status(xmpp_ctx_t *const ctx, xmpp_stanza_t *const presence, } void -stanza_attach_last_activity(xmpp_ctx_t *const ctx, - xmpp_stanza_t *const presence, const int idle) +stanza_attach_last_activity(xmpp_ctx_t* const ctx, + xmpp_stanza_t* const presence, const int idle) { - xmpp_stanza_t *query = xmpp_stanza_new(ctx); + xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_ns(query, STANZA_NS_LASTACTIVITY); char idle_str[10]; @@ -2070,14 +2065,14 @@ stanza_attach_last_activity(xmpp_ctx_t *const ctx, } void -stanza_attach_caps(xmpp_ctx_t *const ctx, xmpp_stanza_t *const presence) +stanza_attach_caps(xmpp_ctx_t* const ctx, xmpp_stanza_t* const presence) { - xmpp_stanza_t *caps = xmpp_stanza_new(ctx); + xmpp_stanza_t* caps = xmpp_stanza_new(ctx); xmpp_stanza_set_name(caps, STANZA_NAME_C); xmpp_stanza_set_ns(caps, STANZA_NS_CAPS); - xmpp_stanza_t *query = stanza_create_caps_query_element(ctx); + xmpp_stanza_t* query = stanza_create_caps_query_element(ctx); - char *sha1 = caps_get_my_sha1(ctx); + char* sha1 = caps_get_my_sha1(ctx); xmpp_stanza_set_attribute(caps, STANZA_ATTR_HASH, "sha-1"); xmpp_stanza_set_attribute(caps, STANZA_ATTR_NODE, "http://profanity-im.github.io"); xmpp_stanza_set_attribute(caps, STANZA_ATTR_VER, sha1); @@ -2089,26 +2084,25 @@ stanza_attach_caps(xmpp_ctx_t *const ctx, xmpp_stanza_t *const presence) const char* stanza_get_presence_string_from_type(resource_presence_t presence_type) { - switch(presence_type) - { - case RESOURCE_AWAY: - return STANZA_TEXT_AWAY; - case RESOURCE_DND: - return STANZA_TEXT_DND; - case RESOURCE_CHAT: - return STANZA_TEXT_CHAT; - case RESOURCE_XA: - return STANZA_TEXT_XA; - default: - return NULL; + switch (presence_type) { + case RESOURCE_AWAY: + return STANZA_TEXT_AWAY; + case RESOURCE_DND: + return STANZA_TEXT_DND; + case RESOURCE_CHAT: + return STANZA_TEXT_CHAT; + case RESOURCE_XA: + return STANZA_TEXT_XA; + default: + return NULL; } } Resource* -stanza_resource_from_presence(XMPPPresence *presence) +stanza_resource_from_presence(XMPPPresence* presence) { // create Resource - Resource *resource = NULL; + Resource* resource = NULL; resource_presence_t resource_presence = resource_presence_from_string(presence->show); if (presence->jid->resourcepart == NULL) { // hack for servers that do not send full jid resource = resource_new("__prof_default", resource_presence, presence->status, presence->priority); @@ -2120,12 +2114,12 @@ stanza_resource_from_presence(XMPPPresence *presence) } char* -stanza_text_strdup(xmpp_stanza_t *stanza) +stanza_text_strdup(xmpp_stanza_t* stanza) { - xmpp_ctx_t *ctx = connection_get_ctx(); + xmpp_ctx_t* ctx = connection_get_ctx(); - char *string = NULL; - char *stanza_text = xmpp_stanza_get_text(stanza); + char* string = NULL; + char* stanza_text = xmpp_stanza_get_text(stanza); if (stanza_text) { string = strdup(stanza_text); xmpp_free(ctx, stanza_text); @@ -2135,7 +2129,7 @@ stanza_text_strdup(xmpp_stanza_t *stanza) } void -stanza_free_caps(XMPPCaps *caps) +stanza_free_caps(XMPPCaps* caps) { if (caps == NULL) { return; @@ -2154,7 +2148,7 @@ stanza_free_caps(XMPPCaps *caps) } void -stanza_free_presence(XMPPPresence *presence) +stanza_free_presence(XMPPPresence* presence) { if (presence == NULL) { return; @@ -2176,21 +2170,21 @@ stanza_free_presence(XMPPPresence *presence) } XMPPPresence* -stanza_parse_presence(xmpp_stanza_t *stanza, int *err) +stanza_parse_presence(xmpp_stanza_t* stanza, int* err) { - const char *from = xmpp_stanza_get_from(stanza); + const char* from = xmpp_stanza_get_from(stanza); if (!from) { *err = STANZA_PARSE_ERROR_NO_FROM; return NULL; } - Jid *from_jid = jid_create(from); + Jid* from_jid = jid_create(from); if (!from_jid) { *err = STANZA_PARSE_ERROR_INVALID_FROM; return NULL; } - XMPPPresence *result = (XMPPPresence *)malloc(sizeof(XMPPPresence)); + XMPPPresence* result = (XMPPPresence*)malloc(sizeof(XMPPPresence)); result->jid = from_jid; result->show = stanza_get_show(stanza, "online"); @@ -2198,7 +2192,7 @@ stanza_parse_presence(xmpp_stanza_t *stanza, int *err) int idle_seconds = stanza_get_idle_time(stanza); if (idle_seconds > 0) { - GDateTime *now = g_date_time_new_now_local(); + GDateTime* now = g_date_time_new_now_local(); result->last_activity = g_date_time_add_seconds(now, 0 - idle_seconds); g_date_time_unref(now); } else { @@ -2206,13 +2200,13 @@ stanza_parse_presence(xmpp_stanza_t *stanza, int *err) } result->priority = 0; - xmpp_stanza_t *priority_stanza = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_PRIORITY); + xmpp_stanza_t* priority_stanza = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_PRIORITY); if (priority_stanza) { - char *priority_str = xmpp_stanza_get_text(priority_stanza); + char* priority_str = xmpp_stanza_get_text(priority_stanza); if (priority_str) { result->priority = atoi(priority_str); } - xmpp_ctx_t *ctx = connection_get_ctx(); + xmpp_ctx_t* ctx = connection_get_ctx(); xmpp_free(ctx, priority_str); } @@ -2220,15 +2214,15 @@ stanza_parse_presence(xmpp_stanza_t *stanza, int *err) } xmpp_stanza_t* -stanza_create_command_exec_iq(xmpp_ctx_t *ctx, const char *const target, - const char *const node) +stanza_create_command_exec_iq(xmpp_ctx_t* ctx, const char* const target, + const char* const node) { - char *id = connection_create_stanza_id(); - xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); + char* id = connection_create_stanza_id(); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); free(id); xmpp_stanza_set_to(iq, target); - xmpp_stanza_t *command = xmpp_stanza_new(ctx); + xmpp_stanza_t* command = xmpp_stanza_new(ctx); xmpp_stanza_set_name(command, STANZA_NAME_COMMAND); xmpp_stanza_set_ns(command, STANZA_NS_COMMAND); @@ -2242,15 +2236,15 @@ stanza_create_command_exec_iq(xmpp_ctx_t *ctx, const char *const target, } xmpp_stanza_t* -stanza_create_command_config_submit_iq(xmpp_ctx_t *ctx, const char *const room, - const char *const node, const char *const sessionid, DataForm *form) +stanza_create_command_config_submit_iq(xmpp_ctx_t* ctx, const char* const room, + const char* const node, const char* const sessionid, DataForm* form) { - char *id = connection_create_stanza_id(); - xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); + char* id = connection_create_stanza_id(); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); free(id); xmpp_stanza_set_to(iq, room); - xmpp_stanza_t *command = xmpp_stanza_new(ctx); + xmpp_stanza_t* command = xmpp_stanza_new(ctx); xmpp_stanza_set_name(command, STANZA_NAME_COMMAND); xmpp_stanza_set_ns(command, STANZA_NS_COMMAND); xmpp_stanza_set_attribute(command, "node", node); @@ -2258,7 +2252,7 @@ stanza_create_command_config_submit_iq(xmpp_ctx_t *ctx, const char *const room, xmpp_stanza_set_attribute(command, "sessionid", sessionid); } - xmpp_stanza_t *x = form_create_submission(form); + xmpp_stanza_t* x = form_create_submission(form); xmpp_stanza_add_child(command, x); xmpp_stanza_release(x); @@ -2269,17 +2263,17 @@ stanza_create_command_config_submit_iq(xmpp_ctx_t *ctx, const char *const room, } xmpp_stanza_t* -stanza_create_omemo_devicelist_request(xmpp_ctx_t *ctx, const char *const id, - const char *const jid) +stanza_create_omemo_devicelist_request(xmpp_ctx_t* ctx, const char* const id, + const char* const jid) { - xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id); xmpp_stanza_set_to(iq, jid); - xmpp_stanza_t *pubsub = xmpp_stanza_new(ctx); + xmpp_stanza_t* pubsub = xmpp_stanza_new(ctx); xmpp_stanza_set_name(pubsub, STANZA_NAME_PUBSUB); xmpp_stanza_set_ns(pubsub, STANZA_NS_PUBSUB); - xmpp_stanza_t *items = xmpp_stanza_new(ctx); + xmpp_stanza_t* items = xmpp_stanza_new(ctx); xmpp_stanza_set_name(items, "items"); xmpp_stanza_set_attribute(items, STANZA_ATTR_NODE, STANZA_NS_OMEMO_DEVICELIST); @@ -2293,17 +2287,17 @@ stanza_create_omemo_devicelist_request(xmpp_ctx_t *ctx, const char *const id, } xmpp_stanza_t* -stanza_create_omemo_devicelist_subscribe(xmpp_ctx_t *ctx, const char *const jid) +stanza_create_omemo_devicelist_subscribe(xmpp_ctx_t* ctx, const char* const jid) { - char *id = connection_create_stanza_id(); - xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); + char* id = connection_create_stanza_id(); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); free(id); - xmpp_stanza_t *pubsub = xmpp_stanza_new(ctx); + xmpp_stanza_t* pubsub = xmpp_stanza_new(ctx); xmpp_stanza_set_name(pubsub, STANZA_NAME_PUBSUB); xmpp_stanza_set_ns(pubsub, STANZA_NS_PUBSUB); - xmpp_stanza_t *subscribe = xmpp_stanza_new(ctx); + xmpp_stanza_t* subscribe = xmpp_stanza_new(ctx); xmpp_stanza_set_name(subscribe, STANZA_NAME_SUBSCRIBE); xmpp_stanza_set_attribute(subscribe, STANZA_ATTR_NODE, STANZA_NS_OMEMO_DEVICELIST); xmpp_stanza_set_attribute(subscribe, "jid", jid); @@ -2318,33 +2312,33 @@ stanza_create_omemo_devicelist_subscribe(xmpp_ctx_t *ctx, const char *const jid) } xmpp_stanza_t* -stanza_create_omemo_devicelist_publish(xmpp_ctx_t *ctx, GList *const ids) +stanza_create_omemo_devicelist_publish(xmpp_ctx_t* ctx, GList* const ids) { - char *id = connection_create_stanza_id(); - xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); + char* id = connection_create_stanza_id(); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); free(id); - xmpp_stanza_t *pubsub = xmpp_stanza_new(ctx); + xmpp_stanza_t* pubsub = xmpp_stanza_new(ctx); xmpp_stanza_set_name(pubsub, STANZA_NAME_PUBSUB); xmpp_stanza_set_ns(pubsub, STANZA_NS_PUBSUB); - xmpp_stanza_t *publish = xmpp_stanza_new(ctx); + xmpp_stanza_t* publish = xmpp_stanza_new(ctx); xmpp_stanza_set_name(publish, STANZA_NAME_PUBLISH); xmpp_stanza_set_attribute(publish, STANZA_ATTR_NODE, STANZA_NS_OMEMO_DEVICELIST); - xmpp_stanza_t *item = xmpp_stanza_new(ctx); + xmpp_stanza_t* item = xmpp_stanza_new(ctx); xmpp_stanza_set_name(item, STANZA_NAME_ITEM); xmpp_stanza_set_attribute(item, "id", "current"); - xmpp_stanza_t *list = xmpp_stanza_new(ctx); + xmpp_stanza_t* list = xmpp_stanza_new(ctx); xmpp_stanza_set_name(list, "list"); xmpp_stanza_set_ns(list, "eu.siacs.conversations.axolotl"); - GList *i; + GList* i; for (i = ids; i != NULL; i = i->next) { - xmpp_stanza_t *device = xmpp_stanza_new(ctx); + xmpp_stanza_t* device = xmpp_stanza_new(ctx); xmpp_stanza_set_name(device, "device"); - char *id = g_strdup_printf("%d", GPOINTER_TO_INT(i->data)); + char* id = g_strdup_printf("%d", GPOINTER_TO_INT(i->data)); xmpp_stanza_set_attribute(device, "id", id); g_free(id); @@ -2366,77 +2360,77 @@ stanza_create_omemo_devicelist_publish(xmpp_ctx_t *ctx, GList *const ids) } xmpp_stanza_t* -stanza_create_omemo_bundle_publish(xmpp_ctx_t *ctx, const char *const id, - uint32_t device_id, - const unsigned char * const identity_key, size_t identity_key_length, - const unsigned char * const signed_prekey, size_t signed_prekey_length, - const unsigned char * const signed_prekey_signature, size_t signed_prekey_signature_length, - GList *const prekeys, GList *const prekeys_id, GList *const prekeys_length) +stanza_create_omemo_bundle_publish(xmpp_ctx_t* ctx, const char* const id, + uint32_t device_id, + const unsigned char* const identity_key, size_t identity_key_length, + const unsigned char* const signed_prekey, size_t signed_prekey_length, + const unsigned char* const signed_prekey_signature, size_t signed_prekey_signature_length, + GList* const prekeys, GList* const prekeys_id, GList* const prekeys_length) { - xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); - xmpp_stanza_t *pubsub = xmpp_stanza_new(ctx); + xmpp_stanza_t* pubsub = xmpp_stanza_new(ctx); xmpp_stanza_set_name(pubsub, STANZA_NAME_PUBSUB); xmpp_stanza_set_ns(pubsub, STANZA_NS_PUBSUB); - xmpp_stanza_t *publish = xmpp_stanza_new(ctx); + xmpp_stanza_t* publish = xmpp_stanza_new(ctx); xmpp_stanza_set_name(publish, STANZA_NAME_PUBLISH); - char *node = g_strdup_printf("%s:%d", "eu.siacs.conversations.axolotl.bundles", device_id); + char* node = g_strdup_printf("%s:%d", "eu.siacs.conversations.axolotl.bundles", device_id); xmpp_stanza_set_attribute(publish, STANZA_ATTR_NODE, node); g_free(node); - xmpp_stanza_t *item = xmpp_stanza_new(ctx); + xmpp_stanza_t* item = xmpp_stanza_new(ctx); xmpp_stanza_set_name(item, STANZA_NAME_ITEM); xmpp_stanza_set_attribute(item, "id", "current"); - xmpp_stanza_t *bundle = xmpp_stanza_new(ctx); + xmpp_stanza_t* bundle = xmpp_stanza_new(ctx); xmpp_stanza_set_name(bundle, "bundle"); xmpp_stanza_set_ns(bundle, "eu.siacs.conversations.axolotl"); - xmpp_stanza_t *signed_prekey_public_stanza = xmpp_stanza_new(ctx); - xmpp_stanza_set_name(signed_prekey_public_stanza , "signedPreKeyPublic"); + xmpp_stanza_t* signed_prekey_public_stanza = xmpp_stanza_new(ctx); + xmpp_stanza_set_name(signed_prekey_public_stanza, "signedPreKeyPublic"); xmpp_stanza_set_attribute(signed_prekey_public_stanza, "signedPreKeyId", "1"); - xmpp_stanza_t *signed_prekey_public_stanza_text= xmpp_stanza_new(ctx); - char *signed_prekey_b64 = g_base64_encode(signed_prekey, signed_prekey_length); + xmpp_stanza_t* signed_prekey_public_stanza_text = xmpp_stanza_new(ctx); + char* signed_prekey_b64 = g_base64_encode(signed_prekey, signed_prekey_length); xmpp_stanza_set_text(signed_prekey_public_stanza_text, signed_prekey_b64); g_free(signed_prekey_b64); xmpp_stanza_add_child(signed_prekey_public_stanza, signed_prekey_public_stanza_text); xmpp_stanza_release(signed_prekey_public_stanza_text); - xmpp_stanza_t *signed_prekey_signature_stanza = xmpp_stanza_new(ctx); - xmpp_stanza_set_name(signed_prekey_signature_stanza , "signedPreKeySignature"); + xmpp_stanza_t* signed_prekey_signature_stanza = xmpp_stanza_new(ctx); + xmpp_stanza_set_name(signed_prekey_signature_stanza, "signedPreKeySignature"); - xmpp_stanza_t *signed_prekey_signature_stanza_text= xmpp_stanza_new(ctx); - char *signed_prekey_signature_b64 = g_base64_encode(signed_prekey_signature, signed_prekey_signature_length); + xmpp_stanza_t* signed_prekey_signature_stanza_text = xmpp_stanza_new(ctx); + char* signed_prekey_signature_b64 = g_base64_encode(signed_prekey_signature, signed_prekey_signature_length); xmpp_stanza_set_text(signed_prekey_signature_stanza_text, signed_prekey_signature_b64); g_free(signed_prekey_signature_b64); xmpp_stanza_add_child(signed_prekey_signature_stanza, signed_prekey_signature_stanza_text); xmpp_stanza_release(signed_prekey_signature_stanza_text); - xmpp_stanza_t *identity_key_stanza = xmpp_stanza_new(ctx); - xmpp_stanza_set_name(identity_key_stanza , "identityKey"); + xmpp_stanza_t* identity_key_stanza = xmpp_stanza_new(ctx); + xmpp_stanza_set_name(identity_key_stanza, "identityKey"); - xmpp_stanza_t *identity_key_stanza_text= xmpp_stanza_new(ctx); - char *identity_key_b64 = g_base64_encode(identity_key, identity_key_length); + xmpp_stanza_t* identity_key_stanza_text = xmpp_stanza_new(ctx); + char* identity_key_b64 = g_base64_encode(identity_key, identity_key_length); xmpp_stanza_set_text(identity_key_stanza_text, identity_key_b64); g_free(identity_key_b64); xmpp_stanza_add_child(identity_key_stanza, identity_key_stanza_text); xmpp_stanza_release(identity_key_stanza_text); - xmpp_stanza_t *prekeys_stanza = xmpp_stanza_new(ctx); + xmpp_stanza_t* prekeys_stanza = xmpp_stanza_new(ctx); xmpp_stanza_set_name(prekeys_stanza, "prekeys"); GList *p, *i, *l; for (p = prekeys, i = prekeys_id, l = prekeys_length; p != NULL; p = p->next, i = i->next, l = l->next) { - xmpp_stanza_t *prekey = xmpp_stanza_new(ctx); + xmpp_stanza_t* prekey = xmpp_stanza_new(ctx); xmpp_stanza_set_name(prekey, "preKeyPublic"); - char *id = g_strdup_printf("%d", GPOINTER_TO_INT(i->data)); + char* id = g_strdup_printf("%d", GPOINTER_TO_INT(i->data)); xmpp_stanza_set_attribute(prekey, "preKeyId", id); g_free(id); - xmpp_stanza_t *prekey_text = xmpp_stanza_new(ctx); - char *prekey_b64 = g_base64_encode(p->data, GPOINTER_TO_INT(l->data)); + xmpp_stanza_t* prekey_text = xmpp_stanza_new(ctx); + char* prekey_b64 = g_base64_encode(p->data, GPOINTER_TO_INT(l->data)); xmpp_stanza_set_text(prekey_text, prekey_b64); g_free(prekey_b64); @@ -2468,18 +2462,18 @@ stanza_create_omemo_bundle_publish(xmpp_ctx_t *ctx, const char *const id, } xmpp_stanza_t* -stanza_create_omemo_bundle_request(xmpp_ctx_t *ctx, const char *const id, const char *const jid, uint32_t device_id) +stanza_create_omemo_bundle_request(xmpp_ctx_t* ctx, const char* const id, const char* const jid, uint32_t device_id) { - xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id); xmpp_stanza_set_to(iq, jid); - xmpp_stanza_t *pubsub = xmpp_stanza_new(ctx); + xmpp_stanza_t* pubsub = xmpp_stanza_new(ctx); xmpp_stanza_set_name(pubsub, STANZA_NAME_PUBSUB); xmpp_stanza_set_ns(pubsub, STANZA_NS_PUBSUB); - xmpp_stanza_t *items = xmpp_stanza_new(ctx); + xmpp_stanza_t* items = xmpp_stanza_new(ctx); xmpp_stanza_set_name(items, "items"); - char *node = g_strdup_printf("%s:%d", STANZA_NS_OMEMO_BUNDLES, device_id); + char* node = g_strdup_printf("%s:%d", STANZA_NS_OMEMO_BUNDLES, device_id); xmpp_stanza_set_attribute(items, STANZA_ATTR_NODE, node); g_free(node); @@ -2493,16 +2487,16 @@ stanza_create_omemo_bundle_request(xmpp_ctx_t *ctx, const char *const id, const } xmpp_stanza_t* -stanza_create_pubsub_configure_request(xmpp_ctx_t *ctx, const char *const id, const char *const jid, const char *const node) +stanza_create_pubsub_configure_request(xmpp_ctx_t* ctx, const char* const id, const char* const jid, const char* const node) { - xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id); xmpp_stanza_set_to(iq, jid); - xmpp_stanza_t *pubsub = xmpp_stanza_new(ctx); + xmpp_stanza_t* pubsub = xmpp_stanza_new(ctx); xmpp_stanza_set_name(pubsub, STANZA_NAME_PUBSUB); xmpp_stanza_set_ns(pubsub, STANZA_NS_PUBSUB_OWNER); - xmpp_stanza_t *configure = xmpp_stanza_new(ctx); + xmpp_stanza_t* configure = xmpp_stanza_new(ctx); xmpp_stanza_set_name(configure, STANZA_NAME_CONFIGURE); xmpp_stanza_set_attribute(configure, STANZA_ATTR_NODE, node); @@ -2516,20 +2510,20 @@ stanza_create_pubsub_configure_request(xmpp_ctx_t *ctx, const char *const id, co } xmpp_stanza_t* -stanza_create_pubsub_configure_submit(xmpp_ctx_t *ctx, const char *const id, const char *const jid, const char *const node, DataForm *form) +stanza_create_pubsub_configure_submit(xmpp_ctx_t* ctx, const char* const id, const char* const jid, const char* const node, DataForm* form) { - xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); xmpp_stanza_set_to(iq, jid); - xmpp_stanza_t *pubsub = xmpp_stanza_new(ctx); + xmpp_stanza_t* pubsub = xmpp_stanza_new(ctx); xmpp_stanza_set_name(pubsub, STANZA_NAME_PUBSUB); xmpp_stanza_set_ns(pubsub, STANZA_NS_PUBSUB_OWNER); - xmpp_stanza_t *configure = xmpp_stanza_new(ctx); + xmpp_stanza_t* configure = xmpp_stanza_new(ctx); xmpp_stanza_set_name(configure, STANZA_NAME_CONFIGURE); xmpp_stanza_set_attribute(configure, STANZA_ATTR_NODE, node); - xmpp_stanza_t *x = form_create_submission(form); + xmpp_stanza_t* x = form_create_submission(form); xmpp_stanza_add_child(configure, x); xmpp_stanza_add_child(pubsub, configure); @@ -2543,9 +2537,9 @@ stanza_create_pubsub_configure_submit(xmpp_ctx_t *ctx, const char *const id, con } xmpp_stanza_t* -stanza_attach_origin_id(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza, const char *const id) +stanza_attach_origin_id(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza, const char* const id) { - xmpp_stanza_t *origin_id = xmpp_stanza_new(ctx); + xmpp_stanza_t* origin_id = xmpp_stanza_new(ctx); xmpp_stanza_set_name(origin_id, STANZA_NAME_ORIGIN_ID); xmpp_stanza_set_ns(origin_id, STANZA_NS_STABLE_ID); xmpp_stanza_set_attribute(origin_id, STANZA_ATTR_ID, id); @@ -2558,34 +2552,34 @@ stanza_attach_origin_id(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza, const char *cons } static void -_stanza_add_unique_id(xmpp_stanza_t *stanza) +_stanza_add_unique_id(xmpp_stanza_t* stanza) { - char *id = connection_create_stanza_id(); + char* id = connection_create_stanza_id(); xmpp_stanza_set_id(stanza, id); free(id); } static char* -_stanza_create_sha1_hash(char *str) +_stanza_create_sha1_hash(char* str) { - unsigned char *digest = (unsigned char*)malloc(XMPP_SHA1_DIGEST_SIZE); - assert(digest != NULL); + unsigned char* digest = (unsigned char*)malloc(XMPP_SHA1_DIGEST_SIZE); + assert(digest != NULL); - xmpp_sha1_digest((unsigned char*)str, strlen(str), digest); + xmpp_sha1_digest((unsigned char*)str, strlen(str), digest); - char *b64 = g_base64_encode(digest, XMPP_SHA1_DIGEST_SIZE); - assert(b64 != NULL); - free(digest); + char* b64 = g_base64_encode(digest, XMPP_SHA1_DIGEST_SIZE); + assert(b64 != NULL); + free(digest); - return b64; + return b64; } xmpp_stanza_t* -stanza_get_child_by_name_and_ns(xmpp_stanza_t * const stanza, const char * const name, const char * const ns) +stanza_get_child_by_name_and_ns(xmpp_stanza_t* const stanza, const char* const name, const char* const ns) { - xmpp_stanza_t *child; - const char *child_ns; - const char *child_name; + xmpp_stanza_t* child; + const char* child_ns; + const char* child_name; for (child = xmpp_stanza_get_children(stanza); child; child = xmpp_stanza_get_next(child)) { child_name = xmpp_stanza_get_name(child); @@ -2601,22 +2595,22 @@ stanza_get_child_by_name_and_ns(xmpp_stanza_t * const stanza, const char * const } xmpp_stanza_t* -stanza_create_avatar_retrieve_data_request(xmpp_ctx_t *ctx, const char *stanza_id, const char *const item_id, const char *const jid) +stanza_create_avatar_retrieve_data_request(xmpp_ctx_t* ctx, const char* stanza_id, const char* const item_id, const char* const jid) { - xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, stanza_id); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, stanza_id); xmpp_stanza_set_to(iq, jid); - xmpp_stanza_t *pubsub = xmpp_stanza_new(ctx); + xmpp_stanza_t* pubsub = xmpp_stanza_new(ctx); xmpp_stanza_set_name(pubsub, STANZA_NAME_PUBSUB); xmpp_stanza_set_ns(pubsub, STANZA_NS_PUBSUB); - xmpp_stanza_t *items = xmpp_stanza_new(ctx); + xmpp_stanza_t* items = xmpp_stanza_new(ctx); xmpp_stanza_set_name(items, "items"); - char *node = g_strdup_printf("%s", STANZA_NS_USER_AVATAR_DATA); + char* node = g_strdup_printf("%s", STANZA_NS_USER_AVATAR_DATA); xmpp_stanza_set_attribute(items, STANZA_ATTR_NODE, node); g_free(node); - xmpp_stanza_t *item = xmpp_stanza_new(ctx); + xmpp_stanza_t* item = xmpp_stanza_new(ctx); xmpp_stanza_set_name(item, STANZA_NAME_ITEM); xmpp_stanza_set_attribute(item, "id", item_id); @@ -2632,9 +2626,9 @@ stanza_create_avatar_retrieve_data_request(xmpp_ctx_t *ctx, const char *stanza_i } xmpp_stanza_t* -stanza_attach_correction(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza, const char *const replace_id) +stanza_attach_correction(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza, const char* const replace_id) { - xmpp_stanza_t *replace_stanza = xmpp_stanza_new(ctx); + xmpp_stanza_t* replace_stanza = xmpp_stanza_new(ctx); xmpp_stanza_set_name(replace_stanza, "replace"); xmpp_stanza_set_id(replace_stanza, replace_id); xmpp_stanza_set_ns(replace_stanza, STANZA_NS_LAST_MESSAGE_CORRECTION); @@ -2645,60 +2639,60 @@ stanza_attach_correction(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza, const char *con } xmpp_stanza_t* -stanza_create_mam_iq(xmpp_ctx_t *ctx, const char *const jid, const char *const startdate) +stanza_create_mam_iq(xmpp_ctx_t* ctx, const char* const jid, const char* const startdate) { - char *id = connection_create_stanza_id(); - xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); + char* id = connection_create_stanza_id(); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); free(id); //xmpp_stanza_set_to(iq, jid); - xmpp_stanza_t *query = xmpp_stanza_new(ctx); + xmpp_stanza_t* query = xmpp_stanza_new(ctx); xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_ns(query, STANZA_NS_MAM2); - xmpp_stanza_t *x = xmpp_stanza_new(ctx); + xmpp_stanza_t* x = xmpp_stanza_new(ctx); xmpp_stanza_set_name(x, STANZA_NAME_X); xmpp_stanza_set_ns(x, STANZA_NS_DATA); xmpp_stanza_set_type(x, "submit"); // field FORM_TYPE MAM2 - xmpp_stanza_t *field_form_type = xmpp_stanza_new(ctx); + xmpp_stanza_t* field_form_type = xmpp_stanza_new(ctx); xmpp_stanza_set_name(field_form_type, STANZA_NAME_FIELD); xmpp_stanza_set_attribute(field_form_type, STANZA_ATTR_VAR, "FORM_TYPE"); xmpp_stanza_set_type(field_form_type, "hidden"); - xmpp_stanza_t *value_mam = xmpp_stanza_new(ctx); + xmpp_stanza_t* value_mam = xmpp_stanza_new(ctx); xmpp_stanza_set_name(value_mam, STANZA_NAME_VALUE); - xmpp_stanza_t *mam_text = xmpp_stanza_new(ctx); + xmpp_stanza_t* mam_text = xmpp_stanza_new(ctx); xmpp_stanza_set_text(mam_text, STANZA_NS_MAM2); xmpp_stanza_add_child(value_mam, mam_text); xmpp_stanza_add_child(field_form_type, value_mam); // field 'with' - xmpp_stanza_t *field_with = xmpp_stanza_new(ctx); + xmpp_stanza_t* field_with = xmpp_stanza_new(ctx); xmpp_stanza_set_name(field_with, STANZA_NAME_FIELD); xmpp_stanza_set_attribute(field_with, STANZA_ATTR_VAR, "with"); - xmpp_stanza_t *value_with = xmpp_stanza_new(ctx); + xmpp_stanza_t* value_with = xmpp_stanza_new(ctx); xmpp_stanza_set_name(value_with, STANZA_NAME_VALUE); - xmpp_stanza_t *with_text = xmpp_stanza_new(ctx); + xmpp_stanza_t* with_text = xmpp_stanza_new(ctx); xmpp_stanza_set_text(with_text, jid); xmpp_stanza_add_child(value_with, with_text); xmpp_stanza_add_child(field_with, value_with); // field 'start' - xmpp_stanza_t *field_start = xmpp_stanza_new(ctx); + xmpp_stanza_t* field_start = xmpp_stanza_new(ctx); xmpp_stanza_set_name(field_start, STANZA_NAME_FIELD); xmpp_stanza_set_attribute(field_start, STANZA_ATTR_VAR, "start"); - xmpp_stanza_t *value_start = xmpp_stanza_new(ctx); + xmpp_stanza_t* value_start = xmpp_stanza_new(ctx); xmpp_stanza_set_name(value_start, STANZA_NAME_VALUE); - xmpp_stanza_t *date_text = xmpp_stanza_new(ctx); + xmpp_stanza_t* date_text = xmpp_stanza_new(ctx); xmpp_stanza_set_text(date_text, startdate); xmpp_stanza_add_child(value_start, date_text); diff --git a/src/xmpp/stanza.h b/src/xmpp/stanza.h index 5910a7d9..a51ee3c6 100644 --- a/src/xmpp/stanza.h +++ b/src/xmpp/stanza.h @@ -48,192 +48,193 @@ #include <xmpp/xmpp.h> -#define STANZA_NAME_ACTIVE "active" -#define STANZA_NAME_INACTIVE "inactive" +#define STANZA_NAME_ACTIVE "active" +#define STANZA_NAME_INACTIVE "inactive" #define STANZA_NAME_COMPOSING "composing" -#define STANZA_NAME_PAUSED "paused" -#define STANZA_NAME_GONE "gone" +#define STANZA_NAME_PAUSED "paused" +#define STANZA_NAME_GONE "gone" -#define STANZA_NAME_MESSAGE "message" -#define STANZA_NAME_BODY "body" -#define STANZA_NAME_BLOCK "block" -#define STANZA_NAME_UNBLOCK "unblock" +#define STANZA_NAME_MESSAGE "message" +#define STANZA_NAME_BODY "body" +#define STANZA_NAME_BLOCK "block" +#define STANZA_NAME_UNBLOCK "unblock" #define STANZA_NAME_BLOCKLIST "blocklist" -#define STANZA_NAME_PRESENCE "presence" -#define STANZA_NAME_PRIORITY "priority" -#define STANZA_NAME_X "x" +#define STANZA_NAME_PRESENCE "presence" +#define STANZA_NAME_PRIORITY "priority" +#define STANZA_NAME_X "x" // XEP-0373: OpenPGP for XMPP -#define STANZA_NAME_OPENPGP "openpgp" -#define STANZA_NAME_PUPKEY "pubkey" +#define STANZA_NAME_OPENPGP "openpgp" +#define STANZA_NAME_PUPKEY "pubkey" #define STANZA_NAME_PUBLIC_KEYS_LIST "public-keys-list" -#define STANZA_NAME_PUBKEY_METADATA "pubkey-metadata" -#define STANZA_NAME_DATA "data" -#define STANZA_NAME_SHOW "show" -#define STANZA_NAME_STATUS "status" -#define STANZA_NAME_IQ "iq" -#define STANZA_NAME_QUERY "query" -#define STANZA_NAME_REQUEST "request" -#define STANZA_NAME_DELAY "delay" -#define STANZA_NAME_ERROR "error" -#define STANZA_NAME_PING "ping" -#define STANZA_NAME_TEXT "text" -#define STANZA_NAME_SUBJECT "subject" -#define STANZA_NAME_ITEM "item" -#define STANZA_NAME_ITEMS "items" -#define STANZA_NAME_C "c" -#define STANZA_NAME_IDENTITY "identity" -#define STANZA_NAME_FEATURE "feature" -#define STANZA_NAME_INVITE "invite" -#define STANZA_NAME_REASON "reason" -#define STANZA_NAME_GROUP "group" -#define STANZA_NAME_PUBSUB "pubsub" -#define STANZA_NAME_PUBLISH "publish" -#define STANZA_NAME_PUBLISH_OPTIONS "publish-options" -#define STANZA_NAME_SUBSCRIBE "subscribe" -#define STANZA_NAME_FIELD "field" -#define STANZA_NAME_STORAGE "storage" -#define STANZA_NAME_NICK "nick" -#define STANZA_NAME_PASSWORD "password" -#define STANZA_NAME_CONFERENCE "conference" -#define STANZA_NAME_VALUE "value" -#define STANZA_NAME_DESTROY "destroy" -#define STANZA_NAME_ACTOR "actor" -#define STANZA_NAME_ENABLE "enable" -#define STANZA_NAME_DISABLE "disable" -#define STANZA_NAME_FILENAME "filename" -#define STANZA_NAME_SIZE "size" -#define STANZA_NAME_CONTENT_TYPE "content-type" -#define STANZA_NAME_SLOT "slot" -#define STANZA_NAME_PUT "put" -#define STANZA_NAME_GET "get" -#define STANZA_NAME_URL "url" -#define STANZA_NAME_COMMAND "command" -#define STANZA_NAME_CONFIGURE "configure" -#define STANZA_NAME_ORIGIN_ID "origin-id" -#define STANZA_NAME_MINIMIZE "minimize" +#define STANZA_NAME_PUBKEY_METADATA "pubkey-metadata" +#define STANZA_NAME_DATA "data" +#define STANZA_NAME_SHOW "show" +#define STANZA_NAME_STATUS "status" +#define STANZA_NAME_IQ "iq" +#define STANZA_NAME_QUERY "query" +#define STANZA_NAME_REQUEST "request" +#define STANZA_NAME_DELAY "delay" +#define STANZA_NAME_ERROR "error" +#define STANZA_NAME_PING "ping" +#define STANZA_NAME_TEXT "text" +#define STANZA_NAME_SUBJECT "subject" +#define STANZA_NAME_ITEM "item" +#define STANZA_NAME_ITEMS "items" +#define STANZA_NAME_C "c" +#define STANZA_NAME_IDENTITY "identity" +#define STANZA_NAME_FEATURE "feature" +#define STANZA_NAME_INVITE "invite" +#define STANZA_NAME_REASON "reason" +#define STANZA_NAME_GROUP "group" +#define STANZA_NAME_PUBSUB "pubsub" +#define STANZA_NAME_PUBLISH "publish" +#define STANZA_NAME_PUBLISH_OPTIONS "publish-options" +#define STANZA_NAME_SUBSCRIBE "subscribe" +#define STANZA_NAME_FIELD "field" +#define STANZA_NAME_STORAGE "storage" +#define STANZA_NAME_NICK "nick" +#define STANZA_NAME_PASSWORD "password" +#define STANZA_NAME_CONFERENCE "conference" +#define STANZA_NAME_VALUE "value" +#define STANZA_NAME_DESTROY "destroy" +#define STANZA_NAME_ACTOR "actor" +#define STANZA_NAME_ENABLE "enable" +#define STANZA_NAME_DISABLE "disable" +#define STANZA_NAME_FILENAME "filename" +#define STANZA_NAME_SIZE "size" +#define STANZA_NAME_CONTENT_TYPE "content-type" +#define STANZA_NAME_SLOT "slot" +#define STANZA_NAME_PUT "put" +#define STANZA_NAME_GET "get" +#define STANZA_NAME_URL "url" +#define STANZA_NAME_COMMAND "command" +#define STANZA_NAME_CONFIGURE "configure" +#define STANZA_NAME_ORIGIN_ID "origin-id" +#define STANZA_NAME_MINIMIZE "minimize" // error conditions -#define STANZA_NAME_BAD_REQUEST "bad-request" -#define STANZA_NAME_CONFLICT "conflict" +#define STANZA_NAME_BAD_REQUEST "bad-request" +#define STANZA_NAME_CONFLICT "conflict" #define STANZA_NAME_FEATURE_NOT_IMPLEMENTED "feature-not-implemented" -#define STANZA_NAME_FORBIDDEN "forbidden" -#define STANZA_NAME_GONE "gone" -#define STANZA_NAME_INTERNAL_SERVER_ERROR "internal-server-error" -#define STANZA_NAME_ITEM_NOT_FOUND "item-not-found" -#define STANZA_NAME_JID_MALFORMED "jid-malformed" -#define STANZA_NAME_NOT_ACCEPTABLE "not-acceptable" -#define STANZA_NAME_NOT_ALLOWED "not-allowed" -#define STANZA_NAME_NOT_AUTHORISED "not-authorised" -#define STANZA_NAME_POLICY_VIOLATION "policy-violation" -#define STANZA_NAME_RECIPIENT_UNAVAILABLE "recipient-unavailable" -#define STANZA_NAME_REDIRECT "redirect" -#define STANZA_NAME_REGISTRATION_REQUIRED "registration-required" +#define STANZA_NAME_FORBIDDEN "forbidden" +#define STANZA_NAME_GONE "gone" +#define STANZA_NAME_INTERNAL_SERVER_ERROR "internal-server-error" +#define STANZA_NAME_ITEM_NOT_FOUND "item-not-found" +#define STANZA_NAME_JID_MALFORMED "jid-malformed" +#define STANZA_NAME_NOT_ACCEPTABLE "not-acceptable" +#define STANZA_NAME_NOT_ALLOWED "not-allowed" +#define STANZA_NAME_NOT_AUTHORISED "not-authorised" +#define STANZA_NAME_POLICY_VIOLATION "policy-violation" +#define STANZA_NAME_RECIPIENT_UNAVAILABLE "recipient-unavailable" +#define STANZA_NAME_REDIRECT "redirect" +#define STANZA_NAME_REGISTRATION_REQUIRED "registration-required" #define STANZA_NAME_REMOTE_SERVER_NOT_FOUND "remote-server-not-found" -#define STANZA_NAME_REMOTE_SERVER_TIMEOUT "remote-server-timeout" -#define STANZA_NAME_RESOURCE_CONSTRAINT "resource-constraint" -#define STANZA_NAME_SERVICE_UNAVAILABLE "service-unavailable" -#define STANZA_NAME_SUBSCRIPTION_REQUIRED "subscription-required" -#define STANZA_NAME_UNDEFINED_CONDITION "undefined-condition" -#define STANZA_NAME_UNEXPECTED_REQUEST "unexpected-request" - -#define STANZA_TYPE_CHAT "chat" -#define STANZA_TYPE_GROUPCHAT "groupchat" -#define STANZA_TYPE_HEADLINE "headline" -#define STANZA_TYPE_NORMAL "normal" -#define STANZA_TYPE_UNAVAILABLE "unavailable" -#define STANZA_TYPE_SUBSCRIBE "subscribe" -#define STANZA_TYPE_SUBSCRIBED "subscribed" +#define STANZA_NAME_REMOTE_SERVER_TIMEOUT "remote-server-timeout" +#define STANZA_NAME_RESOURCE_CONSTRAINT "resource-constraint" +#define STANZA_NAME_SERVICE_UNAVAILABLE "service-unavailable" +#define STANZA_NAME_SUBSCRIPTION_REQUIRED "subscription-required" +#define STANZA_NAME_UNDEFINED_CONDITION "undefined-condition" +#define STANZA_NAME_UNEXPECTED_REQUEST "unexpected-request" + +#define STANZA_TYPE_CHAT "chat" +#define STANZA_TYPE_GROUPCHAT "groupchat" +#define STANZA_TYPE_HEADLINE "headline" +#define STANZA_TYPE_NORMAL "normal" +#define STANZA_TYPE_UNAVAILABLE "unavailable" +#define STANZA_TYPE_SUBSCRIBE "subscribe" +#define STANZA_TYPE_SUBSCRIBED "subscribed" #define STANZA_TYPE_UNSUBSCRIBED "unsubscribed" -#define STANZA_TYPE_GET "get" -#define STANZA_TYPE_SET "set" -#define STANZA_TYPE_ERROR "error" -#define STANZA_TYPE_RESULT "result" - -#define STANZA_ATTR_TO "to" -#define STANZA_ATTR_FROM "from" -#define STANZA_ATTR_STAMP "stamp" -#define STANZA_ATTR_TYPE "type" -#define STANZA_ATTR_CODE "code" -#define STANZA_ATTR_JID "jid" -#define STANZA_ATTR_NAME "name" -#define STANZA_ATTR_SUBSCRIPTION "subscription" -#define STANZA_ATTR_XMLNS "xmlns" -#define STANZA_ATTR_NICK "nick" -#define STANZA_ATTR_ASK "ask" -#define STANZA_ATTR_ID "id" -#define STANZA_ATTR_SECONDS "seconds" -#define STANZA_ATTR_NODE "node" -#define STANZA_ATTR_VER "ver" -#define STANZA_ATTR_VAR "var" -#define STANZA_ATTR_HASH "hash" -#define STANZA_ATTR_CATEGORY "category" -#define STANZA_ATTR_REASON "reason" -#define STANZA_ATTR_AUTOJOIN "autojoin" -#define STANZA_ATTR_PASSWORD "password" -#define STANZA_ATTR_STATUS "status" -#define STANZA_ATTR_DATE "date" +#define STANZA_TYPE_GET "get" +#define STANZA_TYPE_SET "set" +#define STANZA_TYPE_ERROR "error" +#define STANZA_TYPE_RESULT "result" + +#define STANZA_ATTR_TO "to" +#define STANZA_ATTR_FROM "from" +#define STANZA_ATTR_STAMP "stamp" +#define STANZA_ATTR_TYPE "type" +#define STANZA_ATTR_CODE "code" +#define STANZA_ATTR_JID "jid" +#define STANZA_ATTR_NAME "name" +#define STANZA_ATTR_SUBSCRIPTION "subscription" +#define STANZA_ATTR_XMLNS "xmlns" +#define STANZA_ATTR_NICK "nick" +#define STANZA_ATTR_ASK "ask" +#define STANZA_ATTR_ID "id" +#define STANZA_ATTR_SECONDS "seconds" +#define STANZA_ATTR_NODE "node" +#define STANZA_ATTR_VER "ver" +#define STANZA_ATTR_VAR "var" +#define STANZA_ATTR_HASH "hash" +#define STANZA_ATTR_CATEGORY "category" +#define STANZA_ATTR_REASON "reason" +#define STANZA_ATTR_AUTOJOIN "autojoin" +#define STANZA_ATTR_PASSWORD "password" +#define STANZA_ATTR_STATUS "status" +#define STANZA_ATTR_DATE "date" #define STANZA_ATTR_V4_FINGERPRINT "v4-fingerprint" - -#define STANZA_TEXT_AWAY "away" -#define STANZA_TEXT_DND "dnd" -#define STANZA_TEXT_CHAT "chat" -#define STANZA_TEXT_XA "xa" +#define STANZA_TEXT_AWAY "away" +#define STANZA_TEXT_DND "dnd" +#define STANZA_TEXT_CHAT "chat" +#define STANZA_TEXT_XA "xa" #define STANZA_TEXT_ONLINE "online" -#define STANZA_NS_STANZAS "urn:ietf:params:xml:ns:xmpp-stanzas" -#define STANZA_NS_CHATSTATES "http://jabber.org/protocol/chatstates" -#define STANZA_NS_MUC "http://jabber.org/protocol/muc" -#define STANZA_NS_MUC_USER "http://jabber.org/protocol/muc#user" -#define STANZA_NS_MUC_OWNER "http://jabber.org/protocol/muc#owner" -#define STANZA_NS_MUC_ADMIN "http://jabber.org/protocol/muc#admin" -#define STANZA_NS_CAPS "http://jabber.org/protocol/caps" -#define STANZA_NS_PING "urn:xmpp:ping" +#define STANZA_NS_STANZAS "urn:ietf:params:xml:ns:xmpp-stanzas" +#define STANZA_NS_CHATSTATES "http://jabber.org/protocol/chatstates" +#define STANZA_NS_MUC "http://jabber.org/protocol/muc" +#define STANZA_NS_MUC_USER "http://jabber.org/protocol/muc#user" +#define STANZA_NS_MUC_OWNER "http://jabber.org/protocol/muc#owner" +#define STANZA_NS_MUC_ADMIN "http://jabber.org/protocol/muc#admin" +#define STANZA_NS_CAPS "http://jabber.org/protocol/caps" +#define STANZA_NS_PING "urn:xmpp:ping" #define STANZA_NS_LASTACTIVITY "jabber:iq:last" -#define STANZA_NS_DATA "jabber:x:data" -#define STANZA_NS_VERSION "jabber:iq:version" -#define STANZA_NS_CONFERENCE "jabber:x:conference" -#define STANZA_NS_CAPTCHA "urn:xmpp:captcha" -#define STANZA_NS_PUBSUB "http://jabber.org/protocol/pubsub" +#define STANZA_NS_DATA "jabber:x:data" +#define STANZA_NS_VERSION "jabber:iq:version" +#define STANZA_NS_CONFERENCE "jabber:x:conference" +#define STANZA_NS_CAPTCHA "urn:xmpp:captcha" +#define STANZA_NS_PUBSUB "http://jabber.org/protocol/pubsub" #define STANZA_NS_PUBSUB_OWNER "http://jabber.org/protocol/pubsub#owner" #define STANZA_NS_PUBSUB_EVENT "http://jabber.org/protocol/pubsub#event" -#define STANZA_NS_CARBONS "urn:xmpp:carbons:2" -#define STANZA_NS_HINTS "urn:xmpp:hints" -#define STANZA_NS_FORWARD "urn:xmpp:forward:0" -#define STANZA_NS_RECEIPTS "urn:xmpp:receipts" -#define STANZA_NS_SIGNED "jabber:x:signed" -#define STANZA_NS_ENCRYPTED "jabber:x:encrypted" +#define STANZA_NS_CARBONS "urn:xmpp:carbons:2" +#define STANZA_NS_HINTS "urn:xmpp:hints" +#define STANZA_NS_FORWARD "urn:xmpp:forward:0" +#define STANZA_NS_RECEIPTS "urn:xmpp:receipts" +#define STANZA_NS_SIGNED "jabber:x:signed" +#define STANZA_NS_ENCRYPTED "jabber:x:encrypted" // XEP-0373: OpenPGP for XMPP -#define STANZA_NS_OPENPGP_0 "urn:xmpp:openpgp:0" -#define STANZA_NS_OPENPGP_0_PUBLIC_KEYS "urn:xmpp:openpgp:0:public-keys" -#define STANZA_NS_HTTP_UPLOAD "urn:xmpp:http:upload" -#define STANZA_NS_X_OOB "jabber:x:oob" -#define STANZA_NS_BLOCKING "urn:xmpp:blocking" -#define STANZA_NS_COMMAND "http://jabber.org/protocol/commands" -#define STANZA_NS_OMEMO "eu.siacs.conversations.axolotl" -#define STANZA_NS_OMEMO_DEVICELIST "eu.siacs.conversations.axolotl.devicelist" -#define STANZA_NS_OMEMO_BUNDLES "eu.siacs.conversations.axolotl.bundles" -#define STANZA_NS_STABLE_ID "urn:xmpp:sid:0" -#define STANZA_NS_USER_AVATAR_DATA "urn:xmpp:avatar:data" -#define STANZA_NS_USER_AVATAR_METADATA "urn:xmpp:avatar:metadata" +#define STANZA_NS_OPENPGP_0 "urn:xmpp:openpgp:0" +#define STANZA_NS_OPENPGP_0_PUBLIC_KEYS "urn:xmpp:openpgp:0:public-keys" +#define STANZA_NS_HTTP_UPLOAD "urn:xmpp:http:upload" +#define STANZA_NS_X_OOB "jabber:x:oob" +#define STANZA_NS_BLOCKING "urn:xmpp:blocking" +#define STANZA_NS_COMMAND "http://jabber.org/protocol/commands" +#define STANZA_NS_OMEMO "eu.siacs.conversations.axolotl" +#define STANZA_NS_OMEMO_DEVICELIST "eu.siacs.conversations.axolotl.devicelist" +#define STANZA_NS_OMEMO_BUNDLES "eu.siacs.conversations.axolotl.bundles" +#define STANZA_NS_STABLE_ID "urn:xmpp:sid:0" +#define STANZA_NS_USER_AVATAR_DATA "urn:xmpp:avatar:data" +#define STANZA_NS_USER_AVATAR_METADATA "urn:xmpp:avatar:metadata" #define STANZA_NS_LAST_MESSAGE_CORRECTION "urn:xmpp:message-correct:0" -#define STANZA_NS_MAM2 "urn:xmpp:mam:2" -#define STANZA_NS_EXT_GAJIM_BOOKMARKS "xmpp:gajim.org/bookmarks" +#define STANZA_NS_MAM2 "urn:xmpp:mam:2" +#define STANZA_NS_EXT_GAJIM_BOOKMARKS "xmpp:gajim.org/bookmarks" #define STANZA_DATAFORM_SOFTWARE "urn:xmpp:dataforms:softwareinfo" -typedef struct caps_stanza_t { - char *hash; - char *node; - char *ver; +typedef struct caps_stanza_t +{ + char* hash; + char* node; + char* ver; } XMPPCaps; -typedef struct presence_stanza_t { - Jid *jid; - char *show; - char *status; +typedef struct presence_stanza_t +{ + Jid* jid; + char* show; + char* status; int priority; - GDateTime *last_activity; + GDateTime* last_activity; } XMPPPresence; typedef enum { @@ -241,141 +242,141 @@ typedef enum { STANZA_PARSE_ERROR_INVALID_FROM } stanza_parse_error_t; -xmpp_stanza_t* stanza_create_bookmarks_storage_request(xmpp_ctx_t *ctx); +xmpp_stanza_t* stanza_create_bookmarks_storage_request(xmpp_ctx_t* ctx); -xmpp_stanza_t* stanza_create_blocked_list_request(xmpp_ctx_t *ctx); +xmpp_stanza_t* stanza_create_blocked_list_request(xmpp_ctx_t* ctx); -xmpp_stanza_t* stanza_create_http_upload_request(xmpp_ctx_t *ctx, const char *const id, const char *const jid, HTTPUpload *upload); +xmpp_stanza_t* stanza_create_http_upload_request(xmpp_ctx_t* ctx, const char* const id, const char* const jid, HTTPUpload* upload); -xmpp_stanza_t* stanza_enable_carbons(xmpp_ctx_t *ctx); +xmpp_stanza_t* stanza_enable_carbons(xmpp_ctx_t* ctx); -xmpp_stanza_t* stanza_disable_carbons(xmpp_ctx_t *ctx); +xmpp_stanza_t* stanza_disable_carbons(xmpp_ctx_t* ctx); -xmpp_stanza_t* stanza_create_chat_state(xmpp_ctx_t *ctx, - const char *const fulljid, const char *const state); +xmpp_stanza_t* stanza_create_chat_state(xmpp_ctx_t* ctx, + const char* const fulljid, const char* const state); -xmpp_stanza_t* stanza_attach_state(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza, const char *const state); -xmpp_stanza_t* stanza_attach_carbons_private(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza); -xmpp_stanza_t* stanza_attach_hints_no_copy(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza); -xmpp_stanza_t* stanza_attach_hints_no_store(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza); -xmpp_stanza_t* stanza_attach_hints_store(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza); -xmpp_stanza_t* stanza_attach_receipt_request(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza); -xmpp_stanza_t* stanza_attach_x_oob_url(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza, const char *const url); -xmpp_stanza_t* stanza_attach_origin_id(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza, const char *const id); -xmpp_stanza_t* stanza_attach_correction(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza, const char *const replace_id); +xmpp_stanza_t* stanza_attach_state(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza, const char* const state); +xmpp_stanza_t* stanza_attach_carbons_private(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza); +xmpp_stanza_t* stanza_attach_hints_no_copy(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza); +xmpp_stanza_t* stanza_attach_hints_no_store(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza); +xmpp_stanza_t* stanza_attach_hints_store(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza); +xmpp_stanza_t* stanza_attach_receipt_request(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza); +xmpp_stanza_t* stanza_attach_x_oob_url(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza, const char* const url); +xmpp_stanza_t* stanza_attach_origin_id(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza, const char* const id); +xmpp_stanza_t* stanza_attach_correction(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza, const char* const replace_id); -xmpp_stanza_t* stanza_create_room_join_presence(xmpp_ctx_t *const ctx, - const char *const full_room_jid, const char *const passwd); +xmpp_stanza_t* stanza_create_room_join_presence(xmpp_ctx_t* const ctx, + const char* const full_room_jid, const char* const passwd); -xmpp_stanza_t* stanza_create_room_newnick_presence(xmpp_ctx_t *ctx, - const char *const full_room_jid); +xmpp_stanza_t* stanza_create_room_newnick_presence(xmpp_ctx_t* ctx, + const char* const full_room_jid); -xmpp_stanza_t* stanza_create_room_leave_presence(xmpp_ctx_t *ctx, - const char *const room, const char *const nick); +xmpp_stanza_t* stanza_create_room_leave_presence(xmpp_ctx_t* ctx, + const char* const room, const char* const nick); -xmpp_stanza_t* stanza_create_roster_iq(xmpp_ctx_t *ctx); -xmpp_stanza_t* stanza_create_ping_iq(xmpp_ctx_t *ctx, const char *const target); -xmpp_stanza_t* stanza_create_disco_info_iq(xmpp_ctx_t *ctx, const char *const id, - const char *const to, const char *const node); +xmpp_stanza_t* stanza_create_roster_iq(xmpp_ctx_t* ctx); +xmpp_stanza_t* stanza_create_ping_iq(xmpp_ctx_t* ctx, const char* const target); +xmpp_stanza_t* stanza_create_disco_info_iq(xmpp_ctx_t* ctx, const char* const id, + const char* const to, const char* const node); -xmpp_stanza_t* stanza_create_last_activity_iq(xmpp_ctx_t *ctx, const char *const id, - const char *const to); +xmpp_stanza_t* stanza_create_last_activity_iq(xmpp_ctx_t* ctx, const char* const id, + const char* const to); -xmpp_stanza_t* stanza_create_invite(xmpp_ctx_t *ctx, const char *const room, - const char *const contact, const char *const reason, const char *const password); -xmpp_stanza_t* stanza_create_mediated_invite(xmpp_ctx_t *ctx, const char *const room, - const char *const contact, const char *const reason); +xmpp_stanza_t* stanza_create_invite(xmpp_ctx_t* ctx, const char* const room, + const char* const contact, const char* const reason, const char* const password); +xmpp_stanza_t* stanza_create_mediated_invite(xmpp_ctx_t* ctx, const char* const room, + const char* const contact, const char* const reason); -gboolean stanza_contains_chat_state(xmpp_stanza_t *stanza); +gboolean stanza_contains_chat_state(xmpp_stanza_t* stanza); -GDateTime* stanza_get_delay(xmpp_stanza_t *const stanza); -GDateTime* stanza_get_delay_from(xmpp_stanza_t *const stanza, gchar *from); -GDateTime* stanza_get_oldest_delay(xmpp_stanza_t *const stanza); +GDateTime* stanza_get_delay(xmpp_stanza_t* const stanza); +GDateTime* stanza_get_delay_from(xmpp_stanza_t* const stanza, gchar* from); +GDateTime* stanza_get_oldest_delay(xmpp_stanza_t* const stanza); -gboolean stanza_is_muc_presence(xmpp_stanza_t *const stanza); -gboolean stanza_is_muc_self_presence(xmpp_stanza_t *const stanza, - const char *const self_jid); -gboolean stanza_is_room_nick_change(xmpp_stanza_t *const stanza); -gboolean stanza_muc_requires_config(xmpp_stanza_t *const stanza); +gboolean stanza_is_muc_presence(xmpp_stanza_t* const stanza); +gboolean stanza_is_muc_self_presence(xmpp_stanza_t* const stanza, + const char* const self_jid); +gboolean stanza_is_room_nick_change(xmpp_stanza_t* const stanza); +gboolean stanza_muc_requires_config(xmpp_stanza_t* const stanza); -const char* stanza_get_new_nick(xmpp_stanza_t *const stanza); -xmpp_stanza_t* stanza_create_instant_room_request_iq(xmpp_ctx_t *ctx, const char *const room_jid); -xmpp_stanza_t* stanza_create_instant_room_destroy_iq(xmpp_ctx_t *ctx, const char *const room_jid); -xmpp_stanza_t* stanza_create_room_config_request_iq(xmpp_ctx_t *ctx, const char *const room_jid); -xmpp_stanza_t* stanza_create_room_config_cancel_iq(xmpp_ctx_t *ctx, const char *const room_jid); -xmpp_stanza_t* stanza_create_room_config_submit_iq(xmpp_ctx_t *ctx, const char *const room, DataForm *form); -xmpp_stanza_t* stanza_create_room_affiliation_list_iq(xmpp_ctx_t *ctx, const char *const room, - const char *const affiliation); -xmpp_stanza_t* stanza_create_room_affiliation_set_iq(xmpp_ctx_t *ctx, const char *const room, const char *const jid, - const char *const affiliation, const char *const reason); -xmpp_stanza_t* stanza_create_room_role_set_iq(xmpp_ctx_t *const ctx, const char *const room, const char *const jid, - const char *const role, const char *const reason); -xmpp_stanza_t* stanza_create_room_role_list_iq(xmpp_ctx_t *ctx, const char *const room, const char *const role); +const char* stanza_get_new_nick(xmpp_stanza_t* const stanza); +xmpp_stanza_t* stanza_create_instant_room_request_iq(xmpp_ctx_t* ctx, const char* const room_jid); +xmpp_stanza_t* stanza_create_instant_room_destroy_iq(xmpp_ctx_t* ctx, const char* const room_jid); +xmpp_stanza_t* stanza_create_room_config_request_iq(xmpp_ctx_t* ctx, const char* const room_jid); +xmpp_stanza_t* stanza_create_room_config_cancel_iq(xmpp_ctx_t* ctx, const char* const room_jid); +xmpp_stanza_t* stanza_create_room_config_submit_iq(xmpp_ctx_t* ctx, const char* const room, DataForm* form); +xmpp_stanza_t* stanza_create_room_affiliation_list_iq(xmpp_ctx_t* ctx, const char* const room, + const char* const affiliation); +xmpp_stanza_t* stanza_create_room_affiliation_set_iq(xmpp_ctx_t* ctx, const char* const room, const char* const jid, + const char* const affiliation, const char* const reason); +xmpp_stanza_t* stanza_create_room_role_set_iq(xmpp_ctx_t* const ctx, const char* const room, const char* const jid, + const char* const role, const char* const reason); +xmpp_stanza_t* stanza_create_room_role_list_iq(xmpp_ctx_t* ctx, const char* const room, const char* const role); -xmpp_stanza_t* stanza_create_room_subject_message(xmpp_ctx_t *ctx, const char *const room, const char *const subject); -xmpp_stanza_t* stanza_create_room_kick_iq(xmpp_ctx_t *const ctx, const char *const room, const char *const nick, - const char *const reason); +xmpp_stanza_t* stanza_create_room_subject_message(xmpp_ctx_t* ctx, const char* const room, const char* const subject); +xmpp_stanza_t* stanza_create_room_kick_iq(xmpp_ctx_t* const ctx, const char* const room, const char* const nick, + const char* const reason); -xmpp_stanza_t* stanza_create_command_exec_iq(xmpp_ctx_t *ctx, const char *const target, const char *const node); -xmpp_stanza_t* stanza_create_command_config_submit_iq(xmpp_ctx_t *ctx, const char *const room, const char *const node, const char *const sessionid, DataForm *form); +xmpp_stanza_t* stanza_create_command_exec_iq(xmpp_ctx_t* ctx, const char* const target, const char* const node); +xmpp_stanza_t* stanza_create_command_config_submit_iq(xmpp_ctx_t* ctx, const char* const room, const char* const node, const char* const sessionid, DataForm* form); -void stanza_attach_publish_options(xmpp_ctx_t *const ctx, xmpp_stanza_t *const publish, const char *const option, const char *const value); +void stanza_attach_publish_options(xmpp_ctx_t* const ctx, xmpp_stanza_t* const publish, const char* const option, const char* const value); -xmpp_stanza_t* stanza_create_omemo_devicelist_request(xmpp_ctx_t *ctx, const char *const id, const char *const jid); -xmpp_stanza_t* stanza_create_omemo_devicelist_subscribe(xmpp_ctx_t *ctx, const char *const jid); -xmpp_stanza_t* stanza_create_omemo_devicelist_publish(xmpp_ctx_t *ctx, GList *const ids); -xmpp_stanza_t* stanza_create_omemo_bundle_publish(xmpp_ctx_t *ctx, const char *const id, uint32_t device_id, const unsigned char * const identity_key, size_t identity_key_length, const unsigned char * const signed_prekey, size_t signed_prekey_length, const unsigned char * const signed_prekey_signature, size_t signed_prekey_signature_length, GList *const prekeys, GList *const prekeys_id, GList *const prekeys_length); -xmpp_stanza_t* stanza_create_omemo_bundle_request(xmpp_ctx_t *ctx, const char *const id, const char *const jid, uint32_t device_id); +xmpp_stanza_t* stanza_create_omemo_devicelist_request(xmpp_ctx_t* ctx, const char* const id, const char* const jid); +xmpp_stanza_t* stanza_create_omemo_devicelist_subscribe(xmpp_ctx_t* ctx, const char* const jid); +xmpp_stanza_t* stanza_create_omemo_devicelist_publish(xmpp_ctx_t* ctx, GList* const ids); +xmpp_stanza_t* stanza_create_omemo_bundle_publish(xmpp_ctx_t* ctx, const char* const id, uint32_t device_id, const unsigned char* const identity_key, size_t identity_key_length, const unsigned char* const signed_prekey, size_t signed_prekey_length, const unsigned char* const signed_prekey_signature, size_t signed_prekey_signature_length, GList* const prekeys, GList* const prekeys_id, GList* const prekeys_length); +xmpp_stanza_t* stanza_create_omemo_bundle_request(xmpp_ctx_t* ctx, const char* const id, const char* const jid, uint32_t device_id); -xmpp_stanza_t* stanza_create_pubsub_configure_request(xmpp_ctx_t *ctx, const char *const id, const char *const jid, const char *const node); -xmpp_stanza_t* stanza_create_pubsub_configure_submit(xmpp_ctx_t *ctx, const char *const id, const char *const jid, const char *const node, DataForm *form); +xmpp_stanza_t* stanza_create_pubsub_configure_request(xmpp_ctx_t* ctx, const char* const id, const char* const jid, const char* const node); +xmpp_stanza_t* stanza_create_pubsub_configure_submit(xmpp_ctx_t* ctx, const char* const id, const char* const jid, const char* const node, DataForm* form); -int stanza_get_idle_time(xmpp_stanza_t *const stanza); +int stanza_get_idle_time(xmpp_stanza_t* const stanza); -void stanza_attach_priority(xmpp_ctx_t *const ctx, xmpp_stanza_t *const presence, const int pri); -void stanza_attach_last_activity(xmpp_ctx_t *const ctx, xmpp_stanza_t *const presence, const int idle); -void stanza_attach_caps(xmpp_ctx_t *const ctx, xmpp_stanza_t *const presence); -void stanza_attach_show(xmpp_ctx_t *const ctx, xmpp_stanza_t *const presence, const char *const show); -void stanza_attach_status(xmpp_ctx_t *const ctx, xmpp_stanza_t *const presence, const char *const status); +void stanza_attach_priority(xmpp_ctx_t* const ctx, xmpp_stanza_t* const presence, const int pri); +void stanza_attach_last_activity(xmpp_ctx_t* const ctx, xmpp_stanza_t* const presence, const int idle); +void stanza_attach_caps(xmpp_ctx_t* const ctx, xmpp_stanza_t* const presence); +void stanza_attach_show(xmpp_ctx_t* const ctx, xmpp_stanza_t* const presence, const char* const show); +void stanza_attach_status(xmpp_ctx_t* const ctx, xmpp_stanza_t* const presence, const char* const status); -xmpp_stanza_t* stanza_create_caps_query_element(xmpp_ctx_t *ctx); -char* stanza_create_caps_sha1_from_query(xmpp_stanza_t *const query); -EntityCapabilities* stanza_create_caps_from_query_element(xmpp_stanza_t *query); +xmpp_stanza_t* stanza_create_caps_query_element(xmpp_ctx_t* ctx); +char* stanza_create_caps_sha1_from_query(xmpp_stanza_t* const query); +EntityCapabilities* stanza_create_caps_from_query_element(xmpp_stanza_t* query); const char* stanza_get_presence_string_from_type(resource_presence_t presence_type); -xmpp_stanza_t* stanza_create_software_version_iq(xmpp_ctx_t *ctx, const char *const fulljid); -xmpp_stanza_t* stanza_create_disco_items_iq(xmpp_ctx_t *ctx, const char *const id, const char *const jid, const char *const node); +xmpp_stanza_t* stanza_create_software_version_iq(xmpp_ctx_t* ctx, const char* const fulljid); +xmpp_stanza_t* stanza_create_disco_items_iq(xmpp_ctx_t* ctx, const char* const id, const char* const jid, const char* const node); -char* stanza_get_status(xmpp_stanza_t *stanza, char *def); -char* stanza_get_show(xmpp_stanza_t *stanza, char *def); +char* stanza_get_status(xmpp_stanza_t* stanza, char* def); +char* stanza_get_show(xmpp_stanza_t* stanza, char* def); -xmpp_stanza_t* stanza_create_roster_set(xmpp_ctx_t *ctx, const char *const id, const char *const jid, - const char *const handle, GSList *groups); -xmpp_stanza_t* stanza_create_roster_remove_set(xmpp_ctx_t *ctx, const char *const barejid); +xmpp_stanza_t* stanza_create_roster_set(xmpp_ctx_t* ctx, const char* const id, const char* const jid, + const char* const handle, GSList* groups); +xmpp_stanza_t* stanza_create_roster_remove_set(xmpp_ctx_t* ctx, const char* const barejid); -char* stanza_get_error_message(xmpp_stanza_t *const stanza); +char* stanza_get_error_message(xmpp_stanza_t* const stanza); -GSList* stanza_get_status_codes_by_ns(xmpp_stanza_t *const stanza, char *ns); -gboolean stanza_room_destroyed(xmpp_stanza_t *stanza); -const char* stanza_get_muc_destroy_alternative_room(xmpp_stanza_t *stanza); -char* stanza_get_muc_destroy_alternative_password(xmpp_stanza_t *stanza); -char* stanza_get_muc_destroy_reason(xmpp_stanza_t *stanza); -const char* stanza_get_actor(xmpp_stanza_t *stanza); -char* stanza_get_reason(xmpp_stanza_t *stanza); +GSList* stanza_get_status_codes_by_ns(xmpp_stanza_t* const stanza, char* ns); +gboolean stanza_room_destroyed(xmpp_stanza_t* stanza); +const char* stanza_get_muc_destroy_alternative_room(xmpp_stanza_t* stanza); +char* stanza_get_muc_destroy_alternative_password(xmpp_stanza_t* stanza); +char* stanza_get_muc_destroy_reason(xmpp_stanza_t* stanza); +const char* stanza_get_actor(xmpp_stanza_t* stanza); +char* stanza_get_reason(xmpp_stanza_t* stanza); -Resource* stanza_resource_from_presence(XMPPPresence *presence); -XMPPPresence* stanza_parse_presence(xmpp_stanza_t *stanza, int *err); -void stanza_free_presence(XMPPPresence *presence); +Resource* stanza_resource_from_presence(XMPPPresence* presence); +XMPPPresence* stanza_parse_presence(xmpp_stanza_t* stanza, int* err); +void stanza_free_presence(XMPPPresence* presence); -char* stanza_text_strdup(xmpp_stanza_t *stanza); +char* stanza_text_strdup(xmpp_stanza_t* stanza); -XMPPCaps* stanza_parse_caps(xmpp_stanza_t *const stanza); -void stanza_free_caps(XMPPCaps *caps); +XMPPCaps* stanza_parse_caps(xmpp_stanza_t* const stanza); +void stanza_free_caps(XMPPCaps* caps); -xmpp_stanza_t* stanza_get_child_by_name_and_ns(xmpp_stanza_t * const stanza, const char * const name, const char * const ns); +xmpp_stanza_t* stanza_get_child_by_name_and_ns(xmpp_stanza_t* const stanza, const char* const name, const char* const ns); -xmpp_stanza_t* stanza_create_avatar_retrieve_data_request(xmpp_ctx_t *ctx, const char *stanza_id, const char *const item_id, const char *const jid); +xmpp_stanza_t* stanza_create_avatar_retrieve_data_request(xmpp_ctx_t* ctx, const char* stanza_id, const char* const item_id, const char* const jid); -xmpp_stanza_t* stanza_create_mam_iq(xmpp_ctx_t *ctx, const char *const jid, const char *const startdate); +xmpp_stanza_t* stanza_create_mam_iq(xmpp_ctx_t* ctx, const char* const jid, const char* const startdate); #endif diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h index c097387b..da98048a 100644 --- a/src/xmpp/xmpp.h +++ b/src/xmpp/xmpp.h @@ -58,18 +58,18 @@ #define JABBER_PRIORITY_MIN -128 #define JABBER_PRIORITY_MAX 127 -#define XMPP_FEATURE_PING "urn:xmpp:ping" -#define XMPP_FEATURE_BLOCKING "urn:xmpp:blocking" -#define XMPP_FEATURE_RECEIPTS "urn:xmpp:receipts" -#define XMPP_FEATURE_LASTACTIVITY "jabber:iq:last" -#define XMPP_FEATURE_MUC "http://jabber.org/protocol/muc" -#define XMPP_FEATURE_COMMANDS "http://jabber.org/protocol/commands" -#define XMPP_FEATURE_OMEMO_DEVICELIST_NOTIFY "eu.siacs.conversations.axolotl.devicelist+notify" -#define XMPP_FEATURE_PUBSUB "http://jabber.org/protocol/pubsub" -#define XMPP_FEATURE_PUBSUB_PUBLISH_OPTIONS "http://jabber.org/protocol/pubsub#publish-options" +#define XMPP_FEATURE_PING "urn:xmpp:ping" +#define XMPP_FEATURE_BLOCKING "urn:xmpp:blocking" +#define XMPP_FEATURE_RECEIPTS "urn:xmpp:receipts" +#define XMPP_FEATURE_LASTACTIVITY "jabber:iq:last" +#define XMPP_FEATURE_MUC "http://jabber.org/protocol/muc" +#define XMPP_FEATURE_COMMANDS "http://jabber.org/protocol/commands" +#define XMPP_FEATURE_OMEMO_DEVICELIST_NOTIFY "eu.siacs.conversations.axolotl.devicelist+notify" +#define XMPP_FEATURE_PUBSUB "http://jabber.org/protocol/pubsub" +#define XMPP_FEATURE_PUBSUB_PUBLISH_OPTIONS "http://jabber.org/protocol/pubsub#publish-options" #define XMPP_FEATURE_USER_AVATAR_METADATA_NOTIFY "urn:xmpp:avatar:metadata+notify" -#define XMPP_FEATURE_LAST_MESSAGE_CORRECTION "urn:xmpp:message-correct:0" -#define XMPP_FEATURE_MAM2 "urn:xmpp:mam:2" +#define XMPP_FEATURE_LAST_MESSAGE_CORRECTION "urn:xmpp:message-correct:0" +#define XMPP_FEATURE_MAM2 "urn:xmpp:mam:2" typedef enum { JABBER_CONNECTING, @@ -89,37 +89,42 @@ typedef enum { INVITE_MEDIATED } jabber_invite_t; -typedef struct bookmark_t { - char *barejid; - char *nick; - char *password; - char *name; +typedef struct bookmark_t +{ + char* barejid; + char* nick; + char* password; + char* name; gboolean autojoin; int ext_gajim_minimize; //0 - non existant, 1 - true, 2 - false } Bookmark; -typedef struct disco_identity_t { - char *name; - char *type; - char *category; +typedef struct disco_identity_t +{ + char* name; + char* type; + char* category; } DiscoIdentity; -typedef struct software_version_t { - char *software; - char *software_version; - char *os; - char *os_version; +typedef struct software_version_t +{ + char* software; + char* software_version; + char* os; + char* os_version; } SoftwareVersion; -typedef struct entity_capabilities_t { - DiscoIdentity *identity; - SoftwareVersion *software_version; - GSList *features; +typedef struct entity_capabilities_t +{ + DiscoIdentity* identity; + SoftwareVersion* software_version; + GSList* features; } EntityCapabilities; -typedef struct disco_item_t { - char *jid; - char *name; +typedef struct disco_item_t +{ + char* jid; + char* name; } DiscoItem; typedef enum { @@ -140,155 +145,156 @@ typedef enum { PROF_MSG_TYPE_MUCPM } prof_msg_type_t; -typedef struct prof_message_t { - Jid *from_jid; - Jid *to_jid; - /* regular <message id=""> */ - char *id; - /* </origin-id> XEP-0359 */ - char *originid; - /* <replace id> XEP-0308 LMC */ - char *replace_id; - /* for MAM we will need archive_id (stanza-id in XEP-0359) (see database.c) */ - /* The raw body from xmpp message, either plaintext or OTR encrypted text */ - char *body; - /* The encrypted message as for PGP */ - char *encrypted; - /* The message that will be printed on screen and logs */ - char *plain; - GDateTime *timestamp; - prof_enc_t enc; - gboolean trusted; - gboolean is_mam; - prof_msg_type_t type; +typedef struct prof_message_t +{ + Jid* from_jid; + Jid* to_jid; + /* regular <message id=""> */ + char* id; + /* </origin-id> XEP-0359 */ + char* originid; + /* <replace id> XEP-0308 LMC */ + char* replace_id; + /* for MAM we will need archive_id (stanza-id in XEP-0359) (see database.c) */ + /* The raw body from xmpp message, either plaintext or OTR encrypted text */ + char* body; + /* The encrypted message as for PGP */ + char* encrypted; + /* The message that will be printed on screen and logs */ + char* plain; + GDateTime* timestamp; + prof_enc_t enc; + gboolean trusted; + gboolean is_mam; + prof_msg_type_t type; } ProfMessage; void session_init(void); -jabber_conn_status_t session_connect_with_details(const char *const jid, const char *const passwd, - const char *const altdomain, const int port, const char *const tls_policy, const char *const auth_policy); -jabber_conn_status_t session_connect_with_account(const ProfAccount *const account); +jabber_conn_status_t session_connect_with_details(const char* const jid, const char* const passwd, + const char* const altdomain, const int port, const char* const tls_policy, const char* const auth_policy); +jabber_conn_status_t session_connect_with_account(const ProfAccount* const account); void session_disconnect(void); void session_shutdown(void); void session_process_events(void); char* session_get_account_name(void); jabber_conn_status_t connection_get_status(void); -char *connection_get_presence_msg(void); -void connection_set_presence_msg(const char *const message); +char* connection_get_presence_msg(void); +void connection_set_presence_msg(const char* const message); const char* connection_get_fulljid(void); char* connection_get_barejid(void); char* connection_create_uuid(void); -void connection_free_uuid(char *uuid); +void connection_free_uuid(char* uuid); #ifdef HAVE_LIBMESODE TLSCertificate* connection_get_tls_peer_cert(void); #endif gboolean connection_is_secured(void); -gboolean connection_send_stanza(const char *const stanza); +gboolean connection_send_stanza(const char* const stanza); GList* connection_get_available_resources(void); -gboolean connection_supports(const char *const feature); -char* connection_jid_for_feature(const char *const feature); +gboolean connection_supports(const char* const feature); +char* connection_jid_for_feature(const char* const feature); const char* connection_get_profanity_identifier(void); -char* message_send_chat(const char *const barejid, const char *const msg, const char *const oob_url, gboolean request_receipt, const char *const replace_id); -char* message_send_chat_otr(const char *const barejid, const char *const msg, gboolean request_receipt, const char *const replace_id); -char* message_send_chat_pgp(const char *const barejid, const char *const msg, gboolean request_receipt, const char *const replace_id); +char* message_send_chat(const char* const barejid, const char* const msg, const char* const oob_url, gboolean request_receipt, const char* const replace_id); +char* message_send_chat_otr(const char* const barejid, const char* const msg, gboolean request_receipt, const char* const replace_id); +char* message_send_chat_pgp(const char* const barejid, const char* const msg, gboolean request_receipt, const char* const replace_id); // XEP-0373: OpenPGP for XMPP -char* message_send_chat_ox(const char *const barejid, const char *const msg, gboolean request_receipt, const char *const replace_id); -char* message_send_chat_omemo(const char *const jid, uint32_t sid, GList *keys, const unsigned char *const iv, size_t iv_len, const unsigned char *const ciphertext, size_t ciphertext_len, gboolean request_receipt, gboolean muc, const char *const replace_id); -char* message_send_private(const char *const fulljid, const char *const msg, const char *const oob_url); -char* message_send_groupchat(const char *const roomjid, const char *const msg, const char *const oob_url, const char *const replace_id); -void message_send_groupchat_subject(const char *const roomjid, const char *const subject); -void message_send_inactive(const char *const jid); -void message_send_composing(const char *const jid); -void message_send_paused(const char *const jid); -void message_send_gone(const char *const jid); -void message_send_invite(const char *const room, const char *const contact, const char *const reason); - -bool message_is_sent_by_us(const ProfMessage *const message, bool checkOID); - -void presence_subscription(const char *const jid, const jabber_subscr_t action); +char* message_send_chat_ox(const char* const barejid, const char* const msg, gboolean request_receipt, const char* const replace_id); +char* message_send_chat_omemo(const char* const jid, uint32_t sid, GList* keys, const unsigned char* const iv, size_t iv_len, const unsigned char* const ciphertext, size_t ciphertext_len, gboolean request_receipt, gboolean muc, const char* const replace_id); +char* message_send_private(const char* const fulljid, const char* const msg, const char* const oob_url); +char* message_send_groupchat(const char* const roomjid, const char* const msg, const char* const oob_url, const char* const replace_id); +void message_send_groupchat_subject(const char* const roomjid, const char* const subject); +void message_send_inactive(const char* const jid); +void message_send_composing(const char* const jid); +void message_send_paused(const char* const jid); +void message_send_gone(const char* const jid); +void message_send_invite(const char* const room, const char* const contact, const char* const reason); + +bool message_is_sent_by_us(const ProfMessage* const message, bool checkOID); + +void presence_subscription(const char* const jid, const jabber_subscr_t action); GList* presence_get_subscription_requests(void); gint presence_sub_request_count(void); void presence_reset_sub_request_search(void); -char* presence_sub_request_find(const char *const search_str, gboolean previous, void *context); -void presence_join_room(const char *const room, const char *const nick, const char *const passwd); -void presence_change_room_nick(const char *const room, const char *const nick); -void presence_leave_chat_room(const char *const room_jid); -void presence_send(resource_presence_t status, int idle, char *signed_status); -gboolean presence_sub_request_exists(const char *const bare_jid); +char* presence_sub_request_find(const char* const search_str, gboolean previous, void* context); +void presence_join_room(const char* const room, const char* const nick, const char* const passwd); +void presence_change_room_nick(const char* const room, const char* const nick); +void presence_leave_chat_room(const char* const room_jid); +void presence_send(resource_presence_t status, int idle, char* signed_status); +gboolean presence_sub_request_exists(const char* const bare_jid); void iq_enable_carbons(void); void iq_disable_carbons(void); -void iq_send_software_version(const char *const fulljid); +void iq_send_software_version(const char* const fulljid); void iq_rooms_cache_clear(void); void iq_handlers_clear(); -void iq_room_list_request(gchar *conferencejid, gchar *filter); -void iq_disco_info_request(gchar *jid); -void iq_disco_items_request(gchar *jid); -void iq_last_activity_request(gchar *jid); +void iq_room_list_request(gchar* conferencejid, gchar* filter); +void iq_disco_info_request(gchar* jid); +void iq_disco_items_request(gchar* jid); +void iq_last_activity_request(gchar* jid); void iq_set_autoping(int seconds); -void iq_confirm_instant_room(const char *const room_jid); -void iq_destroy_room(const char *const room_jid); -void iq_request_room_config_form(const char *const room_jid); -void iq_submit_room_config(ProfConfWin *confwin); -void iq_room_config_cancel(ProfConfWin *confwin); -void iq_send_ping(const char *const target); -void iq_room_info_request(const char *const room, gboolean display_result); -void iq_room_affiliation_list(const char *const room, char *affiliation, bool show); -void iq_room_affiliation_set(const char *const room, const char *const jid, char *affiliation, - const char *const reason); -void iq_room_kick_occupant(const char *const room, const char *const nick, const char *const reason); -void iq_room_role_set(const char *const room, const char *const nick, char *role, const char *const reason); -void iq_room_role_list(const char * const room, char *role); +void iq_confirm_instant_room(const char* const room_jid); +void iq_destroy_room(const char* const room_jid); +void iq_request_room_config_form(const char* const room_jid); +void iq_submit_room_config(ProfConfWin* confwin); +void iq_room_config_cancel(ProfConfWin* confwin); +void iq_send_ping(const char* const target); +void iq_room_info_request(const char* const room, gboolean display_result); +void iq_room_affiliation_list(const char* const room, char* affiliation, bool show); +void iq_room_affiliation_set(const char* const room, const char* const jid, char* affiliation, + const char* const reason); +void iq_room_kick_occupant(const char* const room, const char* const nick, const char* const reason); +void iq_room_role_set(const char* const room, const char* const nick, char* role, const char* const reason); +void iq_room_role_list(const char* const room, char* role); void iq_autoping_timer_cancel(void); void iq_autoping_check(void); -void iq_http_upload_request(HTTPUpload *upload); -void iq_command_list(const char *const target); -void iq_command_exec(const char *const target, const char *const command); -void iq_mam_request(ProfChatWin *win); +void iq_http_upload_request(HTTPUpload* upload); +void iq_command_list(const char* const target); +void iq_command_exec(const char* const target, const char* const command); +void iq_mam_request(ProfChatWin* win); -EntityCapabilities* caps_lookup(const char *const jid); +EntityCapabilities* caps_lookup(const char* const jid); void caps_close(void); -void caps_destroy(EntityCapabilities *caps); +void caps_destroy(EntityCapabilities* caps); void caps_reset_ver(void); -void caps_add_feature(char *feature); -void caps_remove_feature(char *feature); -gboolean caps_jid_has_feature(const char *const jid, const char *const feature); - -gboolean bookmark_add(const char *jid, const char *nick, const char *password, const char *autojoin_str, const char *name); -gboolean bookmark_update(const char *jid, const char *nick, const char *password, const char *autojoin_str, const char *name); -gboolean bookmark_remove(const char *jid); -gboolean bookmark_join(const char *jid); +void caps_add_feature(char* feature); +void caps_remove_feature(char* feature); +gboolean caps_jid_has_feature(const char* const jid, const char* const feature); + +gboolean bookmark_add(const char* jid, const char* nick, const char* password, const char* autojoin_str, const char* name); +gboolean bookmark_update(const char* jid, const char* nick, const char* password, const char* autojoin_str, const char* name); +gboolean bookmark_remove(const char* jid); +gboolean bookmark_join(const char* jid); GList* bookmark_get_list(void); -char* bookmark_find(const char *const search_str, gboolean previous, void *context); +char* bookmark_find(const char* const search_str, gboolean previous, void* context); void bookmark_autocomplete_reset(void); -gboolean bookmark_exists(const char *const room); +gboolean bookmark_exists(const char* const room); -void roster_send_name_change(const char *const barejid, const char *const new_name, GSList *groups); -void roster_send_add_to_group(const char *const group, PContact contact); -void roster_send_remove_from_group(const char *const group, PContact contact); -void roster_send_add_new(const char *const barejid, const char *const name); -void roster_send_remove(const char *const barejid); +void roster_send_name_change(const char* const barejid, const char* const new_name, GSList* groups); +void roster_send_add_to_group(const char* const group, PContact contact); +void roster_send_remove_from_group(const char* const group, PContact contact); +void roster_send_add_new(const char* const barejid, const char* const name); +void roster_send_remove(const char* const barejid); GList* blocked_list(void); -gboolean blocked_add(char *jid); -gboolean blocked_remove(char *jid); -char* blocked_ac_find(const char *const search_str, gboolean previous, void *context); +gboolean blocked_add(char* jid); +gboolean blocked_remove(char* jid); +char* blocked_ac_find(const char* const search_str, gboolean previous, void* context); void blocked_ac_reset(void); -void form_destroy(DataForm *form); -void form_set_value(DataForm *form, const char *const tag, char *value); -gboolean form_add_unique_value(DataForm *form, const char *const tag, char *value); -void form_add_value(DataForm *form, const char *const tag, char *value); -gboolean form_remove_value(DataForm *form, const char *const tag, char *value); -gboolean form_remove_text_multi_value(DataForm *form, const char *const tag, int index); -gboolean form_tag_exists(DataForm *form, const char *const tag); -form_field_type_t form_get_field_type(DataForm *form, const char *const tag); -gboolean form_field_contains_option(DataForm *form, const char *const tag, char *value); -int form_get_value_count(DataForm *form, const char *const tag); -FormField* form_get_field_by_tag(DataForm *form, const char *const tag); -Autocomplete form_get_value_ac(DataForm *form, const char *const tag); -void form_reset_autocompleters(DataForm *form); +void form_destroy(DataForm* form); +void form_set_value(DataForm* form, const char* const tag, char* value); +gboolean form_add_unique_value(DataForm* form, const char* const tag, char* value); +void form_add_value(DataForm* form, const char* const tag, char* value); +gboolean form_remove_value(DataForm* form, const char* const tag, char* value); +gboolean form_remove_text_multi_value(DataForm* form, const char* const tag, int index); +gboolean form_tag_exists(DataForm* form, const char* const tag); +form_field_type_t form_get_field_type(DataForm* form, const char* const tag); +gboolean form_field_contains_option(DataForm* form, const char* const tag, char* value); +int form_get_value_count(DataForm* form, const char* const tag); +FormField* form_get_field_by_tag(DataForm* form, const char* const tag); +Autocomplete form_get_value_ac(DataForm* form, const char* const tag); +void form_reset_autocompleters(DataForm* form); #endif diff --git a/tests/unittests/config/stub_accounts.c b/tests/unittests/config/stub_accounts.c index ce2c3379..19a0bdcb 100644 --- a/tests/unittests/config/stub_accounts.c +++ b/tests/unittests/config/stub_accounts.c @@ -6,202 +6,309 @@ #include "common.h" #include "config/account.h" -void accounts_load(void) {} -void accounts_close(void) {} +void +accounts_load(void) +{ +} +void +accounts_close(void) +{ +} -char * accounts_find_all(char *prefix) +char* +accounts_find_all(char* prefix) { return NULL; } -char * accounts_find_enabled(char *prefix, void *context) +char* +accounts_find_enabled(char* prefix, void* context) { return NULL; } -void accounts_reset_all_search(void) {} -void accounts_reset_enabled_search(void) {} +void +accounts_reset_all_search(void) +{ +} +void +accounts_reset_enabled_search(void) +{ +} -void accounts_add(const char *jid, const char *altdomain, const int port) +void +accounts_add(const char* jid, const char* altdomain, const int port) { check_expected(jid); check_expected(altdomain); check_expected(port); } -int accounts_remove(const char *jid) +int +accounts_remove(const char* jid) { return 0; } -gchar** accounts_get_list(void) +gchar** +accounts_get_list(void) { - return mock_ptr_type(gchar **); + return mock_ptr_type(gchar**); } -ProfAccount* accounts_get_account(const char * const name) +ProfAccount* +accounts_get_account(const char* const name) { check_expected(name); return mock_ptr_type(ProfAccount*); } -gboolean accounts_enable(const char * const name) +gboolean +accounts_enable(const char* const name) { check_expected(name); return mock_type(gboolean); } -gboolean accounts_disable(const char * const name) +gboolean +accounts_disable(const char* const name) { check_expected(name); return mock_type(gboolean); } -gboolean accounts_rename(const char * const account_name, - const char * const new_name) +gboolean +accounts_rename(const char* const account_name, + const char* const new_name) { check_expected(account_name); check_expected(new_name); return mock_type(gboolean); } -gboolean accounts_account_exists(const char * const account_name) +gboolean +accounts_account_exists(const char* const account_name) { check_expected(account_name); return mock_type(gboolean); } -void accounts_set_jid(const char * const account_name, const char * const value) +void +accounts_set_jid(const char* const account_name, const char* const value) { check_expected(account_name); check_expected(value); } -void accounts_set_server(const char * const account_name, const char * const value) +void +accounts_set_server(const char* const account_name, const char* const value) { check_expected(account_name); check_expected(value); } -void accounts_set_port(const char * const account_name, const int value) {} +void +accounts_set_port(const char* const account_name, const int value) +{ +} -void accounts_set_resource(const char * const account_name, const char * const value) +void +accounts_set_resource(const char* const account_name, const char* const value) { check_expected(account_name); check_expected(value); } -void accounts_set_password(const char * const account_name, const char * const value) +void +accounts_set_password(const char* const account_name, const char* const value) { check_expected(account_name); check_expected(value); } -void accounts_set_eval_password(const char * const account_name, const char * const value) +void +accounts_set_eval_password(const char* const account_name, const char* const value) { check_expected(account_name); check_expected(value); } -void accounts_set_muc_service(const char * const account_name, const char * const value) +void +accounts_set_muc_service(const char* const account_name, const char* const value) { check_expected(account_name); check_expected(value); } -void accounts_set_muc_nick(const char * const account_name, const char * const value) +void +accounts_set_muc_nick(const char* const account_name, const char* const value) { check_expected(account_name); check_expected(value); } -void accounts_set_otr_policy(const char * const account_name, const char * const value) +void +accounts_set_otr_policy(const char* const account_name, const char* const value) { check_expected(account_name); check_expected(value); } -void accounts_set_last_presence(const char * const account_name, const char * const value) {} -void accounts_set_last_status(const char * const account_name, const char * const value) {} -void accounts_set_last_activity(const char * const account_name) {} -void accounts_set_pgp_keyid(const char * const account_name, const char * const value) {} -void accounts_set_script_start(const char * const account_name, const char * const value) {} -void accounts_set_theme(const char * const account_name, const char * const value) {} -void accounts_set_tls_policy(const char * const account_name, const char * const value) {} -void accounts_set_auth_policy(const char * const account_name, const char * const value) {} +void +accounts_set_last_presence(const char* const account_name, const char* const value) +{ +} +void +accounts_set_last_status(const char* const account_name, const char* const value) +{ +} +void +accounts_set_last_activity(const char* const account_name) +{ +} +void +accounts_set_pgp_keyid(const char* const account_name, const char* const value) +{ +} +void +accounts_set_script_start(const char* const account_name, const char* const value) +{ +} +void +accounts_set_theme(const char* const account_name, const char* const value) +{ +} +void +accounts_set_tls_policy(const char* const account_name, const char* const value) +{ +} +void +accounts_set_auth_policy(const char* const account_name, const char* const value) +{ +} -void accounts_set_login_presence(const char * const account_name, const char * const value) +void +accounts_set_login_presence(const char* const account_name, const char* const value) { check_expected(account_name); check_expected(value); } -resource_presence_t accounts_get_login_presence(const char * const account_name) +resource_presence_t +accounts_get_login_presence(const char* const account_name) { return RESOURCE_ONLINE; } -char * accounts_get_last_status(const char * const account_name) +char* +accounts_get_last_status(const char* const account_name) { return NULL; } -resource_presence_t accounts_get_last_presence(const char * const account_name) +resource_presence_t +accounts_get_last_presence(const char* const account_name) { check_expected(account_name); return mock_type(resource_presence_t); } -void accounts_set_priority_online(const char * const account_name, const gint value) +void +accounts_set_priority_online(const char* const account_name, const gint value) { check_expected(account_name); check_expected(value); } -void accounts_set_priority_chat(const char * const account_name, const gint value) +void +accounts_set_priority_chat(const char* const account_name, const gint value) { check_expected(account_name); check_expected(value); } -void accounts_set_priority_away(const char * const account_name, const gint value) +void +accounts_set_priority_away(const char* const account_name, const gint value) { check_expected(account_name); check_expected(value); } -void accounts_set_priority_xa(const char * const account_name, const gint value) +void +accounts_set_priority_xa(const char* const account_name, const gint value) { check_expected(account_name); check_expected(value); } -void accounts_set_priority_dnd(const char * const account_name, const gint value) +void +accounts_set_priority_dnd(const char* const account_name, const gint value) { check_expected(account_name); check_expected(value); } -void accounts_set_priority_all(const char * const account_name, const gint value) {} -gint accounts_get_priority_for_presence_type(const char * const account_name, - resource_presence_t presence_type) +void +accounts_set_priority_all(const char* const account_name, const gint value) +{ +} +gint +accounts_get_priority_for_presence_type(const char* const account_name, + resource_presence_t presence_type) { return 0; } -void accounts_clear_password(const char * const account_name) {} -void accounts_clear_eval_password(const char * const account_name) {} -void accounts_clear_server(const char * const account_name) {} -void accounts_clear_port(const char * const account_name) {} -void accounts_clear_otr(const char * const account_name) {} -void accounts_clear_pgp_keyid(const char * const account_name) {} -void accounts_clear_script_start(const char * const account_name) {} -void accounts_clear_theme(const char * const account_name) {} -void accounts_clear_muc(const char * const account_name) {} -void accounts_clear_resource(const char * const account_name) {} -void accounts_add_otr_policy(const char * const account_name, const char * const contact_jid, const char * const policy) {} -char* accounts_get_last_activity(const char *const account_name) +void +accounts_clear_password(const char* const account_name) +{ +} +void +accounts_clear_eval_password(const char* const account_name) +{ +} +void +accounts_clear_server(const char* const account_name) +{ +} +void +accounts_clear_port(const char* const account_name) +{ +} +void +accounts_clear_otr(const char* const account_name) +{ +} +void +accounts_clear_pgp_keyid(const char* const account_name) +{ +} +void +accounts_clear_script_start(const char* const account_name) +{ +} +void +accounts_clear_theme(const char* const account_name) +{ +} +void +accounts_clear_muc(const char* const account_name) +{ +} +void +accounts_clear_resource(const char* const account_name) +{ +} +void +accounts_add_otr_policy(const char* const account_name, const char* const contact_jid, const char* const policy) +{ +} +char* +accounts_get_last_activity(const char* const account_name) { return NULL; } -void accounts_add_omemo_state(const char *const account_name, const char *const contact_jid, gboolean enabled) {} +void +accounts_add_omemo_state(const char* const account_name, const char* const contact_jid, gboolean enabled) +{ +} diff --git a/tests/unittests/database/stub_database.c b/tests/unittests/database/stub_database.c index 4c79c273..15a4478b 100644 --- a/tests/unittests/database/stub_database.c +++ b/tests/unittests/database/stub_database.c @@ -26,9 +26,28 @@ #include "database.h" -gboolean log_database_init(ProfAccount *account) { return TRUE; } -void log_database_add_incoming(ProfMessage *message) {} -void log_database_add_outgoing_chat(const char * const id, const char * const barejid, const char * const message, const char *const replace_id, prof_enc_t enc) {} -void log_database_add_outgoing_muc(const char * const id, const char * const barejid, const char * const message, const char *const replace_id, prof_enc_t enc) {} -void log_database_add_outgoing_muc_pm(const char * const id, const char * const barejid, const char * const message, const char *const replace_id, prof_enc_t enc) {} -void log_database_close(void) {} +gboolean +log_database_init(ProfAccount* account) +{ + return TRUE; +} +void +log_database_add_incoming(ProfMessage* message) +{ +} +void +log_database_add_outgoing_chat(const char* const id, const char* const barejid, const char* const message, const char* const replace_id, prof_enc_t enc) +{ +} +void +log_database_add_outgoing_muc(const char* const id, const char* const barejid, const char* const message, const char* const replace_id, prof_enc_t enc) +{ +} +void +log_database_add_outgoing_muc_pm(const char* const id, const char* const barejid, const char* const message, const char* const replace_id, prof_enc_t enc) +{ +} +void +log_database_close(void) +{ +} diff --git a/tests/unittests/helpers.c b/tests/unittests/helpers.c index e85045e6..e309b559 100644 --- a/tests/unittests/helpers.c +++ b/tests/unittests/helpers.c @@ -12,7 +12,8 @@ #include "config/preferences.h" #include "xmpp/chat_session.h" -void create_config_dir(void **state) +void +create_config_dir(void** state) { setenv("XDG_CONFIG_HOME", "./tests/files/xdg_config_home", 1); if (!mkdir_recursive("./tests/files/xdg_config_home/profanity")) { @@ -20,13 +21,15 @@ void create_config_dir(void **state) } } -void remove_config_dir(void **state) +void +remove_config_dir(void** state) { rmdir("./tests/files/xdg_config_home/profanity"); rmdir("./tests/files/xdg_config_home"); } -void create_data_dir(void **state) +void +create_data_dir(void** state) { setenv("XDG_DATA_HOME", "./tests/files/xdg_data_home", 1); if (!mkdir_recursive("./tests/files/xdg_data_home/profanity")) { @@ -34,23 +37,26 @@ void create_data_dir(void **state) } } -void remove_data_dir(void **state) +void +remove_data_dir(void** state) { rmdir("./tests/files/xdg_data_home/profanity"); rmdir("./tests/files/xdg_data_home"); } -void load_preferences(void **state) +void +load_preferences(void** state) { create_config_dir(state); - FILE *f = fopen("./tests/files/xdg_config_home/profanity/profrc", "ab+"); + FILE* f = fopen("./tests/files/xdg_config_home/profanity/profrc", "ab+"); if (f) { prefs_load(NULL); } fclose(f); } -void close_preferences(void **state) +void +close_preferences(void** state) { prefs_close(); remove("./tests/files/xdg_config_home/profanity/profrc"); @@ -58,27 +64,29 @@ void close_preferences(void **state) rmdir("./tests/files"); } -void init_chat_sessions(void **state) +void +init_chat_sessions(void** state) { load_preferences(NULL); chat_sessions_init(); } -void close_chat_sessions(void **state) +void +close_chat_sessions(void** state) { chat_sessions_clear(); close_preferences(NULL); } int -utf8_pos_to_col(char *str, int utf8_pos) +utf8_pos_to_col(char* str, int utf8_pos) { int col = 0; int i = 0; - for (i = 0; i<utf8_pos; i++) { + for (i = 0; i < utf8_pos; i++) { col++; - gchar *ch = g_utf8_offset_to_pointer(str, i); + gchar* ch = g_utf8_offset_to_pointer(str, i); gunichar uni = g_utf8_get_char(ch); if (g_unichar_iswide(uni)) { col++; @@ -97,22 +105,22 @@ glist_set_cmp(GCompareFunc func) } int -glist_contents_equal(const void *actual, const void *expected) +glist_contents_equal(const void* actual, const void* expected) { - GList *ac = (GList *)actual; - GList *ex = (GList *)expected; + GList* ac = (GList*)actual; + GList* ex = (GList*)expected; - GList *p = ex; + GList* p = ex; printf("\nExpected\n"); - while(ex) { + while (ex) { printf("\n\n%s\n", (char*)p->data); ex = g_list_next(ex); } printf("\n\n"); p = ac; printf("\nActual\n"); - while(ac) { - printf("\n\n%s\n", (char *)p->data); + while (ac) { + printf("\n\n%s\n", (char*)p->data); ac = g_list_next(ac); } printf("\n\n"); @@ -121,7 +129,7 @@ glist_contents_equal(const void *actual, const void *expected) return 0; } - GList *ex_curr = ex; + GList* ex_curr = ex; while (ex_curr != NULL) { if (g_list_find_custom(ac, ex_curr->data, cmp_func) == NULL) { return 0; diff --git a/tests/unittests/helpers.h b/tests/unittests/helpers.h index 75d446d0..6c00fb51 100644 --- a/tests/unittests/helpers.h +++ b/tests/unittests/helpers.h @@ -1,12 +1,12 @@ #include "glib.h" -void load_preferences(void **state); -void close_preferences(void **state); +void load_preferences(void** state); +void close_preferences(void** state); -void init_chat_sessions(void **state); -void close_chat_sessions(void **state); +void init_chat_sessions(void** state); +void close_chat_sessions(void** state); -int utf8_pos_to_col(char *str, int utf8_pos); +int utf8_pos_to_col(char* str, int utf8_pos); void glist_set_cmp(GCompareFunc func); -int glist_contents_equal(const void *actual, const void *expected); \ No newline at end of file +int glist_contents_equal(const void* actual, const void* expected); \ No newline at end of file diff --git a/tests/unittests/log/stub_log.c b/tests/unittests/log/stub_log.c index 5861a895..ee3780a7 100644 --- a/tests/unittests/log/stub_log.c +++ b/tests/unittests/log/stub_log.c @@ -26,50 +26,131 @@ #include "log.h" -void log_init(log_level_t filter, char *log_file) {} -log_level_t log_get_filter(void) +void +log_init(log_level_t filter, char* log_file) +{ +} +log_level_t +log_get_filter(void) { return mock_type(log_level_t); } -void log_reinit(void) {} -void log_close(void) {} -void log_debug(const char * const msg, ...) {} -void log_info(const char * const msg, ...) {} -void log_warning(const char * const msg, ...) {} -void log_error(const char * const msg, ...) {} -void log_msg(log_level_t level, const char * const area, const char * const msg) {} +void +log_reinit(void) +{ +} +void +log_close(void) +{ +} +void +log_debug(const char* const msg, ...) +{ +} +void +log_info(const char* const msg, ...) +{ +} +void +log_warning(const char* const msg, ...) +{ +} +void +log_error(const char* const msg, ...) +{ +} +void +log_msg(log_level_t level, const char* const area, const char* const msg) +{ +} -const char * get_log_file_location(void) +const char* +get_log_file_location(void) { - return mock_ptr_type(char *); + return mock_ptr_type(char*); } -log_level_t log_level_from_string(char *log_level) +log_level_t +log_level_from_string(char* log_level) { return mock_type(log_level_t); } -void log_stderr_init(log_level_t level) {} -void log_stderr_close(void) {} -void log_stderr_handler(void) {} +void +log_stderr_init(log_level_t level) +{ +} +void +log_stderr_close(void) +{ +} +void +log_stderr_handler(void) +{ +} -void chat_log_init(void) {} +void +chat_log_init(void) +{ +} -void chat_log_msg_out(const char * const barejid, const char * const msg, const char *const resource) {} -void chat_log_otr_msg_out(const char * const barejid, const char * const msg, const char *const resource) {} -void chat_log_pgp_msg_out(const char * const barejid, const char * const msg, const char *const resource) {} -void chat_log_omemo_msg_out(const char *const barejid, const char *const msg, const char *const resource) {} +void +chat_log_msg_out(const char* const barejid, const char* const msg, const char* const resource) +{ +} +void +chat_log_otr_msg_out(const char* const barejid, const char* const msg, const char* const resource) +{ +} +void +chat_log_pgp_msg_out(const char* const barejid, const char* const msg, const char* const resource) +{ +} +void +chat_log_omemo_msg_out(const char* const barejid, const char* const msg, const char* const resource) +{ +} -void chat_log_msg_in(ProfMessage *message) {} -void chat_log_otr_msg_in(ProfMessage *message) {} -void chat_log_pgp_msg_in(ProfMessage *message) {} -void chat_log_omemo_msg_in(ProfMessage *message) {} +void +chat_log_msg_in(ProfMessage* message) +{ +} +void +chat_log_otr_msg_in(ProfMessage* message) +{ +} +void +chat_log_pgp_msg_in(ProfMessage* message) +{ +} +void +chat_log_omemo_msg_in(ProfMessage* message) +{ +} -void chat_log_close(void) {} +void +chat_log_close(void) +{ +} -void groupchat_log_init(void) {} -void groupchat_log_msg_in(const gchar *const room, const gchar *const nick, const gchar *const msg) {} -void groupchat_log_msg_out(const gchar *const room, const gchar *const msg) {} -void groupchat_log_omemo_msg_in(const gchar *const room, const gchar *const nick, const gchar *const msg) {} -void groupchat_log_omemo_msg_out(const gchar *const room, const gchar *const msg) {} +void +groupchat_log_init(void) +{ +} +void +groupchat_log_msg_in(const gchar* const room, const gchar* const nick, const gchar* const msg) +{ +} +void +groupchat_log_msg_out(const gchar* const room, const gchar* const msg) +{ +} +void +groupchat_log_omemo_msg_in(const gchar* const room, const gchar* const nick, const gchar* const msg) +{ +} +void +groupchat_log_omemo_msg_out(const gchar* const room, const gchar* const msg) +{ +} diff --git a/tests/unittests/omemo/stub_omemo.c b/tests/unittests/omemo/stub_omemo.c index fe5d27c5..448d5a0d 100644 --- a/tests/unittests/omemo/stub_omemo.c +++ b/tests/unittests/omemo/stub_omemo.c @@ -3,39 +3,51 @@ #include "config/account.h" #include "ui/ui.h" -void omemo_init(void) {} -void omemo_close(void) {} +void +omemo_init(void) +{ +} +void +omemo_close(void) +{ +} char* -omemo_fingerprint_autocomplete(const char *const search_str, gboolean previous) +omemo_fingerprint_autocomplete(const char* const search_str, gboolean previous) { return NULL; } -void omemo_fingerprint_autocomplete_reset(void) {} +void +omemo_fingerprint_autocomplete_reset(void) +{ +} -char * -omemo_format_fingerprint(const char *const fingerprint) +char* +omemo_format_fingerprint(const char* const fingerprint) { return NULL; } -void omemo_generate_crypto_materials(ProfAccount *account) {} +void +omemo_generate_crypto_materials(ProfAccount* account) +{ +} gboolean -omemo_automatic_start(const char *const jid) +omemo_automatic_start(const char* const jid) { return TRUE; } gboolean -omemo_is_trusted_identity(const char *const jid, const char *const fingerprint) +omemo_is_trusted_identity(const char* const jid, const char* const fingerprint) { return TRUE; } -GList * -omemo_known_device_identities(const char *const jid) +GList* +omemo_known_device_identities(const char* const jid) { return NULL; } @@ -46,25 +58,52 @@ omemo_loaded(void) return TRUE; } -void omemo_on_connect(ProfAccount *account) {} -void omemo_on_disconnect(void) {} +void +omemo_on_connect(ProfAccount* account) +{ +} +void +omemo_on_disconnect(void) +{ +} -char * -omemo_on_message_send(ProfWin *win, const char *const message, gboolean request_receipt, gboolean muc) +char* +omemo_on_message_send(ProfWin* win, const char* const message, gboolean request_receipt, gboolean muc) { return NULL; } -char * +char* omemo_own_fingerprint(gboolean formatted) { return NULL; } -void omemo_start_muc_sessions(const char *const roomjid) {} -void omemo_start_session(const char *const barejid) {} -void omemo_trust(const char *const jid, const char *const fingerprint_formatted) {} -void omemo_untrust(const char *const jid, const char *const fingerprint_formatted) {} -void omemo_devicelist_publish(GList *device_list) {} -void omemo_publish_crypto_materials(void) {} -void omemo_start_sessions(void) {} +void +omemo_start_muc_sessions(const char* const roomjid) +{ +} +void +omemo_start_session(const char* const barejid) +{ +} +void +omemo_trust(const char* const jid, const char* const fingerprint_formatted) +{ +} +void +omemo_untrust(const char* const jid, const char* const fingerprint_formatted) +{ +} +void +omemo_devicelist_publish(GList* device_list) +{ +} +void +omemo_publish_crypto_materials(void) +{ +} +void +omemo_start_sessions(void) +{ +} diff --git a/tests/unittests/otr/stub_otr.c b/tests/unittests/otr/stub_otr.c index dffecfec..d6827c66 100644 --- a/tests/unittests/otr/stub_otr.c +++ b/tests/unittests/otr/stub_otr.c @@ -11,104 +11,154 @@ #include "otr/otr.h" -OtrlUserState otr_userstate(void) +OtrlUserState +otr_userstate(void) { return NULL; } -OtrlMessageAppOps* otr_messageops(void) +OtrlMessageAppOps* +otr_messageops(void) { return NULL; } -GHashTable* otr_smpinitators(void) +GHashTable* +otr_smpinitators(void) { return NULL; } -void otr_init(void) {} -void otr_shutdown(void) {} +void +otr_init(void) +{ +} +void +otr_shutdown(void) +{ +} -char* otr_libotr_version(void) +char* +otr_libotr_version(void) { return mock_ptr_type(char*); } -char* otr_start_query(void) +char* +otr_start_query(void) { return mock_ptr_type(char*); } -void otr_poll(void) {} -void otr_on_connect(ProfAccount *account) {} -char* otr_on_message_recv(const char * const barejid, const char * const resource, const char * const message, gboolean *was_decrypted) +void +otr_poll(void) +{ +} +void +otr_on_connect(ProfAccount* account) +{ +} +char* +otr_on_message_recv(const char* const barejid, const char* const resource, const char* const message, gboolean* was_decrypted) { return NULL; } -gboolean otr_on_message_send(ProfChatWin *chatwin, const char * const message, gboolean request_receipt, const char *const replace_id) +gboolean +otr_on_message_send(ProfChatWin* chatwin, const char* const message, gboolean request_receipt, const char* const replace_id) { return FALSE; } -void otr_keygen(ProfAccount *account) +void +otr_keygen(ProfAccount* account) { check_expected(account); } -gboolean otr_key_loaded(void) +gboolean +otr_key_loaded(void) { return mock_type(gboolean); } -char* otr_tag_message(const char * const msg) +char* +otr_tag_message(const char* const msg) { return NULL; } -gboolean otr_is_secure(const char * const recipient) +gboolean +otr_is_secure(const char* const recipient) { return FALSE; } -gboolean otr_is_trusted(const char * const recipient) +gboolean +otr_is_trusted(const char* const recipient) { return FALSE; } -void otr_trust(const char * const recipient) {} -void otr_untrust(const char * const recipient) {} +void +otr_trust(const char* const recipient) +{ +} +void +otr_untrust(const char* const recipient) +{ +} -void otr_smp_secret(const char * const recipient, const char *secret) {} -void otr_smp_question(const char * const recipient, const char *question, const char *answer) {} -void otr_smp_answer(const char * const recipient, const char *answer) {} +void +otr_smp_secret(const char* const recipient, const char* secret) +{ +} +void +otr_smp_question(const char* const recipient, const char* question, const char* answer) +{ +} +void +otr_smp_answer(const char* const recipient, const char* answer) +{ +} -void otr_end_session(const char * const recipient) {} +void +otr_end_session(const char* const recipient) +{ +} -char * otr_get_my_fingerprint(void) +char* +otr_get_my_fingerprint(void) { - return mock_ptr_type(char *); + return mock_ptr_type(char*); } -char * otr_get_their_fingerprint(const char * const recipient) +char* +otr_get_their_fingerprint(const char* const recipient) { check_expected(recipient); - return mock_ptr_type(char *); + return mock_ptr_type(char*); } -char * otr_encrypt_message(const char * const to, const char * const message) +char* +otr_encrypt_message(const char* const to, const char* const message) { return NULL; } -char * otr_decrypt_message(const char * const from, const char * const message, - gboolean *was_decrypted) +char* +otr_decrypt_message(const char* const from, const char* const message, + gboolean* was_decrypted) { return NULL; } -void otr_free_message(char *message) {} +void +otr_free_message(char* message) +{ +} -prof_otrpolicy_t otr_get_policy(const char * const recipient) +prof_otrpolicy_t +otr_get_policy(const char* const recipient) { return PROF_OTRPOLICY_MANUAL; } diff --git a/tests/unittests/pgp/stub_gpg.c b/tests/unittests/pgp/stub_gpg.c index efa6dcd3..807e9b6b 100644 --- a/tests/unittests/pgp/stub_gpg.c +++ b/tests/unittests/pgp/stub_gpg.c @@ -2,10 +2,17 @@ #include "pgp/gpg.h" -void p_gpg_init(void) {} -void p_gpg_close(void) {} +void +p_gpg_init(void) +{ +} +void +p_gpg_close(void) +{ +} -GHashTable* p_gpg_list_keys(void) +GHashTable* +p_gpg_list_keys(void) { return NULL; } @@ -16,65 +23,96 @@ p_gpg_pubkeys(void) return NULL; } -const char* p_gpg_libver(void) +const char* +p_gpg_libver(void) { return NULL; } -void p_gpg_verify(const char * const barejid, const char *const sign) {} +void +p_gpg_verify(const char* const barejid, const char* const sign) +{ +} -char* p_gpg_sign(const char * const str, const char * const fp) +char* +p_gpg_sign(const char* const str, const char* const fp) { return NULL; } -gboolean p_gpg_valid_key(const char * const keyid, char **err_str) +gboolean +p_gpg_valid_key(const char* const keyid, char** err_str) { return FALSE; } -gboolean p_gpg_available(const char * const barejid) +gboolean +p_gpg_available(const char* const barejid) { return FALSE; } -char * p_gpg_decrypt(const char * const cipher) +char* +p_gpg_decrypt(const char* const cipher) { return NULL; } -void p_gpg_on_connect(const char * const barejid) {} -void p_gpg_on_disconnect(void) {} +void +p_gpg_on_connect(const char* const barejid) +{ +} +void +p_gpg_on_disconnect(void) +{ +} -gboolean p_gpg_addkey(const char * const jid, const char * const keyid) +gboolean +p_gpg_addkey(const char* const jid, const char* const keyid) { return TRUE; } -void p_gpg_free_decrypted(char *decrypted) {} +void +p_gpg_free_decrypted(char* decrypted) +{ +} -void p_gpg_free_keys(GHashTable *keys) {} +void +p_gpg_free_keys(GHashTable* keys) +{ +} -void p_gpg_autocomplete_key_reset(void) {} +void +p_gpg_autocomplete_key_reset(void) +{ +} -char * p_gpg_autocomplete_key(const char * const search_str, gboolean previous, void *context) +char* +p_gpg_autocomplete_key(const char* const search_str, gboolean previous, void* context) { return NULL; } -char * -p_gpg_format_fp_str(char *fp) +char* +p_gpg_format_fp_str(char* fp) { return NULL; } -gboolean ox_is_private_key_available(const char *const barejid) { +gboolean +ox_is_private_key_available(const char* const barejid) +{ return FALSE; } -gboolean ox_is_public_key_available(const char *const barejid) { +gboolean +ox_is_public_key_available(const char* const barejid) +{ return FALSE; } -GHashTable* ox_gpg_public_keys(void) { +GHashTable* +ox_gpg_public_keys(void) +{ return NULL; } diff --git a/tests/unittests/test_autocomplete.c b/tests/unittests/test_autocomplete.c index 54b6af81..599cf390 100644 --- a/tests/unittests/test_autocomplete.c +++ b/tests/unittests/test_autocomplete.c @@ -8,31 +8,35 @@ #include "xmpp/contact.h" #include "tools/autocomplete.h" -void clear_empty(void **state) +void +clear_empty(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_free(ac); } -void reset_after_create(void **state) +void +reset_after_create(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_reset(ac); autocomplete_free(ac); } -void find_after_create(void **state) +void +find_after_create(void** state) { Autocomplete ac = autocomplete_new(); - char *result = autocomplete_complete(ac, "hello", TRUE, FALSE); + char* result = autocomplete_complete(ac, "hello", TRUE, FALSE); autocomplete_free(ac); free(result); } -void get_after_create_returns_null(void **state) +void +get_after_create_returns_null(void** state) { Autocomplete ac = autocomplete_new(); - GList *result = autocomplete_create_list(ac); + GList* result = autocomplete_create_list(ac); assert_null(result); @@ -40,11 +44,12 @@ void get_after_create_returns_null(void **state) g_list_free_full(result, free); } -void add_one_and_complete(void **state) +void +add_one_and_complete(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_add(ac, "Hello"); - char *result = autocomplete_complete(ac, "Hel", TRUE, FALSE); + char* result = autocomplete_complete(ac, "Hel", TRUE, FALSE); assert_string_equal("Hello", result); @@ -52,12 +57,13 @@ void add_one_and_complete(void **state) free(result); } -void add_two_and_complete_returns_first(void **state) +void +add_two_and_complete_returns_first(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_add(ac, "Hello"); autocomplete_add(ac, "Help"); - char *result = autocomplete_complete(ac, "Hel", TRUE, FALSE); + char* result = autocomplete_complete(ac, "Hel", TRUE, FALSE); assert_string_equal("Hello", result); @@ -65,13 +71,14 @@ void add_two_and_complete_returns_first(void **state) free(result); } -void add_two_and_complete_returns_second(void **state) +void +add_two_and_complete_returns_second(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_add(ac, "Hello"); autocomplete_add(ac, "Help"); - char *result1 = autocomplete_complete(ac, "Hel", TRUE, FALSE); - char *result2 = autocomplete_complete(ac, result1, TRUE, FALSE); + char* result1 = autocomplete_complete(ac, "Hel", TRUE, FALSE); + char* result2 = autocomplete_complete(ac, result1, TRUE, FALSE); assert_string_equal("Help", result2); @@ -80,12 +87,13 @@ void add_two_and_complete_returns_second(void **state) free(result2); } -void add_two_adds_two(void **state) +void +add_two_adds_two(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_add(ac, "Hello"); autocomplete_add(ac, "Help"); - GList *result = autocomplete_create_list(ac); + GList* result = autocomplete_create_list(ac); assert_int_equal(2, g_list_length(result)); @@ -93,12 +101,13 @@ void add_two_adds_two(void **state) g_list_free_full(result, free); } -void add_two_same_adds_one(void **state) +void +add_two_same_adds_one(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_add(ac, "Hello"); autocomplete_add(ac, "Hello"); - GList *result = autocomplete_create_list(ac); + GList* result = autocomplete_create_list(ac); assert_int_equal(1, g_list_length(result)); @@ -106,16 +115,17 @@ void add_two_same_adds_one(void **state) g_list_free_full(result, free); } -void add_two_same_updates(void **state) +void +add_two_same_updates(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_add(ac, "Hello"); autocomplete_add(ac, "Hello"); - GList *result = autocomplete_create_list(ac); + GList* result = autocomplete_create_list(ac); - GList *first = g_list_nth(result, 0); + GList* first = g_list_nth(result, 0); - char *str = first->data; + char* str = first->data; assert_string_equal("Hello", str); @@ -123,12 +133,13 @@ void add_two_same_updates(void **state) g_list_free_full(result, free); } -void complete_accented_with_accented(void **state) +void +complete_accented_with_accented(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_add(ac, "èâîô"); - char *result = autocomplete_complete(ac, "èâ", TRUE, FALSE); + char* result = autocomplete_complete(ac, "èâ", TRUE, FALSE); assert_string_equal("èâîô", result); @@ -136,12 +147,13 @@ void complete_accented_with_accented(void **state) free(result); } -void complete_accented_with_base(void **state) +void +complete_accented_with_base(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_add(ac, "èâîô"); - char *result = autocomplete_complete(ac, "ea", TRUE, FALSE); + char* result = autocomplete_complete(ac, "ea", TRUE, FALSE); assert_string_equal("èâîô", result); @@ -149,14 +161,15 @@ void complete_accented_with_base(void **state) free(result); } -void complete_both_with_accented(void **state) +void +complete_both_with_accented(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_add(ac, "eaooooo"); autocomplete_add(ac, "èâîô"); - char *result1 = autocomplete_complete(ac, "èâ", TRUE, FALSE); - char *result2 = autocomplete_complete(ac, result1, TRUE, FALSE); + char* result1 = autocomplete_complete(ac, "èâ", TRUE, FALSE); + char* result2 = autocomplete_complete(ac, result1, TRUE, FALSE); assert_string_equal("èâîô", result2); @@ -165,14 +178,15 @@ void complete_both_with_accented(void **state) free(result2); } -void complete_both_with_base(void **state) +void +complete_both_with_base(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_add(ac, "eaooooo"); autocomplete_add(ac, "èâîô"); - char *result1 = autocomplete_complete(ac, "ea", TRUE, FALSE); - char *result2 = autocomplete_complete(ac, result1, TRUE, FALSE); + char* result1 = autocomplete_complete(ac, "ea", TRUE, FALSE); + char* result2 = autocomplete_complete(ac, result1, TRUE, FALSE); assert_string_equal("èâîô", result2); @@ -182,12 +196,13 @@ void complete_both_with_base(void **state) free(result2); } -void complete_ignores_case(void **state) +void +complete_ignores_case(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_add(ac, "MyBuddy"); - char *result = autocomplete_complete(ac, "myb", TRUE, FALSE); + char* result = autocomplete_complete(ac, "myb", TRUE, FALSE); assert_string_equal("MyBuddy", result); @@ -195,17 +210,18 @@ void complete_ignores_case(void **state) free(result); } -void complete_previous(void **state) +void +complete_previous(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_add(ac, "MyBuddy1"); autocomplete_add(ac, "MyBuddy2"); autocomplete_add(ac, "MyBuddy3"); - char *result1 = autocomplete_complete(ac, "myb", TRUE, FALSE); - char *result2 = autocomplete_complete(ac, result1, TRUE, FALSE); - char *result3 = autocomplete_complete(ac, result2, TRUE, FALSE); - char *result4 = autocomplete_complete(ac, result3, TRUE, TRUE); + char* result1 = autocomplete_complete(ac, "myb", TRUE, FALSE); + char* result2 = autocomplete_complete(ac, result1, TRUE, FALSE); + char* result3 = autocomplete_complete(ac, result2, TRUE, FALSE); + char* result4 = autocomplete_complete(ac, result3, TRUE, TRUE); assert_string_equal("MyBuddy2", result4); diff --git a/tests/unittests/test_autocomplete.h b/tests/unittests/test_autocomplete.h index 746ea2af..3fac7038 100644 --- a/tests/unittests/test_autocomplete.h +++ b/tests/unittests/test_autocomplete.h @@ -1,16 +1,16 @@ -void clear_empty(void **state); -void reset_after_create(void **state); -void find_after_create(void **state); -void get_after_create_returns_null(void **state); -void add_one_and_complete(void **state); -void add_two_and_complete_returns_first(void **state); -void add_two_and_complete_returns_second(void **state); -void add_two_adds_two(void **state); -void add_two_same_adds_one(void **state); -void add_two_same_updates(void **state); -void complete_accented_with_accented(void **state); -void complete_accented_with_base(void **state); -void complete_both_with_accented(void **state); -void complete_both_with_base(void **state); -void complete_ignores_case(void **state); -void complete_previous(void **state); +void clear_empty(void** state); +void reset_after_create(void** state); +void find_after_create(void** state); +void get_after_create_returns_null(void** state); +void add_one_and_complete(void** state); +void add_two_and_complete_returns_first(void** state); +void add_two_and_complete_returns_second(void** state); +void add_two_adds_two(void** state); +void add_two_same_adds_one(void** state); +void add_two_same_updates(void** state); +void complete_accented_with_accented(void** state); +void complete_accented_with_base(void** state); +void complete_both_with_accented(void** state); +void complete_both_with_base(void** state); +void complete_ignores_case(void** state); +void complete_previous(void** state); diff --git a/tests/unittests/test_callbacks.c b/tests/unittests/test_callbacks.c index ec411863..3c5267fe 100644 --- a/tests/unittests/test_callbacks.c +++ b/tests/unittests/test_callbacks.c @@ -9,10 +9,11 @@ #include "plugins/callbacks.h" #include "plugins/plugins.h" -void returns_no_commands(void **state) +void +returns_no_commands(void** state) { callbacks_init(); - GList *commands = plugins_get_command_names(); + GList* commands = plugins_get_command_names(); assert_true(commands == NULL); @@ -20,29 +21,30 @@ void returns_no_commands(void **state) g_list_free(commands); } -void returns_commands(void **state) +void +returns_commands(void** state) { callbacks_init(); - PluginCommand *command1 = malloc(sizeof(PluginCommand)); + PluginCommand* command1 = malloc(sizeof(PluginCommand)); command1->command_name = strdup("command1"); callbacks_add_command("plugin1", command1); - PluginCommand *command2 = malloc(sizeof(PluginCommand)); + PluginCommand* command2 = malloc(sizeof(PluginCommand)); command2->command_name = strdup("command2"); callbacks_add_command("plugin1", command2); - PluginCommand *command3 = malloc(sizeof(PluginCommand)); + PluginCommand* command3 = malloc(sizeof(PluginCommand)); command3->command_name = strdup("command3"); callbacks_add_command("plugin2", command3); - GList *names = plugins_get_command_names(); + GList* names = plugins_get_command_names(); assert_true(g_list_length(names) == 3); gboolean foundCommand1 = FALSE; gboolean foundCommand2 = FALSE; gboolean foundCommand3 = FALSE; - GList *curr = names; + GList* curr = names; while (curr) { if (g_strcmp0(curr->data, "command1") == 0) { foundCommand1 = TRUE; diff --git a/tests/unittests/test_callbacks.h b/tests/unittests/test_callbacks.h index 35751d2e..27130241 100644 --- a/tests/unittests/test_callbacks.h +++ b/tests/unittests/test_callbacks.h @@ -1,2 +1,2 @@ -void returns_no_commands(void **state); -void returns_commands(void **state); +void returns_no_commands(void** state); +void returns_commands(void** state); diff --git a/tests/unittests/test_chat_session.c b/tests/unittests/test_chat_session.c index fd934737..26845dbc 100644 --- a/tests/unittests/test_chat_session.c +++ b/tests/unittests/test_chat_session.c @@ -7,45 +7,49 @@ #include "xmpp/chat_session.h" -void returns_false_when_chat_session_does_not_exist(void **state) +void +returns_false_when_chat_session_does_not_exist(void** state) { - ChatSession *session = chat_session_get("somejid@server.org"); + ChatSession* session = chat_session_get("somejid@server.org"); assert_null(session); } -void creates_chat_session_on_recipient_activity(void **state) +void +creates_chat_session_on_recipient_activity(void** state) { - char *barejid = "myjid@server.org"; - char *resource = "tablet"; + char* barejid = "myjid@server.org"; + char* resource = "tablet"; chat_session_recipient_active(barejid, resource, FALSE); - ChatSession *session = chat_session_get(barejid); + ChatSession* session = chat_session_get(barejid); assert_non_null(session); assert_string_equal(session->resource, resource); } -void replaces_chat_session_on_recipient_activity_with_different_resource(void **state) +void +replaces_chat_session_on_recipient_activity_with_different_resource(void** state) { - char *barejid = "myjid@server.org"; - char *resource1 = "tablet"; - char *resource2 = "mobile"; + char* barejid = "myjid@server.org"; + char* resource1 = "tablet"; + char* resource2 = "mobile"; chat_session_recipient_active(barejid, resource1, FALSE); chat_session_recipient_active(barejid, resource2, FALSE); - ChatSession *session = chat_session_get(barejid); + ChatSession* session = chat_session_get(barejid); assert_string_equal(session->resource, resource2); } -void removes_chat_session(void **state) +void +removes_chat_session(void** state) { - char *barejid = "myjid@server.org"; - char *resource1 = "laptop"; + char* barejid = "myjid@server.org"; + char* resource1 = "laptop"; chat_session_recipient_active(barejid, resource1, FALSE); chat_session_remove(barejid); - ChatSession *session = chat_session_get(barejid); + ChatSession* session = chat_session_get(barejid); assert_null(session); } diff --git a/tests/unittests/test_chat_session.h b/tests/unittests/test_chat_session.h index 4ce03fd5..7f7072f8 100644 --- a/tests/unittests/test_chat_session.h +++ b/tests/unittests/test_chat_session.h @@ -1,4 +1,4 @@ -void returns_false_when_chat_session_does_not_exist(void **state); -void creates_chat_session_on_recipient_activity(void **state); -void replaces_chat_session_on_recipient_activity_with_different_resource(void **state); -void removes_chat_session(void **state); \ No newline at end of file +void returns_false_when_chat_session_does_not_exist(void** state); +void creates_chat_session_on_recipient_activity(void** state); +void replaces_chat_session_on_recipient_activity_with_different_resource(void** state); +void removes_chat_session(void** state); \ No newline at end of file diff --git a/tests/unittests/test_cmd_account.c b/tests/unittests/test_cmd_account.c index 032f4364..69721311 100644 --- a/tests/unittests/test_cmd_account.c +++ b/tests/unittests/test_cmd_account.c @@ -17,9 +17,10 @@ #define CMD_ACCOUNT "/account" -void cmd_account_shows_usage_when_not_connected_and_no_args(void **state) +void +cmd_account_shows_usage_when_not_connected_and_no_args(void** state) { - gchar *args[] = { NULL }; + gchar* args[] = { NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -29,12 +30,12 @@ void cmd_account_shows_usage_when_not_connected_and_no_args(void **state) assert_true(result); } - -void cmd_account_shows_account_when_connected_and_no_args(void **state) +void +cmd_account_shows_account_when_connected_and_no_args(void** state) { - ProfAccount *account = account_new("jabber_org", "me@jabber.org", NULL, NULL, - TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); - gchar *args[] = { NULL }; + ProfAccount* account = account_new("jabber_org", "me@jabber.org", NULL, NULL, + TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + gchar* args[] = { NULL }; will_return(connection_get_status, JABBER_CONNECTED); will_return(session_get_account_name, "account_name"); @@ -47,11 +48,12 @@ void cmd_account_shows_account_when_connected_and_no_args(void **state) assert_true(result); } -void cmd_account_list_shows_accounts(void **state) +void +cmd_account_list_shows_accounts(void** state) { - gchar *args[] = { "list", NULL }; + gchar* args[] = { "list", NULL }; - gchar **accounts = malloc(sizeof(gchar *) * 4); + gchar** accounts = malloc(sizeof(gchar*) * 4); accounts[0] = strdup("account1"); accounts[1] = strdup("account2"); accounts[2] = strdup("account3"); @@ -65,9 +67,10 @@ void cmd_account_list_shows_accounts(void **state) assert_true(result); } -void cmd_account_show_shows_usage_when_no_arg(void **state) +void +cmd_account_show_shows_usage_when_no_arg(void** state) { - gchar *args[] = { "show", NULL }; + gchar* args[] = { "show", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT); @@ -75,9 +78,10 @@ void cmd_account_show_shows_usage_when_no_arg(void **state) assert_true(result); } -void cmd_account_show_shows_message_when_account_does_not_exist(void **state) +void +cmd_account_show_shows_message_when_account_does_not_exist(void** state) { - gchar *args[] = { "show", "account_name", NULL }; + gchar* args[] = { "show", "account_name", NULL }; expect_any(accounts_get_account, name); will_return(accounts_get_account, NULL); @@ -89,11 +93,12 @@ void cmd_account_show_shows_message_when_account_does_not_exist(void **state) assert_true(result); } -void cmd_account_show_shows_account_when_exists(void **state) +void +cmd_account_show_shows_account_when_exists(void** state) { - gchar *args[] = { "show", "account_name", NULL }; - ProfAccount *account = account_new("jabber_org", "me@jabber.org", NULL, NULL, - TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + gchar* args[] = { "show", "account_name", NULL }; + ProfAccount* account = account_new("jabber_org", "me@jabber.org", NULL, NULL, + TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); expect_any(accounts_get_account, name); will_return(accounts_get_account, account); @@ -104,9 +109,10 @@ void cmd_account_show_shows_account_when_exists(void **state) assert_true(result); } -void cmd_account_add_shows_usage_when_no_arg(void **state) +void +cmd_account_add_shows_usage_when_no_arg(void** state) { - gchar *args[] = { "add", NULL }; + gchar* args[] = { "add", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT); @@ -114,9 +120,10 @@ void cmd_account_add_shows_usage_when_no_arg(void **state) assert_true(result); } -void cmd_account_add_adds_account(void **state) +void +cmd_account_add_adds_account(void** state) { - gchar *args[] = { "add", "new_account", NULL }; + gchar* args[] = { "add", "new_account", NULL }; expect_string(accounts_add, jid, "new_account"); expect_value(accounts_add, altdomain, NULL); @@ -128,9 +135,10 @@ void cmd_account_add_adds_account(void **state) assert_true(result); } -void cmd_account_enable_shows_usage_when_no_arg(void **state) +void +cmd_account_enable_shows_usage_when_no_arg(void** state) { - gchar *args[] = { "enable", NULL }; + gchar* args[] = { "enable", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT); @@ -138,9 +146,10 @@ void cmd_account_enable_shows_usage_when_no_arg(void **state) assert_true(result); } -void cmd_account_enable_enables_account(void **state) +void +cmd_account_enable_enables_account(void** state) { - gchar *args[] = { "enable", "account_name", NULL }; + gchar* args[] = { "enable", "account_name", NULL }; expect_string(accounts_enable, name, "account_name"); will_return(accounts_enable, TRUE); @@ -152,9 +161,10 @@ void cmd_account_enable_enables_account(void **state) assert_true(result); } -void cmd_account_enable_shows_message_when_account_doesnt_exist(void **state) +void +cmd_account_enable_shows_message_when_account_doesnt_exist(void** state) { - gchar *args[] = { "enable", "account_name", NULL }; + gchar* args[] = { "enable", "account_name", NULL }; expect_any(accounts_enable, name); will_return(accounts_enable, FALSE); @@ -166,9 +176,10 @@ void cmd_account_enable_shows_message_when_account_doesnt_exist(void **state) assert_true(result); } -void cmd_account_disable_shows_usage_when_no_arg(void **state) +void +cmd_account_disable_shows_usage_when_no_arg(void** state) { - gchar *args[] = { "disable", NULL }; + gchar* args[] = { "disable", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT); @@ -176,9 +187,10 @@ void cmd_account_disable_shows_usage_when_no_arg(void **state) assert_true(result); } -void cmd_account_disable_disables_account(void **state) +void +cmd_account_disable_disables_account(void** state) { - gchar *args[] = { "disable", "account_name", NULL }; + gchar* args[] = { "disable", "account_name", NULL }; expect_string(accounts_disable, name, "account_name"); will_return(accounts_disable, TRUE); @@ -190,9 +202,10 @@ void cmd_account_disable_disables_account(void **state) assert_true(result); } -void cmd_account_disable_shows_message_when_account_doesnt_exist(void **state) +void +cmd_account_disable_shows_message_when_account_doesnt_exist(void** state) { - gchar *args[] = { "disable", "account_name", NULL }; + gchar* args[] = { "disable", "account_name", NULL }; expect_any(accounts_disable, name); will_return(accounts_disable, FALSE); @@ -204,9 +217,10 @@ void cmd_account_disable_shows_message_when_account_doesnt_exist(void **state) assert_true(result); } -void cmd_account_rename_shows_usage_when_no_args(void **state) +void +cmd_account_rename_shows_usage_when_no_args(void** state) { - gchar *args[] = { "rename", NULL }; + gchar* args[] = { "rename", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT); @@ -214,9 +228,10 @@ void cmd_account_rename_shows_usage_when_no_args(void **state) assert_true(result); } -void cmd_account_rename_shows_usage_when_one_arg(void **state) +void +cmd_account_rename_shows_usage_when_one_arg(void** state) { - gchar *args[] = { "rename", "original_name", NULL }; + gchar* args[] = { "rename", "original_name", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT); @@ -224,9 +239,10 @@ void cmd_account_rename_shows_usage_when_one_arg(void **state) assert_true(result); } -void cmd_account_rename_renames_account(void **state) +void +cmd_account_rename_renames_account(void** state) { - gchar *args[] = { "rename", "original_name", "new_name", NULL }; + gchar* args[] = { "rename", "original_name", "new_name", NULL }; expect_string(accounts_rename, account_name, "original_name"); expect_string(accounts_rename, new_name, "new_name"); @@ -239,9 +255,10 @@ void cmd_account_rename_renames_account(void **state) assert_true(result); } -void cmd_account_rename_shows_message_when_not_renamed(void **state) +void +cmd_account_rename_shows_message_when_not_renamed(void** state) { - gchar *args[] = { "rename", "original_name", "new_name", NULL }; + gchar* args[] = { "rename", "original_name", "new_name", NULL }; expect_any(accounts_rename, account_name); expect_any(accounts_rename, new_name); @@ -254,9 +271,10 @@ void cmd_account_rename_shows_message_when_not_renamed(void **state) assert_true(result); } -void cmd_account_set_shows_usage_when_no_args(void **state) +void +cmd_account_set_shows_usage_when_no_args(void** state) { - gchar *args[] = { "set", NULL }; + gchar* args[] = { "set", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT); @@ -264,9 +282,10 @@ void cmd_account_set_shows_usage_when_no_args(void **state) assert_true(result); } -void cmd_account_set_shows_usage_when_one_arg(void **state) +void +cmd_account_set_shows_usage_when_one_arg(void** state) { - gchar *args[] = { "set", "a_account", NULL }; + gchar* args[] = { "set", "a_account", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT); @@ -274,9 +293,10 @@ void cmd_account_set_shows_usage_when_one_arg(void **state) assert_true(result); } -void cmd_account_set_shows_usage_when_two_args(void **state) +void +cmd_account_set_shows_usage_when_two_args(void** state) { - gchar *args[] = { "set", "a_account", "a_property", NULL }; + gchar* args[] = { "set", "a_account", "a_property", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT); @@ -284,9 +304,10 @@ void cmd_account_set_shows_usage_when_two_args(void **state) assert_true(result); } -void cmd_account_set_shows_message_when_account_doesnt_exist(void **state) +void +cmd_account_set_shows_message_when_account_doesnt_exist(void** state) { - gchar *args[] = { "set", "a_account", "a_property", "a_value", NULL }; + gchar* args[] = { "set", "a_account", "a_property", "a_value", NULL }; expect_string(accounts_account_exists, account_name, "a_account"); will_return(accounts_account_exists, FALSE); @@ -298,9 +319,10 @@ void cmd_account_set_shows_message_when_account_doesnt_exist(void **state) assert_true(result); } -void cmd_account_set_jid_shows_message_for_malformed_jid(void **state) +void +cmd_account_set_jid_shows_message_for_malformed_jid(void** state) { - gchar *args[] = { "set", "a_account", "jid", "@malformed", NULL }; + gchar* args[] = { "set", "a_account", "jid", "@malformed", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -311,9 +333,10 @@ void cmd_account_set_jid_shows_message_for_malformed_jid(void **state) assert_true(result); } -void cmd_account_set_jid_sets_barejid(void **state) +void +cmd_account_set_jid_sets_barejid(void** state) { - gchar *args[] = { "set", "a_account", "jid", "a_local@a_domain", NULL }; + gchar* args[] = { "set", "a_account", "jid", "a_local@a_domain", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -328,9 +351,10 @@ void cmd_account_set_jid_sets_barejid(void **state) assert_true(result); } -void cmd_account_set_jid_sets_resource(void **state) +void +cmd_account_set_jid_sets_resource(void** state) { - gchar *args[] = { "set", "a_account", "jid", "a_local@a_domain/a_resource", NULL }; + gchar* args[] = { "set", "a_account", "jid", "a_local@a_domain/a_resource", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -350,9 +374,10 @@ void cmd_account_set_jid_sets_resource(void **state) assert_true(result); } -void cmd_account_set_server_sets_server(void **state) +void +cmd_account_set_server_sets_server(void** state) { - gchar *args[] = { "set", "a_account", "server", "a_server", NULL }; + gchar* args[] = { "set", "a_account", "server", "a_server", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -367,9 +392,10 @@ void cmd_account_set_server_sets_server(void **state) assert_true(result); } -void cmd_account_set_resource_sets_resource(void **state) +void +cmd_account_set_resource_sets_resource(void** state) { - gchar *args[] = { "set", "a_account", "resource", "a_resource", NULL }; + gchar* args[] = { "set", "a_account", "resource", "a_resource", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -386,9 +412,10 @@ void cmd_account_set_resource_sets_resource(void **state) assert_true(result); } -void cmd_account_set_resource_sets_resource_with_online_message(void **state) +void +cmd_account_set_resource_sets_resource_with_online_message(void** state) { - gchar *args[] = { "set", "a_account", "resource", "a_resource", NULL }; + gchar* args[] = { "set", "a_account", "resource", "a_resource", NULL }; will_return(connection_get_status, JABBER_CONNECTED); @@ -405,12 +432,12 @@ void cmd_account_set_resource_sets_resource_with_online_message(void **state) assert_true(result); } -void cmd_account_set_password_sets_password(void **state) +void +cmd_account_set_password_sets_password(void** state) { - gchar *args[] = { "set", "a_account", "password", "a_password", NULL }; - ProfAccount *account = account_new("a_account", NULL, NULL, NULL, - TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); - + gchar* args[] = { "set", "a_account", "password", "a_password", NULL }; + ProfAccount* account = account_new("a_account", NULL, NULL, NULL, + TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -428,11 +455,12 @@ void cmd_account_set_password_sets_password(void **state) assert_true(result); } -void cmd_account_set_eval_password_sets_eval_password(void **state) +void +cmd_account_set_eval_password_sets_eval_password(void** state) { - gchar *args[] = { "set", "a_account", "eval_password", "a_password", NULL }; - ProfAccount *account = account_new("a_account", NULL, NULL, NULL, - TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + gchar* args[] = { "set", "a_account", "eval_password", "a_password", NULL }; + ProfAccount* account = account_new("a_account", NULL, NULL, NULL, + TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -450,10 +478,12 @@ void cmd_account_set_eval_password_sets_eval_password(void **state) assert_true(result); } -void cmd_account_set_password_when_eval_password_set(void **state) { - gchar *args[] = { "set", "a_account", "password", "a_password", NULL }; - ProfAccount *account = account_new("a_account", NULL, NULL, "a_password", - TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); +void +cmd_account_set_password_when_eval_password_set(void** state) +{ + gchar* args[] = { "set", "a_account", "password", "a_password", NULL }; + ProfAccount* account = account_new("a_account", NULL, NULL, "a_password", + TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -467,10 +497,12 @@ void cmd_account_set_password_when_eval_password_set(void **state) { assert_true(result); } -void cmd_account_set_eval_password_when_password_set(void **state) { - gchar *args[] = { "set", "a_account", "eval_password", "a_password", NULL }; - ProfAccount *account = account_new("a_account", NULL, "a_password", NULL, - TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); +void +cmd_account_set_eval_password_when_password_set(void** state) +{ + gchar* args[] = { "set", "a_account", "eval_password", "a_password", NULL }; + ProfAccount* account = account_new("a_account", NULL, "a_password", NULL, + TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -484,9 +516,10 @@ void cmd_account_set_eval_password_when_password_set(void **state) { assert_true(result); } -void cmd_account_set_muc_sets_muc(void **state) +void +cmd_account_set_muc_sets_muc(void** state) { - gchar *args[] = { "set", "a_account", "muc", "a_muc", NULL }; + gchar* args[] = { "set", "a_account", "muc", "a_muc", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -501,9 +534,10 @@ void cmd_account_set_muc_sets_muc(void **state) assert_true(result); } -void cmd_account_set_nick_sets_nick(void **state) +void +cmd_account_set_nick_sets_nick(void** state) { - gchar *args[] = { "set", "a_account", "nick", "a_nick", NULL }; + gchar* args[] = { "set", "a_account", "nick", "a_nick", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -518,9 +552,10 @@ void cmd_account_set_nick_sets_nick(void **state) assert_true(result); } -void cmd_account_show_message_for_missing_otr_policy(void **state) +void +cmd_account_show_message_for_missing_otr_policy(void** state) { - gchar *args[] = { "set", "a_account", "otr", NULL }; + gchar* args[] = { "set", "a_account", "otr", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT); @@ -528,9 +563,10 @@ void cmd_account_show_message_for_missing_otr_policy(void **state) assert_true(result); } -void cmd_account_show_message_for_invalid_otr_policy(void **state) +void +cmd_account_show_message_for_invalid_otr_policy(void** state) { - gchar *args[] = { "set", "a_account", "otr", "bad_otr_policy", NULL }; + gchar* args[] = { "set", "a_account", "otr", "bad_otr_policy", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -541,9 +577,10 @@ void cmd_account_show_message_for_invalid_otr_policy(void **state) assert_true(result); } -void cmd_account_set_otr_sets_otr(void **state) +void +cmd_account_set_otr_sets_otr(void** state) { - gchar *args[] = { "set", "a_account", "otr", "opportunistic", NULL }; + gchar* args[] = { "set", "a_account", "otr", "opportunistic", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -558,9 +595,10 @@ void cmd_account_set_otr_sets_otr(void **state) assert_true(result); } -void cmd_account_set_status_shows_message_when_invalid_status(void **state) +void +cmd_account_set_status_shows_message_when_invalid_status(void** state) { - gchar *args[] = { "set", "a_account", "status", "bad_status", NULL }; + gchar* args[] = { "set", "a_account", "status", "bad_status", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -572,9 +610,10 @@ void cmd_account_set_status_shows_message_when_invalid_status(void **state) assert_true(result); } -void cmd_account_set_status_sets_status_when_valid(void **state) +void +cmd_account_set_status_sets_status_when_valid(void** state) { - gchar *args[] = { "set", "a_account", "status", "away", NULL }; + gchar* args[] = { "set", "a_account", "status", "away", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -589,9 +628,10 @@ void cmd_account_set_status_sets_status_when_valid(void **state) assert_true(result); } -void cmd_account_set_status_sets_status_when_last(void **state) +void +cmd_account_set_status_sets_status_when_last(void** state) { - gchar *args[] = { "set", "a_account", "status", "last", NULL }; + gchar* args[] = { "set", "a_account", "status", "last", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -606,9 +646,10 @@ void cmd_account_set_status_sets_status_when_last(void **state) assert_true(result); } -void cmd_account_set_invalid_presence_string_priority_shows_message(void **state) +void +cmd_account_set_invalid_presence_string_priority_shows_message(void** state) { - gchar *args[] = { "set", "a_account", "blah", "10", NULL }; + gchar* args[] = { "set", "a_account", "blah", "10", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -620,9 +661,10 @@ void cmd_account_set_invalid_presence_string_priority_shows_message(void **state assert_true(result); } -void cmd_account_set_last_priority_shows_message(void **state) +void +cmd_account_set_last_priority_shows_message(void** state) { - gchar *args[] = { "set", "a_account", "last", "10", NULL }; + gchar* args[] = { "set", "a_account", "last", "10", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -634,9 +676,10 @@ void cmd_account_set_last_priority_shows_message(void **state) assert_true(result); } -void cmd_account_set_online_priority_sets_preference(void **state) +void +cmd_account_set_online_priority_sets_preference(void** state) { - gchar *args[] = { "set", "a_account", "online", "10", NULL }; + gchar* args[] = { "set", "a_account", "online", "10", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -653,9 +696,10 @@ void cmd_account_set_online_priority_sets_preference(void **state) assert_true(result); } -void cmd_account_set_chat_priority_sets_preference(void **state) +void +cmd_account_set_chat_priority_sets_preference(void** state) { - gchar *args[] = { "set", "a_account", "chat", "10", NULL }; + gchar* args[] = { "set", "a_account", "chat", "10", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -672,9 +716,10 @@ void cmd_account_set_chat_priority_sets_preference(void **state) assert_true(result); } -void cmd_account_set_away_priority_sets_preference(void **state) +void +cmd_account_set_away_priority_sets_preference(void** state) { - gchar *args[] = { "set", "a_account", "away", "10", NULL }; + gchar* args[] = { "set", "a_account", "away", "10", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -691,9 +736,10 @@ void cmd_account_set_away_priority_sets_preference(void **state) assert_true(result); } -void cmd_account_set_xa_priority_sets_preference(void **state) +void +cmd_account_set_xa_priority_sets_preference(void** state) { - gchar *args[] = { "set", "a_account", "xa", "10", NULL }; + gchar* args[] = { "set", "a_account", "xa", "10", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -710,9 +756,10 @@ void cmd_account_set_xa_priority_sets_preference(void **state) assert_true(result); } -void cmd_account_set_dnd_priority_sets_preference(void **state) +void +cmd_account_set_dnd_priority_sets_preference(void** state) { - gchar *args[] = { "set", "a_account", "dnd", "10", NULL }; + gchar* args[] = { "set", "a_account", "dnd", "10", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -729,9 +776,10 @@ void cmd_account_set_dnd_priority_sets_preference(void **state) assert_true(result); } -void cmd_account_set_priority_too_low_shows_message(void **state) +void +cmd_account_set_priority_too_low_shows_message(void** state) { - gchar *args[] = { "set", "a_account", "online", "-150", NULL }; + gchar* args[] = { "set", "a_account", "online", "-150", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -742,9 +790,10 @@ void cmd_account_set_priority_too_low_shows_message(void **state) assert_true(result); } -void cmd_account_set_priority_too_high_shows_message(void **state) +void +cmd_account_set_priority_too_high_shows_message(void** state) { - gchar *args[] = { "set", "a_account", "online", "150", NULL }; + gchar* args[] = { "set", "a_account", "online", "150", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -755,9 +804,10 @@ void cmd_account_set_priority_too_high_shows_message(void **state) assert_true(result); } -void cmd_account_set_priority_when_not_number_shows_message(void **state) +void +cmd_account_set_priority_when_not_number_shows_message(void** state) { - gchar *args[] = { "set", "a_account", "online", "abc", NULL }; + gchar* args[] = { "set", "a_account", "online", "abc", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -768,9 +818,10 @@ void cmd_account_set_priority_when_not_number_shows_message(void **state) assert_true(result); } -void cmd_account_set_priority_when_empty_shows_message(void **state) +void +cmd_account_set_priority_when_empty_shows_message(void** state) { - gchar *args[] = { "set", "a_account", "online", "", NULL }; + gchar* args[] = { "set", "a_account", "online", "", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -781,9 +832,10 @@ void cmd_account_set_priority_when_empty_shows_message(void **state) assert_true(result); } -void cmd_account_set_priority_updates_presence_when_account_connected_with_presence(void **state) +void +cmd_account_set_priority_updates_presence_when_account_connected_with_presence(void** state) { - gchar *args[] = { "set", "a_account", "online", "10", NULL }; + gchar* args[] = { "set", "a_account", "online", "10", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -799,8 +851,8 @@ void cmd_account_set_priority_updates_presence_when_account_connected_with_prese will_return(session_get_account_name, "a_account"); #ifdef HAVE_LIBGPGME - ProfAccount *account = account_new("a_account", "a_jid", NULL, NULL, TRUE, NULL, 5222, "a_resource", - NULL, NULL, 10, 10, 10, 10, 10, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ProfAccount* account = account_new("a_account", "a_jid", NULL, NULL, TRUE, NULL, 5222, "a_resource", + NULL, NULL, 10, 10, 10, 10, 10, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); will_return(session_get_account_name, "a_account"); expect_any(accounts_get_account, name); @@ -813,14 +865,14 @@ void cmd_account_set_priority_updates_presence_when_account_connected_with_prese expect_cons_show("Updated online priority for account a_account: 10"); expect_cons_show(""); - gboolean result = cmd_account_set(NULL, CMD_ACCOUNT, args); assert_true(result); } -void cmd_account_clear_shows_usage_when_no_args(void **state) +void +cmd_account_clear_shows_usage_when_no_args(void** state) { - gchar *args[] = { "clear", NULL }; + gchar* args[] = { "clear", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT); @@ -828,9 +880,10 @@ void cmd_account_clear_shows_usage_when_no_args(void **state) assert_true(result); } -void cmd_account_clear_shows_usage_when_one_arg(void **state) +void +cmd_account_clear_shows_usage_when_one_arg(void** state) { - gchar *args[] = { "clear", "a_account", NULL }; + gchar* args[] = { "clear", "a_account", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT); @@ -838,9 +891,10 @@ void cmd_account_clear_shows_usage_when_one_arg(void **state) assert_true(result); } -void cmd_account_clear_shows_message_when_account_doesnt_exist(void **state) +void +cmd_account_clear_shows_message_when_account_doesnt_exist(void** state) { - gchar *args[] = { "clear", "a_account", "a_property", NULL }; + gchar* args[] = { "clear", "a_account", "a_property", NULL }; expect_string(accounts_account_exists, account_name, "a_account"); will_return(accounts_account_exists, FALSE); @@ -852,9 +906,10 @@ void cmd_account_clear_shows_message_when_account_doesnt_exist(void **state) assert_true(result); } -void cmd_account_clear_shows_message_when_invalid_property(void **state) +void +cmd_account_clear_shows_message_when_invalid_property(void** state) { - gchar *args[] = { "clear", "a_account", "badproperty", NULL }; + gchar* args[] = { "clear", "a_account", "badproperty", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); diff --git a/tests/unittests/test_cmd_account.h b/tests/unittests/test_cmd_account.h index e8806c4f..7a8d1b42 100644 --- a/tests/unittests/test_cmd_account.h +++ b/tests/unittests/test_cmd_account.h @@ -1,56 +1,56 @@ -void cmd_account_shows_usage_when_not_connected_and_no_args(void **state); -void cmd_account_shows_account_when_connected_and_no_args(void **state); -void cmd_account_list_shows_accounts(void **state); -void cmd_account_show_shows_usage_when_no_arg(void **state); -void cmd_account_show_shows_message_when_account_does_not_exist(void **state); -void cmd_account_show_shows_account_when_exists(void **state); -void cmd_account_add_shows_usage_when_no_arg(void **state); -void cmd_account_add_adds_account(void **state); -void cmd_account_enable_shows_usage_when_no_arg(void **state); -void cmd_account_enable_enables_account(void **state); -void cmd_account_enable_shows_message_when_account_doesnt_exist(void **state); -void cmd_account_disable_shows_usage_when_no_arg(void **state); -void cmd_account_disable_disables_account(void **state); -void cmd_account_disable_shows_message_when_account_doesnt_exist(void **state); -void cmd_account_rename_shows_usage_when_no_args(void **state); -void cmd_account_rename_shows_usage_when_one_arg(void **state); -void cmd_account_rename_renames_account(void **state); -void cmd_account_rename_shows_message_when_not_renamed(void **state); -void cmd_account_set_shows_usage_when_no_args(void **state); -void cmd_account_set_shows_usage_when_one_arg(void **state); -void cmd_account_set_shows_usage_when_two_args(void **state); -void cmd_account_set_shows_message_when_account_doesnt_exist(void **state); -void cmd_account_set_jid_shows_message_for_malformed_jid(void **state); -void cmd_account_set_jid_sets_barejid(void **state); -void cmd_account_set_jid_sets_resource(void **state); -void cmd_account_set_server_sets_server(void **state); -void cmd_account_set_resource_sets_resource(void **state); -void cmd_account_set_resource_sets_resource_with_online_message(void **state); -void cmd_account_set_password_sets_password(void **state); -void cmd_account_set_eval_password_sets_eval_password(void **state); -void cmd_account_set_password_when_eval_password_set(void **state); -void cmd_account_set_eval_password_when_password_set(void **state); -void cmd_account_set_muc_sets_muc(void **state); -void cmd_account_set_nick_sets_nick(void **state); -void cmd_account_show_message_for_missing_otr_policy(void **state); -void cmd_account_show_message_for_invalid_otr_policy(void **state); -void cmd_account_set_otr_sets_otr(void **state); -void cmd_account_set_status_shows_message_when_invalid_status(void **state); -void cmd_account_set_status_sets_status_when_valid(void **state); -void cmd_account_set_status_sets_status_when_last(void **state); -void cmd_account_set_invalid_presence_string_priority_shows_message(void **state); -void cmd_account_set_last_priority_shows_message(void **state); -void cmd_account_set_online_priority_sets_preference(void **state); -void cmd_account_set_chat_priority_sets_preference(void **state); -void cmd_account_set_away_priority_sets_preference(void **state); -void cmd_account_set_xa_priority_sets_preference(void **state); -void cmd_account_set_dnd_priority_sets_preference(void **state); -void cmd_account_set_priority_too_low_shows_message(void **state); -void cmd_account_set_priority_too_high_shows_message(void **state); -void cmd_account_set_priority_when_not_number_shows_message(void **state); -void cmd_account_set_priority_when_empty_shows_message(void **state); -void cmd_account_set_priority_updates_presence_when_account_connected_with_presence(void **state); -void cmd_account_clear_shows_usage_when_no_args(void **state); -void cmd_account_clear_shows_usage_when_one_arg(void **state); -void cmd_account_clear_shows_message_when_account_doesnt_exist(void **state); -void cmd_account_clear_shows_message_when_invalid_property(void **state); +void cmd_account_shows_usage_when_not_connected_and_no_args(void** state); +void cmd_account_shows_account_when_connected_and_no_args(void** state); +void cmd_account_list_shows_accounts(void** state); +void cmd_account_show_shows_usage_when_no_arg(void** state); +void cmd_account_show_shows_message_when_account_does_not_exist(void** state); +void cmd_account_show_shows_account_when_exists(void** state); +void cmd_account_add_shows_usage_when_no_arg(void** state); +void cmd_account_add_adds_account(void** state); +void cmd_account_enable_shows_usage_when_no_arg(void** state); +void cmd_account_enable_enables_account(void** state); +void cmd_account_enable_shows_message_when_account_doesnt_exist(void** state); +void cmd_account_disable_shows_usage_when_no_arg(void** state); +void cmd_account_disable_disables_account(void** state); +void cmd_account_disable_shows_message_when_account_doesnt_exist(void** state); +void cmd_account_rename_shows_usage_when_no_args(void** state); +void cmd_account_rename_shows_usage_when_one_arg(void** state); +void cmd_account_rename_renames_account(void** state); +void cmd_account_rename_shows_message_when_not_renamed(void** state); +void cmd_account_set_shows_usage_when_no_args(void** state); +void cmd_account_set_shows_usage_when_one_arg(void** state); +void cmd_account_set_shows_usage_when_two_args(void** state); +void cmd_account_set_shows_message_when_account_doesnt_exist(void** state); +void cmd_account_set_jid_shows_message_for_malformed_jid(void** state); +void cmd_account_set_jid_sets_barejid(void** state); +void cmd_account_set_jid_sets_resource(void** state); +void cmd_account_set_server_sets_server(void** state); +void cmd_account_set_resource_sets_resource(void** state); +void cmd_account_set_resource_sets_resource_with_online_message(void** state); +void cmd_account_set_password_sets_password(void** state); +void cmd_account_set_eval_password_sets_eval_password(void** state); +void cmd_account_set_password_when_eval_password_set(void** state); +void cmd_account_set_eval_password_when_password_set(void** state); +void cmd_account_set_muc_sets_muc(void** state); +void cmd_account_set_nick_sets_nick(void** state); +void cmd_account_show_message_for_missing_otr_policy(void** state); +void cmd_account_show_message_for_invalid_otr_policy(void** state); +void cmd_account_set_otr_sets_otr(void** state); +void cmd_account_set_status_shows_message_when_invalid_status(void** state); +void cmd_account_set_status_sets_status_when_valid(void** state); +void cmd_account_set_status_sets_status_when_last(void** state); +void cmd_account_set_invalid_presence_string_priority_shows_message(void** state); +void cmd_account_set_last_priority_shows_message(void** state); +void cmd_account_set_online_priority_sets_preference(void** state); +void cmd_account_set_chat_priority_sets_preference(void** state); +void cmd_account_set_away_priority_sets_preference(void** state); +void cmd_account_set_xa_priority_sets_preference(void** state); +void cmd_account_set_dnd_priority_sets_preference(void** state); +void cmd_account_set_priority_too_low_shows_message(void** state); +void cmd_account_set_priority_too_high_shows_message(void** state); +void cmd_account_set_priority_when_not_number_shows_message(void** state); +void cmd_account_set_priority_when_empty_shows_message(void** state); +void cmd_account_set_priority_updates_presence_when_account_connected_with_presence(void** state); +void cmd_account_clear_shows_usage_when_no_args(void** state); +void cmd_account_clear_shows_usage_when_one_arg(void** state); +void cmd_account_clear_shows_message_when_account_doesnt_exist(void** state); +void cmd_account_clear_shows_message_when_invalid_property(void** state); diff --git a/tests/unittests/test_cmd_alias.c b/tests/unittests/test_cmd_alias.c index b7f27d3d..718bca2a 100644 --- a/tests/unittests/test_cmd_alias.c +++ b/tests/unittests/test_cmd_alias.c @@ -19,9 +19,10 @@ #define CMD_ALIAS "/alias" -void cmd_alias_add_shows_usage_when_no_args(void **state) +void +cmd_alias_add_shows_usage_when_no_args(void** state) { - gchar *args[] = { "add", NULL }; + gchar* args[] = { "add", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_ALIAS); @@ -29,9 +30,10 @@ void cmd_alias_add_shows_usage_when_no_args(void **state) assert_true(result); } -void cmd_alias_add_shows_usage_when_no_value(void **state) +void +cmd_alias_add_shows_usage_when_no_value(void** state) { - gchar *args[] = { "add", "alias", NULL }; + gchar* args[] = { "add", "alias", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_ALIAS); @@ -39,9 +41,10 @@ void cmd_alias_add_shows_usage_when_no_value(void **state) assert_true(result); } -void cmd_alias_remove_shows_usage_when_no_args(void **state) +void +cmd_alias_remove_shows_usage_when_no_args(void** state) { - gchar *args[] = { "remove", NULL }; + gchar* args[] = { "remove", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_ALIAS); @@ -49,9 +52,10 @@ void cmd_alias_remove_shows_usage_when_no_args(void **state) assert_true(result); } -void cmd_alias_show_usage_when_invalid_subcmd(void **state) +void +cmd_alias_show_usage_when_invalid_subcmd(void** state) { - gchar *args[] = { "blah", NULL }; + gchar* args[] = { "blah", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_ALIAS); @@ -59,24 +63,26 @@ void cmd_alias_show_usage_when_invalid_subcmd(void **state) assert_true(result); } -void cmd_alias_add_adds_alias(void **state) +void +cmd_alias_add_adds_alias(void** state) { - gchar *args[] = { "add", "hc", "/help commands", NULL }; + gchar* args[] = { "add", "hc", "/help commands", NULL }; expect_cons_show("Command alias added /hc -> /help commands"); gboolean result = cmd_alias(NULL, CMD_ALIAS, args); assert_true(result); - char *returned_val = prefs_get_alias("hc"); + char* returned_val = prefs_get_alias("hc"); assert_string_equal("/help commands", returned_val); free(returned_val); } -void cmd_alias_add_shows_message_when_exists(void **state) +void +cmd_alias_add_shows_message_when_exists(void** state) { - gchar *args[] = { "add", "hc", "/help commands", NULL }; + gchar* args[] = { "add", "hc", "/help commands", NULL }; cmd_init(); prefs_add_alias("hc", "/help commands"); @@ -88,9 +94,10 @@ void cmd_alias_add_shows_message_when_exists(void **state) assert_true(result); } -void cmd_alias_remove_removes_alias(void **state) +void +cmd_alias_remove_removes_alias(void** state) { - gchar *args[] = { "remove", "hn", NULL }; + gchar* args[] = { "remove", "hn", NULL }; prefs_add_alias("hn", "/help navigation"); @@ -99,15 +106,16 @@ void cmd_alias_remove_removes_alias(void **state) gboolean result = cmd_alias(NULL, CMD_ALIAS, args); assert_true(result); - char *returned_val = prefs_get_alias("hn"); + char* returned_val = prefs_get_alias("hn"); assert_null(returned_val); - + free(returned_val); } -void cmd_alias_remove_shows_message_when_no_alias(void **state) +void +cmd_alias_remove_shows_message_when_no_alias(void** state) { - gchar *args[] = { "remove", "hn", NULL }; + gchar* args[] = { "remove", "hn", NULL }; expect_cons_show("No such command alias /hn"); @@ -115,9 +123,10 @@ void cmd_alias_remove_shows_message_when_no_alias(void **state) assert_true(result); } -void cmd_alias_list_shows_all_aliases(void **state) +void +cmd_alias_list_shows_all_aliases(void** state) { - gchar *args[] = { "list", NULL }; + gchar* args[] = { "list", NULL }; prefs_add_alias("vy", "/vercheck on"); prefs_add_alias("q", "/quit"); diff --git a/tests/unittests/test_cmd_alias.h b/tests/unittests/test_cmd_alias.h index bd93ef1a..b674d479 100644 --- a/tests/unittests/test_cmd_alias.h +++ b/tests/unittests/test_cmd_alias.h @@ -1,9 +1,9 @@ -void cmd_alias_add_shows_usage_when_no_args(void **state); -void cmd_alias_add_shows_usage_when_no_value(void **state); -void cmd_alias_remove_shows_usage_when_no_args(void **state); -void cmd_alias_show_usage_when_invalid_subcmd(void **state); -void cmd_alias_add_adds_alias(void **state); -void cmd_alias_add_shows_message_when_exists(void **state); -void cmd_alias_remove_removes_alias(void **state); -void cmd_alias_remove_shows_message_when_no_alias(void **state); -void cmd_alias_list_shows_all_aliases(void **state); +void cmd_alias_add_shows_usage_when_no_args(void** state); +void cmd_alias_add_shows_usage_when_no_value(void** state); +void cmd_alias_remove_shows_usage_when_no_args(void** state); +void cmd_alias_show_usage_when_invalid_subcmd(void** state); +void cmd_alias_add_adds_alias(void** state); +void cmd_alias_add_shows_message_when_exists(void** state); +void cmd_alias_remove_removes_alias(void** state); +void cmd_alias_remove_shows_message_when_no_alias(void** state); +void cmd_alias_list_shows_all_aliases(void** state); diff --git a/tests/unittests/test_cmd_bookmark.c b/tests/unittests/test_cmd_bookmark.c index 7b385706..58201ca6 100644 --- a/tests/unittests/test_cmd_bookmark.c +++ b/tests/unittests/test_cmd_bookmark.c @@ -22,7 +22,8 @@ #define CMD_BOOKMARK "/bookmark" -static void test_with_connection_status(jabber_conn_status_t status) +static void +test_with_connection_status(jabber_conn_status_t status) { ProfWin window; window.type = WIN_CONSOLE; @@ -33,24 +34,28 @@ static void test_with_connection_status(jabber_conn_status_t status) assert_true(result); } -void cmd_bookmark_shows_message_when_disconnected(void **state) +void +cmd_bookmark_shows_message_when_disconnected(void** state) { test_with_connection_status(JABBER_DISCONNECTED); } -void cmd_bookmark_shows_message_when_disconnecting(void **state) +void +cmd_bookmark_shows_message_when_disconnecting(void** state) { test_with_connection_status(JABBER_DISCONNECTING); } -void cmd_bookmark_shows_message_when_connecting(void **state) +void +cmd_bookmark_shows_message_when_connecting(void** state) { test_with_connection_status(JABBER_CONNECTING); } -void cmd_bookmark_shows_usage_when_no_args(void **state) +void +cmd_bookmark_shows_usage_when_no_args(void** state) { - gchar *args[] = { NULL }; + gchar* args[] = { NULL }; ProfWin window; window.type = WIN_CONSOLE; @@ -72,7 +77,7 @@ static void _free_bookmark(Bookmark *bookmark) */ static gboolean -_cmp_bookmark(Bookmark *bm1, Bookmark *bm2) +_cmp_bookmark(Bookmark* bm1, Bookmark* bm2) { if (strcmp(bm1->barejid, bm2->barejid) != 0) { return FALSE; @@ -87,30 +92,31 @@ _cmp_bookmark(Bookmark *bm1, Bookmark *bm2) return TRUE; } -void cmd_bookmark_list_shows_bookmarks(void **state) +void +cmd_bookmark_list_shows_bookmarks(void** state) { - gchar *args[] = { "list", NULL }; - GList *bookmarks = NULL; + gchar* args[] = { "list", NULL }; + GList* bookmarks = NULL; ProfWin window; window.type = WIN_CONSOLE; - Bookmark *bm1 = malloc(sizeof(Bookmark)); + Bookmark* bm1 = malloc(sizeof(Bookmark)); bm1->barejid = strdup("room1@conf.org"); bm1->nick = strdup("bob"); bm1->autojoin = FALSE; - Bookmark *bm2 = malloc(sizeof(Bookmark)); + Bookmark* bm2 = malloc(sizeof(Bookmark)); bm2->barejid = strdup("room2@conf.org"); bm2->nick = strdup("steve"); bm2->autojoin = TRUE; - Bookmark *bm3 = malloc(sizeof(Bookmark)); + Bookmark* bm3 = malloc(sizeof(Bookmark)); bm3->barejid = strdup("room3@conf.org"); bm3->nick = strdup("dave"); bm3->autojoin = TRUE; - Bookmark *bm4 = malloc(sizeof(Bookmark)); + Bookmark* bm4 = malloc(sizeof(Bookmark)); bm4->barejid = strdup("room4@conf.org"); bm4->nick = strdup("james"); bm4->autojoin = FALSE; - Bookmark *bm5 = malloc(sizeof(Bookmark)); + Bookmark* bm5 = malloc(sizeof(Bookmark)); bm5->barejid = strdup("room5@conf.org"); bm5->nick = strdup("mike"); bm5->autojoin = FALSE; @@ -148,10 +154,11 @@ void cmd_bookmark_list_shows_bookmarks(void **state) free(bm5); } -void cmd_bookmark_add_shows_message_when_invalid_jid(void **state) +void +cmd_bookmark_add_shows_message_when_invalid_jid(void** state) { - char *jid = "room"; - gchar *args[] = { "add", jid, NULL }; + char* jid = "room"; + gchar* args[] = { "add", jid, NULL }; ProfWin window; window.type = WIN_CONSOLE; @@ -164,10 +171,11 @@ void cmd_bookmark_add_shows_message_when_invalid_jid(void **state) assert_true(result); } -void cmd_bookmark_add_adds_bookmark_with_jid(void **state) +void +cmd_bookmark_add_adds_bookmark_with_jid(void** state) { - char *jid = "room@conf.server"; - gchar *args[] = { "add", jid, NULL }; + char* jid = "room@conf.server"; + gchar* args[] = { "add", jid, NULL }; ProfWin window; window.type = WIN_CONSOLE; @@ -185,11 +193,12 @@ void cmd_bookmark_add_adds_bookmark_with_jid(void **state) assert_true(result); } -void cmd_bookmark_uses_roomjid_in_room(void **state) +void +cmd_bookmark_uses_roomjid_in_room(void** state) { muc_init(); - gchar *args[] = { NULL }; + gchar* args[] = { NULL }; ProfMucWin muc_win; muc_win.window.type = WIN_MUC; muc_win.memcheck = PROFMUCWIN_MEMCHECK; @@ -211,11 +220,12 @@ void cmd_bookmark_uses_roomjid_in_room(void **state) muc_close(); } -void cmd_bookmark_add_uses_roomjid_in_room(void **state) +void +cmd_bookmark_add_uses_roomjid_in_room(void** state) { muc_init(); - gchar *args[] = { "add", NULL }; + gchar* args[] = { "add", NULL }; ProfMucWin muc_win; muc_win.window.type = WIN_MUC; muc_win.memcheck = PROFMUCWIN_MEMCHECK; @@ -237,12 +247,13 @@ void cmd_bookmark_add_uses_roomjid_in_room(void **state) muc_close(); } -void cmd_bookmark_add_uses_supplied_jid_in_room(void **state) +void +cmd_bookmark_add_uses_supplied_jid_in_room(void** state) { muc_init(); - char *jid = "room1@conf.server"; - gchar *args[] = { "add", jid, NULL }; + char* jid = "room1@conf.server"; + gchar* args[] = { "add", jid, NULL }; ProfMucWin muc_win; muc_win.window.type = WIN_MUC; muc_win.memcheck = PROFMUCWIN_MEMCHECK; @@ -264,11 +275,12 @@ void cmd_bookmark_add_uses_supplied_jid_in_room(void **state) muc_close(); } -void cmd_bookmark_add_adds_bookmark_with_jid_nick(void **state) +void +cmd_bookmark_add_adds_bookmark_with_jid_nick(void** state) { - char *jid = "room@conf.server"; - char *nick = "bob"; - gchar *args[] = { "add", jid, "nick", nick, NULL }; + char* jid = "room@conf.server"; + char* nick = "bob"; + gchar* args[] = { "add", jid, "nick", nick, NULL }; ProfWin window; window.type = WIN_CONSOLE; @@ -286,10 +298,11 @@ void cmd_bookmark_add_adds_bookmark_with_jid_nick(void **state) assert_true(result); } -void cmd_bookmark_add_adds_bookmark_with_jid_autojoin(void **state) +void +cmd_bookmark_add_adds_bookmark_with_jid_autojoin(void** state) { - char *jid = "room@conf.server"; - gchar *args[] = { "add", jid, "autojoin", "on", NULL }; + char* jid = "room@conf.server"; + gchar* args[] = { "add", jid, "autojoin", "on", NULL }; ProfWin window; window.type = WIN_CONSOLE; @@ -307,11 +320,12 @@ void cmd_bookmark_add_adds_bookmark_with_jid_autojoin(void **state) assert_true(result); } -void cmd_bookmark_add_adds_bookmark_with_jid_nick_autojoin(void **state) +void +cmd_bookmark_add_adds_bookmark_with_jid_nick_autojoin(void** state) { - char *jid = "room@conf.server"; - char *nick = "bob"; - gchar *args[] = { "add", jid, "nick", nick, "autojoin", "on", NULL }; + char* jid = "room@conf.server"; + char* nick = "bob"; + gchar* args[] = { "add", jid, "nick", nick, "autojoin", "on", NULL }; ProfWin window; window.type = WIN_CONSOLE; @@ -329,10 +343,11 @@ void cmd_bookmark_add_adds_bookmark_with_jid_nick_autojoin(void **state) assert_true(result); } -void cmd_bookmark_remove_removes_bookmark(void **state) +void +cmd_bookmark_remove_removes_bookmark(void** state) { - char *jid = "room@conf.server"; - gchar *args[] = { "remove", jid, NULL }; + char* jid = "room@conf.server"; + gchar* args[] = { "remove", jid, NULL }; ProfWin window; window.type = WIN_CONSOLE; @@ -347,10 +362,11 @@ void cmd_bookmark_remove_removes_bookmark(void **state) assert_true(result); } -void cmd_bookmark_remove_shows_message_when_no_bookmark(void **state) +void +cmd_bookmark_remove_shows_message_when_no_bookmark(void** state) { - char *jid = "room@conf.server"; - gchar *args[] = { "remove", jid, NULL }; + char* jid = "room@conf.server"; + gchar* args[] = { "remove", jid, NULL }; ProfWin window; window.type = WIN_CONSOLE; @@ -365,11 +381,12 @@ void cmd_bookmark_remove_shows_message_when_no_bookmark(void **state) assert_true(result); } -void cmd_bookmark_remove_uses_roomjid_in_room(void **state) +void +cmd_bookmark_remove_uses_roomjid_in_room(void** state) { muc_init(); - gchar *args[] = { "remove", NULL }; + gchar* args[] = { "remove", NULL }; ProfMucWin muc_win; muc_win.window.type = WIN_MUC; muc_win.memcheck = PROFMUCWIN_MEMCHECK; @@ -388,12 +405,13 @@ void cmd_bookmark_remove_uses_roomjid_in_room(void **state) muc_close(); } -void cmd_bookmark_remove_uses_supplied_jid_in_room(void **state) +void +cmd_bookmark_remove_uses_supplied_jid_in_room(void** state) { muc_init(); - char *jid = "room1@conf.server"; - gchar *args[] = { "remove", jid, NULL }; + char* jid = "room1@conf.server"; + gchar* args[] = { "remove", jid, NULL }; ProfMucWin muc_win; muc_win.window.type = WIN_MUC; muc_win.memcheck = PROFMUCWIN_MEMCHECK; diff --git a/tests/unittests/test_cmd_bookmark.h b/tests/unittests/test_cmd_bookmark.h index 195882b5..d8e598bb 100644 --- a/tests/unittests/test_cmd_bookmark.h +++ b/tests/unittests/test_cmd_bookmark.h @@ -1,18 +1,18 @@ -void cmd_bookmark_shows_message_when_disconnected(void **state); -void cmd_bookmark_shows_message_when_disconnecting(void **state); -void cmd_bookmark_shows_message_when_connecting(void **state); -void cmd_bookmark_shows_message_when_undefined(void **state); -void cmd_bookmark_shows_usage_when_no_args(void **state); -void cmd_bookmark_list_shows_bookmarks(void **state); -void cmd_bookmark_add_shows_message_when_invalid_jid(void **state); -void cmd_bookmark_add_adds_bookmark_with_jid(void **state); -void cmd_bookmark_uses_roomjid_in_room(void **state); -void cmd_bookmark_add_uses_roomjid_in_room(void **state); -void cmd_bookmark_add_uses_supplied_jid_in_room(void **state); -void cmd_bookmark_remove_uses_roomjid_in_room(void **state); -void cmd_bookmark_remove_uses_supplied_jid_in_room(void **state); -void cmd_bookmark_add_adds_bookmark_with_jid_nick(void **state); -void cmd_bookmark_add_adds_bookmark_with_jid_autojoin(void **state); -void cmd_bookmark_add_adds_bookmark_with_jid_nick_autojoin(void **state); -void cmd_bookmark_remove_removes_bookmark(void **state); -void cmd_bookmark_remove_shows_message_when_no_bookmark(void **state); +void cmd_bookmark_shows_message_when_disconnected(void** state); +void cmd_bookmark_shows_message_when_disconnecting(void** state); +void cmd_bookmark_shows_message_when_connecting(void** state); +void cmd_bookmark_shows_message_when_undefined(void** state); +void cmd_bookmark_shows_usage_when_no_args(void** state); +void cmd_bookmark_list_shows_bookmarks(void** state); +void cmd_bookmark_add_shows_message_when_invalid_jid(void** state); +void cmd_bookmark_add_adds_bookmark_with_jid(void** state); +void cmd_bookmark_uses_roomjid_in_room(void** state); +void cmd_bookmark_add_uses_roomjid_in_room(void** state); +void cmd_bookmark_add_uses_supplied_jid_in_room(void** state); +void cmd_bookmark_remove_uses_roomjid_in_room(void** state); +void cmd_bookmark_remove_uses_supplied_jid_in_room(void** state); +void cmd_bookmark_add_adds_bookmark_with_jid_nick(void** state); +void cmd_bookmark_add_adds_bookmark_with_jid_autojoin(void** state); +void cmd_bookmark_add_adds_bookmark_with_jid_nick_autojoin(void** state); +void cmd_bookmark_remove_removes_bookmark(void** state); +void cmd_bookmark_remove_shows_message_when_no_bookmark(void** state); diff --git a/tests/unittests/test_cmd_connect.c b/tests/unittests/test_cmd_connect.c index 9d1fd157..63f08f6d 100644 --- a/tests/unittests/test_cmd_connect.c +++ b/tests/unittests/test_cmd_connect.c @@ -16,7 +16,8 @@ #define CMD_CONNECT "/connect" -static void test_with_connection_status(jabber_conn_status_t status) +static void +test_with_connection_status(jabber_conn_status_t status) { will_return(connection_get_status, status); @@ -26,24 +27,28 @@ static void test_with_connection_status(jabber_conn_status_t status) assert_true(result); } -void cmd_connect_shows_message_when_disconnecting(void **state) +void +cmd_connect_shows_message_when_disconnecting(void** state) { test_with_connection_status(JABBER_DISCONNECTING); } -void cmd_connect_shows_message_when_connecting(void **state) +void +cmd_connect_shows_message_when_connecting(void** state) { test_with_connection_status(JABBER_CONNECTING); } -void cmd_connect_shows_message_when_connected(void **state) +void +cmd_connect_shows_message_when_connected(void** state) { test_with_connection_status(JABBER_CONNECTED); } -void cmd_connect_when_no_account(void **state) +void +cmd_connect_when_no_account(void** state) { - gchar *args[] = { "user@server.org", NULL }; + gchar* args[] = { "user@server.org", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -64,9 +69,10 @@ void cmd_connect_when_no_account(void **state) assert_true(result); } -void cmd_connect_fail_message(void **state) +void +cmd_connect_fail_message(void** state) { - gchar *args[] = { "user@server.org", NULL }; + gchar* args[] = { "user@server.org", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -89,9 +95,10 @@ void cmd_connect_fail_message(void **state) assert_true(result); } -void cmd_connect_lowercases_argument_with_no_account(void **state) +void +cmd_connect_lowercases_argument_with_no_account(void** state) { - gchar *args[] = { "USER@server.ORG", NULL }; + gchar* args[] = { "USER@server.ORG", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -112,11 +119,12 @@ void cmd_connect_lowercases_argument_with_no_account(void **state) assert_true(result); } -void cmd_connect_lowercases_argument_with_account(void **state) +void +cmd_connect_lowercases_argument_with_account(void** state) { -gchar *args[] = { "Jabber_org", NULL }; - ProfAccount *account = account_new("Jabber_org", "me@jabber.org", "password", NULL, - TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + gchar* args[] = { "Jabber_org", NULL }; + ProfAccount* account = account_new("Jabber_org", "me@jabber.org", "password", NULL, + TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); will_return(connection_get_status, JABBER_DISCONNECTED); @@ -132,11 +140,12 @@ gchar *args[] = { "Jabber_org", NULL }; assert_true(result); } -void cmd_connect_asks_password_when_not_in_account(void **state) +void +cmd_connect_asks_password_when_not_in_account(void** state) { - gchar *args[] = { "jabber_org", NULL }; - ProfAccount *account = account_new("jabber_org", "me@jabber.org", NULL, NULL, - TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + gchar* args[] = { "jabber_org", NULL }; + ProfAccount* account = account_new("jabber_org", "me@jabber.org", NULL, NULL, + TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); will_return(connection_get_status, JABBER_DISCONNECTED); @@ -154,9 +163,10 @@ void cmd_connect_asks_password_when_not_in_account(void **state) assert_true(result); } -void cmd_connect_shows_usage_when_no_server_value(void **state) +void +cmd_connect_shows_usage_when_no_server_value(void** state) { - gchar *args[] = { "user@server.org", "server", NULL }; + gchar* args[] = { "user@server.org", "server", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -167,9 +177,10 @@ void cmd_connect_shows_usage_when_no_server_value(void **state) assert_true(result); } -void cmd_connect_shows_usage_when_server_no_port_value(void **state) +void +cmd_connect_shows_usage_when_server_no_port_value(void** state) { - gchar *args[] = { "user@server.org", "server", "aserver", "port", NULL }; + gchar* args[] = { "user@server.org", "server", "aserver", "port", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -180,9 +191,10 @@ void cmd_connect_shows_usage_when_server_no_port_value(void **state) assert_true(result); } -void cmd_connect_shows_usage_when_no_port_value(void **state) +void +cmd_connect_shows_usage_when_no_port_value(void** state) { - gchar *args[] = { "user@server.org", "port", NULL }; + gchar* args[] = { "user@server.org", "port", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -193,9 +205,10 @@ void cmd_connect_shows_usage_when_no_port_value(void **state) assert_true(result); } -void cmd_connect_shows_usage_when_port_no_server_value(void **state) +void +cmd_connect_shows_usage_when_port_no_server_value(void** state) { - gchar *args[] = { "user@server.org", "port", "5678", "server", NULL }; + gchar* args[] = { "user@server.org", "port", "5678", "server", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -206,9 +219,10 @@ void cmd_connect_shows_usage_when_port_no_server_value(void **state) assert_true(result); } -void cmd_connect_shows_message_when_port_0(void **state) +void +cmd_connect_shows_message_when_port_0(void** state) { - gchar *args[] = { "user@server.org", "port", "0", NULL }; + gchar* args[] = { "user@server.org", "port", "0", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -219,9 +233,10 @@ void cmd_connect_shows_message_when_port_0(void **state) assert_true(result); } -void cmd_connect_shows_message_when_port_minus1(void **state) +void +cmd_connect_shows_message_when_port_minus1(void** state) { - gchar *args[] = { "user@server.org", "port", "-1", NULL }; + gchar* args[] = { "user@server.org", "port", "-1", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -232,9 +247,10 @@ void cmd_connect_shows_message_when_port_minus1(void **state) assert_true(result); } -void cmd_connect_shows_message_when_port_65536(void **state) +void +cmd_connect_shows_message_when_port_65536(void** state) { - gchar *args[] = { "user@server.org", "port", "65536", NULL }; + gchar* args[] = { "user@server.org", "port", "65536", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -245,9 +261,10 @@ void cmd_connect_shows_message_when_port_65536(void **state) assert_true(result); } -void cmd_connect_shows_message_when_port_contains_chars(void **state) +void +cmd_connect_shows_message_when_port_contains_chars(void** state) { - gchar *args[] = { "user@server.org", "port", "52f66", NULL }; + gchar* args[] = { "user@server.org", "port", "52f66", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -258,9 +275,10 @@ void cmd_connect_shows_message_when_port_contains_chars(void **state) assert_true(result); } -void cmd_connect_shows_usage_when_server_provided_twice(void **state) +void +cmd_connect_shows_usage_when_server_provided_twice(void** state) { - gchar *args[] = { "user@server.org", "server", "server1", "server", "server2", NULL }; + gchar* args[] = { "user@server.org", "server", "server1", "server", "server2", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -271,9 +289,10 @@ void cmd_connect_shows_usage_when_server_provided_twice(void **state) assert_true(result); } -void cmd_connect_shows_usage_when_port_provided_twice(void **state) +void +cmd_connect_shows_usage_when_port_provided_twice(void** state) { - gchar *args[] = { "user@server.org", "port", "1111", "port", "1111", NULL }; + gchar* args[] = { "user@server.org", "port", "1111", "port", "1111", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -284,9 +303,10 @@ void cmd_connect_shows_usage_when_port_provided_twice(void **state) assert_true(result); } -void cmd_connect_shows_usage_when_invalid_first_property(void **state) +void +cmd_connect_shows_usage_when_invalid_first_property(void** state) { - gchar *args[] = { "user@server.org", "wrong", "server", NULL }; + gchar* args[] = { "user@server.org", "wrong", "server", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -297,9 +317,10 @@ void cmd_connect_shows_usage_when_invalid_first_property(void **state) assert_true(result); } -void cmd_connect_shows_usage_when_invalid_second_property(void **state) +void +cmd_connect_shows_usage_when_invalid_second_property(void** state) { - gchar *args[] = { "user@server.org", "server", "aserver", "wrong", "1234", NULL }; + gchar* args[] = { "user@server.org", "server", "aserver", "wrong", "1234", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -310,9 +331,10 @@ void cmd_connect_shows_usage_when_invalid_second_property(void **state) assert_true(result); } -void cmd_connect_with_server_when_provided(void **state) +void +cmd_connect_with_server_when_provided(void** state) { - gchar *args[] = { "user@server.org", "server", "aserver", NULL }; + gchar* args[] = { "user@server.org", "server", "aserver", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -333,9 +355,10 @@ void cmd_connect_with_server_when_provided(void **state) assert_true(result); } -void cmd_connect_with_port_when_provided(void **state) +void +cmd_connect_with_port_when_provided(void** state) { - gchar *args[] = { "user@server.org", "port", "5432", NULL }; + gchar* args[] = { "user@server.org", "port", "5432", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -356,9 +379,10 @@ void cmd_connect_with_port_when_provided(void **state) assert_true(result); } -void cmd_connect_with_server_and_port_when_provided(void **state) +void +cmd_connect_with_server_and_port_when_provided(void** state) { - gchar *args[] = { "user@server.org", "port", "5432", "server", "aserver", NULL }; + gchar* args[] = { "user@server.org", "port", "5432", "server", "aserver", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -379,11 +403,12 @@ void cmd_connect_with_server_and_port_when_provided(void **state) assert_true(result); } -void cmd_connect_shows_message_when_connecting_with_account(void **state) +void +cmd_connect_shows_message_when_connecting_with_account(void** state) { - gchar *args[] = { "jabber_org", NULL }; - ProfAccount *account = account_new("jabber_org", "user@jabber.org", "password", NULL, - TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + gchar* args[] = { "jabber_org", NULL }; + ProfAccount* account = account_new("jabber_org", "user@jabber.org", "password", NULL, + TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); will_return(connection_get_status, JABBER_DISCONNECTED); @@ -399,11 +424,12 @@ void cmd_connect_shows_message_when_connecting_with_account(void **state) assert_true(result); } -void cmd_connect_connects_with_account(void **state) +void +cmd_connect_connects_with_account(void** state) { - gchar *args[] = { "jabber_org", NULL }; - ProfAccount *account = account_new("jabber_org", "me@jabber.org", "password", NULL, - TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + gchar* args[] = { "jabber_org", NULL }; + ProfAccount* account = account_new("jabber_org", "me@jabber.org", "password", NULL, + TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); will_return(connection_get_status, JABBER_DISCONNECTED); diff --git a/tests/unittests/test_cmd_connect.h b/tests/unittests/test_cmd_connect.h index c9c01c9a..14e7f7b2 100644 --- a/tests/unittests/test_cmd_connect.h +++ b/tests/unittests/test_cmd_connect.h @@ -1,27 +1,27 @@ -void cmd_connect_shows_message_when_disconnecting(void **state); -void cmd_connect_shows_message_when_connecting(void **state); -void cmd_connect_shows_message_when_connected(void **state); -void cmd_connect_shows_message_when_undefined(void **state); -void cmd_connect_when_no_account(void **state); -void cmd_connect_with_altdomain_when_provided(void **state); -void cmd_connect_fail_message(void **state); -void cmd_connect_lowercases_argument_with_no_account(void **state); -void cmd_connect_lowercases_argument_with_account(void **state); -void cmd_connect_asks_password_when_not_in_account(void **state); -void cmd_connect_shows_message_when_connecting_with_account(void **state); -void cmd_connect_connects_with_account(void **state); -void cmd_connect_shows_usage_when_no_server_value(void **state); -void cmd_connect_shows_usage_when_server_no_port_value(void **state); -void cmd_connect_shows_usage_when_no_port_value(void **state); -void cmd_connect_shows_usage_when_port_no_server_value(void **state); -void cmd_connect_shows_message_when_port_0(void **state); -void cmd_connect_shows_message_when_port_minus1(void **state); -void cmd_connect_shows_message_when_port_65536(void **state); -void cmd_connect_shows_message_when_port_contains_chars(void **state); -void cmd_connect_with_server_when_provided(void **state); -void cmd_connect_with_port_when_provided(void **state); -void cmd_connect_with_server_and_port_when_provided(void **state); -void cmd_connect_shows_usage_when_server_provided_twice(void **state); -void cmd_connect_shows_usage_when_port_provided_twice(void **state); -void cmd_connect_shows_usage_when_invalid_first_property(void **state); -void cmd_connect_shows_usage_when_invalid_second_property(void **state); +void cmd_connect_shows_message_when_disconnecting(void** state); +void cmd_connect_shows_message_when_connecting(void** state); +void cmd_connect_shows_message_when_connected(void** state); +void cmd_connect_shows_message_when_undefined(void** state); +void cmd_connect_when_no_account(void** state); +void cmd_connect_with_altdomain_when_provided(void** state); +void cmd_connect_fail_message(void** state); +void cmd_connect_lowercases_argument_with_no_account(void** state); +void cmd_connect_lowercases_argument_with_account(void** state); +void cmd_connect_asks_password_when_not_in_account(void** state); +void cmd_connect_shows_message_when_connecting_with_account(void** state); +void cmd_connect_connects_with_account(void** state); +void cmd_connect_shows_usage_when_no_server_value(void** state); +void cmd_connect_shows_usage_when_server_no_port_value(void** state); +void cmd_connect_shows_usage_when_no_port_value(void** state); +void cmd_connect_shows_usage_when_port_no_server_value(void** state); +void cmd_connect_shows_message_when_port_0(void** state); +void cmd_connect_shows_message_when_port_minus1(void** state); +void cmd_connect_shows_message_when_port_65536(void** state); +void cmd_connect_shows_message_when_port_contains_chars(void** state); +void cmd_connect_with_server_when_provided(void** state); +void cmd_connect_with_port_when_provided(void** state); +void cmd_connect_with_server_and_port_when_provided(void** state); +void cmd_connect_shows_usage_when_server_provided_twice(void** state); +void cmd_connect_shows_usage_when_port_provided_twice(void** state); +void cmd_connect_shows_usage_when_invalid_first_property(void** state); +void cmd_connect_shows_usage_when_invalid_second_property(void** state); diff --git a/tests/unittests/test_cmd_disconnect.c b/tests/unittests/test_cmd_disconnect.c index 0d46d532..ac3c36da 100644 --- a/tests/unittests/test_cmd_disconnect.c +++ b/tests/unittests/test_cmd_disconnect.c @@ -14,7 +14,8 @@ #define CMD_DISCONNECT "/disconnect" -void clears_chat_sessions(void **state) +void +clears_chat_sessions(void** state) { chat_sessions_init(); roster_create(); @@ -29,8 +30,8 @@ void clears_chat_sessions(void **state) assert_true(result); - ChatSession *session1 = chat_session_get("bob@server.org"); - ChatSession *session2 = chat_session_get("mike@server.org"); + ChatSession* session1 = chat_session_get("bob@server.org"); + ChatSession* session2 = chat_session_get("mike@server.org"); assert_null(session1); assert_null(session2); } diff --git a/tests/unittests/test_cmd_disconnect.h b/tests/unittests/test_cmd_disconnect.h index 856b501e..0988bd25 100644 --- a/tests/unittests/test_cmd_disconnect.h +++ b/tests/unittests/test_cmd_disconnect.h @@ -1 +1 @@ -void clears_chat_sessions(void **state); +void clears_chat_sessions(void** state); diff --git a/tests/unittests/test_cmd_join.c b/tests/unittests/test_cmd_join.c index ed14a935..c4af4040 100644 --- a/tests/unittests/test_cmd_join.c +++ b/tests/unittests/test_cmd_join.c @@ -18,7 +18,8 @@ #define CMD_JOIN "/join" -static void test_with_connection_status(jabber_conn_status_t status) +static void +test_with_connection_status(jabber_conn_status_t status) { will_return(connection_get_status, status); @@ -28,24 +29,28 @@ static void test_with_connection_status(jabber_conn_status_t status) assert_true(result); } -void cmd_join_shows_message_when_disconnecting(void **state) +void +cmd_join_shows_message_when_disconnecting(void** state) { test_with_connection_status(JABBER_DISCONNECTING); } -void cmd_join_shows_message_when_connecting(void **state) +void +cmd_join_shows_message_when_connecting(void** state) { test_with_connection_status(JABBER_CONNECTING); } -void cmd_join_shows_message_when_disconnected(void **state) +void +cmd_join_shows_message_when_disconnected(void** state) { test_with_connection_status(JABBER_DISCONNECTED); } -void cmd_join_shows_error_message_when_invalid_room_jid(void **state) +void +cmd_join_shows_error_message_when_invalid_room_jid(void** state) { - gchar *args[] = { "//@@/", NULL }; + gchar* args[] = { "//@@/", NULL }; will_return(connection_get_status, JABBER_CONNECTED); @@ -56,16 +61,17 @@ void cmd_join_shows_error_message_when_invalid_room_jid(void **state) assert_true(result); } -void cmd_join_uses_account_mucservice_when_no_service_specified(void **state) +void +cmd_join_uses_account_mucservice_when_no_service_specified(void** state) { - char *account_name = "an_account"; - char *room = "room"; - char *nick = "bob"; - char *account_service = "conference.server.org"; - char *expected_room = "room@conference.server.org"; - gchar *args[] = { room, "nick", nick, NULL }; - ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL, - TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, account_service, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + char* account_name = "an_account"; + char* room = "room"; + char* nick = "bob"; + char* account_service = "conference.server.org"; + char* expected_room = "room@conference.server.org"; + gchar* args[] = { room, "nick", nick, NULL }; + ProfAccount* account = account_new(account_name, "user@server.org", NULL, NULL, + TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, account_service, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); muc_init(); @@ -85,14 +91,15 @@ void cmd_join_uses_account_mucservice_when_no_service_specified(void **state) muc_close(); } -void cmd_join_uses_supplied_nick(void **state) +void +cmd_join_uses_supplied_nick(void** state) { - char *account_name = "an_account"; - char *room = "room@conf.server.org"; - char *nick = "bob"; - gchar *args[] = { room, "nick", nick, NULL }; - ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL, - TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + char* account_name = "an_account"; + char* room = "room@conf.server.org"; + char* nick = "bob"; + gchar* args[] = { room, "nick", nick, NULL }; + ProfAccount* account = account_new(account_name, "user@server.org", NULL, NULL, + TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); muc_init(); @@ -112,14 +119,15 @@ void cmd_join_uses_supplied_nick(void **state) muc_close(); } -void cmd_join_uses_account_nick_when_not_supplied(void **state) +void +cmd_join_uses_account_nick_when_not_supplied(void** state) { - char *account_name = "an_account"; - char *room = "room2@conf.server.org"; - char *account_nick = "a_nick"; - gchar *args[] = { room, NULL }; - ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL, - TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, account_nick, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + char* account_name = "an_account"; + char* room = "room2@conf.server.org"; + char* account_nick = "a_nick"; + gchar* args[] = { room, NULL }; + ProfAccount* account = account_new(account_name, "user@server.org", NULL, NULL, + TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, account_nick, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); muc_init(); @@ -139,17 +147,18 @@ void cmd_join_uses_account_nick_when_not_supplied(void **state) muc_close(); } -void cmd_join_uses_password_when_supplied(void **state) +void +cmd_join_uses_password_when_supplied(void** state) { - char *account_name = "an_account"; - char *room = "room"; - char *password = "a_password"; - char *account_nick = "a_nick"; - char *account_service = "a_service"; - char *expected_room = "room@a_service"; - gchar *args[] = { room, "password", password, NULL }; - ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL, - TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, account_service, account_nick, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + char* account_name = "an_account"; + char* room = "room"; + char* password = "a_password"; + char* account_nick = "a_nick"; + char* account_service = "a_service"; + char* expected_room = "room@a_service"; + gchar* args[] = { room, "password", password, NULL }; + ProfAccount* account = account_new(account_name, "user@server.org", NULL, NULL, + TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, account_service, account_nick, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); muc_init(); diff --git a/tests/unittests/test_cmd_join.h b/tests/unittests/test_cmd_join.h index a96fa435..c22d9847 100644 --- a/tests/unittests/test_cmd_join.h +++ b/tests/unittests/test_cmd_join.h @@ -1,9 +1,9 @@ -void cmd_join_shows_message_when_disconnecting(void **state); -void cmd_join_shows_message_when_connecting(void **state); -void cmd_join_shows_message_when_disconnected(void **state); -void cmd_join_shows_message_when_undefined(void **state); -void cmd_join_shows_error_message_when_invalid_room_jid(void **state); -void cmd_join_uses_account_mucservice_when_no_service_specified(void **state); -void cmd_join_uses_supplied_nick(void **state); -void cmd_join_uses_account_nick_when_not_supplied(void **state); -void cmd_join_uses_password_when_supplied(void **state); +void cmd_join_shows_message_when_disconnecting(void** state); +void cmd_join_shows_message_when_connecting(void** state); +void cmd_join_shows_message_when_disconnected(void** state); +void cmd_join_shows_message_when_undefined(void** state); +void cmd_join_shows_error_message_when_invalid_room_jid(void** state); +void cmd_join_uses_account_mucservice_when_no_service_specified(void** state); +void cmd_join_uses_supplied_nick(void** state); +void cmd_join_uses_account_nick_when_not_supplied(void** state); +void cmd_join_uses_password_when_supplied(void** state); diff --git a/tests/unittests/test_cmd_otr.c b/tests/unittests/test_cmd_otr.c index 4782d048..72141756 100644 --- a/tests/unittests/test_cmd_otr.c +++ b/tests/unittests/test_cmd_otr.c @@ -26,9 +26,10 @@ #define CMD_OTR "/otr" #ifdef HAVE_LIBOTR -void cmd_otr_log_shows_usage_when_no_args(void **state) +void +cmd_otr_log_shows_usage_when_no_args(void** state) { - gchar *args[] = { "log", NULL }; + gchar* args[] = { "log", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_OTR); @@ -36,9 +37,10 @@ void cmd_otr_log_shows_usage_when_no_args(void **state) assert_true(result); } -void cmd_otr_log_shows_usage_when_invalid_subcommand(void **state) +void +cmd_otr_log_shows_usage_when_invalid_subcommand(void** state) { - gchar *args[] = { "log", "wrong", NULL }; + gchar* args[] = { "log", "wrong", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_OTR); @@ -46,25 +48,27 @@ void cmd_otr_log_shows_usage_when_invalid_subcommand(void **state) assert_true(result); } -void cmd_otr_log_on_enables_logging(void **state) +void +cmd_otr_log_on_enables_logging(void** state) { - gchar *args[] = { "log", "on", NULL }; + gchar* args[] = { "log", "on", NULL }; prefs_set_string(PREF_OTR_LOG, "off"); prefs_set_boolean(PREF_CHLOG, TRUE); expect_cons_show("OTR messages will be logged as plaintext."); gboolean result = cmd_otr_log(NULL, CMD_OTR, args); - char *pref_otr_log = prefs_get_string(PREF_OTR_LOG); + char* pref_otr_log = prefs_get_string(PREF_OTR_LOG); assert_true(result); assert_string_equal("on", pref_otr_log); g_free(pref_otr_log); } -void cmd_otr_log_on_shows_warning_when_chlog_disabled(void **state) +void +cmd_otr_log_on_shows_warning_when_chlog_disabled(void** state) { - gchar *args[] = { "log", "on", NULL }; + gchar* args[] = { "log", "on", NULL }; prefs_set_string(PREF_OTR_LOG, "off"); prefs_set_boolean(PREF_CHLOG, FALSE); @@ -75,41 +79,44 @@ void cmd_otr_log_on_shows_warning_when_chlog_disabled(void **state) assert_true(result); } -void cmd_otr_log_off_disables_logging(void **state) +void +cmd_otr_log_off_disables_logging(void** state) { - gchar *args[] = { "log", "off", NULL }; + gchar* args[] = { "log", "off", NULL }; prefs_set_string(PREF_OTR_LOG, "on"); prefs_set_boolean(PREF_CHLOG, TRUE); expect_cons_show("OTR message logging disabled."); gboolean result = cmd_otr_log(NULL, CMD_OTR, args); - char *pref_otr_log = prefs_get_string(PREF_OTR_LOG); + char* pref_otr_log = prefs_get_string(PREF_OTR_LOG); assert_true(result); assert_string_equal("off", pref_otr_log); g_free(pref_otr_log); } -void cmd_otr_redact_redacts_logging(void **state) +void +cmd_otr_redact_redacts_logging(void** state) { - gchar *args[] = { "log", "redact", NULL }; + gchar* args[] = { "log", "redact", NULL }; prefs_set_string(PREF_OTR_LOG, "on"); prefs_set_boolean(PREF_CHLOG, TRUE); expect_cons_show("OTR messages will be logged as '[redacted]'."); gboolean result = cmd_otr_log(NULL, CMD_OTR, args); - char *pref_otr_log = prefs_get_string(PREF_OTR_LOG); + char* pref_otr_log = prefs_get_string(PREF_OTR_LOG); assert_true(result); assert_string_equal("redact", pref_otr_log); g_free(pref_otr_log); } -void cmd_otr_log_redact_shows_warning_when_chlog_disabled(void **state) +void +cmd_otr_log_redact_shows_warning_when_chlog_disabled(void** state) { - gchar *args[] = { "log", "redact", NULL }; + gchar* args[] = { "log", "redact", NULL }; prefs_set_string(PREF_OTR_LOG, "off"); prefs_set_boolean(PREF_CHLOG, FALSE); @@ -120,11 +127,12 @@ void cmd_otr_log_redact_shows_warning_when_chlog_disabled(void **state) assert_true(result); } -void cmd_otr_libver_shows_libotr_version(void **state) +void +cmd_otr_libver_shows_libotr_version(void** state) { - gchar *args[] = { "libver", NULL }; - char *version = "9.9.9"; - GString *message = g_string_new("Using libotr version "); + gchar* args[] = { "libver", NULL }; + char* version = "9.9.9"; + GString* message = g_string_new("Using libotr version "); g_string_append(message, version); will_return(otr_libotr_version, version); @@ -137,9 +145,10 @@ void cmd_otr_libver_shows_libotr_version(void **state) g_string_free(message, TRUE); } -void cmd_otr_gen_shows_message_when_not_connected(void **state) +void +cmd_otr_gen_shows_message_when_not_connected(void** state) { - gchar *args[] = { "gen", NULL }; + gchar* args[] = { "gen", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -149,40 +158,45 @@ void cmd_otr_gen_shows_message_when_not_connected(void **state) assert_true(result); } -static void test_with_command_and_connection_status(char *command, void *cmd_func, jabber_conn_status_t status) +static void +test_with_command_and_connection_status(char* command, void* cmd_func, jabber_conn_status_t status) { - gchar *args[] = { command, NULL }; + gchar* args[] = { command, NULL }; will_return(connection_get_status, status); expect_cons_show("You must be connected with an account to load OTR information."); - gboolean (*func)(ProfWin *window, const char *const command, gchar **args) = cmd_func; + gboolean (*func)(ProfWin * window, const char* const command, gchar** args) = cmd_func; gboolean result = func(NULL, CMD_OTR, args); assert_true(result); } -void cmd_otr_gen_shows_message_when_disconnected(void **state) +void +cmd_otr_gen_shows_message_when_disconnected(void** state) { test_with_command_and_connection_status("gen", cmd_otr_gen, JABBER_DISCONNECTED); } -void cmd_otr_gen_shows_message_when_connecting(void **state) +void +cmd_otr_gen_shows_message_when_connecting(void** state) { test_with_command_and_connection_status("gen", cmd_otr_gen, JABBER_CONNECTING); } -void cmd_otr_gen_shows_message_when_disconnecting(void **state) +void +cmd_otr_gen_shows_message_when_disconnecting(void** state) { test_with_command_and_connection_status("gen", cmd_otr_gen, JABBER_DISCONNECTING); } -void cmd_otr_gen_generates_key_for_connected_account(void **state) +void +cmd_otr_gen_generates_key_for_connected_account(void** state) { - gchar *args[] = { "gen", NULL }; - char *account_name = "myaccount"; - ProfAccount *account = account_new(account_name, "me@jabber.org", NULL, NULL, - TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + gchar* args[] = { "gen", NULL }; + char* account_name = "myaccount"; + ProfAccount* account = account_new(account_name, "me@jabber.org", NULL, NULL, + TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); will_return(connection_get_status, JABBER_CONNECTED); will_return(session_get_account_name, account_name); @@ -197,24 +211,28 @@ void cmd_otr_gen_generates_key_for_connected_account(void **state) assert_true(result); } -void cmd_otr_myfp_shows_message_when_disconnected(void **state) +void +cmd_otr_myfp_shows_message_when_disconnected(void** state) { test_with_command_and_connection_status("myfp", cmd_otr_myfp, JABBER_DISCONNECTED); } -void cmd_otr_myfp_shows_message_when_connecting(void **state) +void +cmd_otr_myfp_shows_message_when_connecting(void** state) { test_with_command_and_connection_status("myfp", cmd_otr_myfp, JABBER_CONNECTING); } -void cmd_otr_myfp_shows_message_when_disconnecting(void **state) +void +cmd_otr_myfp_shows_message_when_disconnecting(void** state) { test_with_command_and_connection_status("myfp", cmd_otr_myfp, JABBER_DISCONNECTING); } -void cmd_otr_myfp_shows_message_when_no_key(void **state) +void +cmd_otr_myfp_shows_message_when_no_key(void** state) { - gchar *args[] = { "myfp", NULL }; + gchar* args[] = { "myfp", NULL }; will_return(connection_get_status, JABBER_CONNECTED); will_return(otr_key_loaded, FALSE); @@ -225,11 +243,12 @@ void cmd_otr_myfp_shows_message_when_no_key(void **state) assert_true(result); } -void cmd_otr_myfp_shows_my_fingerprint(void **state) +void +cmd_otr_myfp_shows_my_fingerprint(void** state) { - char *fingerprint = "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD EEEEEEEE"; - gchar *args[] = { "myfp", NULL }; - GString *message = g_string_new("Your OTR fingerprint: "); + char* fingerprint = "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD EEEEEEEE"; + gchar* args[] = { "myfp", NULL }; + GString* message = g_string_new("Your OTR fingerprint: "); g_string_append(message, fingerprint); will_return(connection_get_status, JABBER_CONNECTED); @@ -247,7 +266,7 @@ void cmd_otr_myfp_shows_my_fingerprint(void **state) static void test_cmd_otr_theirfp_from_wintype(win_type_t wintype) { - gchar *args[] = { "theirfp", NULL }; + gchar* args[] = { "theirfp", NULL }; ProfWin window; window.type = wintype; window.layout = NULL; @@ -262,24 +281,28 @@ test_cmd_otr_theirfp_from_wintype(win_type_t wintype) assert_true(result); } -void cmd_otr_theirfp_shows_message_when_in_console(void **state) +void +cmd_otr_theirfp_shows_message_when_in_console(void** state) { test_cmd_otr_theirfp_from_wintype(WIN_CONSOLE); } -void cmd_otr_theirfp_shows_message_when_in_muc(void **state) +void +cmd_otr_theirfp_shows_message_when_in_muc(void** state) { test_cmd_otr_theirfp_from_wintype(WIN_MUC); } -void cmd_otr_theirfp_shows_message_when_in_private(void **state) +void +cmd_otr_theirfp_shows_message_when_in_private(void** state) { test_cmd_otr_theirfp_from_wintype(WIN_PRIVATE); } -void cmd_otr_theirfp_shows_message_when_non_otr_chat_window(void **state) +void +cmd_otr_theirfp_shows_message_when_non_otr_chat_window(void** state) { - gchar *args[] = { "theirfp", NULL }; + gchar* args[] = { "theirfp", NULL }; ProfWin window; window.type = WIN_CHAT; @@ -300,12 +323,13 @@ void cmd_otr_theirfp_shows_message_when_non_otr_chat_window(void **state) assert_true(result); } -void cmd_otr_theirfp_shows_fingerprint(void **state) +void +cmd_otr_theirfp_shows_fingerprint(void** state) { - char *recipient = "someone@chat.com"; - char *fingerprint = "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD EEEEEEEE"; - gchar *args[] = { "theirfp", NULL }; - GString *message = g_string_new(recipient); + char* recipient = "someone@chat.com"; + char* fingerprint = "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD EEEEEEEE"; + gchar* args[] = { "theirfp", NULL }; + GString* message = g_string_new(recipient); g_string_append(message, "'s OTR fingerprint: "); g_string_append(message, fingerprint); @@ -336,7 +360,7 @@ void cmd_otr_theirfp_shows_fingerprint(void **state) static void test_cmd_otr_start_from_wintype(win_type_t wintype) { - gchar *args[] = { "start", NULL }; + gchar* args[] = { "start", NULL }; ProfWin window; window.type = wintype; window.layout = NULL; @@ -350,25 +374,29 @@ test_cmd_otr_start_from_wintype(win_type_t wintype) assert_true(result); } -void cmd_otr_start_shows_message_when_in_console(void **state) +void +cmd_otr_start_shows_message_when_in_console(void** state) { test_cmd_otr_start_from_wintype(WIN_CONSOLE); } -void cmd_otr_start_shows_message_when_in_muc(void **state) +void +cmd_otr_start_shows_message_when_in_muc(void** state) { test_cmd_otr_start_from_wintype(WIN_MUC); } -void cmd_otr_start_shows_message_when_in_private(void **state) +void +cmd_otr_start_shows_message_when_in_private(void** state) { test_cmd_otr_start_from_wintype(WIN_PRIVATE); } -void cmd_otr_start_shows_message_when_already_started(void **state) +void +cmd_otr_start_shows_message_when_already_started(void** state) { - char *recipient = "someone@server.org"; - gchar *args[] = { "start", NULL }; + char* recipient = "someone@server.org"; + gchar* args[] = { "start", NULL }; will_return(connection_get_status, JABBER_CONNECTED); @@ -389,10 +417,11 @@ void cmd_otr_start_shows_message_when_already_started(void **state) assert_true(result); } -void cmd_otr_start_shows_message_when_no_key(void **state) +void +cmd_otr_start_shows_message_when_no_key(void** state) { - char *recipient = "someone@server.org"; - gchar *args[] = { "start", NULL }; + char* recipient = "someone@server.org"; + gchar* args[] = { "start", NULL }; will_return(connection_get_status, JABBER_CONNECTED); will_return(otr_key_loaded, FALSE); @@ -415,11 +444,11 @@ void cmd_otr_start_shows_message_when_no_key(void **state) } void -cmd_otr_start_sends_otr_query_message_to_current_recipeint(void **state) +cmd_otr_start_sends_otr_query_message_to_current_recipeint(void** state) { - char *recipient = "buddy@chat.com"; - char *query_message = "?OTR?"; - gchar *args[] = { "start", NULL }; + char* recipient = "buddy@chat.com"; + char* query_message = "?OTR?"; + gchar* args[] = { "start", NULL }; ProfWin window; window.type = WIN_CHAT; @@ -444,9 +473,10 @@ cmd_otr_start_sends_otr_query_message_to_current_recipeint(void **state) } #else -void cmd_otr_shows_message_when_otr_unsupported(void **state) +void +cmd_otr_shows_message_when_otr_unsupported(void** state) { - gchar *args[] = { "gen", NULL }; + gchar* args[] = { "gen", NULL }; expect_cons_show("This version of Profanity has not been built with OTR support enabled"); diff --git a/tests/unittests/test_cmd_otr.h b/tests/unittests/test_cmd_otr.h index 5343cc57..a9ffb1e1 100644 --- a/tests/unittests/test_cmd_otr.h +++ b/tests/unittests/test_cmd_otr.h @@ -1,37 +1,37 @@ #include "config.h" #ifdef HAVE_LIBOTR -void cmd_otr_log_shows_usage_when_no_args(void **state); -void cmd_otr_log_shows_usage_when_invalid_subcommand(void **state); -void cmd_otr_log_on_enables_logging(void **state); -void cmd_otr_log_off_disables_logging(void **state); -void cmd_otr_redact_redacts_logging(void **state); -void cmd_otr_log_on_shows_warning_when_chlog_disabled(void **state); -void cmd_otr_log_redact_shows_warning_when_chlog_disabled(void **state); -void cmd_otr_libver_shows_libotr_version(void **state); -void cmd_otr_gen_shows_message_when_not_connected(void **state); -void cmd_otr_gen_generates_key_for_connected_account(void **state); -void cmd_otr_gen_shows_message_when_disconnected(void **state); -void cmd_otr_gen_shows_message_when_undefined(void **state); -void cmd_otr_gen_shows_message_when_connecting(void **state); -void cmd_otr_gen_shows_message_when_disconnecting(void **state); -void cmd_otr_myfp_shows_message_when_disconnected(void **state); -void cmd_otr_myfp_shows_message_when_undefined(void **state); -void cmd_otr_myfp_shows_message_when_connecting(void **state); -void cmd_otr_myfp_shows_message_when_disconnecting(void **state); -void cmd_otr_myfp_shows_message_when_no_key(void **state); -void cmd_otr_myfp_shows_my_fingerprint(void **state); -void cmd_otr_theirfp_shows_message_when_in_console(void **state); -void cmd_otr_theirfp_shows_message_when_in_muc(void **state); -void cmd_otr_theirfp_shows_message_when_in_private(void **state); -void cmd_otr_theirfp_shows_message_when_non_otr_chat_window(void **state); -void cmd_otr_theirfp_shows_fingerprint(void **state); -void cmd_otr_start_shows_message_when_in_console(void **state); -void cmd_otr_start_shows_message_when_in_muc(void **state); -void cmd_otr_start_shows_message_when_in_private(void **state); -void cmd_otr_start_shows_message_when_already_started(void **state); -void cmd_otr_start_shows_message_when_no_key(void **state); -void cmd_otr_start_sends_otr_query_message_to_current_recipeint(void **state); +void cmd_otr_log_shows_usage_when_no_args(void** state); +void cmd_otr_log_shows_usage_when_invalid_subcommand(void** state); +void cmd_otr_log_on_enables_logging(void** state); +void cmd_otr_log_off_disables_logging(void** state); +void cmd_otr_redact_redacts_logging(void** state); +void cmd_otr_log_on_shows_warning_when_chlog_disabled(void** state); +void cmd_otr_log_redact_shows_warning_when_chlog_disabled(void** state); +void cmd_otr_libver_shows_libotr_version(void** state); +void cmd_otr_gen_shows_message_when_not_connected(void** state); +void cmd_otr_gen_generates_key_for_connected_account(void** state); +void cmd_otr_gen_shows_message_when_disconnected(void** state); +void cmd_otr_gen_shows_message_when_undefined(void** state); +void cmd_otr_gen_shows_message_when_connecting(void** state); +void cmd_otr_gen_shows_message_when_disconnecting(void** state); +void cmd_otr_myfp_shows_message_when_disconnected(void** state); +void cmd_otr_myfp_shows_message_when_undefined(void** state); +void cmd_otr_myfp_shows_message_when_connecting(void** state); +void cmd_otr_myfp_shows_message_when_disconnecting(void** state); +void cmd_otr_myfp_shows_message_when_no_key(void** state); +void cmd_otr_myfp_shows_my_fingerprint(void** state); +void cmd_otr_theirfp_shows_message_when_in_console(void** state); +void cmd_otr_theirfp_shows_message_when_in_muc(void** state); +void cmd_otr_theirfp_shows_message_when_in_private(void** state); +void cmd_otr_theirfp_shows_message_when_non_otr_chat_window(void** state); +void cmd_otr_theirfp_shows_fingerprint(void** state); +void cmd_otr_start_shows_message_when_in_console(void** state); +void cmd_otr_start_shows_message_when_in_muc(void** state); +void cmd_otr_start_shows_message_when_in_private(void** state); +void cmd_otr_start_shows_message_when_already_started(void** state); +void cmd_otr_start_shows_message_when_no_key(void** state); +void cmd_otr_start_sends_otr_query_message_to_current_recipeint(void** state); #else -void cmd_otr_shows_message_when_otr_unsupported(void **state); +void cmd_otr_shows_message_when_otr_unsupported(void** state); #endif diff --git a/tests/unittests/test_cmd_pgp.c b/tests/unittests/test_cmd_pgp.c index 0754773a..55130dac 100644 --- a/tests/unittests/test_cmd_pgp.c +++ b/tests/unittests/test_cmd_pgp.c @@ -16,9 +16,10 @@ #define CMD_PGP "/pgp" #ifdef HAVE_LIBGPGME -void cmd_pgp_shows_usage_when_no_args(void **state) +void +cmd_pgp_shows_usage_when_no_args(void** state) { - gchar *args[] = { NULL }; + gchar* args[] = { NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_PGP); @@ -26,9 +27,10 @@ void cmd_pgp_shows_usage_when_no_args(void **state) assert_true(result); } -void cmd_pgp_start_shows_message_when_connection(jabber_conn_status_t conn_status) +void +cmd_pgp_start_shows_message_when_connection(jabber_conn_status_t conn_status) { - gchar *args[] = { "start", NULL }; + gchar* args[] = { "start", NULL }; ProfWin window; window.type = WIN_CHAT; @@ -40,24 +42,28 @@ void cmd_pgp_start_shows_message_when_connection(jabber_conn_status_t conn_statu assert_true(result); } -void cmd_pgp_start_shows_message_when_disconnected(void **state) +void +cmd_pgp_start_shows_message_when_disconnected(void** state) { cmd_pgp_start_shows_message_when_connection(JABBER_DISCONNECTED); } -void cmd_pgp_start_shows_message_when_disconnecting(void **state) +void +cmd_pgp_start_shows_message_when_disconnecting(void** state) { cmd_pgp_start_shows_message_when_connection(JABBER_DISCONNECTING); } -void cmd_pgp_start_shows_message_when_connecting(void **state) +void +cmd_pgp_start_shows_message_when_connecting(void** state) { cmd_pgp_start_shows_message_when_connection(JABBER_CONNECTING); } -void cmd_pgp_start_shows_message_when_no_arg_in_wintype(win_type_t wintype) +void +cmd_pgp_start_shows_message_when_no_arg_in_wintype(win_type_t wintype) { - gchar *args[] = { "start", NULL }; + gchar* args[] = { "start", NULL }; ProfWin window; window.type = wintype; @@ -69,35 +75,41 @@ void cmd_pgp_start_shows_message_when_no_arg_in_wintype(win_type_t wintype) assert_true(result); } -void cmd_pgp_start_shows_message_when_no_arg_in_console(void **state) +void +cmd_pgp_start_shows_message_when_no_arg_in_console(void** state) { cmd_pgp_start_shows_message_when_no_arg_in_wintype(WIN_CONSOLE); } -void cmd_pgp_start_shows_message_when_no_arg_in_muc(void **state) +void +cmd_pgp_start_shows_message_when_no_arg_in_muc(void** state) { cmd_pgp_start_shows_message_when_no_arg_in_wintype(WIN_MUC); } -void cmd_pgp_start_shows_message_when_no_arg_in_conf(void **state) +void +cmd_pgp_start_shows_message_when_no_arg_in_conf(void** state) { cmd_pgp_start_shows_message_when_no_arg_in_wintype(WIN_CONFIG); } -void cmd_pgp_start_shows_message_when_no_arg_in_private(void **state) +void +cmd_pgp_start_shows_message_when_no_arg_in_private(void** state) { cmd_pgp_start_shows_message_when_no_arg_in_wintype(WIN_PRIVATE); } -void cmd_pgp_start_shows_message_when_no_arg_in_xmlconsole(void **state) +void +cmd_pgp_start_shows_message_when_no_arg_in_xmlconsole(void** state) { cmd_pgp_start_shows_message_when_no_arg_in_wintype(WIN_XML); } #else -void cmd_pgp_shows_message_when_pgp_unsupported(void **state) +void +cmd_pgp_shows_message_when_pgp_unsupported(void** state) { - gchar *args[] = { "gen", NULL }; + gchar* args[] = { "gen", NULL }; expect_cons_show("This version of Profanity has not been built with PGP support enabled"); diff --git a/tests/unittests/test_cmd_pgp.h b/tests/unittests/test_cmd_pgp.h index d6082ecb..60110beb 100644 --- a/tests/unittests/test_cmd_pgp.h +++ b/tests/unittests/test_cmd_pgp.h @@ -1,16 +1,16 @@ #include "config.h" #ifdef HAVE_LIBGPGME -void cmd_pgp_shows_usage_when_no_args(void **state); -void cmd_pgp_start_shows_message_when_disconnected(void **state); -void cmd_pgp_start_shows_message_when_disconnecting(void **state); -void cmd_pgp_start_shows_message_when_connecting(void **state); -void cmd_pgp_start_shows_message_when_undefined(void **state); -void cmd_pgp_start_shows_message_when_no_arg_in_console(void **state); -void cmd_pgp_start_shows_message_when_no_arg_in_muc(void **state); -void cmd_pgp_start_shows_message_when_no_arg_in_conf(void **state); -void cmd_pgp_start_shows_message_when_no_arg_in_private(void **state); -void cmd_pgp_start_shows_message_when_no_arg_in_xmlconsole(void **state); +void cmd_pgp_shows_usage_when_no_args(void** state); +void cmd_pgp_start_shows_message_when_disconnected(void** state); +void cmd_pgp_start_shows_message_when_disconnecting(void** state); +void cmd_pgp_start_shows_message_when_connecting(void** state); +void cmd_pgp_start_shows_message_when_undefined(void** state); +void cmd_pgp_start_shows_message_when_no_arg_in_console(void** state); +void cmd_pgp_start_shows_message_when_no_arg_in_muc(void** state); +void cmd_pgp_start_shows_message_when_no_arg_in_conf(void** state); +void cmd_pgp_start_shows_message_when_no_arg_in_private(void** state); +void cmd_pgp_start_shows_message_when_no_arg_in_xmlconsole(void** state); #else -void cmd_pgp_shows_message_when_pgp_unsupported(void **state); +void cmd_pgp_shows_message_when_pgp_unsupported(void** state); #endif diff --git a/tests/unittests/test_cmd_presence.c b/tests/unittests/test_cmd_presence.c index d4bc8904..0c4e1ffa 100644 --- a/tests/unittests/test_cmd_presence.c +++ b/tests/unittests/test_cmd_presence.c @@ -15,9 +15,10 @@ #define CMD_PRESENCE "/presence" -void cmd_presence_shows_usage_when_bad_subcmd(void **state) +void +cmd_presence_shows_usage_when_bad_subcmd(void** state) { - gchar *args[] = { "badcmd", NULL }; + gchar* args[] = { "badcmd", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_PRESENCE); @@ -25,9 +26,10 @@ void cmd_presence_shows_usage_when_bad_subcmd(void **state) assert_true(result); } -void cmd_presence_shows_usage_when_bad_console_setting(void **state) +void +cmd_presence_shows_usage_when_bad_console_setting(void** state) { - gchar *args[] = { "console", "badsetting", NULL }; + gchar* args[] = { "console", "badsetting", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_PRESENCE); @@ -35,9 +37,10 @@ void cmd_presence_shows_usage_when_bad_console_setting(void **state) assert_true(result); } -void cmd_presence_shows_usage_when_bad_chat_setting(void **state) +void +cmd_presence_shows_usage_when_bad_chat_setting(void** state) { - gchar *args[] = { "chat", "badsetting", NULL }; + gchar* args[] = { "chat", "badsetting", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_PRESENCE); @@ -45,9 +48,10 @@ void cmd_presence_shows_usage_when_bad_chat_setting(void **state) assert_true(result); } -void cmd_presence_shows_usage_when_bad_muc_setting(void **state) +void +cmd_presence_shows_usage_when_bad_muc_setting(void** state) { - gchar *args[] = { "muc", "badsetting", NULL }; + gchar* args[] = { "muc", "badsetting", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_PRESENCE); @@ -55,135 +59,144 @@ void cmd_presence_shows_usage_when_bad_muc_setting(void **state) assert_true(result); } -void cmd_presence_console_sets_all(void **state) +void +cmd_presence_console_sets_all(void** state) { - gchar *args[] = { "console", "all", NULL }; + gchar* args[] = { "console", "all", NULL }; expect_cons_show("All presence updates will appear in the console."); gboolean result = cmd_presence(NULL, CMD_PRESENCE, args); - char *setting = prefs_get_string(PREF_STATUSES_CONSOLE); + char* setting = prefs_get_string(PREF_STATUSES_CONSOLE); assert_non_null(setting); assert_string_equal("all", setting); assert_true(result); g_free(setting); } -void cmd_presence_console_sets_online(void **state) +void +cmd_presence_console_sets_online(void** state) { - gchar *args[] = { "console", "online", NULL }; + gchar* args[] = { "console", "online", NULL }; expect_cons_show("Only online/offline presence updates will appear in the console."); gboolean result = cmd_presence(NULL, CMD_PRESENCE, args); - char *setting = prefs_get_string(PREF_STATUSES_CONSOLE); + char* setting = prefs_get_string(PREF_STATUSES_CONSOLE); assert_non_null(setting); assert_string_equal("online", setting); assert_true(result); g_free(setting); } -void cmd_presence_console_sets_none(void **state) +void +cmd_presence_console_sets_none(void** state) { - gchar *args[] = { "console", "none", NULL }; + gchar* args[] = { "console", "none", NULL }; expect_cons_show("Presence updates will not appear in the console."); gboolean result = cmd_presence(NULL, CMD_PRESENCE, args); - char *setting = prefs_get_string(PREF_STATUSES_CONSOLE); + char* setting = prefs_get_string(PREF_STATUSES_CONSOLE); assert_non_null(setting); assert_string_equal("none", setting); assert_true(result); g_free(setting); } -void cmd_presence_chat_sets_all(void **state) +void +cmd_presence_chat_sets_all(void** state) { - gchar *args[] = { "chat", "all", NULL }; + gchar* args[] = { "chat", "all", NULL }; expect_cons_show("All presence updates will appear in chat windows."); gboolean result = cmd_presence(NULL, CMD_PRESENCE, args); - char *setting = prefs_get_string(PREF_STATUSES_CHAT); + char* setting = prefs_get_string(PREF_STATUSES_CHAT); assert_non_null(setting); assert_string_equal("all", setting); assert_true(result); g_free(setting); } -void cmd_presence_chat_sets_online(void **state) +void +cmd_presence_chat_sets_online(void** state) { - gchar *args[] = { "chat", "online", NULL }; + gchar* args[] = { "chat", "online", NULL }; expect_cons_show("Only online/offline presence updates will appear in chat windows."); gboolean result = cmd_presence(NULL, CMD_PRESENCE, args); - char *setting = prefs_get_string(PREF_STATUSES_CHAT); + char* setting = prefs_get_string(PREF_STATUSES_CHAT); assert_non_null(setting); assert_string_equal("online", setting); assert_true(result); g_free(setting); } -void cmd_presence_chat_sets_none(void **state) +void +cmd_presence_chat_sets_none(void** state) { - gchar *args[] = { "chat", "none", NULL }; + gchar* args[] = { "chat", "none", NULL }; expect_cons_show("Presence updates will not appear in chat windows."); gboolean result = cmd_presence(NULL, CMD_PRESENCE, args); - char *setting = prefs_get_string(PREF_STATUSES_CHAT); + char* setting = prefs_get_string(PREF_STATUSES_CHAT); assert_non_null(setting); assert_string_equal("none", setting); assert_true(result); g_free(setting); } -void cmd_presence_room_sets_all(void **state) +void +cmd_presence_room_sets_all(void** state) { - gchar *args[] = { "room", "all", NULL }; + gchar* args[] = { "room", "all", NULL }; expect_cons_show("All presence updates will appear in chat room windows."); gboolean result = cmd_presence(NULL, CMD_PRESENCE, args); - char *setting = prefs_get_string(PREF_STATUSES_MUC); + char* setting = prefs_get_string(PREF_STATUSES_MUC); assert_non_null(setting); assert_string_equal("all", setting); assert_true(result); g_free(setting); } -void cmd_presence_room_sets_online(void **state) +void +cmd_presence_room_sets_online(void** state) { - gchar *args[] = { "room", "online", NULL }; + gchar* args[] = { "room", "online", NULL }; expect_cons_show("Only join/leave presence updates will appear in chat room windows."); gboolean result = cmd_presence(NULL, CMD_PRESENCE, args); - char *setting = prefs_get_string(PREF_STATUSES_MUC); + char* setting = prefs_get_string(PREF_STATUSES_MUC); assert_non_null(setting); assert_string_equal("online", setting); assert_true(result); g_free(setting); } -void cmd_presence_room_sets_none(void **state) +void +cmd_presence_room_sets_none(void** state) { - gchar *args[] = { "room", "none", NULL }; + gchar* args[] = { "room", "none", NULL }; expect_cons_show("Presence updates will not appear in chat room windows."); gboolean result = cmd_presence(NULL, CMD_PRESENCE, args); - char *setting = prefs_get_string(PREF_STATUSES_MUC); + char* setting = prefs_get_string(PREF_STATUSES_MUC); assert_non_null(setting); assert_string_equal("none", setting); assert_true(result); diff --git a/tests/unittests/test_cmd_presence.h b/tests/unittests/test_cmd_presence.h index 620921ae..96668db2 100644 --- a/tests/unittests/test_cmd_presence.h +++ b/tests/unittests/test_cmd_presence.h @@ -1,13 +1,13 @@ -void cmd_presence_shows_usage_when_bad_subcmd(void **state); -void cmd_presence_shows_usage_when_bad_console_setting(void **state); -void cmd_presence_shows_usage_when_bad_chat_setting(void **state); -void cmd_presence_shows_usage_when_bad_muc_setting(void **state); -void cmd_presence_console_sets_all(void **state); -void cmd_presence_console_sets_online(void **state); -void cmd_presence_console_sets_none(void **state); -void cmd_presence_chat_sets_all(void **state); -void cmd_presence_chat_sets_online(void **state); -void cmd_presence_chat_sets_none(void **state); -void cmd_presence_room_sets_all(void **state); -void cmd_presence_room_sets_online(void **state); -void cmd_presence_room_sets_none(void **state); +void cmd_presence_shows_usage_when_bad_subcmd(void** state); +void cmd_presence_shows_usage_when_bad_console_setting(void** state); +void cmd_presence_shows_usage_when_bad_chat_setting(void** state); +void cmd_presence_shows_usage_when_bad_muc_setting(void** state); +void cmd_presence_console_sets_all(void** state); +void cmd_presence_console_sets_online(void** state); +void cmd_presence_console_sets_none(void** state); +void cmd_presence_chat_sets_all(void** state); +void cmd_presence_chat_sets_online(void** state); +void cmd_presence_chat_sets_none(void** state); +void cmd_presence_room_sets_all(void** state); +void cmd_presence_room_sets_online(void** state); +void cmd_presence_room_sets_none(void** state); diff --git a/tests/unittests/test_cmd_rooms.c b/tests/unittests/test_cmd_rooms.c index 96e29602..8cdc27b2 100644 --- a/tests/unittests/test_cmd_rooms.c +++ b/tests/unittests/test_cmd_rooms.c @@ -16,7 +16,8 @@ #define CMD_ROOMS "/rooms" -static void test_with_connection_status(jabber_conn_status_t status) +static void +test_with_connection_status(jabber_conn_status_t status) { will_return(connection_get_status, status); @@ -26,27 +27,31 @@ static void test_with_connection_status(jabber_conn_status_t status) assert_true(result); } -void cmd_rooms_shows_message_when_disconnected(void **state) +void +cmd_rooms_shows_message_when_disconnected(void** state) { test_with_connection_status(JABBER_DISCONNECTED); } -void cmd_rooms_shows_message_when_disconnecting(void **state) +void +cmd_rooms_shows_message_when_disconnecting(void** state) { test_with_connection_status(JABBER_DISCONNECTING); } -void cmd_rooms_shows_message_when_connecting(void **state) +void +cmd_rooms_shows_message_when_connecting(void** state) { test_with_connection_status(JABBER_CONNECTING); } -void cmd_rooms_uses_account_default_when_no_arg(void **state) +void +cmd_rooms_uses_account_default_when_no_arg(void** state) { - gchar *args[] = { NULL }; + gchar* args[] = { NULL }; - ProfAccount *account = account_new("testaccount", NULL, NULL, NULL, TRUE, NULL, 0, NULL, NULL, NULL, - 0, 0, 0, 0, 0, "default_conf_server", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ProfAccount* account = account_new("testaccount", NULL, NULL, NULL, TRUE, NULL, 0, NULL, NULL, NULL, + 0, 0, 0, 0, 0, "default_conf_server", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); will_return(connection_get_status, JABBER_CONNECTED); will_return(session_get_account_name, "account_name"); @@ -63,9 +68,10 @@ void cmd_rooms_uses_account_default_when_no_arg(void **state) assert_true(result); } -void cmd_rooms_service_arg_used_when_passed(void **state) +void +cmd_rooms_service_arg_used_when_passed(void** state) { - gchar *args[] = { "service", "conf_server_arg", NULL }; + gchar* args[] = { "service", "conf_server_arg", NULL }; will_return(connection_get_status, JABBER_CONNECTED); @@ -79,13 +85,13 @@ void cmd_rooms_service_arg_used_when_passed(void **state) assert_true(result); } -void cmd_rooms_filter_arg_used_when_passed(void **state) +void +cmd_rooms_filter_arg_used_when_passed(void** state) { - gchar *args[] = { "filter", "text", NULL }; + gchar* args[] = { "filter", "text", NULL }; - - ProfAccount *account = account_new("testaccount", NULL, NULL, NULL, TRUE, NULL, 0, NULL, NULL, NULL, - 0, 0, 0, 0, 0, "default_conf_server", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ProfAccount* account = account_new("testaccount", NULL, NULL, NULL, TRUE, NULL, 0, NULL, NULL, NULL, + 0, 0, 0, 0, 0, "default_conf_server", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); will_return(connection_get_status, JABBER_CONNECTED); will_return(session_get_account_name, "account_name"); diff --git a/tests/unittests/test_cmd_rooms.h b/tests/unittests/test_cmd_rooms.h index 4d656948..d1107d78 100644 --- a/tests/unittests/test_cmd_rooms.h +++ b/tests/unittests/test_cmd_rooms.h @@ -1,7 +1,7 @@ -void cmd_rooms_shows_message_when_disconnected(void **state); -void cmd_rooms_shows_message_when_disconnecting(void **state); -void cmd_rooms_shows_message_when_connecting(void **state); -void cmd_rooms_shows_message_when_undefined(void **state); -void cmd_rooms_uses_account_default_when_no_arg(void **state); -void cmd_rooms_service_arg_used_when_passed(void **state); -void cmd_rooms_filter_arg_used_when_passed(void **state); +void cmd_rooms_shows_message_when_disconnected(void** state); +void cmd_rooms_shows_message_when_disconnecting(void** state); +void cmd_rooms_shows_message_when_connecting(void** state); +void cmd_rooms_shows_message_when_undefined(void** state); +void cmd_rooms_uses_account_default_when_no_arg(void** state); +void cmd_rooms_service_arg_used_when_passed(void** state); +void cmd_rooms_filter_arg_used_when_passed(void** state); diff --git a/tests/unittests/test_cmd_roster.c b/tests/unittests/test_cmd_roster.c index 845fa67f..3908ba58 100644 --- a/tests/unittests/test_cmd_roster.c +++ b/tests/unittests/test_cmd_roster.c @@ -15,9 +15,10 @@ #define CMD_ROSTER "/roster" -static void test_with_connection_status(jabber_conn_status_t status) +static void +test_with_connection_status(jabber_conn_status_t status) { - gchar *args[] = { NULL }; + gchar* args[] = { NULL }; will_return(connection_get_status, status); @@ -27,30 +28,34 @@ static void test_with_connection_status(jabber_conn_status_t status) assert_true(result); } -void cmd_roster_shows_message_when_disconnecting(void **state) +void +cmd_roster_shows_message_when_disconnecting(void** state) { test_with_connection_status(JABBER_DISCONNECTING); } -void cmd_roster_shows_message_when_connecting(void **state) +void +cmd_roster_shows_message_when_connecting(void** state) { test_with_connection_status(JABBER_CONNECTING); } -void cmd_roster_shows_message_when_disconnected(void **state) +void +cmd_roster_shows_message_when_disconnected(void** state) { test_with_connection_status(JABBER_DISCONNECTED); } -void cmd_roster_shows_roster_when_no_args(void **state) +void +cmd_roster_shows_roster_when_no_args(void** state) { - gchar *args[] = { NULL }; + gchar* args[] = { NULL }; will_return(connection_get_status, JABBER_CONNECTED); roster_create(); roster_add("bob@server.org", "bob", NULL, "both", FALSE); - GSList *roster = roster_get_contacts(ROSTER_ORD_NAME); + GSList* roster = roster_get_contacts(ROSTER_ORD_NAME); expect_memory(cons_show_roster, list, roster, sizeof(roster)); @@ -61,9 +66,10 @@ void cmd_roster_shows_roster_when_no_args(void **state) roster_destroy(); } -void cmd_roster_add_shows_message_when_no_jid(void **state) +void +cmd_roster_add_shows_message_when_no_jid(void** state) { - gchar *args[] = { "add", NULL }; + gchar* args[] = { "add", NULL }; will_return(connection_get_status, JABBER_CONNECTED); @@ -73,11 +79,12 @@ void cmd_roster_add_shows_message_when_no_jid(void **state) assert_true(result); } -void cmd_roster_add_sends_roster_add_request(void **state) +void +cmd_roster_add_sends_roster_add_request(void** state) { - char *jid = "bob@server.org"; - char *nick = "bob"; - gchar *args[] = { "add", jid, nick, NULL }; + char* jid = "bob@server.org"; + char* nick = "bob"; + gchar* args[] = { "add", jid, nick, NULL }; will_return(connection_get_status, JABBER_CONNECTED); @@ -88,9 +95,10 @@ void cmd_roster_add_sends_roster_add_request(void **state) assert_true(result); } -void cmd_roster_remove_shows_message_when_no_jid(void **state) +void +cmd_roster_remove_shows_message_when_no_jid(void** state) { - gchar *args[] = { "remove", NULL }; + gchar* args[] = { "remove", NULL }; will_return(connection_get_status, JABBER_CONNECTED); @@ -100,10 +108,11 @@ void cmd_roster_remove_shows_message_when_no_jid(void **state) assert_true(result); } -void cmd_roster_remove_sends_roster_remove_request(void **state) +void +cmd_roster_remove_sends_roster_remove_request(void** state) { - char *jid = "bob@server.org"; - gchar *args[] = { "remove", jid, NULL }; + char* jid = "bob@server.org"; + gchar* args[] = { "remove", jid, NULL }; will_return(connection_get_status, JABBER_CONNECTED); @@ -113,9 +122,10 @@ void cmd_roster_remove_sends_roster_remove_request(void **state) assert_true(result); } -void cmd_roster_nick_shows_message_when_no_jid(void **state) +void +cmd_roster_nick_shows_message_when_no_jid(void** state) { - gchar *args[] = { "nick", NULL }; + gchar* args[] = { "nick", NULL }; will_return(connection_get_status, JABBER_CONNECTED); @@ -125,9 +135,10 @@ void cmd_roster_nick_shows_message_when_no_jid(void **state) assert_true(result); } -void cmd_roster_nick_shows_message_when_no_nick(void **state) +void +cmd_roster_nick_shows_message_when_no_nick(void** state) { - gchar *args[] = { "nick", "bob@server.org", NULL }; + gchar* args[] = { "nick", "bob@server.org", NULL }; will_return(connection_get_status, JABBER_CONNECTED); @@ -137,9 +148,10 @@ void cmd_roster_nick_shows_message_when_no_nick(void **state) assert_true(result); } -void cmd_roster_nick_shows_message_when_no_contact_exists(void **state) +void +cmd_roster_nick_shows_message_when_no_contact_exists(void** state) { - gchar *args[] = { "nick", "bob@server.org", "bobster", NULL }; + gchar* args[] = { "nick", "bob@server.org", "bobster", NULL }; roster_create(); @@ -153,14 +165,15 @@ void cmd_roster_nick_shows_message_when_no_contact_exists(void **state) roster_destroy(); } -void cmd_roster_nick_sends_name_change_request(void **state) +void +cmd_roster_nick_sends_name_change_request(void** state) { - char *jid = "bob@server.org"; - char *nick = "bobster"; - gchar *args[] = { "nick", jid, nick, NULL }; + char* jid = "bob@server.org"; + char* nick = "bobster"; + gchar* args[] = { "nick", jid, nick, NULL }; roster_create(); - GSList *groups = NULL; + GSList* groups = NULL; groups = g_slist_append(groups, strdup("group1")); roster_add(jid, "bob", groups, "both", FALSE); @@ -181,9 +194,10 @@ void cmd_roster_nick_sends_name_change_request(void **state) roster_destroy(); } -void cmd_roster_clearnick_shows_message_when_no_jid(void **state) +void +cmd_roster_clearnick_shows_message_when_no_jid(void** state) { - gchar *args[] = { "clearnick", NULL }; + gchar* args[] = { "clearnick", NULL }; will_return(connection_get_status, JABBER_CONNECTED); @@ -193,9 +207,10 @@ void cmd_roster_clearnick_shows_message_when_no_jid(void **state) assert_true(result); } -void cmd_roster_clearnick_shows_message_when_no_contact_exists(void **state) +void +cmd_roster_clearnick_shows_message_when_no_contact_exists(void** state) { - gchar *args[] = { "clearnick", "bob@server.org", NULL }; + gchar* args[] = { "clearnick", "bob@server.org", NULL }; roster_create(); @@ -209,13 +224,14 @@ void cmd_roster_clearnick_shows_message_when_no_contact_exists(void **state) roster_destroy(); } -void cmd_roster_clearnick_sends_name_change_request_with_empty_nick(void **state) +void +cmd_roster_clearnick_sends_name_change_request_with_empty_nick(void** state) { - char *jid = "bob@server.org"; - gchar *args[] = { "clearnick", jid, NULL }; + char* jid = "bob@server.org"; + gchar* args[] = { "clearnick", jid, NULL }; roster_create(); - GSList *groups = NULL; + GSList* groups = NULL; groups = g_slist_append(groups, strdup("group1")); roster_add(jid, "bob", groups, "both", FALSE); diff --git a/tests/unittests/test_cmd_roster.h b/tests/unittests/test_cmd_roster.h index 79f69ec8..49bd8db3 100644 --- a/tests/unittests/test_cmd_roster.h +++ b/tests/unittests/test_cmd_roster.h @@ -1,16 +1,16 @@ -void cmd_roster_shows_message_when_disconnecting(void **state); -void cmd_roster_shows_message_when_connecting(void **state); -void cmd_roster_shows_message_when_disconnected(void **state); -void cmd_roster_shows_message_when_undefined(void **state); -void cmd_roster_shows_roster_when_no_args(void **state); -void cmd_roster_add_shows_message_when_no_jid(void **state); -void cmd_roster_add_sends_roster_add_request(void **state); -void cmd_roster_remove_shows_message_when_no_jid(void **state); -void cmd_roster_remove_sends_roster_remove_request(void **state); -void cmd_roster_nick_shows_message_when_no_jid(void **state); -void cmd_roster_nick_shows_message_when_no_nick(void **state); -void cmd_roster_nick_shows_message_when_no_contact_exists(void **state); -void cmd_roster_nick_sends_name_change_request(void **state); -void cmd_roster_clearnick_shows_message_when_no_jid(void **state); -void cmd_roster_clearnick_shows_message_when_no_contact_exists(void **state); -void cmd_roster_clearnick_sends_name_change_request_with_empty_nick(void **state); +void cmd_roster_shows_message_when_disconnecting(void** state); +void cmd_roster_shows_message_when_connecting(void** state); +void cmd_roster_shows_message_when_disconnected(void** state); +void cmd_roster_shows_message_when_undefined(void** state); +void cmd_roster_shows_roster_when_no_args(void** state); +void cmd_roster_add_shows_message_when_no_jid(void** state); +void cmd_roster_add_sends_roster_add_request(void** state); +void cmd_roster_remove_shows_message_when_no_jid(void** state); +void cmd_roster_remove_sends_roster_remove_request(void** state); +void cmd_roster_nick_shows_message_when_no_jid(void** state); +void cmd_roster_nick_shows_message_when_no_nick(void** state); +void cmd_roster_nick_shows_message_when_no_contact_exists(void** state); +void cmd_roster_nick_sends_name_change_request(void** state); +void cmd_roster_clearnick_shows_message_when_no_jid(void** state); +void cmd_roster_clearnick_shows_message_when_no_contact_exists(void** state); +void cmd_roster_clearnick_sends_name_change_request_with_empty_nick(void** state); diff --git a/tests/unittests/test_cmd_sub.c b/tests/unittests/test_cmd_sub.c index 4afe8752..d03f6b5c 100644 --- a/tests/unittests/test_cmd_sub.c +++ b/tests/unittests/test_cmd_sub.c @@ -15,9 +15,10 @@ #define CMD_SUB "/sub" -void cmd_sub_shows_message_when_not_connected(void **state) +void +cmd_sub_shows_message_when_not_connected(void** state) { - gchar *args[] = { NULL }; + gchar* args[] = { NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -27,9 +28,10 @@ void cmd_sub_shows_message_when_not_connected(void **state) assert_true(result); } -void cmd_sub_shows_usage_when_no_arg(void **state) +void +cmd_sub_shows_usage_when_no_arg(void** state) { - gchar *args[] = { NULL }; + gchar* args[] = { NULL }; will_return(connection_get_status, JABBER_CONNECTED); diff --git a/tests/unittests/test_cmd_sub.h b/tests/unittests/test_cmd_sub.h index 6e8addd3..6cebf649 100644 --- a/tests/unittests/test_cmd_sub.h +++ b/tests/unittests/test_cmd_sub.h @@ -1,2 +1,2 @@ -void cmd_sub_shows_message_when_not_connected(void **state); -void cmd_sub_shows_usage_when_no_arg(void **state); +void cmd_sub_shows_message_when_not_connected(void** state); +void cmd_sub_shows_usage_when_no_arg(void** state); diff --git a/tests/unittests/test_common.c b/tests/unittests/test_common.c index b6ae4bb9..b8958dda 100644 --- a/tests/unittests/test_common.c +++ b/tests/unittests/test_common.c @@ -6,293 +6,324 @@ #include <cmocka.h> #include <stdlib.h> -void replace_one_substr(void **state) +void +replace_one_substr(void** state) { - char *string = "it is a string"; - char *sub = "is"; - char *new = "was"; + char* string = "it is a string"; + char* sub = "is"; + char* new = "was"; - char *result = str_replace(string, sub, new); + char* result = str_replace(string, sub, new); assert_string_equal("it was a string", result); free(result); } -void replace_one_substr_beginning(void **state) +void +replace_one_substr_beginning(void** state) { - char *string = "it is a string"; - char *sub = "it"; - char *new = "that"; + char* string = "it is a string"; + char* sub = "it"; + char* new = "that"; - char *result = str_replace(string, sub, new); + char* result = str_replace(string, sub, new); assert_string_equal("that is a string", result); free(result); } -void replace_one_substr_end(void **state) +void +replace_one_substr_end(void** state) { - char *string = "it is a string"; - char *sub = "string"; - char *new = "thing"; + char* string = "it is a string"; + char* sub = "string"; + char* new = "thing"; - char *result = str_replace(string, sub, new); + char* result = str_replace(string, sub, new); assert_string_equal("it is a thing", result); free(result); } -void replace_two_substr(void **state) +void +replace_two_substr(void** state) { - char *string = "it is a is string"; - char *sub = "is"; - char *new = "was"; + char* string = "it is a is string"; + char* sub = "is"; + char* new = "was"; - char *result = str_replace(string, sub, new); + char* result = str_replace(string, sub, new); assert_string_equal("it was a was string", result); free(result); } -void replace_char(void **state) +void +replace_char(void** state) { - char *string = "some & a thing & something else"; - char *sub = "&"; - char *new = "&"; + char* string = "some & a thing & something else"; + char* sub = "&"; + char* new = "&"; - char *result = str_replace(string, sub, new); + char* result = str_replace(string, sub, new); assert_string_equal("some & a thing & something else", result); free(result); } -void replace_when_none(void **state) +void +replace_when_none(void** state) { - char *string = "its another string"; - char *sub = "haha"; - char *new = "replaced"; + char* string = "its another string"; + char* sub = "haha"; + char* new = "replaced"; - char *result = str_replace(string, sub, new); + char* result = str_replace(string, sub, new); assert_string_equal("its another string", result); free(result); } -void replace_when_match(void **state) +void +replace_when_match(void** state) { - char *string = "hello"; - char *sub = "hello"; - char *new = "goodbye"; + char* string = "hello"; + char* sub = "hello"; + char* new = "goodbye"; - char *result = str_replace(string, sub, new); + char* result = str_replace(string, sub, new); assert_string_equal("goodbye", result); free(result); } -void replace_when_string_empty(void **state) +void +replace_when_string_empty(void** state) { - char *string = ""; - char *sub = "hello"; - char *new = "goodbye"; + char* string = ""; + char* sub = "hello"; + char* new = "goodbye"; - char *result = str_replace(string, sub, new); + char* result = str_replace(string, sub, new); assert_string_equal("", result); free(result); } -void replace_when_string_null(void **state) +void +replace_when_string_null(void** state) { - char *string = NULL; - char *sub = "hello"; - char *new = "goodbye"; + char* string = NULL; + char* sub = "hello"; + char* new = "goodbye"; - char *result = str_replace(string, sub, new); + char* result = str_replace(string, sub, new); assert_null(result); } -void replace_when_sub_empty(void **state) +void +replace_when_sub_empty(void** state) { - char *string = "hello"; - char *sub = ""; - char *new = "goodbye"; + char* string = "hello"; + char* sub = ""; + char* new = "goodbye"; - char *result = str_replace(string, sub, new); + char* result = str_replace(string, sub, new); assert_string_equal("hello", result); free(result); } -void replace_when_sub_null(void **state) +void +replace_when_sub_null(void** state) { - char *string = "hello"; - char *sub = NULL; - char *new = "goodbye"; + char* string = "hello"; + char* sub = NULL; + char* new = "goodbye"; - char *result = str_replace(string, sub, new); + char* result = str_replace(string, sub, new); assert_string_equal("hello", result); free(result); } -void replace_when_new_empty(void **state) +void +replace_when_new_empty(void** state) { - char *string = "hello"; - char *sub = "hello"; - char *new = ""; + char* string = "hello"; + char* sub = "hello"; + char* new = ""; - char *result = str_replace(string, sub, new); + char* result = str_replace(string, sub, new); assert_string_equal("", result); free(result); } -void replace_when_new_null(void **state) +void +replace_when_new_null(void** state) { - char *string = "hello"; - char *sub = "hello"; - char *new = NULL; + char* string = "hello"; + char* sub = "hello"; + char* new = NULL; - char *result = str_replace(string, sub, new); + char* result = str_replace(string, sub, new); assert_string_equal("hello", result); free(result); } -void test_online_is_valid_resource_presence_string(void **state) +void +test_online_is_valid_resource_presence_string(void** state) { assert_true(valid_resource_presence_string("online")); } -void test_chat_is_valid_resource_presence_string(void **state) +void +test_chat_is_valid_resource_presence_string(void** state) { assert_true(valid_resource_presence_string("chat")); } -void test_away_is_valid_resource_presence_string(void **state) +void +test_away_is_valid_resource_presence_string(void** state) { assert_true(valid_resource_presence_string("away")); } -void test_xa_is_valid_resource_presence_string(void **state) +void +test_xa_is_valid_resource_presence_string(void** state) { assert_true(valid_resource_presence_string("xa")); } -void test_dnd_is_valid_resource_presence_string(void **state) +void +test_dnd_is_valid_resource_presence_string(void** state) { assert_true(valid_resource_presence_string("dnd")); } -void test_available_is_not_valid_resource_presence_string(void **state) +void +test_available_is_not_valid_resource_presence_string(void** state) { assert_false(valid_resource_presence_string("available")); } -void test_unavailable_is_not_valid_resource_presence_string(void **state) +void +test_unavailable_is_not_valid_resource_presence_string(void** state) { assert_false(valid_resource_presence_string("unavailable")); } -void test_blah_is_not_valid_resource_presence_string(void **state) +void +test_blah_is_not_valid_resource_presence_string(void** state) { assert_false(valid_resource_presence_string("blah")); } -void utf8_display_len_null_str(void **state) +void +utf8_display_len_null_str(void** state) { int result = utf8_display_len(NULL); assert_int_equal(0, result); } -void utf8_display_len_1_non_wide(void **state) +void +utf8_display_len_1_non_wide(void** state) { int result = utf8_display_len("1"); assert_int_equal(1, result); } -void utf8_display_len_1_wide(void **state) +void +utf8_display_len_1_wide(void** state) { int result = utf8_display_len("四"); assert_int_equal(2, result); } -void utf8_display_len_non_wide(void **state) +void +utf8_display_len_non_wide(void** state) { int result = utf8_display_len("123456789abcdef"); assert_int_equal(15, result); } -void utf8_display_len_wide(void **state) +void +utf8_display_len_wide(void** state) { int result = utf8_display_len("12三四56"); assert_int_equal(8, result); } -void utf8_display_len_all_wide(void **state) +void +utf8_display_len_all_wide(void** state) { int result = utf8_display_len("ひらがな"); assert_int_equal(8, result); } -void strip_quotes_does_nothing_when_no_quoted(void **state) +void +strip_quotes_does_nothing_when_no_quoted(void** state) { - char *input = "/cmd test string"; + char* input = "/cmd test string"; - char *result = strip_arg_quotes(input); + char* result = strip_arg_quotes(input); assert_string_equal("/cmd test string", result); free(result); } -void strip_quotes_strips_first(void **state) +void +strip_quotes_strips_first(void** state) { - char *input = "/cmd \"test string"; + char* input = "/cmd \"test string"; - char *result = strip_arg_quotes(input); + char* result = strip_arg_quotes(input); assert_string_equal("/cmd test string", result); free(result); } -void strip_quotes_strips_last(void **state) +void +strip_quotes_strips_last(void** state) { - char *input = "/cmd test string\""; + char* input = "/cmd test string\""; - char *result = strip_arg_quotes(input); + char* result = strip_arg_quotes(input); assert_string_equal("/cmd test string", result); free(result); } -void strip_quotes_strips_both(void **state) +void +strip_quotes_strips_both(void** state) { - char *input = "/cmd \"test string\""; + char* input = "/cmd \"test string\""; - char *result = strip_arg_quotes(input); + char* result = strip_arg_quotes(input); assert_string_equal("/cmd test string", result); @@ -300,14 +331,14 @@ void strip_quotes_strips_both(void **state) } gboolean -_lists_equal(GSList *a, GSList *b) +_lists_equal(GSList* a, GSList* b) { if (g_slist_length(a) != g_slist_length(b)) { return FALSE; } - GSList *curra = a; - GSList *currb = b; + GSList* curra = a; + GSList* currb = b; while (curra) { int aval = GPOINTER_TO_INT(curra->data); @@ -324,145 +355,297 @@ _lists_equal(GSList *a, GSList *b) return TRUE; } -void prof_partial_occurrences_tests(void **state) +void +prof_partial_occurrences_tests(void** state) { - GSList *actual = NULL; - GSList *expected = NULL; + GSList* actual = NULL; + GSList* expected = NULL; assert_true(_lists_equal(prof_occurrences(NULL, NULL, 0, FALSE, &actual), expected)); - g_slist_free(actual); actual = NULL; - - assert_true(_lists_equal(prof_occurrences(NULL, "some string", 0, FALSE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", NULL, 0, FALSE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences(NULL, NULL, 0, FALSE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "Boothj5", 0, FALSE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("Boothj5", "boothj5", 0, FALSE, &actual), expected)); g_slist_free(actual); actual = NULL; + g_slist_free(actual); + actual = NULL; + + assert_true(_lists_equal(prof_occurrences(NULL, "some string", 0, FALSE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", NULL, 0, FALSE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences(NULL, NULL, 0, FALSE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "Boothj5", 0, FALSE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("Boothj5", "boothj5", 0, FALSE, &actual), expected)); + g_slist_free(actual); + actual = NULL; expected = g_slist_append(expected, GINT_TO_POINTER(0)); - assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5", 0, FALSE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5hello", 0, FALSE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5 hello", 0, FALSE, &actual), expected)); g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5", 0, FALSE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5hello", 0, FALSE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5 hello", 0, FALSE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; expected = g_slist_append(expected, GINT_TO_POINTER(5)); - assert_true(_lists_equal(prof_occurrences("boothj5", "helloboothj5", 0, FALSE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "helloboothj5hello", 0, FALSE, &actual), expected)); g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "helloboothj5", 0, FALSE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "helloboothj5hello", 0, FALSE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; expected = g_slist_append(expected, GINT_TO_POINTER(6)); - assert_true(_lists_equal(prof_occurrences("boothj5", "hello boothj5", 0, FALSE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "hello boothj5 hello", 0, FALSE, &actual), expected)); g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "hello boothj5", 0, FALSE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "hello boothj5 hello", 0, FALSE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; expected = g_slist_append(expected, GINT_TO_POINTER(0)); expected = g_slist_append(expected, GINT_TO_POINTER(7)); - assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5boothj5", 0, FALSE, &actual), expected)); g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5boothj5", 0, FALSE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; expected = g_slist_append(expected, GINT_TO_POINTER(0)); expected = g_slist_append(expected, GINT_TO_POINTER(12)); - assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5helloboothj5", 0, FALSE, &actual), expected)); g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5helloboothj5", 0, FALSE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; expected = g_slist_append(expected, GINT_TO_POINTER(0)); expected = g_slist_append(expected, GINT_TO_POINTER(14)); - assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5 hello boothj5", 0, FALSE, &actual), expected)); g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5 hello boothj5", 0, FALSE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; expected = g_slist_append(expected, GINT_TO_POINTER(2)); expected = g_slist_append(expected, GINT_TO_POINTER(16)); expected = g_slist_append(expected, GINT_TO_POINTER(29)); - assert_true(_lists_equal(prof_occurrences("boothj5", "hiboothj5 hello boothj5there boothj5s", 0, FALSE, &actual), expected)); g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "hiboothj5 hello boothj5there boothj5s", 0, FALSE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; } -void prof_whole_occurrences_tests(void **state) +void +prof_whole_occurrences_tests(void** state) { - GSList *actual = NULL; - GSList *expected = NULL; + GSList* actual = NULL; + GSList* expected = NULL; assert_true(_lists_equal(prof_occurrences(NULL, NULL, 0, FALSE, &actual), expected)); - g_slist_free(actual); actual = NULL; + g_slist_free(actual); + actual = NULL; expected = g_slist_append(expected, GINT_TO_POINTER(0)); - assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5 hi", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5: hi", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5, hi", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5 hi", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5: hi", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5, hi", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; expected = g_slist_append(expected, GINT_TO_POINTER(0)); - assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "我能吞下玻璃而", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "我能吞下玻璃而 hi", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "我能吞下玻璃而: hi", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "我能吞下玻璃而, hi", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "我能吞下玻璃而", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "我能吞下玻璃而 hi", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "我能吞下玻璃而: hi", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "我能吞下玻璃而, hi", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; expected = g_slist_append(expected, GINT_TO_POINTER(6)); - assert_true(_lists_equal(prof_occurrences("boothj5", "hello boothj5", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "hello boothj5 there", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "heyy @boothj5, there", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "hello boothj5", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "hello boothj5 there", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "heyy @boothj5, there", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; expected = g_slist_append(expected, GINT_TO_POINTER(6)); - assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hello 我能吞下玻璃而", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hello 我能吞下玻璃而 there", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "heyy @我能吞下玻璃而, there", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hello 我能吞下玻璃而", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hello 我能吞下玻璃而 there", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "heyy @我能吞下玻璃而, there", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; expected = g_slist_append(expected, GINT_TO_POINTER(6)); expected = g_slist_append(expected, GINT_TO_POINTER(26)); - assert_true(_lists_equal(prof_occurrences("boothj5", "hello boothj5 some more a boothj5 stuff", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "hello boothj5 there ands #boothj5", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "heyy @boothj5, there hows boothj5?", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "hello boothj5 some more a boothj5 stuff", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "hello boothj5 there ands #boothj5", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "heyy @boothj5, there hows boothj5?", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; expected = g_slist_append(expected, GINT_TO_POINTER(6)); expected = g_slist_append(expected, GINT_TO_POINTER(26)); - assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hello 我能吞下玻璃而 some more a 我能吞下玻璃而 stuff", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hello 我能吞下玻璃而 there ands #我能吞下玻璃而", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "heyy @我能吞下玻璃而, there hows 我能吞下玻璃而?", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hello 我能吞下玻璃而 some more a 我能吞下玻璃而 stuff", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hello 我能吞下玻璃而 there ands #我能吞下玻璃而", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "heyy @我能吞下玻璃而, there hows 我能吞下玻璃而?", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; expected = g_slist_append(expected, GINT_TO_POINTER(6)); - assert_true(_lists_equal(prof_occurrences("p", "ppppp p", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + assert_true(_lists_equal(prof_occurrences("p", "ppppp p", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; expected = g_slist_append(expected, GINT_TO_POINTER(0)); - assert_true(_lists_equal(prof_occurrences("p", "p ppppp", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + assert_true(_lists_equal(prof_occurrences("p", "p ppppp", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; expected = g_slist_append(expected, GINT_TO_POINTER(4)); - assert_true(_lists_equal(prof_occurrences("p", "ppp p ppp", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + assert_true(_lists_equal(prof_occurrences("p", "ppp p ppp", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; expected = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5hello", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "heyboothj5", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "heyboothj5hithere", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "hey boothj5hithere", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "hey @boothj5hithere", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "heyboothj5 hithere", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "heyboothj5, hithere", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5boothj5", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5fillboothj5", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("k", "dont know", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("k", "kick", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("k", "kick kick", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("k", "kick kickk", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("k", "kic", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("k", "ick", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("k", "kk", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("k", "kkkkkkk", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5hello", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "heyboothj5", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "heyboothj5hithere", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "hey boothj5hithere", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "hey @boothj5hithere", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "heyboothj5 hithere", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "heyboothj5, hithere", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5boothj5", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5fillboothj5", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("k", "dont know", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("k", "kick", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("k", "kick kick", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("k", "kick kickk", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("k", "kic", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("k", "ick", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("k", "kk", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("k", "kkkkkkk", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; expected = NULL; - assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "我能吞下玻璃而hello", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hey我能吞下玻璃而", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hey我能吞下玻璃而hithere", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hey 我能吞下玻璃而hithere", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hey @我能吞下玻璃而hithere", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hey我能吞下玻璃而 hithere", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hey我能吞下玻璃而, hithere", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "我能吞下玻璃而我能吞下玻璃而", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "我能吞下玻璃而fill我能吞下玻璃而", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "我能吞下玻璃而hello", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hey我能吞下玻璃而", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hey我能吞下玻璃而hithere", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hey 我能吞下玻璃而hithere", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hey @我能吞下玻璃而hithere", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hey我能吞下玻璃而 hithere", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hey我能吞下玻璃而, hithere", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "我能吞下玻璃而我能吞下玻璃而", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "我能吞下玻璃而fill我能吞下玻璃而", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; } diff --git a/tests/unittests/test_common.h b/tests/unittests/test_common.h index bcef3367..75e6a8c4 100644 --- a/tests/unittests/test_common.h +++ b/tests/unittests/test_common.h @@ -1,41 +1,41 @@ -void replace_one_substr(void **state); -void replace_one_substr_beginning(void **state); -void replace_one_substr_end(void **state); -void replace_two_substr(void **state); -void replace_char(void **state); -void replace_when_none(void **state); -void replace_when_match(void **state); -void replace_when_string_empty(void **state); -void replace_when_string_null(void **state); -void replace_when_sub_empty(void **state); -void replace_when_sub_null(void **state); -void replace_when_new_empty(void **state); -void replace_when_new_null(void **state); -void test_online_is_valid_resource_presence_string(void **state); -void test_chat_is_valid_resource_presence_string(void **state); -void test_away_is_valid_resource_presence_string(void **state); -void test_xa_is_valid_resource_presence_string(void **state); -void test_dnd_is_valid_resource_presence_string(void **state); -void test_available_is_not_valid_resource_presence_string(void **state); -void test_unavailable_is_not_valid_resource_presence_string(void **state); -void test_blah_is_not_valid_resource_presence_string(void **state); -void utf8_display_len_null_str(void **state); -void utf8_display_len_1_non_wide(void **state); -void utf8_display_len_1_wide(void **state); -void utf8_display_len_non_wide(void **state); -void utf8_display_len_wide(void **state); -void utf8_display_len_all_wide(void **state); -void strip_quotes_does_nothing_when_no_quoted(void **state); -void strip_quotes_strips_first(void **state); -void strip_quotes_strips_last(void **state); -void strip_quotes_strips_both(void **state); -void str_not_contains_str(void **state); -void str_contains_str_at_start(void **state); -void str_contains_str_at_end(void **state); -void str_contains_str_in_middle(void **state); -void str_contains_str_whole(void **state); -void str_empty_not_contains_str(void **state); -void str_not_contains_str_empty(void **state); -void str_empty_not_contains_str_empty(void **state); -void prof_partial_occurrences_tests(void **state); -void prof_whole_occurrences_tests(void **state); +void replace_one_substr(void** state); +void replace_one_substr_beginning(void** state); +void replace_one_substr_end(void** state); +void replace_two_substr(void** state); +void replace_char(void** state); +void replace_when_none(void** state); +void replace_when_match(void** state); +void replace_when_string_empty(void** state); +void replace_when_string_null(void** state); +void replace_when_sub_empty(void** state); +void replace_when_sub_null(void** state); +void replace_when_new_empty(void** state); +void replace_when_new_null(void** state); +void test_online_is_valid_resource_presence_string(void** state); +void test_chat_is_valid_resource_presence_string(void** state); +void test_away_is_valid_resource_presence_string(void** state); +void test_xa_is_valid_resource_presence_string(void** state); +void test_dnd_is_valid_resource_presence_string(void** state); +void test_available_is_not_valid_resource_presence_string(void** state); +void test_unavailable_is_not_valid_resource_presence_string(void** state); +void test_blah_is_not_valid_resource_presence_string(void** state); +void utf8_display_len_null_str(void** state); +void utf8_display_len_1_non_wide(void** state); +void utf8_display_len_1_wide(void** state); +void utf8_display_len_non_wide(void** state); +void utf8_display_len_wide(void** state); +void utf8_display_len_all_wide(void** state); +void strip_quotes_does_nothing_when_no_quoted(void** state); +void strip_quotes_strips_first(void** state); +void strip_quotes_strips_last(void** state); +void strip_quotes_strips_both(void** state); +void str_not_contains_str(void** state); +void str_contains_str_at_start(void** state); +void str_contains_str_at_end(void** state); +void str_contains_str_in_middle(void** state); +void str_contains_str_whole(void** state); +void str_empty_not_contains_str(void** state); +void str_not_contains_str_empty(void** state); +void str_empty_not_contains_str_empty(void** state); +void prof_partial_occurrences_tests(void** state); +void prof_whole_occurrences_tests(void** state); diff --git a/tests/unittests/test_contact.c b/tests/unittests/test_contact.c index 127ca5cf..849c9bc0 100644 --- a/tests/unittests/test_contact.c +++ b/tests/unittests/test_contact.c @@ -8,66 +8,71 @@ #include "xmpp/contact.h" -void contact_in_group(void **state) +void +contact_in_group(void** state) { - GSList *groups = NULL; + GSList* groups = NULL; groups = g_slist_append(groups, strdup("somegroup")); PContact contact = p_contact_new("bob@server.com", "bob", groups, "both", - "is offline", FALSE); + "is offline", FALSE); gboolean result = p_contact_in_group(contact, "somegroup"); assert_true(result); p_contact_free(contact); -// g_slist_free(groups); + // g_slist_free(groups); } -void contact_not_in_group(void **state) +void +contact_not_in_group(void** state) { - GSList *groups = NULL; + GSList* groups = NULL; groups = g_slist_append(groups, strdup("somegroup")); PContact contact = p_contact_new("bob@server.com", "bob", groups, "both", - "is offline", FALSE); + "is offline", FALSE); gboolean result = p_contact_in_group(contact, "othergroup"); assert_false(result); p_contact_free(contact); -// g_slist_free(groups); + // g_slist_free(groups); } -void contact_name_when_name_exists(void **state) +void +contact_name_when_name_exists(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both", - "is offline", FALSE); + "is offline", FALSE); - const char *name = p_contact_name_or_jid(contact); + const char* name = p_contact_name_or_jid(contact); assert_string_equal("bob", name); p_contact_free(contact); } -void contact_jid_when_name_not_exists(void **state) +void +contact_jid_when_name_not_exists(void** state) { PContact contact = p_contact_new("bob@server.com", NULL, NULL, "both", - "is offline", FALSE); + "is offline", FALSE); - const char *jid = p_contact_name_or_jid(contact); + const char* jid = p_contact_name_or_jid(contact); assert_string_equal("bob@server.com", jid); p_contact_free(contact); } -void contact_string_when_name_exists(void **state) +void +contact_string_when_name_exists(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both", - "is offline", FALSE); + "is offline", FALSE); - char *str = p_contact_create_display_string(contact, "laptop"); + char* str = p_contact_create_display_string(contact, "laptop"); assert_string_equal("bob (laptop)", str); @@ -75,12 +80,13 @@ void contact_string_when_name_exists(void **state) free(str); } -void contact_string_when_name_not_exists(void **state) +void +contact_string_when_name_not_exists(void** state) { PContact contact = p_contact_new("bob@server.com", NULL, NULL, "both", - "is offline", FALSE); + "is offline", FALSE); - char *str = p_contact_create_display_string(contact, "laptop"); + char* str = p_contact_create_display_string(contact, "laptop"); assert_string_equal("bob@server.com (laptop)", str); @@ -88,12 +94,13 @@ void contact_string_when_name_not_exists(void **state) free(str); } -void contact_string_when_default_resource(void **state) +void +contact_string_when_default_resource(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both", - "is offline", FALSE); + "is offline", FALSE); - char *str = p_contact_create_display_string(contact, "__prof_default"); + char* str = p_contact_create_display_string(contact, "__prof_default"); assert_string_equal("bob", str); @@ -101,140 +108,148 @@ void contact_string_when_default_resource(void **state) free(str); } -void contact_presence_offline(void **state) +void +contact_presence_offline(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both", - "is offline", FALSE); + "is offline", FALSE); - const char *presence = p_contact_presence(contact); + const char* presence = p_contact_presence(contact); assert_string_equal("offline", presence); p_contact_free(contact); } -void contact_presence_uses_highest_priority(void **state) +void +contact_presence_uses_highest_priority(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both", - "is offline", FALSE); + "is offline", FALSE); - Resource *resource10 = resource_new("resource10", RESOURCE_ONLINE, NULL, 10); - Resource *resource20 = resource_new("resource20", RESOURCE_CHAT, NULL, 20); - Resource *resource30 = resource_new("resource30", RESOURCE_AWAY, NULL, 30); - Resource *resource1 = resource_new("resource1", RESOURCE_XA, NULL, 1); - Resource *resource2 = resource_new("resource2", RESOURCE_DND, NULL, 2); + Resource* resource10 = resource_new("resource10", RESOURCE_ONLINE, NULL, 10); + Resource* resource20 = resource_new("resource20", RESOURCE_CHAT, NULL, 20); + Resource* resource30 = resource_new("resource30", RESOURCE_AWAY, NULL, 30); + Resource* resource1 = resource_new("resource1", RESOURCE_XA, NULL, 1); + Resource* resource2 = resource_new("resource2", RESOURCE_DND, NULL, 2); p_contact_set_presence(contact, resource10); p_contact_set_presence(contact, resource20); p_contact_set_presence(contact, resource30); p_contact_set_presence(contact, resource1); p_contact_set_presence(contact, resource2); - const char *presence = p_contact_presence(contact); + const char* presence = p_contact_presence(contact); assert_string_equal("away", presence); p_contact_free(contact); } -void contact_presence_chat_when_same_prioroty(void **state) +void +contact_presence_chat_when_same_prioroty(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both", - "is offline", FALSE); + "is offline", FALSE); - Resource *resource_online = resource_new("resource_online", RESOURCE_ONLINE, NULL, 10); - Resource *resource_chat = resource_new("resource_chat", RESOURCE_CHAT, NULL, 10); - Resource *resource_away = resource_new("resource_away", RESOURCE_AWAY, NULL, 10); - Resource *resource_xa = resource_new("resource_xa", RESOURCE_XA, NULL, 10); - Resource *resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 10); + Resource* resource_online = resource_new("resource_online", RESOURCE_ONLINE, NULL, 10); + Resource* resource_chat = resource_new("resource_chat", RESOURCE_CHAT, NULL, 10); + Resource* resource_away = resource_new("resource_away", RESOURCE_AWAY, NULL, 10); + Resource* resource_xa = resource_new("resource_xa", RESOURCE_XA, NULL, 10); + Resource* resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 10); p_contact_set_presence(contact, resource_online); p_contact_set_presence(contact, resource_chat); p_contact_set_presence(contact, resource_away); p_contact_set_presence(contact, resource_xa); p_contact_set_presence(contact, resource_dnd); - const char *presence = p_contact_presence(contact); + const char* presence = p_contact_presence(contact); assert_string_equal("chat", presence); p_contact_free(contact); } -void contact_presence_online_when_same_prioroty(void **state) +void +contact_presence_online_when_same_prioroty(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both", - "is offline", FALSE); + "is offline", FALSE); - Resource *resource_online = resource_new("resource_online", RESOURCE_ONLINE, NULL, 10); - Resource *resource_away = resource_new("resource_away", RESOURCE_AWAY, NULL, 10); - Resource *resource_xa = resource_new("resource_xa", RESOURCE_XA, NULL, 10); - Resource *resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 10); + Resource* resource_online = resource_new("resource_online", RESOURCE_ONLINE, NULL, 10); + Resource* resource_away = resource_new("resource_away", RESOURCE_AWAY, NULL, 10); + Resource* resource_xa = resource_new("resource_xa", RESOURCE_XA, NULL, 10); + Resource* resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 10); p_contact_set_presence(contact, resource_online); p_contact_set_presence(contact, resource_away); p_contact_set_presence(contact, resource_xa); p_contact_set_presence(contact, resource_dnd); - const char *presence = p_contact_presence(contact); + const char* presence = p_contact_presence(contact); assert_string_equal("online", presence); p_contact_free(contact); } -void contact_presence_away_when_same_prioroty(void **state) +void +contact_presence_away_when_same_prioroty(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both", - "is offline", FALSE); + "is offline", FALSE); - Resource *resource_away = resource_new("resource_away", RESOURCE_AWAY, NULL, 10); - Resource *resource_xa = resource_new("resource_xa", RESOURCE_XA, NULL, 10); - Resource *resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 10); + Resource* resource_away = resource_new("resource_away", RESOURCE_AWAY, NULL, 10); + Resource* resource_xa = resource_new("resource_xa", RESOURCE_XA, NULL, 10); + Resource* resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 10); p_contact_set_presence(contact, resource_away); p_contact_set_presence(contact, resource_xa); p_contact_set_presence(contact, resource_dnd); - const char *presence = p_contact_presence(contact); + const char* presence = p_contact_presence(contact); assert_string_equal("away", presence); p_contact_free(contact); } -void contact_presence_xa_when_same_prioroty(void **state) +void +contact_presence_xa_when_same_prioroty(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both", - "is offline", FALSE); + "is offline", FALSE); - Resource *resource_xa = resource_new("resource_xa", RESOURCE_XA, NULL, 10); - Resource *resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 10); + Resource* resource_xa = resource_new("resource_xa", RESOURCE_XA, NULL, 10); + Resource* resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 10); p_contact_set_presence(contact, resource_xa); p_contact_set_presence(contact, resource_dnd); - const char *presence = p_contact_presence(contact); + const char* presence = p_contact_presence(contact); assert_string_equal("xa", presence); p_contact_free(contact); } -void contact_presence_dnd(void **state) +void +contact_presence_dnd(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both", - "is offline", FALSE); + "is offline", FALSE); - Resource *resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 10); + Resource* resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 10); p_contact_set_presence(contact, resource_dnd); - const char *presence = p_contact_presence(contact); + const char* presence = p_contact_presence(contact); assert_string_equal("dnd", presence); p_contact_free(contact); } -void contact_subscribed_when_to(void **state) +void +contact_subscribed_when_to(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "to", - "is offline", FALSE); + "is offline", FALSE); gboolean result = p_contact_subscribed(contact); @@ -243,10 +258,11 @@ void contact_subscribed_when_to(void **state) p_contact_free(contact); } -void contact_subscribed_when_both(void **state) +void +contact_subscribed_when_both(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both", - "is offline", FALSE); + "is offline", FALSE); gboolean result = p_contact_subscribed(contact); @@ -255,10 +271,11 @@ void contact_subscribed_when_both(void **state) p_contact_free(contact); } -void contact_not_subscribed_when_from(void **state) +void +contact_not_subscribed_when_from(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "from", - "is offline", FALSE); + "is offline", FALSE); gboolean result = p_contact_subscribed(contact); @@ -267,10 +284,11 @@ void contact_not_subscribed_when_from(void **state) p_contact_free(contact); } -void contact_not_subscribed_when_no_subscription_value(void **state) +void +contact_not_subscribed_when_no_subscription_value(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, NULL, - "is offline", FALSE); + "is offline", FALSE); gboolean result = p_contact_subscribed(contact); @@ -279,10 +297,11 @@ void contact_not_subscribed_when_no_subscription_value(void **state) p_contact_free(contact); } -void contact_not_available(void **state) +void +contact_not_available(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, NULL, - "is offline", FALSE); + "is offline", FALSE); gboolean result = p_contact_is_available(contact); @@ -291,16 +310,17 @@ void contact_not_available(void **state) p_contact_free(contact); } -void contact_not_available_when_highest_priority_away(void **state) +void +contact_not_available_when_highest_priority_away(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, NULL, - "is offline", FALSE); + "is offline", FALSE); - Resource *resource_online = resource_new("resource_online", RESOURCE_ONLINE, NULL, 10); - Resource *resource_chat = resource_new("resource_chat", RESOURCE_CHAT, NULL, 10); - Resource *resource_away = resource_new("resource_away", RESOURCE_AWAY, NULL, 20); - Resource *resource_xa = resource_new("resource_xa", RESOURCE_XA, NULL, 10); - Resource *resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 10); + Resource* resource_online = resource_new("resource_online", RESOURCE_ONLINE, NULL, 10); + Resource* resource_chat = resource_new("resource_chat", RESOURCE_CHAT, NULL, 10); + Resource* resource_away = resource_new("resource_away", RESOURCE_AWAY, NULL, 20); + Resource* resource_xa = resource_new("resource_xa", RESOURCE_XA, NULL, 10); + Resource* resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 10); p_contact_set_presence(contact, resource_online); p_contact_set_presence(contact, resource_chat); p_contact_set_presence(contact, resource_away); @@ -314,16 +334,17 @@ void contact_not_available_when_highest_priority_away(void **state) p_contact_free(contact); } -void contact_not_available_when_highest_priority_xa(void **state) +void +contact_not_available_when_highest_priority_xa(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, NULL, - "is offline", FALSE); + "is offline", FALSE); - Resource *resource_online = resource_new("resource_online", RESOURCE_ONLINE, NULL, 10); - Resource *resource_chat = resource_new("resource_chat", RESOURCE_CHAT, NULL, 10); - Resource *resource_away = resource_new("resource_away", RESOURCE_AWAY, NULL, 10); - Resource *resource_xa = resource_new("resource_xa", RESOURCE_XA, NULL, 20); - Resource *resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 10); + Resource* resource_online = resource_new("resource_online", RESOURCE_ONLINE, NULL, 10); + Resource* resource_chat = resource_new("resource_chat", RESOURCE_CHAT, NULL, 10); + Resource* resource_away = resource_new("resource_away", RESOURCE_AWAY, NULL, 10); + Resource* resource_xa = resource_new("resource_xa", RESOURCE_XA, NULL, 20); + Resource* resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 10); p_contact_set_presence(contact, resource_online); p_contact_set_presence(contact, resource_chat); p_contact_set_presence(contact, resource_away); @@ -337,16 +358,17 @@ void contact_not_available_when_highest_priority_xa(void **state) p_contact_free(contact); } -void contact_not_available_when_highest_priority_dnd(void **state) +void +contact_not_available_when_highest_priority_dnd(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, NULL, - "is offline", FALSE); + "is offline", FALSE); - Resource *resource_online = resource_new("resource_online", RESOURCE_ONLINE, NULL, 10); - Resource *resource_chat = resource_new("resource_chat", RESOURCE_CHAT, NULL, 10); - Resource *resource_away = resource_new("resource_away", RESOURCE_AWAY, NULL, 10); - Resource *resource_xa = resource_new("resource_xa", RESOURCE_XA, NULL, 10); - Resource *resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 20); + Resource* resource_online = resource_new("resource_online", RESOURCE_ONLINE, NULL, 10); + Resource* resource_chat = resource_new("resource_chat", RESOURCE_CHAT, NULL, 10); + Resource* resource_away = resource_new("resource_away", RESOURCE_AWAY, NULL, 10); + Resource* resource_xa = resource_new("resource_xa", RESOURCE_XA, NULL, 10); + Resource* resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 20); p_contact_set_presence(contact, resource_online); p_contact_set_presence(contact, resource_chat); p_contact_set_presence(contact, resource_away); @@ -360,16 +382,17 @@ void contact_not_available_when_highest_priority_dnd(void **state) p_contact_free(contact); } -void contact_available_when_highest_priority_online(void **state) +void +contact_available_when_highest_priority_online(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, NULL, - "is offline", FALSE); + "is offline", FALSE); - Resource *resource_online = resource_new("resource_online", RESOURCE_ONLINE, NULL, 20); - Resource *resource_chat = resource_new("resource_chat", RESOURCE_CHAT, NULL, 10); - Resource *resource_away = resource_new("resource_away", RESOURCE_AWAY, NULL, 10); - Resource *resource_xa = resource_new("resource_xa", RESOURCE_XA, NULL, 10); - Resource *resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 10); + Resource* resource_online = resource_new("resource_online", RESOURCE_ONLINE, NULL, 20); + Resource* resource_chat = resource_new("resource_chat", RESOURCE_CHAT, NULL, 10); + Resource* resource_away = resource_new("resource_away", RESOURCE_AWAY, NULL, 10); + Resource* resource_xa = resource_new("resource_xa", RESOURCE_XA, NULL, 10); + Resource* resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 10); p_contact_set_presence(contact, resource_online); p_contact_set_presence(contact, resource_chat); p_contact_set_presence(contact, resource_away); @@ -383,16 +406,17 @@ void contact_available_when_highest_priority_online(void **state) p_contact_free(contact); } -void contact_available_when_highest_priority_chat(void **state) +void +contact_available_when_highest_priority_chat(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, NULL, - "is offline", FALSE); + "is offline", FALSE); - Resource *resource_online = resource_new("resource_online", RESOURCE_ONLINE, NULL, 10); - Resource *resource_chat = resource_new("resource_chat", RESOURCE_CHAT, NULL, 20); - Resource *resource_away = resource_new("resource_away", RESOURCE_AWAY, NULL, 10); - Resource *resource_xa = resource_new("resource_xa", RESOURCE_XA, NULL, 10); - Resource *resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 10); + Resource* resource_online = resource_new("resource_online", RESOURCE_ONLINE, NULL, 10); + Resource* resource_chat = resource_new("resource_chat", RESOURCE_CHAT, NULL, 20); + Resource* resource_away = resource_new("resource_away", RESOURCE_AWAY, NULL, 10); + Resource* resource_xa = resource_new("resource_xa", RESOURCE_XA, NULL, 10); + Resource* resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 10); p_contact_set_presence(contact, resource_online); p_contact_set_presence(contact, resource_chat); p_contact_set_presence(contact, resource_away); diff --git a/tests/unittests/test_contact.h b/tests/unittests/test_contact.h index c9d8c1fd..605573ea 100644 --- a/tests/unittests/test_contact.h +++ b/tests/unittests/test_contact.h @@ -1,24 +1,24 @@ -void contact_in_group(void **state); -void contact_not_in_group(void **state); -void contact_name_when_name_exists(void **state); -void contact_jid_when_name_not_exists(void **state); -void contact_string_when_name_exists(void **state); -void contact_string_when_name_not_exists(void **state); -void contact_string_when_default_resource(void **state); -void contact_presence_offline(void **state); -void contact_presence_uses_highest_priority(void **state); -void contact_presence_chat_when_same_prioroty(void **state); -void contact_presence_online_when_same_prioroty(void **state); -void contact_presence_away_when_same_prioroty(void **state); -void contact_presence_xa_when_same_prioroty(void **state); -void contact_presence_dnd(void **state); -void contact_subscribed_when_to(void **state); -void contact_subscribed_when_both(void **state); -void contact_not_subscribed_when_from(void **state); -void contact_not_subscribed_when_no_subscription_value(void **state); -void contact_not_available(void **state); -void contact_not_available_when_highest_priority_away(void **state); -void contact_not_available_when_highest_priority_xa(void **state); -void contact_not_available_when_highest_priority_dnd(void **state); -void contact_available_when_highest_priority_online(void **state); -void contact_available_when_highest_priority_chat(void **state); +void contact_in_group(void** state); +void contact_not_in_group(void** state); +void contact_name_when_name_exists(void** state); +void contact_jid_when_name_not_exists(void** state); +void contact_string_when_name_exists(void** state); +void contact_string_when_name_not_exists(void** state); +void contact_string_when_default_resource(void** state); +void contact_presence_offline(void** state); +void contact_presence_uses_highest_priority(void** state); +void contact_presence_chat_when_same_prioroty(void** state); +void contact_presence_online_when_same_prioroty(void** state); +void contact_presence_away_when_same_prioroty(void** state); +void contact_presence_xa_when_same_prioroty(void** state); +void contact_presence_dnd(void** state); +void contact_subscribed_when_to(void** state); +void contact_subscribed_when_both(void** state); +void contact_not_subscribed_when_from(void** state); +void contact_not_subscribed_when_no_subscription_value(void** state); +void contact_not_available(void** state); +void contact_not_available_when_highest_priority_away(void** state); +void contact_not_available_when_highest_priority_xa(void** state); +void contact_not_available_when_highest_priority_dnd(void** state); +void contact_available_when_highest_priority_online(void** state); +void contact_available_when_highest_priority_chat(void** state); diff --git a/tests/unittests/test_form.c b/tests/unittests/test_form.c index b3158a83..88bf9d55 100644 --- a/tests/unittests/test_form.c +++ b/tests/unittests/test_form.c @@ -7,7 +7,8 @@ #include "xmpp/form.h" -xmpp_ctx_t* connection_get_ctx(void) +xmpp_ctx_t* +connection_get_ctx(void) { return NULL; } @@ -15,7 +16,7 @@ xmpp_ctx_t* connection_get_ctx(void) static DataForm* _new_form(void) { - DataForm *form = malloc(sizeof(DataForm)); + DataForm* form = malloc(sizeof(DataForm)); form->type = NULL; form->title = NULL; form->instructions = NULL; @@ -30,7 +31,7 @@ _new_form(void) static FormField* _new_field(void) { - FormField *field = malloc(sizeof(FormField)); + FormField* field = malloc(sizeof(FormField)); field->label = NULL; field->type = NULL; field->description = NULL; @@ -41,64 +42,67 @@ _new_field(void) field->value_ac = NULL; return field; - } -void get_form_type_field_returns_null_no_fields(void **state) +void +get_form_type_field_returns_null_no_fields(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); - char *result = form_get_form_type_field(form); + char* result = form_get_form_type_field(form); assert_null(result); form_destroy(form); } -void get_form_type_field_returns_null_when_not_present(void **state) +void +get_form_type_field_returns_null_when_not_present(void** state) { - DataForm *form = _new_form(); - FormField *field = _new_field(); + DataForm* form = _new_form(); + FormField* field = _new_field(); field->var = strdup("var1"); field->values = g_slist_append(field->values, strdup("value1")); form->fields = g_slist_append(form->fields, field); - char *result = form_get_form_type_field(form); + char* result = form_get_form_type_field(form); assert_null(result); form_destroy(form); } -void get_form_type_field_returns_value_when_present(void **state) +void +get_form_type_field_returns_value_when_present(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); - FormField *field1 = _new_field(); + FormField* field1 = _new_field(); field1->var = strdup("var1"); field1->values = g_slist_append(field1->values, strdup("value1")); form->fields = g_slist_append(form->fields, field1); - FormField *field2 = _new_field(); + FormField* field2 = _new_field(); field2->var = strdup("FORM_TYPE"); field2->values = g_slist_append(field2->values, strdup("value2")); form->fields = g_slist_append(form->fields, field2); - FormField *field3 = _new_field(); + FormField* field3 = _new_field(); field3->var = strdup("var3"); field3->values = g_slist_append(field3->values, strdup("value3")); form->fields = g_slist_append(form->fields, field3); - char *result = form_get_form_type_field(form); + char* result = form_get_form_type_field(form); assert_string_equal(result, "value2"); form_destroy(form); } -void get_field_type_returns_unknown_when_no_fields(void **state) +void +get_field_type_returns_unknown_when_no_fields(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); form_field_type_t result = form_get_field_type(form, "tag"); @@ -107,19 +111,20 @@ void get_field_type_returns_unknown_when_no_fields(void **state) form_destroy(form); } -void get_field_type_returns_correct_type(void **state) +void +get_field_type_returns_correct_type(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, strdup("tag1"), strdup("var1")); g_hash_table_insert(form->tag_to_var, strdup("tag2"), strdup("var2")); - FormField *field1 = _new_field(); + FormField* field1 = _new_field(); field1->var = strdup("var1"); field1->type_t = FIELD_TEXT_SINGLE; field1->values = g_slist_append(field1->values, strdup("value1")); form->fields = g_slist_append(form->fields, field1); - FormField *field2 = _new_field(); + FormField* field2 = _new_field(); field2->var = strdup("var2"); field2->type_t = FIELD_TEXT_MULTI; field2->values = g_slist_append(field2->values, strdup("value2")); @@ -132,19 +137,20 @@ void get_field_type_returns_correct_type(void **state) form_destroy(form); } -void set_value_adds_when_none(void **state) +void +set_value_adds_when_none(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, strdup("tag1"), strdup("var1")); g_hash_table_insert(form->tag_to_var, strdup("tag2"), strdup("var2")); - FormField *field1 = _new_field(); + FormField* field1 = _new_field(); field1->var = strdup("var1"); field1->type_t = FIELD_TEXT_SINGLE; field1->values = g_slist_append(field1->values, strdup("value1")); form->fields = g_slist_append(form->fields, field1); - FormField *field2 = _new_field(); + FormField* field2 = _new_field(); field2->var = strdup("var2"); field2->type_t = FIELD_LIST_SINGLE; form->fields = g_slist_append(form->fields, field2); @@ -152,10 +158,10 @@ void set_value_adds_when_none(void **state) form_set_value(form, "tag2", "a new value"); int length = 0; - char *value = NULL; - GSList *curr_field = form->fields; + char* value = NULL; + GSList* curr_field = form->fields; while (curr_field != NULL) { - FormField *field = curr_field->data; + FormField* field = curr_field->data; if (g_strcmp0(field->var, "var2") == 0) { length = g_slist_length(field->values); value = field->values->data; @@ -170,18 +176,19 @@ void set_value_adds_when_none(void **state) form_destroy(form); } -void set_value_updates_when_one(void **state) +void +set_value_updates_when_one(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, strdup("tag1"), strdup("var1")); g_hash_table_insert(form->tag_to_var, strdup("tag2"), strdup("var2")); - FormField *field1 = _new_field(); + FormField* field1 = _new_field(); field1->var = strdup("var1"); field1->type_t = FIELD_TEXT_SINGLE; form->fields = g_slist_append(form->fields, field1); - FormField *field2 = _new_field(); + FormField* field2 = _new_field(); field2->var = strdup("var2"); field2->type_t = FIELD_LIST_SINGLE; field2->values = g_slist_append(field2->values, strdup("value2")); @@ -190,10 +197,10 @@ void set_value_updates_when_one(void **state) form_set_value(form, "tag2", "a new value"); int length = 0; - char *value = NULL; - GSList *curr_field = form->fields; + char* value = NULL; + GSList* curr_field = form->fields; while (curr_field != NULL) { - FormField *field = curr_field->data; + FormField* field = curr_field->data; if (g_strcmp0(field->var, "var2") == 0) { length = g_slist_length(field->values); value = field->values->data; @@ -208,18 +215,19 @@ void set_value_updates_when_one(void **state) form_destroy(form); } -void add_unique_value_adds_when_none(void **state) +void +add_unique_value_adds_when_none(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, strdup("tag1"), strdup("var1")); g_hash_table_insert(form->tag_to_var, strdup("tag2"), strdup("var2")); - FormField *field1 = _new_field(); + FormField* field1 = _new_field(); field1->var = strdup("var1"); field1->type_t = FIELD_JID_MULTI; form->fields = g_slist_append(form->fields, field1); - FormField *field2 = _new_field(); + FormField* field2 = _new_field(); field2->var = strdup("var2"); field2->type_t = FIELD_LIST_SINGLE; field2->values = g_slist_append(field2->values, strdup("value2")); @@ -228,10 +236,10 @@ void add_unique_value_adds_when_none(void **state) gboolean ret = form_add_unique_value(form, "tag1", "me@server.com"); int length = 0; - char *value = NULL; - GSList *curr_field = form->fields; + char* value = NULL; + GSList* curr_field = form->fields; while (curr_field != NULL) { - FormField *field = curr_field->data; + FormField* field = curr_field->data; if (g_strcmp0(field->var, "var1") == 0) { length = g_slist_length(field->values); value = field->values->data; @@ -247,19 +255,20 @@ void add_unique_value_adds_when_none(void **state) form_destroy(form); } -void add_unique_value_does_nothing_when_exists(void **state) +void +add_unique_value_does_nothing_when_exists(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, strdup("tag1"), strdup("var1")); g_hash_table_insert(form->tag_to_var, strdup("tag2"), strdup("var2")); - FormField *field1 = _new_field(); + FormField* field1 = _new_field(); field1->var = strdup("var1"); field1->type_t = FIELD_JID_MULTI; field1->values = g_slist_append(field1->values, strdup("me@server.com")); form->fields = g_slist_append(form->fields, field1); - FormField *field2 = _new_field(); + FormField* field2 = _new_field(); field2->var = strdup("var2"); field2->type_t = FIELD_LIST_SINGLE; field2->values = g_slist_append(field2->values, strdup("value2")); @@ -268,10 +277,10 @@ void add_unique_value_does_nothing_when_exists(void **state) gboolean ret = form_add_unique_value(form, "tag1", "me@server.com"); int length = 0; - char *value = NULL; - GSList *curr_field = form->fields; + char* value = NULL; + GSList* curr_field = form->fields; while (curr_field != NULL) { - FormField *field = curr_field->data; + FormField* field = curr_field->data; if (g_strcmp0(field->var, "var1") == 0) { length = g_slist_length(field->values); value = field->values->data; @@ -287,13 +296,14 @@ void add_unique_value_does_nothing_when_exists(void **state) form_destroy(form); } -void add_unique_value_adds_when_doesnt_exist(void **state) +void +add_unique_value_adds_when_doesnt_exist(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, strdup("tag1"), strdup("var1")); g_hash_table_insert(form->tag_to_var, strdup("tag2"), strdup("var2")); - FormField *field1 = _new_field(); + FormField* field1 = _new_field(); field1->var = strdup("var1"); field1->type_t = FIELD_JID_MULTI; field1->values = g_slist_append(field1->values, strdup("dolan@server.com")); @@ -301,7 +311,7 @@ void add_unique_value_adds_when_doesnt_exist(void **state) field1->values = g_slist_append(field1->values, strdup("chi@server.com")); form->fields = g_slist_append(form->fields, field1); - FormField *field2 = _new_field(); + FormField* field2 = _new_field(); field2->var = strdup("var2"); field2->type_t = FIELD_LIST_SINGLE; field2->values = g_slist_append(field2->values, strdup("value2")); @@ -311,12 +321,12 @@ void add_unique_value_adds_when_doesnt_exist(void **state) int length = 0; int count = 0; - GSList *curr_field = form->fields; + GSList* curr_field = form->fields; while (curr_field != NULL) { - FormField *field = curr_field->data; + FormField* field = curr_field->data; if (g_strcmp0(field->var, "var1") == 0) { length = g_slist_length(field->values); - GSList *curr_value = field->values; + GSList* curr_value = field->values; while (curr_value != NULL) { if (g_strcmp0(curr_value->data, "me@server.com") == 0) { count++; @@ -335,12 +345,13 @@ void add_unique_value_adds_when_doesnt_exist(void **state) form_destroy(form); } -void add_value_adds_when_none(void **state) +void +add_value_adds_when_none(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, strdup("tag1"), strdup("var1")); - FormField *field1 = _new_field(); + FormField* field1 = _new_field(); field1->var = strdup("var1"); field1->type_t = FIELD_LIST_MULTI; form->fields = g_slist_append(form->fields, field1); @@ -348,10 +359,10 @@ void add_value_adds_when_none(void **state) form_add_value(form, "tag1", "somevalue"); int length = 0; - char *value = NULL; - GSList *curr_field = form->fields; + char* value = NULL; + GSList* curr_field = form->fields; while (curr_field != NULL) { - FormField *field = curr_field->data; + FormField* field = curr_field->data; if (g_strcmp0(field->var, "var1") == 0) { length = g_slist_length(field->values); value = field->values->data; @@ -366,12 +377,13 @@ void add_value_adds_when_none(void **state) form_destroy(form); } -void add_value_adds_when_some(void **state) +void +add_value_adds_when_some(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, strdup("tag1"), strdup("var1")); - FormField *field1 = _new_field(); + FormField* field1 = _new_field(); field1->var = strdup("var1"); field1->type_t = FIELD_LIST_MULTI; field1->values = g_slist_append(field1->values, strdup("some text")); @@ -383,11 +395,11 @@ void add_value_adds_when_some(void **state) int num_values = 0; int new_value_count = 0; - GSList *curr_field = form->fields; + GSList* curr_field = form->fields; while (curr_field != NULL) { - FormField *field = curr_field->data; + FormField* field = curr_field->data; if (g_strcmp0(field->var, "var1") == 0) { - GSList *curr_value = field->values; + GSList* curr_value = field->values; while (curr_value != NULL) { num_values++; if (g_strcmp0(curr_value->data, "new value") == 0) { @@ -406,12 +418,13 @@ void add_value_adds_when_some(void **state) form_destroy(form); } -void add_value_adds_when_exists(void **state) +void +add_value_adds_when_exists(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, strdup("tag1"), strdup("var1")); - FormField *field1 = _new_field(); + FormField* field1 = _new_field(); field1->var = strdup("var1"); field1->type_t = FIELD_LIST_MULTI; field1->values = g_slist_append(field1->values, strdup("some text")); @@ -424,11 +437,11 @@ void add_value_adds_when_exists(void **state) int num_values = 0; int new_value_count = 0; - GSList *curr_field = form->fields; + GSList* curr_field = form->fields; while (curr_field != NULL) { - FormField *field = curr_field->data; + FormField* field = curr_field->data; if (g_strcmp0(field->var, "var1") == 0) { - GSList *curr_value = field->values; + GSList* curr_value = field->values; while (curr_value != NULL) { num_values++; if (g_strcmp0(curr_value->data, "new value") == 0) { @@ -447,12 +460,13 @@ void add_value_adds_when_exists(void **state) form_destroy(form); } -void remove_value_does_nothing_when_none(void **state) +void +remove_value_does_nothing_when_none(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, strdup("tag1"), strdup("var1")); - FormField *field1 = _new_field(); + FormField* field1 = _new_field(); field1->var = strdup("var1"); field1->type_t = FIELD_LIST_MULTI; form->fields = g_slist_append(form->fields, field1); @@ -460,9 +474,9 @@ void remove_value_does_nothing_when_none(void **state) gboolean res = form_remove_value(form, "tag1", "some value"); int length = -1; - GSList *curr_field = form->fields; + GSList* curr_field = form->fields; while (curr_field != NULL) { - FormField *field = curr_field->data; + FormField* field = curr_field->data; if (g_strcmp0(field->var, "var1") == 0) { length = g_slist_length(field->values); } @@ -475,12 +489,13 @@ void remove_value_does_nothing_when_none(void **state) form_destroy(form); } -void remove_value_does_nothing_when_doesnt_exist(void **state) +void +remove_value_does_nothing_when_doesnt_exist(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, strdup("tag1"), strdup("var1")); - FormField *field1 = _new_field(); + FormField* field1 = _new_field(); field1->var = strdup("var1"); field1->type_t = FIELD_LIST_MULTI; field1->values = g_slist_append(field1->values, strdup("value1")); @@ -493,12 +508,12 @@ void remove_value_does_nothing_when_doesnt_exist(void **state) int length = -1; int value_count = 0; - GSList *curr_field = form->fields; + GSList* curr_field = form->fields; while (curr_field != NULL) { - FormField *field = curr_field->data; + FormField* field = curr_field->data; if (g_strcmp0(field->var, "var1") == 0) { length = g_slist_length(field->values); - GSList *curr_value = field->values; + GSList* curr_value = field->values; while (curr_value != NULL) { if (g_strcmp0(curr_value->data, "value5") == 0) { value_count++; @@ -516,12 +531,13 @@ void remove_value_does_nothing_when_doesnt_exist(void **state) form_destroy(form); } -void remove_value_removes_when_one(void **state) +void +remove_value_removes_when_one(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, strdup("tag1"), strdup("var1")); - FormField *field1 = _new_field(); + FormField* field1 = _new_field(); field1->var = strdup("var1"); field1->type_t = FIELD_LIST_MULTI; field1->values = g_slist_append(field1->values, strdup("value4")); @@ -530,9 +546,9 @@ void remove_value_removes_when_one(void **state) gboolean res = form_remove_value(form, "tag1", "value4"); int length = -1; - GSList *curr_field = form->fields; + GSList* curr_field = form->fields; while (curr_field != NULL) { - FormField *field = curr_field->data; + FormField* field = curr_field->data; if (g_strcmp0(field->var, "var1") == 0) { length = g_slist_length(field->values); } @@ -545,12 +561,13 @@ void remove_value_removes_when_one(void **state) form_destroy(form); } -void remove_value_removes_when_many(void **state) +void +remove_value_removes_when_many(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, strdup("tag1"), strdup("var1")); - FormField *field1 = _new_field(); + FormField* field1 = _new_field(); field1->var = strdup("var1"); field1->type_t = FIELD_LIST_MULTI; field1->values = g_slist_append(field1->values, strdup("value1")); @@ -563,12 +580,12 @@ void remove_value_removes_when_many(void **state) int length = -1; int value_count = 0; - GSList *curr_field = form->fields; + GSList* curr_field = form->fields; while (curr_field != NULL) { - FormField *field = curr_field->data; + FormField* field = curr_field->data; if (g_strcmp0(field->var, "var1") == 0) { length = g_slist_length(field->values); - GSList *curr_value = field->values; + GSList* curr_value = field->values; while (curr_value != NULL) { if (g_strcmp0(curr_value->data, "value2") == 0) { value_count++; @@ -586,12 +603,13 @@ void remove_value_removes_when_many(void **state) form_destroy(form); } -void remove_text_multi_value_does_nothing_when_none(void **state) +void +remove_text_multi_value_does_nothing_when_none(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, strdup("tag1"), strdup("var1")); - FormField *field1 = _new_field(); + FormField* field1 = _new_field(); field1->var = strdup("var1"); field1->type_t = FIELD_LIST_MULTI; form->fields = g_slist_append(form->fields, field1); @@ -599,9 +617,9 @@ void remove_text_multi_value_does_nothing_when_none(void **state) gboolean res = form_remove_text_multi_value(form, "tag1", 3); int length = -1; - GSList *curr_field = form->fields; + GSList* curr_field = form->fields; while (curr_field != NULL) { - FormField *field = curr_field->data; + FormField* field = curr_field->data; if (g_strcmp0(field->var, "var1") == 0) { length = g_slist_length(field->values); } @@ -614,12 +632,13 @@ void remove_text_multi_value_does_nothing_when_none(void **state) form_destroy(form); } -void remove_text_multi_value_does_nothing_when_doesnt_exist(void **state) +void +remove_text_multi_value_does_nothing_when_doesnt_exist(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, strdup("tag1"), strdup("var1")); - FormField *field1 = _new_field(); + FormField* field1 = _new_field(); field1->var = strdup("var1"); field1->type_t = FIELD_LIST_MULTI; field1->values = g_slist_append(field1->values, strdup("value1")); @@ -632,12 +651,12 @@ void remove_text_multi_value_does_nothing_when_doesnt_exist(void **state) int length = -1; int value_count = 0; - GSList *curr_field = form->fields; + GSList* curr_field = form->fields; while (curr_field != NULL) { - FormField *field = curr_field->data; + FormField* field = curr_field->data; if (g_strcmp0(field->var, "var1") == 0) { length = g_slist_length(field->values); - GSList *curr_value = field->values; + GSList* curr_value = field->values; while (curr_value != NULL) { if (g_strcmp0(curr_value->data, "value5") == 0) { value_count++; @@ -655,12 +674,13 @@ void remove_text_multi_value_does_nothing_when_doesnt_exist(void **state) form_destroy(form); } -void remove_text_multi_value_removes_when_one(void **state) +void +remove_text_multi_value_removes_when_one(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, strdup("tag1"), strdup("var1")); - FormField *field1 = _new_field(); + FormField* field1 = _new_field(); field1->var = strdup("var1"); field1->type_t = FIELD_LIST_MULTI; field1->values = g_slist_append(field1->values, strdup("value4")); @@ -669,9 +689,9 @@ void remove_text_multi_value_removes_when_one(void **state) gboolean res = form_remove_text_multi_value(form, "tag1", 1); int length = -1; - GSList *curr_field = form->fields; + GSList* curr_field = form->fields; while (curr_field != NULL) { - FormField *field = curr_field->data; + FormField* field = curr_field->data; if (g_strcmp0(field->var, "var1") == 0) { length = g_slist_length(field->values); } @@ -684,12 +704,13 @@ void remove_text_multi_value_removes_when_one(void **state) form_destroy(form); } -void remove_text_multi_value_removes_when_many(void **state) +void +remove_text_multi_value_removes_when_many(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, strdup("tag1"), strdup("var1")); - FormField *field1 = _new_field(); + FormField* field1 = _new_field(); field1->var = strdup("var1"); field1->type_t = FIELD_LIST_MULTI; field1->values = g_slist_append(field1->values, strdup("value1")); @@ -702,12 +723,12 @@ void remove_text_multi_value_removes_when_many(void **state) int length = -1; int value_count = 0; - GSList *curr_field = form->fields; + GSList* curr_field = form->fields; while (curr_field != NULL) { - FormField *field = curr_field->data; + FormField* field = curr_field->data; if (g_strcmp0(field->var, "var1") == 0) { length = g_slist_length(field->values); - GSList *curr_value = field->values; + GSList* curr_value = field->values; while (curr_value != NULL) { if (g_strcmp0(curr_value->data, "value2") == 0) { value_count++; @@ -724,4 +745,3 @@ void remove_text_multi_value_removes_when_many(void **state) form_destroy(form); } - diff --git a/tests/unittests/test_form.h b/tests/unittests/test_form.h index 65911d0a..a7ae04c5 100644 --- a/tests/unittests/test_form.h +++ b/tests/unittests/test_form.h @@ -1,21 +1,21 @@ -void get_form_type_field_returns_null_no_fields(void **state); -void get_form_type_field_returns_null_when_not_present(void **state); -void get_form_type_field_returns_value_when_present(void **state); -void get_field_type_returns_unknown_when_no_fields(void **state); -void get_field_type_returns_correct_type(void **state); -void set_value_adds_when_none(void **state); -void set_value_updates_when_one(void **state); -void add_unique_value_adds_when_none(void **state); -void add_unique_value_does_nothing_when_exists(void **state); -void add_unique_value_adds_when_doesnt_exist(void **state); -void add_value_adds_when_none(void **state); -void add_value_adds_when_some(void **state); -void add_value_adds_when_exists(void **state); -void remove_value_does_nothing_when_none(void **state); -void remove_value_does_nothing_when_doesnt_exist(void **state); -void remove_value_removes_when_one(void **state); -void remove_value_removes_when_many(void **state); -void remove_text_multi_value_does_nothing_when_none(void **state); -void remove_text_multi_value_does_nothing_when_doesnt_exist(void **state); -void remove_text_multi_value_removes_when_one(void **state); -void remove_text_multi_value_removes_when_many(void **state); +void get_form_type_field_returns_null_no_fields(void** state); +void get_form_type_field_returns_null_when_not_present(void** state); +void get_form_type_field_returns_value_when_present(void** state); +void get_field_type_returns_unknown_when_no_fields(void** state); +void get_field_type_returns_correct_type(void** state); +void set_value_adds_when_none(void** state); +void set_value_updates_when_one(void** state); +void add_unique_value_adds_when_none(void** state); +void add_unique_value_does_nothing_when_exists(void** state); +void add_unique_value_adds_when_doesnt_exist(void** state); +void add_value_adds_when_none(void** state); +void add_value_adds_when_some(void** state); +void add_value_adds_when_exists(void** state); +void remove_value_does_nothing_when_none(void** state); +void remove_value_does_nothing_when_doesnt_exist(void** state); +void remove_value_removes_when_one(void** state); +void remove_value_removes_when_many(void** state); +void remove_text_multi_value_does_nothing_when_none(void** state); +void remove_text_multi_value_does_nothing_when_doesnt_exist(void** state); +void remove_text_multi_value_removes_when_one(void** state); +void remove_text_multi_value_removes_when_many(void** state); diff --git a/tests/unittests/test_jid.c b/tests/unittests/test_jid.c index f1fb0f7b..2650d5da 100644 --- a/tests/unittests/test_jid.c +++ b/tests/unittests/test_jid.c @@ -6,142 +6,162 @@ #include "xmpp/jid.h" -void create_jid_from_null_returns_null(void **state) +void +create_jid_from_null_returns_null(void** state) { - Jid *result = jid_create(NULL); + Jid* result = jid_create(NULL); assert_null(result); } -void create_jid_from_empty_string_returns_null(void **state) +void +create_jid_from_empty_string_returns_null(void** state) { - Jid *result = jid_create(""); + Jid* result = jid_create(""); assert_null(result); } -void create_jid_from_full_returns_full(void **state) +void +create_jid_from_full_returns_full(void** state) { - Jid *result = jid_create("myuser@mydomain/laptop"); + Jid* result = jid_create("myuser@mydomain/laptop"); assert_string_equal("myuser@mydomain/laptop", result->fulljid); jid_destroy(result); } -void create_jid_from_full_returns_bare(void **state) +void +create_jid_from_full_returns_bare(void** state) { - Jid *result = jid_create("myuser@mydomain/laptop"); + Jid* result = jid_create("myuser@mydomain/laptop"); assert_string_equal("myuser@mydomain", result->barejid); jid_destroy(result); } -void create_jid_from_full_returns_resourcepart(void **state) +void +create_jid_from_full_returns_resourcepart(void** state) { - Jid *result = jid_create("myuser@mydomain/laptop"); + Jid* result = jid_create("myuser@mydomain/laptop"); assert_string_equal("laptop", result->resourcepart); jid_destroy(result); } -void create_jid_from_full_returns_localpart(void **state) +void +create_jid_from_full_returns_localpart(void** state) { - Jid *result = jid_create("myuser@mydomain/laptop"); + Jid* result = jid_create("myuser@mydomain/laptop"); assert_string_equal("myuser", result->localpart); jid_destroy(result); } -void create_jid_from_full_returns_domainpart(void **state) +void +create_jid_from_full_returns_domainpart(void** state) { - Jid *result = jid_create("myuser@mydomain/laptop"); + Jid* result = jid_create("myuser@mydomain/laptop"); assert_string_equal("mydomain", result->domainpart); jid_destroy(result); } -void create_jid_from_full_nolocal_returns_full(void **state) +void +create_jid_from_full_nolocal_returns_full(void** state) { - Jid *result = jid_create("mydomain/laptop"); + Jid* result = jid_create("mydomain/laptop"); assert_string_equal("mydomain/laptop", result->fulljid); jid_destroy(result); } -void create_jid_from_full_nolocal_returns_bare(void **state) +void +create_jid_from_full_nolocal_returns_bare(void** state) { - Jid *result = jid_create("mydomain/laptop"); + Jid* result = jid_create("mydomain/laptop"); assert_string_equal("mydomain", result->barejid); jid_destroy(result); } -void create_jid_from_full_nolocal_returns_resourcepart(void **state) +void +create_jid_from_full_nolocal_returns_resourcepart(void** state) { - Jid *result = jid_create("mydomain/laptop"); + Jid* result = jid_create("mydomain/laptop"); assert_string_equal("laptop", result->resourcepart); jid_destroy(result); } -void create_jid_from_full_nolocal_returns_domainpart(void **state) +void +create_jid_from_full_nolocal_returns_domainpart(void** state) { - Jid *result = jid_create("mydomain/laptop"); + Jid* result = jid_create("mydomain/laptop"); assert_string_equal("mydomain", result->domainpart); jid_destroy(result); } -void create_jid_from_full_nolocal_returns_null_localpart(void **state) +void +create_jid_from_full_nolocal_returns_null_localpart(void** state) { - Jid *result = jid_create("mydomain/laptop"); + Jid* result = jid_create("mydomain/laptop"); assert_null(result->localpart); jid_destroy(result); } -void create_jid_from_bare_returns_null_full(void **state) +void +create_jid_from_bare_returns_null_full(void** state) { - Jid *result = jid_create("myuser@mydomain"); + Jid* result = jid_create("myuser@mydomain"); assert_null(result->fulljid); jid_destroy(result); } -void create_jid_from_bare_returns_null_resource(void **state) +void +create_jid_from_bare_returns_null_resource(void** state) { - Jid *result = jid_create("myuser@mydomain"); + Jid* result = jid_create("myuser@mydomain"); assert_null(result->resourcepart); jid_destroy(result); } -void create_jid_from_bare_returns_bare(void **state) +void +create_jid_from_bare_returns_bare(void** state) { - Jid *result = jid_create("myuser@mydomain"); + Jid* result = jid_create("myuser@mydomain"); assert_string_equal("myuser@mydomain", result->barejid); jid_destroy(result); } -void create_jid_from_bare_returns_localpart(void **state) +void +create_jid_from_bare_returns_localpart(void** state) { - Jid *result = jid_create("myuser@mydomain"); + Jid* result = jid_create("myuser@mydomain"); assert_string_equal("myuser", result->localpart); jid_destroy(result); } -void create_jid_from_bare_returns_domainpart(void **state) +void +create_jid_from_bare_returns_domainpart(void** state) { - Jid *result = jid_create("myuser@mydomain"); + Jid* result = jid_create("myuser@mydomain"); assert_string_equal("mydomain", result->domainpart); jid_destroy(result); } -void create_room_jid_returns_room(void **state) +void +create_room_jid_returns_room(void** state) { - Jid *result = jid_create_from_bare_and_resource("room@conference.domain.org", "myname"); + Jid* result = jid_create_from_bare_and_resource("room@conference.domain.org", "myname"); assert_string_equal("room@conference.domain.org", result->barejid); jid_destroy(result); } -void create_room_jid_returns_nick(void **state) +void +create_room_jid_returns_nick(void** state) { - Jid *result = jid_create_from_bare_and_resource("room@conference.domain.org", "myname"); + Jid* result = jid_create_from_bare_and_resource("room@conference.domain.org", "myname"); assert_string_equal("myname", result->resourcepart); jid_destroy(result); } -void create_with_slash_in_resource(void **state) +void +create_with_slash_in_resource(void** state) { - Jid *result = jid_create("room@conference.domain.org/my/nick"); + Jid* result = jid_create("room@conference.domain.org/my/nick"); assert_string_equal("room", result->localpart); assert_string_equal("conference.domain.org", result->domainpart); @@ -152,9 +172,10 @@ void create_with_slash_in_resource(void **state) jid_destroy(result); } -void create_with_at_in_resource(void **state) +void +create_with_at_in_resource(void** state) { - Jid *result = jid_create("room@conference.domain.org/my@nick"); + Jid* result = jid_create("room@conference.domain.org/my@nick"); assert_string_equal("room", result->localpart); assert_string_equal("conference.domain.org", result->domainpart); @@ -165,9 +186,10 @@ void create_with_at_in_resource(void **state) jid_destroy(result); } -void create_with_at_and_slash_in_resource(void **state) +void +create_with_at_and_slash_in_resource(void** state) { - Jid *result = jid_create("room@conference.domain.org/my@nick/something"); + Jid* result = jid_create("room@conference.domain.org/my@nick/something"); assert_string_equal("room", result->localpart); assert_string_equal("conference.domain.org", result->domainpart); @@ -178,9 +200,10 @@ void create_with_at_and_slash_in_resource(void **state) jid_destroy(result); } -void create_full_with_trailing_slash(void **state) +void +create_full_with_trailing_slash(void** state) { - Jid *result = jid_create("room@conference.domain.org/nick/"); + Jid* result = jid_create("room@conference.domain.org/nick/"); assert_string_equal("room", result->localpart); assert_string_equal("conference.domain.org", result->domainpart); @@ -191,22 +214,24 @@ void create_full_with_trailing_slash(void **state) jid_destroy(result); } -void returns_fulljid_when_exists(void **state) +void +returns_fulljid_when_exists(void** state) { - Jid *jid = jid_create("localpart@domainpart/resourcepart"); + Jid* jid = jid_create("localpart@domainpart/resourcepart"); - char *result = jid_fulljid_or_barejid(jid); + char* result = jid_fulljid_or_barejid(jid); assert_string_equal("localpart@domainpart/resourcepart", result); jid_destroy(jid); } -void returns_barejid_when_fulljid_not_exists(void **state) +void +returns_barejid_when_fulljid_not_exists(void** state) { - Jid *jid = jid_create("localpart@domainpart"); + Jid* jid = jid_create("localpart@domainpart"); - char *result = jid_fulljid_or_barejid(jid); + char* result = jid_fulljid_or_barejid(jid); assert_string_equal("localpart@domainpart", result); diff --git a/tests/unittests/test_jid.h b/tests/unittests/test_jid.h index 9b96d0b8..000b820a 100644 --- a/tests/unittests/test_jid.h +++ b/tests/unittests/test_jid.h @@ -1,25 +1,25 @@ -void create_jid_from_null_returns_null(void **state); -void create_jid_from_empty_string_returns_null(void **state); -void create_jid_from_full_returns_full(void **state); -void create_jid_from_full_returns_bare(void **state); -void create_jid_from_full_returns_resourcepart(void **state); -void create_jid_from_full_returns_localpart(void **state); -void create_jid_from_full_returns_domainpart(void **state); -void create_jid_from_full_nolocal_returns_full(void **state); -void create_jid_from_full_nolocal_returns_bare(void **state); -void create_jid_from_full_nolocal_returns_resourcepart(void **state); -void create_jid_from_full_nolocal_returns_domainpart(void **state); -void create_jid_from_full_nolocal_returns_null_localpart(void **state); -void create_jid_from_bare_returns_null_full(void **state); -void create_jid_from_bare_returns_null_resource(void **state); -void create_jid_from_bare_returns_bare(void **state); -void create_jid_from_bare_returns_localpart(void **state); -void create_jid_from_bare_returns_domainpart(void **state); -void create_room_jid_returns_room(void **state); -void create_room_jid_returns_nick(void **state); -void create_with_slash_in_resource(void **state); -void create_with_at_in_resource(void **state); -void create_with_at_and_slash_in_resource(void **state); -void create_full_with_trailing_slash(void **state); -void returns_fulljid_when_exists(void **state); -void returns_barejid_when_fulljid_not_exists(void **state); +void create_jid_from_null_returns_null(void** state); +void create_jid_from_empty_string_returns_null(void** state); +void create_jid_from_full_returns_full(void** state); +void create_jid_from_full_returns_bare(void** state); +void create_jid_from_full_returns_resourcepart(void** state); +void create_jid_from_full_returns_localpart(void** state); +void create_jid_from_full_returns_domainpart(void** state); +void create_jid_from_full_nolocal_returns_full(void** state); +void create_jid_from_full_nolocal_returns_bare(void** state); +void create_jid_from_full_nolocal_returns_resourcepart(void** state); +void create_jid_from_full_nolocal_returns_domainpart(void** state); +void create_jid_from_full_nolocal_returns_null_localpart(void** state); +void create_jid_from_bare_returns_null_full(void** state); +void create_jid_from_bare_returns_null_resource(void** state); +void create_jid_from_bare_returns_bare(void** state); +void create_jid_from_bare_returns_localpart(void** state); +void create_jid_from_bare_returns_domainpart(void** state); +void create_room_jid_returns_room(void** state); +void create_room_jid_returns_nick(void** state); +void create_with_slash_in_resource(void** state); +void create_with_at_in_resource(void** state); +void create_with_at_and_slash_in_resource(void** state); +void create_full_with_trailing_slash(void** state); +void returns_fulljid_when_exists(void** state); +void returns_barejid_when_fulljid_not_exists(void** state); diff --git a/tests/unittests/test_muc.c b/tests/unittests/test_muc.c index 888ce039..80d6fbcf 100644 --- a/tests/unittests/test_muc.c +++ b/tests/unittests/test_muc.c @@ -6,19 +6,22 @@ #include "xmpp/muc.h" -void muc_before_test(void **state) +void +muc_before_test(void** state) { muc_init(); } -void muc_after_test(void **state) +void +muc_after_test(void** state) { muc_close(); } -void test_muc_invites_add(void **state) +void +test_muc_invites_add(void** state) { - char *room = "room@conf.server"; + char* room = "room@conf.server"; muc_invites_add(room, NULL); gboolean invite_exists = muc_invites_contain(room); @@ -26,9 +29,10 @@ void test_muc_invites_add(void **state) assert_true(invite_exists); } -void test_muc_remove_invite(void **state) +void +test_muc_remove_invite(void** state) { - char *room = "room@conf.server"; + char* room = "room@conf.server"; muc_invites_add(room, NULL); muc_invites_remove(room); @@ -37,14 +41,16 @@ void test_muc_remove_invite(void **state) assert_false(invite_exists); } -void test_muc_invites_count_0(void **state) +void +test_muc_invites_count_0(void** state) { int invite_count = muc_invites_count(); assert_true(invite_count == 0); } -void test_muc_invites_count_5(void **state) +void +test_muc_invites_count_5(void** state) { muc_invites_add("room1@conf.server", NULL); muc_invites_add("room2@conf.server", NULL); @@ -57,19 +63,21 @@ void test_muc_invites_count_5(void **state) assert_true(invite_count == 5); } -void test_muc_room_is_not_active(void **state) +void +test_muc_room_is_not_active(void** state) { - char *room = "room@server.org"; + char* room = "room@server.org"; gboolean room_is_active = muc_active(room); assert_false(room_is_active); } -void test_muc_active(void **state) +void +test_muc_active(void** state) { - char *room = "room@server.org"; - char *nick = "bob"; + char* room = "room@server.org"; + char* nick = "bob"; muc_join(room, nick, NULL, FALSE); gboolean room_is_active = muc_active(room); diff --git a/tests/unittests/test_muc.h b/tests/unittests/test_muc.h index 8df54a5d..2140d520 100644 --- a/tests/unittests/test_muc.h +++ b/tests/unittests/test_muc.h @@ -1,9 +1,9 @@ -void muc_before_test(void **state); -void muc_after_test(void **state); +void muc_before_test(void** state); +void muc_after_test(void** state); -void test_muc_invites_add(void **state); -void test_muc_remove_invite(void **state); -void test_muc_invites_count_0(void **state); -void test_muc_invites_count_5(void **state); -void test_muc_room_is_not_active(void **state); -void test_muc_active(void **state); +void test_muc_invites_add(void** state); +void test_muc_remove_invite(void** state); +void test_muc_invites_count_0(void** state); +void test_muc_invites_count_5(void** state); +void test_muc_room_is_not_active(void** state); +void test_muc_active(void** state); diff --git a/tests/unittests/test_parser.c b/tests/unittests/test_parser.c index e64438a4..96143294 100644 --- a/tests/unittests/test_parser.c +++ b/tests/unittests/test_parser.c @@ -7,11 +7,11 @@ #include "tools/parser.h" void -parse_null_returns_null(void **state) +parse_null_returns_null(void** state) { - char *inp = NULL; + char* inp = NULL; gboolean result = TRUE; - gchar **args = parse_args(inp, 1, 2, &result); + gchar** args = parse_args(inp, 1, 2, &result); assert_false(result); assert_null(args); @@ -19,11 +19,11 @@ parse_null_returns_null(void **state) } void -parse_empty_returns_null(void **state) +parse_empty_returns_null(void** state) { - char *inp = ""; + char* inp = ""; gboolean result = TRUE; - gchar **args = parse_args(inp, 1, 2, &result); + gchar** args = parse_args(inp, 1, 2, &result); assert_false(result); assert_null(args); @@ -31,11 +31,11 @@ parse_empty_returns_null(void **state) } void -parse_space_returns_null(void **state) +parse_space_returns_null(void** state) { - char *inp = " "; + char* inp = " "; gboolean result = TRUE; - gchar **args = parse_args(inp, 1, 2, &result); + gchar** args = parse_args(inp, 1, 2, &result); assert_false(result); assert_null(args); @@ -43,11 +43,11 @@ parse_space_returns_null(void **state) } void -parse_cmd_no_args_returns_null(void **state) +parse_cmd_no_args_returns_null(void** state) { - char *inp = "/cmd"; + char* inp = "/cmd"; gboolean result = TRUE; - gchar **args = parse_args(inp, 1, 2, &result); + gchar** args = parse_args(inp, 1, 2, &result); assert_false(result); assert_null(args); @@ -55,11 +55,11 @@ parse_cmd_no_args_returns_null(void **state) } void -parse_cmd_with_space_returns_null(void **state) +parse_cmd_with_space_returns_null(void** state) { - char *inp = "/cmd "; + char* inp = "/cmd "; gboolean result = TRUE; - gchar **args = parse_args(inp, 1, 2, &result); + gchar** args = parse_args(inp, 1, 2, &result); assert_false(result); assert_null(args); @@ -67,11 +67,11 @@ parse_cmd_with_space_returns_null(void **state) } void -parse_cmd_with_too_few_returns_null(void **state) +parse_cmd_with_too_few_returns_null(void** state) { - char *inp = "/cmd arg1"; + char* inp = "/cmd arg1"; gboolean result = TRUE; - gchar **args = parse_args(inp, 2, 3, &result); + gchar** args = parse_args(inp, 2, 3, &result); assert_false(result); assert_null(args); @@ -79,11 +79,11 @@ parse_cmd_with_too_few_returns_null(void **state) } void -parse_cmd_with_too_many_returns_null(void **state) +parse_cmd_with_too_many_returns_null(void** state) { - char *inp = "/cmd arg1 arg2 arg3 arg4"; + char* inp = "/cmd arg1 arg2 arg3 arg4"; gboolean result = TRUE; - gchar **args = parse_args(inp, 1, 3, &result); + gchar** args = parse_args(inp, 1, 3, &result); assert_false(result); assert_null(args); @@ -91,11 +91,11 @@ parse_cmd_with_too_many_returns_null(void **state) } void -parse_cmd_one_arg(void **state) +parse_cmd_one_arg(void** state) { - char *inp = "/cmd arg1"; + char* inp = "/cmd arg1"; gboolean result = FALSE; - gchar **args = parse_args(inp, 1, 2, &result); + gchar** args = parse_args(inp, 1, 2, &result); assert_true(result); assert_int_equal(1, g_strv_length(args)); @@ -104,11 +104,11 @@ parse_cmd_one_arg(void **state) } void -parse_cmd_two_args(void **state) +parse_cmd_two_args(void** state) { - char *inp = "/cmd arg1 arg2"; + char* inp = "/cmd arg1 arg2"; gboolean result = FALSE; - gchar **args = parse_args(inp, 1, 2, &result); + gchar** args = parse_args(inp, 1, 2, &result); assert_true(result); assert_int_equal(2, g_strv_length(args)); @@ -118,11 +118,11 @@ parse_cmd_two_args(void **state) } void -parse_cmd_three_args(void **state) +parse_cmd_three_args(void** state) { - char *inp = "/cmd arg1 arg2 arg3"; + char* inp = "/cmd arg1 arg2 arg3"; gboolean result = FALSE; - gchar **args = parse_args(inp, 3, 3, &result); + gchar** args = parse_args(inp, 3, 3, &result); assert_true(result); assert_int_equal(3, g_strv_length(args)); @@ -133,11 +133,11 @@ parse_cmd_three_args(void **state) } void -parse_cmd_three_args_with_spaces(void **state) +parse_cmd_three_args_with_spaces(void** state) { - char *inp = " /cmd arg1 arg2 arg3 "; + char* inp = " /cmd arg1 arg2 arg3 "; gboolean result = FALSE; - gchar **args = parse_args(inp, 3, 3, &result); + gchar** args = parse_args(inp, 3, 3, &result); assert_true(result); assert_int_equal(3, g_strv_length(args)); @@ -148,11 +148,11 @@ parse_cmd_three_args_with_spaces(void **state) } void -parse_cmd_with_freetext(void **state) +parse_cmd_with_freetext(void** state) { - char *inp = "/cmd this is some free text"; + char* inp = "/cmd this is some free text"; gboolean result = FALSE; - gchar **args = parse_args_with_freetext(inp, 1, 1, &result); + gchar** args = parse_args_with_freetext(inp, 1, 1, &result); assert_true(result); assert_int_equal(1, g_strv_length(args)); @@ -161,11 +161,11 @@ parse_cmd_with_freetext(void **state) } void -parse_cmd_one_arg_with_freetext(void **state) +parse_cmd_one_arg_with_freetext(void** state) { - char *inp = "/cmd arg1 this is some free text"; + char* inp = "/cmd arg1 this is some free text"; gboolean result = FALSE; - gchar **args = parse_args_with_freetext(inp, 1, 2, &result); + gchar** args = parse_args_with_freetext(inp, 1, 2, &result); assert_true(result); assert_int_equal(2, g_strv_length(args)); @@ -175,11 +175,11 @@ parse_cmd_one_arg_with_freetext(void **state) } void -parse_cmd_two_args_with_freetext(void **state) +parse_cmd_two_args_with_freetext(void** state) { - char *inp = "/cmd arg1 arg2 this is some free text"; + char* inp = "/cmd arg1 arg2 this is some free text"; gboolean result = FALSE; - gchar **args = parse_args_with_freetext(inp, 1, 3, &result); + gchar** args = parse_args_with_freetext(inp, 1, 3, &result); assert_true(result); assert_int_equal(3, g_strv_length(args)); @@ -190,11 +190,11 @@ parse_cmd_two_args_with_freetext(void **state) } void -parse_cmd_min_zero(void **state) +parse_cmd_min_zero(void** state) { - char *inp = "/cmd"; + char* inp = "/cmd"; gboolean result = FALSE; - gchar **args = parse_args(inp, 0, 2, &result); + gchar** args = parse_args(inp, 0, 2, &result); assert_true(result); assert_int_equal(0, g_strv_length(args)); @@ -203,11 +203,11 @@ parse_cmd_min_zero(void **state) } void -parse_cmd_min_zero_with_freetext(void **state) +parse_cmd_min_zero_with_freetext(void** state) { - char *inp = "/cmd"; + char* inp = "/cmd"; gboolean result = FALSE; - gchar **args = parse_args_with_freetext(inp, 0, 2, &result); + gchar** args = parse_args_with_freetext(inp, 0, 2, &result); assert_true(result); assert_int_equal(0, g_strv_length(args)); @@ -216,11 +216,11 @@ parse_cmd_min_zero_with_freetext(void **state) } void -parse_cmd_with_quoted(void **state) +parse_cmd_with_quoted(void** state) { - char *inp = "/cmd \"arg1\" arg2"; + char* inp = "/cmd \"arg1\" arg2"; gboolean result = FALSE; - gchar **args = parse_args(inp, 2, 2, &result); + gchar** args = parse_args(inp, 2, 2, &result); assert_true(result); assert_int_equal(2, g_strv_length(args)); @@ -230,11 +230,11 @@ parse_cmd_with_quoted(void **state) } void -parse_cmd_with_quoted_and_space(void **state) +parse_cmd_with_quoted_and_space(void** state) { - char *inp = "/cmd \"the arg1\" arg2"; + char* inp = "/cmd \"the arg1\" arg2"; gboolean result = FALSE; - gchar **args = parse_args(inp, 2, 2, &result); + gchar** args = parse_args(inp, 2, 2, &result); assert_true(result); assert_int_equal(2, g_strv_length(args)); @@ -244,11 +244,11 @@ parse_cmd_with_quoted_and_space(void **state) } void -parse_cmd_with_quoted_and_many_spaces(void **state) +parse_cmd_with_quoted_and_many_spaces(void** state) { - char *inp = "/cmd \"the arg1 is here\" arg2"; + char* inp = "/cmd \"the arg1 is here\" arg2"; gboolean result = FALSE; - gchar **args = parse_args(inp, 2, 2, &result); + gchar** args = parse_args(inp, 2, 2, &result); assert_true(result); assert_int_equal(2, g_strv_length(args)); @@ -258,11 +258,11 @@ parse_cmd_with_quoted_and_many_spaces(void **state) } void -parse_cmd_with_many_quoted_and_many_spaces(void **state) +parse_cmd_with_many_quoted_and_many_spaces(void** state) { - char *inp = "/cmd \"the arg1 is here\" \"and arg2 is right here\""; + char* inp = "/cmd \"the arg1 is here\" \"and arg2 is right here\""; gboolean result = FALSE; - gchar **args = parse_args(inp, 2, 2, &result); + gchar** args = parse_args(inp, 2, 2, &result); assert_true(result); assert_int_equal(2, g_strv_length(args)); @@ -272,11 +272,11 @@ parse_cmd_with_many_quoted_and_many_spaces(void **state) } void -parse_cmd_freetext_with_quoted(void **state) +parse_cmd_freetext_with_quoted(void** state) { - char *inp = "/cmd \"arg1\" arg2 hello there whats up"; + char* inp = "/cmd \"arg1\" arg2 hello there whats up"; gboolean result = FALSE; - gchar **args = parse_args_with_freetext(inp, 3, 3, &result); + gchar** args = parse_args_with_freetext(inp, 3, 3, &result); assert_true(result); assert_int_equal(3, g_strv_length(args)); @@ -287,11 +287,11 @@ parse_cmd_freetext_with_quoted(void **state) } void -parse_cmd_freetext_with_quoted_and_space(void **state) +parse_cmd_freetext_with_quoted_and_space(void** state) { - char *inp = "/cmd \"the arg1\" arg2 another bit of freetext"; + char* inp = "/cmd \"the arg1\" arg2 another bit of freetext"; gboolean result = FALSE; - gchar **args = parse_args_with_freetext(inp, 3, 3, &result); + gchar** args = parse_args_with_freetext(inp, 3, 3, &result); assert_true(result); assert_int_equal(3, g_strv_length(args)); @@ -302,11 +302,11 @@ parse_cmd_freetext_with_quoted_and_space(void **state) } void -parse_cmd_freetext_with_quoted_and_many_spaces(void **state) +parse_cmd_freetext_with_quoted_and_many_spaces(void** state) { - char *inp = "/cmd \"the arg1 is here\" arg2 some more freetext"; + char* inp = "/cmd \"the arg1 is here\" arg2 some more freetext"; gboolean result = FALSE; - gchar **args = parse_args_with_freetext(inp, 3, 3, &result); + gchar** args = parse_args_with_freetext(inp, 3, 3, &result); assert_true(result); assert_int_equal(3, g_strv_length(args)); @@ -317,11 +317,11 @@ parse_cmd_freetext_with_quoted_and_many_spaces(void **state) } void -parse_cmd_freetext_with_many_quoted_and_many_spaces(void **state) +parse_cmd_freetext_with_many_quoted_and_many_spaces(void** state) { - char *inp = "/cmd \"the arg1 is here\" \"and arg2 is right here\" and heres the free text"; + char* inp = "/cmd \"the arg1 is here\" \"and arg2 is right here\" and heres the free text"; gboolean result = FALSE; - gchar **args = parse_args_with_freetext(inp, 3, 3, &result); + gchar** args = parse_args_with_freetext(inp, 3, 3, &result); assert_true(result); assert_int_equal(3, g_strv_length(args)); @@ -332,11 +332,11 @@ parse_cmd_freetext_with_many_quoted_and_many_spaces(void **state) } void -parse_cmd_with_quoted_freetext(void **state) +parse_cmd_with_quoted_freetext(void** state) { - char *inp = "/cmd arg1 here is \"some\" quoted freetext"; + char* inp = "/cmd arg1 here is \"some\" quoted freetext"; gboolean result = FALSE; - gchar **args = parse_args_with_freetext(inp, 1, 2, &result); + gchar** args = parse_args_with_freetext(inp, 1, 2, &result); assert_true(result); assert_int_equal(2, g_strv_length(args)); @@ -346,11 +346,11 @@ parse_cmd_with_quoted_freetext(void **state) } void -parse_cmd_with_third_arg_quoted_0_min_3_max(void **state) +parse_cmd_with_third_arg_quoted_0_min_3_max(void** state) { - char *inp = "/group add friends \"The User\""; + char* inp = "/group add friends \"The User\""; gboolean result = FALSE; - gchar **args = parse_args_with_freetext(inp, 0, 3, &result); + gchar** args = parse_args_with_freetext(inp, 0, 3, &result); assert_true(result); assert_int_equal(3, g_strv_length(args)); @@ -362,11 +362,11 @@ parse_cmd_with_third_arg_quoted_0_min_3_max(void **state) } void -parse_cmd_with_second_arg_quoted_0_min_3_max(void **state) +parse_cmd_with_second_arg_quoted_0_min_3_max(void** state) { - char *inp = "/group add \"The Group\" friend"; + char* inp = "/group add \"The Group\" friend"; gboolean result = FALSE; - gchar **args = parse_args_with_freetext(inp, 0, 3, &result); + gchar** args = parse_args_with_freetext(inp, 0, 3, &result); assert_true(result); assert_int_equal(3, g_strv_length(args)); @@ -378,11 +378,11 @@ parse_cmd_with_second_arg_quoted_0_min_3_max(void **state) } void -parse_cmd_with_second_and_third_arg_quoted_0_min_3_max(void **state) +parse_cmd_with_second_and_third_arg_quoted_0_min_3_max(void** state) { - char *inp = "/group add \"The Group\" \"The User\""; + char* inp = "/group add \"The Group\" \"The User\""; gboolean result = FALSE; - gchar **args = parse_args_with_freetext(inp, 0, 3, &result); + gchar** args = parse_args_with_freetext(inp, 0, 3, &result); assert_true(result); assert_int_equal(3, g_strv_length(args)); @@ -394,137 +394,137 @@ parse_cmd_with_second_and_third_arg_quoted_0_min_3_max(void **state) } void -count_one_token(void **state) +count_one_token(void** state) { - char *inp = "one"; + char* inp = "one"; int result = count_tokens(inp); assert_int_equal(1, result); } void -count_one_token_quoted_no_whitespace(void **state) +count_one_token_quoted_no_whitespace(void** state) { - char *inp = "\"one\""; + char* inp = "\"one\""; int result = count_tokens(inp); assert_int_equal(1, result); } void -count_one_token_quoted_with_whitespace(void **state) +count_one_token_quoted_with_whitespace(void** state) { - char *inp = "\"one two\""; + char* inp = "\"one two\""; int result = count_tokens(inp); assert_int_equal(1, result); } void -count_two_tokens(void **state) +count_two_tokens(void** state) { - char *inp = "one two"; + char* inp = "one two"; int result = count_tokens(inp); assert_int_equal(2, result); } void -count_two_tokens_first_quoted(void **state) +count_two_tokens_first_quoted(void** state) { - char *inp = "\"one and\" two"; + char* inp = "\"one and\" two"; int result = count_tokens(inp); assert_int_equal(2, result); } void -count_two_tokens_second_quoted(void **state) +count_two_tokens_second_quoted(void** state) { - char *inp = "one \"two and\""; + char* inp = "one \"two and\""; int result = count_tokens(inp); assert_int_equal(2, result); } void -count_two_tokens_both_quoted(void **state) +count_two_tokens_both_quoted(void** state) { - char *inp = "\"one and then\" \"two and\""; + char* inp = "\"one and then\" \"two and\""; int result = count_tokens(inp); assert_int_equal(2, result); } void -get_first_of_one(void **state) +get_first_of_one(void** state) { - char *inp = "one"; - char *result = get_start(inp, 2); + char* inp = "one"; + char* result = get_start(inp, 2); assert_string_equal("one", result); free(result); } void -get_first_of_two(void **state) +get_first_of_two(void** state) { - char *inp = "one two"; - char *result = get_start(inp, 2); + char* inp = "one two"; + char* result = get_start(inp, 2); assert_string_equal("one ", result); free(result); } void -get_first_two_of_three(void **state) +get_first_two_of_three(void** state) { - char *inp = "one two three"; - char *result = get_start(inp, 3); + char* inp = "one two three"; + char* result = get_start(inp, 3); assert_string_equal("one two ", result); free(result); } void -get_first_two_of_three_first_quoted(void **state) +get_first_two_of_three_first_quoted(void** state) { - char *inp = "\"one\" two three"; - char *result = get_start(inp, 3); + char* inp = "\"one\" two three"; + char* result = get_start(inp, 3); assert_string_equal("\"one\" two ", result); free(result); } void -get_first_two_of_three_second_quoted(void **state) +get_first_two_of_three_second_quoted(void** state) { - char *inp = "one \"two\" three"; - char *result = get_start(inp, 3); + char* inp = "one \"two\" three"; + char* result = get_start(inp, 3); assert_string_equal("one \"two\" ", result); free(result); } void -get_first_two_of_three_first_and_second_quoted(void **state) +get_first_two_of_three_first_and_second_quoted(void** state) { - char *inp = "\"one\" \"two\" three"; - char *result = get_start(inp, 3); + char* inp = "\"one\" \"two\" three"; + char* result = get_start(inp, 3); assert_string_equal("\"one\" \"two\" ", result); free(result); } void -parse_options_when_none_returns_empty_hasmap(void **state) +parse_options_when_none_returns_empty_hasmap(void** state) { - gchar *args[] = { "cmd1", "cmd2", NULL }; - gchar *keys[] = { "opt1", NULL }; + gchar* args[] = { "cmd1", "cmd2", NULL }; + gchar* keys[] = { "opt1", NULL }; gboolean res = FALSE; - GHashTable *options = parse_options(&args[2], keys, &res); + GHashTable* options = parse_options(&args[2], keys, &res); assert_true(options != NULL); assert_int_equal(0, g_hash_table_size(options)); @@ -534,14 +534,14 @@ parse_options_when_none_returns_empty_hasmap(void **state) } void -parse_options_when_opt1_no_val_sets_error(void **state) +parse_options_when_opt1_no_val_sets_error(void** state) { - gchar *args[] = { "cmd1", "cmd2", "opt1", NULL }; - gchar *keys[] = { "opt1", NULL }; + gchar* args[] = { "cmd1", "cmd2", "opt1", NULL }; + gchar* keys[] = { "opt1", NULL }; gboolean res = TRUE; - GHashTable *options = parse_options(&args[2], keys, &res); + GHashTable* options = parse_options(&args[2], keys, &res); assert_null(options); assert_false(res); @@ -550,14 +550,14 @@ parse_options_when_opt1_no_val_sets_error(void **state) } void -parse_options_when_one_returns_map(void **state) +parse_options_when_one_returns_map(void** state) { - gchar *args[] = { "cmd1", "cmd2", "opt1", "val1", NULL }; - gchar *keys[] = { "opt1", NULL }; + gchar* args[] = { "cmd1", "cmd2", "opt1", "val1", NULL }; + gchar* keys[] = { "opt1", NULL }; gboolean res = FALSE; - GHashTable *options = parse_options(&args[2], keys, &res); + GHashTable* options = parse_options(&args[2], keys, &res); assert_int_equal(1, g_hash_table_size(options)); assert_true(g_hash_table_contains(options, "opt1")); @@ -568,14 +568,14 @@ parse_options_when_one_returns_map(void **state) } void -parse_options_when_opt2_no_val_sets_error(void **state) +parse_options_when_opt2_no_val_sets_error(void** state) { - gchar *args[] = { "cmd1", "cmd2", "opt1", "val1", "opt2", NULL }; - gchar *keys[] = { "opt1", "opt2", NULL }; + gchar* args[] = { "cmd1", "cmd2", "opt1", "val1", "opt2", NULL }; + gchar* keys[] = { "opt1", "opt2", NULL }; gboolean res = TRUE; - GHashTable *options = parse_options(&args[2], keys, &res); + GHashTable* options = parse_options(&args[2], keys, &res); assert_null(options); assert_false(res); @@ -584,14 +584,14 @@ parse_options_when_opt2_no_val_sets_error(void **state) } void -parse_options_when_two_returns_map(void **state) +parse_options_when_two_returns_map(void** state) { - gchar *args[] = { "cmd1", "cmd2", "opt1", "val1", "opt2", "val2", NULL }; - gchar *keys[] = { "opt1", "opt2", NULL }; + gchar* args[] = { "cmd1", "cmd2", "opt1", "val1", "opt2", "val2", NULL }; + gchar* keys[] = { "opt1", "opt2", NULL }; gboolean res = FALSE; - GHashTable *options = parse_options(&args[2], keys, &res); + GHashTable* options = parse_options(&args[2], keys, &res); assert_int_equal(2, g_hash_table_size(options)); assert_true(g_hash_table_contains(options, "opt1")); @@ -604,14 +604,14 @@ parse_options_when_two_returns_map(void **state) } void -parse_options_when_opt3_no_val_sets_error(void **state) +parse_options_when_opt3_no_val_sets_error(void** state) { - gchar *args[] = { "cmd1", "cmd2", "opt1", "val1", "opt2", "val2", "opt3", NULL }; - gchar *keys[] = { "opt1", "opt2", "opt3", NULL }; + gchar* args[] = { "cmd1", "cmd2", "opt1", "val1", "opt2", "val2", "opt3", NULL }; + gchar* keys[] = { "opt1", "opt2", "opt3", NULL }; gboolean res = TRUE; - GHashTable *options = parse_options(&args[2], keys, &res); + GHashTable* options = parse_options(&args[2], keys, &res); assert_null(options); assert_false(res); @@ -620,14 +620,14 @@ parse_options_when_opt3_no_val_sets_error(void **state) } void -parse_options_when_three_returns_map(void **state) +parse_options_when_three_returns_map(void** state) { - gchar *args[] = { "cmd1", "cmd2", "opt1", "val1", "opt2", "val2", "opt3", "val3", NULL }; - gchar *keys[] = { "opt1", "opt2", "opt3", NULL }; + gchar* args[] = { "cmd1", "cmd2", "opt1", "val1", "opt2", "val2", "opt3", "val3", NULL }; + gchar* keys[] = { "opt1", "opt2", "opt3", NULL }; gboolean res = FALSE; - GHashTable *options = parse_options(&args[2], keys, &res); + GHashTable* options = parse_options(&args[2], keys, &res); assert_int_equal(3, g_hash_table_size(options)); assert_true(g_hash_table_contains(options, "opt1")); @@ -642,14 +642,14 @@ parse_options_when_three_returns_map(void **state) } void -parse_options_when_unknown_opt_sets_error(void **state) +parse_options_when_unknown_opt_sets_error(void** state) { - gchar *args[] = { "cmd1", "cmd2", "opt1", "val1", "oops", "val2", "opt3", "val3", NULL }; - gchar *keys[] = { "opt1", "opt2", "opt3", NULL }; + gchar* args[] = { "cmd1", "cmd2", "opt1", "val1", "oops", "val2", "opt3", "val3", NULL }; + gchar* keys[] = { "opt1", "opt2", "opt3", NULL }; gboolean res = TRUE; - GHashTable *options = parse_options(&args[2], keys, &res); + GHashTable* options = parse_options(&args[2], keys, &res); assert_null(options); assert_false(res); @@ -658,14 +658,14 @@ parse_options_when_unknown_opt_sets_error(void **state) } void -parse_options_with_duplicated_option_sets_error(void **state) +parse_options_with_duplicated_option_sets_error(void** state) { - gchar *args[] = { "cmd1", "cmd2", "opt1", "val1", "opt2", "val2", "opt1", "val3", NULL }; - gchar *keys[] = { "opt1", "opt2", "opt3", NULL }; + gchar* args[] = { "cmd1", "cmd2", "opt1", "val1", "opt2", "val2", "opt1", "val3", NULL }; + gchar* keys[] = { "opt1", "opt2", "opt3", NULL }; gboolean res = TRUE; - GHashTable *options = parse_options(&args[2], keys, &res); + GHashTable* options = parse_options(&args[2], keys, &res); assert_null(options); assert_false(res); diff --git a/tests/unittests/test_parser.h b/tests/unittests/test_parser.h index 51d768fe..7babb0be 100644 --- a/tests/unittests/test_parser.h +++ b/tests/unittests/test_parser.h @@ -1,50 +1,50 @@ -void parse_null_returns_null(void **state); -void parse_empty_returns_null(void **state); -void parse_space_returns_null(void **state); -void parse_cmd_no_args_returns_null(void **state); -void parse_cmd_with_space_returns_null(void **state); -void parse_cmd_with_too_few_returns_null(void **state); -void parse_cmd_with_too_many_returns_null(void **state); -void parse_cmd_one_arg(void **state); -void parse_cmd_two_args(void **state); -void parse_cmd_three_args(void **state); -void parse_cmd_three_args_with_spaces(void **state); -void parse_cmd_with_freetext(void **state); -void parse_cmd_one_arg_with_freetext(void **state); -void parse_cmd_two_args_with_freetext(void **state); -void parse_cmd_min_zero(void **state); -void parse_cmd_min_zero_with_freetext(void **state); -void parse_cmd_with_quoted(void **state); -void parse_cmd_with_quoted_and_space(void **state); -void parse_cmd_with_quoted_and_many_spaces(void **state); -void parse_cmd_with_many_quoted_and_many_spaces(void **state); -void parse_cmd_freetext_with_quoted(void **state); -void parse_cmd_freetext_with_quoted_and_space(void **state); -void parse_cmd_freetext_with_quoted_and_many_spaces(void **state); -void parse_cmd_freetext_with_many_quoted_and_many_spaces(void **state); -void parse_cmd_with_quoted_freetext(void **state); -void parse_cmd_with_third_arg_quoted_0_min_3_max(void **state); -void parse_cmd_with_second_arg_quoted_0_min_3_max(void **state); -void parse_cmd_with_second_and_third_arg_quoted_0_min_3_max(void **state); -void count_one_token(void **state); -void count_one_token_quoted_no_whitespace(void **state); -void count_one_token_quoted_with_whitespace(void **state); -void count_two_tokens(void **state); -void count_two_tokens_first_quoted(void **state); -void count_two_tokens_second_quoted(void **state); -void count_two_tokens_both_quoted(void **state); -void get_first_of_one(void **state); -void get_first_of_two(void **state); -void get_first_two_of_three(void **state); -void get_first_two_of_three_first_quoted(void **state); -void get_first_two_of_three_second_quoted(void **state); -void get_first_two_of_three_first_and_second_quoted(void **state); -void parse_options_when_none_returns_empty_hasmap(void **state); -void parse_options_when_opt1_no_val_sets_error(void **state); -void parse_options_when_one_returns_map(void **state); -void parse_options_when_opt2_no_val_sets_error(void **state); -void parse_options_when_two_returns_map(void **state); -void parse_options_when_opt3_no_val_sets_error(void **state); -void parse_options_when_three_returns_map(void **state); -void parse_options_when_unknown_opt_sets_error(void **state); -void parse_options_with_duplicated_option_sets_error(void **state); +void parse_null_returns_null(void** state); +void parse_empty_returns_null(void** state); +void parse_space_returns_null(void** state); +void parse_cmd_no_args_returns_null(void** state); +void parse_cmd_with_space_returns_null(void** state); +void parse_cmd_with_too_few_returns_null(void** state); +void parse_cmd_with_too_many_returns_null(void** state); +void parse_cmd_one_arg(void** state); +void parse_cmd_two_args(void** state); +void parse_cmd_three_args(void** state); +void parse_cmd_three_args_with_spaces(void** state); +void parse_cmd_with_freetext(void** state); +void parse_cmd_one_arg_with_freetext(void** state); +void parse_cmd_two_args_with_freetext(void** state); +void parse_cmd_min_zero(void** state); +void parse_cmd_min_zero_with_freetext(void** state); +void parse_cmd_with_quoted(void** state); +void parse_cmd_with_quoted_and_space(void** state); +void parse_cmd_with_quoted_and_many_spaces(void** state); +void parse_cmd_with_many_quoted_and_many_spaces(void** state); +void parse_cmd_freetext_with_quoted(void** state); +void parse_cmd_freetext_with_quoted_and_space(void** state); +void parse_cmd_freetext_with_quoted_and_many_spaces(void** state); +void parse_cmd_freetext_with_many_quoted_and_many_spaces(void** state); +void parse_cmd_with_quoted_freetext(void** state); +void parse_cmd_with_third_arg_quoted_0_min_3_max(void** state); +void parse_cmd_with_second_arg_quoted_0_min_3_max(void** state); +void parse_cmd_with_second_and_third_arg_quoted_0_min_3_max(void** state); +void count_one_token(void** state); +void count_one_token_quoted_no_whitespace(void** state); +void count_one_token_quoted_with_whitespace(void** state); +void count_two_tokens(void** state); +void count_two_tokens_first_quoted(void** state); +void count_two_tokens_second_quoted(void** state); +void count_two_tokens_both_quoted(void** state); +void get_first_of_one(void** state); +void get_first_of_two(void** state); +void get_first_two_of_three(void** state); +void get_first_two_of_three_first_quoted(void** state); +void get_first_two_of_three_second_quoted(void** state); +void get_first_two_of_three_first_and_second_quoted(void** state); +void parse_options_when_none_returns_empty_hasmap(void** state); +void parse_options_when_opt1_no_val_sets_error(void** state); +void parse_options_when_one_returns_map(void** state); +void parse_options_when_opt2_no_val_sets_error(void** state); +void parse_options_when_two_returns_map(void** state); +void parse_options_when_opt3_no_val_sets_error(void** state); +void parse_options_when_three_returns_map(void** state); +void parse_options_when_unknown_opt_sets_error(void** state); +void parse_options_with_duplicated_option_sets_error(void** state); diff --git a/tests/unittests/test_plugins_disco.c b/tests/unittests/test_plugins_disco.c index f152d935..880a09b1 100644 --- a/tests/unittests/test_plugins_disco.c +++ b/tests/unittests/test_plugins_disco.c @@ -7,10 +7,10 @@ #include "plugins/disco.h" void -returns_empty_list_when_none(void **state) +returns_empty_list_when_none(void** state) { disco_close(); - GList *features = disco_get_features(); + GList* features = disco_get_features(); assert_int_equal(g_list_length(features), 0); @@ -19,14 +19,14 @@ returns_empty_list_when_none(void **state) } void -returns_added_feature(void **state) +returns_added_feature(void** state) { disco_close(); disco_add_feature("my_plugin", "some:feature:example"); - GList *features = disco_get_features(); + GList* features = disco_get_features(); assert_int_equal(g_list_length(features), 1); - char *feature = features->data; + char* feature = features->data; assert_string_equal(feature, "some:feature:example"); g_list_free(features); @@ -34,12 +34,12 @@ returns_added_feature(void **state) } void -resets_features_on_close(void **state) +resets_features_on_close(void** state) { disco_close(); disco_add_feature("my_plugin", "some:feature:example"); - GList *features = disco_get_features(); + GList* features = disco_get_features(); assert_int_equal(g_list_length(features), 1); g_list_free(features); @@ -52,7 +52,7 @@ resets_features_on_close(void **state) } void -returns_all_added_features(void **state) +returns_all_added_features(void** state) { disco_close(); disco_add_feature("first_plugin", "first:feature"); @@ -61,7 +61,7 @@ returns_all_added_features(void **state) disco_add_feature("third_plugin", "fourth:feature"); disco_add_feature("third_plugin", "fifth:feature"); - GList *features = disco_get_features(); + GList* features = disco_get_features(); assert_int_equal(g_list_length(features), 5); assert_true(g_list_find_custom(features, "first:feature", (GCompareFunc)g_strcmp0)); @@ -75,13 +75,13 @@ returns_all_added_features(void **state) } void -does_not_add_duplicate_feature(void **state) +does_not_add_duplicate_feature(void** state) { disco_close(); disco_add_feature("my_plugin", "my:feature"); disco_add_feature("some_other_plugin", "my:feature"); - GList *features = disco_get_features(); + GList* features = disco_get_features(); assert_int_equal(g_list_length(features), 1); g_list_free(features); @@ -89,14 +89,14 @@ does_not_add_duplicate_feature(void **state) } void -removes_plugin_features(void **state) +removes_plugin_features(void** state) { disco_close(); disco_add_feature("plugin1", "plugin1:feature1"); disco_add_feature("plugin1", "plugin1:feature2"); disco_add_feature("plugin2", "plugin2:feature1"); - GList *features = disco_get_features(); + GList* features = disco_get_features(); assert_int_equal(g_list_length(features), 3); g_list_free(features); @@ -110,14 +110,14 @@ removes_plugin_features(void **state) } void -does_not_remove_feature_when_more_than_one_reference(void **state) +does_not_remove_feature_when_more_than_one_reference(void** state) { disco_close(); disco_add_feature("plugin1", "feature1"); disco_add_feature("plugin1", "feature2"); disco_add_feature("plugin2", "feature1"); - GList *features = disco_get_features(); + GList* features = disco_get_features(); assert_int_equal(g_list_length(features), 2); g_list_free(features); diff --git a/tests/unittests/test_plugins_disco.h b/tests/unittests/test_plugins_disco.h index 937cbfe1..4377e28e 100644 --- a/tests/unittests/test_plugins_disco.h +++ b/tests/unittests/test_plugins_disco.h @@ -1,7 +1,7 @@ -void returns_empty_list_when_none(void **state); -void returns_added_feature(void **state); -void resets_features_on_close(void **state); -void returns_all_added_features(void **state); -void does_not_add_duplicate_feature(void **state); -void removes_plugin_features(void **state); -void does_not_remove_feature_when_more_than_one_reference(void **state); +void returns_empty_list_when_none(void** state); +void returns_added_feature(void** state); +void resets_features_on_close(void** state); +void returns_all_added_features(void** state); +void does_not_add_duplicate_feature(void** state); +void removes_plugin_features(void** state); +void does_not_remove_feature_when_more_than_one_reference(void** state); diff --git a/tests/unittests/test_preferences.c b/tests/unittests/test_preferences.c index 5aeb266d..f3fe8e3e 100644 --- a/tests/unittests/test_preferences.c +++ b/tests/unittests/test_preferences.c @@ -8,27 +8,30 @@ #include "config/preferences.h" -void statuses_console_defaults_to_all(void **state) +void +statuses_console_defaults_to_all(void** state) { - char *setting = prefs_get_string(PREF_STATUSES_CONSOLE); + char* setting = prefs_get_string(PREF_STATUSES_CONSOLE); assert_non_null(setting); assert_string_equal("all", setting); g_free(setting); } -void statuses_chat_defaults_to_all(void **state) +void +statuses_chat_defaults_to_all(void** state) { - char *setting = prefs_get_string(PREF_STATUSES_CHAT); + char* setting = prefs_get_string(PREF_STATUSES_CHAT); assert_non_null(setting); assert_string_equal("all", setting); g_free(setting); } -void statuses_muc_defaults_to_all(void **state) +void +statuses_muc_defaults_to_all(void** state) { - char *setting = prefs_get_string(PREF_STATUSES_MUC); + char* setting = prefs_get_string(PREF_STATUSES_MUC); assert_non_null(setting); assert_string_equal("all", setting); diff --git a/tests/unittests/test_preferences.h b/tests/unittests/test_preferences.h index 5bf79a6a..84438e95 100644 --- a/tests/unittests/test_preferences.h +++ b/tests/unittests/test_preferences.h @@ -1,3 +1,3 @@ -void statuses_console_defaults_to_all(void **state); -void statuses_chat_defaults_to_all(void **state); -void statuses_muc_defaults_to_all(void **state); +void statuses_console_defaults_to_all(void** state); +void statuses_chat_defaults_to_all(void** state); +void statuses_muc_defaults_to_all(void** state); diff --git a/tests/unittests/test_roster_list.c b/tests/unittests/test_roster_list.c index c8af855a..b46e7b57 100644 --- a/tests/unittests/test_roster_list.c +++ b/tests/unittests/test_roster_list.c @@ -9,32 +9,35 @@ #include "xmpp/contact.h" #include "xmpp/roster_list.h" -void empty_list_when_none_added(void **state) +void +empty_list_when_none_added(void** state) { roster_create(); - GSList *list = roster_get_contacts(ROSTER_ORD_NAME); + GSList* list = roster_get_contacts(ROSTER_ORD_NAME); assert_null(list); g_slist_free(list); roster_destroy(); } -void contains_one_element(void **state) +void +contains_one_element(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); - GSList *list = roster_get_contacts(ROSTER_ORD_NAME); + GSList* list = roster_get_contacts(ROSTER_ORD_NAME); assert_int_equal(1, g_slist_length(list)); g_slist_free(list); roster_destroy(); } -void first_element_correct(void **state) +void +first_element_correct(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); - GSList *list = roster_get_contacts(ROSTER_ORD_NAME); + GSList* list = roster_get_contacts(ROSTER_ORD_NAME); PContact james = list->data; assert_string_equal("James", p_contact_barejid(james)); @@ -43,12 +46,13 @@ void first_element_correct(void **state) roster_destroy(); } -void contains_two_elements(void **state) +void +contains_two_elements(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); roster_add("Dave", NULL, NULL, NULL, FALSE); - GSList *list = roster_get_contacts(ROSTER_ORD_NAME); + GSList* list = roster_get_contacts(ROSTER_ORD_NAME); assert_int_equal(2, g_slist_length(list)); @@ -56,12 +60,13 @@ void contains_two_elements(void **state) roster_destroy(); } -void first_and_second_elements_correct(void **state) +void +first_and_second_elements_correct(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); roster_add("Dave", NULL, NULL, NULL, FALSE); - GSList *list = roster_get_contacts(ROSTER_ORD_NAME); + GSList* list = roster_get_contacts(ROSTER_ORD_NAME); PContact first = list->data; PContact second = (g_slist_next(list))->data; @@ -73,13 +78,14 @@ void first_and_second_elements_correct(void **state) roster_destroy(); } -void contains_three_elements(void **state) +void +contains_three_elements(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); roster_add("Bob", NULL, NULL, NULL, FALSE); roster_add("Dave", NULL, NULL, NULL, FALSE); - GSList *list = roster_get_contacts(ROSTER_ORD_NAME); + GSList* list = roster_get_contacts(ROSTER_ORD_NAME); assert_int_equal(3, g_slist_length(list)); @@ -87,13 +93,14 @@ void contains_three_elements(void **state) roster_destroy(); } -void first_three_elements_correct(void **state) +void +first_three_elements_correct(void** state) { roster_create(); roster_add("Bob", NULL, NULL, NULL, FALSE); roster_add("Dave", NULL, NULL, NULL, FALSE); roster_add("James", NULL, NULL, NULL, FALSE); - GSList *list = roster_get_contacts(ROSTER_ORD_NAME); + GSList* list = roster_get_contacts(ROSTER_ORD_NAME); PContact bob = list->data; PContact dave = (g_slist_next(list))->data; PContact james = (g_slist_next(g_slist_next(list)))->data; @@ -106,14 +113,15 @@ void first_three_elements_correct(void **state) roster_destroy(); } -void add_twice_at_beginning_adds_once(void **state) +void +add_twice_at_beginning_adds_once(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); roster_add("James", NULL, NULL, NULL, FALSE); roster_add("Dave", NULL, NULL, NULL, FALSE); roster_add("Bob", NULL, NULL, NULL, FALSE); - GSList *list = roster_get_contacts(ROSTER_ORD_NAME); + GSList* list = roster_get_contacts(ROSTER_ORD_NAME); PContact first = list->data; PContact second = (g_slist_next(list))->data; PContact third = (g_slist_next(g_slist_next(list)))->data; @@ -127,14 +135,15 @@ void add_twice_at_beginning_adds_once(void **state) roster_destroy(); } -void add_twice_in_middle_adds_once(void **state) +void +add_twice_in_middle_adds_once(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); roster_add("Dave", NULL, NULL, NULL, FALSE); roster_add("James", NULL, NULL, NULL, FALSE); roster_add("Bob", NULL, NULL, NULL, FALSE); - GSList *list = roster_get_contacts(ROSTER_ORD_NAME); + GSList* list = roster_get_contacts(ROSTER_ORD_NAME); PContact first = list->data; PContact second = (g_slist_next(list))->data; PContact third = (g_slist_next(g_slist_next(list)))->data; @@ -148,14 +157,15 @@ void add_twice_in_middle_adds_once(void **state) roster_destroy(); } -void add_twice_at_end_adds_once(void **state) +void +add_twice_at_end_adds_once(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); roster_add("Dave", NULL, NULL, NULL, FALSE); roster_add("Bob", NULL, NULL, NULL, FALSE); roster_add("James", NULL, NULL, NULL, FALSE); - GSList *list = roster_get_contacts(ROSTER_ORD_NAME); + GSList* list = roster_get_contacts(ROSTER_ORD_NAME); PContact first = list->data; PContact second = (g_slist_next(list))->data; PContact third = (g_slist_next(g_slist_next(list)))->data; @@ -169,84 +179,91 @@ void add_twice_at_end_adds_once(void **state) roster_destroy(); } -void find_first_exists(void **state) +void +find_first_exists(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); roster_add("Dave", NULL, NULL, NULL, FALSE); roster_add("Bob", NULL, NULL, NULL, FALSE); - char *search = strdup("B"); + char* search = strdup("B"); - char *result = roster_contact_autocomplete(search, FALSE, NULL); + char* result = roster_contact_autocomplete(search, FALSE, NULL); assert_string_equal("Bob", result); free(result); free(search); roster_destroy(); } -void find_second_exists(void **state) +void +find_second_exists(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); roster_add("Dave", NULL, NULL, NULL, FALSE); roster_add("Bob", NULL, NULL, NULL, FALSE); - char *result = roster_contact_autocomplete("Dav", FALSE, NULL); + char* result = roster_contact_autocomplete("Dav", FALSE, NULL); assert_string_equal("Dave", result); free(result); roster_destroy(); } -void find_third_exists(void **state) +void +find_third_exists(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); roster_add("Dave", NULL, NULL, NULL, FALSE); roster_add("Bob", NULL, NULL, NULL, FALSE); - char *result = roster_contact_autocomplete("Ja", FALSE, NULL); + char* result = roster_contact_autocomplete("Ja", FALSE, NULL); assert_string_equal("James", result); free(result); roster_destroy(); } -void find_returns_null(void **state) +void +find_returns_null(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); roster_add("Dave", NULL, NULL, NULL, FALSE); roster_add("Bob", NULL, NULL, NULL, FALSE); - char *result = roster_contact_autocomplete("Mike", FALSE, NULL); + char* result = roster_contact_autocomplete("Mike", FALSE, NULL); assert_null(result); roster_destroy(); } -void find_on_empty_returns_null(void **state) +void +find_on_empty_returns_null(void** state) { roster_create(); - char *result = roster_contact_autocomplete("James", FALSE, NULL); + char* result = roster_contact_autocomplete("James", FALSE, NULL); assert_null(result); roster_destroy(); } -void find_twice_returns_second_when_two_match(void **state) +void +find_twice_returns_second_when_two_match(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); roster_add("Jamie", NULL, NULL, NULL, FALSE); roster_add("Bob", NULL, NULL, NULL, FALSE); - char *result1 = roster_contact_autocomplete("Jam", FALSE, NULL); - char *result2 = roster_contact_autocomplete(result1, FALSE, NULL); + char* result1 = roster_contact_autocomplete("Jam", FALSE, NULL); + char* result2 = roster_contact_autocomplete(result1, FALSE, NULL); assert_string_equal("Jamie", result2); free(result1); free(result2); roster_destroy(); } -void find_five_times_finds_fifth(void **state) +void +find_five_times_finds_fifth(void** state) { roster_create(); roster_add("Jama", NULL, NULL, NULL, FALSE); @@ -260,11 +277,11 @@ void find_five_times_finds_fifth(void **state) roster_add("Jamy", NULL, NULL, NULL, FALSE); roster_add("Jamz", NULL, NULL, NULL, FALSE); - char *result1 = roster_contact_autocomplete("Jam", FALSE, NULL); - char *result2 = roster_contact_autocomplete(result1, FALSE, NULL); - char *result3 = roster_contact_autocomplete(result2, FALSE, NULL); - char *result4 = roster_contact_autocomplete(result3, FALSE, NULL); - char *result5 = roster_contact_autocomplete(result4, FALSE, NULL); + char* result1 = roster_contact_autocomplete("Jam", FALSE, NULL); + char* result2 = roster_contact_autocomplete(result1, FALSE, NULL); + char* result3 = roster_contact_autocomplete(result2, FALSE, NULL); + char* result4 = roster_contact_autocomplete(result3, FALSE, NULL); + char* result5 = roster_contact_autocomplete(result4, FALSE, NULL); assert_string_equal("Jamo", result5); free(result1); free(result2); @@ -274,46 +291,49 @@ void find_five_times_finds_fifth(void **state) roster_destroy(); } -void find_twice_returns_first_when_two_match_and_reset(void **state) +void +find_twice_returns_first_when_two_match_and_reset(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); roster_add("Jamie", NULL, NULL, NULL, FALSE); roster_add("Bob", NULL, NULL, NULL, FALSE); - char *result1 = roster_contact_autocomplete("Jam", FALSE, NULL); + char* result1 = roster_contact_autocomplete("Jam", FALSE, NULL); roster_reset_search_attempts(); - char *result2 = roster_contact_autocomplete(result1, FALSE, NULL); + char* result2 = roster_contact_autocomplete(result1, FALSE, NULL); assert_string_equal("James", result2); free(result1); free(result2); roster_destroy(); } -void add_contact_with_no_group(void **state) +void +add_contact_with_no_group(void** state) { roster_create(); roster_add("person@server.org", NULL, NULL, NULL, FALSE); - GList *groups_res = roster_get_groups(); + GList* groups_res = roster_get_groups(); assert_int_equal(g_list_length(groups_res), 0); g_list_free_full(groups_res, free); roster_destroy(); } -void add_contact_with_group(void **state) +void +add_contact_with_group(void** state) { roster_create(); - GSList *groups = NULL; + GSList* groups = NULL; groups = g_slist_append(groups, strdup("friends")); roster_add("person@server.org", NULL, groups, NULL, FALSE); - GList *groups_res = roster_get_groups(); + GList* groups_res = roster_get_groups(); assert_int_equal(g_list_length(groups_res), 1); - GList *found = g_list_find_custom(groups_res, "friends", (GCompareFunc)g_strcmp0); + GList* found = g_list_find_custom(groups_res, "friends", (GCompareFunc)g_strcmp0); assert_true(found != NULL); assert_string_equal(found->data, "friends"); @@ -321,19 +341,20 @@ void add_contact_with_group(void **state) roster_destroy(); } -void add_contact_with_two_groups(void **state) +void +add_contact_with_two_groups(void** state) { roster_create(); - GSList *groups = NULL; + GSList* groups = NULL; groups = g_slist_append(groups, strdup("friends")); groups = g_slist_append(groups, strdup("work")); roster_add("person@server.org", NULL, groups, NULL, FALSE); - GList *groups_res = roster_get_groups(); + GList* groups_res = roster_get_groups(); assert_int_equal(g_list_length(groups_res), 2); - GList *found = g_list_find_custom(groups_res, "friends", (GCompareFunc)g_strcmp0); + GList* found = g_list_find_custom(groups_res, "friends", (GCompareFunc)g_strcmp0); assert_true(found != NULL); assert_string_equal(found->data, "friends"); found = g_list_find_custom(groups_res, "work", (GCompareFunc)g_strcmp0); @@ -344,20 +365,21 @@ void add_contact_with_two_groups(void **state) roster_destroy(); } -void add_contact_with_three_groups(void **state) +void +add_contact_with_three_groups(void** state) { roster_create(); - GSList *groups = NULL; + GSList* groups = NULL; groups = g_slist_append(groups, strdup("friends")); groups = g_slist_append(groups, strdup("work")); groups = g_slist_append(groups, strdup("stuff")); roster_add("person@server.org", NULL, groups, NULL, FALSE); - GList *groups_res = roster_get_groups(); + GList* groups_res = roster_get_groups(); assert_int_equal(g_list_length(groups_res), 3); - GList *found = g_list_find_custom(groups_res, "friends", (GCompareFunc)g_strcmp0); + GList* found = g_list_find_custom(groups_res, "friends", (GCompareFunc)g_strcmp0); assert_true(found != NULL); assert_string_equal(found->data, "friends"); found = g_list_find_custom(groups_res, "work", (GCompareFunc)g_strcmp0); @@ -371,17 +393,18 @@ void add_contact_with_three_groups(void **state) roster_destroy(); } -void add_contact_with_three_groups_update_adding_two(void **state) +void +add_contact_with_three_groups_update_adding_two(void** state) { roster_create(); - GSList *groups1 = NULL; + GSList* groups1 = NULL; groups1 = g_slist_append(groups1, strdup("friends")); groups1 = g_slist_append(groups1, strdup("work")); groups1 = g_slist_append(groups1, strdup("stuff")); roster_add("person@server.org", NULL, groups1, NULL, FALSE); - GSList *groups2 = NULL; + GSList* groups2 = NULL; groups2 = g_slist_append(groups2, strdup("friends")); groups2 = g_slist_append(groups2, strdup("work")); groups2 = g_slist_append(groups2, strdup("stuff")); @@ -389,10 +412,10 @@ void add_contact_with_three_groups_update_adding_two(void **state) groups2 = g_slist_append(groups2, strdup("people")); roster_update("person@server.org", NULL, groups2, NULL, FALSE); - GList *groups_res = roster_get_groups(); + GList* groups_res = roster_get_groups(); assert_int_equal(g_list_length(groups_res), 5); - GList *found = g_list_find_custom(groups_res, "friends", (GCompareFunc)g_strcmp0); + GList* found = g_list_find_custom(groups_res, "friends", (GCompareFunc)g_strcmp0); assert_true(found != NULL); assert_string_equal(found->data, "friends"); found = g_list_find_custom(groups_res, "work", (GCompareFunc)g_strcmp0); @@ -412,25 +435,26 @@ void add_contact_with_three_groups_update_adding_two(void **state) roster_destroy(); } -void add_contact_with_three_groups_update_removing_one(void **state) +void +add_contact_with_three_groups_update_removing_one(void** state) { roster_create(); - GSList *groups1 = NULL; + GSList* groups1 = NULL; groups1 = g_slist_append(groups1, strdup("friends")); groups1 = g_slist_append(groups1, strdup("work")); groups1 = g_slist_append(groups1, strdup("stuff")); roster_add("person@server.org", NULL, groups1, NULL, FALSE); - GSList *groups2 = NULL; + GSList* groups2 = NULL; groups2 = g_slist_append(groups2, strdup("friends")); groups2 = g_slist_append(groups2, strdup("stuff")); roster_update("person@server.org", NULL, groups2, NULL, FALSE); - GList *groups_res = roster_get_groups(); + GList* groups_res = roster_get_groups(); assert_int_equal(g_list_length(groups_res), 2); - GList *found = g_list_find_custom(groups_res, "friends", (GCompareFunc)g_strcmp0); + GList* found = g_list_find_custom(groups_res, "friends", (GCompareFunc)g_strcmp0); assert_true(found != NULL); assert_string_equal(found->data, "friends"); found = g_list_find_custom(groups_res, "stuff", (GCompareFunc)g_strcmp0); @@ -441,24 +465,25 @@ void add_contact_with_three_groups_update_removing_one(void **state) roster_destroy(); } -void add_contact_with_three_groups_update_removing_two(void **state) +void +add_contact_with_three_groups_update_removing_two(void** state) { roster_create(); - GSList *groups1 = NULL; + GSList* groups1 = NULL; groups1 = g_slist_append(groups1, strdup("friends")); groups1 = g_slist_append(groups1, strdup("work")); groups1 = g_slist_append(groups1, strdup("stuff")); roster_add("person@server.org", NULL, groups1, NULL, FALSE); - GSList *groups2 = NULL; + GSList* groups2 = NULL; groups2 = g_slist_append(groups2, strdup("stuff")); roster_update("person@server.org", NULL, groups2, NULL, FALSE); - GList *groups_res = roster_get_groups(); + GList* groups_res = roster_get_groups(); assert_int_equal(g_list_length(groups_res), 1); - GList *found = g_list_find_custom(groups_res, "stuff", (GCompareFunc)g_strcmp0); + GList* found = g_list_find_custom(groups_res, "stuff", (GCompareFunc)g_strcmp0); assert_true(found != NULL); assert_string_equal(found->data, "stuff"); @@ -466,11 +491,12 @@ void add_contact_with_three_groups_update_removing_two(void **state) roster_destroy(); } -void add_contact_with_three_groups_update_removing_three(void **state) +void +add_contact_with_three_groups_update_removing_three(void** state) { roster_create(); - GSList *groups1 = NULL; + GSList* groups1 = NULL; groups1 = g_slist_append(groups1, strdup("friends")); groups1 = g_slist_append(groups1, strdup("work")); groups1 = g_slist_append(groups1, strdup("stuff")); @@ -478,32 +504,33 @@ void add_contact_with_three_groups_update_removing_three(void **state) roster_update("person@server.org", NULL, NULL, NULL, FALSE); - GList *groups_res = roster_get_groups(); + GList* groups_res = roster_get_groups(); assert_int_equal(g_list_length(groups_res), 0); g_list_free_full(groups_res, free); roster_destroy(); } -void add_contact_with_three_groups_update_two_new(void **state) +void +add_contact_with_three_groups_update_two_new(void** state) { roster_create(); - GSList *groups1 = NULL; + GSList* groups1 = NULL; groups1 = g_slist_append(groups1, strdup("friends")); groups1 = g_slist_append(groups1, strdup("work")); groups1 = g_slist_append(groups1, strdup("stuff")); roster_add("person@server.org", NULL, groups1, NULL, FALSE); - GSList *groups2 = NULL; + GSList* groups2 = NULL; groups2 = g_slist_append(groups2, strdup("newfriends")); groups2 = g_slist_append(groups2, strdup("somepeople")); roster_update("person@server.org", NULL, groups2, NULL, FALSE); - GList *groups_res = roster_get_groups(); + GList* groups_res = roster_get_groups(); assert_int_equal(g_list_length(groups_res), 2); - GList *found = g_list_find_custom(groups_res, "newfriends", (GCompareFunc)g_strcmp0); + GList* found = g_list_find_custom(groups_res, "newfriends", (GCompareFunc)g_strcmp0); assert_true(found != NULL); found = g_list_find_custom(groups_res, "somepeople", (GCompareFunc)g_strcmp0); assert_true(found != NULL); @@ -512,11 +539,12 @@ void add_contact_with_three_groups_update_two_new(void **state) roster_destroy(); } -void add_remove_contact_groups(void **state) +void +add_remove_contact_groups(void** state) { roster_create(); - GSList *groups1 = NULL; + GSList* groups1 = NULL; groups1 = g_slist_append(groups1, strdup("friends")); groups1 = g_slist_append(groups1, strdup("work")); groups1 = g_slist_append(groups1, strdup("stuff")); @@ -524,32 +552,33 @@ void add_remove_contact_groups(void **state) roster_remove("person@server.org", "person@server.org"); - GList *groups_res = roster_get_groups(); + GList* groups_res = roster_get_groups(); assert_int_equal(g_list_length(groups_res), 0); g_list_free_full(groups_res, free); roster_destroy(); } -void add_contacts_with_different_groups(void **state) +void +add_contacts_with_different_groups(void** state) { roster_create(); - GSList *groups1 = NULL; + GSList* groups1 = NULL; groups1 = g_slist_append(groups1, strdup("friends")); groups1 = g_slist_append(groups1, strdup("work")); groups1 = g_slist_append(groups1, strdup("stuff")); roster_add("person@server.org", NULL, groups1, NULL, FALSE); - GSList *groups2 = NULL; + GSList* groups2 = NULL; groups2 = g_slist_append(groups2, strdup("newfriends")); groups2 = g_slist_append(groups2, strdup("somepeople")); roster_add("bob@server.org", NULL, groups2, NULL, FALSE); - GList *groups_res = roster_get_groups(); + GList* groups_res = roster_get_groups(); assert_int_equal(g_list_length(groups_res), 5); - GList *found = g_list_find_custom(groups_res, "friends", (GCompareFunc)g_strcmp0); + GList* found = g_list_find_custom(groups_res, "friends", (GCompareFunc)g_strcmp0); assert_true(found != NULL); found = g_list_find_custom(groups_res, "work", (GCompareFunc)g_strcmp0); assert_true(found != NULL); @@ -564,26 +593,27 @@ void add_contacts_with_different_groups(void **state) roster_destroy(); } -void add_contacts_with_same_groups(void **state) +void +add_contacts_with_same_groups(void** state) { roster_create(); - GSList *groups1 = NULL; + GSList* groups1 = NULL; groups1 = g_slist_append(groups1, strdup("friends")); groups1 = g_slist_append(groups1, strdup("work")); groups1 = g_slist_append(groups1, strdup("stuff")); roster_add("person@server.org", NULL, groups1, NULL, FALSE); - GSList *groups2 = NULL; + GSList* groups2 = NULL; groups2 = g_slist_append(groups2, strdup("friends")); groups2 = g_slist_append(groups2, strdup("work")); groups2 = g_slist_append(groups2, strdup("stuff")); roster_add("bob@server.org", NULL, groups2, NULL, FALSE); - GList *groups_res = roster_get_groups(); + GList* groups_res = roster_get_groups(); assert_int_equal(g_list_length(groups_res), 3); - GList *found = g_list_find_custom(groups_res, "friends", (GCompareFunc)g_strcmp0); + GList* found = g_list_find_custom(groups_res, "friends", (GCompareFunc)g_strcmp0); assert_true(found != NULL); found = g_list_find_custom(groups_res, "work", (GCompareFunc)g_strcmp0); assert_true(found != NULL); @@ -594,26 +624,27 @@ void add_contacts_with_same_groups(void **state) roster_destroy(); } -void add_contacts_with_overlapping_groups(void **state) +void +add_contacts_with_overlapping_groups(void** state) { roster_create(); - GSList *groups1 = NULL; + GSList* groups1 = NULL; groups1 = g_slist_append(groups1, strdup("friends")); groups1 = g_slist_append(groups1, strdup("work")); groups1 = g_slist_append(groups1, strdup("stuff")); roster_add("person@server.org", NULL, groups1, NULL, FALSE); - GSList *groups2 = NULL; + GSList* groups2 = NULL; groups2 = g_slist_append(groups2, strdup("friends")); groups2 = g_slist_append(groups2, strdup("work")); groups2 = g_slist_append(groups2, strdup("different")); roster_add("bob@server.org", NULL, groups2, NULL, FALSE); - GList *groups_res = roster_get_groups(); + GList* groups_res = roster_get_groups(); assert_int_equal(g_list_length(groups_res), 4); - GList *found = g_list_find_custom(groups_res, "friends", (GCompareFunc)g_strcmp0); + GList* found = g_list_find_custom(groups_res, "friends", (GCompareFunc)g_strcmp0); assert_true(found != NULL); found = g_list_find_custom(groups_res, "work", (GCompareFunc)g_strcmp0); assert_true(found != NULL); @@ -626,17 +657,18 @@ void add_contacts_with_overlapping_groups(void **state) roster_destroy(); } -void remove_contact_with_remaining_in_group(void **state) +void +remove_contact_with_remaining_in_group(void** state) { roster_create(); - GSList *groups1 = NULL; + GSList* groups1 = NULL; groups1 = g_slist_append(groups1, strdup("friends")); groups1 = g_slist_append(groups1, strdup("work")); groups1 = g_slist_append(groups1, strdup("stuff")); roster_add("person@server.org", NULL, groups1, NULL, FALSE); - GSList *groups2 = NULL; + GSList* groups2 = NULL; groups2 = g_slist_append(groups2, strdup("friends")); groups2 = g_slist_append(groups2, strdup("work")); groups2 = g_slist_append(groups2, strdup("different")); @@ -644,10 +676,10 @@ void remove_contact_with_remaining_in_group(void **state) roster_remove("bob@server.org", "bob@server.org"); - GList *groups_res = roster_get_groups(); + GList* groups_res = roster_get_groups(); assert_int_equal(g_list_length(groups_res), 3); - GList *found = g_list_find_custom(groups_res, "friends", (GCompareFunc)g_strcmp0); + GList* found = g_list_find_custom(groups_res, "friends", (GCompareFunc)g_strcmp0); assert_true(found != NULL); found = g_list_find_custom(groups_res, "work", (GCompareFunc)g_strcmp0); assert_true(found != NULL); diff --git a/tests/unittests/test_roster_list.h b/tests/unittests/test_roster_list.h index 464ecd55..b9874fec 100644 --- a/tests/unittests/test_roster_list.h +++ b/tests/unittests/test_roster_list.h @@ -1,32 +1,32 @@ -void empty_list_when_none_added(void **state); -void contains_one_element(void **state); -void first_element_correct(void **state); -void contains_two_elements(void **state); -void first_and_second_elements_correct(void **state); -void contains_three_elements(void **state); -void first_three_elements_correct(void **state); -void add_twice_at_beginning_adds_once(void **state); -void add_twice_in_middle_adds_once(void **state); -void add_twice_at_end_adds_once(void **state); -void find_first_exists(void **state); -void find_second_exists(void **state); -void find_third_exists(void **state); -void find_returns_null(void **state); -void find_on_empty_returns_null(void **state); -void find_twice_returns_second_when_two_match(void **state); -void find_five_times_finds_fifth(void **state); -void find_twice_returns_first_when_two_match_and_reset(void **state); -void add_contact_with_no_group(void **state); -void add_contact_with_group(void **state); -void add_contact_with_two_groups(void **state); -void add_contact_with_three_groups(void **state); -void add_contact_with_three_groups_update_adding_two(void **state); -void add_contact_with_three_groups_update_removing_one(void **state); -void add_contact_with_three_groups_update_removing_two(void **state); -void add_contact_with_three_groups_update_removing_three(void **state); -void add_contact_with_three_groups_update_two_new(void **state); -void add_remove_contact_groups(void **state); -void add_contacts_with_different_groups(void **state); -void add_contacts_with_same_groups(void **state); -void add_contacts_with_overlapping_groups(void **state); -void remove_contact_with_remaining_in_group(void **state); +void empty_list_when_none_added(void** state); +void contains_one_element(void** state); +void first_element_correct(void** state); +void contains_two_elements(void** state); +void first_and_second_elements_correct(void** state); +void contains_three_elements(void** state); +void first_three_elements_correct(void** state); +void add_twice_at_beginning_adds_once(void** state); +void add_twice_in_middle_adds_once(void** state); +void add_twice_at_end_adds_once(void** state); +void find_first_exists(void** state); +void find_second_exists(void** state); +void find_third_exists(void** state); +void find_returns_null(void** state); +void find_on_empty_returns_null(void** state); +void find_twice_returns_second_when_two_match(void** state); +void find_five_times_finds_fifth(void** state); +void find_twice_returns_first_when_two_match_and_reset(void** state); +void add_contact_with_no_group(void** state); +void add_contact_with_group(void** state); +void add_contact_with_two_groups(void** state); +void add_contact_with_three_groups(void** state); +void add_contact_with_three_groups_update_adding_two(void** state); +void add_contact_with_three_groups_update_removing_one(void** state); +void add_contact_with_three_groups_update_removing_two(void** state); +void add_contact_with_three_groups_update_removing_three(void** state); +void add_contact_with_three_groups_update_two_new(void** state); +void add_remove_contact_groups(void** state); +void add_contacts_with_different_groups(void** state); +void add_contacts_with_same_groups(void** state); +void add_contacts_with_overlapping_groups(void** state); +void remove_contact_with_remaining_in_group(void** state); diff --git a/tests/unittests/test_server_events.c b/tests/unittests/test_server_events.c index 54688dec..4ecedace 100644 --- a/tests/unittests/test_server_events.c +++ b/tests/unittests/test_server_events.c @@ -17,15 +17,16 @@ #include "plugins/plugins.h" #include "ui/window_list.h" -void console_shows_online_presence_when_set_online(void **state) +void +console_shows_online_presence_when_set_online(void** state) { prefs_set_string(PREF_STATUSES_CONSOLE, "online"); plugins_init(); roster_create(); roster_process_pending_presence(); - char *barejid = "test1@server"; + char* barejid = "test1@server"; roster_add(barejid, "bob", NULL, "both", FALSE); - Resource *resource = resource_new("resource", RESOURCE_ONLINE, NULL, 10); + Resource* resource = resource_new("resource", RESOURCE_ONLINE, NULL, 10); expect_memory(ui_contact_online, barejid, barejid, sizeof(barejid)); expect_memory(ui_contact_online, resource, resource, sizeof(resource)); @@ -37,15 +38,16 @@ void console_shows_online_presence_when_set_online(void **state) plugins_shutdown(); } -void console_shows_online_presence_when_set_all(void **state) +void +console_shows_online_presence_when_set_all(void** state) { prefs_set_string(PREF_STATUSES_CONSOLE, "all"); plugins_init(); roster_create(); roster_process_pending_presence(); - char *barejid = "test1@server"; + char* barejid = "test1@server"; roster_add(barejid, "bob", NULL, "both", FALSE); - Resource *resource = resource_new("resource", RESOURCE_ONLINE, NULL, 10); + Resource* resource = resource_new("resource", RESOURCE_ONLINE, NULL, 10); expect_memory(ui_contact_online, barejid, barejid, sizeof(barejid)); expect_memory(ui_contact_online, resource, resource, sizeof(resource)); @@ -57,15 +59,16 @@ void console_shows_online_presence_when_set_all(void **state) plugins_shutdown(); } -void console_shows_dnd_presence_when_set_all(void **state) +void +console_shows_dnd_presence_when_set_all(void** state) { prefs_set_string(PREF_STATUSES_CONSOLE, "all"); plugins_init(); roster_create(); roster_process_pending_presence(); - char *barejid = "test1@server"; + char* barejid = "test1@server"; roster_add(barejid, "bob", NULL, "both", FALSE); - Resource *resource = resource_new("resource", RESOURCE_ONLINE, NULL, 10); + Resource* resource = resource_new("resource", RESOURCE_ONLINE, NULL, 10); expect_memory(ui_contact_online, barejid, barejid, sizeof(barejid)); expect_memory(ui_contact_online, resource, resource, sizeof(resource)); @@ -77,23 +80,24 @@ void console_shows_dnd_presence_when_set_all(void **state) plugins_shutdown(); } -void handle_offline_removes_chat_session(void **state) +void +handle_offline_removes_chat_session(void** state) { plugins_init(); roster_create(); roster_process_pending_presence(); chat_sessions_init(); - char *barejid = "friend@server.chat.com"; - char *resource = "home"; + char* barejid = "friend@server.chat.com"; + char* resource = "home"; roster_add(barejid, "bob", NULL, "both", FALSE); - Resource *resourcep = resource_new(resource, RESOURCE_ONLINE, NULL, 10); + Resource* resourcep = resource_new(resource, RESOURCE_ONLINE, NULL, 10); roster_update_presence(barejid, resourcep, NULL); chat_session_recipient_active(barejid, resource, FALSE); - ProfConsoleWin *console = malloc(sizeof(ProfConsoleWin)); + ProfConsoleWin* console = malloc(sizeof(ProfConsoleWin)); will_return(win_create_console, &console->window); wins_init(); sv_ev_contact_offline(barejid, resource, NULL); - ChatSession *session = chat_session_get(barejid); + ChatSession* session = chat_session_get(barejid); assert_null(session); @@ -102,7 +106,8 @@ void handle_offline_removes_chat_session(void **state) plugins_shutdown(); } -void lost_connection_clears_chat_sessions(void **state) +void +lost_connection_clears_chat_sessions(void** state) { roster_create(); roster_process_pending_presence(); @@ -113,8 +118,8 @@ void lost_connection_clears_chat_sessions(void **state) sv_ev_lost_connection(); - ChatSession *session1 = chat_session_get("bob@server.org"); - ChatSession *session2 = chat_session_get("steve@server.org"); + ChatSession* session1 = chat_session_get("bob@server.org"); + ChatSession* session2 = chat_session_get("steve@server.org"); assert_null(session1); assert_null(session2); } diff --git a/tests/unittests/test_server_events.h b/tests/unittests/test_server_events.h index 81a436f4..1cac6799 100644 --- a/tests/unittests/test_server_events.h +++ b/tests/unittests/test_server_events.h @@ -1,14 +1,14 @@ -void console_doesnt_show_online_presence_when_set_none(void **state); -void console_shows_online_presence_when_set_online(void **state); -void console_shows_online_presence_when_set_all(void **state); -void console_doesnt_show_dnd_presence_when_set_none(void **state); -void console_doesnt_show_dnd_presence_when_set_online(void **state); -void console_shows_dnd_presence_when_set_all(void **state); -void handle_message_error_when_no_recipient(void **state); -void handle_message_error_when_recipient_cancel(void **state); -void handle_message_error_when_recipient_cancel_disables_chat_session(void **state); -void handle_message_error_when_recipient_and_no_type(void **state); -void handle_presence_error_when_no_recipient(void **state); -void handle_presence_error_when_from_recipient(void **state); -void handle_offline_removes_chat_session(void **state); -void lost_connection_clears_chat_sessions(void **state); +void console_doesnt_show_online_presence_when_set_none(void** state); +void console_shows_online_presence_when_set_online(void** state); +void console_shows_online_presence_when_set_all(void** state); +void console_doesnt_show_dnd_presence_when_set_none(void** state); +void console_doesnt_show_dnd_presence_when_set_online(void** state); +void console_shows_dnd_presence_when_set_all(void** state); +void handle_message_error_when_no_recipient(void** state); +void handle_message_error_when_recipient_cancel(void** state); +void handle_message_error_when_recipient_cancel_disables_chat_session(void** state); +void handle_message_error_when_recipient_and_no_type(void** state); +void handle_presence_error_when_no_recipient(void** state); +void handle_presence_error_when_from_recipient(void** state); +void handle_offline_removes_chat_session(void** state); +void lost_connection_clears_chat_sessions(void** state); diff --git a/tests/unittests/tools/stub_http_upload.c b/tests/unittests/tools/stub_http_upload.c index 3cfb1c5d..25a81708 100644 --- a/tests/unittests/tools/stub_http_upload.c +++ b/tests/unittests/tools/stub_http_upload.c @@ -7,26 +7,39 @@ // forward -> ui/win_types.h typedef struct prof_win_t ProfWin; -typedef struct http_upload_t { - char *filename; +typedef struct http_upload_t +{ + char* filename; off_t filesize; curl_off_t bytes_sent; - char *mime_type; - char *get_url; - char *put_url; - ProfWin *window; + char* mime_type; + char* get_url; + char* put_url; + ProfWin* window; pthread_t worker; int cancel; } HTTPUpload; //GSList *upload_processes; -void* http_file_put(void *userdata) { return NULL; } - -char* file_mime_type(const char* const file_name) { return NULL; } -off_t file_size(const char* const file_name) { return 0; } - -void http_upload_cancel_processes() {}; -void http_upload_add_upload() {}; +void* +http_file_put(void* userdata) +{ + return NULL; +} + +char* +file_mime_type(const char* const file_name) +{ + return NULL; +} +off_t +file_size(const char* const file_name) +{ + return 0; +} + +void http_upload_cancel_processes(){}; +void http_upload_add_upload(){}; #endif diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index e14daa01..8b30f718 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -19,7 +19,7 @@ static char output[256]; void -expect_cons_show(char *expected) +expect_cons_show(char* expected) { expect_string(cons_show, output, expected); } @@ -31,7 +31,7 @@ expect_any_cons_show(void) } void -expect_cons_show_error(char *expected) +expect_cons_show_error(char* expected) { expect_string(cons_show_error, output, expected); } @@ -43,68 +43,142 @@ expect_any_cons_show_error(void) } void -expect_win_println(char *message) +expect_win_println(char* message) { expect_string(win_println, output, message); } // stubs -void ui_init(void) {} -void ui_load_colours(void) {} -void ui_update(void) {} -void ui_close(void) {} -void ui_redraw(void) {} -void ui_resize(void) {} +void +ui_init(void) +{ +} +void +ui_load_colours(void) +{ +} +void +ui_update(void) +{ +} +void +ui_close(void) +{ +} +void +ui_redraw(void) +{ +} +void +ui_resize(void) +{ +} -void ui_focus_win(ProfWin *win) {} +void +ui_focus_win(ProfWin* win) +{ +} #ifdef HAVE_LIBOTR -void chatwin_otr_secured(ProfChatWin *chatwin, gboolean trusted) {} -void chatwin_otr_unsecured(ProfChatWin *chatwin) {} -void chatwin_otr_trust(ProfChatWin *chatwin) {} -void chatwin_otr_untrust(ProfChatWin *chatwin) {} -void chatwin_otr_smp_event(ProfChatWin *chatwin, prof_otr_smp_event_t event, void *data) {} +void +chatwin_otr_secured(ProfChatWin* chatwin, gboolean trusted) +{ +} +void +chatwin_otr_unsecured(ProfChatWin* chatwin) +{ +} +void +chatwin_otr_trust(ProfChatWin* chatwin) +{ +} +void +chatwin_otr_untrust(ProfChatWin* chatwin) +{ +} +void +chatwin_otr_smp_event(ProfChatWin* chatwin, prof_otr_smp_event_t event, void* data) +{ +} #endif -void chatwin_set_enctext(ProfChatWin *chatwin, const char *const enctext) {} -void chatwin_unset_enctext(ProfChatWin *chatwin) {} -void chatwin_set_incoming_char(ProfChatWin *chatwin, const char *const ch) {} -void chatwin_unset_incoming_char(ProfChatWin *chatwin) {} -void chatwin_set_outgoing_char(ProfChatWin *chatwin, const char *const ch) {} -void chatwin_unset_outgoing_char(ProfChatWin *chatwin) {} +void +chatwin_set_enctext(ProfChatWin* chatwin, const char* const enctext) +{ +} +void +chatwin_unset_enctext(ProfChatWin* chatwin) +{ +} +void +chatwin_set_incoming_char(ProfChatWin* chatwin, const char* const ch) +{ +} +void +chatwin_unset_incoming_char(ProfChatWin* chatwin) +{ +} +void +chatwin_set_outgoing_char(ProfChatWin* chatwin, const char* const ch) +{ +} +void +chatwin_unset_outgoing_char(ProfChatWin* chatwin) +{ +} -void ui_sigwinch_handler(int sig) {} +void +ui_sigwinch_handler(int sig) +{ +} -unsigned long ui_get_idle_time(void) +unsigned long +ui_get_idle_time(void) { return 0; } -void ui_reset_idle_time(void) {} +void +ui_reset_idle_time(void) +{ +} -ProfChatWin* chatwin_new(const char * const barejid) +ProfChatWin* +chatwin_new(const char* const barejid) { return NULL; } -void ui_print_system_msg_from_recipient(const char * const barejid, const char *message) {} +void +ui_print_system_msg_from_recipient(const char* const barejid, const char* message) +{ +} -void ui_close_connected_win(int index) {} -int ui_close_all_wins(void) +void +ui_close_connected_win(int index) +{ +} +int +ui_close_all_wins(void) { return 0; } -int ui_close_read_wins(void) +int +ui_close_read_wins(void) { return 0; } // current window actions -void ui_clear_current(void) {} +void +ui_clear_current(void) +{ +} -void ui_current_print_line(const char * const msg, ...) +void +ui_current_print_line(const char* const msg, ...) { va_list args; va_start(args, msg); @@ -113,7 +187,8 @@ void ui_current_print_line(const char * const msg, ...) va_end(args); } -void ui_current_print_formatted_line(const char show_char, int attrs, const char * const msg, ...) +void +ui_current_print_formatted_line(const char show_char, int attrs, const char* const msg, ...) { check_expected(show_char); check_expected(attrs); @@ -124,195 +199,506 @@ void ui_current_print_formatted_line(const char show_char, int attrs, const char va_end(args); } -void ui_close_win(int index) {} +void +ui_close_win(int index) +{ +} -int ui_win_unread(int index) +int +ui_win_unread(int index) { return 0; } -char * ui_ask_password(void) +char* +ui_ask_password(void) { - return mock_ptr_type(char *); + return mock_ptr_type(char*); } -char *ui_get_line(void) +char* +ui_get_line(void) { return NULL; } -void xmlwin_show(ProfXMLWin *xmlwin, const char * const msg) {} +void +xmlwin_show(ProfXMLWin* xmlwin, const char* const msg) +{ +} // ui events -void ui_contact_online(char *barejid, Resource *resource, GDateTime *last_activity) +void +ui_contact_online(char* barejid, Resource* resource, GDateTime* last_activity) { check_expected(barejid); check_expected(resource); check_expected(last_activity); } -void ui_contact_typing(const char * const barejid, const char * const resource) {} -void chatwin_incoming_msg(ProfChatWin *chatwin, ProfMessage *message, gboolean win_created) {} -void chatwin_receipt_received(ProfChatWin *chatwin, const char * const id) {} - -void privwin_incoming_msg(ProfPrivateWin *privatewin, ProfMessage *message) {} - -void ui_disconnected(void) {} -void chatwin_recipient_gone(ProfChatWin *chatwin) {} - -void chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id, prof_enc_t enc_mode, gboolean request_receipt, const char *const replace_id) {} -void chatwin_outgoing_carbon(ProfChatWin *chatwin, ProfMessage *message) {} -void privwin_outgoing_msg(ProfPrivateWin *privwin, const char * const message) {} - -void privwin_occupant_offline(ProfPrivateWin *privwin) {} -void privwin_occupant_kicked(ProfPrivateWin *privwin, const char *const actor, const char *const reason) {} -void privwin_occupant_banned(ProfPrivateWin *privwin, const char *const actor, const char *const reason) {} -void privwin_occupant_online(ProfPrivateWin *privwin) {} -void privwin_message_occupant_offline(ProfPrivateWin *privwin) {} - -void privwin_message_left_room(ProfPrivateWin *privwin) {} - -void ui_room_join(const char * const roomjid, gboolean focus) {} -void ui_switch_to_room(const char * const roomjid) {} - -void mucwin_role_change(ProfMucWin *mucwin, const char * const role, const char * const actor, - const char * const reason) {} -void mucwin_affiliation_change(ProfMucWin *mucwin, const char * const affiliation, const char * const actor, - const char * const reason) {} -void mucwin_role_and_affiliation_change(ProfMucWin *mucwin, const char * const role, - const char * const affiliation, const char * const actor, const char * const reason) {} -void mucwin_occupant_role_change(ProfMucWin *mucwin, const char * const nick, const char * const role, - const char * const actor, const char * const reason) {} -void mucwin_occupant_affiliation_change(ProfMucWin *mucwin, const char * const nick, const char * const affiliation, - const char * const actor, const char * const reason) {} -void mucwin_occupant_role_and_affiliation_change(ProfMucWin *mucwin, const char * const nick, const char * const role, - const char * const affiliation, const char * const actor, const char * const reason) {} -void mucwin_roster(ProfMucWin *mucwin, GList *occupants, const char * const presence) {} -void mucwin_history(ProfMucWin *mucwin, const ProfMessage *const message) {} -void mucwin_incoming_msg(ProfMucWin *mucwin, const ProfMessage *const message, GSList *mentions, GList *triggers, gboolean filter_reflection) {} -void mucwin_outgoing_msg(ProfMucWin *mucwin, const char *const message, const char *const id, prof_enc_t enc_mode, const char *const replace_id) {} -void mucwin_subject(ProfMucWin *mucwin, const char * const nick, const char * const subject) {} -void mucwin_requires_config(ProfMucWin *mucwin) {} -void ui_room_destroy(const char * const roomjid) {} -void mucwin_info(ProfMucWin *mucwin) {} -void mucwin_show_role_list(ProfMucWin *mucwin, muc_role_t role) {} -void mucwin_show_affiliation_list(ProfMucWin *mucwin, muc_affiliation_t affiliation) {} -void mucwin_room_info_error(ProfMucWin *mucwin, const char * const error) {} -void mucwin_room_disco_info(ProfMucWin *mucwin, GSList *identities, GSList *features) {} -void ui_room_destroyed(const char * const roomjid, const char * const reason, const char * const new_jid, - const char * const password) {} -void ui_room_kicked(const char * const roomjid, const char * const actor, const char * const reason) {} -void mucwin_occupant_kicked(ProfMucWin *mucwin, const char * const nick, const char * const actor, - const char * const reason) {} -void ui_room_banned(const char * const roomjid, const char * const actor, const char * const reason) {} -void mucwin_occupant_banned(ProfMucWin *mucwin, const char * const nick, const char * const actor, - const char * const reason) {} -void ui_leave_room(const char * const roomjid) {} -void mucwin_broadcast(ProfMucWin *mucwin, const char * const message) {} -void mucwin_occupant_offline(ProfMucWin *mucwin, const char * const nick) {} -void mucwin_occupant_online(ProfMucWin *mucwin, const char * const nick, const char * const roles, - const char * const affiliation, const char * const show, const char * const status) {} -void mucwin_occupant_nick_change(ProfMucWin *mucwin, const char * const old_nick, const char * const nick) {} -void mucwin_nick_change(ProfMucWin *mucwin, const char * const nick) {} -void mucwin_occupant_presence(ProfMucWin *mucwin, const char * const nick, const char * const show, - const char * const status) {} -void mucwin_update_occupants(ProfMucWin *mucwin) {} -void mucwin_show_occupants(ProfMucWin *mucwin) {} -void mucwin_hide_occupants(ProfMucWin *mucwin) {} -void mucwin_set_enctext(ProfMucWin *mucwin, const char *const enctext) {} -void mucwin_unset_enctext(ProfMucWin *mucwin) {} -void mucwin_set_message_char(ProfMucWin *mucwin, const char *const ch) {} -void mucwin_unset_message_char(ProfMucWin *mucwin) {} - -void ui_show_roster(void) {} -void ui_hide_roster(void) {} -void ui_roster_add(const char * const barejid, const char * const name) {} -void ui_roster_remove(const char * const barejid) {} -void ui_contact_already_in_group(const char * const contact, const char * const group) {} -void ui_contact_not_in_group(const char * const contact, const char * const group) {} -void ui_group_added(const char * const contact, const char * const group) {} -void ui_group_removed(const char * const contact, const char * const group) {} -void chatwin_contact_online(ProfChatWin *chatwin, Resource *resource, GDateTime *last_activity) {} -void chatwin_contact_offline(ProfChatWin *chatwin, char *resource, char *status) {} - -void ui_contact_offline(char *barejid, char *resource, char *status) {} - -void ui_handle_recipient_error(const char * const recipient, const char * const err_msg) +void +ui_contact_typing(const char* const barejid, const char* const resource) +{ +} +void +chatwin_incoming_msg(ProfChatWin* chatwin, ProfMessage* message, gboolean win_created) +{ +} +void +chatwin_receipt_received(ProfChatWin* chatwin, const char* const id) +{ +} + +void +privwin_incoming_msg(ProfPrivateWin* privatewin, ProfMessage* message) +{ +} + +void +ui_disconnected(void) +{ +} +void +chatwin_recipient_gone(ProfChatWin* chatwin) +{ +} + +void +chatwin_outgoing_msg(ProfChatWin* chatwin, const char* const message, char* id, prof_enc_t enc_mode, gboolean request_receipt, const char* const replace_id) +{ +} +void +chatwin_outgoing_carbon(ProfChatWin* chatwin, ProfMessage* message) +{ +} +void +privwin_outgoing_msg(ProfPrivateWin* privwin, const char* const message) +{ +} + +void +privwin_occupant_offline(ProfPrivateWin* privwin) +{ +} +void +privwin_occupant_kicked(ProfPrivateWin* privwin, const char* const actor, const char* const reason) +{ +} +void +privwin_occupant_banned(ProfPrivateWin* privwin, const char* const actor, const char* const reason) +{ +} +void +privwin_occupant_online(ProfPrivateWin* privwin) +{ +} +void +privwin_message_occupant_offline(ProfPrivateWin* privwin) +{ +} + +void +privwin_message_left_room(ProfPrivateWin* privwin) +{ +} + +void +ui_room_join(const char* const roomjid, gboolean focus) +{ +} +void +ui_switch_to_room(const char* const roomjid) +{ +} + +void +mucwin_role_change(ProfMucWin* mucwin, const char* const role, const char* const actor, + const char* const reason) +{ +} +void +mucwin_affiliation_change(ProfMucWin* mucwin, const char* const affiliation, const char* const actor, + const char* const reason) +{ +} +void +mucwin_role_and_affiliation_change(ProfMucWin* mucwin, const char* const role, + const char* const affiliation, const char* const actor, const char* const reason) +{ +} +void +mucwin_occupant_role_change(ProfMucWin* mucwin, const char* const nick, const char* const role, + const char* const actor, const char* const reason) +{ +} +void +mucwin_occupant_affiliation_change(ProfMucWin* mucwin, const char* const nick, const char* const affiliation, + const char* const actor, const char* const reason) +{ +} +void +mucwin_occupant_role_and_affiliation_change(ProfMucWin* mucwin, const char* const nick, const char* const role, + const char* const affiliation, const char* const actor, const char* const reason) +{ +} +void +mucwin_roster(ProfMucWin* mucwin, GList* occupants, const char* const presence) +{ +} +void +mucwin_history(ProfMucWin* mucwin, const ProfMessage* const message) +{ +} +void +mucwin_incoming_msg(ProfMucWin* mucwin, const ProfMessage* const message, GSList* mentions, GList* triggers, gboolean filter_reflection) +{ +} +void +mucwin_outgoing_msg(ProfMucWin* mucwin, const char* const message, const char* const id, prof_enc_t enc_mode, const char* const replace_id) +{ +} +void +mucwin_subject(ProfMucWin* mucwin, const char* const nick, const char* const subject) +{ +} +void +mucwin_requires_config(ProfMucWin* mucwin) +{ +} +void +ui_room_destroy(const char* const roomjid) +{ +} +void +mucwin_info(ProfMucWin* mucwin) +{ +} +void +mucwin_show_role_list(ProfMucWin* mucwin, muc_role_t role) +{ +} +void +mucwin_show_affiliation_list(ProfMucWin* mucwin, muc_affiliation_t affiliation) +{ +} +void +mucwin_room_info_error(ProfMucWin* mucwin, const char* const error) +{ +} +void +mucwin_room_disco_info(ProfMucWin* mucwin, GSList* identities, GSList* features) +{ +} +void +ui_room_destroyed(const char* const roomjid, const char* const reason, const char* const new_jid, + const char* const password) +{ +} +void +ui_room_kicked(const char* const roomjid, const char* const actor, const char* const reason) +{ +} +void +mucwin_occupant_kicked(ProfMucWin* mucwin, const char* const nick, const char* const actor, + const char* const reason) +{ +} +void +ui_room_banned(const char* const roomjid, const char* const actor, const char* const reason) +{ +} +void +mucwin_occupant_banned(ProfMucWin* mucwin, const char* const nick, const char* const actor, + const char* const reason) +{ +} +void +ui_leave_room(const char* const roomjid) +{ +} +void +mucwin_broadcast(ProfMucWin* mucwin, const char* const message) +{ +} +void +mucwin_occupant_offline(ProfMucWin* mucwin, const char* const nick) +{ +} +void +mucwin_occupant_online(ProfMucWin* mucwin, const char* const nick, const char* const roles, + const char* const affiliation, const char* const show, const char* const status) +{ +} +void +mucwin_occupant_nick_change(ProfMucWin* mucwin, const char* const old_nick, const char* const nick) +{ +} +void +mucwin_nick_change(ProfMucWin* mucwin, const char* const nick) +{ +} +void +mucwin_occupant_presence(ProfMucWin* mucwin, const char* const nick, const char* const show, + const char* const status) +{ +} +void +mucwin_update_occupants(ProfMucWin* mucwin) +{ +} +void +mucwin_show_occupants(ProfMucWin* mucwin) +{ +} +void +mucwin_hide_occupants(ProfMucWin* mucwin) +{ +} +void +mucwin_set_enctext(ProfMucWin* mucwin, const char* const enctext) +{ +} +void +mucwin_unset_enctext(ProfMucWin* mucwin) +{ +} +void +mucwin_set_message_char(ProfMucWin* mucwin, const char* const ch) +{ +} +void +mucwin_unset_message_char(ProfMucWin* mucwin) +{ +} + +void +ui_show_roster(void) +{ +} +void +ui_hide_roster(void) +{ +} +void +ui_roster_add(const char* const barejid, const char* const name) +{ +} +void +ui_roster_remove(const char* const barejid) +{ +} +void +ui_contact_already_in_group(const char* const contact, const char* const group) +{ +} +void +ui_contact_not_in_group(const char* const contact, const char* const group) +{ +} +void +ui_group_added(const char* const contact, const char* const group) +{ +} +void +ui_group_removed(const char* const contact, const char* const group) +{ +} +void +chatwin_contact_online(ProfChatWin* chatwin, Resource* resource, GDateTime* last_activity) +{ +} +void +chatwin_contact_offline(ProfChatWin* chatwin, char* resource, char* status) +{ +} + +void +ui_contact_offline(char* barejid, char* resource, char* status) +{ +} + +void +ui_handle_recipient_error(const char* const recipient, const char* const err_msg) { check_expected(recipient); check_expected(err_msg); } -void ui_handle_error(const char * const err_msg) +void +ui_handle_error(const char* const err_msg) { check_expected(err_msg); } -void ui_clear_win_title(void) {} -void ui_goodbye_title(void) {} -void confwin_handle_configuration(ProfConfWin *confwin, DataForm *form) {} -void ui_handle_room_configuration_form_error(const char * const roomjid, const char * const message) {} -void ui_handle_room_config_submit_result(const char * const roomjid) {} -void ui_handle_room_config_submit_result_error(const char * const roomjid, const char * const message) {} -void mucwin_affiliation_list_error(ProfMucWin *mucwin, const char * const affiliation, const char * const error) {} -void mucwin_handle_affiliation_list(ProfMucWin *mucwin, const char * const affiliation, GSList *jids) {} -void mucwin_affiliation_set_error(ProfMucWin *mucwin, const char * const jid, const char * const affiliation, - const char * const error) {} -void mucwin_role_set_error(ProfMucWin *mucwin, const char * const nick, const char * const role, - const char * const error) {} -void mucwin_role_list_error(ProfMucWin *mucwin, const char * const role, const char * const error) {} -void mucwin_handle_role_list(ProfMucWin *mucwin, const char * const role, GSList *nicks) {} -void mucwin_kick_error(ProfMucWin *mucwin, const char * const nick, const char * const error) {} -void confwin_show_form(ProfConfWin *confwin) {} -void confwin_show_form_field(ProfConfWin *confwin, DataForm *form, char *tag) {} -void confwin_form_help(ProfConfWin *confwin) {} -void confwin_field_help(ProfConfWin *confwin, char *tag) {} -void ui_show_lines(ProfWin *window, gchar** lines) {} -void ui_redraw_all_room_rosters(void) {} -void ui_show_all_room_rosters(void) {} -void ui_hide_all_room_rosters(void) {} - -gboolean jabber_conn_is_secured(void) +void +ui_clear_win_title(void) +{ +} +void +ui_goodbye_title(void) +{ +} +void +confwin_handle_configuration(ProfConfWin* confwin, DataForm* form) +{ +} +void +ui_handle_room_configuration_form_error(const char* const roomjid, const char* const message) +{ +} +void +ui_handle_room_config_submit_result(const char* const roomjid) +{ +} +void +ui_handle_room_config_submit_result_error(const char* const roomjid, const char* const message) +{ +} +void +mucwin_affiliation_list_error(ProfMucWin* mucwin, const char* const affiliation, const char* const error) +{ +} +void +mucwin_handle_affiliation_list(ProfMucWin* mucwin, const char* const affiliation, GSList* jids) +{ +} +void +mucwin_affiliation_set_error(ProfMucWin* mucwin, const char* const jid, const char* const affiliation, + const char* const error) +{ +} +void +mucwin_role_set_error(ProfMucWin* mucwin, const char* const nick, const char* const role, + const char* const error) +{ +} +void +mucwin_role_list_error(ProfMucWin* mucwin, const char* const role, const char* const error) +{ +} +void +mucwin_handle_role_list(ProfMucWin* mucwin, const char* const role, GSList* nicks) +{ +} +void +mucwin_kick_error(ProfMucWin* mucwin, const char* const nick, const char* const error) +{ +} +void +confwin_show_form(ProfConfWin* confwin) +{ +} +void +confwin_show_form_field(ProfConfWin* confwin, DataForm* form, char* tag) +{ +} +void +confwin_form_help(ProfConfWin* confwin) +{ +} +void +confwin_field_help(ProfConfWin* confwin, char* tag) +{ +} +void +ui_show_lines(ProfWin* window, gchar** lines) +{ +} +void +ui_redraw_all_room_rosters(void) +{ +} +void +ui_show_all_room_rosters(void) +{ +} +void +ui_hide_all_room_rosters(void) +{ +} + +gboolean +jabber_conn_is_secured(void) { return TRUE; } -TLSCertificate* jabber_get_tls_peer_cert(void) +TLSCertificate* +jabber_get_tls_peer_cert(void) { return NULL; } -void cons_show_tlscert(TLSCertificate *cert) {} -void cons_show_tlscert_summary(TLSCertificate *cert) {} +void +cons_show_tlscert(TLSCertificate* cert) +{ +} +void +cons_show_tlscert_summary(TLSCertificate* cert) +{ +} -void ui_prune_wins(void) {} +void +ui_prune_wins(void) +{ +} -void ui_handle_login_account_success(ProfAccount *account, int secured) {} -void ui_update_presence(const resource_presence_t resource_presence, - const char * const message, const char * const show) {} +void +ui_handle_login_account_success(ProfAccount* account, int secured) +{ +} +void +ui_update_presence(const resource_presence_t resource_presence, + const char* const message, const char* const show) +{ +} -char* inp_readline(void) +char* +inp_readline(void) { return NULL; } -void inp_nonblocking(gboolean reset) {} +void +inp_nonblocking(gboolean reset) +{ +} -void ui_inp_history_append(char *inp) {} +void +ui_inp_history_append(char* inp) +{ +} -void ui_invalid_command_usage(const char * const usage, void (*setting_func)(void)) {} +void +ui_invalid_command_usage(const char* const usage, void (*setting_func)(void)) +{ +} -gboolean ui_win_has_unsaved_form(int num) +gboolean +ui_win_has_unsaved_form(int num) { return FALSE; } -void ui_status_bar_inactive(const int win) {} -void ui_status_bar_active(const int win) {} -void ui_status_bar_new(const int win) {} -void ui_write(char *line, int offset) {} +void +ui_status_bar_inactive(const int win) +{ +} +void +ui_status_bar_active(const int win) +{ +} +void +ui_status_bar_new(const int win) +{ +} +void +ui_write(char* line, int offset) +{ +} // console window actions -void cons_show(const char * const msg, ...) +void +cons_show(const char* const msg, ...) { va_list args; va_start(args, msg); @@ -321,34 +707,90 @@ void cons_show(const char * const msg, ...) va_end(args); } -void cons_show_padded(int pad, const char * const msg, ...) {} +void +cons_show_padded(int pad, const char* const msg, ...) +{ +} -void cons_show_help(const char *const cmd, CommandHelp *help) {} +void +cons_show_help(const char* const cmd, CommandHelp* help) +{ +} -void cons_about(void) {} -void cons_help(void) {} -void cons_navigation_help(void) {} -void cons_prefs(void) {} -void cons_show_ui_prefs(void) {} -void cons_show_desktop_prefs(void) {} -void cons_show_chat_prefs(void) {} -void cons_show_log_prefs(void) {} -void cons_show_presence_prefs(void) {} -void cons_show_connection_prefs(void) {} -void cons_show_otr_prefs(void) {} -void cons_show_pgp_prefs(void) {} -void cons_show_omemo_prefs(void) {} +void +cons_about(void) +{ +} +void +cons_help(void) +{ +} +void +cons_navigation_help(void) +{ +} +void +cons_prefs(void) +{ +} +void +cons_show_ui_prefs(void) +{ +} +void +cons_show_desktop_prefs(void) +{ +} +void +cons_show_chat_prefs(void) +{ +} +void +cons_show_log_prefs(void) +{ +} +void +cons_show_presence_prefs(void) +{ +} +void +cons_show_connection_prefs(void) +{ +} +void +cons_show_otr_prefs(void) +{ +} +void +cons_show_pgp_prefs(void) +{ +} +void +cons_show_omemo_prefs(void) +{ +} -void cons_show_account(ProfAccount *account) +void +cons_show_account(ProfAccount* account) { check_expected(account); } -void cons_debug(const char * const msg, ...) {} -void cons_show_time(void) {} -void cons_show_word(const char * const word) {} +void +cons_debug(const char* const msg, ...) +{ +} +void +cons_show_time(void) +{ +} +void +cons_show_word(const char* const word) +{ +} -void cons_show_error(const char * const cmd, ...) +void +cons_show_error(const char* const cmd, ...) { va_list args; va_start(args, cmd); @@ -357,185 +799,450 @@ void cons_show_error(const char * const cmd, ...) va_end(args); } -void cons_show_contacts(GSList * list) {} +void +cons_show_contacts(GSList* list) +{ +} -void cons_show_roster(GSList * list) +void +cons_show_roster(GSList* list) { check_expected(list); } void -cons_bad_cmd_usage(const char * const cmd) +cons_bad_cmd_usage(const char* const cmd) { check_expected(cmd); } -void cons_show_roster_group(const char * const group, GSList * list) {} -void cons_show_wins(gboolean unread) {} -void cons_show_status(const char * const barejid) {} -void cons_show_info(PContact pcontact) {} -void cons_show_caps(const char * const fulljid, resource_presence_t presence) {} -void cons_show_themes(GSList *themes) {} -void cons_show_scripts(GSList *scripts) {} -void cons_show_script(const char *const script, GSList *commands) {} +void +cons_show_roster_group(const char* const group, GSList* list) +{ +} +void +cons_show_wins(gboolean unread) +{ +} +void +cons_show_status(const char* const barejid) +{ +} +void +cons_show_info(PContact pcontact) +{ +} +void +cons_show_caps(const char* const fulljid, resource_presence_t presence) +{ +} +void +cons_show_themes(GSList* themes) +{ +} +void +cons_show_scripts(GSList* scripts) +{ +} +void +cons_show_script(const char* const script, GSList* commands) +{ +} -void cons_show_aliases(GList *aliases) +void +cons_show_aliases(GList* aliases) { check_expected(aliases); } -void cons_show_login_success(ProfAccount *account, int secured) {} -void cons_show_software_version(const char * const jid, - const char * const presence, const char * const name, - const char * const version, const char * const os) {} +void +cons_show_login_success(ProfAccount* account, int secured) +{ +} +void +cons_show_software_version(const char* const jid, + const char* const presence, const char* const name, + const char* const version, const char* const os) +{ +} -void cons_show_account_list(gchar **accounts) +void +cons_show_account_list(gchar** accounts) { check_expected(accounts); } -void cons_show_room_list(GSList *room, const char * const conference_node) {} +void +cons_show_room_list(GSList* room, const char* const conference_node) +{ +} -void cons_show_bookmarks(const GList *list) +void +cons_show_bookmarks(const GList* list) { check_expected(list); } -void cons_show_disco_items(GSList *items, const char * const jid) {} -void cons_show_disco_info(const char *from, GSList *identities, GSList *features) {} -void cons_show_room_invite(const char * const invitor, const char * const room, - const char * const reason) {} -void cons_check_version(gboolean not_available_msg) {} -void cons_show_typing(const char * const barejid) {} -void cons_show_incoming_room_message(const char *const nick, const char *const room, const int win_index, gboolean mention, GList *triggers, int unread) {} -void cons_show_incoming_message(const char * const short_from, const int win_index, int unread) {} -void cons_show_room_invites(GList *invites) {} -void cons_show_received_subs(void) {} -void cons_show_sent_subs(void) {} -void cons_alert(void) {} -void cons_theme_setting(void) {} -void cons_privileges_setting(void) {} -void cons_beep_setting(void) {} -void cons_color_setting(void) {} -void cons_console_setting(void) {} -void cons_flash_setting(void) {} -void cons_splash_setting(void) {} -void cons_vercheck_setting(void) {} -void cons_resource_setting(void) {} -void cons_occupants_setting(void) {} -void cons_roster_setting(void) {} -void cons_presence_setting(void) {} -void cons_wrap_setting(void) {} -void cons_winstidy_setting(void) {} -void cons_titlebar_setting(void) {} -void cons_time_setting(void) {} -void cons_statuses_setting(void) {} -void cons_wintitle_setting(void) {} -void cons_notify_setting(void) {} -void cons_states_setting(void) {} -void cons_outtype_setting(void) {} -void cons_intype_setting(void) {} -void cons_gone_setting(void) {} -void cons_history_setting(void) {} -void cons_carbons_setting(void) {} -void cons_receipts_setting(void) {} -void cons_log_setting(void) {} -void cons_logging_setting(void) {} -void cons_autoaway_setting(void) {} -void cons_reconnect_setting(void) {} -void cons_autoping_setting(void) {} -void cons_autoconnect_setting(void) {} -void cons_rooms_cache_setting(void) {} -void cons_inpblock_setting(void) {} -void cons_winpos_setting(void) {} -void cons_statusbar_setting(void) {} -void cons_tray_setting(void) {} -void cons_os_setting(void) {} -void cons_correction_setting(void) {} -void cons_executable_setting(void) {} -void cons_slashguard_setting(void) {} -void cons_show_bookmarks_ignore(gchar **list, gsize len) {} - -void cons_show_contact_online(PContact contact, Resource *resource, GDateTime *last_activity) +void +cons_show_disco_items(GSList* items, const char* const jid) +{ +} +void +cons_show_disco_info(const char* from, GSList* identities, GSList* features) +{ +} +void +cons_show_room_invite(const char* const invitor, const char* const room, + const char* const reason) +{ +} +void +cons_check_version(gboolean not_available_msg) +{ +} +void +cons_show_typing(const char* const barejid) +{ +} +void +cons_show_incoming_room_message(const char* const nick, const char* const room, const int win_index, gboolean mention, GList* triggers, int unread) +{ +} +void +cons_show_incoming_message(const char* const short_from, const int win_index, int unread) +{ +} +void +cons_show_room_invites(GList* invites) +{ +} +void +cons_show_received_subs(void) +{ +} +void +cons_show_sent_subs(void) +{ +} +void +cons_alert(void) +{ +} +void +cons_theme_setting(void) +{ +} +void +cons_privileges_setting(void) +{ +} +void +cons_beep_setting(void) +{ +} +void +cons_color_setting(void) +{ +} +void +cons_console_setting(void) +{ +} +void +cons_flash_setting(void) +{ +} +void +cons_splash_setting(void) +{ +} +void +cons_vercheck_setting(void) +{ +} +void +cons_resource_setting(void) +{ +} +void +cons_occupants_setting(void) +{ +} +void +cons_roster_setting(void) +{ +} +void +cons_presence_setting(void) +{ +} +void +cons_wrap_setting(void) +{ +} +void +cons_winstidy_setting(void) +{ +} +void +cons_titlebar_setting(void) +{ +} +void +cons_time_setting(void) +{ +} +void +cons_statuses_setting(void) +{ +} +void +cons_wintitle_setting(void) +{ +} +void +cons_notify_setting(void) +{ +} +void +cons_states_setting(void) +{ +} +void +cons_outtype_setting(void) +{ +} +void +cons_intype_setting(void) +{ +} +void +cons_gone_setting(void) +{ +} +void +cons_history_setting(void) +{ +} +void +cons_carbons_setting(void) +{ +} +void +cons_receipts_setting(void) +{ +} +void +cons_log_setting(void) +{ +} +void +cons_logging_setting(void) +{ +} +void +cons_autoaway_setting(void) +{ +} +void +cons_reconnect_setting(void) +{ +} +void +cons_autoping_setting(void) +{ +} +void +cons_autoconnect_setting(void) +{ +} +void +cons_rooms_cache_setting(void) +{ +} +void +cons_inpblock_setting(void) +{ +} +void +cons_winpos_setting(void) +{ +} +void +cons_statusbar_setting(void) +{ +} +void +cons_tray_setting(void) +{ +} +void +cons_os_setting(void) +{ +} +void +cons_correction_setting(void) +{ +} +void +cons_executable_setting(void) +{ +} +void +cons_slashguard_setting(void) +{ +} +void +cons_show_bookmarks_ignore(gchar** list, gsize len) +{ +} + +void +cons_show_contact_online(PContact contact, Resource* resource, GDateTime* last_activity) { check_expected(contact); check_expected(resource); check_expected(last_activity); } -void cons_show_contact_offline(PContact contact, char *resource, char *status) {} -void cons_theme_colours(void) {} -void cons_theme_properties(void) {} +void +cons_show_contact_offline(PContact contact, char* resource, char* status) +{ +} +void +cons_theme_colours(void) +{ +} +void +cons_theme_properties(void) +{ +} // title bar -void title_bar_set_presence(contact_presence_t presence) {} +void +title_bar_set_presence(contact_presence_t presence) +{ +} // status bar -void status_bar_inactive(const int win) {} -void status_bar_active(const int win, win_type_t type, char *identifier) {} -void status_bar_new(const int win, win_type_t type, char *identifier) {} -void status_bar_set_all_inactive(void) {} +void +status_bar_inactive(const int win) +{ +} +void +status_bar_active(const int win, win_type_t type, char* identifier) +{ +} +void +status_bar_new(const int win, win_type_t type, char* identifier) +{ +} +void +status_bar_set_all_inactive(void) +{ +} // roster window -void rosterwin_roster(void) {} +void +rosterwin_roster(void) +{ +} // occupants window -void occupantswin_occupants(const char * const room) {} -void occupantswin_occupants_all(void) {} +void +occupantswin_occupants(const char* const room) +{ +} +void +occupantswin_occupants_all(void) +{ +} // window interface -ProfWin* win_create_console(void) +ProfWin* +win_create_console(void) { return mock_ptr_type(ProfWin*); } -ProfWin* win_create_xmlconsole(void) +ProfWin* +win_create_xmlconsole(void) { return NULL; } -ProfWin* win_create_chat(const char * const barejid) +ProfWin* +win_create_chat(const char* const barejid) { return mock_ptr_type(ProfWin*); } -ProfWin* win_create_muc(const char * const roomjid) +ProfWin* +win_create_muc(const char* const roomjid) { return NULL; } -ProfWin* win_create_config(const char *const title, DataForm *form, ProfConfWinCallback submit, ProfConfWinCallback cancel, const void *userdata) +ProfWin* +win_create_config(const char* const title, DataForm* form, ProfConfWinCallback submit, ProfConfWinCallback cancel, const void* userdata) { return NULL; } -ProfWin* win_create_private(const char * const fulljid) +ProfWin* +win_create_private(const char* const fulljid) { return NULL; } -ProfWin* win_create_plugin(const char *const plugin_name, const char * const tag) +ProfWin* +win_create_plugin(const char* const plugin_name, const char* const tag) { return NULL; } -char* win_get_tab_identifier(ProfWin *window) +char* +win_get_tab_identifier(ProfWin* window) { return NULL; } -void win_update_virtual(ProfWin *window) {} -void win_free(ProfWin *window) {} -gboolean win_notify_remind(ProfWin *window) +void +win_update_virtual(ProfWin* window) +{ +} +void +win_free(ProfWin* window) +{ +} +gboolean +win_notify_remind(ProfWin* window) { return TRUE; } -int win_unread(ProfWin *window) +int +win_unread(ProfWin* window) { return 0; } -void win_resize(ProfWin *window) {} -void win_hide_subwin(ProfWin *window) {} -void win_show_subwin(ProfWin *window) {} -void win_refresh_without_subwin(ProfWin *window) {} -void win_refresh_with_subwin(ProfWin *window) {} +void +win_resize(ProfWin* window) +{ +} +void +win_hide_subwin(ProfWin* window) +{ +} +void +win_show_subwin(ProfWin* window) +{ +} +void +win_refresh_without_subwin(ProfWin* window) +{ +} +void +win_refresh_with_subwin(ProfWin* window) +{ +} -void win_println(ProfWin *window, theme_item_t theme, const char *ch, const char *const message, ...) +void +win_println(ProfWin* window, theme_item_t theme, const char* ch, const char* const message, ...) { va_list args; va_start(args, message); @@ -544,35 +1251,84 @@ void win_println(ProfWin *window, theme_item_t theme, const char *ch, const char va_end(args); } -void win_print(ProfWin *window, theme_item_t theme_item, const char *ch, const char *const message, ...) {} -void win_appendln(ProfWin *window, theme_item_t theme_item, const char *const message, ...) {} +void +win_print(ProfWin* window, theme_item_t theme_item, const char* ch, const char* const message, ...) +{ +} +void +win_appendln(ProfWin* window, theme_item_t theme_item, const char* const message, ...) +{ +} -char* win_get_title(ProfWin *window) +char* +win_get_title(ProfWin* window) { return NULL; } -void win_show_occupant(ProfWin *window, Occupant *occupant) {} -void win_show_occupant_info(ProfWin *window, const char * const room, Occupant *occupant) {} -void win_show_contact(ProfWin *window, PContact contact) {} -void win_show_info(ProfWin *window, PContact contact) {} -void win_println_indent(ProfWin *window, int pad, const char * const message, ...) {} -void win_clear(ProfWin *window) {} -char* win_to_string(ProfWin *window) +void +win_show_occupant(ProfWin* window, Occupant* occupant) +{ +} +void +win_show_occupant_info(ProfWin* window, const char* const room, Occupant* occupant) +{ +} +void +win_show_contact(ProfWin* window, PContact contact) +{ +} +void +win_show_info(ProfWin* window, PContact contact) +{ +} +void +win_println_indent(ProfWin* window, int pad, const char* const message, ...) +{ +} +void +win_clear(ProfWin* window) +{ +} +char* +win_to_string(ProfWin* window) { return NULL; } // desktop notifier actions -void notifier_uninit(void) {} - -void notify_typing(const char * const handle) {} -void notify_message(const char *const name, int win, const char *const text) {} -void notify_room_message(const char * const handle, const char * const room, - int win, const char * const text) {} -void notify_remind(void) {} -void notify_invite(const char * const from, const char * const room, - const char * const reason) {} -void notify_subscription(const char * const from) {} -void notify(const char * const message, int timeout, - const char * const category) {} +void +notifier_uninit(void) +{ +} +void +notify_typing(const char* const handle) +{ +} +void +notify_message(const char* const name, int win, const char* const text) +{ +} +void +notify_room_message(const char* const handle, const char* const room, + int win, const char* const text) +{ +} +void +notify_remind(void) +{ +} +void +notify_invite(const char* const from, const char* const room, + const char* const reason) +{ +} +void +notify_subscription(const char* const from) +{ +} +void +notify(const char* const message, int timeout, + const char* const category) +{ +} diff --git a/tests/unittests/ui/stub_ui.h b/tests/unittests/ui/stub_ui.h index 635f719e..faff0710 100644 --- a/tests/unittests/ui/stub_ui.h +++ b/tests/unittests/ui/stub_ui.h @@ -1,5 +1,5 @@ -void expect_cons_show(char *expected); +void expect_cons_show(char* expected); void expect_any_cons_show(void); -void expect_cons_show_error(char *expected); +void expect_cons_show_error(char* expected); void expect_any_cons_show_error(void); -void expect_win_println(char *message); +void expect_win_println(char* message); diff --git a/tests/unittests/unittests.c b/tests/unittests/unittests.c index 86d0ac62..874f6194 100644 --- a/tests/unittests/unittests.c +++ b/tests/unittests/unittests.c @@ -39,10 +39,12 @@ #include "test_callbacks.h" #include "test_plugins_disco.h" -int main(int argc, char* argv[]) { +int +main(int argc, char* argv[]) +{ setlocale(LC_ALL, "en_GB.UTF-8"); - char *codeset = nl_langinfo(CODESET); - char *lang = getenv("LANG"); + char* codeset = nl_langinfo(CODESET); + char* lang = getenv("LANG"); printf("Charset information:\n"); @@ -217,93 +219,93 @@ int main(int argc, char* argv[]) { unit_test(remove_contact_with_remaining_in_group), unit_test_setup_teardown(returns_false_when_chat_session_does_not_exist, - init_chat_sessions, - close_chat_sessions), + init_chat_sessions, + close_chat_sessions), unit_test_setup_teardown(creates_chat_session_on_recipient_activity, - init_chat_sessions, - close_chat_sessions), + init_chat_sessions, + close_chat_sessions), unit_test_setup_teardown(replaces_chat_session_on_recipient_activity_with_different_resource, - init_chat_sessions, - close_chat_sessions), + init_chat_sessions, + close_chat_sessions), unit_test_setup_teardown(removes_chat_session, - init_chat_sessions, - close_chat_sessions), + init_chat_sessions, + close_chat_sessions), unit_test_setup_teardown(cmd_connect_shows_message_when_disconnecting, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_shows_message_when_connecting, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_shows_message_when_connected, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_when_no_account, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_fail_message, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_lowercases_argument_with_account, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_lowercases_argument_with_no_account, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_asks_password_when_not_in_account, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_shows_usage_when_no_server_value, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_shows_message_when_connecting_with_account, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_connects_with_account, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_shows_usage_when_server_no_port_value, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_shows_usage_when_no_port_value, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_shows_usage_when_port_no_server_value, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_shows_message_when_port_0, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_shows_message_when_port_minus1, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_shows_message_when_port_65536, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_shows_message_when_port_contains_chars, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_with_server_when_provided, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_with_port_when_provided, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_with_server_and_port_when_provided, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_shows_usage_when_server_provided_twice, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_shows_usage_when_port_provided_twice, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_shows_usage_when_invalid_first_property, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_shows_usage_when_invalid_second_property, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test(cmd_rooms_shows_message_when_disconnected), unit_test(cmd_rooms_shows_message_when_disconnecting), @@ -404,55 +406,55 @@ int main(int argc, char* argv[]) { unit_test(cmd_presence_shows_usage_when_bad_chat_setting), unit_test(cmd_presence_shows_usage_when_bad_muc_setting), unit_test_setup_teardown(cmd_presence_console_sets_all, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_presence_console_sets_online, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_presence_console_sets_none, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_presence_chat_sets_all, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_presence_chat_sets_online, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_presence_chat_sets_none, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_presence_room_sets_all, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_presence_room_sets_online, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_presence_room_sets_none, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(statuses_console_defaults_to_all, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(statuses_chat_defaults_to_all, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(statuses_muc_defaults_to_all, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(console_shows_online_presence_when_set_online, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(console_shows_online_presence_when_set_all, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(console_shows_dnd_presence_when_set_all, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(handle_offline_removes_chat_session, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test(lost_connection_clears_chat_sessions), unit_test(cmd_alias_add_shows_usage_when_no_args), @@ -460,20 +462,20 @@ int main(int argc, char* argv[]) { unit_test(cmd_alias_remove_shows_usage_when_no_args), unit_test(cmd_alias_show_usage_when_invalid_subcmd), unit_test_setup_teardown(cmd_alias_add_adds_alias, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_alias_add_shows_message_when_exists, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_alias_remove_removes_alias, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_alias_remove_shows_message_when_no_alias, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_alias_list_shows_all_aliases, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(test_muc_invites_add, muc_before_test, muc_after_test), unit_test_setup_teardown(test_muc_remove_invite, muc_before_test, muc_after_test), @@ -504,20 +506,20 @@ int main(int argc, char* argv[]) { unit_test(cmd_otr_log_shows_usage_when_no_args), unit_test(cmd_otr_log_shows_usage_when_invalid_subcommand), unit_test_setup_teardown(cmd_otr_log_on_enables_logging, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_otr_log_off_disables_logging, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_otr_redact_redacts_logging, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_otr_log_on_shows_warning_when_chlog_disabled, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_otr_log_redact_shows_warning_when_chlog_disabled, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test(cmd_otr_libver_shows_libotr_version), unit_test(cmd_otr_gen_shows_message_when_not_connected), unit_test(cmd_otr_gen_generates_key_for_connected_account), @@ -540,8 +542,8 @@ int main(int argc, char* argv[]) { unit_test(cmd_otr_start_shows_message_when_already_started), unit_test(cmd_otr_start_shows_message_when_no_key), unit_test_setup_teardown(cmd_otr_start_sends_otr_query_message_to_current_recipeint, - load_preferences, - close_preferences), + load_preferences, + close_preferences), #else unit_test(cmd_otr_shows_message_when_otr_unsupported), #endif @@ -608,8 +610,8 @@ int main(int argc, char* argv[]) { unit_test(remove_text_multi_value_removes_when_many), unit_test_setup_teardown(clears_chat_sessions, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test(prof_partial_occurrences_tests), unit_test(prof_whole_occurrences_tests), diff --git a/tests/unittests/xmpp/stub_avatar.c b/tests/unittests/xmpp/stub_avatar.c index 64b8a95f..ccd9cf4d 100644 --- a/tests/unittests/xmpp/stub_avatar.c +++ b/tests/unittests/xmpp/stub_avatar.c @@ -2,6 +2,9 @@ #include <glib.h> #include <stdlib.h> -void avatar_pep_subscribe(void) {}; -gboolean avatar_get_by_nick(const char* nick) {return TRUE;} - +void avatar_pep_subscribe(void){}; +gboolean +avatar_get_by_nick(const char* nick) +{ + return TRUE; +} diff --git a/tests/unittests/xmpp/stub_message.c b/tests/unittests/xmpp/stub_message.c index 3e22e539..e99acbc9 100644 --- a/tests/unittests/xmpp/stub_message.c +++ b/tests/unittests/xmpp/stub_message.c @@ -1,7 +1,12 @@ #include "xmpp/message.h" -ProfMessage *message_init(void) { +ProfMessage* +message_init(void) +{ return NULL; } -void message_free(ProfMessage *message) {} +void +message_free(ProfMessage* message) +{ +} diff --git a/tests/unittests/xmpp/stub_ox.c b/tests/unittests/xmpp/stub_ox.c index 11529533..ce5532ae 100644 --- a/tests/unittests/xmpp/stub_ox.c +++ b/tests/unittests/xmpp/stub_ox.c @@ -2,7 +2,7 @@ #include <glib.h> #include <stdlib.h> -gboolean +gboolean ox_announce_public_key(const char* const filename) { return FALSE; diff --git a/tests/unittests/xmpp/stub_xmpp.c b/tests/unittests/xmpp/stub_xmpp.c index 16392283..e1b6fdd8 100644 --- a/tests/unittests/xmpp/stub_xmpp.c +++ b/tests/unittests/xmpp/stub_xmpp.c @@ -6,13 +6,23 @@ #include "xmpp/xmpp.h" // connection functions -void session_init(void) {} -void session_init_activity(void) {} -void session_check_autoaway(void) {} +void +session_init(void) +{ +} +void +session_init_activity(void) +{ +} +void +session_check_autoaway(void) +{ +} -jabber_conn_status_t session_connect_with_details(const char * const jid, - const char * const passwd, const char * const altdomain, const int port, const char *const tls_policy, - const char *const auth_policy) +jabber_conn_status_t +session_connect_with_details(const char* const jid, + const char* const passwd, const char* const altdomain, const int port, const char* const tls_policy, + const char* const auth_policy) { check_expected(jid); check_expected(passwd); @@ -21,31 +31,45 @@ jabber_conn_status_t session_connect_with_details(const char * const jid, return mock_type(jabber_conn_status_t); } -jabber_conn_status_t session_connect_with_account(const ProfAccount * const account) +jabber_conn_status_t +session_connect_with_account(const ProfAccount* const account) { check_expected(account); return mock_type(jabber_conn_status_t); } -void session_disconnect(void) {} -void session_shutdown(void) {} -void session_process_events(void) {} -const char * connection_get_fulljid(void) +void +session_disconnect(void) +{ +} +void +session_shutdown(void) { - return mock_ptr_type(char *); +} +void +session_process_events(void) +{ +} +const char* +connection_get_fulljid(void) +{ + return mock_ptr_type(char*); } -char* connection_get_barejid(void) +char* +connection_get_barejid(void) { - return mock_ptr_type(char *); + return mock_ptr_type(char*); } -const char * connection_get_domain(void) +const char* +connection_get_domain(void) { return NULL; } -gboolean connection_is_secured(void) +gboolean +connection_is_secured(void) { return 1; } @@ -56,202 +80,355 @@ connection_get_tls_peer_cert(void) return NULL; } - -char* connection_create_uuid(void) +char* +connection_create_uuid(void) { return NULL; } -void connection_free_uuid(char * uuid) {} +void +connection_free_uuid(char* uuid) +{ +} -jabber_conn_status_t connection_get_status(void) +jabber_conn_status_t +connection_get_status(void) { return mock_type(jabber_conn_status_t); } -char* connection_get_presence_msg(void) +char* +connection_get_presence_msg(void) { return mock_ptr_type(char*); } -char* session_get_account_name(void) +char* +session_get_account_name(void) { return mock_ptr_type(char*); } -GList * session_get_available_resources(void) +GList* +session_get_available_resources(void) { return NULL; } -void connection_set_presence_msg(const char *const message) {} +void +connection_set_presence_msg(const char* const message) +{ +} gboolean -connection_send_stanza(const char *const stanza) +connection_send_stanza(const char* const stanza) { return TRUE; } gboolean -connection_supports(const char *const feature) +connection_supports(const char* const feature) { return FALSE; } -const char* connection_get_profanity_identifier(void) { +const char* +connection_get_profanity_identifier(void) +{ return "profident"; } // message functions -char* message_send_chat(const char *const barejid, const char *const msg, const char *const oob_url, gboolean request_receipt, const char *const replace_id) +char* +message_send_chat(const char* const barejid, const char* const msg, const char* const oob_url, gboolean request_receipt, const char* const replace_id) { check_expected(barejid); check_expected(msg); return NULL; } -char* message_send_chat_otr(const char * const barejid, const char * const msg, gboolean request_receipt, const char *const replace_id) +char* +message_send_chat_otr(const char* const barejid, const char* const msg, gboolean request_receipt, const char* const replace_id) { check_expected(barejid); check_expected(msg); return NULL; } -char* message_send_chat_pgp(const char * const barejid, const char * const msg, gboolean request_receipt, const char *const replace_id) +char* +message_send_chat_pgp(const char* const barejid, const char* const msg, gboolean request_receipt, const char* const replace_id) { return NULL; } -char* message_send_chat_ox(const char * const barejid, const char * const msg, gboolean request_receipt, const char *const replace_id) +char* +message_send_chat_ox(const char* const barejid, const char* const msg, gboolean request_receipt, const char* const replace_id) { return NULL; } -char* message_send_private(const char *const fulljid, const char *const msg, const char *const oob_url) +char* +message_send_private(const char* const fulljid, const char* const msg, const char* const oob_url) { return NULL; } -char* message_send_groupchat(const char *const roomjid, const char *const msg, const char *const oob_url, const char *const replace_id) +char* +message_send_groupchat(const char* const roomjid, const char* const msg, const char* const oob_url, const char* const replace_id) { return NULL; } -void message_send_groupchat_subject(const char * const roomjid, const char * const subject) {} +void +message_send_groupchat_subject(const char* const roomjid, const char* const subject) +{ +} -void message_send_inactive(const char * const barejid) {} -void message_send_composing(const char * const barejid) {} -void message_send_paused(const char * const barejid) {} -void message_send_gone(const char * const barejid) {} +void +message_send_inactive(const char* const barejid) +{ +} +void +message_send_composing(const char* const barejid) +{ +} +void +message_send_paused(const char* const barejid) +{ +} +void +message_send_gone(const char* const barejid) +{ +} -void message_send_invite(const char * const room, const char * const contact, - const char * const reason) {} +void +message_send_invite(const char* const room, const char* const contact, + const char* const reason) +{ +} -bool message_is_sent_by_us(const ProfMessage *const message, bool checkOID) { +bool +message_is_sent_by_us(const ProfMessage* const message, bool checkOID) +{ return TRUE; } // presence functions -void presence_subscription(const char * const jid, const jabber_subscr_t action) {} +void +presence_subscription(const char* const jid, const jabber_subscr_t action) +{ +} -GList* presence_get_subscription_requests(void) +GList* +presence_get_subscription_requests(void) { return NULL; } -gint presence_sub_request_count(void) +gint +presence_sub_request_count(void) { return 0; } -void presence_reset_sub_request_search(void) {} +void +presence_reset_sub_request_search(void) +{ +} -char * presence_sub_request_find(const char * const search_str, gboolean previous, void *context) +char* +presence_sub_request_find(const char* const search_str, gboolean previous, void* context) { - return NULL; + return NULL; } -void presence_join_room(const char *const room, const char *const nick, const char *const passwd) +void +presence_join_room(const char* const room, const char* const nick, const char* const passwd) { check_expected(room); check_expected(nick); check_expected(passwd); } -void presence_change_room_nick(const char * const room, const char * const nick) {} -void presence_leave_chat_room(const char * const room_jid) {} +void +presence_change_room_nick(const char* const room, const char* const nick) +{ +} +void +presence_leave_chat_room(const char* const room_jid) +{ +} -void presence_send(resource_presence_t status, int idle, char *signed_status) +void +presence_send(resource_presence_t status, int idle, char* signed_status) { check_expected(status); check_expected(idle); check_expected(signed_status); } -gboolean presence_sub_request_exists(const char * const bare_jid) +gboolean +presence_sub_request_exists(const char* const bare_jid) { return FALSE; } // iq functions -void iq_disable_carbons() {}; -void iq_enable_carbons() {}; -void iq_send_software_version(const char * const fulljid) {} +void iq_disable_carbons(){}; +void iq_enable_carbons(){}; +void +iq_send_software_version(const char* const fulljid) +{ +} -void iq_room_list_request(gchar *conferencejid, gchar *filter) +void +iq_room_list_request(gchar* conferencejid, gchar* filter) { check_expected(conferencejid); check_expected(filter); } -void iq_disco_info_request(gchar *jid) {} -void iq_disco_items_request(gchar *jid) {} -void iq_set_autoping(int seconds) {} -void iq_http_upload_request(HTTPUpload *upload) {} -void iq_confirm_instant_room(const char * const room_jid) {} -void iq_destroy_room(const char * const room_jid) {} -void iq_request_room_config_form(const char * const room_jid) {} -void iq_submit_room_config(ProfConfWin *confwin) {} -void iq_room_config_cancel(ProfConfWin *confwin) {} -void iq_send_ping(const char * const target) {} -void iq_send_caps_request(const char * const to, const char * const id, - const char * const node, const char * const ver) {} -void iq_send_caps_request_for_jid(const char * const to, const char * const id, - const char * const node, const char * const ver) {} -void iq_send_caps_request_legacy(const char * const to, const char * const id, - const char * const node, const char * const ver) {} -void iq_room_info_request(const char * const room, gboolean display) {} -void iq_room_affiliation_list(const char * const room, char *affiliation, bool show) {} -void iq_room_affiliation_set(const char * const room, const char * const jid, char *affiliation, - const char * const reason) {} -void iq_room_kick_occupant(const char * const room, const char * const nick, const char * const reason) {} -void iq_room_role_set(const char * const room, const char * const nick, char *role, - const char * const reason) {} -void iq_room_role_list(const char * const room, char *role) {} -void iq_last_activity_request(gchar *jid) {} -void iq_autoping_timer_cancel(void) {} -void iq_autoping_check(void) {} -void iq_rooms_cache_clear(void) {} -void iq_command_list(const char *const target) {} -void iq_command_exec(const char *const target, const char *const command) {} +void +iq_disco_info_request(gchar* jid) +{ +} +void +iq_disco_items_request(gchar* jid) +{ +} +void +iq_set_autoping(int seconds) +{ +} +void +iq_http_upload_request(HTTPUpload* upload) +{ +} +void +iq_confirm_instant_room(const char* const room_jid) +{ +} +void +iq_destroy_room(const char* const room_jid) +{ +} +void +iq_request_room_config_form(const char* const room_jid) +{ +} +void +iq_submit_room_config(ProfConfWin* confwin) +{ +} +void +iq_room_config_cancel(ProfConfWin* confwin) +{ +} +void +iq_send_ping(const char* const target) +{ +} +void +iq_send_caps_request(const char* const to, const char* const id, + const char* const node, const char* const ver) +{ +} +void +iq_send_caps_request_for_jid(const char* const to, const char* const id, + const char* const node, const char* const ver) +{ +} +void +iq_send_caps_request_legacy(const char* const to, const char* const id, + const char* const node, const char* const ver) +{ +} +void +iq_room_info_request(const char* const room, gboolean display) +{ +} +void +iq_room_affiliation_list(const char* const room, char* affiliation, bool show) +{ +} +void +iq_room_affiliation_set(const char* const room, const char* const jid, char* affiliation, + const char* const reason) +{ +} +void +iq_room_kick_occupant(const char* const room, const char* const nick, const char* const reason) +{ +} +void +iq_room_role_set(const char* const room, const char* const nick, char* role, + const char* const reason) +{ +} +void +iq_room_role_list(const char* const room, char* role) +{ +} +void +iq_last_activity_request(gchar* jid) +{ +} +void +iq_autoping_timer_cancel(void) +{ +} +void +iq_autoping_check(void) +{ +} +void +iq_rooms_cache_clear(void) +{ +} +void +iq_command_list(const char* const target) +{ +} +void +iq_command_exec(const char* const target, const char* const command) +{ +} // caps functions -void caps_add_feature(char *feature) {} -void caps_remove_feature(char *feature) {} -EntityCapabilities* caps_lookup(const char * const jid) +void +caps_add_feature(char* feature) +{ +} +void +caps_remove_feature(char* feature) +{ +} +EntityCapabilities* +caps_lookup(const char* const jid) { return NULL; } -void caps_close(void) {} -void caps_destroy(EntityCapabilities *caps) {} -void caps_reset_ver(void) {} -gboolean caps_jid_has_feature(const char *const jid, const char *const feature) +void +caps_close(void) +{ +} +void +caps_destroy(EntityCapabilities* caps) +{ +} +void +caps_reset_ver(void) +{ +} +gboolean +caps_jid_has_feature(const char* const jid, const char* const feature) { return FALSE; } -gboolean bookmark_add(const char *jid, const char *nick, const char *password, const char *autojoin_str, const char *name) +gboolean +bookmark_add(const char* jid, const char* nick, const char* password, const char* autojoin_str, const char* name) { check_expected(jid); check_expected(nick); @@ -260,78 +437,103 @@ gboolean bookmark_add(const char *jid, const char *nick, const char *password, c return mock_type(gboolean); } -gboolean bookmark_update(const char *jid, const char *nick, const char *password, const char *autojoin_str, const char *name) +gboolean +bookmark_update(const char* jid, const char* nick, const char* password, const char* autojoin_str, const char* name) { return FALSE; } -gboolean bookmark_remove(const char *jid) +gboolean +bookmark_remove(const char* jid) { check_expected(jid); return mock_type(gboolean); } -gboolean bookmark_join(const char *jid) +gboolean +bookmark_join(const char* jid) { return FALSE; } -GList * bookmark_get_list(void) +GList* +bookmark_get_list(void) { - return mock_ptr_type(GList *); + return mock_ptr_type(GList*); } -char * bookmark_find(const char * const search_str, gboolean previous, void *context) +char* +bookmark_find(const char* const search_str, gboolean previous, void* context) { return NULL; } -void bookmark_autocomplete_reset(void) {} +void +bookmark_autocomplete_reset(void) +{ +} -void roster_send_name_change(const char * const barejid, const char * const new_name, GSList *groups) +void +roster_send_name_change(const char* const barejid, const char* const new_name, GSList* groups) { check_expected(barejid); check_expected(new_name); check_expected(groups); } -gboolean bookmark_exists(const char *const room) +gboolean +bookmark_exists(const char* const room) { return FALSE; } -void roster_send_add_to_group(const char * const group, PContact contact) {} -void roster_send_remove_from_group(const char * const group, PContact contact) {} +void +roster_send_add_to_group(const char* const group, PContact contact) +{ +} +void +roster_send_remove_from_group(const char* const group, PContact contact) +{ +} -void roster_send_add_new(const char * const barejid, const char * const name) +void +roster_send_add_new(const char* const barejid, const char* const name) { check_expected(barejid); check_expected(name); } -void roster_send_remove(const char * const barejid) +void +roster_send_remove(const char* const barejid) { check_expected(barejid); } -GList* blocked_list(void) +GList* +blocked_list(void) { return NULL; } -gboolean blocked_add(char *jid) +gboolean +blocked_add(char* jid) { return TRUE; } -gboolean blocked_remove(char *jid) +gboolean +blocked_remove(char* jid) { return TRUE; } -char* blocked_ac_find(const char *const search_str, gboolean previous, void *context) +char* +blocked_ac_find(const char* const search_str, gboolean previous, void* context) { return NULL; } -void blocked_ac_reset(void) {} +void +blocked_ac_reset(void) +{ +} |