diff options
author | Michael Vetter <jubalh@iodoru.org> | 2021-10-13 21:19:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-13 21:19:22 +0200 |
commit | e0e45b7b24aad0932c2778ba5f93a87778cb9c24 (patch) | |
tree | db71f24a3498f76b8fd2fab37e2d07636cdffd23 | |
parent | f21595597f4fa872b77d7f76ae04916f4aae732e (diff) | |
parent | 0653200965122c46be4f31996d2396b568ee8dcf (diff) | |
download | profani-tty-e0e45b7b24aad0932c2778ba5f93a87778cb9c24.tar.gz |
Merge pull request #1574 from binex-dsk/master
Add in-band account registration Fix https://github.com/profanity-im/profanity/issues/199
-rw-r--r-- | src/command/cmd_defs.c | 27 | ||||
-rw-r--r-- | src/command/cmd_funcs.c | 66 | ||||
-rw-r--r-- | src/command/cmd_funcs.h | 2 | ||||
-rw-r--r-- | src/event/client_events.c | 1 | ||||
-rw-r--r-- | src/event/client_events.h | 1 | ||||
-rw-r--r-- | src/profanity.c | 1 | ||||
-rw-r--r-- | src/xmpp/connection.c | 357 | ||||
-rw-r--r-- | src/xmpp/connection.h | 3 | ||||
-rw-r--r-- | src/xmpp/iq.c | 1 | ||||
-rw-r--r-- | src/xmpp/session.c | 3 | ||||
-rw-r--r-- | src/xmpp/stanza.c | 38 | ||||
-rw-r--r-- | src/xmpp/stanza.h | 2 | ||||
-rw-r--r-- | src/xmpp/xmpp.h | 6 |
13 files changed, 506 insertions, 2 deletions
diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index 1b8c3112..9ac9c1dd 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -2636,6 +2636,32 @@ static struct cmd_t command_defs[] = { CMD_NOEXAMPLES }, + { "/register", + parse_args, 2, 6, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_register) + CMD_TAGS( + CMD_TAG_CONNECTION) + CMD_SYN( + "/register <username> <server> [port <port>] [tls force|allow|trust|legacy|disable]") + CMD_DESC( + "Register an account on a server.") + CMD_ARGS( + { "<username>", "Username to register with." }, + { "<server>", "Server to register account on." }, + { "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 the default behavior." }, + { "tls allow", "Use TLS for the connection if it is available." }, + { "tls trust", "Force TLS connection and trust the server's certificate." }, + { "tls legacy", "Use legacy TLS for the connection. This forces TLS just after the TCP connection is established. Use when a server doesn't support STARTTLS." }, + { "tls disable", "Disable TLS for the connection." }) + CMD_EXAMPLES( + "/register odin valhalla.edda ", + "/register freyr vanaheimr.edda port 5678", + "/register me 127.0.0.1 tls disable", + "/register someuser my.xmppserv.er port 5443 tls force") + }, + // NEXT-COMMAND (search helper) }; @@ -3006,3 +3032,4 @@ command_mangen(void) g_free(header); g_list_free(cmds); } + diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 67c59802..3a89425d 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -9534,3 +9534,69 @@ cmd_silence(ProfWin* window, const char* const command, gchar** args) return TRUE; } + +gboolean +cmd_register(ProfWin* window, const char* const command, gchar** args) +{ + gchar* opt_keys[] = { "port", "tls", "auth", NULL }; + gboolean parsed; + + GHashTable* options = parse_options(&args[2], opt_keys, &parsed); + if (!parsed) { + cons_bad_cmd_usage(command); + cons_show(""); + options_destroy(options); + return TRUE; + } + + 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; + } + + int port = 0; + if (g_hash_table_contains(options, "port")) { + 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); + cons_show(""); + free(err_msg); + port = 0; + options_destroy(options); + return TRUE; + } + } + + char* username = args[0]; + char* server = args[1]; + + char* passwd = ui_ask_password(false); + char* confirm_passwd = ui_ask_password(true); + + if (g_strcmp0(passwd, confirm_passwd) == 0) { + log_info("Attempting to register account %s on server %s.", username, server); + connection_register(server, port, tls_policy, username, passwd); + } else { + cons_show("The two passwords do not match."); + } + + if (connection_get_status() == JABBER_DISCONNECTED) { + cons_show_error("Connection attempt to server %s port %d failed.", server, port); + log_info("Connection attempt to server %s port %d failed.", server, port); + return TRUE; + } + + free(passwd); + free(confirm_passwd); + + options_destroy(options); + + log_info("we are leaving the registration process"); + return TRUE; +} + diff --git a/src/command/cmd_funcs.h b/src/command/cmd_funcs.h index 54cc6e78..dee71371 100644 --- a/src/command/cmd_funcs.h +++ b/src/command/cmd_funcs.h @@ -247,5 +247,7 @@ gboolean cmd_executable_editor(ProfWin* window, const char* const command, gchar gboolean cmd_mam(ProfWin* window, const char* const command, gchar** args); gboolean cmd_editor(ProfWin* window, const char* const command, gchar** args); gboolean cmd_silence(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_register(ProfWin* window, const char* const command, gchar** args); #endif + diff --git a/src/event/client_events.c b/src/event/client_events.c index bf519feb..a25ce106 100644 --- a/src/event/client_events.c +++ b/src/event/client_events.c @@ -262,3 +262,4 @@ cl_ev_send_priv_msg(ProfPrivateWin* privwin, const char* const msg, const char* jid_destroy(jidp); } } + diff --git a/src/event/client_events.h b/src/event/client_events.h index fed2bb37..de180d21 100644 --- a/src/event/client_events.h +++ b/src/event/client_events.h @@ -52,3 +52,4 @@ void cl_ev_send_muc_msg(ProfMucWin* mucwin, const char* const msg, const char* c void cl_ev_send_priv_msg(ProfPrivateWin* privwin, const char* const msg, const char* const oob_url); #endif + diff --git a/src/profanity.c b/src/profanity.c index eb829bad..a74f26d2 100644 --- a/src/profanity.c +++ b/src/profanity.c @@ -268,3 +268,4 @@ _shutdown(void) ui_close(); prefs_close(); } + diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c index 30ef0a9e..4fecad3b 100644 --- a/src/xmpp/connection.c +++ b/src/xmpp/connection.c @@ -58,6 +58,7 @@ #include "event/server_events.h" #include "xmpp/connection.h" #include "xmpp/session.h" +#include "xmpp/stanza.h" #include "xmpp/iq.h" #include "ui/ui.h" @@ -77,6 +78,11 @@ typedef struct prof_conn_t GHashTable* requested_features; } ProfConnection; +typedef struct { + const char* username; + const char* password; +} prof_reg_t; + static ProfConnection conn; static gchar* profanity_instance_id = NULL; static gchar* prof_identifier = NULL; @@ -245,6 +251,338 @@ connection_connect(const char* const jid, const char* const passwd, const char* return conn.conn_status; } +static int iq_reg2_cb(xmpp_conn_t *xmpp_conn, xmpp_stanza_t *stanza, void *userdata) +{ + const char *type; + + (void)userdata; + + type = xmpp_stanza_get_type(stanza); + if (!type || strcmp(type, "error") == 0) { + char* error_message = stanza_get_error_message(stanza); + cons_show_error("Server error: %s", error_message); + log_debug("Registration error: %s", error_message); + goto quit; + } + + if (strcmp(type, "result") != 0) { + log_debug("Expected type 'result', but got %s.", type); + goto quit; + } + + cons_show("Registration successful."); + log_info("Registration successful."); + goto quit; + +quit: + xmpp_disconnect(xmpp_conn); + + return 0; +} + +static int iq_reg_cb(xmpp_conn_t *xmpp_conn, xmpp_stanza_t *stanza, void *userdata) +{ + prof_reg_t *reg = (prof_reg_t *)userdata; + xmpp_stanza_t *registered = NULL; + xmpp_stanza_t *query; + const char *type; + + type = xmpp_stanza_get_type(stanza); + if (!type || strcmp(type, "error") == 0) { + char* error_message = stanza_get_error_message(stanza); + cons_show_error("Server error: %s", error_message); + log_debug("Registration error: %s", error_message); + xmpp_disconnect(xmpp_conn); + goto quit; + } + + if (strcmp(type, "result") != 0) { + log_debug("Expected type 'result', but got %s.", type); + xmpp_disconnect(xmpp_conn); + goto quit; + } + + query = xmpp_stanza_get_child_by_name(stanza, "query"); + if (query) + registered = xmpp_stanza_get_child_by_name(query, "registered"); + if (registered != NULL) { + cons_show_error("Already registered."); + log_debug("Already registered."); + xmpp_disconnect(xmpp_conn); + goto quit; + } + xmpp_stanza_t* iq = stanza_register_new_account(conn.xmpp_ctx, reg->username, reg->password); + xmpp_id_handler_add(xmpp_conn, iq_reg2_cb, xmpp_stanza_get_id(iq), reg); + xmpp_send(xmpp_conn, iq); + +quit: + return 0; +} + +static int +_register_handle_error(xmpp_conn_t *xmpp_conn, xmpp_stanza_t *stanza, void *userdata) +{ + (void)stanza; + (void)userdata; + + char* error_message = stanza_get_error_message(stanza); + cons_show_error("Server error: %s", error_message); + log_debug("Registration error: %s", error_message); + xmpp_disconnect(xmpp_conn); + + return 0; +} + +static int _register_handle_proceedtls_default(xmpp_conn_t *xmpp_conn, + xmpp_stanza_t *stanza, + void *userdata) +{ + const char *name = xmpp_stanza_get_name(stanza); + + (void)userdata; + + if (strcmp(name, "proceed") == 0) { + log_debug("Proceeding with TLS."); + if (xmpp_conn_tls_start(xmpp_conn) == 0) { + xmpp_handler_delete(xmpp_conn, _register_handle_error); + xmpp_conn_open_stream_default(xmpp_conn); + } else { + log_debug("TLS failed."); + /* failed tls spoils the connection, so disconnect */ + xmpp_disconnect(xmpp_conn); + } + } + return 0; +} + +static int _register_handle_missing_features(xmpp_conn_t *xmpp_conn, void *userdata) +{ + (void)userdata; + + log_debug("Timeout"); + xmpp_disconnect(xmpp_conn); + + return 0; +} + +static int +_register_handle_features(xmpp_conn_t *xmpp_conn, xmpp_stanza_t *stanza, void *userdata) +{ + prof_reg_t *reg = (prof_reg_t *)userdata; + xmpp_ctx_t *ctx = conn.xmpp_ctx; + xmpp_stanza_t *child; + xmpp_stanza_t *iq; + char *domain; + + xmpp_timed_handler_delete(xmpp_conn, _register_handle_missing_features); + + /* secure connection if possible */ + child = xmpp_stanza_get_child_by_name(stanza, "starttls"); + if (child && (strcmp(xmpp_stanza_get_ns(child), XMPP_NS_TLS) == 0)) { + log_debug("Server supports TLS. Attempting to establish..."); + child = xmpp_stanza_new(ctx); + xmpp_stanza_set_name(child, "starttls"); + xmpp_stanza_set_ns(child, XMPP_NS_TLS); + xmpp_handler_add(xmpp_conn, _register_handle_proceedtls_default, XMPP_NS_TLS, NULL, + NULL, NULL); + xmpp_send(xmpp_conn, child); + xmpp_stanza_release(child); + return 0; + } + + /* check whether server supports in-band registration */ + child = xmpp_stanza_get_child_by_name(stanza, "register"); + if (!child) { + log_debug("Server does not support in-band registration."); + cons_show_error("Server does not support in-band registration, aborting."); + xmpp_disconnect(xmpp_conn); + return 0; + } + + log_debug("Server supports in-band registration. Attempting registration."); + + domain = strdup(conn.domain); + iq = xmpp_iq_new(ctx, "get", "reg1"); + xmpp_stanza_set_to(iq, domain); + child = xmpp_stanza_new(ctx); + xmpp_stanza_set_name(child, "query"); + xmpp_stanza_set_ns(child, STANZA_NS_REGISTER); + xmpp_stanza_add_child(iq, child); + + xmpp_handler_add(xmpp_conn, iq_reg_cb, STANZA_NS_REGISTER, "iq", NULL, reg); + xmpp_send(xmpp_conn, iq); + + xmpp_free(ctx, domain); + xmpp_stanza_release(child); + xmpp_stanza_release(iq); + + return 0; +} + +static void +_register_handler(xmpp_conn_t *xmpp_conn, + xmpp_conn_event_t status, + int error, + xmpp_stream_error_t *stream_error, + void *userdata) +{ + conn.conn_last_event = status; + + prof_reg_t *reg = (prof_reg_t *)userdata; + int secured; + + (void)error; + (void)stream_error; + + switch (status) { + + case XMPP_CONN_RAW_CONNECT: + log_debug("Raw connection established."); + xmpp_conn_open_stream_default(xmpp_conn); + conn.conn_status = JABBER_RAW_CONNECTED; + break; + + case XMPP_CONN_CONNECT: + log_debug("Connected."); + secured = xmpp_conn_is_secured(xmpp_conn); + conn.conn_status = JABBER_CONNECTED; + log_debug("Connection is %s.\n", + secured ? "secured" : "NOT secured"); + + Jid* my_jid = jid_create(xmpp_conn_get_jid(xmpp_conn)); + conn.domain = strdup(my_jid->domainpart); + jid_destroy(my_jid); + + xmpp_handler_add(xmpp_conn, _register_handle_error, XMPP_NS_STREAMS, "error", NULL, + NULL); + xmpp_handler_add(xmpp_conn, _register_handle_features, XMPP_NS_STREAMS, "features", + NULL, reg); + xmpp_timed_handler_add(xmpp_conn, _register_handle_missing_features, 5000, + NULL); + break; + + case XMPP_CONN_DISCONNECT: + log_debug("Disconnected"); + conn.conn_status = JABBER_DISCONNECTED; + break; + + default: + break; + + } +} + +jabber_conn_status_t +connection_register(const char* const altdomain, int port, const char* const tls_policy, + const char* const username, const char* const password) +{ + long flags; + + Jid* jidp = jid_create(altdomain); + if (jidp == NULL) { + log_error("Malformed JID not able to connect: %s", altdomain); + conn.conn_status = JABBER_DISCONNECTED; + return conn.conn_status; + } + + _compute_identifier(jidp->barejid); + jid_destroy(jidp); + + if (conn.xmpp_log) { + free(conn.xmpp_log); + } + conn.xmpp_log = _xmpp_get_file_logger(); + + if (conn.xmpp_conn) { + xmpp_conn_release(conn.xmpp_conn); + } + if (conn.xmpp_ctx) { + xmpp_ctx_free(conn.xmpp_ctx); + } + conn.xmpp_ctx = xmpp_ctx_new(NULL, conn.xmpp_log); + if (conn.xmpp_ctx == NULL) { + log_warning("Failed to get libstrophe ctx during connect"); + return JABBER_DISCONNECTED; + } + conn.xmpp_conn = xmpp_conn_new(conn.xmpp_ctx); + if (conn.xmpp_conn == NULL) { + log_warning("Failed to get libstrophe conn during connect"); + return JABBER_DISCONNECTED; + } + xmpp_conn_set_jid(conn.xmpp_conn, altdomain); + + flags = xmpp_conn_get_flags(conn.xmpp_conn); + + if (!tls_policy || (g_strcmp0(tls_policy, "force") == 0)) { + flags |= XMPP_CONN_FLAG_MANDATORY_TLS; + } else if (g_strcmp0(tls_policy, "trust") == 0) { + flags |= XMPP_CONN_FLAG_MANDATORY_TLS; + flags |= XMPP_CONN_FLAG_TRUST_TLS; + } else if (g_strcmp0(tls_policy, "disable") == 0) { + flags |= XMPP_CONN_FLAG_DISABLE_TLS; + } else if (g_strcmp0(tls_policy, "legacy") == 0) { + flags |= XMPP_CONN_FLAG_LEGACY_SSL; + } + + xmpp_conn_set_flags(conn.xmpp_conn, flags); + + /* 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); \ + } + 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); + LOG_FLAG_IF_SET(XMPP_CONN_FLAG_LEGACY_SSL); +#undef LOG_FLAG_IF_SET + } + + prof_reg_t *reg; + + reg = calloc(1, sizeof(*reg)); + if (reg == NULL) { + log_warning("Failed to allocate registration data struct during connect"); + return JABBER_DISCONNECTED; + } + + reg->username = strdup(username); + reg->password = strdup(password); + +#ifdef HAVE_LIBMESODE + char* cert_path = prefs_get_tls_certpath(); + if (cert_path) { + xmpp_conn_tlscert_path(conn.xmpp_conn, cert_path); + free(cert_path); + } + + int connect_status = xmpp_connect_raw( + conn.xmpp_conn, + altdomain, + port, + _connection_certfail_cb, + _register_handler, + reg); +#else + int connect_status = xmpp_connect_raw( + conn.xmpp_conn, + altdomain, + port, + _register_handler, + reg); +#endif + + if (connect_status == 0) { + conn.conn_status = JABBER_RAW_CONNECTING; + } else { + conn.conn_status = JABBER_DISCONNECTED; + } + + return conn.conn_status; +} + void connection_disconnect(void) { @@ -515,7 +853,6 @@ char* connection_create_stanza_id(void) { char* rndid = get_random_string(CON_RAND_ID_LEN); - assert(rndid != NULL); gchar* hmac = g_compute_hmac_for_string(G_CHECKSUM_SHA1, @@ -581,6 +918,23 @@ _connection_handler(xmpp_conn_t* const xmpp_conn, const xmpp_conn_event_t status break; + // raw connection success + case XMPP_CONN_RAW_CONNECT: + log_debug("Connection handler: XMPP_CONN_RAW_CONNECT"); + conn.conn_status = JABBER_RAW_CONNECTED; + + Jid* my_raw_jid = jid_create(xmpp_conn_get_jid(conn.xmpp_conn)); + log_debug("jid: %s", xmpp_conn_get_jid(conn.xmpp_conn)); + conn.domain = strdup(my_raw_jid->domainpart); + jid_destroy(my_raw_jid); + + conn.features_by_jid = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)g_hash_table_destroy); + g_hash_table_insert(conn.features_by_jid, strdup(conn.domain), g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL)); + + xmpp_conn_open_stream_default(xmpp_conn); + + break; + // disconnected case XMPP_CONN_DISCONNECT: log_debug("Connection handler: XMPP_CONN_DISCONNECT"); @@ -755,3 +1109,4 @@ connection_get_profanity_identifier(void) { return prof_identifier; } + diff --git a/src/xmpp/connection.h b/src/xmpp/connection.h index cab579f7..0f0c2c10 100644 --- a/src/xmpp/connection.h +++ b/src/xmpp/connection.h @@ -46,6 +46,8 @@ 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_register(const char* const altdomain, int port, const char* const tls_policy, + const char* const username, const char* const password); void connection_disconnect(void); void connection_set_disconnected(void); @@ -68,3 +70,4 @@ void connection_remove_available_resource(const char* const resource); char* connection_create_stanza_id(void); #endif + diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index dd3c2423..8f7c8290 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -2804,3 +2804,4 @@ iq_muc_register_nick(const char* const roomjid) xmpp_stanza_release(iq); xmpp_stanza_release(query); } + diff --git a/src/xmpp/session.c b/src/xmpp/session.c index e81d55ae..de255116 100644 --- a/src/xmpp/session.c +++ b/src/xmpp/session.c @@ -261,6 +261,8 @@ session_process_events(void) switch (conn_status) { case JABBER_CONNECTED: case JABBER_CONNECTING: + case JABBER_RAW_CONNECTED: + case JABBER_RAW_CONNECTING: case JABBER_DISCONNECTING: connection_check_events(); break; @@ -543,3 +545,4 @@ _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 81a41bed..bb9083f0 100644 --- a/src/xmpp/stanza.c +++ b/src/xmpp/stanza.c @@ -2750,6 +2750,43 @@ stanza_change_password(xmpp_ctx_t* ctx, const char* const user, const char* cons } xmpp_stanza_t* +stanza_register_new_account(xmpp_ctx_t* ctx, const char* const user, const char* const password) +{ + char* id = connection_create_stanza_id(); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); + free(id); + + xmpp_stanza_t* register_new_account = xmpp_stanza_new(ctx); + xmpp_stanza_set_name(register_new_account, STANZA_NAME_QUERY); + xmpp_stanza_set_ns(register_new_account, STANZA_NS_REGISTER); + + xmpp_stanza_t* username_st = xmpp_stanza_new(ctx); + xmpp_stanza_set_name(username_st, STANZA_NAME_USERNAME); + xmpp_stanza_t* username_text = xmpp_stanza_new(ctx); + xmpp_stanza_set_text(username_text, user); + xmpp_stanza_add_child(username_st, username_text); + xmpp_stanza_release(username_text); + + 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_set_text(password_text, password); + xmpp_stanza_add_child(password_st, password_text); + xmpp_stanza_release(password_text); + + xmpp_stanza_add_child(register_new_account, username_st); + xmpp_stanza_release(username_st); + + xmpp_stanza_add_child(register_new_account, password_st); + xmpp_stanza_release(password_st); + + xmpp_stanza_add_child(iq, register_new_account); + xmpp_stanza_release(register_new_account); + + return iq; +} + +xmpp_stanza_t* stanza_request_voice(xmpp_ctx_t* ctx, const char* const room) { char* id = connection_create_stanza_id(); @@ -2887,3 +2924,4 @@ stanza_get_service_contact_addresses(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza) return addresses; } + diff --git a/src/xmpp/stanza.h b/src/xmpp/stanza.h index c58395bb..f19b4f4c 100644 --- a/src/xmpp/stanza.h +++ b/src/xmpp/stanza.h @@ -409,8 +409,10 @@ void stanza_free_caps(XMPPCaps* caps); 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, const char* const lastid); xmpp_stanza_t* stanza_change_password(xmpp_ctx_t* ctx, const char* const user, const char* const password); +xmpp_stanza_t* stanza_register_new_account(xmpp_ctx_t* ctx, const char* const user, const char* const password); xmpp_stanza_t* stanza_request_voice(xmpp_ctx_t* ctx, const char* const room); xmpp_stanza_t* stanza_create_approve_voice(xmpp_ctx_t* ctx, const char* const id, const char* const jid, const char* const node, DataForm* form); xmpp_stanza_t* stanza_create_muc_register_nick(xmpp_ctx_t* ctx, const char* const id, const char* const jid, const char* const node, DataForm* form); #endif + diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h index 4c49eb8b..f4a7a6e5 100644 --- a/src/xmpp/xmpp.h +++ b/src/xmpp/xmpp.h @@ -76,7 +76,9 @@ typedef enum { JABBER_CONNECTING, JABBER_CONNECTED, JABBER_DISCONNECTING, - JABBER_DISCONNECTED + JABBER_DISCONNECTED, + JABBER_RAW_CONNECTING, + JABBER_RAW_CONNECTED } jabber_conn_status_t; typedef enum { @@ -183,6 +185,7 @@ 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); + void session_disconnect(void); void session_shutdown(void); void session_process_events(void); @@ -313,3 +316,4 @@ Autocomplete form_get_value_ac(DataForm* form, const char* const tag); void form_reset_autocompleters(DataForm* form); #endif + |