diff --git a/.gitignore b/.gitignore
index 446a3868..cc3402a9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -55,6 +55,9 @@ tests/unittests/unittests.log
tests/unittests/unittests.trs
test-suite.log
+# valgrind output
+profval*
+
# local scripts
clean-test.sh
gen_docs.sh
diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c
index f0210713..f424d401 100644
--- a/src/command/cmd_ac.c
+++ b/src/command/cmd_ac.c
@@ -131,6 +131,7 @@ static char* _executable_autocomplete(ProfWin* window, const char* const input,
static char* _lastactivity_autocomplete(ProfWin* window, const char* const input, gboolean previous);
static char* _intype_autocomplete(ProfWin* window, const char* const input, gboolean previous);
static char* _mood_autocomplete(ProfWin* window, const char* const input, gboolean previous);
+static char* _strophe_autocomplete(ProfWin* window, const char* const input, gboolean previous);
static char* _adhoc_cmd_autocomplete(ProfWin* window, const char* const input, gboolean previous);
static char* _vcard_autocomplete(ProfWin* window, const char* const input, gboolean previous);
@@ -276,6 +277,9 @@ static Autocomplete executable_ac;
static Autocomplete intype_ac;
static Autocomplete mood_ac;
static Autocomplete mood_type_ac;
+static Autocomplete strophe_ac;
+static Autocomplete strophe_sm_ac;
+static Autocomplete strophe_verbosity_ac;
static Autocomplete adhoc_cmd_ac;
static Autocomplete lastactivity_ac;
static Autocomplete vcard_ac;
@@ -1098,6 +1102,19 @@ cmd_ac_init(void)
autocomplete_add(intype_ac, "console");
autocomplete_add(intype_ac, "titlebar");
+ strophe_ac = autocomplete_new();
+ autocomplete_add(strophe_ac, "sm");
+ autocomplete_add(strophe_ac, "verbosity");
+ strophe_sm_ac = autocomplete_new();
+ autocomplete_add(strophe_sm_ac, "on");
+ autocomplete_add(strophe_sm_ac, "no-resend");
+ autocomplete_add(strophe_sm_ac, "off");
+ strophe_verbosity_ac = autocomplete_new();
+ autocomplete_add(strophe_verbosity_ac, "0");
+ autocomplete_add(strophe_verbosity_ac, "1");
+ autocomplete_add(strophe_verbosity_ac, "2");
+ autocomplete_add(strophe_verbosity_ac, "3");
+
mood_ac = autocomplete_new();
autocomplete_add(mood_ac, "set");
autocomplete_add(mood_ac, "clear");
@@ -1298,7 +1315,7 @@ cmd_ac_add_help(const char* const value)
}
void
-cmd_ac_add_cmd(Command* command)
+cmd_ac_add_cmd(const Command* command)
{
autocomplete_add(commands_ac, command->cmd);
autocomplete_add(help_ac, command->cmd + 1);
@@ -1595,6 +1612,9 @@ cmd_ac_reset(ProfWin* window)
autocomplete_reset(intype_ac);
autocomplete_reset(mood_ac);
autocomplete_reset(mood_type_ac);
+ autocomplete_reset(strophe_verbosity_ac);
+ autocomplete_reset(strophe_sm_ac);
+ autocomplete_reset(strophe_ac);
autocomplete_reset(adhoc_cmd_ac);
autocomplete_reset(vcard_ac);
@@ -2057,6 +2077,7 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ
g_hash_table_insert(ac_funcs, "/lastactivity", _lastactivity_autocomplete);
g_hash_table_insert(ac_funcs, "/intype", _intype_autocomplete);
g_hash_table_insert(ac_funcs, "/mood", _mood_autocomplete);
+ g_hash_table_insert(ac_funcs, "/strophe", _strophe_autocomplete);
g_hash_table_insert(ac_funcs, "/cmd", _adhoc_cmd_autocomplete);
g_hash_table_insert(ac_funcs, "/vcard", _vcard_autocomplete);
@@ -2360,7 +2381,7 @@ _bookmark_autocomplete(ProfWin* window, const char* const input, gboolean previo
char* found = NULL;
gboolean result;
- gchar** args = parse_args(input, 2, 8, &result);
+ auto_gcharv gchar** args = parse_args(input, 2, 8, &result);
if (result && ((strcmp(args[0], "add") == 0) || (strcmp(args[0], "update") == 0))) {
gboolean space_at_end = g_str_has_suffix(input, " ");
@@ -2371,7 +2392,6 @@ _bookmark_autocomplete(ProfWin* window, const char* const input, gboolean previo
found = autocomplete_param_with_ac(input, beginning->str, bookmark_property_ac, TRUE, previous);
g_string_free(beginning, TRUE);
if (found) {
- g_strfreev(args);
return found;
}
}
@@ -2382,7 +2402,6 @@ _bookmark_autocomplete(ProfWin* window, const char* const input, gboolean previo
found = autocomplete_param_with_func(input, beginning->str, prefs_autocomplete_boolean_choice, previous, NULL);
g_string_free(beginning, TRUE);
if (found) {
- g_strfreev(args);
return found;
}
}
@@ -2392,7 +2411,6 @@ _bookmark_autocomplete(ProfWin* window, const char* const input, gboolean previo
found = autocomplete_param_with_ac(input, beginning->str, bookmark_property_ac, TRUE, previous);
g_string_free(beginning, TRUE);
if (found) {
- g_strfreev(args);
return found;
}
}
@@ -2403,7 +2421,6 @@ _bookmark_autocomplete(ProfWin* window, const char* const input, gboolean previo
found = autocomplete_param_with_func(input, beginning->str, prefs_autocomplete_boolean_choice, previous, NULL);
g_string_free(beginning, TRUE);
if (found) {
- g_strfreev(args);
return found;
}
}
@@ -2413,7 +2430,6 @@ _bookmark_autocomplete(ProfWin* window, const char* const input, gboolean previo
found = autocomplete_param_with_ac(input, beginning->str, bookmark_property_ac, TRUE, previous);
g_string_free(beginning, TRUE);
if (found) {
- g_strfreev(args);
return found;
}
}
@@ -2424,14 +2440,11 @@ _bookmark_autocomplete(ProfWin* window, const char* const input, gboolean previo
found = autocomplete_param_with_func(input, beginning->str, prefs_autocomplete_boolean_choice, previous, NULL);
g_string_free(beginning, TRUE);
if (found) {
- g_strfreev(args);
return found;
}
}
}
- g_strfreev(args);
-
found = autocomplete_param_with_func(input, "/bookmark remove", bookmark_find, previous, NULL);
if (found) {
return found;
@@ -2633,7 +2646,7 @@ _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);
+ auto_gcharv gchar** args = parse_args(input, 2, 3, &result);
if (result && (strcmp(args[0], "policy") == 0)) {
GString* beginning = g_string_new("/otr ");
g_string_append(beginning, args[0]);
@@ -2645,11 +2658,9 @@ _otr_autocomplete(ProfWin* window, const char* const input, gboolean previous)
found = autocomplete_param_with_func(input, beginning->str, roster_contact_autocomplete, previous, NULL);
g_string_free(beginning, TRUE);
if (found) {
- g_strfreev(args);
return found;
}
}
- g_strfreev(args);
}
found = autocomplete_param_with_ac(input, "/otr policy", otr_policy_ac, TRUE, previous);
@@ -2697,7 +2708,7 @@ _pgp_autocomplete(ProfWin* window, const char* const input, gboolean previous)
}
gboolean result;
- gchar** args = parse_args(input, 2, 3, &result);
+ auto_gcharv gchar** args = parse_args(input, 2, 3, &result);
if ((strncmp(input, "/pgp", 4) == 0) && (result == TRUE)) {
GString* beginning = g_string_new("/pgp ");
g_string_append(beginning, args[0]);
@@ -2708,11 +2719,9 @@ _pgp_autocomplete(ProfWin* window, const char* const input, gboolean previous)
found = autocomplete_param_with_func(input, beginning->str, p_gpg_autocomplete_key, previous, NULL);
g_string_free(beginning, TRUE);
if (found) {
- g_strfreev(args);
return found;
}
}
- g_strfreev(args);
if (conn_status == JABBER_CONNECTED) {
found = autocomplete_param_with_func(input, "/pgp setkey", roster_barejid_autocomplete, previous, NULL);
@@ -2826,9 +2835,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);
+ auto_gcharv gchar** args = parse_args(input, 2, 3, &result);
if (result) {
- gchar* jid = g_strdup(args[1]);
+ auto_gchar 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;
@@ -2853,9 +2862,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);
+ auto_gcharv gchar** args = parse_args(input, 2, 3, &result);
if (result) {
- gchar* jid = g_strdup(args[1]);
+ auto_gchar gchar* jid = g_strdup(args[1]);
found = autocomplete_param_no_with_func(input, "/omemo untrust", 4, omemo_fingerprint_autocomplete, previous, jid);
if (found) {
return found;
@@ -3389,7 +3398,7 @@ _affiliation_autocomplete(ProfWin* window, const char* const input, gboolean pre
gboolean parse_result;
Autocomplete jid_ac = muc_roster_jid_ac(mucwin->roomjid);
- gchar** args = parse_args(input, 2, 3, &parse_result);
+ auto_gcharv gchar** args = parse_args(input, 2, 3, &parse_result);
if ((strncmp(input, "/affiliation", 12) == 0) && (parse_result == TRUE)) {
GString* beginning = g_string_new("/affiliation ");
@@ -3402,12 +3411,9 @@ _affiliation_autocomplete(ProfWin* window, const char* const input, gboolean pre
result = autocomplete_param_with_ac(input, beginning->str, jid_ac, TRUE, previous);
g_string_free(beginning, TRUE);
if (result) {
- g_strfreev(args);
return result;
}
}
-
- g_strfreev(args);
}
result = autocomplete_param_with_ac(input, "/affiliation set", affiliation_ac, TRUE, previous);
@@ -3436,7 +3442,7 @@ _role_autocomplete(ProfWin* window, const char* const input, gboolean previous)
gboolean parse_result;
Autocomplete nick_ac = muc_roster_ac(mucwin->roomjid);
- gchar** args = parse_args(input, 2, 3, &parse_result);
+ auto_gcharv gchar** args = parse_args(input, 2, 3, &parse_result);
if ((strncmp(input, "/role", 5) == 0) && (parse_result == TRUE)) {
GString* beginning = g_string_new("/role ");
@@ -3449,12 +3455,9 @@ _role_autocomplete(ProfWin* window, const char* const input, gboolean previous)
result = autocomplete_param_with_ac(input, beginning->str, nick_ac, TRUE, previous);
g_string_free(beginning, TRUE);
if (result) {
- g_strfreev(args);
return result;
}
}
-
- g_strfreev(args);
}
result = autocomplete_param_with_ac(input, "/role set", role_ac, TRUE, previous);
@@ -3568,7 +3571,7 @@ _connect_autocomplete(ProfWin* window, const char* const input, gboolean previou
char* found = NULL;
gboolean result = FALSE;
- gchar** args = parse_args(input, 1, 9, &result);
+ auto_gcharv gchar** args = parse_args(input, 1, 9, &result);
if (result) {
gboolean space_at_end = g_str_has_suffix(input, " ");
@@ -3579,7 +3582,6 @@ _connect_autocomplete(ProfWin* window, const char* const input, gboolean previou
found = autocomplete_param_with_ac(input, beginning->str, connect_property_ac, TRUE, previous);
g_string_free(beginning, TRUE);
if (found) {
- g_strfreev(args);
return found;
}
}
@@ -3590,7 +3592,6 @@ _connect_autocomplete(ProfWin* window, const char* const input, gboolean previou
found = autocomplete_param_with_ac(input, beginning->str, tls_property_ac, TRUE, previous);
g_string_free(beginning, TRUE);
if (found) {
- g_strfreev(args);
return found;
}
}
@@ -3600,7 +3601,6 @@ _connect_autocomplete(ProfWin* window, const char* const input, gboolean previou
found = autocomplete_param_with_ac(input, beginning->str, connect_property_ac, TRUE, previous);
g_string_free(beginning, TRUE);
if (found) {
- g_strfreev(args);
return found;
}
}
@@ -3611,7 +3611,6 @@ _connect_autocomplete(ProfWin* window, const char* const input, gboolean previou
found = autocomplete_param_with_ac(input, beginning->str, tls_property_ac, TRUE, previous);
g_string_free(beginning, TRUE);
if (found) {
- g_strfreev(args);
return found;
}
}
@@ -3621,7 +3620,6 @@ _connect_autocomplete(ProfWin* window, const char* const input, gboolean previou
found = autocomplete_param_with_ac(input, beginning->str, connect_property_ac, TRUE, previous);
g_string_free(beginning, TRUE);
if (found) {
- g_strfreev(args);
return found;
}
}
@@ -3632,7 +3630,6 @@ _connect_autocomplete(ProfWin* window, const char* const input, gboolean previou
found = autocomplete_param_with_ac(input, beginning->str, tls_property_ac, TRUE, previous);
g_string_free(beginning, TRUE);
if (found) {
- g_strfreev(args);
return found;
}
}
@@ -3642,7 +3639,6 @@ _connect_autocomplete(ProfWin* window, const char* const input, gboolean previou
found = autocomplete_param_with_ac(input, beginning->str, connect_property_ac, TRUE, previous);
g_string_free(beginning, TRUE);
if (found) {
- g_strfreev(args);
return found;
}
}
@@ -3653,7 +3649,6 @@ _connect_autocomplete(ProfWin* window, const char* const input, gboolean previou
found = autocomplete_param_with_ac(input, beginning->str, tls_property_ac, TRUE, previous);
g_string_free(beginning, TRUE);
if (found) {
- g_strfreev(args);
return found;
}
}
@@ -3667,7 +3662,6 @@ _connect_autocomplete(ProfWin* window, const char* const input, gboolean previou
found = autocomplete_param_with_ac(input, beginning->str, auth_property_ac, TRUE, previous);
g_string_free(beginning, TRUE);
if (found) {
- g_strfreev(args);
return found;
}
}
@@ -3678,7 +3672,6 @@ _connect_autocomplete(ProfWin* window, const char* const input, gboolean previou
found = autocomplete_param_with_ac(input, beginning->str, auth_property_ac, TRUE, previous);
g_string_free(beginning, TRUE);
if (found) {
- g_strfreev(args);
return found;
}
}
@@ -3689,7 +3682,6 @@ _connect_autocomplete(ProfWin* window, const char* const input, gboolean previou
found = autocomplete_param_with_ac(input, beginning->str, auth_property_ac, TRUE, previous);
g_string_free(beginning, TRUE);
if (found) {
- g_strfreev(args);
return found;
}
}
@@ -3700,14 +3692,11 @@ _connect_autocomplete(ProfWin* window, const char* const input, gboolean previou
found = autocomplete_param_with_ac(input, beginning->str, auth_property_ac, TRUE, previous);
g_string_free(beginning, TRUE);
if (found) {
- g_strfreev(args);
return found;
}
}
}
- g_strfreev(args);
-
found = autocomplete_param_with_func(input, "/connect", accounts_find_enabled, previous, NULL);
if (found) {
return found;
@@ -3736,7 +3725,7 @@ _join_autocomplete(ProfWin* window, const char* const input, gboolean previous)
char* found = NULL;
gboolean result = FALSE;
- gchar** args = parse_args(input, 1, 5, &result);
+ auto_gcharv gchar** args = parse_args(input, 1, 5, &result);
if (result) {
gboolean space_at_end = g_str_has_suffix(input, " ");
@@ -3747,7 +3736,6 @@ _join_autocomplete(ProfWin* window, const char* const input, gboolean previous)
found = autocomplete_param_with_ac(input, beginning->str, join_property_ac, TRUE, previous);
g_string_free(beginning, TRUE);
if (found) {
- g_strfreev(args);
return found;
}
}
@@ -3757,14 +3745,11 @@ _join_autocomplete(ProfWin* window, const char* const input, gboolean previous)
found = autocomplete_param_with_ac(input, beginning->str, join_property_ac, TRUE, previous);
g_string_free(beginning, TRUE);
if (found) {
- g_strfreev(args);
return found;
}
}
}
- g_strfreev(args);
-
found = autocomplete_param_with_func(input, "/join", bookmark_find, previous, NULL);
return found;
@@ -3856,7 +3841,7 @@ _account_autocomplete(ProfWin* window, const char* const input, gboolean previou
char* found = NULL;
gboolean result = FALSE;
- gchar** args = parse_args(input, 2, 4, &result);
+ auto_gcharv 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);
@@ -3866,7 +3851,6 @@ _account_autocomplete(ProfWin* window, const char* const input, gboolean previou
found = autocomplete_param_with_ac(input, beginning->str, account_set_ac, TRUE, previous);
g_string_free(beginning, TRUE);
if (found) {
- g_strfreev(args);
return found;
}
}
@@ -3890,7 +3874,6 @@ _account_autocomplete(ProfWin* window, const char* const input, gboolean previou
found = autocomplete_param_with_ac(input, beginning->str, account_status_ac, TRUE, previous);
g_string_free(beginning, TRUE);
if (found) {
- g_strfreev(args);
return found;
}
}
@@ -3901,7 +3884,6 @@ _account_autocomplete(ProfWin* window, const char* const input, gboolean previou
found = autocomplete_param_with_ac(input, beginning->str, tls_property_ac, TRUE, previous);
g_string_free(beginning, TRUE);
if (found) {
- g_strfreev(args);
return found;
}
}
@@ -3912,7 +3894,6 @@ _account_autocomplete(ProfWin* window, const char* const input, gboolean previou
found = autocomplete_param_with_ac(input, beginning->str, auth_property_ac, TRUE, previous);
g_string_free(beginning, TRUE);
if (found) {
- g_strfreev(args);
return found;
}
}
@@ -3923,7 +3904,6 @@ _account_autocomplete(ProfWin* window, const char* const input, gboolean previou
found = autocomplete_param_with_func(input, beginning->str, _script_autocomplete_func, previous, NULL);
g_string_free(beginning, TRUE);
if (found) {
- g_strfreev(args);
return found;
}
}
@@ -3945,7 +3925,6 @@ _account_autocomplete(ProfWin* window, const char* const input, gboolean previou
found = autocomplete_param_with_ac(input, beginning->str, theme_load_ac, TRUE, previous);
g_string_free(beginning, TRUE);
if (found) {
- g_strfreev(args);
return found;
}
}
@@ -3957,7 +3936,6 @@ _account_autocomplete(ProfWin* window, const char* const input, gboolean previou
found = autocomplete_param_with_func(input, beginning->str, p_gpg_autocomplete_key, previous, NULL);
g_string_free(beginning, TRUE);
if (found) {
- g_strfreev(args);
return found;
}
}
@@ -3970,13 +3948,10 @@ _account_autocomplete(ProfWin* window, const char* const input, gboolean previou
found = autocomplete_param_with_ac(input, beginning->str, account_clear_ac, TRUE, previous);
g_string_free(beginning, TRUE);
if (found) {
- g_strfreev(args);
return found;
}
}
- g_strfreev(args);
-
found = autocomplete_param_with_ac(input, "/account default", account_default_ac, TRUE, previous);
if (found) {
return found;
@@ -4033,7 +4008,7 @@ _rooms_autocomplete(ProfWin* window, const char* const input, gboolean previous)
char* found = NULL;
gboolean result = FALSE;
- gchar** args = parse_args(input, 0, 4, &result);
+ auto_gcharv gchar** args = parse_args(input, 0, 4, &result);
if (result) {
gboolean space_at_end = g_str_has_suffix(input, " ");
@@ -4041,21 +4016,18 @@ _rooms_autocomplete(ProfWin* window, const char* const input, gboolean previous)
if (num_args <= 1) {
found = autocomplete_param_with_ac(input, "/rooms", rooms_all_ac, TRUE, previous);
if (found) {
- g_strfreev(args);
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)) {
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)) {
found = autocomplete_param_with_ac(input, "/rooms cache", rooms_cache_ac, TRUE, previous);
if (found) {
- g_strfreev(args);
return found;
}
}
@@ -4065,7 +4037,6 @@ _rooms_autocomplete(ProfWin* window, const char* const input, gboolean previous)
found = autocomplete_param_with_ac(input, beginning->str, rooms_list_ac, TRUE, previous);
g_string_free(beginning, TRUE);
if (found) {
- g_strfreev(args);
return found;
}
}
@@ -4075,18 +4046,14 @@ _rooms_autocomplete(ProfWin* window, const char* const input, gboolean previous)
found = autocomplete_param_with_func(input, beginning->str, muc_confserver_find, previous, NULL);
g_string_free(beginning, TRUE);
if (found) {
- g_strfreev(args);
return found;
}
}
if ((num_args >= 2) && g_strcmp0(args[0], "cache") == 0) {
- g_strfreev(args);
return NULL;
}
}
- g_strfreev(args);
-
return NULL;
}
@@ -4353,7 +4320,7 @@ _url_autocomplete(ProfWin* window, const char* const input, gboolean previous)
}
gboolean arg_result;
- gchar** args = parse_args(input, 1, 8, &arg_result);
+ auto_gcharv gchar** args = parse_args(input, 1, 8, &arg_result);
gboolean space_at_end = g_str_has_suffix(input, " ");
int num_args = g_strv_length(args);
@@ -4366,7 +4333,6 @@ _url_autocomplete(ProfWin* window, const char* const input, gboolean previous)
g_free(cmd);
}
}
- g_strfreev(args);
}
return result;
@@ -4442,6 +4408,24 @@ _mood_autocomplete(ProfWin* window, const char* const input, gboolean previous)
return result;
}
+static char*
+_strophe_autocomplete(ProfWin* window, const char* const input, gboolean previous)
+{
+ char* result = NULL;
+
+ result = autocomplete_param_with_ac(input, "/strophe sm", strophe_sm_ac, FALSE, previous);
+ if (result) {
+ return result;
+ }
+
+ result = autocomplete_param_with_ac(input, "/strophe verbosity", strophe_verbosity_ac, FALSE, previous);
+ if (result) {
+ return result;
+ }
+
+ return autocomplete_param_with_ac(input, "/strophe", strophe_ac, FALSE, previous);
+}
+
static char*
_adhoc_cmd_autocomplete(ProfWin* window, const char* const input, gboolean previous)
{
@@ -4458,7 +4442,7 @@ _vcard_autocomplete(ProfWin* window, const char* const input, gboolean previous)
char* result = NULL;
gboolean parse_result = FALSE;
- gchar** args = parse_args(input, 0, 7, &parse_result);
+ auto_gcharv gchar** args = parse_args(input, 0, 7, &parse_result);
if (parse_result && (g_strcmp0(args[0], "set") == 0)) {
gboolean space_at_end = g_str_has_suffix(input, " ");
@@ -4480,7 +4464,6 @@ _vcard_autocomplete(ProfWin* window, const char* const input, gboolean previous)
result = autocomplete_param_with_ac(input, beginning->str, vcard_set_param_ac, TRUE, previous);
g_string_free(beginning, TRUE);
if (result) {
- g_strfreev(args);
return result;
}
} else if ((num_args == 3 && space_at_end && is_num && (g_strcmp0(args[2], "type") == 0)) || (num_args == 4 && !space_at_end && is_num && (g_strcmp0(args[2], "type") == 0))) {
@@ -4489,7 +4472,6 @@ _vcard_autocomplete(ProfWin* window, const char* const input, gboolean previous)
result = autocomplete_param_with_ac(input, beginning->str, vcard_address_type_ac, TRUE, previous);
g_string_free(beginning, TRUE);
if (result) {
- g_strfreev(args);
return result;
}
} else if ((num_args == 3 && space_at_end && is_num && autocomplete_contains(vcard_togglable_param_ac, args[2])) || (num_args == 4 && !space_at_end && is_num && autocomplete_contains(vcard_togglable_param_ac, args[2]))) {
@@ -4498,7 +4480,6 @@ _vcard_autocomplete(ProfWin* window, const char* const input, gboolean previous)
result = autocomplete_param_with_ac(input, beginning->str, vcard_toggle_ac, TRUE, previous);
g_string_free(beginning, TRUE);
if (result) {
- g_strfreev(args);
return result;
}
} else {
diff --git a/src/command/cmd_ac.h b/src/command/cmd_ac.h
index ef715310..ceab49b2 100644
--- a/src/command/cmd_ac.h
+++ b/src/command/cmd_ac.h
@@ -47,7 +47,7 @@ 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_cmd(const Command* command);
void cmd_ac_add_alias(ProfAlias* alias);
void cmd_ac_add_alias_value(char* value);
diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c
index 0a2a7440..fb37341d 100644
--- a/src/command/cmd_defs.c
+++ b/src/command/cmd_defs.c
@@ -88,31 +88,14 @@
#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 \
- } \
- }
+#define CMD_PREAMBLE(c, p, min, max, set) .cmd = c, .parser = p, .min_args = min, .max_args = max, .setting_func = set,
+#define CMD_MAINFUNC(f) .func = f,
+#define CMD_SUBFUNCS(...) .sub_funcs = { __VA_ARGS__, { NULL, NULL } },
+#define CMD_TAGS(...) .help.tags = { __VA_ARGS__, NULL },
+#define CMD_SYN(...) .help.synopsis = { __VA_ARGS__, NULL },
+#define CMD_DESC(d) .help.desc = d,
+#define CMD_ARGS(...) .help.args = { __VA_ARGS__, { NULL, NULL } },
+#define CMD_EXAMPLES(...) .help.examples = { __VA_ARGS__, NULL }
GHashTable* commands = NULL;
@@ -123,12 +106,10 @@ static gboolean _cmd_has_tag(Command* pcmd, const char* const tag);
*/
// clang-format off
-static struct cmd_t command_defs[] = {
- { "/help",
- parse_args_with_freetext, 0, 2, NULL,
- CMD_NOSUBFUNCS
+static const struct cmd_t command_defs[] = {
+ { CMD_PREAMBLE("/help",
+ parse_args_with_freetext, 0, 2, NULL)
CMD_MAINFUNC(cmd_help)
- CMD_NOTAGS
CMD_SYN(
"/help [||search_all|search_any] []")
CMD_DESC(
@@ -149,36 +130,34 @@ static struct cmd_t command_defs[] = {
"/help who")
},
- { "/about",
- parse_args, 0, 0, NULL,
- CMD_NOSUBFUNCS
+ { CMD_PREAMBLE("/about",
+ parse_args, 0, 0, NULL)
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_PREAMBLE("/connect",
+ parse_args, 0, 7, NULL)
CMD_MAINFUNC(cmd_connect)
CMD_TAGS(
CMD_TAG_CONNECTION)
CMD_SYN(
"/connect []",
- "/connect [server ] [port ] [tls force|allow|trust|legacy|disable] [auth default|legacy]")
+ "/connect [server ] [port ] [tls force|allow|trust|legacy|disable] [auth default|legacy]",
+ "/connect ")
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.")
+ "A local account is created with the JID as it's name if it doesn't already exist. "
+ "In case you want to connect to a server via SASL ANONYMOUS (c.f. XEP-0175) you can also do that.")
CMD_ARGS(
{ "", "The local account you wish to connect with, or a JID if connecting for the first time." },
{ "server ", "Supply a server if it is different to the domain part of your JID." },
{ "port ", "The port to use if different to the default (5222, or 5223 for SSL)." },
+ { "", "Connect to said server in an anonymous way. (Be aware: There aren't many servers that support this.)" },
{ "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." },
@@ -192,54 +171,52 @@ static struct cmd_t command_defs[] = {
"/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")
+ "/connect me@chatty server chatty.com port 5443",
+ "/connect server.supporting.sasl.anonymous.example")
},
- { "/tls",
- parse_args, 1, 3, NULL,
+ { CMD_PREAMBLE("/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 []",
- "/tls trust",
- "/tls trusted",
- "/tls revoke ",
- "/tls certpath",
- "/tls certpath set ",
- "/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 ", "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 ", "Remove a manually trusted certificate." },
- { "certpath", "Show the trusted certificate path." },
- { "certpath set ", "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
+ CMD_TAGS(
+ CMD_TAG_CONNECTION,
+ CMD_TAG_UI)
+ CMD_SYN(
+ "/tls allow",
+ "/tls always",
+ "/tls deny",
+ "/tls cert []",
+ "/tls trust",
+ "/tls trusted",
+ "/tls revoke ",
+ "/tls certpath",
+ "/tls certpath set ",
+ "/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 ", "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 ", "Remove a manually trusted certificate." },
+ { "certpath", "Show the trusted certificate path." },
+ { "certpath set ", "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." })
},
- { "/disconnect",
- parse_args, 0, 0, NULL,
- CMD_NOSUBFUNCS
+ { CMD_PREAMBLE("/disconnect",
+ parse_args, 0, 0, NULL)
CMD_MAINFUNC(cmd_disconnect)
CMD_TAGS(
CMD_TAG_CONNECTION)
@@ -247,13 +224,10 @@ static struct cmd_t command_defs[] = {
"/disconnect")
CMD_DESC(
"Disconnect from the current chat service.")
- CMD_NOARGS
- CMD_NOEXAMPLES
},
- { "/msg",
- parse_args_with_freetext, 1, 2, NULL,
- CMD_NOSUBFUNCS
+ { CMD_PREAMBLE("/msg",
+ parse_args_with_freetext, 1, 2, NULL)
CMD_MAINFUNC(cmd_msg)
CMD_TAGS(
CMD_TAG_CHAT)
@@ -276,8 +250,8 @@ static struct cmd_t command_defs[] = {
"/msg \"My Friend\" Hi, how are you?")
},
- { "/roster",
- parse_args_with_freetext, 0, 4, NULL,
+ { CMD_PREAMBLE("/roster",
+ parse_args_with_freetext, 0, 4, NULL)
CMD_SUBFUNCS(
{ "group", cmd_group })
CMD_MAINFUNC(cmd_roster)
@@ -419,9 +393,8 @@ static struct cmd_t command_defs[] = {
"/roster group remove colleagues boss@work.com")
},
- { "/blocked",
- parse_args_with_freetext, 0, 3, NULL,
- CMD_NOSUBFUNCS
+ { CMD_PREAMBLE("/blocked",
+ parse_args_with_freetext, 0, 3, NULL)
CMD_MAINFUNC(cmd_blocked)
CMD_TAGS(
CMD_TAG_ROSTER,
@@ -447,9 +420,8 @@ static struct cmd_t command_defs[] = {
"/blocked add profanity@rooms.dismail.de/spammy-user")
},
- { "/info",
- parse_args, 0, 1, NULL,
- CMD_NOSUBFUNCS
+ { CMD_PREAMBLE("/info",
+ parse_args, 0, 1, NULL)
CMD_MAINFUNC(cmd_info)
CMD_TAGS(
CMD_TAG_ROSTER,
@@ -470,9 +442,8 @@ static struct cmd_t command_defs[] = {
"/info heimdall")
},
- { "/caps",
- parse_args, 0, 1, NULL,
- CMD_NOSUBFUNCS
+ { CMD_PREAMBLE("/caps",
+ parse_args, 0, 1, NULL)
CMD_MAINFUNC(cmd_caps)
CMD_TAGS(
CMD_TAG_DISCOVERY,
@@ -493,9 +464,8 @@ static struct cmd_t command_defs[] = {
"/caps aegir")
},
- { "/software",
- parse_args, 0, 1, NULL,
- CMD_NOSUBFUNCS
+ { CMD_PREAMBLE("/software",
+ parse_args, 0, 1, NULL)
CMD_MAINFUNC(cmd_software)
CMD_TAGS(
CMD_TAG_DISCOVERY,
@@ -517,12 +487,11 @@ static struct cmd_t command_defs[] = {
"/software thor")
},
- { "/status",
- parse_args, 2, 3, NULL,
+ { CMD_PREAMBLE("/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)
@@ -543,9 +512,8 @@ static struct cmd_t command_defs[] = {
"/status set online")
},
- { "/resource",
- parse_args, 1, 2, &cons_resource_setting,
- CMD_NOSUBFUNCS
+ { CMD_PREAMBLE("/resource",
+ parse_args, 1, 2, &cons_resource_setting)
CMD_MAINFUNC(cmd_resource)
CMD_TAGS(
CMD_TAG_CHAT,
@@ -562,12 +530,10 @@ static struct cmd_t command_defs[] = {
{ "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_PREAMBLE("/join",
+ parse_args, 0, 5, NULL)
CMD_MAINFUNC(cmd_join)
CMD_TAGS(
CMD_TAG_GROUPCHAT)
@@ -594,9 +560,8 @@ static struct cmd_t command_defs[] = {
"/join mychannel")
},
- { "/invite",
- parse_args_with_freetext, 1, 3, NULL,
- CMD_NOSUBFUNCS
+ { CMD_PREAMBLE("/invite",
+ parse_args_with_freetext, 1, 3, NULL)
CMD_MAINFUNC(cmd_invite)
CMD_TAGS(
CMD_TAG_GROUPCHAT)
@@ -619,9 +584,8 @@ static struct cmd_t command_defs[] = {
"/invite list")
},
- { "/room",
- parse_args, 1, 1, NULL,
- CMD_NOSUBFUNCS
+ { CMD_PREAMBLE("/room",
+ parse_args, 1, 1, NULL)
CMD_MAINFUNC(cmd_room)
CMD_TAGS(
CMD_TAG_GROUPCHAT)
@@ -633,12 +597,10 @@ static struct cmd_t command_defs[] = {
{ "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_PREAMBLE("/kick",
+ parse_args_with_freetext, 1, 2, NULL)
CMD_MAINFUNC(cmd_kick)
CMD_TAGS(
CMD_TAG_GROUPCHAT)
@@ -649,11 +611,10 @@ static struct cmd_t command_defs[] = {
CMD_ARGS(
{ "", "Nickname of the occupant to kick from the room." },
{ "", "Optional reason for kicking the occupant." })
- CMD_NOEXAMPLES },
+ },
- { "/ban",
- parse_args_with_freetext, 1, 2, NULL,
- CMD_NOSUBFUNCS
+ { CMD_PREAMBLE("/ban",
+ parse_args_with_freetext, 1, 2, NULL)
CMD_MAINFUNC(cmd_ban)
CMD_TAGS(
CMD_TAG_GROUPCHAT)
@@ -664,12 +625,10 @@ static struct cmd_t command_defs[] = {
CMD_ARGS(
{ "", "Bare JID of the user to ban from the room." },
{ "", "Optional reason for banning the user." })
- CMD_NOEXAMPLES
},
- { "/subject",
- parse_args_with_freetext, 0, 2, NULL,
- CMD_NOSUBFUNCS
+ { CMD_PREAMBLE("/subject",
+ parse_args_with_freetext, 0, 2, NULL)
CMD_MAINFUNC(cmd_subject)
CMD_TAGS(
CMD_TAG_GROUPCHAT)
@@ -689,12 +648,10 @@ static struct cmd_t command_defs[] = {
{ "prepend ", "Prepend text to the current room subject, use double quotes if a trailing space is needed." },
{ "append ", "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_PREAMBLE("/affiliation",
+ parse_args_with_freetext, 1, 4, NULL)
CMD_MAINFUNC(cmd_affiliation)
CMD_TAGS(
CMD_TAG_GROUPCHAT)
@@ -711,12 +668,10 @@ static struct cmd_t command_defs[] = {
{ "list []", "List all users with the specified affiliation, or all if none specified." },
{ "request", "Request voice."},
{ "register", "Register your nickname with the MUC."})
- CMD_NOEXAMPLES
},
- { "/role",
- parse_args_with_freetext, 1, 4, NULL,
- CMD_NOSUBFUNCS
+ { CMD_PREAMBLE("/role",
+ parse_args_with_freetext, 1, 4, NULL)
CMD_MAINFUNC(cmd_role)
CMD_TAGS(
CMD_TAG_GROUPCHAT)
@@ -729,12 +684,10 @@ static struct cmd_t command_defs[] = {
CMD_ARGS(
{ "set []", "Set the role of occupant with nick, with an optional reason." },
{ "list []", "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_PREAMBLE("/occupants",
+ parse_args, 1, 3, cons_occupants_setting)
CMD_MAINFUNC(cmd_occupants)
CMD_TAGS(
CMD_TAG_GROUPCHAT,
@@ -769,12 +722,10 @@ static struct cmd_t command_defs[] = {
{ "header 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_PREAMBLE("/form",
+ parse_args, 1, 2, NULL)
CMD_MAINFUNC(cmd_form)
CMD_TAGS(
CMD_TAG_GROUPCHAT)
@@ -790,12 +741,10 @@ static struct cmd_t command_defs[] = {
{ "submit", "Submit the current form." },
{ "cancel", "Cancel changes to the current form." },
{ "help []", "Display help for form, or a specific field." })
- CMD_NOEXAMPLES
},
- { "/rooms",
- parse_args, 0, 4, NULL,
- CMD_NOSUBFUNCS
+ { CMD_PREAMBLE("/rooms",
+ parse_args, 0, 4, NULL)
CMD_MAINFUNC(cmd_rooms)
CMD_TAGS(
CMD_TAG_GROUPCHAT)
@@ -821,8 +770,8 @@ static struct cmd_t command_defs[] = {
"/rooms service conference.jabber.org filter \"News Room\"")
},
- { "/bookmark",
- parse_args, 0, 8, NULL,
+ { CMD_PREAMBLE("/bookmark",
+ parse_args, 0, 8, NULL)
CMD_SUBFUNCS(
{ "ignore", cmd_bookmark_ignore })
CMD_MAINFUNC(cmd_bookmark)
@@ -866,9 +815,8 @@ static struct cmd_t command_defs[] = {
"/bookmark remove room@example.com")
},
- { "/disco",
- parse_args, 1, 2, NULL,
- CMD_NOSUBFUNCS
+ { CMD_PREAMBLE("/disco",
+ parse_args, 1, 2, NULL)
CMD_MAINFUNC(cmd_disco)
CMD_TAGS(
CMD_TAG_DISCOVERY)
@@ -889,9 +837,8 @@ static struct cmd_t command_defs[] = {
"/disco info odin@valhalla.edda/laptop")
},
- { "/sendfile",
- parse_args_with_freetext, 1, 1, NULL,
- CMD_NOSUBFUNCS
+ { CMD_PREAMBLE("/sendfile",
+ parse_args_with_freetext, 1, 1, NULL)
CMD_MAINFUNC(cmd_sendfile)
CMD_TAGS(
CMD_TAG_CHAT,
@@ -907,9 +854,8 @@ static struct cmd_t command_defs[] = {
"/sendfile ~/images/sweet_cat.jpg")
},
- { "/lastactivity",
- parse_args, 1, 2, NULL,
- CMD_NOSUBFUNCS
+ { CMD_PREAMBLE("/lastactivity",
+ parse_args, 1, 2, NULL)
CMD_MAINFUNC(cmd_lastactivity)
CMD_TAGS(
CMD_TAG_PRESENCE)
@@ -929,9 +875,8 @@ static struct cmd_t command_defs[] = {
"/lastactivity get someserver.com")
},
- { "/nick",
- parse_args_with_freetext, 1, 1, NULL,
- CMD_NOSUBFUNCS
+ { CMD_PREAMBLE("/nick",
+ parse_args_with_freetext, 1, 1, NULL)
CMD_MAINFUNC(cmd_nick)
CMD_TAGS(
CMD_TAG_GROUPCHAT)
@@ -941,12 +886,10 @@ static struct cmd_t command_defs[] = {
"Change your nickname in the current chat room.")
CMD_ARGS(
{ "", "Your new nickname." })
- CMD_NOEXAMPLES
},
- { "/win",
- parse_args, 1, 1, NULL,
- CMD_NOSUBFUNCS
+ { CMD_PREAMBLE("/win",
+ parse_args, 1, 1, NULL)
CMD_MAINFUNC(cmd_win)
CMD_TAGS(
CMD_TAG_UI)
@@ -980,8 +923,8 @@ static struct cmd_t command_defs[] = {
"/win wikipedia")
},
- { "/wins",
- parse_args, 0, 3, NULL,
+ { CMD_PREAMBLE("/wins",
+ parse_args, 0, 3, NULL)
CMD_SUBFUNCS(
{ "unread", cmd_wins_unread },
{ "attention", cmd_wins_attention },
@@ -1004,12 +947,10 @@ static struct cmd_t command_defs[] = {
{ "attention", "List windows that have been marked with the attention flag (alt+v). You can toggle between marked windows with alt+m." },
{ "prune", "Close all windows with no unread messages." },
{ "swap