about summary refs log tree commit diff stats
path: root/src/command/cmd_funcs.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/command/cmd_funcs.c')
-rw-r--r--src/command/cmd_funcs.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index 7329046a..1c13d12f 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -338,7 +338,7 @@ cmd_connect(ProfWin *window, const char *const command, gchar **args)
         return TRUE;
     }
 
-    gchar *opt_keys[] = { "server", "port", "tls", NULL };
+    gchar *opt_keys[] = { "server", "port", "tls", "auth", NULL };
     gboolean parsed;
 
     GHashTable *options = parse_options(&args[args[0] ? 1 : 0], opt_keys, &parsed);
@@ -364,6 +364,16 @@ cmd_connect(ProfWin *window, const char *const command, gchar **args)
         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)) {
+        cons_bad_cmd_usage(command);
+        cons_show("");
+        options_destroy(options);
+        return TRUE;
+    }
+
     int port = 0;
     if (g_hash_table_contains(options, "port")) {
         char *port_str = g_hash_table_lookup(options, "port");
@@ -406,6 +416,8 @@ cmd_connect(ProfWin *window, const char *const command, gchar **args)
             account_set_port(account, port);
         if (tls_policy != NULL)
             account_set_tls_policy(account, tls_policy);
+        if (auth_policy != NULL)
+            account_set_auth_policy(account, auth_policy);
 
         // use password if set
         if (account->password) {
@@ -441,7 +453,7 @@ cmd_connect(ProfWin *window, const char *const command, gchar **args)
     } else {
         jid = g_utf8_strdown(user, -1);
         char *passwd = ui_ask_password();
-        conn_status = cl_ev_connect_jid(jid, passwd, altdomain, port, tls_policy);
+        conn_status = cl_ev_connect_jid(jid, passwd, altdomain, port, tls_policy, auth_policy);
         free(passwd);
     }
 
@@ -497,7 +509,7 @@ cmd_account_add(ProfWin *window, const char *const command, gchar **args)
         return TRUE;
     }
 
-    accounts_add(account_name, NULL, 0, NULL);
+    accounts_add(account_name, NULL, 0, NULL, NULL);
     cons_show("Account created.");
     cons_show("");
 
@@ -844,6 +856,20 @@ _account_set_tls(char *account_name, char *policy)
 }
 
 gboolean
+_account_set_auth(char *account_name, char *policy)
+{
+    if ((g_strcmp0(policy, "default") != 0)
+            && (g_strcmp0(policy, "legacy") != 0)) {
+        cons_show("Auth policy must be either default or legacy.");
+    } else {
+        accounts_set_auth_policy(account_name, policy);
+        cons_show("Updated auth policy for account %s: %s", account_name, policy);
+        cons_show("");
+    }
+    return TRUE;
+}
+
+gboolean
 _account_set_presence_priority(char *account_name, char *presence, char *priority)
 {
     int intval;
@@ -919,6 +945,7 @@ cmd_account_set(ProfWin *window, const char *const command, gchar **args)
     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);