diff options
author | John Hernandez <129467592+H3rnand3zzz@users.noreply.github.com> | 2023-04-03 17:58:09 +0200 |
---|---|---|
committer | John Hernandez <129467592+H3rnand3zzz@users.noreply.github.com> | 2023-04-09 14:17:01 +0200 |
commit | 5d3c8ce7c164f74f606ff06d1adf849821591a51 (patch) | |
tree | 22163056dd27624216d91de3ab8b4053e5289a7b /src/command | |
parent | 6b597f6608c454e48000847bb3c0b5c2fdc4f292 (diff) | |
download | profani-tty-5d3c8ce7c164f74f606ff06d1adf849821591a51.tar.gz |
Allow setting client identification name/version manually
Add changes allowing user to switch client name and version. Useful for enhancing user privacy. Minor cleanup.
Diffstat (limited to 'src/command')
-rw-r--r-- | src/command/cmd_ac.c | 2 | ||||
-rw-r--r-- | src/command/cmd_defs.c | 5 | ||||
-rw-r--r-- | src/command/cmd_funcs.c | 26 |
3 files changed, 21 insertions, 12 deletions
diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index 8654a07b..13c8f09d 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -478,6 +478,7 @@ cmd_ac_init(void) autocomplete_add(account_set_ac, "otr"); autocomplete_add(account_set_ac, "pgpkeyid"); autocomplete_add(account_set_ac, "startscript"); + autocomplete_add(account_set_ac, "clientid"); autocomplete_add(account_set_ac, "tls"); autocomplete_add(account_set_ac, "auth"); autocomplete_add(account_set_ac, "theme"); @@ -490,6 +491,7 @@ cmd_ac_init(void) autocomplete_add(account_clear_ac, "otr"); autocomplete_add(account_clear_ac, "pgpkeyid"); autocomplete_add(account_clear_ac, "startscript"); + autocomplete_add(account_clear_ac, "clientid"); autocomplete_add(account_clear_ac, "theme"); autocomplete_add(account_clear_ac, "muc"); autocomplete_add(account_clear_ac, "resource"); diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index d204db3b..60c1c971 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -2063,6 +2063,7 @@ static const struct cmd_t command_defs[] = { "/account set <account> otr <policy>", "/account set <account> pgpkeyid <pgpkeyid>", "/account set <account> startscript <script>", + "/account set <account> clientid \"<name> <version>\"", "/account set <account> tls force|allow|trust|legacy|disable", "/account set <account> auth default|legacy", "/account set <account> theme <theme>", @@ -2073,6 +2074,7 @@ static const struct cmd_t command_defs[] = { "/account clear <account> otr", "/account clear <account> pgpkeyid", "/account clear <account> startscript", + "/account clear <account> clientid", "/account clear <account> muc", "/account clear <account> resource") CMD_DESC( @@ -2102,6 +2104,7 @@ static const struct cmd_t command_defs[] = { { "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> clientid \"<name> <version>\"", "[EXPERIMENTAL] Set XMPP client name according for discovery according to XEP-0092. Use with caution." }, { "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." }, @@ -2117,6 +2120,7 @@ static const struct cmd_t command_defs[] = { { "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> clientid", "Reset client's name to default." }, { "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." }) @@ -2129,6 +2133,7 @@ static const struct cmd_t command_defs[] = { "/account set me nick dennis", "/account set me status dnd", "/account set me dnd -1", + "/account set me clientid \"Profanity 0.42 (Dev)\"", "/account rename me chattyme", "/account clear me pgpkeyid") }, diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 919b7ddb..b9ad139c 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -841,6 +841,14 @@ _account_set_startscript(char* account_name, char* script) } gboolean +_account_set_client(char* account_name, char* new_client) +{ + accounts_set_client(account_name, new_client); + cons_show("Client name for account %s has been set to %s", account_name, new_client); + return TRUE; +} + +gboolean _account_set_theme(char* account_name, char* theme) { if (!theme_exists(theme)) { @@ -981,6 +989,8 @@ cmd_account_set(ProfWin* window, const char* const command, gchar** args) return _account_set_pgpkeyid(account_name, value); if (strcmp(property, "startscript") == 0) return _account_set_startscript(account_name, value); + if (strcmp(property, "clientid") == 0) + return _account_set_client(account_name, value); if (strcmp(property, "theme") == 0) return _account_set_theme(account_name, value); if (strcmp(property, "tls") == 0) @@ -1017,48 +1027,40 @@ cmd_account_clear(ProfWin* window, const char* const command, gchar** args) if (strcmp(property, "password") == 0) { accounts_clear_password(account_name); cons_show("Removed password for account %s", account_name); - cons_show(""); } else if (strcmp(property, "eval_password") == 0) { accounts_clear_eval_password(account_name); cons_show("Removed eval password for account %s", account_name); - cons_show(""); } else if (strcmp(property, "server") == 0) { accounts_clear_server(account_name); cons_show("Removed server for account %s", account_name); - cons_show(""); } else if (strcmp(property, "port") == 0) { accounts_clear_port(account_name); cons_show("Removed port for account %s", account_name); - cons_show(""); } else if (strcmp(property, "otr") == 0) { accounts_clear_otr(account_name); cons_show("OTR policy removed for account %s", account_name); - cons_show(""); } else if (strcmp(property, "pgpkeyid") == 0) { accounts_clear_pgp_keyid(account_name); cons_show("Removed PGP key ID for account %s", account_name); - cons_show(""); } else if (strcmp(property, "startscript") == 0) { accounts_clear_script_start(account_name); cons_show("Removed start script for account %s", account_name); - cons_show(""); + } else if (strcmp(property, "clientid") == 0) { + accounts_clear_client(account_name); + cons_show("Reset client name for account %s", account_name); } else if (strcmp(property, "theme") == 0) { accounts_clear_theme(account_name); cons_show("Removed theme for account %s", account_name); - cons_show(""); } else if (strcmp(property, "muc") == 0) { accounts_clear_muc(account_name); cons_show("Removed MUC service for account %s", account_name); - cons_show(""); } else if (strcmp(property, "resource") == 0) { accounts_clear_resource(account_name); cons_show("Removed resource for account %s", account_name); - cons_show(""); } else { cons_show("Invalid property: %s", property); - cons_show(""); } - + cons_show(""); return TRUE; } |