about summary refs log tree commit diff stats
path: root/src/command/cmd_funcs.c
diff options
context:
space:
mode:
authorswirl <roachh@protonmail.com>2021-07-04 19:02:38 -0400
committerswirl <roachh@protonmail.com>2021-08-17 14:09:48 -0400
commit2cc354b6aef2f54b3f4dacc81f257c0625d5c734 (patch)
treeff7ff510e0ec21db07d80c5a0633370eb9564b7c /src/command/cmd_funcs.c
parent5ea1ccbb468bd6c1195cb85fe29ac664e74436e7 (diff)
downloadprofani-tty-2cc354b6aef2f54b3f4dacc81f257c0625d5c734.tar.gz
fixed some bugs, added some more
- Added JABBER_RAW_CONNECT[ING/ED] connection states
- Added cl_ev_connect_raw and session_connect_raw to conform to normal
connection functions
- Fixed SIGABRT during registration
- Added a check in cmd_register to ensure it's actually connected before
registering--but this will always fail atm
Diffstat (limited to 'src/command/cmd_funcs.c')
-rw-r--r--src/command/cmd_funcs.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index 68eec91b..07acd266 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -9589,7 +9589,7 @@ cmd_register(ProfWin* window, const char* const command, gchar** args)
 
     char* server = args[1];
 
-    jabber_conn_status_t conn_status = connection_connect_raw(server, port, tls_policy, auth_policy);
+    jabber_conn_status_t conn_status = cl_ev_connect_raw(server, port, tls_policy, auth_policy);
 
     if (conn_status == JABBER_DISCONNECTED) {
         cons_show_error("Connection attempt to server %s port %d failed.", server, port);
@@ -9598,19 +9598,26 @@ cmd_register(ProfWin* window, const char* const command, gchar** args)
     }
 
     char* username = args[0];
-    char* passwd = ui_ask_password(false);
-    char* confirm_passwd = ui_ask_password(true);
+    if (connection_get_status() != JABBER_RAW_CONNECTED) { // FIXME: this is ALWAYS the case, as the connection doesn't finish by this time.
+        cons_show_error("Raw connection attempt failed or not yet completed.");
+        log_info("Raw connection attempt failed or not yet completed.");
+    } //else {
+        char* passwd = ui_ask_password(false);
+        char* confirm_passwd = ui_ask_password(true);
 
-    if (g_strcmp0(passwd, confirm_passwd) == 0) {
-        iq_register_new_account(username, passwd);
-    } else {
-        cons_show("The two passwords do not match.");
-    }
+        if (g_strcmp0(passwd, confirm_passwd) == 0) {
+            log_info("Attempting to register account %s on server %s.", username, server);
+            iq_register_new_account(username, passwd);
+        } else {
+            cons_show("The two passwords do not match.");
+        }
+        free(passwd);
+        free(confirm_passwd);
+    //}
 
-    free(username);
-    free(passwd);
-    free(confirm_passwd);
+    options_destroy(options);
 
+    log_info("we are leaving the registration process");
     return TRUE;
 }